diff --git a/CHECKSUMS.txt b/CHECKSUMS.txt index aa4a6586290a91809ff0deaa3a98cc5fb6f9ad58..4055409a7b1d7dce93b9621be91dff5a3356700c 100644 --- a/CHECKSUMS.txt +++ b/CHECKSUMS.txt @@ -1,34 +1,34 @@ -Cover Charge v0.3.12.171: web apps, plus the Cover Charge for Display tablet app for Android (downloads/android/, its SHA-256 is in downloads/android/SHA256.txt). No phone APKs were built for v0.1.2 to v0.3.12.171. +Cover Charge v0.3.12.172: web apps, plus the Cover Charge for Display tablet app for Android (downloads/android/, its SHA-256 is in downloads/android/SHA256.txt). No phone APKs were built for v0.1.2 to v0.3.12.172. SHA-256 of each web app's start page, service worker, manifest and logo: -1c0369d52e88f48c37cc5a5b2ed8e4f4ba906462498a9a642539b094470e5d3b owner-app/index.html -4a0d26ebafbe39190d824e292d565dffc35b44af08cf883b069b1b947f1631fe owner-app/sw.js +ada806a5b472f580c6f2c643b8374586d4b76107752a6c95a883090147c22e07 owner-app/index.html +c313325eba7c4636f7526a99737c41d397584aff81fefb1efb7a352c06534351 owner-app/sw.js e305c44d11a9c25f37372f3fa4d329d4ffb04df2edee6e7b4b9ac91f3875ac67 owner-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 owner-app/brand-logo.png -1e04ee1124c9fb344dffe582c78776eff640eeee638b8baa61c6eff3d0b84a14 staff-app/index.html -bd08788c9f43e3f69ef8f843fa46dbcba5f7fd247a529f9e9669288e0b32fbb0 staff-app/sw.js +ca8df9fbfd320a8f8c462a8429edefdf4ad1e92dd63398cfc78b2b3edbdf518f staff-app/index.html +72c654fb06061d77b1215e76e3dc3b30fb7ed5ca1694d39d0a4d2032b58599c9 staff-app/sw.js bd1d310ebf8e2a80808e100c41fb7fe1c4369d3026478f3ad8eececaeadaf4ac staff-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 staff-app/brand-logo.png -6a698fd21fbaca8fcd274ac9b46f6ec3ed5a7d9b849069b0c29991098bdd5005 customer-app/index.html -5db6ff2e50dcf77e412e11decb79679c6bc7a70dc0d6284c95c14cd3af7fa7d7 customer-app/sw.js +74417e9f91416f334b3db721db70ec715c640d4d53662293661b4cdd22682170 customer-app/index.html +ceefb3202b2f8c2151e9c724e28aa4ece5bc219321c4e67375ee223a04258cd7 customer-app/sw.js 3bfb1fd10cc13f09ca6be65c461e1f6b5750ae51a3ece12e079750b2a066052e customer-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 customer-app/brand-logo.png -654619b57827527e1e30e1f42cd9f93ebdd512f35000f95bcb5eef59b46f8b99 display-app/index.html -1474447f09dba59ca2d5cac62115cdd446588b73ceeae57ca4434884d0d986ab display-app/sw.js +2a54b8858ea608c1b6272abb1215c15fe9f775e404f3193ac6734fe6552599f5 display-app/index.html +e20283a2e88a8bff79466e1da8f18b2c5de29841f89862fe124b0099bc8fe88a display-app/sw.js 35e2721b86eb1ae1605e55bee64177adcee72f4e53a24ac417d19ea2873434a1 display-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 display-app/brand-logo.png -860febc957254547686d758b8fc20357b2273048a59798567382f0dcc7cc7e9b chef-app/index.html -ff81ea27b9a21a828e2f6fb2c3dcdc3ec8316a60a84a29d51bd765373adc639c chef-app/sw.js +3c57e3fc15b843c3792504ca0bd318feb507be1a849845d1adeff95334782ad6 chef-app/index.html +4aa085b8fe657858034b444f626ad340409c12f074a02647740d40a619abaf5d chef-app/sw.js 97ed43decde8a888e22b7411e13a2122c6f8b9944cf38b2e28e8f62ef2e25397 chef-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 chef-app/brand-logo.png -0241ec2e4daa5b209395e2e4724b0d569e5119a806c446dbdeffce6a33801eff car-app/index.html -ef324767e4e82da04d79f6e649f48ba56192223f68107d5268b060a7278f9826 car-app/sw.js +e4a786f580e0c80636f490d66f5bc1a844bc16b4eead9101dccb5e560c4f678d car-app/index.html +326dc8fe1dd8d84876b6780992efe24a734ef829c7979b336de18f30e71b3b70 car-app/sw.js 091b9f96d36153d270b44dbf458aa99e4fd5e2f127769d030436fcd1d51e724a car-app/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 car-app/brand-logo.png fb1f73283c30e03612191eb339980b1b4922f3929cc60fa4780340c53d6434f1 car.html 98081968ac06b8ca464c4e5c66c95465d50c20bd7318d2b18eac93464c6e39af t.html -74d5da1d80f2e75897388cc0d8cccae73b68a07bc3bc3c57ec30b98280e90cb7 owner-desktop/index.html -7b8553819427f624ffeb7bcb9b900354b07bf183c9fdc049a47705e39bfdf63d owner-desktop/sw.js +9596dc912d282a6b9d45978ff6d0b155d35d391a5c37b6d5f4279aa5371c0a92 owner-desktop/index.html +2f7f3d80b35774b0c40cd39177f55fec65dfb4878c6d1418d52fe001e081935d owner-desktop/sw.js 600cd2564464ea11c3fa2446efa4fc5ecc43fa3f2bce6e8a66cec6f02fa48652 owner-desktop/manifest.webmanifest cc3dd9b8a359ba6c3f28d625c27cc6a01a46233311c2a5f5c8aaf09e91be8239 owner-desktop/brand-logo.png 37eea85956fc1d2f7b80905f2c7aa002f048f5167877f9adbaed6b0cff2bbe92 desktop.html diff --git a/car-app/_expo/static/js/web/bundle.js b/car-app/_expo/static/js/web/bundle.js index f4386aa9b7613cd595534396c3145f7ed0494828..43ee3a6800619957fcb63458fbb65c63b93f39e1 100644 --- a/car-app/_expo/static/js/web/bundle.js +++ b/car-app/_expo/static/js/web/bundle.js @@ -23,11 +23,11 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_VENUE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PITCH_TEAM",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PITCH_TEXT",{enumerable:!0,get:function(){return o}}),e.pitchText=function(a,n=!1){let l=a;for(const[a,s]of o){if(n&&t.test(a.source.replace(/\\/g,'')))continue;a.test(l)?(a.lastIndex=0,l=l.replace(a,s)):a.lastIndex=0}return l};const a={name:'The Harbour Kitchen',tagline:'Harbourside seafood & seasonal plates',location:'12 Quay Street, Portmorran',phone:'01632 960 123',website:'harbourkitchen.example'},n={'st-tracy':{name:'Morgan',job:'Owner',hourlyPence:null,salaried:!0},'st-gordon':{name:'Alex',job:'General Manager',dept:'Management',hourlyPence:null,salaried:!0},'st-bisto':{name:'Ravi',job:'Head Chef',hourlyPence:null,salaried:!0},'st-agate':{name:'Priya',job:'Front of house supervisor',hourlyPence:1450},'st-lenny':{name:'Tom',job:'Commis Chef',hourlyPence:1325},'st-finn':{name:'Lewis',job:'Bar staff',hourlyPence:1290},'st-eilidh':{name:'Chloe',job:'Front of house',hourlyPence:1271},'st-emily':{name:'Ellie',job:'Front of house',hourlyPence:1271},'st-lillie':{name:'Jordan',job:'Kitchen porter (KP)',hourlyPence:1271},'st-jack':{name:'Sam',job:'Kitchen porter (KP)',hourlyPence:1271}},o=[['Harbour View, Dunure, South Ayrshire',a.location],['Harbour View, Dunure',a.location],['Harbour View mug','Harbour Kitchen mug'],['Harbour View','Quay Street'],['anchoragedunure.com',a.website],['01292 502826',a.phone],['Mini Anchors','Little Crew'],['The Anchorage',a.name],['Anchorage','Harbour Kitchen'],['ANCHORAGE','HARBOUR KITCHEN'],['South Ayrshire','the Firth coast'],['Ayrshire','the Firth coast'],['Dunure','Portmorran'],['Kittyfisher boat (Big Sean)','Coastal Fish Co'],['Kittyfisher','Coastal Fish Co'],['Big Sean','Coastal Fish Co'],['Example Fish Co.','Coastal Fish Co'],['Sample Dairy Ltd','Hillside Dairy'],['Sample Fruit & Veg','Fieldfare Veg'],['Mills milk','Hillside Dairy milk'],['Mills','Hillside Dairy'],['J. Pieroni & Sons','Fieldfare Veg'],["Pieroni's",'Fieldfare Veg'],['Pieroni','Fieldfare Veg'],['Alsons (drinks)','Drinks wholesaler'],['Alsons','the drinks wholesaler'],['Spes Bona','the deli wholesaler'],['Tarelgin','the butcher'],['Reids','the bakery'],['Reeds','the bakery'],['Example Butchers Ltd','Quayside Butchers'],['Example Dry Goods Wholesale','Dry goods wholesaler'],['Sample Brewing Co.','Harbourside Brewing'],['Example Cleaning Supplies','Cleaning supplies'],['Sample Packaging Ltd','Packaging supplier'],['Example Kitchen Repairs','Kitchen repairs'],['Preston','Ravi'],['Bisto','Ravi'],['Tracy','Morgan'],['James','Morgan'],['Gordon','Alex'],['Agate','Priya'],['Lenny','Tom'],['Finn','Lewis'],['Eilidh','Chloe'],['Emily','Ellie'],['Gabrielle','Ellie'],['Cameron Mc','Sam'],['Cameron','Sam'],['Lillie','Jordan'],['Lily','Jordan'],['Mia','Jordan'],['Jack','Sam'],['Harvey','Jordan'],['Anna','the supplier'],['(preview)',''],[' (example)','']].map(([a,n])=>[new RegExp(`${/^[A-Za-z]/.test(a)?'(?g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},23,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1619,1622]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1623,1626]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},25,[26]); __d(function(g,r,i,a,m,e,d){ /** @@ -41,8 +41,8 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},26,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},27,[28]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1052,1255,1256,1260,1262,1264,1271,1325,1326,1327,1328,1329,1330,1332,1333,1334,1335,1336,1337,1338,1339,1342,1409,1410,1411,1571,1576,1577,1618]); -__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,993,25]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1053,1256,1257,1261,1263,1265,1272,1326,1327,1328,1329,1330,1331,1333,1334,1335,1336,1339,1340,1341,1342,1345,1412,1413,1414,1575,1580,1581,1622]); +__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,994,25]); __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)},30,[31,32,782,783,785]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},31,[]); __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}},32,[33,692,487,708,557,709,770,761,764,774,647,645,650,562,560,591,465,467,204,205,775,472,473,462,460,569,556,639,659,776,658,162,151,547,433,777,780]); @@ -872,9 +872,9 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},789,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},790,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},791,[]); -__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1054,1055,1015,2,1056,1060,1061,1093,858,1098,1102,1103,1106,1107,1110,1111,1113,1114,1115,1144,1146,1091,34,373,236,402,295,426,102,36,873,1156,794,867,821,1087,1158,1164,1167,1168,1171,1185,1184,1186,1187,1190,1191,1198,1201,1204,1217,1218,1222,1223,925,1003,1224,1177,1225,1232,1237,1246,1239,1175,1248,1252,1219,874,1253,1173,987,1254,25]); +__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1055,1056,1016,2,1057,1061,1062,1094,858,1099,1103,1104,1107,1108,1111,1112,1114,1115,1116,1145,1147,1092,34,373,236,402,295,426,102,36,873,1157,794,867,821,1088,1159,1165,1168,1169,1172,1186,1185,1187,1188,1191,1192,1199,1202,1205,1218,1219,1223,1224,925,1004,1225,1178,1226,1233,1238,1247,1240,1176,1249,1253,1220,874,1254,1174,987,1255,25]); __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=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.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."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.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 CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};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]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(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 v(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 b(e){const{img:t,url:a}=await f(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),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.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()})}},793,[34,336,236,402,102,794,925,929,926,821,930,25]); -__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=D,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(H,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(x.default,{style:{flex:1},children:u}),s?(0,B.jsx)(x.default,{style:N.footer,children:(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=v,_e.Card=F,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(x.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:L?'center':'flex-start'}],children:(0,B.jsx)(D,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(x.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(D,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(D,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(x.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(D,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,p.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(D,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(D,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(x.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(D,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),x=e(_r(d[14])),p=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),L='display'!==S.APP_VARIANT;function D({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),x=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,p=f.default.flatten(t)||{},j=1===p.flex||1===p.flexGrow||'number'==typeof p.width||'left'===p.textAlign,k=c??(L&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,x,(0,W.webLine)(t,r),k&&'left'!==p.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(D,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(D,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(D,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??L});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(x.default,{style:N.brandBar,children:[(0,B.jsxs)(x.default,{style:N.row,children:[(0,B.jsx)(x.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(D,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(x.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(x.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function H(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(D,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function v({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],x={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:x,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(D,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(D,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function F({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(x.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(x.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(D,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(D,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,v.centreRow=!0;const V=()=>(0,B.jsx)(E,{kind:"example",title:"Allergens awaiting kitchen verification",children:"This allergen information has not been verified by the kitchen. Head chef sign-off is required. Always speak to staff about allergies."}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Card payments: not set up yet",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===F?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(L&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(x.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=L&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(x.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(x.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); +__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(v,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(p.default,{style:{flex:1},children:u}),s?(0,B.jsx)(p.default,{style:N.footer,children:(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=F,_e.Card=H,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:D?'center':'flex-start'}],children:(0,B.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,x.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),D='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(D&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??D});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(p.default,{style:N.brandBar,children:[(0,B.jsxs)(p.default,{style:N.row,children:[(0,B.jsx)(p.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function v(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function F({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function H({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,F.centreRow=!0;const V=({phone:e})=>(0,B.jsx)(E,{kind:"warn",title:"Allergies",children:"All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===H?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(D&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=D&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},795,[]); __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.GoldX=h,_e.GoldClose=j,Object.defineProperty(_e,"TEXT_ONLY_CLOSE",{enumerable:!0,get:function(){return x}}),_e.ToastClose=function({onPress:e,label:o="Close",testID:s,size:l="md",style:c,colour:h}){return x?(0,b.jsx)(t.default,{testID:s,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:[{minWidth:64,minHeight:48,alignItems:'center',justifyContent:'center',paddingHorizontal:8},c],children:(0,b.jsx)(u.Text,{style:{fontSize:16,color:h??n.colours.text},children:"Close"})}):(0,b.jsx)(j,{onPress:e,label:o,testID:s,size:l,style:c})},r(d[0]);var t=e(r(d[1])),o=e(r(d[2])),s=r(d[3]),l=e(s),n=r(d[4]),c=r(d[5]),u=r(d[6]),b=r(d[7]);function h({size:e=16,colour:t=n.colours.gold,stroke:o}){const c=o??(e>=20?2.4:2.2);return(0,b.jsx)(l.default,{width:e,height:e,viewBox:"0 0 24 24",accessible:!1,focusable:!1,pointerEvents:"none",children:(0,b.jsx)(s.Path,{d:"M6 6 L18 18 M18 6 L6 18",stroke:t,strokeWidth:Math.min(4,c*(24/e)),strokeLinecap:"round",fill:"none"})})}const f={sm:32,md:38,lg:46},y={sm:13,md:15,lg:18};function j({onPress:e,label:s="Close",testID:l,size:c="md",style:u,disabled:j,hint:x}){const C=f[c],I=Math.max(44,C+8);return(0,b.jsx)(t.default,{testID:l,accessibilityRole:"button",accessibilityLabel:s,accessibilityHint:x,disabled:j,onPress:e,dataSet:{goldClose:'1'},style:[{width:I,height:I,alignItems:'center',justifyContent:'center',flexShrink:0,opacity:j?.4:1},u],children:({pressed:e,hovered:t})=>(0,b.jsx)(o.default,{style:{width:C,height:C,borderRadius:C/2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:e||t?n.colours.gold:n.colours.accentBorder,backgroundColor:e?n.colours.goldTint:t?n.colours.accentBg:'rgba(0,0,0,0.18)'},children:(0,b.jsx)(h,{size:y[c],colour:e?n.colours.goldLight:n.colours.gold})})})}const x=['kirkton','abbotsford'].includes(c.VENUE_RID)},796,[34,402,102,797,821,5,827,25]); __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}},797,[798]); @@ -911,7 +911,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule? __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOUTERS_BG",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SOUTERS_SURFACE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SOUTERS_TYPE_SCALE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"soutersFont",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"soutersSurface",{enumerable:!0,get:function(){return f}}),e.soutersInk=function(o){if(!t.IS_SOUTERS)return o;const c=(0,n.normaliseHex)(o);return c?'#A4622E'===c?'#D9AD8A':(0,n.contrast)(c,u)<4.5?'#FFFFFF':o:o};var t=r(d[0]),n=r(d[1]);const u='#56152A',o='#43122F',c=.88,S=n=>t.IS_SOUTERS?Math.round(n*c*100)/100:n,f=n=>t.IS_SOUTERS?o:n},828,[5,829]); __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normaliseHex=n,e.hexToRgb=r,e.rgbToHex=o,e.hsvToRgb=s,Object.defineProperty(e,"hsvToHex",{enumerable:!0,get:function(){return a}}),e.hexToHsv=function(t){const{r:n,g:o,b:s}=r(t),a=n/255,c=o/255,u=s/255,i=Math.max(a,c,u),h=Math.min(a,c,u),l=i-h;let p=0;l&&(p=i===a?(c-u)/l%6:i===c?(u-a)/l+2:(a-c)/l+4);return{h:(60*p+360)%360,s:i?l/i:0,v:i}},e.luminance=c,e.contrast=u,e.shade=i,e.checkAccent=function(t,r,o,s){const a=n(t)??'#CFA45F',c=u(a,o),h=u(a,s),l=c>=h?o:s,p=[];Math.max(c,h)<4.5?p.push('Button text may be hard to read on this colour. We picked the clearer text colour for you, but a lighter or darker shade will read better.'):l===s&&p.push('This is a dark colour, so buttons use light text.');let b=a,d=0;for(;u(b,r)<4.5&&d<20;)b=i(a,.05*(d+1)),d++;b!==a&&p.push('This colour is hard to read on the dark background, so header text uses a lighter shade of it.');return{onAccent:l,accentText:b,tips:p}},e.pushRecent=function(t,r,o=8){const s=n(r);return s?[s,...(t??[]).filter(t=>t!==s)].slice(0,o):t??[]};const t=(t,n=0,r=1)=>Math.min(r,Math.max(n,t));function n(t){const n=t.trim().replace(/^#/,'');return/^[0-9a-fA-F]{3}$/.test(n)?'#'+n.split('').map(t=>t+t).join('').toUpperCase():/^[0-9a-fA-F]{6}$/.test(n)?'#'+n.toUpperCase():null}function r(t){const r=(n(t)??'#000000').slice(1);return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function o({r:n,g:r,b:o}){return'#'+[n,r,o].map(n=>Math.round(t(n,0,255)).toString(16).padStart(2,'0')).join('').toUpperCase()}function s({h:t,s:n,v:r}){const o=(t%360+360)%360/60,s=r*n,a=s*(1-Math.abs(o%2-1)),c=r-s,[u,i,h]=o<1?[s,a,0]:o<2?[a,s,0]:o<3?[0,s,a]:o<4?[0,a,s]:o<5?[a,0,s]:[s,0,a];return{r:255*(u+c),g:255*(i+c),b:255*(h+c)}}const a=t=>o(s(t));function c(t){const n=t=>{const n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)},{r:o,g:s,b:a}=r(t);return.2126*n(o)+.7152*n(s)+.0722*n(a)}function u(t,n){const r=c(t),o=c(n);return(Math.max(r,o)+.05)/(Math.min(r,o)+.05)}function i(t,n){const{r:s,g:a,b:c}=r(t),u=n>0?255:0,i=Math.abs(n);return o({r:s+(u-s)*i,g:a+(u-a)*i,b:c+(u-c)*i})}},829,[]); __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,"isEditable",{enumerable:!0,get:function(){return u}}),_e.hideKeyboard=s,_e.installKeyboardHide=f,_e.useTyping=function(){const[e,n]=t.default.useState(c);return t.default.useEffect(()=>{if(!o)return;f();const e=()=>setTimeout(()=>n(c()),0);return document.addEventListener('focusin',e,!0),document.addEventListener('focusout',e,!0),()=>{document.removeEventListener('focusin',e,!0),document.removeEventListener('focusout',e,!0)}},[]),e},_e.useVisibleArea=function(){const e=o?window.visualViewport:null,n=()=>e?{height:Math.round(e.height),top:Math.round(e.offsetTop)}:null,[u,c]=t.default.useState(n);return t.default.useEffect(()=>{if(!e)return;const t=()=>c(e=>{const t=n();return e&&t&&e.height===t.height&&e.top===t.top?e:t});return e.addEventListener('resize',t),e.addEventListener('scroll',t),()=>{e.removeEventListener('resize',t),e.removeEventListener('scroll',t)}},[]),u};var t=e(r(d[0])),n=e(r(d[1]));r(d[2]);const o='undefined'!=typeof document,u=e=>!!e&&'function'==typeof e.matches&&e.matches("input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]"),c=()=>!!o&&u(document.activeElement);function s(){try{n.default.dismiss()}catch{}o&&u(document.activeElement)&&document.activeElement.blur()}function a(){if(!o)return;const e=document.activeElement;if(u(e))try{e.scrollIntoView({block:'nearest',inline:'nearest'})}catch{}}let l=!1;function f(){o&&!l&&(l=!0,document.addEventListener('click',e=>{if(!c())return;const t=document.activeElement;if('function'!=typeof t.closest||!t.closest('[aria-modal="true"], [role="dialog"]'))return;const n=e.target;n&&!u(n)&&('function'==typeof n.closest&&n.closest('label, [data-keep-keyboard]')||s())},!0),document.addEventListener('focusin',e=>{u(e.target)&&setTimeout(a,300)},!0),window.visualViewport?.addEventListener('resize',()=>setTimeout(a,50)))}},830,[34,376,236]); -__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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 O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:u,phone:g,email:m})=>{const p=t(),b=p.basket,f=b.restaurantId,k=w(b,p.menu,p.customer.allergies),I=k.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,h=$(p.orders.filter(e=>e.restaurantId===f).map(e=>e.ref),S?'Q-':'T-',S?p.counters.table:p.counters.order),O=u?n(o,f,I+i):0,C=I+i,v={id:(0,y.uuid)(),ref:`${S?'Q':'T'}-${h}`,restaurantId:f,customerId:p.customer.id,customerName:p.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:k,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:u?C:0,status:'new',createdAt:a().toISOString(),allergies:p.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:g??p.customer.phone,email:m??p.customer.email}:{}};e(e=>({orders:[v,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:h}:{...e.counters,order:h}}));const A=k.filter(e=>e.overridden);return r(f,'order',`Order ${v.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${A.length?` \u2014 ALLERGY OVERRIDE on ${A.map(e=>e.name).join(', ')}`:''}`),v.allergies.length&&r(f,'allergy',`Allergies declared and confirmed by customer on ${v.ref}: ${v.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),c(v),v},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); +__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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,choiceIds:s.map(e=>e.id)}]})}const O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:n,tip:s,notes:i,phone:o,email:l,customerName:u})=>{const g=t(),m=g.basket,p=m.restaurantId,b=w(m,g.menu,g.customer.allergies),f=b.reduce((e,t)=>e+t.unitPrice*t.qty,0),k='table'===m.mode,I=$(g.orders.filter(e=>e.restaurantId===p).map(e=>e.ref),k?'Q-':'T-',k?g.counters.table:g.counters.order),S=!k,h=f+(S?0:s),O=(u??'').trim()||g.customer.name,C={id:(0,y.uuid)(),ref:`${k?'Q':'T'}-${I}`,restaurantId:p,customerId:g.customer.id,customerName:O,type:m.mode,tableNo:m.tableNo,slotTime:n,lines:b,subtotal:f,tip:S?0:s,giftCardApplied:0,giftCardCode:void 0,total:h,paid:0,status:S?'awaiting_payment':'new',createdAt:a().toISOString(),allergies:g.customer.allergies,readiness:{},notes:i,channel:'app',...'takeaway'===m.mode?{phone:o??g.customer.phone,email:l??g.customer.email}:{}};e(e=>({orders:[C,...e.orders],basket:{...e.basket,lines:[]},counters:k?{...e.counters,table:I}:{...e.counters,order:I}}));const v=b.filter(e=>e.overridden);return r(p,'order',`Order ${C.ref} placed (${k?`Table ${m.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),C.allergies.length&&r(p,'allergy',`Allergies declared and confirmed by customer on ${C.ref}: ${C.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),'awaiting_payment'!==C.status&&c(C),C},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WILDINGS_LOCATION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WILDINGS_ADDRESS",{enumerable:!0,get:function(){return t}}),e.withWildingsAddress=function(r){return'wildings'===r.id?{...r,location:n,address:t}:r},e.withWildingsQuestionnaireAddress=function(n,r){return'wildings'===n&&r?{...r,venue:{...r.venue,address:t}}:r};const n='Maidens, KA26 9NR',t='Maidens Road, Maidens, KA26 9NR'},832,[]); __d(function(g,r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sampleFingerprint=i,e.stripOwnerLiveSamples=function(n){const a={};for(const[s,o]of Object.entries(t.OWNER_SAMPLE_HASHES)){const t=n[s]||[];a[s]=t.filter(t=>!o.includes(i(t)))}a.chat=(n.chat||[]).filter(t=>!(0,s.isSeedChefChat)(t));const o=(n.changeRequests||[]).length-a.changeRequests.length;o&&(a.changesUsed=Math.max(0,(n.changesUsed||0)-o));return a},e.stripCoreLiveSamples=function(a){const c={...(0,n.stripCoreChefSamples)(a)};c.giftCards=(a.giftCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.giftCards.includes(i(s))),c.stampCards=(a.stampCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.stampCards.includes(i(s))),c.ratings=(a.ratings||[]).filter(t=>!(/^rt-[123]$/.test(t.id)&&(0,s.demoActor)(t.customerName))),i(a.customer)===t.LEGACY_CUSTOMER_HASH&&(c.customer={...a.customer,id:'',name:'',email:'',phone:'',allergies:[],allergyConsent:!1,referralCode:'',marketingOptIn:{}});return c.restaurants=(a.restaurants||[]).filter(t=>!('saltmarsh'===t.id&&['The Venue','Saltmarsh Bistro'].includes(t.name))),c.menu=(c.menu||a.menu||[]).filter(t=>'saltmarsh'!==t.restaurantId).map(t=>t.signOff?t:o(t)),c};var t=r(d[0]),s=r(d[1]),n=r(d[2]);const a=t=>Array.isArray(t)?t.map(a):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&'function'!=typeof t).sort(([t],[s])=>ts?1:0).map(([t,s])=>[t,a(s)])):t;function i(t){const s=JSON.stringify(a(t))??"null";let n=2166136261;for(let t=0;t>>0).toString(16)}const o=t=>Array.isArray(t)?t.map(o):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).map(([t,s])=>[t,'allergenNotes'===t&&'string'==typeof s&&/\(example\)/i.test(s)?'':o(s)])):t},833,[834,835,836]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"OWNER_SAMPLE_HASHES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CORE_SAMPLE_HASHES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"LEGACY_CUSTOMER_HASH",{enumerable:!0,get:function(){return b}});const c={referrals:["43f09bc0","c438fbad","96bf8c62","3399d421"],coats:["f51097ad","2f7efa3a"],merch:["ef6e14e","dbbc0999","dc233c1d"],merchOrders:["13b15512","bc27f242"],offers:["ad0fcde0","59e6c0cf"],photos:["53a60fd9","ab778a74","95de43cd"],changeRequests:["81c5be12","6819542c"],lost:["5bbf0d77","7d3aa9ed","850c049e"],campaigns:["9cdf8346","82150e7"],suppliers:["41df06e7","466e32ac","fa3d8eea","dfafa674","1e26fbd0","c195b120","5fc49e74","6aa8b0af","602fc2e4"],supplierOrders:["22636226","464d6a6a"]},f={giftCards:["b1bba36d","f029bc0e"],stampCards:["e7bedf6f","a3c8404d"]},b="4b1e9971"},834,[]); @@ -1067,643 +1067,647 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},984,[835]); __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 t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(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 u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{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}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},985,[984]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},986,[872,34,102,987,2,821,794,25]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return W.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return W.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return W.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return W.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return W.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return I.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return I.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return It}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ne.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ne.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ne.useOwner.getState().chatSeen(t,e)),Ft(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ne.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...St(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(le.PITCH)return pe.unlockCashUp(e,t,a);const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?oe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):oe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(le.PITCH)return pe.cashAudit(e);const t=Oe.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(ma.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=fa,i.readAccessLog=async function(){const e=Oe.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Oe.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return pa}}),i.uploadOrderLogo=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(pa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ga.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(pa).createSignedUrl(e,3600);if(t?.signedUrl)return ga.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(pa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return ma}}),i.claimInvite=Da,i.makeChromeHandover=async function(){const e=Oe.getState();if(le.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ue});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(le.PITCH||!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ue});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),Pe&&xa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Te();const t=await x.kv.get(ka,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Te(),await x.kv.get(Ia,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_WILDINGS||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Te(),await x.kv.remove(ka),await x.kv.remove(Ia),Ae({mode:'signin',perms:[]});try{await Ma()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Oe.getState().venueId;if(le.PITCH||!s||'staff'!==Oe.getState().kind)return{ok:!0};if(!(0,ie.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ka('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Da(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(le.PITCH)return pe.reissueInvite(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ka('staff_app_link_history',{p_venue:Oe.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ka('revoke_staff_app_link',{p_venue:Oe.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(le.PITCH)return pe.linkPhones();const e=Oe.getState().venueId;if(!e||'staff'!==Oe.getState().kind)return{};try{const t=await Ka('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(le.PITCH)return pe.resetPhone(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ka('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(le.PITCH)return pe.inviteStatus();const e=Oe.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:t,error:a}=await Re().rpc(o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_pairing_code':o.IS_GREENSIDE?'claim_greenside_pairing_code':o.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':o.IS_KIRKTON?'claim_kirkton_pairing_code':o.IS_WILDINGS?'claim_wildings_pairing_code':o.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':o.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await x.kv.set(ba,n),xa(),{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}`}}},i.carPairStart=async function(){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await x.kv.set(Ua,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ea(e)}}},i.carPairPoll=async function(e){try{Te();const t=e??await x.kv.get(Ua,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,G.carPairApproved)(n)){const e=(0,G.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await x.kv.get(ba,null);await x.kv.set(ba,e),await x.kv.remove(ka),O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||xa()}return'revoked'!==i&&'unknown'!==i||await Ta(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Te(),await Re().rpc('car_sign_out')}catch{}await Ta(),await Ma();try{await Re().auth.signOut({scope:'local'})}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ka('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ea(e)}}},i.carList=async function(){const e=Oe.getState().venueId;if(!e)return[];return(await Ka('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ka('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ea(e)}}},i.unpairDisplay=async function(){await x.kv.remove(ba),await Ma();try{await Re().auth.signOut()}catch{}Ae({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await x.kv.remove(ka),await x.kv.remove(Ia),await Ma();try{await Re().auth.signOut()}catch{}Ae({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.'})},i.wipeThisDevice=async function(e={}){try{await Ma()}catch{}try{(0,T.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${o.VENUE_RID}:`)):(0,I.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!o.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Na,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ka}}),i.mendSession=qa,i.startAppSync=async function(e=o.VENUE_RID){if(o.IS_ISOLATED_VENUE&&e!==o.VENUE_RID)return;if(Pe)return;Pe=!0,La=e,'customer'===Ue&&'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Te(),'customer'!==Ue){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ue&&(0,h.isAnchorage)(e)?[H.useStore,ne.useOwner,ae.useKitchen,se.useSafety,Y.useCardStore,m.useGpCalc,X.useOrderSheets,S.useSpecials,A.useHr]:[H.useStore,ne.useOwner,ae.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ue&&(0,h.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ae({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await vs(e)}catch{if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e))return void Ae({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,T.isSupabaseConfigured)())return void Ae({mode:'off'});j.mutationQueue.subscribe(()=>{const e=j.mutationQueue.waiting,t=e[0];Ae({pending:j.mutationQueue.pending.length,failed:j.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,L.describeWrite)(t)}: ${(0,L.plainReason)({...t.lastErr},'retry')}`:void 0})}),j.mutationQueue.onFailed(e=>Ae({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:j.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,L.describeWrite)(e),why:'conflict'===e.reason?(0,L.plainReason)({code:'conflict'},'refused'):(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Ke.push((0,N.onConnectivity)(e=>Ae({mode:e?Oe.getState().venueId?'live':Oe.getState().mode:Oe.getState().venueId?'offline':Oe.getState().mode}))),await Ba()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return za}}),i.stockSaveBlocker=Za,i.stockEventStatus=function(e){if(ze(e))return{state:'saved'};const t=j.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,L.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=Ya,i.saveStockEventsNow=Xa,i.bookingSaveBlocker=ts,i.resendUnsavedBookings=ns,i.saveBookingsNow=is,i.waitForBookingSave=function(e,t=12e3){if(!De())return Promise.resolve({state:'local'});const a=ts();if(a)return Promise.resolve({state:'refused',why:a});const s=as()[0]?.venueId??'',n=()=>es.some(t=>j.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=F.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,N.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(j.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(j.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||as().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||as().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=cs,i.tempLogState=function(){const e=ls()[0]?.venueId??'',t=ls().find(e=>'temp_readings'===e.spec.table),a=j.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!j.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values($.useTempSaves.getState().notSaved),i=se.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=fs,i.waitForTempSave=function(e,t,a=1e4){if(!De()||!ls().length)return Promise.resolve({state:'local'});const s=cs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ls()[0]?.venueId??'',i=ls().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>$.useTempSaves.getState().notSaved[(0,$.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>j.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=_s,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ts}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Es.get(a);if('customer'!==Ue||!(0,T.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Es.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ka('public_day',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:qe(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:qe(a.from_time),to:qe(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Es.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ts.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Es.get(a);e&&!e.ok&&Es.delete(a)}));const n=Es.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Oe.getState().venueId;if(!n||'staff'!==Oe.getState().kind)throw new Error('Connect to your venue first.');const i=await Ka('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});H.useStore.getState().updateRestaurant(e,{...i,id:e})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(fe),ge=t(r[60]),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]);const Re=()=>(0,E.getSupabase)();j.mutationQueue.setExecutor(q.executeMutation),(0,P.setClockServer)(()=>'staff'===Oe.getState().kind);const Oe=(0,U.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ae=e=>Oe.setState(e),Ce=e=>{const t=Oe.getState().perms;return t.includes('*')||t.includes(e)},De=()=>{const e=Oe.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Oe.subscribe(()=>(0,ve.setLiveData)(De()));let Ue=V.IS_CAR?'car':V.APP_VARIANT,Ee=!1;const Te=()=>{Ee||((0,x.setSyncNamespace)(Ue),Ee=!0)};let Ne=[],Ke=[],Pe=!1;const Me=()=>(new Date).toISOString().slice(0,10),xe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),qe=e=>e?e.slice(0,5):'',Le=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))):[],Be=e=>JSON.parse(JSON.stringify(e));function je(e,t){const a=xe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>H.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Be(e);if(t)return{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:Le(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,ie.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:Le(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Fe(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>H.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.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,ie.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Be(e.lines??[]),allergies:Le(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:Be(e.allergyChain??{}),readiness:Be(e.readiness??{}),allergy_ticks:Be(e.allergyTicks??{}),handover_check:e.handoverCheck?Be(e.handoverCheck):null,accepted:e.accepted?Be(e.accepted):null,doc:Be(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)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function $e(e){const t=xe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...J.useBlocks.getState().blocks,...J.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Oe.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:Be(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,J.blockClock)(t.from_time)??a?.from,n=(0,J.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>J.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>J.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let We=null,Qe='Main plan';function He(e){const t=e=>Be({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(z.useFloor.getState().plans[e]??(0,z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Ce('floor.manage')||Ce('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:We??(0,be.uuidFrom)(`plan:${a}`),venue_id:a,name:Qe||'Main plan',is_active:!0,...t(e),updated_by:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>(We=String(e.id),Qe=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,ke.withSeedBest)(e,t[0]):void 0;a&&z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ve(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Z.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Ce('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,ie.isUuid)(e.supplierId)?e.supplierId:(0,be.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),ot.get(t)??t)}:{}};var t},apply:(t,a)=>Z.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Ge=new Set,Je=new Set;j.mutationQueue.onDone(e=>{'stock_events'===e.table&&Je.add(e.rowKey)});const ze=e=>Je.has(e)||Ge.has(e),Ze=()=>Ce('*')||Ce('staff.manage')||Ce('recipes.edit')||Ce('recipes.signoff'),Ye=()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write'));function Xe(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Z.useShellStore.getState().events.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,ie.isUuid)(t.id)&&!!(Z.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('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,ie.isUuid)(e.undoes)&&(ze(e.undoes)||j.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Ge.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)=>Z.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function et(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Z.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={...Z.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Z.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Ge]}}}))},afterRead:()=>{Z.useShellStore.getState().server[e]||Z.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Ge]}}}))},subscribe:()=>()=>{}}}const tt=new Set;function at(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=H.useStore.getState().menu;return Y.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:t=>(0,ie.isUuid)(t.card.id)&&!((0,h.isAnchorage)(e)&&(0,h.isDemoCard)(t.card))&&!(0,h.isPlaceholderCard)(t.card),writable:()=>Ce('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,h.isAnchorage)(e)&&(s={...s,signOff:(0,h.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,h.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,h.isAnchorage)(e)&&(0,h.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,be.photoPath)(a,s),t=st(s.photo);t&&((0,Y.cachePhotoAs)(e,t),nt(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,be.cardToRow)(s,a);return{...i,...r,doc:Be({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,h.isPlaceholderCard)(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,signOff:(0,h.isAnchorage)(e)&&(0,h.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Ce('recipes.edit')&&t.length){const e=new Set(t);Y.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);Y.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&H.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&H.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=Y.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=H.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const st=e=>(0,Y.readLocalPhoto)(e);async function nt(e,t){if(!tt.has(e)){tt.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(be.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){tt.delete(e),Ae({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const it=new Map,rt=(0,U.create)(()=>({n:0}));(0,Y.setStoragePhotoResolver)(e=>{const t=it.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,T.isSupabaseConfigured)()&&'off'!==Oe.getState().mode?(t||(it.set(e,{url:'',at:Date.now()}),Re().storage.from(be.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(it.set(e,{url:t.signedUrl,at:Date.now()}),rt.setState(e=>({n:e.n+1})),Y.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const ot=new Map;const dt=(e,t)=>{const a=(0,ie.isUuid)(t)?t:(0,be.uuidFrom)(`sup:${e}:${t}`);return ot.set(a,t),a};function ut(e){return{name:'order_sheets',table:'suppliers',list:()=>X.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,h.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Ce('suppliers.manage'),toRow:(e,t)=>({id:dt(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:Be(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(ot.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>X.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>X.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,ie.isUuid)(e)?e:(0,be.uuidFrom)(`sup:${Oe.getState().venueId}:${e}`)})}}let ct=!1,lt=!1;const ft=new Map,pt=new Map,gt=new Map,mt=new Map,_t=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',St=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'},ht=(e,t)=>({...e,managerAccess:t}),yt=()=>({nickname:ct,display:lt}),wt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=ht({role:e.role,level:e.level??St(_t(e)).level},!0===e.managerAccess);return(0,B.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},yt())};const vt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},bt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},kt=e=>{const t=ne.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,d.isKitchenTeam)(t)},It=2e3;function Rt(e,t){return t||!e.length||e.length>=It?null:e=>(0,ie.isUuid)(e.id)}function Ot(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,Ce('rota.manage')):null,keepOnEmpty:()=>e&&!Ce('rota.manage'),list:()=>ne.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&ft.has(e.staffId)&&(Ce('rota.manage')||kt(e.staffId)),writable:()=>Ce('rota.manage')||Ce('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(vt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:bt(e.start),end_time:bt(e.end),published:!!e.published,doc:Be(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function At(){const e=xe(62),t=e=>Ce('rota.manage')||e.staffId===Oe.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ne.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&t(e),writable:()=>'staff'===Oe.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=xe(2)&&e.staffId===Oe.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Be(e.breaks??[]),break_mins:e.breakMins??0,doc:Be((0,y.privateAttendance)(o.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,y.privateAttendance)(o.VENUE_RID,{...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Ct(){const e=xe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.staffId===Oe.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Oe.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:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,ie.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:Be({...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Dt(e){ne.leaveRemote.decide=t=>!(!Ce('rota.manage')||!(0,ie.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(j.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Ke.push(()=>{ne.leaveRemote.decide=null})}function Ut(e){ne.timesheetRemote.send=(t,a)=>{if(!Ce('rota.manage')||!(0,ie.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return j.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:Be(s)}}),!0}const s=a;if('attendance_void'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return j.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:Be(s.breaks??[]),p_reason:n,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0},Ke.push(()=>{ne.timesheetRemote.send=null})}function Et(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>H.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Oe.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,ie.isUuid)(a)?a:(0,be.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,ie.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Be(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>H.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=>H.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Tt=e=>H.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Nt(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}));H.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Kt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=H.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Be({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Tt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Ce('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Mt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...Mt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Mt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Pt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Pt=t.feature_flags??{},Mt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Be({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}:{}})},apply:t=>{const a=t[0];a&&(H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,l.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Nt(e,a.events))},subscribe:e=>{const t=H.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Pt=null,Mt=null;const xt=()=>new Date(Date.now()-2592e6).toISOString(),qt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ft.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Lt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?(0,Se.dmId)(t[0],t[1]):null},Bt=()=>Oe.getState().perms.includes('*');function jt(){const e=()=>Oe.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ne.useOwner.getState().chat.filter(e=>(0,ie.isUuid)(e.id)).map(e=>Be({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=>!!qt(t.ch)&&(t.from===e()||Bt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('created_at',xt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=xt(),toRow:(e,t)=>{const a=qt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ft.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=Lt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?pt.get(String(e.from_staff)):'system';return s?Be({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ne.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?pt.get(String(t.from_staff)):'system',i=Lt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ne.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,Se.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,he.soundAllowed)())try{(0,he.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,b.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Ft(e,t,a){const s=Oe.getState();if(!_e.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ft.get(e),i='*'===t?'*':qt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function $t(e){const t=Oe.getState().staffRef,a=t?ft.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Lt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ne.useOwner.getState().chatMarkRead(t,i)}catch{}}function Wt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=C.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Be(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>C.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,D.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Qt(e){const t=xe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>C.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.reminderId)&&e.staffRef===Oe.getState().staffRef,writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>C.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Ht(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Vt=e=>null==e||''===e?null:Number(e),Gt=e=>e.filter(e=>!e.startsWith('data:')),Jt=()=>Ce('takings.view');function zt(e){const t=!Jt();return{name:'cash_ups',table:'cash_ups',list:()=>oe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,v.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,v.tradingDay)()&&!e.onServer),writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,v.tradingDay)()):e.gte('for_date',xe(400)),...t?{inWindow:e=>e.date===(0,v.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:Be(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({cashUps:Ht(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Zt(e){return{name:'sales_reports',table:'sales_reports',list:()=>oe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Be(e.vals),categories:e.categories,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({sales:Ht(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Yt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=oe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,oe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Be({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,oe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>oe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function Xt(e){return{name:'day_tips',table:'day_tips',list:()=>oe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',xe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>oe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ea(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>oe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Vt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>oe.useCashUp.setState(s=>({pot:Ht(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function ta(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=oe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Ce('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>oe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function aa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>re.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Be(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>re.useNotifs.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>re.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function sa(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=de.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Be(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>de.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ue.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Ht(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function na(e){const t=()=>Ce('venue.settings')||Ce('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>de.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,ie.isUuid)(a.id)&&(0,ie.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,de.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Oe.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Oe.getState().staffRef)||null,doc:Be(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ia(e){const t=xe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>de.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Be(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({history:Ht(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function ra(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=ce.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Be(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&ce.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,y.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>ce.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function oa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=ge.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,ge.libraryRowId)(e),kind:'library',doc:Be({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,ge.personRowId)(e,i),kind:'person',staffRef:i,doc:Be({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ne.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,me.canEditTasks)(t,a)},writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>ge.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,ge.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function da(e){const t=xe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>ge.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Oe.getState();return e.byRef===t.staffRef||Ce('staff.manage')},writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>ge.useDailyTasks.setState(s=>({ticks:Ht(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ua(e,t=!1){const a=xe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>ye.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind||Ce('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,be.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>ye.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>ye.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{we.autoSync.soldOutRead.add(e)}}}function ca(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>we.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:(0,be.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>we.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>we.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{we.autoSync.linksRead.add(e)}}}async function la(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&x.kv.get(a,!1):(x.kv.set(a,!0),!0)}catch{return x.kv.get(a,!1)}}async function fa(){const e=Oe.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();ma.setState({live:!!t?.push_live,known:!0})}catch{}}const pa='order-list-logos';const ga=new Map;const ma=(0,U.create)(()=>({live:!1,known:!1}));async function _a(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('reminders:ok',!1):(x.kv.set('reminders:ok',!0),!0)}catch{return x.kv.get('reminders:ok',!1)}}async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('chat:ok',!1):(x.kv.set('chat:ok',!0),!0)}catch{return x.kv.get('chat:ok',!1)}}const ha=(e,t)=>Be({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),ya='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function wa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>A.useHr.getState().questions.filter(t=>t.venue===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ha(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);A.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>A.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function va(e,t){const a=(t,a,s)=>{j.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(A.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(ya).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||A.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ha(e,t)))}catch{}}}),Ke.push(()=>{Object.assign(A.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ba='pair:v1',ka='staff:v1',Ia='staff:rejoin:v1';async function Ra(e){const t=o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_invite':o.IS_GREENSIDE?'claim_greenside_invite':o.IS_ABBOTSFORD?'claim_abbotsford_invite':o.IS_KIRKTON?'claim_kirkton_invite':o.IS_WILDINGS?'claim_wildings_invite':o.IS_KIRKMICHAEL?'claim_kirkmichael_invite':o.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ue,p_device:(0,O.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,O.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Oa(){if('display'===Ue||'customer'===Ue||le.PITCH)return'none';const e=await x.kv.get(Ia,null);if(!e)return'none';try{await Ca();const{data:t,error:a}=await Ra(e);if(a)return(0,I.inviteRefusal)(a.message)?(await x.kv.remove(Ia),await x.kv.remove(ka),'refused'):'offline';const s=t?.[0];return s?(await x.kv.set(ka,{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,displayName:s.display_name}),'ok'):(await x.kv.remove(Ia),'refused')}catch{return'offline'}}const Aa=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Ca(){Te();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ae({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 Da(e){if(le.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,I.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Ra(e);if(a){const e=(0,I.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,o.venueKey)(`cc-pending-invite:${Ue}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),await x.kv.set(Ia,e),Pe&&xa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ae({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ua='car:request:v1',Ea=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Ta(){await x.kv.remove(ba),await x.kv.remove(ka),await x.kv.remove(Ua),O.useSession.getState().meId&&O.useSession.getState().signOut()}async function Na(){if(!(0,T.isSupabaseConfigured)())return!1;try{return await Ca(),!0}catch{return!1}}const Ka=async(e,t={})=>{if(le.PITCH)return(0,fe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Pa=null;async function Ma(){for(const e of Ke)try{e()}catch{}Ke=[],Ne.forEach(e=>e.stop()),Ne=[],Pa&&(clearInterval(Pa),Pa=null)}async function xa(){await Ma(),await Ba()}async function qa(){if(!(0,T.isSupabaseConfigured)()||'customer'===Ue||le.PITCH)return!1;try{Te();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ue)return!1;if(!await x.kv.get(Ia,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Oa()&&(xa(),!0)}catch{return!1}}(0,u.setSessionMender)(qa);let La=o.VENUE_RID;async function Ba(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=La;try{if(Ae({mode:'connecting'}),await j.mutationQueue.load(),'customer'===Ue)return void await Ha(e);let t=await x.kv.get(ba,null),a=await x.kv.get(ka,null);if(V.IS_CAR&&!t&&a){const e=(0,G.migrateCarStaffIdentity)(a);e&&(t=e,await x.kv.set(ba,t)),await x.kv.remove(ka),a=null,O.useSession.getState().meId&&O.useSession.getState().signOut()}if(o.IS_ISOLATED_VENUE&&(t&&!(0,o.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,o.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ae({mode:'display'===Ue?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ue&&!V.IS_CAR&&a&&!s.session){const t=await Oa();if('offline'===t)return Ae({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{La===e&&xa()},6e4);'refused'===t&&a.staffRef&&O.useSession.getState().meId===a.staffRef&&O.useSession.getState().signOut(),a=await x.kv.get(ka,null),({data:s}=await Re().auth.getSession())}const n='display'===Ue||V.IS_CAR?t:a;if(!s.session||!n)return void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ka('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ue||V.IS_CAR?await x.kv.remove(ba):(await x.kv.remove(ka),await x.kv.remove(Ia)),'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId===n.staffRef&&O.useSession.getState().signOut(),void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ue?'This display was unpaired by a manager.':V.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,N.isOnline)()||/fetch|network/i.test(String(t?.message)))Ae({mode:'offline'});else if(Aa(t)&&'display'!==Ue){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Oa()&&setTimeout(()=>{La===e&&xa()},500)}i=Oe.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ae({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!V.IS_CAR&&'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId!==n.staffRef&&(O.useSession.getState().signIn(n.staffRef),ne.useOwner.setState({staffAs:n.staffRef})),V.IS_CAR&&(O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({previewRole:'owner'})),await Fa(n.venueId,e,n.kind)}catch(e){Ae({mode:'local',lastError:String(e?.message??e)})}}const ja=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','venue_reminders','reminder_done']);async function Fa(e,a,s){if(!(0,o.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||V.IS_CAR&&'device'===s;await _s(a),Ke.push(Us(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])gt.set(e.key,e.id),mt.set(e.id,e.key)}catch{}const i=[Kt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ne.useOwner.getState().staff.map(wt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Ce('staff.manage'),deletes:!1,revision:e=>(0,B.staffRevision)(e,yt()),toRow:(e,t)=>(0,B.staffRow)(e,t,yt(),e.managerAccess||e.ownerAccess?null:gt.get(_t(e))),fromRow:e=>{if(!e.external_ref)return null;ft.set(String(e.external_ref),String(e.id)),pt.set(String(e.id),String(e.external_ref)),Os.set(String(e.external_ref),e.avatar_path??null);const t=ht(St(mt.get(String(e.role_id))),!0===e.manager_access);return(0,B.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},yt())},apply:e=>ne.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=>ne.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ds()},onRemote:()=>{Ds()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ne.useOwner.getState(),t=te.useSetup.getState().sites[La]?.staffGrade??{};return e.staff.filter(e=>ft.has(e.id)).map(a=>Be({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=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ft.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=pt.get(String(e.staff_id));return t?Be({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=>ne.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=te.useSetup.getState().sites[La],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&&te.useSetup.getState().patch(La,{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=ne.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=te.useSetup.subscribe((t,a)=>{t.sites[La]?.staffGrade!==a.sites[La]?.staffGrade&&e()});return()=>{t(),a()}}},je(a,!1),je(a,!0),$e(a),He(a),Fe(a),Ve(a),Xe(a),et(a),ut(a),{name:'supplier_directory',table:'suppliers',list:()=>ne.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('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:Be(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ne.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId),writable:()=>Ce('suppliers.order')||Ce('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||Me(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Be(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},at(a),ks(a)];Ce('wages.view')&&i.push(Is(a)),n&&(i.push(Ot(!0),At(),Ct(),Et(a)),Ut(e)),n&&await la('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Oe.getState().staffRef&&'pending'===e.status||Ce('rota.manage')),writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Be(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),ja.add('staff_leave'),Dt(e));const d=n&&await Sa();if(_e.useChatSync.setState({synced:d,checked:!0}),Ke.push(()=>_e.useChatSync.setState({synced:!1})),d&&i.push(jt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(Se.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ft.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ft.get(e.id),include:e.include}),fromRow:e=>{const t=pt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>Se.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=>Se.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await la('hr_questions')&&(i.push(wa(a)),ja.add('hr_questions'),va(e,a)),'guest'!==s&&'customer'!==Ue&&await la('temp_readings')&&(i.push((0,W.tempUnitsSpec)(se.useSafety,Ze),(0,W.tempReadingsSpec)(se.useSafety,Ye)),ja.add('temp_units'),ja.add('temp_readings')),'guest'!==s&&await la('sold_out_items')?(i.push(ua(a,await la('sold_out_items','auto'))),ja.add('sold_out_items')):we.autoSync.soldOutRead.add(a),'guest'!==s&&await la('sold_out_links')?(i.push(ca(a)),ja.add('sold_out_links')):we.autoSync.linksRead.add(a),C.useReminders.getState().ensure(a),'guest'!==s&&await _a()&&(i.push(Wt(a)),n&&i.push(Qt(a))),re.useNotifs.getState().ensure(a),de.useOrderLists.getState().ensure(a),n){ct=await la('staff','nickname'),lt=await la('staff','display_clock');const[e,t,s,n]=await Promise.all([la('scheduled_notifications'),la('order_lists'),la('venue_clock_area'),la('daily_tasks')]);ge.useDailyTasks.getState().ensure(a),n&&(i.push(oa(a),da(a)),ja.add('daily_tasks'),ja.add('daily_task_ticks')),e&&(i.push(aa(a)),fa()),t&&i.push(sa(a),na(a),ia(a)),s&&i.push(ra(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&ja.add(n)}if('guest'!==s&&await la('day_tips')){i.push(Xt(a));for(const e of['day_tips','tips_pot_events','tips_settings'])ja.add(e);await la('tips_pot_events')&&i.push(ea(a),ta(a)),n&&(Jt()||(0,oe.forgetPastTakings)(a,(0,v.tradingDay)()),i.push(zt(a),Yt(a)),ja.add('cash_ups'),Jt()&&(i.push(Zt(a)),ja.add('sales_reports')),t(r[72])(r[71],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Ot(),At()),await la('scheduled_notifications')&&i.push(aa(a)));let u=!1;const c=()=>{if(V.IS_CAR&&n&&Ce('recipes.edit'))return!0;const e=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);return!!e&&e.active&&Ce('recipes.edit')&&(0,_.costsAllowedFor)(e)};n&&c()&&await la('ingredient_prices')&&(i.push((0,m.gpSyncSpec)('ing',c)),ja.add('ingredient_prices'),await la('card_costs')&&(i.push((0,m.gpSyncSpec)('card',c)),ja.add('card_costs')),await la('kitchen_deliveries')&&(i.push((0,m.gpSyncSpec)('del',c)),ja.add('kitchen_deliveries')),await la('kitchen_stock_counts')&&(i.push((0,m.gpSyncSpec)('count',c)),ja.add('kitchen_stock_counts'))),(0,Ie.specialsSyncOn)()&&'guest'!==s&&await la('specials_boards')&&(i.push((0,Ie.specialsBoardSpec)(a,()=>Ce('recipes.edit')||Ce('floor.manage')||Ce('*'))),ja.add('specials_boards'));const l={onActivity:()=>Ae({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ae({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ae({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Ka('whoami')??[]).some(t=>t.venue_id===e))return void(La===a&&xa());for(const a of Ne){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||F.useBookingSaves.getState().mark({id:t,table:e,why:ts()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||$.useTempSaves.getState().mark({id:t,table:e,why:cs(e)??'this screen could not send it'})}};Ne=i.map(t=>new Q.EntityBridge(t,e,l)),await Promise.all(Ne.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,N.isOnline)())try{const t=await Ka('whoami');if(!t?.some(t=>t.venue_id===e))return void(La===a&&xa())}catch(e){if(Aa(e)){if(V.IS_CAR)return void(La===a&&xa());const e=await Oa();return void('ok'!==e&&'refused'!==e||La===a&&xa())}}let t=0;for(const[a,s]of Ne.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(_e.useChatSync.getState().error&&_e.useChatSync.setState({error:void 0}),await $t(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&_e.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({mode:'live',lastSyncAt:e,lastServerAt:e}),j.mutationQueue.flush()}else Ae({mode:'offline'});if(!Ce('wages.view')){const e=Oe.getState().staffRef;ne.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const S=new Map;for(const e of Ne)S.set(e.spec.table,[...S.get(e.spec.table)??[],e]);const h=[...S.keys()].filter(e=>ja.has(e)).map(e=>({table:e,venueColumn:S.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,Q.venueChannel)(e,h,(e,t,a)=>{for(const s of S.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ae({lastSyncAt:s,lastServerAt:s})},e=>{Ae({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Ke.push(()=>{Re().removeChannel(w)}),Ke.push((0,N.onConnectivity)(e=>{e&&p()}));const b=Ne.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,K.superviseSync)({fastMs:Wa(Ue),readFast:async()=>{for(const e of b)await e.read()},readAll:p,flush:()=>{j.mutationQueue.flush()},wake:()=>{j.mutationQueue.retryNow()},restart:()=>{La===a&&xa()},realtime:()=>Oe.getState().realtime,lastServerAt:()=>{const e=Oe.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Aa,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>$a(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Ke.push(k.stop)}async function $a(e){const t=Oe.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ka('sync_heartbeat',{p_venue:e,p_device:(0,O.deviceId)()??'unknown',p_app:Ue,p_version:M.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Wa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Oe.getState(),queue:j.mutationQueue.pending.map(e=>e.table),failedTables:j.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),le.PITCH&&(window.__ccSyncPreview=e=>Ae(e)));const Qa='guest:sent:v1';async function Ha(e){Ae({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ka('public_venue',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!o.IS_ISOLATED_VENUE||t.id===o.VENUE_UUID)){Ae({venueId:t.id,venueName:t.name}),await _s(e);const a=t.app?.restaurant;a&&H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,l.withWildingsAddress)({...a,id:e}):t)})),Nt(e,t.app?.events)}await Va(e),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ae({mode:(0,N.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Va(e).catch(()=>{})},6e4);Ke.push(()=>clearInterval(t)),o.IS_ISOLATED_VENUE||await Ga(e)}async function Va(e){const t=await Ka('public_menu',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));Y.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&H.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))]}})}async function Ga(e){let t=await x.kv.get(Qa,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=H.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Na())return;for(const a of n)try{const s=(await Ka('guest_create_booking',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_booking:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(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&&H.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'},Ae({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ka('guest_create_takeaway',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_order:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ae({lastError:`Order: ${e?.message}`}))}await x.kv.set(Qa,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ka('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await x.kv.set(Qa,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ka('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));H.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 Ja(n)===Ja(e)?e:n})})),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ae({mode:(0,N.isOnline)()?Oe.getState().mode:'offline'})}finally{a=!1}}};Ke.push(H.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Pa=setInterval(()=>{n()},15e3),n()}const Ja=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),za={bridges:()=>Ne,restart:xa};function Za(){const e=Oe.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Ce('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function Ya(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(!e||Za())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(j.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function Xa(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}Ya();try{await j.mutationQueue.retryNow()}catch{}}Oe.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{Xa()},3e3)});const es=['bookings','walk_ins'];function ts(){const e=Oe.getState();return De()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const as=()=>Ne.filter(e=>es.includes(e.spec.table)),ss=e=>j.mutationQueue.failed.some(t=>es.includes(t.table)&&t.rowKey===e);function ns(e=!1){return ts()?0:as().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ss(t)&&!!F.useBookingSaves.getState().notSaved[t]),0)}async function is(e=!1){const t=ts();if(t)return t;for(const e of as())try{await e.read()}catch{}ns(e);try{await j.mutationQueue.retryNow()}catch{}return e&&rs(),null}function rs(){const e=as()[0]?.venueId??'',t=F.useBookingSaves.getState(),a=new Set(as().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ss(s)||es.some(t=>j.mutationQueue.hasPending(t,e,s))||t.clear(s)}j.mutationQueue.onFailed(e=>{es.includes(e.table)&&F.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{es.includes(e.table)&&F.useBookingSaves.getState().clear(e.rowKey)});let os=null;const ds=(e=2500)=>{os&&clearTimeout(os),os=setTimeout(()=>{os=null,is(!1)},e)};(0,N.onConnectivity)(e=>{e&&ds()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ds(3e3)});const us=['temp_readings','temp_units'];function cs(e="temp_readings"){const t=Oe.getState();return De()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ze()?'device'!==t.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ls=()=>Ne.filter(e=>us.includes(e.spec.table));async function fs(e=!1){const t=cs();if(t)return t;for(const e of ls())try{await e.read()}catch{}const a=ls()[0]?.venueId??'';for(const t of ls())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,j.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await j.mutationQueue.retryNow()}catch{}if(e){const e=$.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ls().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||j.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,$.tempKey)(t.table,t.id))}}return null}j.mutationQueue.onFailed(e=>{us.includes(e.table)&&$.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{us.includes(e.table)&&$.useTempSaves.getState().clear((0,$.tempKey)(e.table,e.rowKey))});let ps=null;const gs=(e=3e3)=>{ps&&clearTimeout(ps),ps=setTimeout(()=>{ps=null,fs(!1)},e)};(0,N.onConnectivity)(e=>{e&&gs()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&gs(3500)});const ms='golive:v1:';async function _s(e){'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)?await vs(e):(await x.kv.get(ms+e,!1)||await vs(e),await x.kv.get(ys+e,!1)||(ws(e),await x.kv.set(ys+e,!0)),await x.kv.get(Ss+e,!1)||(hs(),await x.kv.set(Ss+e,!0)))}const Ss='golive:v3:';function hs(){const e=e=>JSON.stringify(e).includes('(example)');try{ae.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ys='golive:v2:';function ws(e){const t=e=>JSON.stringify(e).includes('(example)');H.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)))})),ne.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 vs(e){if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)){const t=(0,p.stripCoreLiveSamples)(H.useStore.getState()),a=(0,ae.stripKitchenExamples)(ae.useKitchen.getState()),s=ne.useOwner.getState(),n=(0,p.stripOwnerLiveSamples)(s),i={accidents:se.useSafety.getState().accidents.filter(e=>!(0,se.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(H.useStore.getState(),t)&&(await(0,g.archiveChefCache)('core',H.useStore.getState()),H.useStore.setState(t)),r(ae.useKitchen.getState(),a)&&(await(0,g.archiveChefCache)('kitchen',ae.useKitchen.getState()),ae.useKitchen.setState(a)),r(s,n)&&(await(0,g.archiveChefCache)('owner',s),ne.useOwner.setState(n)),r(se.useSafety.getState(),i)&&(await(0,g.archiveChefCache)('safety',se.useSafety.getState()),se.useSafety.setState(i));const o=(0,A.stripHrSamples)(A.useHr.getState());r(A.useHr.getState(),o)&&(await(0,g.archiveChefCache)('hr',A.useHr.getState()),A.useHr.setState(o));const d=(0,m.stripGpSamples)(m.useGpCalc.getState());r(m.useGpCalc.getState(),d)&&(await(0,g.archiveChefCache)('gp',m.useGpCalc.getState()),m.useGpCalc.setState(d));const u=X.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,g.archiveChefCache)('order-sheets',u),X.useOrderSheets.setState(c));const l=Y.useCardStore.getState(),_={cards:l.cards.filter(e=>!(0,f.isLiveVenue)(e.restaurantId)||!(0,h.isDemoCard)(e)),log:l.log.filter(e=>!(0,h.demoActor)(e.by))};return r(l,_)&&(await(0,g.archiveChefCache)('recipe-cards',l),Y.useCardStore.setState(_)),void await x.kv.set(ms+e,!0)}const t=t=>t.restaurantId===e&&!(0,ie.isUuid)(t.id);H.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)))})),J.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,ie.isUuid)(t.id))})),z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ne.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,ie.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,ie.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,ie.isUuid)(e.id)),leave:e.leave.filter(e=>(0,ie.isUuid)(e.id)),swaps:[]}));try{ae.useKitchen.setState(e=>(0,ae.stripKitchenExamples)(e))}catch{}ne.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,ie.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId))}));try{se.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await x.kv.set(ms+e,!0)}const bs=(e,t)=>Be({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function ks(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(z.useFloor.getState().live[e]??{}).map(([e,t])=>bs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Oe.getState().kind||Ce('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:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>bs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>z.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=>z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Is(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(te.useSetup.getState().sites[e]?.grades??te.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:()=>Ce('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=te.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));te.useSetup.getState().patch(e,{grades:i})},subscribe:t=>te.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Rs='staff-avatars',Os=new Map;let As=!1;const Cs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ds(){if(!As){As=!0;try{for(const[e,t]of Os){const a=ee.useAvatars.getState().photos[e];if(!t){a?.path&&ee.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Oe.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Rs).download(t);if(n||!s)continue;const i=await Cs(s);i.startsWith('data:image/')&&ee.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{As=!1}}}function Us(e){const t=async()=>{const t=Oe.getState().staffRef,a=t?ft.get(t)??Oe.getState().staffUuid:void 0;if(!t||!a||'staff'!==Oe.getState().kind)return;const s=ee.useAvatars.getState().photos[t];try{const n=Os.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Rs).remove([t]).catch(()=>{})};if(!s){const e=!!ee.useAvatars.getState().clears?.[t];return e&&n&&(await Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}),Os.set(t,null),i(n)),void(e&&ee.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ae({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Rs).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ka('set_staff_avatar',{p_staff_ref:t,p_path:d}),Os.set(t,d),n!==d&&i(n),ee.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ae({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ee.useAvatars.getState().photos},s=ee.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Ce('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Oe.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Os.set(t,null),ee.useAvatars.getState().doneClear(t),Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Rs).remove([e])).catch(()=>{})}});return t(),s}const Es=new Map,Ts=(0,U.create)(()=>({n:0}))},987,[5,988,932,6,832,837,833,838,989,993,994,835,996,998,999,1000,1001,1002,13,1003,1005,1008,1009,846,933,976,1010,1011,1012,1015,977,1016,1014,1019,1013,1020,1021,1022,1023,831,872,1024,1025,1028,983,883,1030,926,927,1032,1033,891,870,1035,1038,1039,1040,1041,2,1042,1043,1044,1045,1046,1047,979,981,884,863,859,1048,1051,1052]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},989,[837,34,838,5,839,846,849,990,863,870,991,992]); -__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},990,[984]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},991,[990]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},992,[990,991]); -__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},993,[]); -__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},994,[835,837,838,5,839,846,849,995,831,884]); -__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'}}]},995,[]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},996,[6,997]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},997,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},998,[846]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},999,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1000,[846]); -__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1001,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1002,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1003,[839,846,849,5,872,1004,15,1002]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1004,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1005,[838,835,837,5,839,846,849,1006,870]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1007,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1008,[839,846,849,863,1009,870]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1009,[]); -__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)))},1010,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1011,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1012,[34,1013]); -__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1013,[1010,977,1014]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1014,[1010]); -__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.3.12.171'},1015,[]); -__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1016,[1017,1018,933,977,1013]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1018,[977]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1019,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1020,[846,849,839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1021,[846,849,839]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1022,[1023]); -__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1023,[1017,933,1010,977,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1024,[]); -__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1025,[860,839,870,846,849,858,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1026,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1027,[891,1003,1026]); -__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1028,[5,860,839,1029,846,849,859]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1029,[1007]); -__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1030,[837,838,5,839,846,849,1031]); -__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1031,[984]); -__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1032,[837,984,838,835,5,839,846,849]); -__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1033,[837,838,5,839,846,849,1034]); -__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1034,[]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1035,[839,846,849,863,1036,15,870,1037]); -__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1036,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1037,[]); -__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1038,[34,839,846,849,863,13,870]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1039,[839,846,849,863,1040,870,1037]); -__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1040,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1041,[5,996,839,846,849,997]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1042,[1038]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1043,[839,846,849,863,1044,870]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1044,[]); -__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},1045,[846]); -__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(':')}`},1046,[839,846,849]); -__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{}}},1047,[236,872]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1048,[994,1049,1050,976,933]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1049,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1050,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1051,[933,987,998]); -__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1052,[1053]); -__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1053,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1054,[34]); -__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1055,[34,236,402,102,846,821,794,1054,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1056,[34,102,794,1057,821,1058,25]); -__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1057,[827,34,379,236,402,102,821,987,1058,2,872,1015,5,796,797,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1058,[1059,933,987,872,236]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1059,[]); -__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1060,[827,796,34,402,102,794,821,1043,1044,1009,1000,870,891,25]); -__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1061,[828,1062,796,827,34,281,283,364,336,402,102,426,794,821,1038,831,13,1063,1064,1000,1074,1079,1080,1083,1084,1085,1092,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1062,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1063,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1064,[34,876,1065,1066,1063]); -__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1065,[839,846,849]); -__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1066,[6,1067,1068,1069,1070,1071,1072,1073,3]); -__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1067,[]); -__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1068,[]); -__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1069,[]); -__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1070,[]); -__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1071,[]); -__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1072,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1073,[1063]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1074,[236,933,987,1075]); -__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})},1075,[499,1076,1078,1077]); -__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1076,[499,1077,1078]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1077,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1078,[1077]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1079,[933,987]); -__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1080,[34,281,236,102,794,1038,13,1081,821,1082,25]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1081,[13]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1082,[]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1083,[827,2,34,102,794,821,1038,891,13,987,1000,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1084,[13]); -__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1085,[34,1062,281,402,102,794,1086,1087,1091,1092,821,25]); -__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1086,[34,402,102,794,821,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1087,[837,34,874,891,858,872,1024,987,1088,1003,15,1090]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1088,[1089]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1089,[1090]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1090,[858]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1091,[34,872,1092,858,987,933]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1092,[]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1093,[34,1094,891,1008,1009,1000,1046,831,1097]); -__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1094,[996,1041,891,997,1095,1096]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1095,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1096,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1097,[]); -__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1098,[34,986,402,102,1099,794,874,1100,858,1101,821,25]); -__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)'}})]})}},1099,[34,281,283,364,102,1047,821,25]); -__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1100,[861,859]); -__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1101,[34,402,102,794,1100,858,821,25]); -__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1102,[34,102,794,874,877,821,25]); -__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1103,[860,34,102,794,874,1025,1028,1104,1105,877,821,25]); -__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1104,[1028,859,1100]); -__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1105,[860,877]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1106,[860,34,102,794,874,983,891,1100,858,821,25]); -__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1107,[828,827,1055,34,336,379,236,402,102,794,821,1039,1040,1000,1108,1109,987,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1108,[1075,236]); -__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1109,[839,846,849]); -__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1110,[827,996,34,379,402,102,794,821,1035,1036,891,1039,1040,1041,997,1095,987,1058,1000,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1111,[34,1035,891,1039,1112,1008,831,1036,1000,1093]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1112,[846]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1113,[996,34,1041,891,831,997,1009,1095,1000,1094]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1114,[860,34,1000,874,1100,1047]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1115,[860,1116,34,102,794,874,1100,821,1117,1106,1118,1139,1142,1098,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1116,[34,102,14,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1117,[821]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1118,[34,102,1119,821,1120,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1119,[860,1104]); -__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1120,[1121,860,34,1122,987,1124,402,102,874,1028,1119,1123,821,858,794,1125,1025,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1121,[34,859,821,794,25]); -__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1122,[34,402,102,874,1123,1124,987,1020,821,1120,794,25]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1123,[860,1104]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1124,[281,236]); -__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1125,[827,1126,1127,860,867,14,1128,1129,34,859,402,102,872,1087,874,1130,1104,858,821,864,794,1028,1025,1131,1132,1137,1106,1100,1138,1123,1122,25]); -__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1126,[34,402,412,102,1127,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1127,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1128,[34,102,794,25]); -__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1129,[34,236,402,295,102,426,821,794,1000,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1130,[878,858,877]); -__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1131,[34,402,102,878,858,821,794,25]); -__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1132,[860,877,34,102,879,1133,1134,1136,794,874,1028,983,861,867,872,1100,821,25]); -__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1133,[34,402,821,794,25]); -__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1134,[828,860,1135,34,281,236,102,1028,1104,821,794,1106,859,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1136,[34,402,102,874,861,863,821,794,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1137,[1127,1119,1123]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1138,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1139,[1140,34,102,874,1028,1123,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1140,[34,102,874,1028,1119,1141,1123,821,1003,891,872,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1141,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1142,[34,1062,1126,102,874,1028,1025,876,872,1137,861,1003,891,1026,1119,821,858,1131,1116,1128,1143,14,1140,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1143,[34,102,874,872,1137,14,1124,821,794,25]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1144,[34,102,794,1062,1092,1145,1091,1085,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1145,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1146,[34,102,794,827,1033,891,835,1147,821,1148,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1147,[1034]); -__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1148,[34,402,102,1124,987,1149,1021,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1149,[933,976,1010,1018,1013,1016,1150,1151,1152,1153,1154,1155,977]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1150,[1018,933,1016]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1151,[1018,933,976,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1152,[1010,976,1151,1013,1016,1150]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1153,[933,977]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1154,[34,1013]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1155,[933]); -__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1156,[30,34,426,102,846,872,1087,1157,25]); -__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1157,[839,846,849]); -__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()},1158,[1159]); -__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1159,[1160,858,884]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1160,[1161,877,1162,878,858,884,1163]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1161,[858]); -__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'},1162,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1163,[858]); -__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1164,[978,34,835,402,102,874,891,1165,1160,794,821,1087,1158,1032,15,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1165,[34,102,794,874,1038,884,1166,831,13,1163,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1166,[34,884]); -__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1167,[34,402,102,794,867,821,1159,1158,1164,1032,25]); -__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1168,[34,402,102,794,874,1160,858,821,1169,1165,1164,25]); -__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1169,[828,34,283,364,236,102,426,797,794,827,821,1170,25]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1170,[]); -__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1171,[827,984,1172,835,860,1173,1174,34,402,295,102,794,874,882,1175,891,993,861,867,1178,858,821,1179,1112,1087,1159,1158,1180,869,1164,1032,925,1181,1003,987,1184,988,1097,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1172,[1158,984]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1173,[827,34,102,794,874,979,891,980,981,982,831,821,25]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1174,[]); -__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1175,[827,796,34,336,402,102,821,794,874,1176,1055,882,861,863,885,1108,1177,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1176,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1177,[827,796,34,336,236,402,102,794,831,989,861,990,993,891,1003,882,821,930,991,25]); -__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])},1178,[858]); -__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1179,[928,828,827,837,5,34,1055,336,402,102,794,891,858,821,1087,1024,925,1046,1045,987,1112,1097,25]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1180,[828,34,102,794,876,831,869,821,925,25]); -__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1181,[928,828,34,395,236,402,102,925,794,926,891,1182,927,831,5,1183,987,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1182,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1183,[933,976,987,977]); -__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1184,[34,402,102,794,891,988,1097,993,987,1090,858,1124,821,25]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1185,[1172,984,34,379,102,794,891,993,867,821,1087,1164,1032,1186,25]); -__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1186,[827,835,984,34,379,236,402,102,794,1030,983,985,867,1031,821,1164,25]); -__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1187,[984,872,34,986,1188,336,402,102,1189,794,985,983,1030,821,874,1100,858,1124,987,25]); -__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1188,[5,822,823,828,236,826]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1189,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1190,[827,1030,1172,984,34,402,102,794,891,867,821,1164,1032,25]); -__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1191,[827,34,402,102,794,796,989,874,863,990,991,821,930,1192,1196,1177,25]); -__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1193,[1194,933,987,872,2,1195,1074]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1194,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1195,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1196,[34,102,797,794,989,874,992,821,930,1177,1197,25]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1197,[]); -__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1198,[827,1199,34,402,102,426,794,891,867,858,821,1200,1087,1064,25]); -__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:d,accent:u,children:a,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:d?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:u??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:u??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,a]});return d?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:d,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const d=e.key===n,u=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.note??String(u)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:d?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(u?2:0,e.a/t*c),backgroundColor:d?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,d=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',u=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,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1200,[34,402,102,794,821,5,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1201,[860,1101,1098,1116,34,102,846,794,874,1100,878,877,858,821,1106,1202,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1202,[34,794,874,1203,25]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1203,[379]); -__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1204,[827,1062,1199,34,1205,236,402,426,102,1207,1208,1209,794,831,891,867,1063,821,930,1217,1200,1087,1064,1210,872,1211,1215,25]); -__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1205,[34,402,102,1206,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1206,[34,797,25]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1207,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1208,[34,102,794,827,891,867,1207,821,25]); -__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1209,[827,1207,34,402,102,794,925,891,1097,858,821,1200,1087,1210,872,1211,1212,1214,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1210,[1062,1084,1092]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1211,[34,102,794,891,1038,1062,1092,1086,1210,821,872,1209,1085,1087,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1212,[1063,1213]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1213,[1063,1207]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1214,[34,102,794,827,1062,1063,1212,1124,821,1215,25]); -__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1215,[1062,34,402,102,794,827,891,1213,1063,1216,1124,821,1204,1087,1207,1212,1064,25]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1216,[]); -__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1217,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1179,1200,1087,1064,1159,987,1038,1061,13,1084,1063,2,25]); -__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1218,[828,891,1219,1199,1005,1006,34,1012,1013,236,402,295,102,794,874,1097,1209,1181,1220,1089,5,1221,1160,867,858,821,1200,1179,1087,925,1041,996,997,1094,1000,1096,1165,1163,1212,1214,1090,25]); -__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1219,[827,34,402,102,794,821,891,831,876,1005,1006,25]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1220,[34,102,794,891,1089,821,1097,25]); -__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1221,[34,402,102,794,891,858,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1222,[34,102,794,891,821,1087,1090,1220,1097,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1223,[34,102,1087,821,794,25]); -__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1224,[827,1062,34,402,102,794,1033,821,930,25]); -__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1225,[827,796,1226,1148,835,891,34,336,402,102,794,1033,1034,821,925,930,1227,1230,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1226,[34,1033,891,835]); -__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1227,[828,1062,796,827,1226,835,891,34,336,402,102,797,794,925,1033,1034,1228,821,930,1229,25]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1228,[]); -__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1229,[831,891,5]); -__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1230,[34,1062,379,236,102,794,891,1033,1229,1034,1231,821,930,1226,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1231,[1034]); -__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1232,[34,402,102,794,994,861,995,821,930,1233,25]); -__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1233,[828,34,336,395,402,295,102,1234,794,994,861,995,858,821,1048,25,1236]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1234,[34,1235,102,861,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1235,[2,987]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1236,[]); -__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1237,[860,1057,34,236,402,102,797,874,821,794,1238,1129,1239,25]); -__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1238,[860,34,380,236,402,102,36,821,794,796,1129,874,25,277]); -__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1239,[1240,1241,1243,1242,1244,1047,1245]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1240,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1241,[839,5,846,849,872,1047,1242]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1242,[860,236,872,1240]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1243,[34,874,861,869,867,1241,1240]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1244,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1245,[34,1241,987,933]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1246,[34,402,102,426,874,861,821,794,1237,1129,1247,25]); -__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1247,[34,102,426,874,861,1239,1047,821,794,1129,25]); -__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1248,[34,236,402,102,879,794,821,1000,1249,1250,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1249,[872,6,933,976,1000,1239,1250]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1250,[839,1251,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1251,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1252,[34,872,1249]); -__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1253,[827,796,1226,835,984,34,931,1205,395,236,402,295,102,846,794,861,1034,867,882,1033,821,1164,1158,1185,932,25]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1254,[34,402,346,102,426,821,1206,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1255,[30,34,792,872,25]); -__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1256,[860,1126,877,30,34,1257,1001,102,14,1128,1137,794,861,867,1130,858,874,987,821,1203,864,1025,1028,1104,1132,1100,1258,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1257,[827,34,236,102,25]); -__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1258,[34,402,102,878,858,1062,1259,821,794,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1259,[1062]); -__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:"ok",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"})]})]})}},1260,[30,34,336,102,1234,1261,794,861,867,874,882,821,25]); -__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])},1261,[30,34,402,874,821,794,25]); -__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1262,[30,34,794,1263,874,1248,25]); -__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])},1263,[34,402,821,794,25]); -__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1264,[837,30,34,1265,794,867,874,821,1266,1270,25]); -__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:x=!0,onPaid:f,title:g="Pay"}){const y=(0,o.useGiftCards)(b).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),_=y.find(e=>e.code===m),v=_?Math.min(_.balance,p):0,R=p-v;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:g,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),x&&y.length>0?(0,h.jsxs)(l.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:!m,onPress:()=>w(void 0)}),y.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,h.jsxs)(l.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)})]}),v?(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.ok,children:["\u2212",(0,n.gbp)(v)]})]}):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)})]})]}),T?(0,h.jsx)(t.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),f({giftCardCode:m,giftApplied:v,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1265,[34,385,102,874,867,821,794,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1266,[34,102,794,867,1267,1268,1269,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1267,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1268,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1269,[933,987,1268]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1270,[846,933,976,987,2,1267]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),r=e(_r(_d[4])),o=e(_r(_d[5])),i=e(_r(_d[6])),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),b=e(c);_r(_d[10]);var h=e(_r(_d[11])),f=e(_r(_d[12])),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),S=_r(_d[20]),T=_r(_d[21]),I=_r(_d[22]),O=_r(_d[23]),R=_r(_d[24]),A=_r(_d[25]),B=_r(_d[26]),P=_r(_d[27]),C=_r(_d[28]),_=_r(_d[29]),v=_r(_d[30]),N=_r(_d[31]);const $=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let E=!1,M=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,u.useLocalSearchParams)(),d=(0,w.useRestaurant)(e),c=s.IS_QUEUED_VENUE?(0,N.jsx)(t.default,{}):s.IS_ABBOTSFORD?(0,N.jsx)(o.default,{}):s.IS_KIRKTON?(0,N.jsx)(i.default,{}):s.IS_GREENSIDE?(0,N.jsx)(r.default,{}):l.IsolatedCustomerHome&&(s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS)?(0,N.jsx)(l.IsolatedCustomerHome,{}):(0,N.jsx)(K,{});return s.IS_ABBOTSFORD||s.IS_KIRKTON||s.IS_WILDINGS||!d?.settings.hotel?.enabled?c:(0,N.jsx)(n.HotelRequestGate,{rid:e,hotel:d.settings.hotel,children:c})}function K(){const{rid:e}=(0,u.useLocalSearchParams)(),t=(0,w.useRestaurant)(e),l=(0,w.useMenu)(e),s=(0,w.useCustomer)(),n=(0,w.useBasket)(),r=(0,w.useStore)(e=>e.startBasket),o=(0,w.useNow)(3e4),[i,H]=(0,c.useState)('All'),[K,W]=(0,c.useState)(null),[G,F]=(0,c.useState)(!1),[U,Q]=(0,c.useState)(!1),[V,Y]=(0,c.useState)('takeaway'===$?'takeaway':'main');b.default.useEffect(()=>{$&&!E&&(E=!0,'book'===$?setTimeout(()=>u.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,w.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,v.guestServer)();b.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>u.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),b.default.useEffect(()=>{C.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>u.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,w.useOrderAtTable)(e);if(b.default.useEffect(()=>{te||n.restaurantId!==e||'table'!==n.mode||w.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,n.mode,n.restaurantId,e]),!t)return(0,N.jsx)(x.Screen,{title:"Not found",children:(0,N.jsx)(x.T,{children:"Restaurant not found."})});const le=te&&n.restaurantId===t.id&&'table'===n.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ae=e=>!(e.soldOut||!e.signOff||null===e.price),ne=l.filter(e=>('All'===i||e.section===i)&&('takeaway'!==V||ae(e))),re=(0,k.hoursFor)(t,o),oe=e=>()=>u.router.push(`/customer/${t.id}${e}`),ie=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),le&&r(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>Q(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:oe('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:oe('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:oe('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:oe('/refer')},{icon:'gift',label:'Gift cards',on:oe('/gift')},{icon:'alert',label:'My allergens',sub:s.allergies.length?`${s.allergies.length} declared`:'None declared',on:()=>u.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:s.marketingOptIn[t.id]?'Opted in':'Opt in',on:oe('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:oe('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:oe('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:oe('/feedback')},{icon:'hanger',label:'Lost property',on:oe('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:oe('/merch')}];return(0,N.jsxs)(x.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,N.jsxs)(x.Row,{children:[(0,N.jsx)(m.BasketButton,{}),(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>u.router.push('/customer/profile')})]}),children:[t.fictional?(0,N.jsx)(x.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,le?(0,N.jsx)(x.Banner,{kind:"success",title:`Ordering at ${(0,d.tableNumbers)(n.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,N.jsx)(x.Card,{children:(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(f.default,{style:{flex:1},children:[(0,N.jsx)(x.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,N.jsxs)(x.Muted,{children:[re?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,N.jsx)(x.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,N.jsx)(x.Row,{wrap:!0,gap:8,children:ie.slice(2,7).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,N.jsx)(f.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ie.map(e=>(0,N.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),le?(0,N.jsx)(x.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,N.jsx)(x.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,N.jsx)(x.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,N.jsx)(x.ExampleAllergenNotice,{}),(0,N.jsxs)(x.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,N.jsx)(f.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,N.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,N.jsx)(x.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,N.jsx)(f.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,N.jsx)(A.SpecialsTab,{rid:t.id,declared:s.allergies,now:o}):null,'takeaway'===V?(0,N.jsx)(x.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==V?(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,N.jsx)(x.Chip,{label:"All",selected:'All'===i,onPress:()=>H('All')}),se.map(e=>(0,N.jsx)(x.Chip,{label:e,selected:i===e,onPress:()=>H(e)},e))]}):null,'specials'!==V?se.filter(e=>('All'===i||e===i)&&ne.some(t=>t.section===e)).map(e=>(0,N.jsxs)(f.default,{style:{gap:10},children:[(0,N.jsx)(x.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),ne.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,s.allergies),o=e.soldOut||!e.signOff||null===e.price;return(0,N.jsxs)(x.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,N.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)},children:[(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,N.jsx)(x.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,N.jsx)(x.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,j.gbp)(e.price)})]}),(0,N.jsx)(x.Muted,{numberOfLines:2,children:e.description})]}),(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,N.jsx)(x.Badge,{kind:"ok",label:e},e)),e.special?(0,N.jsx)(x.Badge,{kind:"gold",label:"Special"}):null,e.soldOut?(0,N.jsx)(x.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,N.jsx)(x.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,N.jsx)(x.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,N.jsx)(x.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,N.jsx)(p.AllergenChips,{map:e.allergens,declared:s.allergies}),K===e.id?(0,N.jsx)(p.AllergenPanel,{item:e,map:e.allergens,declared:s.allergies}):null,(0,N.jsxs)(x.Row,{gap:8,children:[(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,N.jsx)(f.default,{style:{flex:1}}),(0,N.jsx)(x.Button,{small:!0,label:o?e.soldOut?'Sold out':'Not available online':'Choose',disabled:o,onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,N.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,N.jsx)(x.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,N.jsx)(x.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,N.jsx)(T.LauncherLine,{}),te?(0,N.jsxs)(x.Sheet,{visible:U,onClose:()=>Q(!1),title:"Order at your table",children:[(0,N.jsx)(x.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,N.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:`${(0,d.tableNumbers)(e)}`,onPress:()=>{Q(!1),r(t.id,'table',e)}},e))}),(0,N.jsx)(x.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1271,[1272,1281,5,1282,1283,1284,1287,860,30,34,236,402,102,1234,1261,794,861,867,878,874,821,1288,1248,872,891,1233,994,995,1003,1289,1270,25]); -__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1272,[34,379,794,873,1273,1274,1280,874,5,6,25]); -__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1273,[34,379,102,794,996,997,1095,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1274,[6,34,933,794,1275,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1275,[6,1062,1276,1277,1278,34,102,827,794,821,11,1279,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1277,[4,11]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1278,[11]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1279,[6,933]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1280,[34,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1281,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1282,[34,102,794,1275,25]); -__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1283,[34,379,933,794,873,1273,1275,4,25]); -__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1284,[34,379,794,1273,873,1274,8,1285,25]); -__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1285,[34,102,794,1286,25]); -__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1286,[]); -__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1287,[34,794,873,1273,1274,874,9,25]); -__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1288,[34,402,102,426,794,821,1206,25]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1289,[34,102,1290,794,874,1003,1267,1270,821,25]); -__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1290,[34,102,1291,821,25]); -__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1291,[1292]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1292,[34,797,1293,1322,1323,25]); -__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1293,[1294]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1294,[1295,1296,1319,1321]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1295,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1296,[1297,1298,1299,1300,1301,1302,1303,1304,1305,1308,1312,1309,1313]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1297,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1298,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1299,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1300,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1305,[1306]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1309,[1310,1311]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1310,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1311,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1314,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1315,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1317,[1309,1297]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1318,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1319,[1320]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1321,[1320]); -__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1322,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1323,[34,797,1324,25]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1324,[]); -__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1325,[30,34,794,874,891,25]); -__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1326,[837,30,34,102,1290,794,867,874,821,1289,1270,25]); -__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1327,[837,30,34,102,1265,794,874,891,867,858,821,1266,1270,25]); -__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1328,[837,30,34,794,874,891,858,821,1289,1270,25]); -__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1329,[837,30,34,794,874,891,821,1289,1270,25]); -__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1330,[30,34,794,858,1160,1331,874,821,25]); -__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}},1331,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1332,[30,1100,34,402,102,794,858,874,821,25]); -__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 l=_r(d[0]),t=_r(d[1]),n=_r(d[2]),s=e(n),a=_r(d[3]),o=_r(d[4]),r=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),p=_r(d[15]),k=_r(d[16]);function f(){const e=(0,y.useBasket)(),f=(0,y.useRestaurant)(e.restaurantId??void 0),w=(0,y.useAllMenu)(e.restaurantId??void 0),v=(0,y.useCustomer)(),C=(0,y.useOrders)(f?.id),S=(0,y.useStore)(e=>e.setLineQty),T=(0,y.useStore)(e=>e.overrideLine),B=(0,y.useStore)(e=>e.startBasket),P=(0,y.useNow)(15e3),[$,O]=(0,n.useState)(null),[I,M]=(0,n.useState)(!1),[N,F]=(0,n.useState)(''),[L]=(0,n.useState)(()=>(0,o.startForm)()),[R,z]=(0,n.useState)(''),[A,D]=(0,n.useState)(v.phone??''),[E,Y]=(0,n.useState)(v.email??''),[_,q]=(0,n.useState)(!1),H=(0,y.useOrderAtTable)(e.restaurantId??void 0);s.default.useEffect(()=>{H||'table'!==e.mode||y.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[H,e.mode]);const[G,K]=(0,n.useState)(null),[Q,J]=(0,n.useState)(!1),U=(0,n.useMemo)(()=>(0,j.linesFromBasket)(e,w,v.allergies),[e,w,v.allergies]);if(!f||!e.lines.length)return(0,k.jsxs)(u.Screen,{title:"Your basket",children:[(0,k.jsx)(u.Muted,{children:"Your basket is empty."}),(0,k.jsx)(u.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const V=H&&'table'===e.mode,W=(0,m.takeawaySlots)(f,C,P),X=U.reduce((e,l)=>e+l.unitPrice*l.qty,0),Z=U.some(e=>e.contains.length&&!e.overridden),ee=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff}),le=!V&&!$,te=!V&&f.settings.takeawayPaused,ne=(0,p.ukPhone)(A),se=!Z&&!ee.length&&I&&!le&&!te&&(V||ne.ok&&(0,p.emailOk)(E)),ae=async e=>{const l=await y.repo.orders.placeFromBasket({slotTime:V?void 0:$,tip:0,giftCardCode:e?.giftCardCode,notes:N,paidNow:!V,phone:V?void 0:ne.pretty,email:V?void 0:E.trim()||void 0});(0,o.rememberGuard)(l.id,(0,o.guardFor)({...L,hp:R})),q(!1),t.router.replace(`/customer/order/${l.id}`)},oe=e.lines.find(e=>e.key===G),re=oe?U[e.lines.indexOf(oe)]:void 0;return(0,k.jsxs)(u.Screen,{title:"Your basket",subtitle:`${f.name} \xb7 ${V?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,k.jsxs)(r.default,{style:{gap:8},children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.T,{weight:"semibold",children:"Subtotal"}),(0,k.jsx)(u.T,{weight:"bold",size:20,colour:x.colours.gold,children:(0,h.gbp)(X)})]}),Z?(0,k.jsx)(u.T,{size:14,colour:x.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):I?le&&!te?(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Choose a collection time."}):null:(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Confirm your allergies to continue."}),V?(0,k.jsx)(u.Button,{label:"Send order to the kitchen",disabled:!se,onPress:()=>ae(),testID:"send-table-order"}):(0,k.jsx)(u.Button,{label:`Continue to payment \xb7 ${(0,h.gbp)(X)}`,disabled:!se,onPress:()=>q(!0),testID:"checkout"})]}),children:[(V||e.tableNo,null),V?(0,k.jsx)(u.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,f.fictional?null:(0,k.jsx)(u.ExampleAllergenNotice,{}),U.map((l,t)=>{const n=e.lines[t],s=l.contains.length&&!l.overridden;return(0,k.jsxs)(u.Card,{highlight:l.contains.length?x.colours.red:l.may.length?x.colours.amber:void 0,children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(r.default,{style:{flex:1,paddingRight:8},children:[(0,k.jsx)(u.T,{weight:"semibold",children:l.name}),l.choices.length?(0,k.jsx)(u.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,k.jsxs)(u.Muted,{children:["Note: ",l.notes]}):null]}),(0,k.jsx)(u.T,{weight:"semibold",children:(0,h.gbp)(l.unitPrice*l.qty)})]}),s?(0,k.jsxs)(u.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:[(0,k.jsx)(u.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${v.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} (${(0,c.severityLabel)(e.severity)})`).join(', ')}.`}),(0,k.jsxs)(u.Row,{gap:8,style:{marginTop:6},children:[(0,k.jsx)(u.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{J(!1),K(n.key)}})]})]}):l.contains.length?(0,k.jsx)(u.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,k.jsx)(u.Banner,{kind:"warn",title:`May contain ${l.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ee.includes(n)?(0,k.jsx)(u.Badge,{kind:"amber",label:"No longer available online \u2014 please remove"}):null,(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Stepper,{value:n.qty,onChange:e=>S(n.key,e),min:1,label:l.name})]})]},n.key)}),(0,k.jsx)(u.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${f.id}`)}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsxs)(u.H2,{children:["Collection time \u2014 ",(0,b.niceDate)(P)]}),te?(0,k.jsx)(u.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===W.length?(0,k.jsx)(u.Banner,{kind:"warn",children:"No collection slots left today."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u.Muted,{children:["15-minute slots, max ",f.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:W.slice(0,16).map(e=>(0,k.jsx)(u.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>O(e.time.toISOString())},e.label))})]})]}),(0,k.jsxs)(u.Card,{highlight:I?void 0:x.colours.amber,children:[(0,k.jsx)(u.H2,{children:"Confirm allergies for this order"}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:v.allergies.length?v.allergies.map(e=>(0,k.jsx)(u.Badge,{kind:"red",label:`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`},e.allergen)):(0,k.jsx)(u.Muted,{children:"No allergies declared on your profile."})}),(0,k.jsx)(u.Toggle,{label:v.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:I,onChange:M}),(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsx)(u.H2,{children:"Your details"}),(0,k.jsx)(u.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:A,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!ne.ok&&A?(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:ne.error}):null,(0,k.jsx)(u.Field,{label:"Email (optional)",value:E,onChangeText:Y,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,p.emailOk)(E)?null:(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,k.jsx)(u.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,k.jsx)(u.Field,{label:"Order notes (optional)",value:N,onChangeText:F,placeholder:"e.g. cutlery please"}),V?(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>B(f.id,'takeaway')}):null,(0,k.jsx)(i.MockPay,{visible:_,onClose:()=>q(!1),amount:X,restaurantId:f.id,onPaid:e=>ae({giftCardCode:e.giftCardCode}),title:"Pay for your takeaway"}),(0,k.jsxs)(u.Sheet,{visible:!!oe,onClose:()=>K(null),title:"Allergy override",children:[re?(0,k.jsx)(u.Banner,{kind:"danger",title:`${re.name} contains ${re.contains.map(c.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,k.jsx)(u.Toggle,{label:"I understand and want to add it anyway",value:Q,onChange:J}),(0,k.jsx)(u.Button,{kind:"danger",disabled:!Q,label:"Confirm override",onPress:()=>{oe&&re&&T(oe.key,re.contains),K(null)}})]}),(0,k.jsx)(a.Honeypot,{value:R,onChange:z})]})}},1333,[860,30,34,1257,1001,102,1265,794,861,867,1130,858,874,831,821,864,25]); -__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1334,[30,34,102,1261,794,861,878,874,821,1288,5,25]); -__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 f}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},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]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,s.useLocalSearchParams)(),r=(0,b.useOrder)(e),f=(0,b.useRestaurant)(r?.restaurantId),[C,S]=(0,l.useState)(0),[k,T]=(0,l.useState)(''),[v,P]=(0,l.useState)(!1),[M,$]=(0,l.useState)(!1),[R,A]=(0,l.useState)(1),[I,N]=(0,l.useState)(0),[O,B]=(0,l.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(c.Screen,{title:"Order",children:(0,j.jsx)(c.T,{children:"Order not found."})});const H='takeaway'===r.type?x:w,_=Math.max(0,H.findIndex(([e])=>e===r.status)),D=Math.round(r.subtotal*I/100),F='table'===r.type?r.subtotal+(r.split?r.tip:D):r.total,q=F-r.paid,L=r.split?.ways??O,W=r.split?.paidShares??0,Y=Math.ceil(F/L),E='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(c.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,p.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(c.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Status"}),H.map(([e,t],s)=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=_?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(c.T,{weight:s===_?'semibold':'regular',colour:s<=_?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(c.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,p.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(c.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||E?null:(0,j.jsxs)(c.Row,{gap:8,children:[(0,j.jsx)(c.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>b.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(c.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>b.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(c.T,{children:(0,h.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(c.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(c.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(u.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Subtotal"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Of which gift card"}),(0,j.jsxs)(c.T,{colour:y.colours.ok,children:["\u2212",(0,h.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Tip"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.tip)})]}):null,(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.gold,children:(0,h.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(c.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(F)," \xb7 split ",L," way",L>1?'s':''," \xb7 ",(0,h.gbp)(Y)," each"]}),(0,j.jsxs)(c.T,{children:["Shares paid: ",W," of ",L," \xb7 remaining ",(0,h.gbp)(q)]}),L>1?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{children:"Shares to pay now"}),(0,j.jsx)(c.Stepper,{value:R,onChange:A,min:1,max:L-W,label:"shares"})]}):null,(0,j.jsx)(c.Button,{label:`Pay ${L>1?`${R} share${R>1?'s':''}`:'bill'} \xb7 ${(0,h.gbp)(Math.min(q,Y*R))}`,onPress:()=>$(!0),testID:"pay-bill"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(c.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(c.Chip,{label:e?`${e}%`:'No tip',selected:I===e,onPress:()=>N(e)},e))}),(0,j.jsx)(c.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(c.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(r.subtotal+D),O>1?` \xb7 ${(0,h.gbp)(Math.ceil((r.subtotal+D)/O))} each`:'']}),(0,j.jsx)(c.Button,{label:"Get the bill",onPress:()=>b.repo.orders.setSplit(r.id,O,D),testID:"get-bill"})]})]}):null,!E||r.rated||v?null:(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(c.H2,{children:"How was everything?"}),(0,j.jsxs)(c.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(i.Stars,{value:C,onChange:S}),C?(0,j.jsx)(c.Field,{label:"Anything to add? (optional)",value:k,onChangeText:T}):null,(0,j.jsx)(c.Button,{label:"Send feedback",disabled:!C,onPress:()=>{b.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:C,comment:k,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),P(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(c.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,E?(0,j.jsx)(c.Button,{kind:"secondary",label:"View stamp card",onPress:()=>s.router.push(`/customer/${f.id}/loyalty`)}):null,(0,j.jsx)(o.MockPay,{visible:M,onClose:()=>$(!1),amount:Math.min(q,Y*R),restaurantId:f.id,title:`Pay \u2014 ${(0,t.tableNumbers)(r.tableNo)}`,onPaid:e=>{b.repo.orders.payTable(r.id,{shares:R,giftCardCode:e.giftCardCode}),$(!1),A(1)}})]})}},1335,[860,30,34,102,1265,1263,794,861,867,858,874,821,25]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1336,[860,1270,30,34,102,794,861,867,858,874,879,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1337,[30,34,872,25]); -__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1338,[837,30,34,794,874,5,1270,25]); -__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1339,[30,34,794,1340,1174,1270,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1340,[827,860,34,102,794,861,867,1174,1341,874,821,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1341,[933,987,1174]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1342,[30,34,872,1343,1407,25]); -__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1343,[1161,796,5,6,1344,828,853,1121,860,1160,1345,1346,1347,1118,1142,1348,1349,1354,1355,1356,872,1357,1173,979,1129,1358,34,1098,1201,1047,1114,1156,1359,395,380,402,295,102,426,36,794,1248,1252,873,861,858,874,821,1117,891,1125,1087,1028,1104,1134,1360,1133,1361,1368,1370,1373,1376,1372,1377,1379,1380,1139,1122,1123,878,1384,1237,1385,1247,1239,1025,1390,1398,1399,1101,1141,1401,1402,1403,1097,1188,1404,1187,1180,869,1405,1406,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1345,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1346,[1026,1087]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1347,[34,102,1104,794,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1348,[860,34,102,794,874,1174,821,25]); -__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1349,[34,395,402,426,102,1290,794,1188,796,1028,1350,1351,1353,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1350,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1351,[34,395,402,295,412,102,426,796,794,821,1352,1353,25]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1352,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1353,[1024,872,1352,933,987]); -__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1354,[846]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1355,[828,34,379,395,402,102,794,1188,821,25]); -__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1356,[34,236,402,102,794,821,891,1003,858,1097,25]); -__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1357,[828,827,34,236,402,295,102,794,1173,874,979,831,981,982,872,980,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1358,[828,34,102,821,794,25]); -__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1359,[34,102,797,821,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1360,[]); -__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1361,[828,796,827,1121,860,1129,34,236,402,295,426,102,859,821,794,1362,1363,1028,891,1133,1365,987,872,25]); -__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1362,[828,860,34,1363,102,859,821,794,1134,1364,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1363,[859]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1364,[1363,859]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1365,[34,385,295,102,859,1366,1367,821,796,827,794,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1366,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1367,[1366,1024,872,933,987]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1368,[34,236,402,102,821,794,1188,1369,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1369,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1370,[828,860,1122,34,281,236,295,102,1135,874,1028,1104,14,858,1123,1371,821,794,1372,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1371,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1372,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1373,[5,828,34,283,336,236,402,102,426,821,873,794,1029,1000,1354,1374,2,1375,1376,874,858,25]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1374,[236]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1376,[34,846,933,987,1375]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1377,[860,14,1028,1378]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1378,[861]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1379,[34,102,797,821,25]); -__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1380,[1381,860,1122,1028,34,102,794,1125,874,1383,1377,1123,858,1120,1139,1140,1141,821,1346,25]); -__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1381,[34,379,402,102,874,1003,891,1026,1382,872,821,794,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1382,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1383,[1028,1104]); -__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1384,[1381,828,1122,827,860,1160,1118,1139,858,34,1106,236,402,295,102,794,1125,1372,874,1028,861,1116,1104,1331,821,1346,25]); -__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1385,[827,34,236,402,102,794,874,1028,1386,821,1387,1389,25]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1386,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1387,[846,874,1028,1386,1388,1389]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1388,[860]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1389,[236,1388]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1390,[860,34,1205,1188,402,102,1025,1028,878,858,821,794,1391,1394,25]); -__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1391,[1392,870,860,34,281,395,402,295,102,874,1025,1028,1393,858,821,1055,794,1394,1395,987,1346,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1392,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1393,[878,858,877]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1394,[5,1028,933,987]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1395,[846,933,987,1396,2,1397]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1396,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1397,[15]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1399,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1400,[1104]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1401,[860,1378]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1402,[34,402,102,794,1401,821,1359,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1403,[34,102,925,794,1188,858,821,25]); -__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1404,[34,1188,402,102,426,794,25]); -__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1405,[828,1062,827,2,1188,34,402,102,426,794,821,891,997,858,1000,1395,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1406,[34,1035,891,1008,831,1036,1000,1395,1093]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1407,[5,828,873,34,236,402,102,426,987,821,794,1354,1408,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1408,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1409,[30,34,872,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1410,[30,34,872,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1411,[30,34,1412,872,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1412,[34,872,1413,1546,25]); -__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,"canSignOffHours",{enumerable:!0,get:function(){return he}}),_e.barTabsFor=me,_e.signOffSpeech=be,_e.OwnerApp=function(){return H.IS_OWNER_DESKTOP?(0,ue.jsx)(de.DesktopGate,{phone:(0,ue.jsx)(xe,{})}):(0,le.isDesktop)()?(0,ue.jsx)(ce.DesktopShell,{}):(0,ue.jsx)(xe,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),j=_r(d[14]),w=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=e(_r(d[20])),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),I=_r(d[24]),L=_r(d[25]),O=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]),$=_r(d[32]);_r(d[33]);var D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),z=_r(d[39]),F=_r(d[40]),U=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]),Y=_r(d[45]);_r(d[46]);var J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]),de=_r(d[60]),ce=_r(d[61]),ue=_r(d[62]);const fe=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ge=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],he=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function me(e,t){return ge.filter(t=>!t.can||t.can(e)).map(e=>'orders'===e.id&&t?{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'}:'forecast'===e.id?{id:'rota',label:'Rota',icon:'rota'}:e)}function be(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const pe={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function xe(){const{rid:e,r:le,role:de,today:ce,now:xe,meId:je,me:we}=(0,_.useCtx)(3e4);(0,b.useTipsPosted)(e,ce,'staff'!==de);const Se=(0,_.useSignedIn)();(0,c.useSoldOutLink)(!0,(Se?.name??we).replace(' (example)',''));const ye=(0,I.useOrders)(e),[Ae,ke]=(0,j.useState)('home'),[Re,Ce]=(0,j.useState)(null),[ve,Te]=(0,j.useState)(!1),Ie=(0,n.useLiveVenue)(),[Le,Oe]=(0,j.useState)(!1),Ee=(0,j.useRef)(null);(0,j.useEffect)(()=>{(0,_.ensureAttendance)(ce,xe),(0,Q.ensureChat)(xe)},[ce]),globalThis.__ccNow=xe.getTime();const Be=(0,Q.useChatUnread)().total,Pe=(0,j.useRef)({t:'home',s:null});Pe.current={t:Ae,s:Re};const Ne=(0,j.useRef)([]),$e=(0,l.useScrollMemory)(Ee),De=(0,j.useCallback)((e,t=null)=>{const s=Pe.current;s.t===e&&s.s===t||(Ne.current=[...Ne.current,{...s,y:$e.leave()}].slice(-30),$e.restore(0)),ke(e),Ce(t)},[]),Me=(0,j.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Pe.current;let t=Ne.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Ne.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return $e.leave(),ke(s.t),Ce(s.s),$e.restore(s.y??0),!0},[]);(0,u.useWebBack)(Me);const He=(0,u.useInnerBackShown)();(0,j.useEffect)(()=>(re.useVoiceNav.setState({go:De}),()=>re.useVoiceNav.setState({go:null})),[De]),(0,j.useEffect)(()=>{f.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchOwner=L.useOwner)},[De]),(0,j.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Me);return()=>e.remove()},[Me]),(0,j.useEffect)(()=>{const e=ge.find(e=>e.id===Ae);e?.can&&!e.can(de)&&De('home');const t=(0,K.pageFor)(Re);t?.can&&!t.can(de)&&Ce(null)},[de]);const We='more'===Ae?(0,K.pageFor)(Re):void 0,Ve=ye.filter(e=>(0,B.LIVE)(e)&&'new'===e.status).length,{unread:ze,list:Fe,read:Ue}=(0,J.useNotifications)();(0,se.useAlertWatcher)(e,{nag:'staff'!==de}),(0,oe.useReviewAlerts)(e),(0,ne.useScheduledNotices)({rid:e,staffId:Se?.id??'',name:we,onOpen:e=>'bookings'===e?De('bookings'):'chat'===e?De('chat'):De('more',e)}),(0,ae.useOffRotaAlerts)({enabled:'staff'!==de&&!!Se});const qe=Se?.role??de,Ge='owner'===qe?'OWNER':'manager'===qe?'MANAGER':'STAFF',Ke=(0,se.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,se.isUnread)(t,s)&&!(0,se.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),Ye=(0,se.useAlerts)(t=>t.todoSeen[e]),Je=Math.max(0,ze-Fe.filter(e=>!Ue[e.id]&&(Ye??[]).includes(e.id)).length)+Ke;(0,se.useAlertSeenSync)(e),(0,j.useEffect)(()=>{G.useShellBadges.setState({notifCount:Je})},[Je]);const Qe=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Xe=he(de),Ze=(0,r.useOutstanding)(),et=Ze.days.length+Ze.requests,tt=me(de,Xe),st='more'===Ae&&'signoff'===Re?'signoff':'more'===Ae&&'rota'===Re?'rota':'forecast'===Ae||'orders'===Ae&&Xe?'more':Ae,ot=t.IS_ISOLATED_VENUE?[{id:e,name:le.name,place:le.location||le.address||''}]:fe,rt=ot.find(t=>t.id===e)??ot[0],nt=Se?.ownerAccess&&'owner'!==Se.role?'owner privileges':Se?.managerAccess&&'staff'===Se.role?'manager privileges':'',at=(0,M.ownerHomeLayout)(de,Se);(0,k.default)().width;return(0,ue.jsxs)(C.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,ue.jsxs)(R.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,ue.jsxs)(R.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>De('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,ue.jsx)(y.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:Je?`Notifications, ${Je} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>De('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),Je?(0,ue.jsx)(R.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(v.T,{size:10,weight:"bold",children:Je})}):null]})}),(0,ue.jsx)(Z.VoiceSlot,{size:44})]}),(0,ue.jsx)(R.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ue.jsx)(R.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,ue.jsx)(y.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${we}. Account and role${nt?`, ${nt}`:''}`,disabled:'owner'!==H.APP_VARIANT,onPress:()=>Oe(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ue.jsxs)(v.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ue.jsx)(P.StaffAvatar,{id:je,size:24,ring:!1}),(0,ue.jsxs)(R.default,{style:{flexShrink:1},children:[(0,ue.jsxs)(v.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[Se?`${we} \xb7 ${Se.level??L.ROLE_LABEL[Se.role]}`:`${we} \xb7 ${L.ROLE_LABEL[de]}`,'owner'===H.APP_VARIANT?' \u25be':'']}),nt?(0,ue.jsx)(v.Muted,{center:!1,size:10,numberOfLines:1,children:nt}):null]})]})})})}),(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>Te(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,ue.jsx)(T.VenueHeaderBlock,{rid:e,name:le.name,badge:Ge,place:`${'staff'===de?'Staff preview \xb7 ':'Managers \xb7 '}${rt.place}`})}),de!==(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner')&&'owner'===H.APP_VARIANT?(0,ue.jsx)(y.default,{onPress:()=>L.useOwner.getState().setPreviewRole(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,ue.jsx)(v.T,{size:12,colour:O.colours.gold,children:'staff'===de?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[de].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`})}):null]}),(0,ue.jsxs)(A.default,{ref:Ee,...$e.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ue.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Re||He),onBack:Me,title:We?We.title:'bookings'===Ae&&'waitlist'===Re?'Waitlist':'staff'===de&&'home'===Ae?'Staff app preview':pe[Ae]}),'home'===Ae&&Se&&'staff'===Se.role&&'owner'===H.APP_VARIANT?(0,ue.jsxs)(R.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,ue.jsx)(v.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,ue.jsx)(v.Button,{label:"Clock in and my shifts",onPress:()=>De('more','clock')})]}):null,'home'!==Ae||at?null:(0,ue.jsx)(a.WhoBar,{}),'home'===Ae&&!at&&Se?(0,ue.jsx)(ie.MyShiftCard,{go:De}):null,'home'===Ae&&!at&&Se?(0,ue.jsx)(h.MyTasksToday,{rid:e,staffId:Se.id,name:Se.name,onShift:(0,p.shiftNow)(Se.id,Date.now()).on}):null,'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TodaysTipsCard,{rid:e,today:ce}),'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TipsPotCard,{rid:e,today:ce}),'home'===Ae?'staff'===de?(0,ue.jsx)(z.StaffHome,{go:De}):(0,ue.jsx)(D.Dashboard,{go:De,ownerHome:at}):null,'orders'===Ae?(0,ue.jsx)(Y.Orders,{}):null,'bookings'===Ae?(0,ue.jsx)(E.Bookings,{go:De,only:'waitlist'===Re?'waitlist':void 0}):null,'forecast'===Ae?(0,ue.jsx)(F.Forecasts,{go:De}):null,'chat'===Ae?(0,ue.jsx)(Q.Chat,{go:De}):null,'more'===Ae?We?(0,ue.jsx)(We.C,{go:De}):(0,ue.jsx)(K.MoreMenu,{go:De}):null]}),(0,ue.jsx)(x.SeatAllergenReminder,{rid:e}),'staff'!==de?(0,ue.jsx)(te.PrintHost,{rid:e}):null,'staff'!==de?(0,ue.jsx)(ee.AlertHost,{variant:"managers",rid:e,me:we,onOpen:e=>De('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,ue.jsx)(X.AssistantSheet,{}),(0,ue.jsx)(q.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:st,onPress:e=>'signoff'===e?De('more','signoff'):'rota'===e?De('more','rota'):De(e),tabs:tt.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?be(Ze.days.length,Ze.requests):'more'===e.id&&Xe&&Ve?`More, ${Ve} new order${Ve>1?'s':''} in Orders`:void 0,badge:'chat'===e.id&&Be?{text:String(Be),bg:O.colours.red}:'bookings'===e.id&&Qe?{text:String(Qe),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&Ve?{text:String(Ve),bg:O.colours.red}:'signoff'===e.id&&et?{text:String(et),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Xe&&Ve?{text:String(Ve),bg:O.colours.red,testID:'more-orders-badge'}:null}))}),(0,ue.jsx)(S.default,{visible:ve,transparent:!0,animationType:"fade",onRequestClose:()=>Te(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Te(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Your venues"}),ot.filter(e=>!Ie||'saltmarsh'!==e.id).map(t=>(0,ue.jsx)(y.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),Te(!1),De('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,ue.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(v.T,{weight:"medium",children:t.name}),(0,ue.jsx)(v.Muted,{children:t.place})]}),t.id===e?(0,ue.jsx)(v.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,ue.jsx)(v.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${le.name}.`:Ie?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,ue.jsx)(S.default,{visible:Le,transparent:!0,animationType:"fade",onRequestClose:()=>Oe(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Oe(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[Se?(0,ue.jsxs)(v.Row,{gap:10,children:[(0,ue.jsx)(P.StaffAvatar,{id:Se.id,size:44}),(0,ue.jsxs)(R.default,{style:{flex:1},children:[(0,ue.jsxs)(v.T,{weight:"semibold",children:["Signed in as ",Se.name]}),(0,ue.jsx)(v.Muted,{children:(0,$.levelJob)(Se.level??L.ROLE_LABEL[Se.role],Se.job)})]})]}):(0,ue.jsxs)(R.default,{style:{gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,ue.jsx)(v.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,ue.jsx)(N.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!Se?null:(0,ue.jsx)(v.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,$.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,ue.jsx)(v.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!Se||(0,_.clampRole)(e,Se.ownerAccess?'owner':Se.managerAccess?'manager':Se.role)===e).map(e=>(0,ue.jsx)(v.Button,{kind:e===de?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),Oe(!1)}},e))]})})}),(0,ue.jsx)(W.OnboardingHost,{go:De}),(0,ue.jsx)(V.CoachHost,{})]})}},1413,[5,828,987,1209,1235,1223,1054,979,1055,2,1060,1061,1093,1114,34,373,395,402,295,426,102,36,794,873,874,891,821,1414,1200,1087,925,1423,1003,236,1432,13,872,1464,1470,1471,1472,1206,1254,1473,1456,1474,1475,1454,1179,1489,1156,1237,1385,1239,1252,1477,1111,1113,1222,1542,1543,1562,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1414,[5,1415,1122,11,1416,827,837,1139,1140,1118,1142,1417,1137,1141,1401,1402,1087,1346,1026,1116,14,1143,1419,1248,1420,1390,1106,1100,1117,34,102,794,1359,874,861,867,858,1331,821,1200,1125,1028,1421,1086,1180,1422,1239,987,1202,1398,878,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1415,[34,794,25]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1416,[6,34,102,794,987,1279,25]); -__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1417,[34,402,102,1418,987,933,821,794,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1418,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1419,[827,5,34,379,236,102,794,876,14,867,1031,933,821,1203,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1420,[34,402,1188,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1421,[34,102,874,1028,794,821,25]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1422,[34,102,879,874,864,821,794,25]); -__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1423,[5,1424,1425,1426,1427,1428,34,236,41,102,872,1429,1003,821,1431,794,987,2,1096,1002,891,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1424,[34,102,873,794,5,6,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1425,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1426,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1427,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1428,[34,102,873,794,25]); -__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1429,[34,295,102,794,873,821,1430,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1430,[]); -__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1431,[929,828,34,1096,336,236,402,295,41,102,872,926,891,831,987,1003,15,793,821,925,794,25]); -__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.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:b,now:F,role:oe,me:ae,today:ne}=(0,A.useCtx)(5e3),ie=(0,p.useOrders)(n),re=(0,p.useBookings)(n),de=(0,p.useWaitlist)(n),ue=(0,p.useEvents)(n),ge=(0,p.useRatings)(n),xe=(0,k.useOwner)(e=>e.staff),ye=(0,k.useOwner)(e=>(0,k.liveAttendance)(e.attendance)),be=(0,k.useOwner)(e=>e.shifts),fe=(0,L.useRealHistory)(n,F),me=(0,o.useMemo)(()=>(0,t.forecastToday)(b,re,ie,ue,F,fe??void 0),[b,re,ie,ue,fe,F.getTime()/6e4|0]),je=(0,N.useExamples)(),pe=(0,P.useCashUp)(e=>e.cashUps),ke=re.filter(e=>e.date===ne),we=ie.filter(D.LIVE),$e=de.filter(e=>'waiting'===e.status||'notified'===e.status),ve=ke.filter(e=>['seated','finished'].includes((0,I.shownStatus)(e))).reduce((e,s)=>e+s.partySize,0),Ce=(0,te.coversSplit)(ke,ne),Ie=Ce.walkIns,Te=Ce.bookings,Be=we.filter(e=>(0,q.chainNeedsAction)(e,re)),De=ke.filter(e=>['confirmed','seated'].includes(e.status)&&(0,q.bookingNeedsAction)(e,we)),Ae=we.flatMap(e=>(0,v.readinessFor)(e,b,F).map(s=>({...s,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Se=me.nextHour,Le=(0,D.busyLevel)(Se?.coversHigh??0,me.busy.busy),Ne=(0,D.restOfDayLevel)(me,b),Pe=ie.filter(e=>e.paid>0&&!!e.createdAt&&(0,C.ymd)(new Date(e.createdAt))===ne).reduce((e,s)=>e+s.paid,0),Me=(0,H.tradingDay)(F),Fe=je?(0,S.revenueHistory)(b,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Oe=je?{today:186e3+Pe,last:Fe?{date:(0,C.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,W.takingsToday)(pe,n,Me,Pe),Re=k.CAN.takings(oe)&&(!(0,R.isLive)()||(0,R.can)('takings.view')),He=(0,o.useMemo)(()=>(0,S.insights)(b,re,ie,ue,ge,F,ve),[b.id,re.length,ge.length,ve]),We=((0,A.weekday)(F),ye.filter(e=>e.date===ne&&e.in&&!e.out)),Ee=(0,J.useFrontDoor)(ne),ze=(0,h.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,r.useTravelDay)('owner',ne),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,M.canSeeMonthTakings)(oe,qe,{inStaffApp:Ye,live:(0,R.isLive)()}),Qe=(0,O.homeSetupNagsHidden)(n),Ve=(0,k.useOwner)(e=>e.socialPosts.reduce((e,s)=>e+('awaiting approval'===s.status?1:0),0)),[Xe,Ze]=(0,o.useState)(!1),Je=ae.replace(' (example)',''),es=k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(r.DayView,{rid:n,day:Ue,today:ne,app:"owner"})]}):a?(0,le.jsxs)(m.default,{style:{gap:12},testID:"owner-home",children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Re&&Oe.show?(0,le.jsx)(j.Row,{wrap:!0,gap:10,children:(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})})}):null,(0,le.jsx)(X.TodaysTipsCard,{rid:n,today:ne}),(0,le.jsx)(X.TipsPotCard,{rid:n,today:ne}),k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),qe&&'owner'!==qe.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,le.jsx)(V.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,Z.shiftNow)(qe.id,Date.now()).on}):null,k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]}):(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,Re&&Oe.show?(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=de,_e.MonthTakingsCard=ce,_e.WalkInSplitCard=he;var s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),o=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),y=_r(_d[12]),b=e(_r(_d[13])),f=e(_r(_d[14])),m=e(_r(_d[15])),j=_r(_d[16]),p=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),I=_r(_d[23]),T=_r(_d[24]),B=_r(_d[25]),D=_r(_d[26]),A=_r(_d[27]),S=_r(_d[28]),L=_r(_d[29]),N=_r(_d[30]),P=_r(_d[31]),M=_r(_d[32]),F=_r(_d[33]),O=_r(_d[34]),R=_r(_d[35]),H=_r(_d[36]),W=_r(_d[37]),E=_r(_d[38]),z=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),q=_r(_d[42]),Y=_r(_d[43]),_=_r(_d[44]),K=_r(_d[45]),Q=_r(_d[46]),V=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),se=_r(_d[52]),te=_r(_d[53]),le=_r(_d[54]);const oe=18,ae=18,ne=150,ie=34;function re(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const s=e.length,t=[],l=[];for(let l=0;l9){const n=3/Math.sqrt(a);l[e]=n*s*t[e],l[e+1]=n*o*t[e]}}let o=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let t=0;toe+(s-1)/Math.max(1,e-1)*t,o=[1,5,10,15,20,25].filter(s=>s=36)&&a.push(e);for(;a.length&&l(e)-l(a[a.length-1])<36;)a.pop();return[...a,e]}function ce({rid:e,today:s}){const t=(0,P.useCashUp)(e=>e.cashUps),[l,i]=(0,o.useState)(s.slice(0,7)),[r,d]=(0,o.useState)(0),[c,u]=(0,o.useState)(null),h=(0,o.useMemo)(()=>(0,M.monthTakings)(t,e,l,s),[t,e,l,s]),x=(0,o.useMemo)(()=>(0,M.firstTakingsMonth)(t,e),[t,e]),y=!!x&&xoe+(e-1)/Math.max(1,k-1)*w,I=e=>$-e/v*128,T=[];h.days.forEach((e,s)=>{if('recorded'!==e.state)return;const t={x:C(e.day),y:I(e.value)};s&&'recorded'===h.days[s-1].state?T[T.length-1].push(t):T.push([t])});const D=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),S=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===s):void 0)??A??D[D.length-1],L=e=>{const s=D.findIndex(e=>e.date===S?.date),t=D[Math.max(0,Math.min(D.length-1,s+e))];t&&(u(t.date),b.default.announceForAccessibility?.(N(t)))},N=e=>`${(0,M.longDay)(e.date)}, ${'recorded'===e.state?(0,M.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,O=h.current?`so far in ${h.month}`:`in ${h.month} ${l.slice(0,4)}`,R=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,M.monthName)((0,M.addMonths)(l,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,H=h.recorded?`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. ${(0,M.poundsWhole)(h.total)} ${O}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,M.longDay)(h.best.date)}, ${(0,M.poundsWhole)(h.best.value)}.${R?` ${R.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,W=r?de(k,r):[],E=(e,s,t,o,a)=>(0,le.jsx)(f.default,{testID:a,accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{disabled:!t},disabled:!t,onPress:()=>{i((0,M.addMonths)(l,o)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:t?e?.6:1:.25}),children:(0,le.jsx)(j.T,{size:24,colour:B.colours.gold,center:!0,children:e})});return(0,le.jsx)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(m.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),y||p?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[E('\u2039',`Previous month, ${(0,M.monthName)((0,M.addMonths)(l,-1))}`,y,-1,'mt-prev'),(0,le.jsxs)(j.T,{center:!0,colour:B.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",l.slice(0,4)]}),E('\u203a',`Next month, ${(0,M.monthName)((0,M.addMonths)(l,1))}`,p,1,'mt-next')]}):null,(0,le.jsx)(m.default,{accessible:!0,accessibilityLabel:H,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(j.T,{size:38,weight:"bold",colour:B.colours.gold,center:!0,testID:"mt-total",children:(0,M.poundsWhole)(h.total)}),(0,le.jsx)(j.T,{center:!0,colour:B.colours.goldLight,children:O}),(0,le.jsxs)(j.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,M.shortDay)(h.best.date)," \xb7 ",(0,M.poundsWhole)(h.best.value)]}),R?(0,le.jsx)(j.Muted,{center:!0,testID:"mt-vs",children:R}):null]}):(0,le.jsx)(j.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(m.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(m.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ne,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ne,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:oe,y1:$,x2:r-ae,y2:$,stroke:B.colours.hairline,strokeWidth:1}),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:`${re(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${s}`)),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:re(e),stroke:B.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${s}`)),T.filter(e=>1===e.length).map((e,s)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:B.colours.gold},`s${s}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:C(e.day),cy:$,r:2,fill:"none",stroke:B.colours.muted,strokeWidth:1},e.date)),S&&'recorded'===S.state?(0,le.jsx)(a.Line,{x1:C(S.day),y1:10,x2:C(S.day),y2:$,stroke:B.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===s);return(0,le.jsx)(a.Circle,{cx:C(e.day),cy:'recorded'===e.state?I(e.value):$,r:4.5,fill:B.colours.gold,stroke:B.colours.surface,strokeWidth:1.5})})():null,S&&'recorded'===S.state&&S.date!==s?(0,le.jsx)(a.Circle,{cx:C(S.day),cy:I(S.value),r:5,fill:B.colours.surface,stroke:B.colours.gold,strokeWidth:2}):null]}):null,r?D.map(e=>(0,le.jsx)(f.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:N(e),accessibilityState:{selected:S?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ne,left:C(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(m.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:W.map(e=>(0,le.jsx)(j.T,{size:F.AXIS_FONT,colour:B.colours.muted,style:{position:'absolute',left:C(e)-17,width:ie,top:0,textAlign:'center'},children:String(e)},e))})]}),S&&D.length?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(f.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:D[0]?.date===S.date,onPress:()=>L(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[0]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(m.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:N(S),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(j.Muted,{center:!0,children:S.date===s?`Today \xb7 ${(0,M.shortDay)(S.date)}`:(0,M.shortDay)(S.date)}),(0,le.jsx)(j.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===S.state?B.colours.goldLight:B.colours.muted,children:'recorded'===S.state?(0,M.poundsWhole)(S.value):'pending'===S.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(f.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:D[D.length-1]?.date===S.date,onPress:()=>L(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[D.length-1]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(j.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ue='#3A2F1E';function he({split:e}){return(0,le.jsx)(j.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(m.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(j.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(m.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",colour:B.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(m.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ue,borderWidth:1,borderColor:B.colours.gold},children:[(0,le.jsx)(m.default,{style:{width:`${e.walkInPct}%`,backgroundColor:B.colours.gold}}),(0,le.jsx)(m.default,{style:{flex:1,backgroundColor:ue}})]})]})]})})}},1432,[860,1160,1433,34,797,1098,1201,1102,1103,1420,1346,877,1106,281,402,102,794,874,891,1209,861,1178,858,1100,881,821,1200,1087,1159,1165,1166,1038,13,1170,927,987,999,1442,1443,1169,1444,1180,869,1447,1204,1223,1222,1060,1061,1093,1125,1390,1173,1345,25]); -__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.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:z}=(0,R.useCtx)(6e4),V=z.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsxs)(j.Muted,{size:12,children:["Uses: ",e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')," from the counted stock. Held from the Display count and shown as \u201cReserved\u201d."]})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),De=J.hourOverrides??[],Re=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:D.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),Re?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:Re}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!Re,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),De.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:De.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...De.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),ze=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,$e]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{$e(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From a party of"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from party size"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:D.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)($.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:ze,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:D.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:D.colours.accentBorder,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:D.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:D.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,R.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:D.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:D.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:D.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),D=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),z=_r(_d[31]),I=_r(_d[32]),$=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:D.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?D.colours.red:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:D.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:D.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:D.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:D.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,z.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:D.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1433,[1161,1062,5,1415,827,1434,1435,1437,1438,1439,1219,1060,1061,1038,1043,34,402,102,794,14,1440,831,878,1100,877,821,1087,874,1203,1008,1009,891,1441,1385,1028,1110,1035,1163,980,25]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1434,[827,34,102,794,1160,877,821,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1435,[860,34,236,102,794,874,1028,1174,1270,987,1341,1436,25]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1436,[860,1294]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1437,[34,102,794,1028,1350,821,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1438,[34,102,794,1028,858,1393,5,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1439,[]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1440,[34,1062,102,821,794,1267,1270,25]); -__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1441,[34,102,794,1028,1363,821,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1442,[]); -__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},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])},1443,[34,402,102,794,821,1169,1442,25]); -__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1444,[927,796,831,828,837,878,1075,1445,34,993,336,379,236,402,102,794,874,891,858,821,1200,1087,1229,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1445,[499,1446]); -__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 t={}},1446,[]); -__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.ProgressBar=D,_e.useSetupDone=O,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,C.useCtx)(6e4),n=O(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=f.SETUP_STEPS.findIndex(e=>e.id===a),s=f.SETUP_STEPS[e+1]?.id??null;return(0,E.jsx)(L,{id:a,wizard:!0,onBack:()=>l(e>0?f.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=f.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,E.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{gap:12,children:[(0,E.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(m.T,{size:20,weight:"bold",colour:S.colours.gold,children:["Set up ",t.name]}),(0,E.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,E.jsx)(D,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,E.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,E.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:S.colours.border,backgroundColor:S.colours.surface,overflow:'hidden'},children:f.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,E.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:S.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,E.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?S.colours.gold:'transparent',borderWidth:1.5,borderColor:t?S.colours.gold:S.colours.border},children:(0,E.jsx)(m.T,{weight:"bold",colour:t?S.colours.onGold:S.colours.muted,children:t?'\u2713':s+1})}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"medium",children:e.title}),(0,E.jsx)(m.Muted,{children:e.sub}),o.length?(0,E.jsxs)(m.T,{size:13,colour:S.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,E.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=L,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return W}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,C.useCtx)(6e4),t=O(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,E.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:"Finish setting up"}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]}),(0,E.jsx)(D,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,E.jsxs)(m.Muted,{size:13,children:["Next: ",f.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]);const M=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],R=[1,2,3,4,5,6,0],I=/^([01]\d|2[0-3]):[0-5]\d$/,$=e=>{const s=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(s)&&s>0?Math.round(100*s):null},B=e=>f.SETUP_STEPS.findIndex(s=>s.id===e)+1;function D({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,E.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,E.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:S.colours.gold,borderRadius:5}})}),(0,E.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function O(e){const s=(0,f.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=f.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:f.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function L({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,C.useCtx)(6e4),l=O(a),r=l.prog,d=(0,i.useLiveVenue)(),u=f.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=_[e];return(0,E.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(m.T,{size:12,weight:"semibold",colour:S.colours.gold,children:["STEP ",B(e)," OF ",f.SETUP_STEPS.length]}),s&&o?(0,E.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,E.jsx)(m.T,{size:13,colour:S.colours.muted,children:"All steps"})}):null]}),(0,E.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,E.jsx)(D,{done:r.done,total:r.total})]}),(0,E.jsx)(b,{rid:a,done:(t="Saved.")=>{f.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,E.jsx)(m.Banner,{kind:"success",title:p}):null,(0,E.jsx)(N,{rid:a,id:e,title:u.title,onDone:x}),s?(0,E.jsxs)(m.Row,{gap:10,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,E.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const A=({wizard:e,onPress:s,disabled:t,label:n})=>(0,E.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const F=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function U({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,C.useHourly)(),d=(0,f.useSiteSetup)(e),u=(0,f.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,w.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,f.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),T(null)},z=!!p?.id&&(M=p.id,k.ROSTER.some(e=>e.id===M));var M;const R=p?$(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=R||z&&!p.wage);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,E.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,E.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?S.colours.gold:S.colours.border,backgroundColor:s?'#1d1a14':S.colours.surface}),children:[(0,E.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"semibold",children:e.name}),(0,E.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,f.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,E.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,f.accessOf)(e.level,e.role)})]},e.id))}),y?(0,E.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:S.colours.gold},children:(0,E.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,E.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,E.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,E.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,E.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,E.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Access level"}),(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:f.ACCESS_LEVELS.map(e=>(0,E.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,E.jsxs)(m.Muted,{size:13,children:["Uses the ",f.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Pay"}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,E.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,E.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,E.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,E.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,w.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,E.jsx)(m.Field,{label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=R&&R<1271?(0,E.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,E.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,E.jsxs)(m.Row,{gap:8,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,E.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),f.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:f.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=R&&s.setRate(t,R);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),f.useSetup.getState().patch(e,{staffGrade:o}),f.useSetup.getState().setLook(t,p.look),T(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,E.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,E.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(F(d.grades[0]?.id??'')),T(null)}}),(0,E.jsx)(A,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const _={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,f.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,E.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,E.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,E.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,E.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':'anchorage'===e?'The Anchorage logo in black and gold.':'greenside'===e?'The Greenside Restaurant logo.':'abbotsford'===e?'The Abbotsford Hotel logo.':'kirkton'===e?'The Kirkton Inn logo.':'wildings'===e?'The Wildings Hotel & Restaurant logo.':'kirkmichael'===e?'The Kirkmichael Arms logo.':'souters'===e?'The Souter\u2019s Inn logo.':'Placeholder initials.'," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,E.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,E.jsx)(P.OrderAtTableCard,{rid:e,compact:!0}),u?(0,E.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,E.jsx)(A,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,C.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=R.filter(e=>{const s=n[e];return s&&(!I.test(s[0])||!I.test(s[1]))});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),M.map((e,s)=>{const t=R[s],l=n[t];return(0,E.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:S.colours.border,paddingTop:s?6:0},children:[(0,E.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,E.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"to"}),(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,E.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,E.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries(R.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,E.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,E.jsx)(A,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,y.usePlan)(e),o=(0,y.planCounts)(n);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.TablePlan,{startStep:"areas"}),(0,E.jsx)(A,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,E.jsx)(U,{...e,payList:!0})]})},staff:U,permissions:function({done:e,wizard:s}){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(z.PermissionsScreen,{}),(0,E.jsx)(A,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,f.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,E.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,E.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,E.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,E.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,E.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,E.jsx)(A,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),a=(0,f.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,T.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,E.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,E.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:S.colours.border,padding:10},children:(0,E.jsx)(m.T,{size:14,colour:S.colours.goldLight,children:i})}),(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,T.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,E.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,E.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,E.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,E.jsx)(A,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),f.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,C.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,E.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,E.jsx)(A,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},W=e=>function(){return(0,E.jsx)(L,{id:e})};function N({rid:e,id:s,title:t,onDone:n}){const o=O(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,E.jsxs)(g.default,{style:{gap:4},children:[(0,E.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),f.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,E.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,E.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1447,[929,928,828,827,1075,1448,1449,1450,1451,1453,34,402,102,873,925,794,874,891,1028,927,15,867,821,1087,1454,1457,1461,1462,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1448,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1449,[34,987]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1450,[34,846,987]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1451,[2,827,34,236,383,102,794,1452,987,821,1204,1003,891,993,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1452,[]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1453,[34,402,794,987,821,1451,25]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1454,[827,979,1160,987,797,1237,1239,34,281,379,236,402,102,426,879,794,874,1248,891,867,858,821,1200,1087,869,1444,1179,1455,1456,1159,1166,1165,1038,13,1163,1169,1229,25]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1455,[827,34,1235,1055,870,379,402,102,794,891,867,858,821,1200,1087,1229,25]); -__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1456,[1015,34,402,102,794,891,821,1087,987,25]); -__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1457,[827,34,1047,395,102,1133,1134,1361,1390,794,1025,1028,858,821,1087,1029,1458,1459,1049,25]); -__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1458,[827,34,402,102,794,821,1028,5,1029,872,987,25]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1459,[34,102,794,1028,1460,859,821,1074,933,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1460,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1461,[5,1415,34,102,794,874,891,25]); -__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.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1462,[34,281,402,102,794,821,999,1463,25]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1463,[933,987,891,872,999]); -__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.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=M,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=M(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',O[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:O[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withWildingsQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function M(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const O={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from Bidfood or Booker? Add them here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1464,[832,1206,34,281,283,364,395,236,295,102,36,794,873,876,891,1028,1065,1066,5,859,1063,1073,821,872,1087,1465,1468,25]); -__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.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1465,[827,34,379,402,295,102,794,1466,1467,821,1464,1087,891,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1466,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1467,[839,846,849]); -__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.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1468,[34,402,102,794,876,1467,1028,859,1469,1073,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1469,[]); -__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1470,[828,34,283,364,236,402,102,846,794,821,25]); -__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1471,[1201,1098,1139,1116,34,402,102,794,891,858,821,1117,1187,1087,1198,1444,1180,876,1202,869,1200,925,1421,1028,860,1125,1217,1221,1097,25]); -__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.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1472,[34,1100,102,426,794,874,1162,1160,877,858,821,891,1200,1087,1169,1165,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1473,[846]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=P,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,x]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)).slice(0,8),R=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),A=R.filter(e=>'due'===e.state||'overdue'===e.state),M=R.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,B.jsxs)(o.default,{style:{gap:12},children:[(0,B.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),b?(0,B.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,B.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,B.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,B.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,B.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,B.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===A.length?(0,B.jsx)(i.Muted,{children:"Nothing due right now."}):null,A.map(e=>(0,B.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,y.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,B.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,B.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,B.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),M.map(e=>(0,B.jsxs)(i.Muted,{children:[(0,y.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,y.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,B.jsx)(k.SectionHead,{title:"Live orders",right:(0,B.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,B.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,B.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,B.jsx)(P,{o:e},e.id)),v.length?(0,B.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,B.jsx)(i.Card,{style:{opacity:.7},children:(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,B.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,B.jsx)(O,{onClose:e=>{h(!1),e&&x(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),x=_r(d[13]),y=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]);const R={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function O({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),y=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,R]=(0,r.useState)(''),[O,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[N,$]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,F]=(0,r.useState)(''),[_,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,x.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries(N).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(y.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.ukPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(_),J=K.length>0&&Y&&(Q?O.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(y.map(e=>e.section)));return(0,B.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,B.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,B.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,B.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,B.jsx)(i.Field,{label:"Table number",value:O,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,B.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:R,placeholder:"e.g. Mrs Reid"}),Q?null:(0,B.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:F,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,B.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,B.jsx)(i.Field,{label:"Email (optional)",value:_,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too"}),'phone'===T?(0,B.jsxs)(o.default,{style:{gap:4},children:[(0,B.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,B.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,B.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,B.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),y.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,B.jsxs)(o.default,{style:{flex:1},children:[(0,B.jsx)(i.T,{size:15,children:e.name}),(0,B.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,B.jsx)(i.Stepper,{value:N[e.id]??0,min:0,max:20,label:e.name,onChange:t=>$({...N,[e.id]:t})})]},e.id)),(0,B.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,B.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,B.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,B.jsx)(l.GreensideCashOnly,{}):(0,B.jsx)(i.Banner,{kind:"demo",title:"Card payments: not set up yet",children:"Pay on collection or at the table. Nothing is charged in the app."}),(0,B.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?O.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:_.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${O.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function P({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),x=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,B.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,B.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,y.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",R[e.channel??(e.type,'app')]," \xb7 ",(0,y.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,B.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,B.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,B.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,B.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,B.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,B.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,y.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,B.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,B.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,B.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,B.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,B.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:x,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,B.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,B.jsx)(i.Button,{small:!0,kind:"ghost",label:"Reject",onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1474,[5,1415,860,1385,34,102,794,874,876,881,861,867,1178,1130,858,821,1200,1087,1179,1180,869,1422,864,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return pe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),b=_r(d[9]),h=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),E=_r(d[18]),N=_r(d[19]),P=_r(d[20]),W=_r(d[21]),A=_r(d[22]),R=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),G=_r(d[27]),B=(e=G)&&e.__esModule?e:{default:e},x=_r(d[28]),D=_r(d[29]),I=_r(d[30]),L=_r(d[31]),H=_r(d[32]),_=_r(d[33]),F=_r(d[34]),V=_r(d[35]),Q=_r(d[36]),q=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),K=_r(d[41]),z=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),ae=_r(d[49]),se=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),de=_r(d[55]),ue=_r(d[56]),le=_r(d[57]),ge=_r(d[58]),ce=_r(d[59]);const pe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},be=e=>n.CAN.manage(e);(0,y.register)([{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>be(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:be,C:R.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:w.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:be,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>be(e)&&!r.IS_CAR,badge:'NEW',C:P.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:be,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:be,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',badge:'NEW',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:be,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:be,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:be,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:be,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:b.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:be,badge:'NEW',C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:h.PLAN_SUB,group:'Account',can:n.CAN.billing,C:h.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',badge:'NEW',C:T.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',badge:'NEW',C:W.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:W.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',badge:'NEW',can:be,C:A.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:W.Timesheets}]),(0,y.register)([{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:M.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:M.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',badge:'NEW',can:be,C:E.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',badge:'NEW',can:be,C:N.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'Photo of the cash up sheet, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',badge:'NEW',can:be,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:M.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:M.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:M.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:be,C:M.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:be,C:M.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:be,C:M.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:be,C:M.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:be,C:M.ReviewEmailSettings},{id:'compliance',title:'Daily checks & allergen log',sub:'Fridge temps, opening checks, audit log',group:'Compliance',C:M.Compliance},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:M.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:be,badge:'NEW',C:M.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:M.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:O.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>pe(),C:O.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:be,C:O.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:be,C:O.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:O.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:be,C:O.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:be,C:O.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:be,C:O.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:be,C:O.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:O.TabletPreview}]);const he=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',badge:'NEW',C:()=>B.default.createElement(D.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:x.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',badge:'NEW',can:he,C:x.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',badge:'NEW',can:he,C:D.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',badge:'NEW',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:I.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',badge:'NEW',C:L.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:be,C:L.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:be,badge:'NEW',C:L.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:be,badge:'NEW',C:H.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:be,badge:'NEW',C:H.DisplaySettingsPage}]);const fe=e=>'owner'===e||'manager'===e;_.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:fe,badge:'NEW',C:_.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off, voice, connected services',group:'Account',can:fe,C:_.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',badge:'NEW',can:e=>'owner'===e&&!r.IS_CAR,C:V.CarScreen}]);const ye=e=>'owner'===e||'manager'===e,me=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Ce=e=>ye(e)&&me();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ye,badge:'NEW',C:F.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Prices},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning, allergen checks; filters; CSV and print for the EHO',group:'Compliance',can:ye,badge:'NEW',C:F.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ye,badge:'NEW',C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',badge:'NEW',C:F.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:be,badge:'NEW',C:Q.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:be,badge:'NEW',C:Q.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:be,badge:'NEW',C:Q.Outbox}]);const Se=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Se,badge:'NEW',C:U.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Se,badge:'NEW',C:q.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Se,badge:'NEW',C:Y.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Se,badge:'NEW',C:j.OrderSheetSettings},...K.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Se,C:(0,q.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Se,badge:'NEW',C:z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Se,badge:'NEW',C:$.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:be,badge:'NEW',C:$.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Se,badge:'NEW',C:$.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Se,badge:'NEW',C:J.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:be,badge:'NEW',C:X.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:be,badge:'NEW',C:X.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:be,badge:'NEW',C:X.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:be,badge:'NEW',C:Z.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:be,badge:'NEW',C:ee.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:be,badge:'NEW',C:ae.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, Booker and Bidfood lists, offers, events and specials the voice helper prepared; nothing is sent',group:'Run the day',can:be,badge:'NEW',C:se.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift, left by voice or typing',group:'Run the day',badge:'NEW',C:se.ShiftNotesPage},{id:'voice',title:'Voice helper',sub:'Hold-to-talk input, text-only replies, who gets it and microphone privacy',group:'Settings',can:be,badge:'NEW',C:se.VoiceSettingsPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ie.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update',group:'Compliance',can:ye,badge:'NEW',C:function(){return B.default.createElement(re.FoodSafetyCard,null)}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ne.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ye,badge:'NEW',C:function(){const{rid:e,today:t}=(0,oe.useCtx)(6e4);return B.default.createElement(ne.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',badge:'NEW',C:function(){const{rid:e,me:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:be,badge:'NEW',C:te.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',badge:'NEW',C:function(){const{me:e,role:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(ue.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:be,C:le.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:be,C:ge.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,badge:'NEW',C:ce.UseOnComputerPage}])},1475,[837,1085,872,1476,891,1003,993,831,881,1478,1485,1495,1456,1496,1497,1499,1500,1472,1501,1502,1504,1218,1209,1474,1505,1454,1506,34,1217,1198,1455,1444,1457,1489,1511,1512,1513,1447,1433,1461,1514,927,1515,1516,1518,1204,1464,1519,1385,1465,1531,1107,1110,1087,1219,1173,1532,1535,1538,1541]); -__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,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return k}}),_e.DashCorners=I,_e.ServiceBoard=function(){const{role:e}=(0,j.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,D.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,D.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,D.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,D.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,D.jsx)(I,{onLeave:y}),(0,D.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,D.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,D.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,D.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,D.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,D.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?w((0,D.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]),D=r(d[16]);const k=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function C({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,D.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,D.jsxs)(s.default,{children:[(0,D.jsx)(p.Icon,{name:t,colour:h.colours.gold}),u?(0,D.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,D.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function I({onLeave:e}){const t=(0,x.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>y.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,D.jsx)(C,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,D.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,D.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:k.filter(e=>'left'===e.side).map(n)}),(0,D.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[k.filter(e=>'right'===e.side).map(n),(0,D.jsx)(C,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')}),(0,D.jsx)(f.VoiceSlot,{size:44,layer:1})]})]})}function w(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[17]);return t(e,document.body)}},1476,[34,395,236,402,102,36,794,1055,1343,891,821,1156,1477,1206,1473,1087,25,277]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1477,[846]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, take a picture of the taking sheet and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1478,[827,1453,34,867,102,794,891,821,1087,925,926,1479,987,1000,1060,1451,1480,1481,1483,1026,1484,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1479,[]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1480,[827,34,102,794,821,891,1395,1405,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1481,[34,102,794,1482,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1482,[846,933,987,2]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1483,[34,102,794,821,998,1051,987,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1484,[933,987]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_VOICE_LINE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_SUPPLIER_LINE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DONE_FOR_YOU",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"doneForYouLine",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return v}}),_e.PlanBilling=function(){const{now:e,role:n,rid:b}=(0,p.useCtx)(6e4),j=(0,c.trialStatus)((0,l.defaultSimStart)(),e),[x,w]=(0,s.useState)(!1);return u.CAN.billing(n)?x?(0,y.jsx)(M,{onBack:()=>w(!1)}):(0,y.jsxs)(i.default,{style:{gap:10},children:[(0,y.jsx)(o.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,y.jsx)(t.VoiceUsageCard,{rid:b,now:e}),(0,y.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,y.jsxs)(i.default,{testID:"plan-founding",children:[(0,y.jsx)(o.T,{size:12,weight:"semibold",colour:h.colours.goldMuted,children:"FOUNDING OFFER \xb7 FIRST 50 VENUES"}),(0,y.jsxs)(o.T,{size:30,weight:"bold",children:["\xa349",(0,y.jsx)(o.T,{size:14,colour:h.colours.muted,children:" a month + VAT if applicable, per venue"})]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,y.jsx)(o.Badge,{kind:"gold",label:"Every Full Restaurant Pro feature"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"One month free"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"\xa349 net locked in"})]}),(0,y.jsx)(o.Muted,{children:"Early adopter price for the first 50 venues: every Full Restaurant Pro App feature, including the owner's dashboard and admin and the voice Assistant. \xa349 net stays locked in while your subscription stays active."}),(0,y.jsxs)(o.T,{size:13,testID:"plan-early-done-for-you",children:["\u2713 ",T(P.early)]}),(0,y.jsx)(o.Muted,{children:"From venue 51, usual prices:"}),(0,y.jsxs)(i.default,{testID:"plan-usual-lite",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[k," \xb7 ",C," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:S}),O.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e)),(0,y.jsx)(o.T,{size:13,testID:"plan-lite-not-included",children:"Not included: the owner's dashboard and admin, or the voice Assistant."})]}),(0,y.jsxs)(i.default,{testID:"plan-usual-pro",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[_," \xb7 ",L," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:v}),R.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e))]}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>w(!0),style:{marginTop:6}})]}),(0,y.jsx)(o.Card,{children:(0,y.jsxs)(i.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,y.jsx)(o.T,{weight:"bold",colour:h.colours.gold,children:"free"}),"."]}),(0,y.jsx)(o.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,y.jsx)(o.Muted,{children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, and subscribers get free lifetime 24/7 customer support. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{children:"Free trial"}),(0,y.jsxs)(o.T,{weight:"bold",colour:h.colours.gold,children:[j.daysLeft," day",1===j.daysLeft?'':'s'," left"]})]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(100*(1-j.daysLeft/j.total))}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),(0,y.jsxs)(o.Muted,{children:["Then \xa3",c.PLAN.monthlyPence/100," a month + VAT if applicable. The trial start date is not set up yet."]})]}),(0,y.jsx)(f.AssistantPlanCard,{}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{weight:"semibold",children:"Free lifetime customer support"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"Included"})]}),(0,y.jsx)(o.Muted,{children:"Free for as long as you subscribe, day or night. Setup is all done digitally. Support contact details: not set up yet."})]})]}):(0,y.jsx)(o.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),i=(e=n)&&e.__esModule?e:{default:e},o=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]);const b=!0,j='Founding offer, free trial, set-up guide',x='. The owner\'s dashboard and admin come with Full Restaurant Pro App (\xa399 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',w='Voice Assistant (hold to talk) for seating guests, marking tables as cleared, temperature logs and finding something in the app: fair usage 1,000 voice tasks a month per venue',A='Supplier links: open your suppliers\' ordering sites and keep order lists',P={lite:1,pro:3,early:3},T=e=>`${e} done-for-you ${1===e?'change':'changes'} a month`,k='Customer & Takeaway App',_='Full Restaurant Pro App',C='\xa349',L='\xa399',S='A lite version of CoverCharge: 3 core customer and takeaway functions tailored to you, set up digitally with the in-app guided setup and step-by-step guides, free lifetime 24/7 customer support while subscribed, and unlimited self-edits of your basic info. The owner\'s dashboard and admin, and the voice Assistant, are not included.',v='Every feature, every app, including the owner\'s dashboard and admin and the voice Assistant. Set up digitally with the in-app guided setup and step-by-step guides, the Assistant (fair use 300 tasks a month), free lifetime 24/7 customer support while subscribed, and unlimited self-edits.',O=['Customer app: menu, allergens, bookings and loyalty','Takeaway ordering','Set up digitally: in-app guided setup and step-by-step guides','Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits of your basic info',T(P.lite)],R=['Every feature, every app','The owner\'s dashboard and admin',A,'Set up digitally: in-app guided setup and step-by-step guides','The Assistant, fair use 300 tasks a month',w,'Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits',T(P.pro)],I=[['Choose your 3 core functions','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function M({onBack:e}){const[t,n]=(0,s.useState)([]);return(0,y.jsxs)(i.default,{style:{gap:10},testID:"setup-guide",children:[(0,y.jsx)(o.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,y.jsx)(o.H2,{children:"Set-up guide"}),(0,y.jsxs)(o.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",t.length," of ",I.length," done."]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(t.length/I.length*100)}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),I.map(([e,s],l)=>{const u=t.includes(l);return(0,y.jsx)(o.Card,{children:(0,y.jsxs)(o.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,y.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:u?h.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(o.T,{size:14,weight:"bold",colour:u?'#1a1610':h.colours.gold,children:u?'\u2713':String(l+1)})}),(0,y.jsxs)(i.default,{style:{flex:1,gap:4},children:[(0,y.jsx)(o.T,{weight:"semibold",children:e}),(0,y.jsx)(o.Muted,{children:s}),(0,y.jsx)(o.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>n(u?t.filter(e=>e!==l):[...t,l])})]})]})},e)}),(0,y.jsx)(o.Muted,{children:"Stuck? Free lifetime customer support is included while you subscribe. Ticks on this guide are not saved."})]})}},1485,[1486,34,102,794,850,891,1488,821,1087,1489,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1486,[34,102,794,821,1487,25]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1487,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1488,[]); -__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,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return v}}),_e.AssistantFab=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)(e=>e.enabled);return R(e)&&t?(0,A.jsxs)(c.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>v.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:k.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,A.jsx)(M,{size:22}),(0,A.jsx)(b.T,{weight:"bold",colour:I,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=v(e=>e.open),o=()=>v.getState().setOpen(!1),{rid:a,role:p,me:C}=(0,w.useCtx)(3e4),S=(0,j.useAssistant)(),I=B(),[E,L]=(0,r.useState)([]),[W,z]=(0,r.useState)(''),[$,_]=(0,r.useState)(!1),N=(0,r.useRef)(null),F=(0,r.useRef)(null);if((0,r.useEffect)(()=>{setTimeout(()=>N.current?.scrollToEnd?.({animated:!0}),50)},[E.length]),!e||!R(p))return null;const H=(e,t,s)=>j.useAssistant.getState().record({at:(new Date).toISOString(),by:C,role:p,asked:e,action:t,outcome:s}),U=(e,t="result")=>L(s=>[...s,{id:D(),from:'assistant',text:e,kind:t}]),V=async e=>{const t=e.trim();if(!t)return;let s;z(''),L(e=>[...e,{id:D(),from:'you',text:t}]);try{s=await(0,y.getProvider)('xai').interpret(t,I)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&H(t,'\u2014','not understood'),L(e=>[...e,{id:D(),from:'assistant',proposal:s,state:'open',asked:t}])},G=(e,t)=>L(s=>s.map(s=>s.id===e?{...s,state:t}:s)),q=async(e,t,n)=>{if(G(e.id,'confirmed'),'external'===t.kind)return H(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void U(T,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await m.repo.bookings.seatWalkIn(a,Number(o.party),s,'Added by Assistant'),s&&(0,f.resetTableLive)(a,s),U(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),H(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),U(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),H(e.asked,t.title,'done');break;case'price':await m.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),U(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),H(e.asked,t.title,'done');break;case'offer':x.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),U(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),H(e.asked,t.title,'done');break;case'rota':case'bookings':U(String(o.result)),H(e.asked,t.title,'looked up')}},Y=e=>{G(e.id,'cancelled'),H(e.asked,e.proposal?.title??'\u2014','cancelled'),U('Cancelled. Nothing was changed.','note')},K='lite'===S.tier,J=(0,j.tasksUsed)(S);return(0,A.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,A.jsx)(h.default,{style:[b.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,A.jsxs)(h.default,{testID:"assistant-sheet",style:{backgroundColor:k.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:k.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.Row,{gap:8,style:{flex:1},children:[(0,A.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:18})}),(0,A.jsx)(b.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,A.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,A.jsx)(h.default,{testID:"assistant-demo-badge",children:(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),K?(0,A.jsxs)(h.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,A.jsx)(b.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,A.jsx)(b.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(u.default,{ref:N,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===E.length?(0,A.jsxs)(h.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,A.jsxs)(b.T,{children:["Hi ",C.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,A.jsx)(b.Muted,{children:"Try:"}),y.SUGGESTED_PROMPTS.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:k.colours.surface2},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]}):null,E.map(e=>'you'===e.from?(0,A.jsx)(h.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,A.jsx)(b.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,A.jsx)(P,{m:e,onConfirm:(t,s)=>q(e,t,s),onCancel:()=>Y(e)},e.id):'choose'===e.proposal.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),(0,A.jsx)(b.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>V(e.prompt)},e.label))})]},e.id):(0,A.jsxs)(h.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:8},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]},e.id):(0,A.jsx)(h.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?k.colours.amberBg:k.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:k.colours.amber},children:(0,A.jsx)(b.T,{children:e.text})},e.id))]}),(0,A.jsxs)(b.Row,{gap:8,children:[(0,A.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:W,onChangeText:z,onSubmitEditing:()=>V(W),returnKeyType:"send",style:[b.styles.input,{flex:1,minWidth:0,width:40}]}),S.voice?(0,A.jsx)(c.default,{testID:"assistant-mic",accessibilityRole:"button",accessibilityLabel:$?'Stop listening':'Speak',onPress:()=>{const e=O();if(e)if($)F.current?.stop?.();else try{const t=new e;F.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&z(t)},t.onend=()=>_(!1),t.onerror=()=>{_(!1),U("Sorry, I didn't catch that. You can type instead.",'note')},_(!0),t.start()}catch{_(!1),U("Voice input isn't available here. Please type instead.",'note')}else U("Voice input isn't available in this browser (for example Huawei Browser). Please type your request instead.",'note')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:$?k.colours.gold:'transparent'},children:(0,A.jsx)(b.T,{size:20,children:"\ud83c\udfa4"})}):null,(0,A.jsx)(b.Button,{label:"Send",accessibilityLabel:"Send",disabled:!W.trim(),onPress:()=>V(W)})]}),(0,A.jsxs)(b.Muted,{center:!0,children:["Demo on this device \xb7 ",J," of ",j.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,w.useCtx)(6e4),s=(0,j.useAssistant)();return R(t)?(0,A.jsxs)(h.default,{style:{gap:12},children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{gap:10,children:[(0,A.jsx)(h.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:22})}),(0,A.jsxs)(h.default,{style:{flex:1},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,A.jsx)(b.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,A.jsx)(b.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>v.getState().setOpen(!0)}),(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,A.jsxs)(h.default,{testID:"assistant-log",style:{gap:6},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>j.useAssistant.getState().clearLog()}):null]}),(0,A.jsx)(b.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,A.jsx)(b.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,A.jsxs)(h.default,{style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.T,{size:12,colour:k.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,A.jsx)(b.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,A.jsxs)(b.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,A.jsxs)(b.T,{size:13,colour:k.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,A.jsx)(b.Muted,{children:"The activity log is visible to the owner."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)();return R(e)?(0,A.jsxs)(h.default,{style:{gap:12},testID:"assistant-settings",children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,A.jsx)(b.Muted,{children:"Shows the gold Assistant button on every Managers screen."}),(0,A.jsx)(b.Toggle,{label:"Voice input (microphone)",value:t.voice,onChange:e=>t.set({voice:e})}),(0,A.jsx)(b.Muted,{children:"What you say is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. If this device can\u2019t record, just type."})]}),(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Connected services"}),E.map(e=>(0,A.jsxs)(h.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:k.colours.border,paddingTop:8},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{children:e.name}),(0,A.jsx)(b.Badge,{kind:"neutral",label:"Not connected"})]}),(0,A.jsxs)(b.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,A.jsx)(b.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,A.jsx)(b.Muted,{children:"The Assistant comes with Full Restaurant Pro App and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,A.jsx)(b.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to the voice assistant to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,j.useAssistant)(),t=(0,j.tasksUsed)(e),s=Math.min(1,t/j.FAIR_USE);return(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,A.jsx)(b.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,A.jsx)(h.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${j.FAIR_USE} tasks used`,style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,A.jsx)(h.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:k.colours.gold,borderRadius:4}})}),(0,A.jsxs)(b.Muted,{children:[t," of ",j.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]),a=_r(d[4]),r=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var c=e(_r(d[8])),u=e(_r(d[9])),h=e(_r(d[10])),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),m=_r(d[14]),x=_r(d[15]),y=_r(d[16]),j=_r(d[17]),k=_r(d[18]),w=_r(d[19]),C=_r(d[20]),A=_r(d[21]);const S=!0,T='Nothing was sent or changed: this connection is not set up yet.',I='#1A1408',v=(0,p.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=e=>'owner'===e||'manager'===e,D=()=>Math.random().toString(36).slice(2,9);function M({size:e=24,colour:t=I}){return(0,A.jsx)(b.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function B(){const{rid:e,r:t,now:s,today:n}=(0,w.useCtx)(3e4),a=(0,m.useAllMenu)(e),l=(0,f.useTableNames)(e),c=(0,m.useBookings)(e),u=(0,x.useOwner)(e=>e.staff),h=(0,x.useOwner)(e=>e.shifts),p=(0,x.useOwner)(e=>e.offers),b=(0,x.useOwner)(e=>e.suppliers);return(0,r.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:a.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:l,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,C.workingShifts)(h,x.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,x.addDays)(n,-(0,x.weekdayOf)(n))&&e.date<=(0,x.addDays)(n,6-(0,x.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${b[0]?.contact??'Alex Sample'}, ${b[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),a,l,c,u,h,p,b])}function P({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[a,l]=(0,r.useState)(!1),[c,u]=(0,r.useState)('external'===o.kind?o.text:''),p='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,A.jsxs)(h.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:p?k.colours.gold:k.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:k.colours.surface2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,A.jsx)(b.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[o.detail?(0,A.jsx)(b.Muted,{children:o.detail}):null,(0,A.jsx)(b.T,{size:14,colour:k.colours.muted,children:o.label}),a&&p?(0,A.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:u,style:[b.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,A.jsx)(h.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:k.colours.gold,paddingLeft:10},children:(0,A.jsxs)(b.T,{children:["\u201c",c,"\u201d"]})}),(0,A.jsxs)(b.Muted,{children:["Sends to: ",o.service.map(e=>y.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,A.jsxs)(h.default,{style:{gap:4},children:[(0,A.jsx)(b.Muted,{children:o.detail}),o.warning?(0,A.jsxs)(b.T,{size:13,colour:k.colours.amber,children:["\u26a0 ",o.warning]}):null]}),p?(0,A.jsxs)(b.Row,{wrap:!0,gap:8,children:[(0,A.jsx)(b.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:a?'Done editing':'Edit',testID:"edit-action",onPress:()=>l(!a)}):null,(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,A.jsx)(b.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),p?(0,A.jsxs)(b.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}function O(){return'undefined'==typeof window?null:(0,a.speechRecognizer)()}const E=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1489,[827,979,796,884,931,34,395,236,402,295,102,846,794,1125,874,891,1490,1494,821,1087,1097,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);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]}})})},1490,[1491,1493,1492]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1491,[860,1492]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1492,[]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Voice assistant (server, with on-device fallback)',interpret:s}},1493,[1491,932]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1494,[884,839,846,849]); -__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.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1495,[5,1062,979,1415,828,827,837,1270,1440,34,402,410,102,879,794,874,891,861,867,858,821,1200,1087,1179,1444,1229,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1496,[860,34,102,1180,794,874,861,869,858,821,1200,1087,25]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1497,[1075,34,102,1498,829,873,794,891,821,1087,25]); -__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.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1498,[827,34,236,402,102,797,829,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1499,[34,1175,863,1087,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1500,[34,1061,1087,987,999,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1501,[34,1391,1087,25]); -__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.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:s}=(0,c.useCtx)(6e4),a=(0,r.useBookings)(e),n=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,t.useState)('day'),k=(0,d.hasAnyTakings)(n,e),w=(0,d.dayRows)(n,a,e,s,14),f=(0,d.weekRows)(n,a,e,s,8),v=(0,d.averageSph)(w),$=(e,t,s,a,n)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${t}: ${'No takings entered'===a?'no takings entered':`spend per head ${a}`}, ${s}${n?`, ${n}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:t}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:s}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===a?h.colours.muted:h.colours.goldLight,size:'No takings entered'===a?13:16,children:a}),n?(0,u.jsx)(i.Muted,{center:!0,children:n}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:k?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:w.map(e=>({label:x(e.date),value:e.sph}))}),[...w].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),a=_r(_d[2]),n=e(a),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,t.useState)(320),[x,y]=(0,t.useState)(e.length);(0,t.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),k=Math.max(0,j-b),w=e.slice(k,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),T=e=>38+e*(f-76)/Math.max(1,w.length-1),S=e=>140-e/$*106,L=[];let D=[];w.forEach((e,t)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:t,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(n.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(a.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(n.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(a.Line,{x1:0,x2:f,y1:S($*e/4),y2:S($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,t)=>(0,u.jsx)(a.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},t)),w.map((e,t)=>(0,u.jsx)(s.default.Fragment,{children:null==e.value?(0,u.jsx)(a.Circle,{cx:T(t),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.Circle,{cx:T(t),cy:S(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(a.Text,{x:T(t),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},k+t))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:w.map((e,t)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},k+t))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===k,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1502,[34,102,797,794,874,1038,1503,821,1087,25]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1503,[13]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1504,[34,102,1351,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1505,[34,793,1087,25]); -__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.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1506,[5,1415,827,837,860,1507,1439,1477,1235,14,1270,987,1508,1510,1440,34,1125,1485,30,402,102,879,1290,794,874,891,867,881,1130,1259,858,821,1200,1087,1159,884,1456,869,1055,1175,863,861,25]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1507,[860,34,102,794,861,867,1174,874,869,821,25]); -__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1508,[987,34,281,236,102,1290,794,1267,1270,821,1509,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1509,[34,236,102,794,1267,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1510,[5,1415,34,102,794,867,1267,1268,1269,987,1270,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1511,[34,1224,1177,1225,1232,1087,1191,863,872,1024,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1512,[34,102,794,987,858,821,25]); -__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.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["Every booking and takeaway order gets a text (a phone number is needed to book) and an email if they gave one. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1513,[828,827,837,34,236,402,102,794,1237,874,1494,864,1239,1047,821,1056,1087,25]); -__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.OrderSheetSettings=function(){const e=(0,i.useOwner)(e=>e.site),u=(0,o.useSheets)(e),[c,m]=(0,l.useState)(null);return c?(0,p.jsxs)(s.Card,{children:[(0,p.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===c.id)?`Edit ${c.name}`:'New supplier'}),(0,p.jsx)(x,{rid:e,s:c,onDone:()=>m(null)})]}):(0,p.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,p.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,p.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,p.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,p.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,p.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,p.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,p.jsx)(s.Row,{wrap:!0,gap:8,children:(0,p.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var l=r(_d[0]),t=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),i=r(_d[4]),o=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]);const c=['online','phone','text','whatsapp','tbc'];function m({label:e,value:l,onChange:t}){return(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,p.jsx)(s.Chip,{label:e,selected:l.includes(n),onPress:()=>t(l.includes(n)?l.filter(e=>e!==n):[...l,n].sort())},e))})]})}function x({rid:e,s:t,onDone:i}){const d=(0,o.useOrderSheets)(e=>e.upsert),x=(0,o.useOrderSheets)(e=>e.remove),[b,f]=(0,l.useState)(t),[j,y]=(0,l.useState)(t.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[C,v]=(0,l.useState)(t.priceCapPerKg?(t.priceCapPerKg/100).toFixed(2):''),[w,T]=(0,l.useState)(!1),D=e=>f(l=>({...l,...e}));return(0,p.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,p.jsx)(s.Field,{label:"Supplier name",value:b.name,onChangeText:e=>D({name:e})}),(0,p.jsx)(s.Field,{label:"What they supply",value:b.goods,onChangeText:e=>D({goods:e})}),(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:c.map(e=>(0,p.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:b.method===e,onPress:()=>D({method:e})},e))})]}),'text'===b.method||'whatsapp'===b.method||'phone'===b.method?(0,p.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:b.number,keyboardType:"phone-pad",onChangeText:e=>D({number:e})}):null,'online'===b.method?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:b.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>D({url:e.trim()})}),(0,p.jsx)(s.Field,{label:"Button label",value:b.urlLabel??'',placeholder:"Open website",onChangeText:e=>D({urlLabel:e})})]}):null,(0,p.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:b.contact??'',onChangeText:e=>D({contact:e})}),(0,p.jsx)(m,{label:"Delivery days",value:b.deliveryDays,onChange:e=>D({deliveryDays:e})}),(0,p.jsx)(m,{label:"Order days (a reminder shows in the Head Chef app)",value:b.orderDays,onChange:e=>D({orderDays:e})}),(0,p.jsxs)(s.Row,{gap:10,children:[(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:b.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>D({cutoff:e})})}),(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Price cap \xa3/kg (optional)",value:C,keyboardType:"decimal-pad",onChangeText:v})})]}),(0,p.jsx)(s.Field,{label:"Reminder text (optional)",value:b.reminder,onChangeText:e=>D({reminder:e})}),(0,p.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:b.frequency,onChangeText:e=>D({frequency:e})}),b.priceCapPerKg||C?(0,p.jsx)(s.Field,{label:"Seller",value:b.seller,onChangeText:e=>D({seller:e})}):null,(0,p.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:y}),(0,p.jsx)(s.Field,{label:"Notes for the chef",value:b.notes,multiline:!0,onChangeText:e=>D({notes:e})}),(0,p.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,p.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const l=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,l)=>{const[n,s]=e.split('|').map(e=>e.trim()),i=t.items.find(e=>e.name===n);return{id:i?.id??`${b.id}-i${l}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*parseFloat(C.replace(/[\xa3,]/g,'')));d(e,{...b,items:l,priceCapPerKg:n>0?n:0,placeholder:b.placeholder&&'tbc'===b.method}),i()},disabled:!b.name.trim()}),(0,p.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:i}),w?(0,p.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{x(e,t.id),i()}}):(0,p.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>T(!0)})]})]})}},1514,[34,402,102,794,891,1030,867,1031,821,25]); -__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.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1515,[34,236,402,102,426,794,821,1373,873,1375,858,987,1376,1087,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1516,[835,984,1454,34,236,102,794,831,891,983,1030,985,987,1517,821,2,1181,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1517,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1518,[34,102,794,821,1435,1507,1087,25]); -__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.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1519,[827,1062,796,34,402,102,794,891,1470,1520,1521,1522,821,1087,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1520,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1521,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1522,[1523,1127,860,1524,1525,891,874,1028,1470,1520,1521,1527,1526,1529,1530,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1523,[1092,1091,1052]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1524,[984,1127,835,860,874,831,1028,983,985,1039,891,1094,882,863,861]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1525,[835,874,831,1028,891,1033,1043,1044,1009,1008,1038,13,1063,1064,1065,1034,1094,882,1104,1025,870,1526,1524]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1526,[835,979,1127,860,1160,1270,874,831,1028,1033,994,862,861,1104,1105,1025,1034,867,1527,1528]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1527,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1528,[839,846,849]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1529,[831,891,994,867,1526,1046,1097]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1530,[]); -__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.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"Staff hold the gold button, say what they need and let go. It sits at the top right in Managers, Head Chef, the Staff app (the full voice assistant, without team financial or HR information) and on the Display (no money, tips or HR either), never in the customer app. Tap it to type or open the Assistant. Replies and change confirmations are shown in text, never spoken. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts for you."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,r.useDrafts)(e=>e.drafts),u=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[j,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:r.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The voice helper and the Assistant save bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting. Try holding the voice button and saying \u201cadd blue roll to the Booker list\u201d."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!j,onClose:()=>y(null),title:'approved'===j?.status?'Approve this draft?':'Dismiss this draft?',children:j?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:j.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===j.status?`This marks it approved${v[j.d.kind]?` and opens ${v[j.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===j.status?'success':'danger',label:'approved'===j.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(j.d.id,j.status,o.replace(' (example)',''));const e=v[j.d.kind];y(null),'approved'===j.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const v={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1531,[34,379,102,794,821,1466,1527,1477,1528,1157,931,1486,1087,25]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1532,[34,796,102,794,861,1267,1533,1534,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1533,[861]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1534,[987,1533,1270]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_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]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1535,[34,102,794,874,1038,1536,979,13,1537,1049,821,1087,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1536,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(o){const{rid:u,date:c,bookings:f,cashUps:p,fields:v,soldOut:h}=o,b=f.filter(t=>t.restaurantId===u&&t.date===c),k=p.find(t=>t.rid===u&&t.date===c&&t.confirmedAt),y=p.find(n=>n.rid===u&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),N=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,O=(0,n.coversOn)(f,u,c),S=null==N||O<=0?null:Math.round(N/O*100)/100,_=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&_.set(n,(_.get(n)??0)+(t.partySize||0))}let w=null;for(const[t,n]of _)(!w||n>w.n)&&(w={hour:t,n:n});return{date:c,spendPerHead:s(S),covers:O,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(N),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(y?(0,t.grossOf)(y.vals)??(0,t.takings)(y.vals):null),busiestHour:w?`${String(w.hour).padStart(2,'0')}:00 \xb7 ${w.n} Covers`:'Not entered',soldOut:h.filter(Boolean),cashUp:v.map(t=>({label:t.label,value:k?l(k.vals[t.key],t.kind):'Not entered'}))}};var t=r(d[0]),n=r(d[1]);const s=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?s(t):String(t)},1537,[13,1503]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1538,[827,34,102,794,1539,1050,821,1540,1087,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1539,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1540,[1049,1050,976,933,987]); -__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.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1541,[34,281,236,102,794,827,821,987,1430,1204,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1542,[236]); -__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,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','voice','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1544,[]); -__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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1545,[34,283,364,236,402,295,102,426,36,797,827,796,794,1237,1385,1114,1470,1113,1111,1239,1252,979,891,1061,1477,2,987,821,1343,1546,1087,1489,1414,1179,1472,1474,1464,1456,1475,1542,1544,1552,1553,1554,1557,1560,25]); -__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.micAvailable=O,_e.NoShows=z,_e.CarApp=function(){(0,H.useCarViewport)();const{width:e,height:n}=(0,c.default)(),o=Math.max(320,A(e)),{role:d,today:u,now:h}=(0,w.useCtx)(3e4),[p,f]=(0,t.useState)(n),x=o,[y,I]=(0,t.useState)(null),[D,W]=(0,t.useState)(!1),[M,z]=(0,t.useState)(null),[V,F]=(0,t.useState)(!1),[G,Y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{O().then(z)},[]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==d&&T.useOwner.getState().setPreviewRole('owner')},[d]);const X=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,X);const q=(0,t.useCallback)(()=>W(!1),[]);(0,j.useBackLayer)(D,q);const J=e=>{W(!1),I({btn:e,page:e.pages[0].id})},K=(0,t.useCallback)((e,t)=>{const n=e=>R.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:n('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:n('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??R.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=n(t);return I(n=>({btn:e??n?.btn??R.CAR_BUTTONS[0],page:t}))}I(null)},[]),Q=x,Z=y?y.btn.label:'';return(0,L.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-p)>1&&f(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:o,maxWidth:'100%',overflow:'hidden'},children:[(0,L.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,L.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,L.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,L.jsx)(B.ParkedOnly,{small:o<1400}),(0,L.jsx)(N,{open:D,onPress:()=>W(!0)})]}),subHeader:(0,L.jsx)($,{onRota:()=>J(R.CAR_BUTTONS[0]),onAccount:()=>F(!0)})}),y?(0,L.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:Q,zIndex:40,backgroundColor:S.colours.bg},children:[(0,L.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${Z}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||X()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,L.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,L.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,L.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,L.jsx)(N,{testID:"car-menu-button-page",open:D,onPress:()=>W(!0)})})]}),y.btn.pages.length>1?(0,L.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,L.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?P:'transparent',alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,L.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:'assistant'===y.page&&!1===M?(0,L.jsx)(U,{}):(0,L.jsx)(_,{id:y.page,go:K},y.page)})]}):null]}),(0,L.jsx)(E,{visible:D,onClose:q,onPick:J,current:y?.btn.id,W:o,H:p}),V?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>F(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,L.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,L.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,L.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{F(!1),Y(!0)},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>F(!1),style:{minHeight:56}})]}):null,G?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>Y(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,L.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,L.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{Y(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>Y(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),c=e(r(_d[7])),d=r(_d[8]),u=e(d),h=r(_d[9]),b=r(_d[10]),p=r(_d[11]);r(_d[12]);var f=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),R=r(_d[26]),W=r(_d[27]),B=r(_d[28]),M=r(_d[29]),H=r(_d[30]),L=r(_d[31]);const P='rgba(201,162,74,0.14)';async function O(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}}function $({onRota:e,onAccount:n}){const o=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[c,d]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>d(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=o.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,L.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,L.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,L.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:n,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,L.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,L.jsx)(M.CarGameButton,{})]})}function z({go:e}){const{rid:t,now:n}=(0,w.useCtx)(3e4),o=(0,I.useBookings)(t),s=(0,D.ymd)(n),a=(0,D.ymd)(new Date(n.getTime()-24192e5)),c=o.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),d=o.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,L.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,L.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:c.length?`${c.length} no-show${1===c.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),d.length?(0,L.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),d.map(e=>(0,L.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,L.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,c.map(e=>(0,L.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,L.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,L.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function N({onPress:e,open:t,testID:n="car-menu-button"}){return(0,L.jsx)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:R.MENU_BUTTON,height:R.MENU_BUTTON,borderRadius:R.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,L.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,L.jsx)(d.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function E({visible:e,onClose:a,onPick:c,current:d,W:u,H:b}){const[p,f]=(0,t.useState)(0),m=(0,R.menuSizes)(u,b),x=p?Math.floor((p-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new n.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),n.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,L.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,L.jsx)(n.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,L.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,L.jsxs)(n.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,L.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,L.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,L.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,L.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>f(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:R.CAR_BUTTONS.map(e=>{const t=d===e.id;return(0,L.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>c(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,L.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:P,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(W.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,L.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U(){return(0,L.jsxs)(l.default,{testID:"car-no-mic",accessibilityLiveRegion:"polite",style:{gap:10,alignItems:'center',paddingVertical:24},children:[(0,L.jsx)(C.T,{center:!0,size:20,weight:"semibold",colour:S.colours.goldLight,children:"The Assistant needs the car\u2019s microphone"}),(0,L.jsx)(C.Muted,{center:!0,style:{maxWidth:520},children:"Sorry, this car\u2019s browser isn\u2019t letting the page use a microphone. For now, please use the Assistant in Managers on your phone."})]})}function _({id:e,go:t}){if('@bookings'===e)return(0,L.jsx)(f.Bookings,{go:t});if('@chat'===e)return(0,L.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,L.jsx)(z,{go:t});if('@orders'===e)return(0,L.jsx)(x.Orders,{});if('@forecast'===e)return(0,L.jsx)(y.Forecasts,{go:t});const n=(0,p.pageFor)(e);if(!n)return(0,L.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const o=n.C;return(0,L.jsx)(o,{go:t})}function A(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,n=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,n))}},1546,[34,283,364,236,402,295,102,426,797,796,1343,1456,1475,1414,1179,1474,1472,1087,1055,794,874,891,858,987,2,821,1547,1548,1549,1550,1551,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1547,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1548,[34,797,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1549,[34,102,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1550,[34,402,1181,1182,831,5,794,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1551,[34,236]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1552,[1547]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1553,[]); -__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.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1554,[34,402,102,426,827,794,1098,1061,1196,1142,1118,874,1038,891,1100,13,930,987,821,1414,1087,1456,1555,1544,1553,1556,25]); -__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,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1555,[34,402,295,102,794,821,25]); -__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.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1556,[34,102,797,794,821,1555,1553,25]); -__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.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1557,[34,281,402,102,797,794,874,891,1558,999,1226,1463,821,1548,1087,1555,1559,1553,1556,1554,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1558,[846,849,839]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1559,[999]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1560,[34,102,794,821,1561,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1561,[]); -__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.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:$,meId:V,me:Q}=(0,z.useCtx)(3e4);(0,m.useTipsPosted)(e,_);const Y=(0,z.useSignedIn)();(0,x.useSoldOutLink)(!0,(Y?.name??Q).replace(' (example)',''));const[ee,te]=(0,a.useState)({kind:'tab',tab:'home'}),[se,ae]=(0,a.useState)(''),oe=(0,a.useRef)(null);(0,a.useEffect)(()=>{(0,z.ensureAttendance)(_,$),(0,M.ensureChat)($)},[_]),globalThis.__ccNow=$.getTime();const ne=(0,a.useCallback)((e,t=null)=>{if('more'===e&&t){const e=q[t];return void te(e?{kind:'edit',id:e}:{kind:'page',id:t})}te('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,a.useEffect)(()=>(S.useVoiceNav.setState({go:ne}),()=>S.useVoiceNav.setState({go:null})),[ne]),(0,a.useEffect)(()=>{D.PITCH&&(globalThis.__pitchGo=ne,globalThis.__deskGo=e=>te(e))},[ne]),(0,E.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:Y?.id??'',name:Q,onOpen:e=>'bookings'===e?ne('bookings'):'chat'===e?ne('chat'):ne('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!Y}),(0,a.useEffect)(()=>((0,T.warmDesktopStt)(),(0,C.installVoiceKeys)()),[]);const re=(0,a.useMemo)(()=>[...G,...U].map(e=>e.s),[]);(0,a.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void oe.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=re[Number(e.key)-1];return void(t&&(e.preventDefault(),te(t)))}if('z'===t&&!Z(e.target)){const t=(0,W.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!Z(e.target)){const t=(0,W.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[re]);const ie=O.PAGES.filter(e=>(!e.can||e.can(f))&&!q[e.id]),le=(0,a.useMemo)(()=>{const e=se.trim().toLowerCase(),t={};return ie.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ie,se]),de=G.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ue=p.CAN.forecasts(f)?U:U.filter(e=>'rota'===e.s.id),ce='page'===ee.kind?(0,O.pageFor)(ee.id):void 0,be='tab'===ee.kind?G.find(e=>X(e.s,ee))?.label:'edit'===ee.kind?U.find(e=>X(e.s,ee))?.label:ce?.title,he='tab'===ee.kind?G.find(e=>X(e.s,ee))?.tip:'page'===ee.kind?`${ce?.sub??''}. Press ${(0,N.CMD)()}K to jump to any page, or hold Space and ask.`:'',ge=({label:e,s:t,n:s})=>{const a=X(t,ee);return(0,K.jsxs)(o.default,{accessibilityRole:"button",accessibilityState:{selected:a},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>te(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:a?A.colours.goldTint:e?A.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:a?A.colours.gold:'transparent'}),children:[(0,K.jsx)(g.T,{size:14,weight:a?'semibold':'regular',colour:a?A.colours.gold:A.colours.text,style:{flex:1},numberOfLines:1,children:e}),s?(0,K.jsxs)(g.T,{size:11,colour:A.colours.muted,children:[(0,N.CMD)(),s]}):null]})},fe=({t:e})=>(0,K.jsx)(g.T,{size:11,weight:"semibold",colour:A.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),pe='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,K.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:A.colours.bg},testID:"desktop-shell",children:[(0,K.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,K.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(g.Row,{gap:10,children:[(0,K.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(u.VenueName,{name:c.name}),(0,K.jsx)(g.Row,{gap:6,children:(0,K.jsx)(l.AppBadge,{label:pe})})]})]}),(0,K.jsx)(u.PoweredBy,{}),(0,K.jsx)(s.TextInput,{ref:oe,testID:"side-filter",value:se,onChangeText:ae,placeholder:`Find a page (${(0,N.CMD)()}K)`,placeholderTextColor:A.colours.muted,style:[g.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,K.jsxs)(n.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[se?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fe,{t:"Run the day"}),de.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:t+1},e.label)),(0,K.jsx)(fe,{t:"Drag-and-drop editors"}),ue.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:de.length+t+1},e.label))]}),Object.entries(le).map(([e,t])=>(0,K.jsxs)(r.default,{children:[(0,K.jsx)(fe,{t:e}),t.map(e=>(0,K.jsx)(ge,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{flex:1},children:[(0,K.jsx)(r.default,{testID:"desk-title",children:(0,K.jsx)(g.T,{size:24,weight:"bold",children:be??''})}),(0,K.jsxs)(g.Muted,{size:12,children:[Y?`Signed in as ${Y.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]}),(0,K.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(g.T,{size:15,weight:"bold",colour:A.colours.gold,children:"Talk to CoverCharge"}),(0,K.jsxs)(g.Muted,{size:12,children:["Hold Space, or ",(0,N.CMD)(),"\u21e7G"]})]}),(0,K.jsx)(v.VoiceSlot,{size:76})]}),(0,K.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[he?(0,K.jsx)(F.Tip,{children:he}):null,'edit'===ee.kind?(0,K.jsx)(J,{id:ee.id,rid:e,me:Q,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,K.jsxs)(n.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===ee.kind&&'home'===ee.tab?(0,K.jsx)(H.Dashboard,{go:ne}):null,'tab'===ee.kind&&'orders'===ee.tab?(0,K.jsx)(I.Orders,{}):null,'tab'===ee.kind&&'bookings'===ee.tab?(0,K.jsx)(R.Bookings,{}):null,'tab'===ee.kind&&'forecast'===ee.tab?(0,K.jsx)(P.Forecasts,{go:ne}):null,'tab'===ee.kind&&'chat'===ee.tab?(0,K.jsx)(M.Chat,{go:ne}):null,ce?(0,K.jsx)(ce.C,{go:ne}):'page'===ee.kind?(0,K.jsx)(g.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,K.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,K.jsx)(h.PrintHost,{rid:e}):null,'staff'!==f?(0,K.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Q,onOpen:e=>ne('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,K.jsx)(L.AssistantSheet,{}),(0,K.jsx)(B.OnboardingHost,{go:ne}),(0,K.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),s=_r(d[1]),a=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]),g=_r(d[12]),f=_r(d[13]),p=_r(d[14]),x=_r(d[15]),m=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),S=_r(d[22]),v=_r(d[23]),T=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),z=_r(d[31]),H=_r(d[32]),P=_r(d[33]),B=_r(d[34]),I=_r(d[35]),O=_r(d[36]);_r(d[37]);var _=_r(d[38]),N=_r(d[39]),W=_r(d[40]),$=_r(d[41]),V=_r(d[42]),F=_r(d[43]),K=_r(d[44]);const G=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Hold Space and say \u201chow many Covers tonight?\u201d for a quick answer without leaving this screen.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first. Say \u201cshow new orders\u201d to jump back any time.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber. Hold Space and say \u201caccept the 7 o\u2019clock\u201d.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],U=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],q={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},X=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),Z=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function J({id:e,rid:t,me:s,role:o,today:n,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,a.useState)(0),[h,p]=(0,a.useState)('');return'menu'===e?(0,K.jsx)($.MenuEditor,{rid:t,me:s,role:o}):'rota'===e?(0,K.jsx)(V.RotaEditor,{today:n}):'brand'===e?(0,K.jsx)(_.BrandEditor,{rid:t}):(0,K.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,K.jsxs)(F.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,N.CMD)(),"Z undoes, then Save."]}),h?(0,K.jsx)(g.T,{size:13,colour:A.colours.goldLight,children:h}):null,(0,K.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:A.colours.border,borderRadius:12,overflow:'hidden'},children:(0,K.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1562,[828,827,34,402,295,102,36,1358,873,1361,1237,1385,794,1028,891,979,1061,1470,1114,1113,1111,1563,1477,1156,931,1239,2,821,1489,1414,1179,1087,1432,1472,1464,1474,1456,1475,1564,1542,1566,1568,1570,1567,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1563,[846]); -__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.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1564,[34,295,102,1498,873,794,891,829,1457,821,1565,1566,1567,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1565,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1566,[34]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1567,[34,102,794,821,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1568,[827,34,102,794,876,831,979,981,982,861,882,1173,821,1565,1566,1567,1569,25]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1569,[891]); -__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.RotaEditor=function({today:e}){const y=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[$,j]=(0,t.useState)((0,i.mondayOfDate)(e)),[v,k]=(0,t.useState)(null),[w,D]=(0,t.useState)(''),B=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),O=b.map((e,t)=>(0,i.addDays)($,t)),P=(e,t,o)=>{e.preventDefault(),k(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=y.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=$&&e.date<=O[6]),I=T.filter(e=>!e.published||e.changed).length;return(0,p.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,p.jsx)(h.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,p.jsxs)(s.Row,{gap:8,children:[(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>j((0,i.addDays)($,-7))}),(0,p.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date($+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>j((0,i.addDays)($,7))}),(0,p.jsx)(d.default,{style:{flex:1}}),w?(0,p.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:w}):null,(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!B.canUndo,onPress:B.undo,testID:"rota-undo"}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!B.canRedo,onPress:B.redo,testID:"rota-redo"}),(0,p.jsx)(s.Button,{small:!0,label:I?`Publish (${I})`:'Published',disabled:!I,onPress:()=>{B.record('published the week');const e=i.useOwner.getState().publishWeek($);D(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,p.jsx)("div",{style:(0,h.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,p.jsxs)("div",{style:(0,h.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,p.jsx)("div",{style:(0,h.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),O.map((t,o)=>(0,p.jsxs)("div",{style:(0,h.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[b[o]," ",Number(t.slice(8))]},t)),y.map(e=>(0,p.jsxs)(o.default.Fragment,{children:[(0,p.jsxs)("div",{style:(0,h.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,p.jsx)("div",{style:(0,h.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,p.jsx)("div",{style:(0,h.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),O.map(t=>{const o=`${e.id}|${t}`,d=T.filter(o=>o.staffId===e.id&&o.date===t);return(0,p.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',k(o)},onDragLeave:()=>k(null),onDrop:o=>P(o,e.id,t),style:(0,h.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,p.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,h.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,p.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]),f=r(_d[9]),p=r(_d[10]);const b=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],x=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1570,[34,102,794,891,1090,821,1565,1566,1567,1569,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1571,[30,34,872,1572,25]); -__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1572,[1457,1573,828,996,1098,1507,1223,1054,1055,1508,1532,1510,1173,979,1015,1574,1012,2,1060,1061,1483,998,1038,999,34,1175,1248,1252,1219,373,402,295,102,426,36,794,873,1156,891,821,1179,1414,1093,1111,1113,1107,1056,1039,1087,1501,1496,1516,1575,1423,1003,236,1254,1198,1204,1455,1218,1217,1471,1201,15,1224,1225,925,793,987,25]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1573,[34,102,794,1087,987,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1574,[236,1013]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1575,[860,34,102,794,891,1028,858,1090,1088,987,1089,5,1000,821,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1576,[30,34,872,25]); -__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1577,[1451,987,795,1408,1578,1025,30,1605,496,34,385,336,236,41,102,5,873,872,1607,36,874,1028,891,821,1423,1003,1023,1608,1609,1057,1610,1129,2,1038,998,1612,1376,25,1614,1615,1616,1617]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1578,[1579,1602,1604]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1579,[215,1580,1583,1597,1598,1599,1600,1601]); -__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1580,[215,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1581,[1582]); -__d(function(g,r,i,a,m,e,d){},1582,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1583,[1584,215,1580,1597,1598]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1584,[1585,1586,1596]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1585,[1586,1590,1595]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1586,[215,372,1587,1591,1592,1593,1594,1590,1595]); -__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1587,[215,1588,339,280,1589,1590]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1588,[504]); -__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1589,[215,339]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1590,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1591,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1592,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1593,[1591]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1594,[]); -__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1595,[372,1589]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1596,[34,1586]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1597,[1584,215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1598,[1584,1597]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1599,[1580]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1600,[215,1580,1583,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1601,[]); -__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1602,[215,54,1603]); -__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1603,[215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1604,[34,1579]); -__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]}})})},1605,[1606]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1606,[]); -__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1607,[34,41,102,426,794,873,1003,987,2,5,821,1547,1549,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1608,[989,883,882,987]); -__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1609,[828,796,827,34,1011,1458,1029,402,102,872,987,1013,1028,5,821,794,1354,976,2,25]); -__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1610,[5,796,827,34,385,283,364,380,236,402,295,426,102,1489,1156,2,797,1087,15,891,794,821,1522,932,1611,1520,1521,1477,1157,1487,931,1563,1530,25,277]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1611,[891,831,1028]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1612,[874,831,891,1038,15,1003,872,2,1613]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1613,[874,1038]); -__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1614,[]); -__d(function(o,s,e,p,c,t,d){"use strict";c.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1615,[]); -__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1616,[]); -__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1617,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1618,[30,34,872,25]); -__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1619,[1620]); -__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1620,[25,1621,591]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1621,[34,172]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1622,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1623,[25,499,34,270,651]); +__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return Q.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return Q.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return Q.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return Q.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return Q.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ot}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ie.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ie.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ie.useOwner.getState().chatSeen(t,e)),$t(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ie.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...ht(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(fe.PITCH)return ge.unlockCashUp(e,t,a);const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?de.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):de.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(fe.PITCH)return ge.cashAudit(e);const t=Ae.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(_a.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=pa,i.readAccessLog=async function(){const e=Ae.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ae.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return ga}}),i.uploadOrderLogo=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(ga).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ma.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(ga).createSignedUrl(e,3600);if(t?.signedUrl)return ma.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(ga).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return _a}}),i.claimInvite=Ua,i.makeChromeHandover=async function(){const e=Ae.getState();if(fe.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ee});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(fe.PITCH||!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ee});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),Me&&qa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Ne();const t=await q.kv.get(Ia,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Ne(),await q.kv.get(Oa,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_WILDINGS||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Ne(),await q.kv.remove(Ia),await q.kv.remove(Oa),Ce({mode:'signin',perms:[]});try{await xa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ae.getState().venueId;if(fe.PITCH||!s||'staff'!==Ae.getState().kind)return{ok:!0};if(!(0,re.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Pa('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ua(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(fe.PITCH)return ge.reissueInvite(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Pa('staff_app_link_history',{p_venue:Ae.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Pa('revoke_staff_app_link',{p_venue:Ae.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(fe.PITCH)return ge.linkPhones();const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return{};try{const t=await Pa('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(fe.PITCH)return ge.resetPhone(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Number(await Pa('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(fe.PITCH)return ge.inviteStatus();const e=Ae.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:t,error:a}=await Re().rpc(d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_pairing_code':d.IS_GREENSIDE?'claim_greenside_pairing_code':d.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':d.IS_KIRKTON?'claim_kirkton_pairing_code':d.IS_WILDINGS?'claim_wildings_pairing_code':d.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':d.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await q.kv.set(ka,n),qa(),{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}`}}},i.carPairStart=async function(){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await q.kv.set(Ea,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ta(e)}}},i.carPairPoll=async function(e){try{Ne();const t=e??await q.kv.get(Ea,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,J.carPairApproved)(n)){const e=(0,J.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await q.kv.get(ka,null);await q.kv.set(ka,e),await q.kv.remove(Ia),A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||qa()}return'revoked'!==i&&'unknown'!==i||await Na(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Ne(),await Re().rpc('car_sign_out')}catch{}await Na(),await xa();try{await Re().auth.signOut({scope:'local'})}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Pa('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ta(e)}}},i.carList=async function(){const e=Ae.getState().venueId;if(!e)return[];return(await Pa('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Pa('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ta(e)}}},i.unpairDisplay=async function(){await q.kv.remove(ka),await xa();try{await Re().auth.signOut()}catch{}Ce({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await q.kv.remove(Ia),await q.kv.remove(Oa),await xa();try{await Re().auth.signOut()}catch{}Ce({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.'})},i.wipeThisDevice=async function(e={}){try{await xa()}catch{}try{(0,N.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${d.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!d.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Ka,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Pa}}),i.mendSession=La,i.startAppSync=async function(e=d.VENUE_RID){if(d.IS_ISOLATED_VENUE&&e!==d.VENUE_RID)return;if(Me)return;Me=!0,Ba=e,'customer'===Ee&&'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Ne(),'customer'!==Ee){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ee&&(0,y.isAnchorage)(e)?[V.useStore,ie.useOwner,se.useKitchen,ne.useSafety,X.useCardStore,_.useGpCalc,ee.useOrderSheets,h.useSpecials,C.useHr]:[V.useStore,ie.useOwner,se.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ee&&(0,y.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ce({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Os(e)}catch{if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e))return void Ce({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,N.isSupabaseConfigured)())return void Ce({mode:'off'});F.mutationQueue.subscribe(()=>{const e=F.mutationQueue.waiting,t=e[0];Ce({pending:F.mutationQueue.pending.length,failed:F.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,B.describeWrite)(t)}: ${(0,B.plainReason)({...t.lastErr},'retry')}`:void 0})}),F.mutationQueue.onFailed(e=>Ce({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:F.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,B.describeWrite)(e),why:'conflict'===e.reason?(0,B.plainReason)({code:'conflict'},'refused'):(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Pe.push((0,K.onConnectivity)(e=>Ce({mode:e?Ae.getState().venueId?'live':Ae.getState().mode:Ae.getState().venueId?'offline':Ae.getState().mode}))),await ja()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Qa}}),i.serverOrder=Za,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return Ya}}),i.nudgeGuestSync=function(){Xa?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return es}}),i.stockSaveBlocker=ts,i.stockEventStatus=function(e){if(Ze(e))return{state:'saved'};const t=F.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,B.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=as,i.saveStockEventsNow=ss,i.bookingSaveBlocker=is,i.resendUnsavedBookings=ds,i.saveBookingsNow=us,i.waitForBookingSave=function(e,t=12e3){if(!Ue())return Promise.resolve({state:'local'});const a=is();if(a)return Promise.resolve({state:'refused',why:a});const s=rs()[0]?.venueId??'',n=()=>ns.some(t=>F.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=$.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,K.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(F.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(F.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||rs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||rs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=gs,i.tempLogState=function(){const e=ms()[0]?.venueId??'',t=ms().find(e=>'temp_readings'===e.spec.table),a=F.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!F.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(W.useTempSaves.getState().notSaved),i=ne.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=_s,i.waitForTempSave=function(e,t,a=1e4){if(!Ue()||!ms().length)return Promise.resolve({state:'local'});const s=gs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ms()[0]?.venueId??'',i=ms().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>W.useTempSaves.getState().notSaved[(0,W.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>F.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=ws,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ms}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Ps.get(a);if('customer'!==Ee||!(0,N.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Ps.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Pa('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:Le(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:Le(a.from_time),to:Le(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Ps.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ms.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Ps.get(a);e&&!e.ok&&Ps.delete(a)}));const n=Ps.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ae.getState().venueId;if(!n||'staff'!==Ae.getState().kind)throw new Error('Connect to your venue first.');const i=await Pa('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});V.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return null;return(await Pa('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');await Pa('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),O=t(r[18]),R=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(pe),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]),Oe=t(r[71]);const Re=()=>(0,T.getSupabase)();F.mutationQueue.setExecutor(L.executeMutation),(0,M.setClockServer)(()=>'staff'===Ae.getState().kind);const Ae=(0,E.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ce=e=>Ae.setState(e),De=e=>{const t=Ae.getState().perms;return t.includes('*')||t.includes(e)},Ue=()=>{const e=Ae.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ae.subscribe(()=>(0,be.setLiveData)(Ue()));let Ee=G.IS_CAR?'car':G.APP_VARIANT,Te=!1;const Ne=()=>{Te||((0,q.setSyncNamespace)(Ee),Te=!0)};let Ke=[],Pe=[],Me=!1;const xe=()=>(new Date).toISOString().slice(0,10),qe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),Le=e=>e?e.slice(0,5):'',Be=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))):[],je=e=>JSON.parse(JSON.stringify(e));function Fe(e,t){const a=qe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>V.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=je(e);if(t)return{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:Be(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,re.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:Be(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function $e(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>V.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.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,re.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:je(e.lines??[]),allergies:Be(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:je(e.allergyChain??{}),readiness:je(e.readiness??{}),allergy_ticks:je(e.allergyTicks??{}),handover_check:e.handoverCheck?je(e.handoverCheck):null,accepted:e.accepted?je(e.accepted):null,doc:je(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)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function We(e){const t=qe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...z.useBlocks.getState().blocks,...z.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Ae.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:je(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,z.blockClock)(t.from_time)??a?.from,n=(0,z.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>z.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>z.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Qe=null,He='Main plan';function Ve(e){const t=e=>je({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(Z.useFloor.getState().plans[e]??(0,Z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>De('floor.manage')||De('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Qe??(0,ke.uuidFrom)(`plan:${a}`),venue_id:a,name:He||'Main plan',is_active:!0,...t(e),updated_by:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>(Qe=String(e.id),He=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,Ie.withSeedBest)(e,t[0]):void 0;a&&Z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>Z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ge(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Y.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>De('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,re.isUuid)(e.supplierId)?e.supplierId:(0,ke.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),dt.get(t)??t)}:{}};var t},apply:(t,a)=>Y.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Je=new Set,ze=new Set;F.mutationQueue.onDone(e=>{'stock_events'===e.table&&ze.add(e.rowKey)});const Ze=e=>ze.has(e)||Je.has(e),Ye=()=>De('*')||De('staff.manage')||De('recipes.edit')||De('recipes.signoff'),Xe=()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write'));function et(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Y.useShellStore.getState().events.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,re.isUuid)(t.id)&&!!(Y.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('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,re.isUuid)(e.undoes)&&(Ze(e.undoes)||F.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Je.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)=>Y.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function tt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Y.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={...Y.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Y.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Je]}}}))},afterRead:()=>{Y.useShellStore.getState().server[e]||Y.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Je]}}}))},subscribe:()=>()=>{}}}const at=new Set;function st(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=V.useStore.getState().menu;return X.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:t=>(0,re.isUuid)(t.card.id)&&!((0,y.isAnchorage)(e)&&(0,y.isDemoCard)(t.card))&&!(0,y.isPlaceholderCard)(t.card),writable:()=>De('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,y.isAnchorage)(e)&&(s={...s,signOff:(0,y.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,y.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,y.isAnchorage)(e)&&(0,y.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,ke.photoPath)(a,s),t=nt(s.photo);t&&((0,X.cachePhotoAs)(e,t),it(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,ke.cardToRow)(s,a);return{...i,...r,doc:je({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,y.isPlaceholderCard)(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,signOff:(0,y.isAnchorage)(e)&&(0,y.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!De('recipes.edit')&&t.length){const e=new Set(t);X.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);X.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&V.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&V.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=X.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=V.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const nt=e=>(0,X.readLocalPhoto)(e);async function it(e,t){if(!at.has(e)){at.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(ke.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){at.delete(e),Ce({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const rt=new Map,ot=(0,E.create)(()=>({n:0}));(0,X.setStoragePhotoResolver)(e=>{const t=rt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,N.isSupabaseConfigured)()&&'off'!==Ae.getState().mode?(t||(rt.set(e,{url:'',at:Date.now()}),Re().storage.from(ke.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(rt.set(e,{url:t.signedUrl,at:Date.now()}),ot.setState(e=>({n:e.n+1})),X.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const dt=new Map;const ut=(e,t)=>{const a=(0,re.isUuid)(t)?t:(0,ke.uuidFrom)(`sup:${e}:${t}`);return dt.set(a,t),a};function ct(e){return{name:'order_sheets',table:'suppliers',list:()=>ee.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,y.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>De('suppliers.manage'),toRow:(e,t)=>({id:ut(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:je(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(dt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ee.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ee.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,re.isUuid)(e)?e:(0,ke.uuidFrom)(`sup:${Ae.getState().venueId}:${e}`)})}}let lt=!1,ft=!1;const pt=new Map,gt=new Map,mt=new Map,_t=new Map,St=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ht=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'},yt=(e,t)=>({...e,managerAccess:t}),wt=()=>({nickname:lt,display:ft}),vt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=yt({role:e.role,level:e.level??ht(St(e)).level},!0===e.managerAccess);return(0,j.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},wt())};const bt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},kt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},It=e=>{const t=ie.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ot=2e3;function Rt(e,t){return t||!e.length||e.length>=Ot?null:e=>(0,re.isUuid)(e.id)}function At(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,De('rota.manage')):null,keepOnEmpty:()=>e&&!De('rota.manage'),list:()=>ie.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&pt.has(e.staffId)&&(De('rota.manage')||It(e.staffId)),writable:()=>De('rota.manage')||De('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(bt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:kt(e.start),end_time:kt(e.end),published:!!e.published,doc:je(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Ct(){const e=qe(62),t=e=>De('rota.manage')||e.staffId===Ae.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ie.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ae.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=qe(2)&&e.staffId===Ae.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:je(e.breaks??[]),break_mins:e.breakMins??0,doc:je((0,w.privateAttendance)(d.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,w.privateAttendance)(d.VENUE_RID,{...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Dt(){const e=qe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.staffId===Ae.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ae.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:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,re.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:je({...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Ut(e){ie.leaveRemote.decide=t=>!(!De('rota.manage')||!(0,re.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(F.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Pe.push(()=>{ie.leaveRemote.decide=null})}function Et(e){ie.timesheetRemote.send=(t,a)=>{if(!De('rota.manage')||!(0,re.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return F.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:je(s)}}),!0}const s=a;if('attendance_void'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return F.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:je(s.breaks??[]),p_reason:n,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0},Pe.push(()=>{ie.timesheetRemote.send=null})}function Tt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>V.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ae.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,re.isUuid)(a)?a:(0,ke.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,re.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:je(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>V.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=>V.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Nt=e=>V.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Kt(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}));V.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Pt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=V.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[je({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:Z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Nt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>De('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...xt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...xt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...xt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Mt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Mt=t.feature_flags??{},xt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),je({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}:{}})},apply:t=>{const a=t[0];a&&(V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&Z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Kt(e,a.events))},subscribe:e=>{const t=V.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=Z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Mt=null,xt=null;const qt=()=>new Date(Date.now()-2592e6).toISOString(),Lt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Bt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>gt.get(e));return 2===t.length&&t[0]&&t[1]?(0,he.dmId)(t[0],t[1]):null},jt=()=>Ae.getState().perms.includes('*');function Ft(){const e=()=>Ae.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ie.useOwner.getState().chat.filter(e=>(0,re.isUuid)(e.id)).map(e=>je({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=>!!Lt(t.ch)&&(t.from===e()||jt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('created_at',qt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=qt(),toRow:(e,t)=>{const a=Lt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:pt.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=Bt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?gt.get(String(e.from_staff)):'system';return s?je({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ie.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?gt.get(String(t.from_staff)):'system',i=Bt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ie.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,he.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,ye.soundAllowed)())try{(0,ye.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,k.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function $t(e,t,a){const s=Ae.getState();if(!Se.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=pt.get(e),i='*'===t?'*':Lt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Wt(e){const t=Ae.getState().staffRef,a=t?pt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Bt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ie.useOwner.getState().chatMarkRead(t,i)}catch{}}function Qt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=D.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:je(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>D.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,U.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Ht(e){const t=qe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>D.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.reminderId)&&e.staffRef===Ae.getState().staffRef,writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>D.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Vt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Gt=e=>null==e||''===e?null:Number(e),Jt=e=>e.filter(e=>!e.startsWith('data:')),zt=()=>De('takings.view');function Zt(e){const t=!zt();return{name:'cash_ups',table:'cash_ups',list:()=>de.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',qe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:je(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({cashUps:Vt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Yt(e){return{name:'sales_reports',table:'sales_reports',list:()=>de.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:je(e.vals),categories:e.categories,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({sales:Vt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Xt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=de.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,de.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:je({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,de.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>de.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ea(e){return{name:'day_tips',table:'day_tips',list:()=>de.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',qe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>de.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ta(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>de.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Gt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>de.useCashUp.setState(s=>({pot:Vt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function aa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=de.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>De('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>de.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function sa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>oe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:je(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>oe.useNotifs.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>oe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function na(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ue.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:je(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ue.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ce.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Vt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ia(e){const t=()=>De('venue.settings')||De('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ue.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,re.isUuid)(a.id)&&(0,re.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ue.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ae.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ae.getState().staffRef)||null,doc:je(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ra(e){const t=qe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ue.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:je(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({history:Vt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function oa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=le.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:je(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>De('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&le.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,w.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>le.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function da(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=me.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,me.libraryRowId)(e),kind:'library',doc:je({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,me.personRowId)(e,i),kind:'person',staffRef:i,doc:je({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ie.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,_e.canEditTasks)(t,a)},writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>me.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,me.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ua(e){const t=qe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>me.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ae.getState();return e.byRef===t.staffRef||De('staff.manage')},writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>me.useDailyTasks.setState(s=>({ticks:Vt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ca(e,t=!1){const a=qe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>we.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind||De('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,ke.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>we.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>we.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{ve.autoSync.soldOutRead.add(e)}}}function la(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>ve.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:(0,ke.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>ve.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>ve.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{ve.autoSync.linksRead.add(e)}}}async function fa(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&q.kv.get(a,!1):(q.kv.set(a,!0),!0)}catch{return q.kv.get(a,!1)}}async function pa(){const e=Ae.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();_a.setState({live:!!t?.push_live,known:!0})}catch{}}const ga='order-list-logos';const ma=new Map;const _a=(0,E.create)(()=>({live:!1,known:!1}));async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('reminders:ok',!1):(q.kv.set('reminders:ok',!0),!0)}catch{return q.kv.get('reminders:ok',!1)}}async function ha(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('chat:ok',!1):(q.kv.set('chat:ok',!0),!0)}catch{return q.kv.get('chat:ok',!1)}}const ya=(e,t)=>je({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),wa='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function va(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>C.useHr.getState().questions.filter(t=>t.venue===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ya(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);C.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>C.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function ba(e,t){const a=(t,a,s)=>{F.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(C.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(wa).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||C.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ya(e,t)))}catch{}}}),Pe.push(()=>{Object.assign(C.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ka='pair:v1',Ia='staff:v1',Oa='staff:rejoin:v1';async function Ra(e){const t=d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_invite':d.IS_GREENSIDE?'claim_greenside_invite':d.IS_ABBOTSFORD?'claim_abbotsford_invite':d.IS_KIRKTON?'claim_kirkton_invite':d.IS_WILDINGS?'claim_wildings_invite':d.IS_KIRKMICHAEL?'claim_kirkmichael_invite':d.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ee,p_device:(0,A.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,A.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Aa(){if('display'===Ee||'customer'===Ee||fe.PITCH)return'none';const e=await q.kv.get(Oa,null);if(!e)return'none';try{await Da();const{data:t,error:a}=await Ra(e);if(a)return(0,O.inviteRefusal)(a.message)?(await q.kv.remove(Oa),await q.kv.remove(Ia),'refused'):'offline';const s=t?.[0];return s?(await q.kv.set(Ia,{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,displayName:s.display_name}),'ok'):(await q.kv.remove(Oa),'refused')}catch{return'offline'}}const Ca=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Da(){Ne();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ce({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 Ua(e){if(fe.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Ra(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,d.venueKey)(`cc-pending-invite:${Ee}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),await q.kv.set(Oa,e),Me&&qa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ce({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ea='car:request:v1',Ta=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Na(){await q.kv.remove(ka),await q.kv.remove(Ia),await q.kv.remove(Ea),A.useSession.getState().meId&&A.useSession.getState().signOut()}async function Ka(){if(!(0,N.isSupabaseConfigured)())return!1;try{return await Da(),!0}catch{return!1}}const Pa=async(e,t={})=>{if(fe.PITCH)return(0,pe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Ma=null;async function xa(){for(const e of Pe)try{e()}catch{}Pe=[],Ke.forEach(e=>e.stop()),Ke=[],Ma&&(clearInterval(Ma),Ma=null)}async function qa(){await xa(),await ja()}async function La(){if(!(0,N.isSupabaseConfigured)()||'customer'===Ee||fe.PITCH)return!1;try{Ne();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ee)return!1;if(!await q.kv.get(Oa,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Aa()&&(qa(),!0)}catch{return!1}}(0,c.setSessionMender)(La);let Ba=d.VENUE_RID;async function ja(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Ba;try{if(Ce({mode:'connecting'}),await F.mutationQueue.load(),'customer'===Ee)return void await Va(e);let t=await q.kv.get(ka,null),a=await q.kv.get(Ia,null);if(G.IS_CAR&&!t&&a){const e=(0,J.migrateCarStaffIdentity)(a);e&&(t=e,await q.kv.set(ka,t)),await q.kv.remove(Ia),a=null,A.useSession.getState().meId&&A.useSession.getState().signOut()}if(d.IS_ISOLATED_VENUE&&(t&&!(0,d.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,d.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ce({mode:'display'===Ee?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ee&&!G.IS_CAR&&a&&!s.session){const t=await Aa();if('offline'===t)return Ce({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Ba===e&&qa()},6e4);'refused'===t&&a.staffRef&&A.useSession.getState().meId===a.staffRef&&A.useSession.getState().signOut(),a=await q.kv.get(Ia,null),({data:s}=await Re().auth.getSession())}const n='display'===Ee||G.IS_CAR?t:a;if(!s.session||!n)return void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Pa('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ee||G.IS_CAR?await q.kv.remove(ka):(await q.kv.remove(Ia),await q.kv.remove(Oa)),'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId===n.staffRef&&A.useSession.getState().signOut(),void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ee?'This display was unpaired by a manager.':G.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,K.isOnline)()||/fetch|network/i.test(String(t?.message)))Ce({mode:'offline'});else if(Ca(t)&&'display'!==Ee){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Aa()&&setTimeout(()=>{Ba===e&&qa()},500)}i=Ae.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ce({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!G.IS_CAR&&'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId!==n.staffRef&&(A.useSession.getState().signIn(n.staffRef),ie.useOwner.setState({staffAs:n.staffRef})),G.IS_CAR&&(A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({previewRole:'owner'})),await $a(n.venueId,e,n.kind)}catch(e){Ce({mode:'local',lastError:String(e?.message??e)})}}const Fa=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','venue_reminders','reminder_done']);async function $a(e,a,s){if(!(0,d.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||G.IS_CAR&&'device'===s;await ws(a),Pe.push(Ks(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])mt.set(e.key,e.id),_t.set(e.id,e.key)}catch{}const i=[Pt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ie.useOwner.getState().staff.map(vt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>De('staff.manage'),deletes:!1,revision:e=>(0,j.staffRevision)(e,wt()),toRow:(e,t)=>(0,j.staffRow)(e,t,wt(),e.managerAccess||e.ownerAccess?null:mt.get(St(e))),fromRow:e=>{if(!e.external_ref)return null;pt.set(String(e.external_ref),String(e.id)),gt.set(String(e.id),String(e.external_ref)),Us.set(String(e.external_ref),e.avatar_path??null);const t=yt(ht(_t.get(String(e.role_id))),!0===e.manager_access);return(0,j.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},wt())},apply:e=>ie.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=>ie.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ns()},onRemote:()=>{Ns()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ie.useOwner.getState(),t=ae.useSetup.getState().sites[Ba]?.staffGrade??{};return e.staff.filter(e=>pt.has(e.id)).map(a=>je({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=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:pt.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=gt.get(String(e.staff_id));return t?je({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=>ie.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=ae.useSetup.getState().sites[Ba],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&&ae.useSetup.getState().patch(Ba,{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=ie.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=ae.useSetup.subscribe((t,a)=>{t.sites[Ba]?.staffGrade!==a.sites[Ba]?.staffGrade&&e()});return()=>{t(),a()}}},Fe(a,!1),Fe(a,!0),We(a),Ve(a),$e(a),Ge(a),et(a),tt(a),ct(a),{name:'supplier_directory',table:'suppliers',list:()=>ie.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('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:je(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ie.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId),writable:()=>De('suppliers.order')||De('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||xe(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:je(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},st(a),As(a)];De('wages.view')&&i.push(Cs(a)),n&&(i.push(At(!0),Ct(),Dt(),Tt(a)),Et(e)),n&&await fa('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ae.getState().staffRef&&'pending'===e.status||De('rota.manage')),writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:je(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Fa.add('staff_leave'),Ut(e));const o=n&&await ha();if(Se.useChatSync.setState({synced:o,checked:!0}),Pe.push(()=>Se.useChatSync.setState({synced:!1})),o&&i.push(Ft(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(he.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:pt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:pt.get(e.id),include:e.include}),fromRow:e=>{const t=gt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>he.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=>he.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await fa('hr_questions')&&(i.push(va(a)),Fa.add('hr_questions'),ba(e,a)),'guest'!==s&&'customer'!==Ee&&await fa('temp_readings')&&(i.push((0,Q.tempUnitsSpec)(ne.useSafety,Ye),(0,Q.tempReadingsSpec)(ne.useSafety,Xe)),Fa.add('temp_units'),Fa.add('temp_readings')),'guest'!==s&&await fa('sold_out_items')?(i.push(ca(a,await fa('sold_out_items','auto'))),Fa.add('sold_out_items')):ve.autoSync.soldOutRead.add(a),'guest'!==s&&await fa('sold_out_links')?(i.push(la(a)),Fa.add('sold_out_links')):ve.autoSync.linksRead.add(a),D.useReminders.getState().ensure(a),'guest'!==s&&await Sa()&&(i.push(Qt(a)),n&&i.push(Ht(a))),oe.useNotifs.getState().ensure(a),ue.useOrderLists.getState().ensure(a),n){lt=await fa('staff','nickname'),ft=await fa('staff','display_clock');const[e,t,s,n]=await Promise.all([fa('scheduled_notifications'),fa('order_lists'),fa('venue_clock_area'),fa('daily_tasks')]);me.useDailyTasks.getState().ensure(a),n&&(i.push(da(a),ua(a)),Fa.add('daily_tasks'),Fa.add('daily_task_ticks')),e&&(i.push(sa(a)),pa()),t&&i.push(na(a),ia(a),ra(a)),s&&i.push(oa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Fa.add(n)}if('guest'!==s&&await fa('day_tips')){i.push(ea(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Fa.add(e);await fa('tips_pot_events')&&i.push(ta(a),aa(a)),n&&(zt()||(0,de.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(Zt(a),Xt(a)),Fa.add('cash_ups'),zt()&&(i.push(Yt(a)),Fa.add('sales_reports')),t(r[73])(r[72],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(At(),Ct()),await fa('scheduled_notifications')&&i.push(sa(a)));let u=!1;const c=()=>{if(G.IS_CAR&&n&&De('recipes.edit'))return!0;const e=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);return!!e&&e.active&&De('recipes.edit')&&(0,S.costsAllowedFor)(e)};n&&c()&&await fa('ingredient_prices')&&(i.push((0,_.gpSyncSpec)('ing',c)),Fa.add('ingredient_prices'),await fa('card_costs')&&(i.push((0,_.gpSyncSpec)('card',c)),Fa.add('card_costs')),await fa('kitchen_deliveries')&&(i.push((0,_.gpSyncSpec)('del',c)),Fa.add('kitchen_deliveries')),await fa('kitchen_stock_counts')&&(i.push((0,_.gpSyncSpec)('count',c)),Fa.add('kitchen_stock_counts'))),(0,Oe.specialsSyncOn)()&&'guest'!==s&&await fa('specials_boards')&&(i.push((0,Oe.specialsBoardSpec)(a,()=>De('recipes.edit')||De('floor.manage')||De('*'))),Fa.add('specials_boards'));const l={onActivity:()=>Ce({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ce({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ce({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Pa('whoami')??[]).some(t=>t.venue_id===e))return void(Ba===a&&qa());for(const a of Ke){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||$.useBookingSaves.getState().mark({id:t,table:e,why:is()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||W.useTempSaves.getState().mark({id:t,table:e,why:gs(e)??'this screen could not send it'})}};Ke=i.map(t=>new H.EntityBridge(t,e,l)),await Promise.all(Ke.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,K.isOnline)())try{const t=await Pa('whoami');if(!t?.some(t=>t.venue_id===e))return void(Ba===a&&qa())}catch(e){if(Ca(e)){if(G.IS_CAR)return void(Ba===a&&qa());const e=await Aa();return void('ok'!==e&&'refused'!==e||Ba===a&&qa())}}let t=0;for(const[a,s]of Ke.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(Se.useChatSync.getState().error&&Se.useChatSync.setState({error:void 0}),await Wt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&Se.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({mode:'live',lastSyncAt:e,lastServerAt:e}),F.mutationQueue.flush()}else Ce({mode:'offline'});if(!De('wages.view')){const e=Ae.getState().staffRef;ie.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const m=new Map;for(const e of Ke)m.set(e.spec.table,[...m.get(e.spec.table)??[],e]);const h=[...m.keys()].filter(e=>Fa.has(e)).map(e=>({table:e,venueColumn:m.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,H.venueChannel)(e,h,(e,t,a)=>{for(const s of m.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ce({lastSyncAt:s,lastServerAt:s})},e=>{Ce({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Pe.push(()=>{Re().removeChannel(w)}),Pe.push((0,K.onConnectivity)(e=>{e&&p()}));const v=Ke.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,P.superviseSync)({fastMs:Qa(Ee),readFast:async()=>{for(const e of v)await e.read()},readAll:p,flush:()=>{F.mutationQueue.flush()},wake:()=>{F.mutationQueue.retryNow()},restart:()=>{Ba===a&&qa()},realtime:()=>Ae.getState().realtime,lastServerAt:()=>{const e=Ae.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Ca,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>Wa(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Pe.push(k.stop)}async function Wa(e){const t=Ae.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Pa('sync_heartbeat',{p_venue:e,p_device:(0,A.deviceId)()??'unknown',p_app:Ee,p_version:x.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Qa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ae.getState(),queue:F.mutationQueue.pending.map(e=>e.table),failedTables:F.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),fe.PITCH&&(window.__ccSyncPreview=e=>Ce(e)));const Ha='guest:sent:v1';async function Va(e){Ce({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Pa('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!d.IS_ISOLATED_VENUE||t.id===d.VENUE_UUID)){Ce({venueId:t.id,venueName:t.name}),await ws(e);const a=t.app?.restaurant;a&&V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withWildingsAddress)({...a,id:e}):t)})),Kt(e,t.app?.events)}await Ga(e),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ce({mode:(0,K.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Ga(e).catch(()=>{})},6e4);Pe.push(()=>clearInterval(t)),d.IS_ISOLATED_VENUE||await Ja(e)}async function Ga(e){const t=await Pa('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));X.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&V.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))]}});try{const t=await Pa('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function Ja(e){let t=await q.kv.get(Ha,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=V.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Ka())return;for(const a of n)try{const s=(await Pa('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(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&&V.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'},Ce({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Pa('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(a.allergies)}}))?.[0];t={...t,[a.id]:'order'},s&&V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?Za(e,s):e)}))}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ce({lastError:`Order: ${s}`}),V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:Ya(s)}}:e)})))}await q.kv.set(Ha,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Pa('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await q.kv.set(Ha,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Pa('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));V.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=Za(e,a);return za(s)===za(e)?e:s})})),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ce({mode:(0,K.isOnline)()?Ae.getState().mode:'offline'})}finally{a=!1}}};Pe.push(V.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Ma=setInterval(()=>{n()},15e3),Xa=()=>{n()},n()}const za=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function Za(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const Ya=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let Xa=null;const es={bridges:()=>Ke,restart:qa};function ts(){const e=Ae.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!De('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function as(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(!e||ts())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(F.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function ss(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}as();try{await F.mutationQueue.retryNow()}catch{}}Ae.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{ss()},3e3)});const ns=['bookings','walk_ins'];function is(){const e=Ae.getState();return Ue()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const rs=()=>Ke.filter(e=>ns.includes(e.spec.table)),os=e=>F.mutationQueue.failed.some(t=>ns.includes(t.table)&&t.rowKey===e);function ds(e=!1){return is()?0:rs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&os(t)&&!!$.useBookingSaves.getState().notSaved[t]),0)}async function us(e=!1){const t=is();if(t)return t;for(const e of rs())try{await e.read()}catch{}ds(e);try{await F.mutationQueue.retryNow()}catch{}return e&&cs(),null}function cs(){const e=rs()[0]?.venueId??'',t=$.useBookingSaves.getState(),a=new Set(rs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||os(s)||ns.some(t=>F.mutationQueue.hasPending(t,e,s))||t.clear(s)}F.mutationQueue.onFailed(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().clear(e.rowKey)});let ls=null;const fs=(e=2500)=>{ls&&clearTimeout(ls),ls=setTimeout(()=>{ls=null,us(!1)},e)};(0,K.onConnectivity)(e=>{e&&fs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&fs(3e3)});const ps=['temp_readings','temp_units'];function gs(e="temp_readings"){const t=Ae.getState();return Ue()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ye()?'device'!==t.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ms=()=>Ke.filter(e=>ps.includes(e.spec.table));async function _s(e=!1){const t=gs();if(t)return t;for(const e of ms())try{await e.read()}catch{}const a=ms()[0]?.venueId??'';for(const t of ms())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,F.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await F.mutationQueue.retryNow()}catch{}if(e){const e=W.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ms().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||F.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,W.tempKey)(t.table,t.id))}}return null}F.mutationQueue.onFailed(e=>{ps.includes(e.table)&&W.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ps.includes(e.table)&&W.useTempSaves.getState().clear((0,W.tempKey)(e.table,e.rowKey))});let Ss=null;const hs=(e=3e3)=>{Ss&&clearTimeout(Ss),Ss=setTimeout(()=>{Ss=null,_s(!1)},e)};(0,K.onConnectivity)(e=>{e&&hs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3500)});const ys='golive:v1:';async function ws(e){'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)?await Os(e):(await q.kv.get(ys+e,!1)||await Os(e),await q.kv.get(ks+e,!1)||(Is(e),await q.kv.set(ks+e,!0)),await q.kv.get(vs+e,!1)||(bs(),await q.kv.set(vs+e,!0)))}const vs='golive:v3:';function bs(){const e=e=>JSON.stringify(e).includes('(example)');try{se.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ks='golive:v2:';function Is(e){const t=e=>JSON.stringify(e).includes('(example)');V.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)))})),ie.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 Os(e){if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)){const t=(0,g.stripCoreLiveSamples)(V.useStore.getState()),a=(0,se.stripKitchenExamples)(se.useKitchen.getState()),s=ie.useOwner.getState(),n=(0,g.stripOwnerLiveSamples)(s),i={accidents:ne.useSafety.getState().accidents.filter(e=>!(0,ne.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(V.useStore.getState(),t)&&(await(0,m.archiveChefCache)('core',V.useStore.getState()),V.useStore.setState(t)),r(se.useKitchen.getState(),a)&&(await(0,m.archiveChefCache)('kitchen',se.useKitchen.getState()),se.useKitchen.setState(a)),r(s,n)&&(await(0,m.archiveChefCache)('owner',s),ie.useOwner.setState(n)),r(ne.useSafety.getState(),i)&&(await(0,m.archiveChefCache)('safety',ne.useSafety.getState()),ne.useSafety.setState(i));const o=(0,C.stripHrSamples)(C.useHr.getState());r(C.useHr.getState(),o)&&(await(0,m.archiveChefCache)('hr',C.useHr.getState()),C.useHr.setState(o));const d=(0,_.stripGpSamples)(_.useGpCalc.getState());r(_.useGpCalc.getState(),d)&&(await(0,m.archiveChefCache)('gp',_.useGpCalc.getState()),_.useGpCalc.setState(d));const u=ee.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,m.archiveChefCache)('order-sheets',u),ee.useOrderSheets.setState(c));const l=X.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,p.isLiveVenue)(e.restaurantId)||!(0,y.isDemoCard)(e)),log:l.log.filter(e=>!(0,y.demoActor)(e.by))};return r(l,f)&&(await(0,m.archiveChefCache)('recipe-cards',l),X.useCardStore.setState(f)),void await q.kv.set(ys+e,!0)}const t=t=>t.restaurantId===e&&!(0,re.isUuid)(t.id);V.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)))})),z.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,re.isUuid)(t.id))})),Z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ie.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,re.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,re.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,re.isUuid)(e.id)),leave:e.leave.filter(e=>(0,re.isUuid)(e.id)),swaps:[]}));try{se.useKitchen.setState(e=>(0,se.stripKitchenExamples)(e))}catch{}ie.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,re.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId))}));try{ne.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await q.kv.set(ys+e,!0)}const Rs=(e,t)=>je({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function As(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(Z.useFloor.getState().live[e]??{}).map(([e,t])=>Rs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ae.getState().kind||De('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:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>Rs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>Z.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=>Z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Cs(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(ae.useSetup.getState().sites[e]?.grades??ae.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:()=>De('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=ae.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));ae.useSetup.getState().patch(e,{grades:i})},subscribe:t=>ae.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ds='staff-avatars',Us=new Map;let Es=!1;const Ts=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ns(){if(!Es){Es=!0;try{for(const[e,t]of Us){const a=te.useAvatars.getState().photos[e];if(!t){a?.path&&te.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ae.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Ds).download(t);if(n||!s)continue;const i=await Ts(s);i.startsWith('data:image/')&&te.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{Es=!1}}}function Ks(e){const t=async()=>{const t=Ae.getState().staffRef,a=t?pt.get(t)??Ae.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ae.getState().kind)return;const s=te.useAvatars.getState().photos[t];try{const n=Us.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Ds).remove([t]).catch(()=>{})};if(!s){const e=!!te.useAvatars.getState().clears?.[t];return e&&n&&(await Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}),Us.set(t,null),i(n)),void(e&&te.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ce({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Ds).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Pa('set_staff_avatar',{p_staff_ref:t,p_path:d}),Us.set(t,d),n!==d&&i(n),te.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ce({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:te.useAvatars.getState().photos},s=te.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),De('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ae.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Us.set(t,null),te.useAvatars.getState().doneClear(t),Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Ds).remove([e])).catch(()=>{})}});return t(),s}const Ps=new Map,Ms=(0,E.create)(()=>({n:0}))},987,[988,5,989,932,6,832,837,833,838,990,994,995,835,997,999,1000,1001,1002,1003,13,1004,1006,1009,1010,846,933,976,1011,1012,1013,1016,977,1017,1015,1020,1014,1021,1022,1023,1024,831,872,1025,1026,1029,983,883,1031,926,927,1033,1034,891,870,1036,1039,1040,1041,1042,2,1043,1044,1045,1046,1047,1048,979,981,884,863,859,1049,1052,1053]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},988,[846]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},990,[837,34,838,5,839,846,849,991,863,870,992,993]); +__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},991,[984]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},992,[991]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},993,[991,992]); +__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},994,[]); +__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},995,[835,837,838,5,839,846,849,996,831,884]); +__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'}}]},996,[]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},997,[6,998]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},999,[846]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},1000,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1001,[846]); +__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1002,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1003,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1004,[839,846,849,5,872,1005,15,1003]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1005,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1006,[838,835,837,5,839,846,849,1007,870]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1008,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1009,[839,846,849,863,1010,870]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1010,[]); +__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)))},1011,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1012,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1013,[34,1014]); +__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1014,[1011,977,1015]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1015,[1011]); +__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.3.12.172'},1016,[]); +__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1017,[1018,1019,933,977,1014]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1019,[977]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1020,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1021,[846,849,839]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1022,[846,849,839]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1023,[1024]); +__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1024,[1018,933,1011,977,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1025,[]); +__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1026,[860,839,870,846,849,858,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1028,[891,1004,1027]); +__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1029,[5,860,839,1030,846,849,859]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1030,[1008]); +__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1031,[837,838,5,839,846,849,1032]); +__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1032,[984]); +__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1033,[837,984,838,835,5,839,846,849]); +__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1034,[837,838,5,839,846,849,1035]); +__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1035,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1036,[839,846,849,863,1037,15,870,1038]); +__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1037,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1038,[]); +__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1039,[34,839,846,849,863,13,870]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1040,[839,846,849,863,1041,870,1038]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1041,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1042,[5,997,839,846,849,998]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1043,[1039]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1044,[839,846,849,863,1045,870]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1045,[]); +__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},1046,[846]); +__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(':')}`},1047,[839,846,849]); +__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{}}},1048,[236,872]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1049,[995,1050,1051,976,933]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1051,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1052,[933,987,999]); +__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1053,[1054]); +__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1054,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1055,[34]); +__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1056,[34,236,402,102,846,821,794,1055,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1057,[34,102,794,1058,821,1059,25]); +__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1058,[827,34,379,236,402,102,821,987,1059,2,872,1016,5,796,797,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1059,[1060,933,987,872,236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1060,[]); +__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1061,[827,796,34,402,102,794,821,1044,1045,1010,1001,870,891,25]); +__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1062,[828,1063,796,827,34,281,283,364,336,402,102,426,794,821,1039,831,13,1064,1065,1001,1075,1080,1081,1084,1085,1086,1093,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1063,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1064,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1065,[34,876,1066,1067,1064]); +__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1066,[839,846,849]); +__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1067,[6,1068,1069,1070,1071,1072,1073,1074,3]); +__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1068,[]); +__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1069,[]); +__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1070,[]); +__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1071,[]); +__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1072,[]); +__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1073,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1074,[1064]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1075,[236,933,987,1076]); +__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})},1076,[499,1077,1079,1078]); +__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1077,[499,1078,1079]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1078,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1079,[1078]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1080,[933,987]); +__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1081,[34,281,236,102,794,1039,13,1082,821,1083,25]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1082,[13]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1083,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1084,[827,2,34,102,794,821,1039,891,13,987,1001,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1085,[13]); +__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1086,[34,1063,281,402,102,794,1087,1088,1092,1093,821,25]); +__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1087,[34,402,102,794,821,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1088,[837,34,874,891,858,872,1025,987,1089,1004,15,1091]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1089,[1090]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1090,[1091]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1091,[858]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1092,[34,872,1093,858,987,933]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1093,[]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1094,[34,1095,891,1009,1010,1001,1047,831,1098]); +__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1095,[997,1042,891,998,1096,1097]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1096,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1097,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1098,[]); +__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1099,[34,986,402,102,1100,794,874,1101,858,1102,821,25]); +__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)'}})]})}},1100,[34,281,283,364,102,1048,821,25]); +__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1101,[861,859]); +__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1102,[34,402,102,794,1101,858,821,25]); +__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1103,[34,102,794,874,877,821,25]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1104,[860,34,102,794,874,1026,1029,1105,1106,877,821,25]); +__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1105,[1029,859,1101]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1106,[860,877]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1107,[860,34,102,794,874,983,891,1101,858,821,25]); +__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1108,[828,827,1056,34,336,379,236,402,102,794,821,1040,1041,1001,1109,1110,987,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1109,[1076,236]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1110,[839,846,849]); +__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1111,[827,997,34,379,402,102,794,821,1036,1037,891,1040,1041,1042,998,1096,987,1059,1001,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1112,[34,1036,891,1040,1113,1009,831,1037,1001,1094]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1113,[846]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1114,[997,34,1042,891,831,998,1010,1096,1001,1095]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1115,[860,34,1001,874,1101,1048]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1116,[860,1117,34,102,794,874,1101,821,1118,1107,1119,1140,1143,1099,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1117,[34,102,14,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1118,[821]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1119,[34,102,1120,821,1121,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1120,[860,1105]); +__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1121,[1122,860,34,1123,987,1125,402,102,874,1029,1120,1124,821,858,794,1126,1026,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1122,[34,859,821,794,25]); +__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1123,[34,402,102,874,1124,1125,987,1021,821,1121,794,25]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1124,[860,1105]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1125,[281,236]); +__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1126,[827,1127,1128,860,867,14,1129,1130,34,859,402,102,872,1088,874,1131,1105,858,821,864,794,1029,1026,1132,1133,1138,1107,1101,1139,1124,1123,25]); +__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1127,[34,402,412,102,1128,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1128,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1129,[34,102,794,25]); +__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1130,[34,236,402,295,102,426,821,794,1001,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1131,[878,858,877]); +__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1132,[34,402,102,878,858,821,794,25]); +__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1133,[860,877,34,102,879,1134,1135,1137,794,874,1029,983,861,867,872,1101,821,25]); +__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1134,[34,402,821,794,25]); +__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1135,[828,860,1136,34,281,236,102,1029,1105,821,794,1107,859,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1137,[34,402,102,874,861,863,821,794,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1138,[1128,1120,1124]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1139,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1140,[1141,34,102,874,1029,1124,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1141,[34,102,874,1029,1120,1142,1124,821,1004,891,872,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1142,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1143,[34,1063,1127,102,874,1029,1026,876,872,1138,861,1004,891,1027,1120,821,858,1132,1117,1129,1144,14,1141,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1144,[34,102,874,872,1138,14,1125,821,794,25]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1145,[34,102,794,1063,1093,1146,1092,1086,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1146,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1147,[34,102,794,827,1034,891,835,1148,821,1149,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1148,[1035]); +__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1149,[34,402,102,1125,987,1150,1022,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1150,[933,976,1011,1019,1014,1017,1151,1152,1153,1154,1155,1156,977]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1151,[1019,933,1017]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1152,[1019,933,976,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1153,[1011,976,1152,1014,1017,1151]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1154,[933,977]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1155,[34,1014]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1156,[933]); +__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1157,[30,34,426,102,846,872,1088,1158,25]); +__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1158,[839,846,849]); +__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()},1159,[1160]); +__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1160,[1161,858,884]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1161,[1162,877,1163,878,858,884,1164]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1162,[858]); +__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'},1163,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1164,[858]); +__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1165,[978,34,835,402,102,874,891,1166,1161,794,821,1088,1159,1033,15,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1166,[34,102,794,874,1039,884,1167,831,13,1164,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1167,[34,884]); +__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1168,[34,402,102,794,867,821,1160,1159,1165,1033,25]); +__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1169,[34,402,102,794,874,1161,858,821,1170,1166,1165,25]); +__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1170,[828,34,283,364,236,102,426,797,794,827,821,1171,25]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1171,[]); +__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1172,[827,984,1173,835,860,1174,1175,34,402,295,102,794,874,882,1176,891,994,861,867,1179,858,821,1180,1113,1088,1160,1159,1181,869,1165,1033,925,1182,1004,987,1185,989,1098,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1173,[1159,984]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1174,[827,34,102,794,874,979,891,980,981,982,831,821,25]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1175,[]); +__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1176,[827,796,34,336,402,102,821,794,874,1177,1056,882,861,863,885,1109,1178,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1177,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1178,[827,796,34,336,236,402,102,794,831,990,861,991,994,891,1004,882,821,930,992,25]); +__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])},1179,[858]); +__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1180,[928,828,827,837,5,34,1056,336,402,102,794,891,858,821,1088,1025,925,1047,1046,987,1113,1098,25]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1181,[828,34,102,794,876,831,869,821,925,25]); +__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1182,[928,828,34,395,236,402,102,925,794,926,891,1183,927,831,5,1184,987,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1183,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1184,[933,976,987,977]); +__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1185,[34,402,102,794,891,989,1098,994,987,1091,858,1125,821,25]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1186,[1173,984,34,379,102,794,891,994,867,821,1088,1165,1033,1187,25]); +__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1187,[827,835,984,34,379,236,402,102,794,1031,983,985,867,1032,821,1165,25]); +__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1188,[984,872,34,986,1189,336,402,102,1190,794,985,983,1031,821,874,1101,858,1125,987,25]); +__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1189,[5,822,823,828,236,826]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1190,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1191,[827,1031,1173,984,34,402,102,794,891,867,821,1165,1033,25]); +__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1192,[827,34,402,102,794,796,990,874,863,991,992,821,930,1193,1197,1178,25]); +__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1194,[1195,933,987,872,2,1196,1075]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1195,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1196,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1197,[34,102,797,794,990,874,993,821,930,1178,1198,25]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1198,[]); +__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1199,[827,1200,34,402,102,426,794,891,867,858,821,1201,1088,1065,25]); +__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1201,[34,402,102,794,821,5,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1202,[860,1102,1099,1117,34,102,846,794,874,1101,878,877,858,821,1107,1203,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1203,[34,794,874,1204,25]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1204,[379]); +__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1205,[827,1063,1200,34,1206,236,402,426,102,1208,1209,1210,794,831,891,867,1064,821,930,1218,1201,1088,1065,1211,872,1212,1216,25]); +__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1206,[34,402,102,1207,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1207,[34,797,25]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1208,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1209,[34,102,794,827,891,867,1208,821,25]); +__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1210,[827,1208,34,402,102,794,925,891,1098,858,821,1201,1088,1211,872,1212,1213,1215,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1211,[1063,1085,1093]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1212,[34,102,794,891,1039,1063,1093,1087,1211,821,872,1210,1086,1088,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1213,[1064,1214]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1214,[1064,1208]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1215,[34,102,794,827,1063,1064,1213,1125,821,1216,25]); +__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1216,[1063,34,402,102,794,827,891,1214,1064,1217,1125,821,1205,1088,1208,1213,1065,25]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1217,[]); +__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1218,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1180,1201,1088,1065,1160,987,1039,1062,13,1085,1064,2,25]); +__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1219,[828,891,1220,1200,1006,1007,34,1013,1014,236,402,295,102,794,874,1098,1210,1182,1221,1090,5,1222,1161,867,858,821,1201,1180,1088,925,1042,997,998,1095,1001,1097,1166,1164,1213,1215,1091,25]); +__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1220,[827,34,402,102,794,821,891,831,876,1006,1007,25]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1221,[34,102,794,891,1090,821,1098,25]); +__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1222,[34,402,102,794,891,858,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1223,[34,102,794,891,821,1088,1091,1221,1098,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1224,[34,102,1088,821,794,25]); +__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1225,[827,1063,34,402,102,794,1034,821,930,25]); +__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1226,[827,796,1227,1149,835,891,34,336,402,102,794,1034,1035,821,925,930,1228,1231,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1227,[34,1034,891,835]); +__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1228,[828,1063,796,827,1227,835,891,34,336,402,102,797,794,925,1034,1035,1229,821,930,1230,25]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1229,[]); +__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1230,[831,891,5]); +__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1231,[34,1063,379,236,102,794,891,1034,1230,1035,1232,821,930,1227,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1232,[1035]); +__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1233,[34,402,102,794,995,861,996,821,930,1234,25]); +__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1234,[828,34,336,395,402,295,102,1235,794,995,861,996,858,821,1049,25,1237]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1235,[34,1236,102,861,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1236,[2,987]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1237,[]); +__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1238,[860,1058,34,236,402,102,797,874,821,794,1239,1130,1240,25]); +__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1239,[860,34,380,236,402,102,36,821,794,796,1130,874,25,277]); +__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1240,[1241,1242,1244,1243,1245,1048,1246]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1241,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1242,[839,5,846,849,872,1048,1243]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1243,[860,236,872,1241]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1244,[34,874,861,869,867,1242,1241]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1245,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1246,[34,1242,987,933]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1247,[34,402,102,426,874,861,821,794,1238,1130,1248,25]); +__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1248,[34,102,426,874,861,1240,1048,821,794,1130,25]); +__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1249,[34,236,402,102,879,794,821,1001,1250,1251,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1250,[872,6,933,976,1001,1240,1251]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1251,[839,1252,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1252,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1253,[34,872,1250]); +__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1254,[827,796,1227,835,984,34,931,1206,395,236,402,295,102,846,794,861,1035,867,882,1034,821,1165,1159,1186,932,25]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1255,[34,402,346,102,426,821,1207,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1256,[30,34,792,872,25]); +__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1257,[860,1127,877,30,34,1258,1002,102,14,1129,1138,794,861,867,1131,858,874,987,821,1204,864,1026,1029,1105,1133,1101,1259,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1258,[827,34,236,102,25]); +__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1259,[34,402,102,878,858,1063,1260,821,794,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1260,[1063]); +__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 b}});var n=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),a=e(_r(_d[3])),l=e(_r(_d[4])),r=_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]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,t.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),x=(0,h.useMenu)(e).find(e=>e.id===b),y=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===x?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,n.useTakeawayMenu)(n=>n.byVenue[e]),S=(0,h.useStore)(n=>n.basket.restaurantId===e&&'table'===n.basket.mode),[C,B]=(0,s.useState)(()=>(x?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,s.useState)(1),[P,T]=(0,s.useState)(''),[L,O]=(0,s.useState)(!1),[D,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[q,_]=(0,s.useState)(!1),N=(0,s.useMemo)(()=>x?(0,c.effectiveAllergens)(x,C):{},[x,C]);if(!j||!x)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(N,y.allergies),Y=(x.price??0)+(x.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,n)=>e+n.priceDelta,0),z=S||j.fictional?'on':(0,n.takeawayAvail)(x,w),F=x.soldOut||!x.signOff||null===x.price||'on'!==z,Q=(e,n)=>{const t=x.optionGroups.find(n=>n.id===e);B(e=>{const s=t.choices.map(e=>e.id);return t.multi?e.includes(n)?e.filter(e=>e!==n):[...e,n]:e.includes(n)&&!t.required?e.filter(e=>e!==n):[...e.filter(e=>!s.includes(e)),n]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:x.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),_(!0)};return(0,f.jsxs)(d.Screen,{title:x.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(a.default,{testID:"dish-photo",source:k,accessibilityLabel:`${x.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===x.price?x.priceNote:(0,u.gbp)(Y)}),x.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:x.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(x.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(n=>(0,f.jsx)(d.Chip,{label:n.label,sub:n.priceDelta?`+${(0,u.gbp)(n.priceDelta)}`:void 0,selected:C.includes(n.id),onPress:()=>Q(e.id,n.id)},n.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:x,map:N,declared:y.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:x.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&x.signOff&&null!==x.price?'This dish isn\u2019t on the takeaway menu. You can have it when you eat in.':x.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(l.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${x.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1261,[988,30,34,336,102,1235,1262,794,861,867,874,882,821,25]); +__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])},1262,[30,34,402,874,821,794,25]); +__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1263,[30,34,794,1264,874,1249,25]); +__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])},1264,[34,402,821,794,25]); +__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1265,[837,30,34,1266,794,867,874,821,1267,1271,25]); +__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:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1266,[34,385,102,874,867,821,794,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1267,[34,102,794,867,1268,1269,1270,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1268,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1269,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1270,[933,987,1269]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1271,[846,933,976,987,2,1268]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),I=_r(_d[23]),O=_r(_d[24]),R=_r(_d[25]),A=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),C=_r(_d[29]),_=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const M=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let $=!1,E=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,k.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,k.useRestaurant)(e),l=(0,k.useMenu)(e),a=(0,k.useCustomer)(),s=(0,k.useBasket)(),n=(0,k.useStore)(e=>e.startBasket),o=(0,k.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[U,V]=(0,u.useState)(!1),[Q,Y]=(0,u.useState)('takeaway'===M?'takeaway':'main');c.default.useEffect(()=>{M&&!$&&($=!0,'book'===M?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,k.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>d.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{C.START_LOYALTY_CODE&&!E&&(E=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,k.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||k.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=l.filter(e=>!('All'!==r&&e.section!==r||'takeaway'===Q&&'off'===ne(e))),re=(0,j.hoursFor)(t,o),ie=e=>()=>d.router.push(`/customer/${t.id}${e}`),de=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>V(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:ie('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:ie('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:ie('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:ie('/refer')},{icon:'gift',label:'Gift cards',on:ie('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:ie('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:ie('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:ie('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:ie('/feedback')},{icon:'hanger',label:'Lost property',on:ie('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:ie('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[re?`Kitchen today ${(0,j.kitchenHoursOn)(t,o)[0]}\u2013${(0,j.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:de.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:de.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=Q===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===Q?(0,v.jsx)(A.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===Q?(0,v.jsx)(m.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==Q?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==Q||oe.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==Q?se.filter(e=>('All'===r||e===r)&&oe.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),oe.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?'Not on the takeaway menu':'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:U,onClose:()=>V(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{V(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1272,[1273,1282,5,1283,1284,1285,1288,860,30,34,236,402,102,1235,1262,794,861,867,878,874,988,821,1289,1249,872,891,1234,995,996,1004,1290,1271,25]); +__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1273,[34,379,794,873,1274,1275,1281,874,5,6,25]); +__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1274,[34,379,102,794,997,998,1096,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1275,[6,34,933,794,1276,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1276,[6,1063,1277,1278,1279,34,102,827,794,821,11,1280,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1278,[4,11]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1279,[11]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1280,[6,933]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1281,[34,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1282,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1283,[34,102,794,1276,25]); +__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1284,[34,379,933,794,873,1274,1276,4,25]); +__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1285,[34,379,794,1274,873,1275,8,1286,25]); +__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1286,[34,102,794,1287,25]); +__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1287,[]); +__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1288,[34,794,873,1274,1275,874,9,25]); +__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1289,[34,402,102,426,794,821,1207,25]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1290,[34,102,1291,794,874,1004,1268,1271,821,25]); +__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1291,[34,102,1292,821,25]); +__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1292,[1293]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1293,[34,797,1294,1323,1324,25]); +__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1294,[1295]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1295,[1296,1297,1320,1322]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1296,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1297,[1298,1299,1300,1301,1302,1303,1304,1305,1306,1309,1313,1310,1314]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1298,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1299,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1300,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1301,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1306,[1307]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1310,[1311,1312]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1311,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1312,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1315,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1316,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1318,[1310,1298]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1319,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1320,[1321]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1322,[1321]); +__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1323,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1324,[34,797,1325,25]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1325,[]); +__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1326,[30,34,794,874,891,25]); +__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1327,[837,30,34,102,1291,794,867,874,821,1290,1271,25]); +__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1328,[837,30,34,102,1266,794,874,891,867,858,821,1267,1271,25]); +__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1329,[837,30,34,794,874,891,858,821,1290,1271,25]); +__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1330,[837,30,34,794,874,891,821,1290,1271,25]); +__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1331,[30,34,794,858,1161,1332,874,821,25]); +__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}},1332,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1333,[30,1101,34,402,102,794,858,874,821,25]); +__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 v}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),o=_r(d[3]),r=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),k=_r(d[15]),p=_r(d[16]),f=_r(d[17]);function v(){const e=(0,b.useBasket)(),v=(0,b.useRestaurant)(e.restaurantId??void 0),w=(0,b.useAllMenu)(e.restaurantId??void 0),C=(0,b.useCustomer)(),S=(0,b.useOrders)(v?.id),T=(0,b.useStore)(e=>e.setLineQty),B=(0,b.useStore)(e=>e.overrideLine),P=(0,b.useStore)(e=>e.startBasket),I=(0,b.useNow)(15e3),[O,$]=(0,a.useState)(null),[N,M]=(0,a.useState)(!1),[F,L]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,r.startForm)()),[A,R]=(0,a.useState)(''),[Y,D]=(0,a.useState)(C.phone??''),[E,_]=(0,a.useState)(C.email??''),[q,H]=(0,a.useState)(C.name&&'Guest'!==C.name?C.name:''),[G,V]=(0,a.useState)(!1),K=(0,b.useOrderAtTable)(e.restaurantId??void 0),Q=(0,p.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{K||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[K,e.mode]);const[U,J]=(0,a.useState)(null),[W,X]=(0,a.useState)(!1),Z=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,w,C.allergies),[e,w,C.allergies]);if(!v||!e.lines.length)return(0,f.jsxs)(i.Screen,{title:"Your basket",children:[(0,f.jsx)(i.Muted,{children:"Your basket is empty."}),(0,f.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ee=K&&'table'===e.mode,le=(0,h.takeawaySlots)(v,S,I),te=Z.reduce((e,l)=>e+l.unitPrice*l.qty,0),ae=Z.some(e=>e.contains.length&&!e.overridden),ne=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ee&&'on'!==(0,p.takeawayAvail)(l,Q)}),oe=!ee&&!O,re=!ee&&v.settings.takeawayPaused,se=(0,x.ukPhone)(Y),ie=q.trim().length>=2&&'guest'!==q.trim().toLowerCase(),de=ee||(0,p.takesCardTakeaway)(v,k.IS_ISOLATED_VENUE),ue=!G&&de&&!ae&&!ne.length&&N&&!oe&&!re&&(ee||ie&&se.ok&&(0,x.emailOk)(E)),ce=async()=>{V(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ee?void 0:O,tip:0,notes:F,phone:ee?void 0:se.pretty,email:ee?void 0:E.trim()||void 0,customerName:ee?void 0:q.trim()});(0,r.rememberGuard)(e.id,(0,r.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{V(!1)}},he=e.lines.find(e=>e.key===U),me=he?Z[e.lines.indexOf(he)]:void 0;return(0,f.jsxs)(i.Screen,{title:"Your basket",subtitle:`${v.name} \xb7 ${ee?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,f.jsx)(i.T,{weight:"bold",size:20,colour:j.colours.gold,children:(0,c.gbp)(te)})]}),de?ae?(0,f.jsx)(i.T,{size:14,colour:j.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):N?oe&&!re?(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Choose a collection time."}):ee||ie?ee||se.ok?null:(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your mobile number."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your name for the order."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Confirm your allergies to continue."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ee?(0,f.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!ue,onPress:()=>ce(),testID:"send-table-order"}):(0,f.jsx)(i.Button,{label:G?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(te)}`,disabled:!ue,onPress:()=>ce(),testID:"checkout"}),ee?null:(0,f.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ee||e.tableNo,null),ee?(0,f.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,v.fictional?null:(0,f.jsx)(i.AllergenNotice,{phone:v.phone}),Z.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,f.jsxs)(i.Card,{highlight:l.contains.length?j.colours.red:l.may.length?j.colours.amber:void 0,children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,f.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,f.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,f.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,f.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,f.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,f.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${C.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,f.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{X(!1),J(a.key)}})]})]}):l.contains.length?(0,f.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,f.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ne.includes(a)?(0,f.jsx)(i.Badge,{kind:"amber",label:!ee&&Q&&w.find(e=>e.id===a.itemId)&&'sold-out'===(0,p.takeawayAvail)(w.find(e=>e.id===a.itemId),Q)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Stepper,{value:a.qty,onChange:e=>T(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${v.id}`)}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(I)]}),re?(0,f.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===le.length?(0,f.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(i.Muted,{children:["15-minute slots, max ",v.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:le.slice(0,16).map(e=>(0,f.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:O===e.time.toISOString(),onPress:()=>$(e.time.toISOString())},e.label))})]})]}),(0,f.jsxs)(i.Card,{highlight:N?void 0:j.colours.amber,children:[(0,f.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:C.allergies.length?C.allergies.map(e=>(0,f.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,f.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,f.jsx)(i.Toggle,{label:C.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:N,onChange:M}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.H2,{children:"Your details"}),(0,f.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:q,onChangeText:H,autoComplete:"name",placeholder:"e.g. Sam Smith"}),q&&!ie?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"Please add your name."}):null,(0,f.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:Y,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!se.ok&&Y?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:se.error}):null,(0,f.jsx)(i.Field,{label:"Email (optional)",value:E,onChangeText:_,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,x.emailOk)(E)?null:(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,f.jsx)(i.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,f.jsx)(i.Field,{label:"Order notes (optional)",value:F,onChangeText:L,placeholder:"e.g. cutlery please"}),ee?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>P(v.id,'takeaway')}):null,(0,f.jsxs)(i.Sheet,{visible:!!he,onClose:()=>J(null),title:"Allergy override",children:[me?(0,f.jsx)(i.Banner,{kind:"danger",title:`${me.name} contains ${me.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,f.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:W,onChange:X}),(0,f.jsx)(i.Button,{kind:"danger",disabled:!W,label:"Confirm override",onPress:()=>{he&&me&&B(he.key,me.contains),J(null)}})]}),(0,f.jsx)(o.Honeypot,{value:A,onChange:R})]})}},1334,[860,30,34,1258,1002,102,794,861,867,1131,858,874,831,821,864,5,988,25]); +__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1335,[30,34,102,1262,794,861,878,874,821,1289,5,25]); +__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 f}});var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1336,[860,30,34,102,1264,794,861,867,858,874,821,1337,25]); +__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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1337,[34,371,379,236,30,794,867,821,988,1338,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1338,[933,987]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1339,[860,1271,30,34,102,794,861,867,858,874,879,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1340,[30,34,872,25]); +__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1341,[837,30,34,794,874,5,1271,25]); +__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1342,[30,34,794,1343,1175,1271,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1343,[827,860,34,102,794,861,867,1175,1344,874,821,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1344,[933,987,1175]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1345,[30,34,872,1346,1410,25]); +__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1346,[1162,796,5,6,1347,828,853,1122,860,1161,1348,1349,1350,1119,1143,1351,1352,1357,1358,1359,872,1360,1174,979,1130,1361,34,1099,1202,1048,1115,1157,1362,395,380,402,295,102,426,36,794,1249,1253,873,861,858,874,821,1118,891,1126,1088,1029,1105,1135,1363,1134,1364,1371,1373,1376,1379,1375,1380,1382,1383,1140,1123,1124,878,1387,1238,1388,1248,1240,1026,1393,1401,1402,1102,1142,1404,1405,1406,1098,1189,1407,1188,1181,869,1408,1409,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1348,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1349,[1027,1088]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1350,[34,102,1105,794,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1351,[860,34,102,794,874,1175,821,25]); +__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1352,[34,395,402,426,102,1291,794,1189,796,1029,1353,1354,1356,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1353,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1354,[34,395,402,295,412,102,426,796,794,821,1355,1356,25]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1355,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1356,[1025,872,1355,933,987]); +__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1357,[846]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1358,[828,34,379,395,402,102,794,1189,821,25]); +__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1359,[34,236,402,102,794,821,891,1004,858,1098,25]); +__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1360,[828,827,34,236,402,295,102,794,1174,874,979,831,981,982,872,980,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1361,[828,34,102,821,794,25]); +__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1362,[34,102,797,821,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1363,[]); +__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1364,[828,796,827,1122,860,1130,34,236,402,295,426,102,859,821,794,1365,1366,1029,891,1134,1368,987,872,25]); +__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1365,[828,860,34,1366,102,859,821,794,1135,1367,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1366,[859]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1367,[1366,859]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1368,[34,385,295,102,859,1369,1370,821,796,827,794,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1369,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[1369,1025,872,933,987]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[34,236,402,102,821,794,1189,1372,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[828,860,1123,34,281,236,295,102,1136,874,1029,1105,14,858,1124,1374,821,794,1375,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1376,[5,828,34,283,336,236,402,102,426,821,873,794,1030,1001,1357,1377,2,1378,1379,874,858,25]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1377,[236]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1379,[34,846,933,987,1378]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1380,[860,14,1029,1381]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1381,[861]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1382,[34,102,797,821,25]); +__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1383,[1384,860,1123,1029,34,102,794,1126,874,1386,1380,1124,858,1121,1140,1141,1142,821,1349,25]); +__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1384,[34,379,402,102,874,1004,891,1027,1385,872,821,794,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1385,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1386,[1029,1105]); +__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1387,[1384,828,1123,827,860,1161,1119,1140,858,34,1107,236,402,295,102,794,1126,1375,874,1029,861,1117,1105,1332,821,1349,25]); +__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1388,[827,34,236,402,102,794,874,1029,1389,821,1390,1392,25]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1389,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1390,[846,874,1029,1389,1391,1392]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1391,[860]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1392,[236,1391]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1393,[860,34,1206,1189,402,102,1026,1029,878,858,821,794,1394,1397,25]); +__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1394,[1395,870,860,34,281,395,402,295,102,874,1026,1029,1396,858,821,1056,794,1397,1398,987,1349,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1395,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1396,[878,858,877]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1397,[5,1029,933,987]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1398,[846,933,987,1399,2,1400]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1399,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1400,[15]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1402,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1403,[1105]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1404,[860,1381]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1405,[34,402,102,794,1404,821,1362,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1406,[34,102,925,794,1189,858,821,25]); +__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1407,[34,1189,402,102,426,794,25]); +__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1408,[828,1063,827,2,1189,34,402,102,426,794,821,891,998,858,1001,1398,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[34,1036,891,1009,831,1037,1001,1398,1094]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[5,828,873,34,236,402,102,426,987,821,794,1357,1411,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1412,[30,34,872,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1413,[30,34,872,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1414,[30,34,1415,872,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1415,[34,872,1416,1550,25]); +__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,"canSignOffHours",{enumerable:!0,get:function(){return he}}),_e.barTabsFor=me,_e.signOffSpeech=be,_e.OwnerApp=function(){return H.IS_OWNER_DESKTOP?(0,ue.jsx)(de.DesktopGate,{phone:(0,ue.jsx)(xe,{})}):(0,le.isDesktop)()?(0,ue.jsx)(ce.DesktopShell,{}):(0,ue.jsx)(xe,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),j=_r(d[14]),w=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=e(_r(d[20])),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),I=_r(d[24]),L=_r(d[25]),O=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]),$=_r(d[32]);_r(d[33]);var D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),z=_r(d[39]),F=_r(d[40]),U=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]),Y=_r(d[45]);_r(d[46]);var J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]),de=_r(d[60]),ce=_r(d[61]),ue=_r(d[62]);const fe=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ge=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],he=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function me(e,t){return ge.filter(t=>!t.can||t.can(e)).map(e=>'orders'===e.id&&t?{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'}:'forecast'===e.id?{id:'rota',label:'Rota',icon:'rota'}:e)}function be(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const pe={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function xe(){const{rid:e,r:le,role:de,today:ce,now:xe,meId:je,me:we}=(0,_.useCtx)(3e4);(0,b.useTipsPosted)(e,ce,'staff'!==de);const Se=(0,_.useSignedIn)();(0,c.useSoldOutLink)(!0,(Se?.name??we).replace(' (example)',''));const ye=(0,I.useOrders)(e),[Ae,ke]=(0,j.useState)('home'),[Re,Ce]=(0,j.useState)(null),[ve,Te]=(0,j.useState)(!1),Ie=(0,n.useLiveVenue)(),[Le,Oe]=(0,j.useState)(!1),Ee=(0,j.useRef)(null);(0,j.useEffect)(()=>{(0,_.ensureAttendance)(ce,xe),(0,Q.ensureChat)(xe)},[ce]),globalThis.__ccNow=xe.getTime();const Be=(0,Q.useChatUnread)().total,Pe=(0,j.useRef)({t:'home',s:null});Pe.current={t:Ae,s:Re};const Ne=(0,j.useRef)([]),$e=(0,l.useScrollMemory)(Ee),De=(0,j.useCallback)((e,t=null)=>{const s=Pe.current;s.t===e&&s.s===t||(Ne.current=[...Ne.current,{...s,y:$e.leave()}].slice(-30),$e.restore(0)),ke(e),Ce(t)},[]),Me=(0,j.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Pe.current;let t=Ne.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Ne.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return $e.leave(),ke(s.t),Ce(s.s),$e.restore(s.y??0),!0},[]);(0,u.useWebBack)(Me);const He=(0,u.useInnerBackShown)();(0,j.useEffect)(()=>(re.useVoiceNav.setState({go:De}),()=>re.useVoiceNav.setState({go:null})),[De]),(0,j.useEffect)(()=>{f.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchOwner=L.useOwner)},[De]),(0,j.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Me);return()=>e.remove()},[Me]),(0,j.useEffect)(()=>{const e=ge.find(e=>e.id===Ae);e?.can&&!e.can(de)&&De('home');const t=(0,K.pageFor)(Re);t?.can&&!t.can(de)&&Ce(null)},[de]);const We='more'===Ae?(0,K.pageFor)(Re):void 0,Ve=ye.filter(e=>(0,B.LIVE)(e)&&'new'===e.status).length,{unread:ze,list:Fe,read:Ue}=(0,J.useNotifications)();(0,se.useAlertWatcher)(e,{nag:'staff'!==de}),(0,oe.useReviewAlerts)(e),(0,ne.useScheduledNotices)({rid:e,staffId:Se?.id??'',name:we,onOpen:e=>'bookings'===e?De('bookings'):'chat'===e?De('chat'):De('more',e)}),(0,ae.useOffRotaAlerts)({enabled:'staff'!==de&&!!Se});const qe=Se?.role??de,Ge='owner'===qe?'OWNER':'manager'===qe?'MANAGER':'STAFF',Ke=(0,se.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,se.isUnread)(t,s)&&!(0,se.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),Ye=(0,se.useAlerts)(t=>t.todoSeen[e]),Je=Math.max(0,ze-Fe.filter(e=>!Ue[e.id]&&(Ye??[]).includes(e.id)).length)+Ke;(0,se.useAlertSeenSync)(e),(0,j.useEffect)(()=>{G.useShellBadges.setState({notifCount:Je})},[Je]);const Qe=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Xe=he(de),Ze=(0,r.useOutstanding)(),et=Ze.days.length+Ze.requests,tt=me(de,Xe),st='more'===Ae&&'signoff'===Re?'signoff':'more'===Ae&&'rota'===Re?'rota':'forecast'===Ae||'orders'===Ae&&Xe?'more':Ae,ot=t.IS_ISOLATED_VENUE?[{id:e,name:le.name,place:le.location||le.address||''}]:fe,rt=ot.find(t=>t.id===e)??ot[0],nt=Se?.ownerAccess&&'owner'!==Se.role?'owner privileges':Se?.managerAccess&&'staff'===Se.role?'manager privileges':'',at=(0,M.ownerHomeLayout)(de,Se);(0,k.default)().width;return(0,ue.jsxs)(C.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,ue.jsxs)(R.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,ue.jsxs)(R.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>De('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,ue.jsx)(y.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:Je?`Notifications, ${Je} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>De('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),Je?(0,ue.jsx)(R.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(v.T,{size:10,weight:"bold",children:Je})}):null]})}),(0,ue.jsx)(Z.VoiceSlot,{size:44})]}),(0,ue.jsx)(R.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ue.jsx)(R.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,ue.jsx)(y.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${we}. Account and role${nt?`, ${nt}`:''}`,disabled:'owner'!==H.APP_VARIANT,onPress:()=>Oe(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ue.jsxs)(v.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ue.jsx)(P.StaffAvatar,{id:je,size:24,ring:!1}),(0,ue.jsxs)(R.default,{style:{flexShrink:1},children:[(0,ue.jsxs)(v.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[Se?`${we} \xb7 ${Se.level??L.ROLE_LABEL[Se.role]}`:`${we} \xb7 ${L.ROLE_LABEL[de]}`,'owner'===H.APP_VARIANT?' \u25be':'']}),nt?(0,ue.jsx)(v.Muted,{center:!1,size:10,numberOfLines:1,children:nt}):null]})]})})})}),(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>Te(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,ue.jsx)(T.VenueHeaderBlock,{rid:e,name:le.name,badge:Ge,place:`${'staff'===de?'Staff preview \xb7 ':'Managers \xb7 '}${rt.place}`})}),de!==(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner')&&'owner'===H.APP_VARIANT?(0,ue.jsx)(y.default,{onPress:()=>L.useOwner.getState().setPreviewRole(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,ue.jsx)(v.T,{size:12,colour:O.colours.gold,children:'staff'===de?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[de].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`})}):null]}),(0,ue.jsxs)(A.default,{ref:Ee,...$e.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ue.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Re||He),onBack:Me,title:We?We.title:'bookings'===Ae&&'waitlist'===Re?'Waitlist':'staff'===de&&'home'===Ae?'Staff app preview':pe[Ae]}),'home'===Ae&&Se&&'staff'===Se.role&&'owner'===H.APP_VARIANT?(0,ue.jsxs)(R.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,ue.jsx)(v.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,ue.jsx)(v.Button,{label:"Clock in and my shifts",onPress:()=>De('more','clock')})]}):null,'home'!==Ae||at?null:(0,ue.jsx)(a.WhoBar,{}),'home'===Ae&&!at&&Se?(0,ue.jsx)(ie.MyShiftCard,{go:De}):null,'home'===Ae&&!at&&Se?(0,ue.jsx)(h.MyTasksToday,{rid:e,staffId:Se.id,name:Se.name,onShift:(0,p.shiftNow)(Se.id,Date.now()).on}):null,'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TodaysTipsCard,{rid:e,today:ce}),'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TipsPotCard,{rid:e,today:ce}),'home'===Ae?'staff'===de?(0,ue.jsx)(z.StaffHome,{go:De}):(0,ue.jsx)(D.Dashboard,{go:De,ownerHome:at}):null,'orders'===Ae?(0,ue.jsx)(Y.Orders,{}):null,'bookings'===Ae?(0,ue.jsx)(E.Bookings,{go:De,only:'waitlist'===Re?'waitlist':void 0}):null,'forecast'===Ae?(0,ue.jsx)(F.Forecasts,{go:De}):null,'chat'===Ae?(0,ue.jsx)(Q.Chat,{go:De}):null,'more'===Ae?We?(0,ue.jsx)(We.C,{go:De}):(0,ue.jsx)(K.MoreMenu,{go:De}):null]}),(0,ue.jsx)(x.SeatAllergenReminder,{rid:e}),'staff'!==de?(0,ue.jsx)(te.PrintHost,{rid:e}):null,'staff'!==de?(0,ue.jsx)(ee.AlertHost,{variant:"managers",rid:e,me:we,onOpen:e=>De('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,ue.jsx)(X.AssistantSheet,{}),(0,ue.jsx)(q.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:st,onPress:e=>'signoff'===e?De('more','signoff'):'rota'===e?De('more','rota'):De(e),tabs:tt.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?be(Ze.days.length,Ze.requests):'more'===e.id&&Xe&&Ve?`More, ${Ve} new order${Ve>1?'s':''} in Orders`:void 0,badge:'chat'===e.id&&Be?{text:String(Be),bg:O.colours.red}:'bookings'===e.id&&Qe?{text:String(Qe),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&Ve?{text:String(Ve),bg:O.colours.red}:'signoff'===e.id&&et?{text:String(et),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Xe&&Ve?{text:String(Ve),bg:O.colours.red,testID:'more-orders-badge'}:null}))}),(0,ue.jsx)(S.default,{visible:ve,transparent:!0,animationType:"fade",onRequestClose:()=>Te(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Te(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Your venues"}),ot.filter(e=>!Ie||'saltmarsh'!==e.id).map(t=>(0,ue.jsx)(y.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),Te(!1),De('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,ue.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(v.T,{weight:"medium",children:t.name}),(0,ue.jsx)(v.Muted,{children:t.place})]}),t.id===e?(0,ue.jsx)(v.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,ue.jsx)(v.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${le.name}.`:Ie?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,ue.jsx)(S.default,{visible:Le,transparent:!0,animationType:"fade",onRequestClose:()=>Oe(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Oe(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[Se?(0,ue.jsxs)(v.Row,{gap:10,children:[(0,ue.jsx)(P.StaffAvatar,{id:Se.id,size:44}),(0,ue.jsxs)(R.default,{style:{flex:1},children:[(0,ue.jsxs)(v.T,{weight:"semibold",children:["Signed in as ",Se.name]}),(0,ue.jsx)(v.Muted,{children:(0,$.levelJob)(Se.level??L.ROLE_LABEL[Se.role],Se.job)})]})]}):(0,ue.jsxs)(R.default,{style:{gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,ue.jsx)(v.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,ue.jsx)(N.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!Se?null:(0,ue.jsx)(v.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,$.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,ue.jsx)(v.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!Se||(0,_.clampRole)(e,Se.ownerAccess?'owner':Se.managerAccess?'manager':Se.role)===e).map(e=>(0,ue.jsx)(v.Button,{kind:e===de?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),Oe(!1)}},e))]})})}),(0,ue.jsx)(W.OnboardingHost,{go:De}),(0,ue.jsx)(V.CoachHost,{})]})}},1416,[5,828,987,1210,1236,1224,1055,979,1056,2,1061,1062,1094,1115,34,373,395,402,295,426,102,36,794,873,874,891,821,1417,1201,1088,925,1426,1004,236,1435,13,872,1467,1473,1474,1475,1207,1255,1476,1459,1477,1479,1457,1180,1493,1157,1238,1388,1240,1253,1481,1112,1114,1223,1546,1547,1566,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1417,[5,1418,1123,11,1419,827,837,1140,1141,1119,1143,1420,1138,1142,1404,1405,1088,1349,1027,1117,14,1144,1422,1249,1423,1393,1107,1101,1118,34,102,794,1362,874,861,867,858,1332,821,1201,1126,1029,1424,1087,1181,1425,1240,987,1203,1401,878,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1418,[34,794,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1419,[6,34,102,794,987,1280,25]); +__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[34,402,102,1421,987,933,821,794,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[827,5,34,379,236,102,794,876,14,867,1032,933,821,1204,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[34,402,1189,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1424,[34,102,874,1029,794,821,25]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1425,[34,102,879,874,864,821,794,25]); +__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1426,[5,1427,1428,1429,1430,1431,34,236,41,102,872,1432,1004,821,1434,794,987,2,1097,1003,891,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1427,[34,102,873,794,5,6,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1428,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1429,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1430,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1431,[34,102,873,794,25]); +__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1432,[34,295,102,794,873,821,1433,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1433,[]); +__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1434,[929,828,34,1097,336,236,402,295,41,102,872,926,891,831,987,1004,15,793,821,925,794,25]); +__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.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:b,now:F,role:oe,me:ae,today:ne}=(0,A.useCtx)(5e3),ie=(0,p.useOrders)(n),re=(0,p.useBookings)(n),de=(0,p.useWaitlist)(n),ue=(0,p.useEvents)(n),ge=(0,p.useRatings)(n),xe=(0,k.useOwner)(e=>e.staff),ye=(0,k.useOwner)(e=>(0,k.liveAttendance)(e.attendance)),be=(0,k.useOwner)(e=>e.shifts),fe=(0,L.useRealHistory)(n,F),me=(0,o.useMemo)(()=>(0,t.forecastToday)(b,re,ie,ue,F,fe??void 0),[b,re,ie,ue,fe,F.getTime()/6e4|0]),je=(0,N.useExamples)(),pe=(0,P.useCashUp)(e=>e.cashUps),ke=re.filter(e=>e.date===ne),we=ie.filter(D.LIVE),$e=de.filter(e=>'waiting'===e.status||'notified'===e.status),ve=ke.filter(e=>['seated','finished'].includes((0,I.shownStatus)(e))).reduce((e,s)=>e+s.partySize,0),Ce=(0,te.coversSplit)(ke,ne),Ie=Ce.walkIns,Te=Ce.bookings,Be=we.filter(e=>(0,q.chainNeedsAction)(e,re)),De=ke.filter(e=>['confirmed','seated'].includes(e.status)&&(0,q.bookingNeedsAction)(e,we)),Ae=we.flatMap(e=>(0,v.readinessFor)(e,b,F).map(s=>({...s,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Se=me.nextHour,Le=(0,D.busyLevel)(Se?.coversHigh??0,me.busy.busy),Ne=(0,D.restOfDayLevel)(me,b),Pe=ie.filter(e=>e.paid>0&&!!e.createdAt&&(0,C.ymd)(new Date(e.createdAt))===ne).reduce((e,s)=>e+s.paid,0),Me=(0,H.tradingDay)(F),Fe=je?(0,S.revenueHistory)(b,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Oe=je?{today:186e3+Pe,last:Fe?{date:(0,C.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,W.takingsToday)(pe,n,Me,Pe),Re=k.CAN.takings(oe)&&(!(0,R.isLive)()||(0,R.can)('takings.view')),He=(0,o.useMemo)(()=>(0,S.insights)(b,re,ie,ue,ge,F,ve),[b.id,re.length,ge.length,ve]),We=((0,A.weekday)(F),ye.filter(e=>e.date===ne&&e.in&&!e.out)),Ee=(0,J.useFrontDoor)(ne),ze=(0,h.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,r.useTravelDay)('owner',ne),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,M.canSeeMonthTakings)(oe,qe,{inStaffApp:Ye,live:(0,R.isLive)()}),Qe=(0,O.homeSetupNagsHidden)(n),Ve=(0,k.useOwner)(e=>e.socialPosts.reduce((e,s)=>e+('awaiting approval'===s.status?1:0),0)),[Xe,Ze]=(0,o.useState)(!1),Je=ae.replace(' (example)',''),es=k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(r.DayView,{rid:n,day:Ue,today:ne,app:"owner"})]}):a?(0,le.jsxs)(m.default,{style:{gap:12},testID:"owner-home",children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Re&&Oe.show?(0,le.jsx)(j.Row,{wrap:!0,gap:10,children:(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})})}):null,(0,le.jsx)(X.TodaysTipsCard,{rid:n,today:ne}),(0,le.jsx)(X.TipsPotCard,{rid:n,today:ne}),k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),qe&&'owner'!==qe.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,le.jsx)(V.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,Z.shiftNow)(qe.id,Date.now()).on}):null,k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]}):(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,Re&&Oe.show?(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=de,_e.MonthTakingsCard=ce,_e.WalkInSplitCard=he;var s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),o=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),y=_r(_d[12]),b=e(_r(_d[13])),f=e(_r(_d[14])),m=e(_r(_d[15])),j=_r(_d[16]),p=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),I=_r(_d[23]),T=_r(_d[24]),B=_r(_d[25]),D=_r(_d[26]),A=_r(_d[27]),S=_r(_d[28]),L=_r(_d[29]),N=_r(_d[30]),P=_r(_d[31]),M=_r(_d[32]),F=_r(_d[33]),O=_r(_d[34]),R=_r(_d[35]),H=_r(_d[36]),W=_r(_d[37]),E=_r(_d[38]),z=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),q=_r(_d[42]),Y=_r(_d[43]),_=_r(_d[44]),K=_r(_d[45]),Q=_r(_d[46]),V=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),se=_r(_d[52]),te=_r(_d[53]),le=_r(_d[54]);const oe=18,ae=18,ne=150,ie=34;function re(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const s=e.length,t=[],l=[];for(let l=0;l9){const n=3/Math.sqrt(a);l[e]=n*s*t[e],l[e+1]=n*o*t[e]}}let o=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let t=0;toe+(s-1)/Math.max(1,e-1)*t,o=[1,5,10,15,20,25].filter(s=>s=36)&&a.push(e);for(;a.length&&l(e)-l(a[a.length-1])<36;)a.pop();return[...a,e]}function ce({rid:e,today:s}){const t=(0,P.useCashUp)(e=>e.cashUps),[l,i]=(0,o.useState)(s.slice(0,7)),[r,d]=(0,o.useState)(0),[c,u]=(0,o.useState)(null),h=(0,o.useMemo)(()=>(0,M.monthTakings)(t,e,l,s),[t,e,l,s]),x=(0,o.useMemo)(()=>(0,M.firstTakingsMonth)(t,e),[t,e]),y=!!x&&xoe+(e-1)/Math.max(1,k-1)*w,I=e=>$-e/v*128,T=[];h.days.forEach((e,s)=>{if('recorded'!==e.state)return;const t={x:C(e.day),y:I(e.value)};s&&'recorded'===h.days[s-1].state?T[T.length-1].push(t):T.push([t])});const D=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),S=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===s):void 0)??A??D[D.length-1],L=e=>{const s=D.findIndex(e=>e.date===S?.date),t=D[Math.max(0,Math.min(D.length-1,s+e))];t&&(u(t.date),b.default.announceForAccessibility?.(N(t)))},N=e=>`${(0,M.longDay)(e.date)}, ${'recorded'===e.state?(0,M.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,O=h.current?`so far in ${h.month}`:`in ${h.month} ${l.slice(0,4)}`,R=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,M.monthName)((0,M.addMonths)(l,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,H=h.recorded?`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. ${(0,M.poundsWhole)(h.total)} ${O}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,M.longDay)(h.best.date)}, ${(0,M.poundsWhole)(h.best.value)}.${R?` ${R.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,W=r?de(k,r):[],E=(e,s,t,o,a)=>(0,le.jsx)(f.default,{testID:a,accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{disabled:!t},disabled:!t,onPress:()=>{i((0,M.addMonths)(l,o)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:t?e?.6:1:.25}),children:(0,le.jsx)(j.T,{size:24,colour:B.colours.gold,center:!0,children:e})});return(0,le.jsx)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(m.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),y||p?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[E('\u2039',`Previous month, ${(0,M.monthName)((0,M.addMonths)(l,-1))}`,y,-1,'mt-prev'),(0,le.jsxs)(j.T,{center:!0,colour:B.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",l.slice(0,4)]}),E('\u203a',`Next month, ${(0,M.monthName)((0,M.addMonths)(l,1))}`,p,1,'mt-next')]}):null,(0,le.jsx)(m.default,{accessible:!0,accessibilityLabel:H,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(j.T,{size:38,weight:"bold",colour:B.colours.gold,center:!0,testID:"mt-total",children:(0,M.poundsWhole)(h.total)}),(0,le.jsx)(j.T,{center:!0,colour:B.colours.goldLight,children:O}),(0,le.jsxs)(j.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,M.shortDay)(h.best.date)," \xb7 ",(0,M.poundsWhole)(h.best.value)]}),R?(0,le.jsx)(j.Muted,{center:!0,testID:"mt-vs",children:R}):null]}):(0,le.jsx)(j.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(m.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(m.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ne,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ne,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:oe,y1:$,x2:r-ae,y2:$,stroke:B.colours.hairline,strokeWidth:1}),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:`${re(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${s}`)),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:re(e),stroke:B.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${s}`)),T.filter(e=>1===e.length).map((e,s)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:B.colours.gold},`s${s}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:C(e.day),cy:$,r:2,fill:"none",stroke:B.colours.muted,strokeWidth:1},e.date)),S&&'recorded'===S.state?(0,le.jsx)(a.Line,{x1:C(S.day),y1:10,x2:C(S.day),y2:$,stroke:B.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===s);return(0,le.jsx)(a.Circle,{cx:C(e.day),cy:'recorded'===e.state?I(e.value):$,r:4.5,fill:B.colours.gold,stroke:B.colours.surface,strokeWidth:1.5})})():null,S&&'recorded'===S.state&&S.date!==s?(0,le.jsx)(a.Circle,{cx:C(S.day),cy:I(S.value),r:5,fill:B.colours.surface,stroke:B.colours.gold,strokeWidth:2}):null]}):null,r?D.map(e=>(0,le.jsx)(f.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:N(e),accessibilityState:{selected:S?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ne,left:C(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(m.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:W.map(e=>(0,le.jsx)(j.T,{size:F.AXIS_FONT,colour:B.colours.muted,style:{position:'absolute',left:C(e)-17,width:ie,top:0,textAlign:'center'},children:String(e)},e))})]}),S&&D.length?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(f.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:D[0]?.date===S.date,onPress:()=>L(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[0]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(m.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:N(S),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(j.Muted,{center:!0,children:S.date===s?`Today \xb7 ${(0,M.shortDay)(S.date)}`:(0,M.shortDay)(S.date)}),(0,le.jsx)(j.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===S.state?B.colours.goldLight:B.colours.muted,children:'recorded'===S.state?(0,M.poundsWhole)(S.value):'pending'===S.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(f.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:D[D.length-1]?.date===S.date,onPress:()=>L(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[D.length-1]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(j.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ue='#3A2F1E';function he({split:e}){return(0,le.jsx)(j.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(m.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(j.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(m.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",colour:B.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(m.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ue,borderWidth:1,borderColor:B.colours.gold},children:[(0,le.jsx)(m.default,{style:{width:`${e.walkInPct}%`,backgroundColor:B.colours.gold}}),(0,le.jsx)(m.default,{style:{flex:1,backgroundColor:ue}})]})]})]})})}},1435,[860,1161,1436,34,797,1099,1202,1103,1104,1423,1349,877,1107,281,402,102,794,874,891,1210,861,1179,858,1101,881,821,1201,1088,1160,1166,1167,1039,13,1171,927,987,1000,1445,1446,1170,1447,1181,869,1450,1205,1224,1223,1061,1062,1094,1126,1393,1174,1348,25]); +__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.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:z}=(0,R.useCtx)(6e4),V=z.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsxs)(j.Muted,{size:12,children:["Uses: ",e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')," from the counted stock. Held from the Display count and shown as \u201cReserved\u201d."]})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),De=J.hourOverrides??[],Re=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:D.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),Re?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:Re}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!Re,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),De.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:De.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...De.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),ze=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,$e]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{$e(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From a party of"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from party size"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:D.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)($.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:ze,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:D.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:D.colours.accentBorder,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:D.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:D.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,R.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:D.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:D.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:D.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),D=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),z=_r(_d[31]),I=_r(_d[32]),$=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:D.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?D.colours.red:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:D.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:D.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:D.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:D.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,z.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:D.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1436,[1162,1063,5,1418,827,1437,1438,1440,1441,1442,1220,1061,1062,1039,1044,34,402,102,794,14,1443,831,878,1101,877,821,1088,874,1204,1009,1010,891,1444,1388,1029,1111,1036,1164,980,25]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1437,[827,34,102,794,1161,877,821,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1438,[860,34,236,102,794,874,1029,1175,1271,987,1344,1439,25]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1439,[860,1295]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1440,[34,102,794,1029,1353,821,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1441,[34,102,794,1029,858,1396,5,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1442,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1443,[34,1063,102,821,794,1268,1271,25]); +__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1444,[34,102,794,1029,1366,821,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1445,[]); +__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},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])},1446,[34,402,102,794,821,1170,1445,25]); +__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1447,[927,796,831,828,837,878,1076,1448,34,994,336,379,236,402,102,794,874,891,858,821,1201,1088,1230,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1448,[499,1449]); +__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 t={}},1449,[]); +__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.ProgressBar=D,_e.useSetupDone=O,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,C.useCtx)(6e4),n=O(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=f.SETUP_STEPS.findIndex(e=>e.id===a),s=f.SETUP_STEPS[e+1]?.id??null;return(0,E.jsx)(L,{id:a,wizard:!0,onBack:()=>l(e>0?f.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=f.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,E.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{gap:12,children:[(0,E.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(m.T,{size:20,weight:"bold",colour:S.colours.gold,children:["Set up ",t.name]}),(0,E.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,E.jsx)(D,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,E.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,E.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:S.colours.border,backgroundColor:S.colours.surface,overflow:'hidden'},children:f.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,E.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:S.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,E.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?S.colours.gold:'transparent',borderWidth:1.5,borderColor:t?S.colours.gold:S.colours.border},children:(0,E.jsx)(m.T,{weight:"bold",colour:t?S.colours.onGold:S.colours.muted,children:t?'\u2713':s+1})}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"medium",children:e.title}),(0,E.jsx)(m.Muted,{children:e.sub}),o.length?(0,E.jsxs)(m.T,{size:13,colour:S.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,E.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=L,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return W}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,C.useCtx)(6e4),t=O(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,E.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:"Finish setting up"}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]}),(0,E.jsx)(D,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,E.jsxs)(m.Muted,{size:13,children:["Next: ",f.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]);const M=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],R=[1,2,3,4,5,6,0],I=/^([01]\d|2[0-3]):[0-5]\d$/,$=e=>{const s=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(s)&&s>0?Math.round(100*s):null},B=e=>f.SETUP_STEPS.findIndex(s=>s.id===e)+1;function D({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,E.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,E.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:S.colours.gold,borderRadius:5}})}),(0,E.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function O(e){const s=(0,f.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=f.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:f.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function L({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,C.useCtx)(6e4),l=O(a),r=l.prog,d=(0,i.useLiveVenue)(),u=f.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=_[e];return(0,E.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(m.T,{size:12,weight:"semibold",colour:S.colours.gold,children:["STEP ",B(e)," OF ",f.SETUP_STEPS.length]}),s&&o?(0,E.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,E.jsx)(m.T,{size:13,colour:S.colours.muted,children:"All steps"})}):null]}),(0,E.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,E.jsx)(D,{done:r.done,total:r.total})]}),(0,E.jsx)(b,{rid:a,done:(t="Saved.")=>{f.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,E.jsx)(m.Banner,{kind:"success",title:p}):null,(0,E.jsx)(N,{rid:a,id:e,title:u.title,onDone:x}),s?(0,E.jsxs)(m.Row,{gap:10,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,E.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const A=({wizard:e,onPress:s,disabled:t,label:n})=>(0,E.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const F=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function U({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,C.useHourly)(),d=(0,f.useSiteSetup)(e),u=(0,f.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,w.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,f.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),T(null)},z=!!p?.id&&(M=p.id,k.ROSTER.some(e=>e.id===M));var M;const R=p?$(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=R||z&&!p.wage);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,E.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,E.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?S.colours.gold:S.colours.border,backgroundColor:s?'#1d1a14':S.colours.surface}),children:[(0,E.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"semibold",children:e.name}),(0,E.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,f.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,E.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,f.accessOf)(e.level,e.role)})]},e.id))}),y?(0,E.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:S.colours.gold},children:(0,E.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,E.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,E.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,E.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,E.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,E.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Access level"}),(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:f.ACCESS_LEVELS.map(e=>(0,E.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,E.jsxs)(m.Muted,{size:13,children:["Uses the ",f.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Pay"}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,E.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,E.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,E.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,E.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,w.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,E.jsx)(m.Field,{label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=R&&R<1271?(0,E.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,E.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,E.jsxs)(m.Row,{gap:8,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,E.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),f.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:f.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=R&&s.setRate(t,R);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),f.useSetup.getState().patch(e,{staffGrade:o}),f.useSetup.getState().setLook(t,p.look),T(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,E.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,E.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(F(d.grades[0]?.id??'')),T(null)}}),(0,E.jsx)(A,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const _={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,f.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,E.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,E.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,E.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,E.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':'anchorage'===e?'The Anchorage logo in black and gold.':'greenside'===e?'The Greenside Restaurant logo.':'abbotsford'===e?'The Abbotsford Hotel logo.':'kirkton'===e?'The Kirkton Inn logo.':'wildings'===e?'The Wildings Hotel & Restaurant logo.':'kirkmichael'===e?'The Kirkmichael Arms logo.':'souters'===e?'The Souter\u2019s Inn logo.':'Placeholder initials.'," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,E.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,E.jsx)(P.OrderAtTableCard,{rid:e,compact:!0}),u?(0,E.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,E.jsx)(A,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,C.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=R.filter(e=>{const s=n[e];return s&&(!I.test(s[0])||!I.test(s[1]))});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),M.map((e,s)=>{const t=R[s],l=n[t];return(0,E.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:S.colours.border,paddingTop:s?6:0},children:[(0,E.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,E.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"to"}),(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,E.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,E.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries(R.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,E.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,E.jsx)(A,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,y.usePlan)(e),o=(0,y.planCounts)(n);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.TablePlan,{startStep:"areas"}),(0,E.jsx)(A,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,E.jsx)(U,{...e,payList:!0})]})},staff:U,permissions:function({done:e,wizard:s}){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(z.PermissionsScreen,{}),(0,E.jsx)(A,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,f.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,E.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,E.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,E.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,E.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,E.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,E.jsx)(A,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),a=(0,f.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,T.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,E.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,E.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:S.colours.border,padding:10},children:(0,E.jsx)(m.T,{size:14,colour:S.colours.goldLight,children:i})}),(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,T.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,E.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,E.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,E.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,E.jsx)(A,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),f.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,C.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,E.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,E.jsx)(A,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},W=e=>function(){return(0,E.jsx)(L,{id:e})};function N({rid:e,id:s,title:t,onDone:n}){const o=O(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,E.jsxs)(g.default,{style:{gap:4},children:[(0,E.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),f.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,E.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,E.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1450,[929,928,828,827,1076,1451,1452,1453,1454,1456,34,402,102,873,925,794,874,891,1029,927,15,867,821,1088,1457,1460,1464,1465,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1451,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1452,[34,987]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1453,[34,846,987]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1454,[2,827,34,236,383,102,794,1455,987,821,1205,1004,891,994,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1455,[]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1456,[34,402,794,987,821,1454,25]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1457,[827,979,1161,987,797,1238,1240,34,281,379,236,402,102,426,879,794,874,1249,891,867,858,821,1201,1088,869,1447,1180,1458,1459,1160,1167,1166,1039,13,1164,1170,1230,25]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1458,[827,34,1236,1056,870,379,402,102,794,891,867,858,821,1201,1088,1230,25]); +__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1459,[1016,34,402,102,794,891,821,1088,987,25]); +__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1460,[827,34,1048,395,102,1134,1135,1364,1393,794,1026,1029,858,821,1088,1030,1461,1462,1050,25]); +__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1461,[827,34,402,102,794,821,1029,5,1030,872,987,25]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1462,[34,102,794,1029,1463,859,821,1075,933,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1463,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1464,[5,1418,34,102,794,874,891,25]); +__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.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1465,[34,281,402,102,794,821,1000,1466,25]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1466,[933,987,891,872,1000]); +__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.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=M,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=M(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',O[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:O[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withWildingsQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function M(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const O={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from Bidfood or Booker? Add them here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1467,[832,1207,34,281,283,364,395,236,295,102,36,794,873,876,891,1029,1066,1067,5,859,1064,1074,821,872,1088,1468,1471,25]); +__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.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1468,[827,34,379,402,295,102,794,1469,1470,821,1467,1088,891,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1469,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1470,[839,846,849]); +__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.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1471,[34,402,102,794,876,1470,1029,859,1472,1074,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1472,[]); +__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1473,[828,34,283,364,236,402,102,846,794,821,25]); +__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1474,[1202,1099,1140,1117,34,402,102,794,891,858,821,1118,1188,1088,1199,1447,1181,876,1203,869,1201,925,1424,1029,860,1126,1218,1222,1098,25]); +__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.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1475,[34,1101,102,426,794,874,1163,1161,877,858,821,891,1201,1088,1170,1166,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1476,[846]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,x]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),B=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),v=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=v.filter(e=>'due'===e.state||'overdue'===e.state),$=v.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,y.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,y.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,y.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),B.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,B.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&x(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),x=_r(d[13]),y=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),B=_r(d[22]),v=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),y=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,v]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,F]=(0,r.useState)(''),[_,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,x.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(y.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,B.ukPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,B.emailOk)(_),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(y.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:v,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:F,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:_,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),y.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:_.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),x=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,v.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,v.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,y.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,y.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,y.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:x,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1477,[5,1418,860,1388,34,102,794,874,876,881,861,867,1179,1131,858,821,1201,1088,1180,1181,869,1425,864,988,1478,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1478,[34,102,794,874,867,987,821,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return pe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),b=_r(d[9]),h=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),E=_r(d[18]),N=_r(d[19]),P=_r(d[20]),W=_r(d[21]),A=_r(d[22]),R=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),G=_r(d[27]),B=(e=G)&&e.__esModule?e:{default:e},x=_r(d[28]),D=_r(d[29]),I=_r(d[30]),L=_r(d[31]),H=_r(d[32]),_=_r(d[33]),F=_r(d[34]),V=_r(d[35]),Q=_r(d[36]),q=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),K=_r(d[41]),z=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),ae=_r(d[49]),se=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),de=_r(d[55]),ue=_r(d[56]),le=_r(d[57]),ge=_r(d[58]),ce=_r(d[59]);const pe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},be=e=>n.CAN.manage(e);(0,y.register)([{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>be(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:be,C:R.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:w.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:be,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>be(e)&&!r.IS_CAR,badge:'NEW',C:P.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:be,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:be,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',badge:'NEW',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:be,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:be,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:be,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:be,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:b.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:be,badge:'NEW',C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:h.PLAN_SUB,group:'Account',can:n.CAN.billing,C:h.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',badge:'NEW',C:T.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',badge:'NEW',C:W.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:W.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',badge:'NEW',can:be,C:A.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:W.Timesheets}]),(0,y.register)([{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:M.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:M.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',badge:'NEW',can:be,C:E.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',badge:'NEW',can:be,C:N.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'Photo of the cash up sheet, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',badge:'NEW',can:be,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:M.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:M.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:M.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:be,C:M.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:be,C:M.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:be,C:M.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:be,C:M.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:be,C:M.ReviewEmailSettings},{id:'compliance',title:'Daily checks & allergen log',sub:'Fridge temps, opening checks, audit log',group:'Compliance',C:M.Compliance},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:M.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:be,badge:'NEW',C:M.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:M.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:O.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>pe(),C:O.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:be,C:O.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:be,C:O.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:O.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:be,C:O.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:be,C:O.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:be,C:O.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:be,C:O.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:O.TabletPreview}]);const he=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',badge:'NEW',C:()=>B.default.createElement(D.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:x.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',badge:'NEW',can:he,C:x.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',badge:'NEW',can:he,C:D.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',badge:'NEW',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:I.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',badge:'NEW',C:L.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:be,C:L.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:be,badge:'NEW',C:L.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:be,badge:'NEW',C:H.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:be,badge:'NEW',C:H.DisplaySettingsPage}]);const fe=e=>'owner'===e||'manager'===e;_.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:fe,badge:'NEW',C:_.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off, voice, connected services',group:'Account',can:fe,C:_.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',badge:'NEW',can:e=>'owner'===e&&!r.IS_CAR,C:V.CarScreen}]);const ye=e=>'owner'===e||'manager'===e,me=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Ce=e=>ye(e)&&me();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ye,badge:'NEW',C:F.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Prices},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning, allergen checks; filters; CSV and print for the EHO',group:'Compliance',can:ye,badge:'NEW',C:F.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ye,badge:'NEW',C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',badge:'NEW',C:F.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:be,badge:'NEW',C:Q.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:be,badge:'NEW',C:Q.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:be,badge:'NEW',C:Q.Outbox}]);const Se=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Se,badge:'NEW',C:U.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Se,badge:'NEW',C:q.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Se,badge:'NEW',C:Y.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Se,badge:'NEW',C:j.OrderSheetSettings},...K.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Se,C:(0,q.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Se,badge:'NEW',C:z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Se,badge:'NEW',C:$.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:be,badge:'NEW',C:$.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Se,badge:'NEW',C:$.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Se,badge:'NEW',C:J.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:be,badge:'NEW',C:X.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:be,badge:'NEW',C:X.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:be,badge:'NEW',C:X.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:be,badge:'NEW',C:Z.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:be,badge:'NEW',C:ee.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:be,badge:'NEW',C:ae.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, Booker and Bidfood lists, offers, events and specials the voice helper prepared; nothing is sent',group:'Run the day',can:be,badge:'NEW',C:se.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift, left by voice or typing',group:'Run the day',badge:'NEW',C:se.ShiftNotesPage},{id:'voice',title:'Voice helper',sub:'Hold-to-talk input, text-only replies, who gets it and microphone privacy',group:'Settings',can:be,badge:'NEW',C:se.VoiceSettingsPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ie.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update',group:'Compliance',can:ye,badge:'NEW',C:function(){return B.default.createElement(re.FoodSafetyCard,null)}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ne.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ye,badge:'NEW',C:function(){const{rid:e,today:t}=(0,oe.useCtx)(6e4);return B.default.createElement(ne.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',badge:'NEW',C:function(){const{rid:e,me:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:be,badge:'NEW',C:te.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',badge:'NEW',C:function(){const{me:e,role:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(ue.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:be,C:le.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:be,C:ge.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,badge:'NEW',C:ce.UseOnComputerPage}])},1479,[837,1086,872,1480,891,1004,994,831,881,1482,1489,1499,1459,1500,1501,1503,1504,1475,1505,1506,1508,1219,1210,1477,1509,1457,1510,34,1218,1199,1458,1447,1460,1493,1515,1516,1517,1450,1436,1464,1518,927,1519,1520,1522,1205,1467,1523,1388,1468,1535,1108,1111,1088,1220,1174,1536,1539,1542,1545]); +__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,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return k}}),_e.DashCorners=I,_e.ServiceBoard=function(){const{role:e}=(0,j.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,D.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,D.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,D.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,D.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,D.jsx)(I,{onLeave:y}),(0,D.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,D.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,D.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,D.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,D.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,D.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?w((0,D.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]),D=r(d[16]);const k=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function C({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,D.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,D.jsxs)(s.default,{children:[(0,D.jsx)(p.Icon,{name:t,colour:h.colours.gold}),u?(0,D.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,D.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function I({onLeave:e}){const t=(0,x.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>y.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,D.jsx)(C,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,D.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,D.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:k.filter(e=>'left'===e.side).map(n)}),(0,D.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[k.filter(e=>'right'===e.side).map(n),(0,D.jsx)(C,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')}),(0,D.jsx)(f.VoiceSlot,{size:44,layer:1})]})]})}function w(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[17]);return t(e,document.body)}},1480,[34,395,236,402,102,36,794,1056,1346,891,821,1157,1481,1207,1476,1088,25,277]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1481,[846]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, take a picture of the taking sheet and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1482,[827,1456,34,867,102,794,891,821,1088,925,926,1483,987,1001,1061,1454,1484,1485,1487,1027,1488,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1483,[]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1484,[827,34,102,794,821,891,1398,1408,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1485,[34,102,794,1486,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1486,[846,933,987,2]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1487,[34,102,794,821,999,1052,987,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1488,[933,987]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_VOICE_LINE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_SUPPLIER_LINE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DONE_FOR_YOU",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"doneForYouLine",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return v}}),_e.PlanBilling=function(){const{now:e,role:n,rid:b}=(0,p.useCtx)(6e4),j=(0,c.trialStatus)((0,l.defaultSimStart)(),e),[x,w]=(0,s.useState)(!1);return u.CAN.billing(n)?x?(0,y.jsx)(M,{onBack:()=>w(!1)}):(0,y.jsxs)(i.default,{style:{gap:10},children:[(0,y.jsx)(o.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,y.jsx)(t.VoiceUsageCard,{rid:b,now:e}),(0,y.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,y.jsxs)(i.default,{testID:"plan-founding",children:[(0,y.jsx)(o.T,{size:12,weight:"semibold",colour:h.colours.goldMuted,children:"FOUNDING OFFER \xb7 FIRST 50 VENUES"}),(0,y.jsxs)(o.T,{size:30,weight:"bold",children:["\xa349",(0,y.jsx)(o.T,{size:14,colour:h.colours.muted,children:" a month + VAT if applicable, per venue"})]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,y.jsx)(o.Badge,{kind:"gold",label:"Every Full Restaurant Pro feature"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"One month free"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"\xa349 net locked in"})]}),(0,y.jsx)(o.Muted,{children:"Early adopter price for the first 50 venues: every Full Restaurant Pro App feature, including the owner's dashboard and admin and the voice Assistant. \xa349 net stays locked in while your subscription stays active."}),(0,y.jsxs)(o.T,{size:13,testID:"plan-early-done-for-you",children:["\u2713 ",T(P.early)]}),(0,y.jsx)(o.Muted,{children:"From venue 51, usual prices:"}),(0,y.jsxs)(i.default,{testID:"plan-usual-lite",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[k," \xb7 ",C," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:S}),O.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e)),(0,y.jsx)(o.T,{size:13,testID:"plan-lite-not-included",children:"Not included: the owner's dashboard and admin, or the voice Assistant."})]}),(0,y.jsxs)(i.default,{testID:"plan-usual-pro",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[_," \xb7 ",L," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:v}),R.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e))]}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>w(!0),style:{marginTop:6}})]}),(0,y.jsx)(o.Card,{children:(0,y.jsxs)(i.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,y.jsx)(o.T,{weight:"bold",colour:h.colours.gold,children:"free"}),"."]}),(0,y.jsx)(o.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,y.jsx)(o.Muted,{children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, and subscribers get free lifetime 24/7 customer support. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{children:"Free trial"}),(0,y.jsxs)(o.T,{weight:"bold",colour:h.colours.gold,children:[j.daysLeft," day",1===j.daysLeft?'':'s'," left"]})]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(100*(1-j.daysLeft/j.total))}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),(0,y.jsxs)(o.Muted,{children:["Then \xa3",c.PLAN.monthlyPence/100," a month + VAT if applicable. The trial start date is not set up yet."]})]}),(0,y.jsx)(f.AssistantPlanCard,{}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{weight:"semibold",children:"Free lifetime customer support"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"Included"})]}),(0,y.jsx)(o.Muted,{children:"Free for as long as you subscribe, day or night. Setup is all done digitally. Support contact details: not set up yet."})]})]}):(0,y.jsx)(o.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),i=(e=n)&&e.__esModule?e:{default:e},o=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]);const b=!0,j='Founding offer, free trial, set-up guide',x='. The owner\'s dashboard and admin come with Full Restaurant Pro App (\xa399 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',w='Voice Assistant (hold to talk) for seating guests, marking tables as cleared, temperature logs and finding something in the app: fair usage 1,000 voice tasks a month per venue',A='Supplier links: open your suppliers\' ordering sites and keep order lists',P={lite:1,pro:3,early:3},T=e=>`${e} done-for-you ${1===e?'change':'changes'} a month`,k='Customer & Takeaway App',_='Full Restaurant Pro App',C='\xa349',L='\xa399',S='A lite version of CoverCharge: 3 core customer and takeaway functions tailored to you, set up digitally with the in-app guided setup and step-by-step guides, free lifetime 24/7 customer support while subscribed, and unlimited self-edits of your basic info. The owner\'s dashboard and admin, and the voice Assistant, are not included.',v='Every feature, every app, including the owner\'s dashboard and admin and the voice Assistant. Set up digitally with the in-app guided setup and step-by-step guides, the Assistant (fair use 300 tasks a month), free lifetime 24/7 customer support while subscribed, and unlimited self-edits.',O=['Customer app: menu, allergens, bookings and loyalty','Takeaway ordering','Set up digitally: in-app guided setup and step-by-step guides','Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits of your basic info',T(P.lite)],R=['Every feature, every app','The owner\'s dashboard and admin',A,'Set up digitally: in-app guided setup and step-by-step guides','The Assistant, fair use 300 tasks a month',w,'Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits',T(P.pro)],I=[['Choose your 3 core functions','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function M({onBack:e}){const[t,n]=(0,s.useState)([]);return(0,y.jsxs)(i.default,{style:{gap:10},testID:"setup-guide",children:[(0,y.jsx)(o.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,y.jsx)(o.H2,{children:"Set-up guide"}),(0,y.jsxs)(o.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",t.length," of ",I.length," done."]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(t.length/I.length*100)}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),I.map(([e,s],l)=>{const u=t.includes(l);return(0,y.jsx)(o.Card,{children:(0,y.jsxs)(o.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,y.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:u?h.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(o.T,{size:14,weight:"bold",colour:u?'#1a1610':h.colours.gold,children:u?'\u2713':String(l+1)})}),(0,y.jsxs)(i.default,{style:{flex:1,gap:4},children:[(0,y.jsx)(o.T,{weight:"semibold",children:e}),(0,y.jsx)(o.Muted,{children:s}),(0,y.jsx)(o.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>n(u?t.filter(e=>e!==l):[...t,l])})]})]})},e)}),(0,y.jsx)(o.Muted,{children:"Stuck? Free lifetime customer support is included while you subscribe. Ticks on this guide are not saved."})]})}},1489,[1490,34,102,794,850,891,1492,821,1088,1493,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1490,[34,102,794,821,1491,25]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1491,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1492,[]); +__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,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return v}}),_e.AssistantFab=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)(e=>e.enabled);return R(e)&&t?(0,A.jsxs)(c.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>v.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:k.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,A.jsx)(M,{size:22}),(0,A.jsx)(b.T,{weight:"bold",colour:I,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=v(e=>e.open),o=()=>v.getState().setOpen(!1),{rid:a,role:p,me:C}=(0,w.useCtx)(3e4),S=(0,j.useAssistant)(),I=B(),[E,L]=(0,r.useState)([]),[W,z]=(0,r.useState)(''),[$,_]=(0,r.useState)(!1),N=(0,r.useRef)(null),F=(0,r.useRef)(null);if((0,r.useEffect)(()=>{setTimeout(()=>N.current?.scrollToEnd?.({animated:!0}),50)},[E.length]),!e||!R(p))return null;const H=(e,t,s)=>j.useAssistant.getState().record({at:(new Date).toISOString(),by:C,role:p,asked:e,action:t,outcome:s}),U=(e,t="result")=>L(s=>[...s,{id:D(),from:'assistant',text:e,kind:t}]),V=async e=>{const t=e.trim();if(!t)return;let s;z(''),L(e=>[...e,{id:D(),from:'you',text:t}]);try{s=await(0,y.getProvider)('xai').interpret(t,I)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&H(t,'\u2014','not understood'),L(e=>[...e,{id:D(),from:'assistant',proposal:s,state:'open',asked:t}])},G=(e,t)=>L(s=>s.map(s=>s.id===e?{...s,state:t}:s)),q=async(e,t,n)=>{if(G(e.id,'confirmed'),'external'===t.kind)return H(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void U(T,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await m.repo.bookings.seatWalkIn(a,Number(o.party),s,'Added by Assistant'),s&&(0,f.resetTableLive)(a,s),U(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),H(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),U(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),H(e.asked,t.title,'done');break;case'price':await m.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),U(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),H(e.asked,t.title,'done');break;case'offer':x.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),U(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),H(e.asked,t.title,'done');break;case'rota':case'bookings':U(String(o.result)),H(e.asked,t.title,'looked up')}},Y=e=>{G(e.id,'cancelled'),H(e.asked,e.proposal?.title??'\u2014','cancelled'),U('Cancelled. Nothing was changed.','note')},K='lite'===S.tier,J=(0,j.tasksUsed)(S);return(0,A.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,A.jsx)(h.default,{style:[b.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,A.jsxs)(h.default,{testID:"assistant-sheet",style:{backgroundColor:k.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:k.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.Row,{gap:8,style:{flex:1},children:[(0,A.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:18})}),(0,A.jsx)(b.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,A.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,A.jsx)(h.default,{testID:"assistant-demo-badge",children:(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),K?(0,A.jsxs)(h.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,A.jsx)(b.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,A.jsx)(b.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(u.default,{ref:N,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===E.length?(0,A.jsxs)(h.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,A.jsxs)(b.T,{children:["Hi ",C.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,A.jsx)(b.Muted,{children:"Try:"}),y.SUGGESTED_PROMPTS.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:k.colours.surface2},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]}):null,E.map(e=>'you'===e.from?(0,A.jsx)(h.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,A.jsx)(b.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,A.jsx)(P,{m:e,onConfirm:(t,s)=>q(e,t,s),onCancel:()=>Y(e)},e.id):'choose'===e.proposal.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),(0,A.jsx)(b.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>V(e.prompt)},e.label))})]},e.id):(0,A.jsxs)(h.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:8},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]},e.id):(0,A.jsx)(h.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?k.colours.amberBg:k.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:k.colours.amber},children:(0,A.jsx)(b.T,{children:e.text})},e.id))]}),(0,A.jsxs)(b.Row,{gap:8,children:[(0,A.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:W,onChangeText:z,onSubmitEditing:()=>V(W),returnKeyType:"send",style:[b.styles.input,{flex:1,minWidth:0,width:40}]}),S.voice?(0,A.jsx)(c.default,{testID:"assistant-mic",accessibilityRole:"button",accessibilityLabel:$?'Stop listening':'Speak',onPress:()=>{const e=O();if(e)if($)F.current?.stop?.();else try{const t=new e;F.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&z(t)},t.onend=()=>_(!1),t.onerror=()=>{_(!1),U("Sorry, I didn't catch that. You can type instead.",'note')},_(!0),t.start()}catch{_(!1),U("Voice input isn't available here. Please type instead.",'note')}else U("Voice input isn't available in this browser (for example Huawei Browser). Please type your request instead.",'note')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:$?k.colours.gold:'transparent'},children:(0,A.jsx)(b.T,{size:20,children:"\ud83c\udfa4"})}):null,(0,A.jsx)(b.Button,{label:"Send",accessibilityLabel:"Send",disabled:!W.trim(),onPress:()=>V(W)})]}),(0,A.jsxs)(b.Muted,{center:!0,children:["Demo on this device \xb7 ",J," of ",j.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,w.useCtx)(6e4),s=(0,j.useAssistant)();return R(t)?(0,A.jsxs)(h.default,{style:{gap:12},children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{gap:10,children:[(0,A.jsx)(h.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:22})}),(0,A.jsxs)(h.default,{style:{flex:1},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,A.jsx)(b.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,A.jsx)(b.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>v.getState().setOpen(!0)}),(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,A.jsxs)(h.default,{testID:"assistant-log",style:{gap:6},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>j.useAssistant.getState().clearLog()}):null]}),(0,A.jsx)(b.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,A.jsx)(b.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,A.jsxs)(h.default,{style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.T,{size:12,colour:k.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,A.jsx)(b.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,A.jsxs)(b.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,A.jsxs)(b.T,{size:13,colour:k.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,A.jsx)(b.Muted,{children:"The activity log is visible to the owner."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)();return R(e)?(0,A.jsxs)(h.default,{style:{gap:12},testID:"assistant-settings",children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,A.jsx)(b.Muted,{children:"Shows the gold Assistant button on every Managers screen."}),(0,A.jsx)(b.Toggle,{label:"Voice input (microphone)",value:t.voice,onChange:e=>t.set({voice:e})}),(0,A.jsx)(b.Muted,{children:"What you say is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. If this device can\u2019t record, just type."})]}),(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Connected services"}),E.map(e=>(0,A.jsxs)(h.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:k.colours.border,paddingTop:8},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{children:e.name}),(0,A.jsx)(b.Badge,{kind:"neutral",label:"Not connected"})]}),(0,A.jsxs)(b.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,A.jsx)(b.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,A.jsx)(b.Muted,{children:"The Assistant comes with Full Restaurant Pro App and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,A.jsx)(b.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to the voice assistant to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,j.useAssistant)(),t=(0,j.tasksUsed)(e),s=Math.min(1,t/j.FAIR_USE);return(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,A.jsx)(b.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,A.jsx)(h.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${j.FAIR_USE} tasks used`,style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,A.jsx)(h.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:k.colours.gold,borderRadius:4}})}),(0,A.jsxs)(b.Muted,{children:[t," of ",j.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]),a=_r(d[4]),r=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var c=e(_r(d[8])),u=e(_r(d[9])),h=e(_r(d[10])),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),m=_r(d[14]),x=_r(d[15]),y=_r(d[16]),j=_r(d[17]),k=_r(d[18]),w=_r(d[19]),C=_r(d[20]),A=_r(d[21]);const S=!0,T='Nothing was sent or changed: this connection is not set up yet.',I='#1A1408',v=(0,p.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=e=>'owner'===e||'manager'===e,D=()=>Math.random().toString(36).slice(2,9);function M({size:e=24,colour:t=I}){return(0,A.jsx)(b.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function B(){const{rid:e,r:t,now:s,today:n}=(0,w.useCtx)(3e4),a=(0,m.useAllMenu)(e),l=(0,f.useTableNames)(e),c=(0,m.useBookings)(e),u=(0,x.useOwner)(e=>e.staff),h=(0,x.useOwner)(e=>e.shifts),p=(0,x.useOwner)(e=>e.offers),b=(0,x.useOwner)(e=>e.suppliers);return(0,r.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:a.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:l,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,C.workingShifts)(h,x.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,x.addDays)(n,-(0,x.weekdayOf)(n))&&e.date<=(0,x.addDays)(n,6-(0,x.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${b[0]?.contact??'Alex Sample'}, ${b[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),a,l,c,u,h,p,b])}function P({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[a,l]=(0,r.useState)(!1),[c,u]=(0,r.useState)('external'===o.kind?o.text:''),p='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,A.jsxs)(h.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:p?k.colours.gold:k.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:k.colours.surface2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,A.jsx)(b.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[o.detail?(0,A.jsx)(b.Muted,{children:o.detail}):null,(0,A.jsx)(b.T,{size:14,colour:k.colours.muted,children:o.label}),a&&p?(0,A.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:u,style:[b.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,A.jsx)(h.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:k.colours.gold,paddingLeft:10},children:(0,A.jsxs)(b.T,{children:["\u201c",c,"\u201d"]})}),(0,A.jsxs)(b.Muted,{children:["Sends to: ",o.service.map(e=>y.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,A.jsxs)(h.default,{style:{gap:4},children:[(0,A.jsx)(b.Muted,{children:o.detail}),o.warning?(0,A.jsxs)(b.T,{size:13,colour:k.colours.amber,children:["\u26a0 ",o.warning]}):null]}),p?(0,A.jsxs)(b.Row,{wrap:!0,gap:8,children:[(0,A.jsx)(b.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:a?'Done editing':'Edit',testID:"edit-action",onPress:()=>l(!a)}):null,(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,A.jsx)(b.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),p?(0,A.jsxs)(b.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}function O(){return'undefined'==typeof window?null:(0,a.speechRecognizer)()}const E=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1493,[827,979,796,884,931,34,395,236,402,295,102,846,794,1126,874,891,1494,1498,821,1088,1098,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);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]}})})},1494,[1495,1497,1496]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1495,[860,1496]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1496,[]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Voice assistant (server, with on-device fallback)',interpret:s}},1497,[1495,932]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1498,[884,839,846,849]); +__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.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1499,[5,1063,979,1418,828,827,837,1271,1443,34,402,410,102,879,794,874,891,861,867,858,821,1201,1088,1180,1447,1230,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1500,[860,34,102,1181,794,874,861,869,858,821,1201,1088,25]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1501,[1076,34,102,1502,829,873,794,891,821,1088,25]); +__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.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1502,[827,34,236,402,102,797,829,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1503,[34,1176,863,1088,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1504,[34,1062,1088,987,1000,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1505,[34,1394,1088,25]); +__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.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:s}=(0,c.useCtx)(6e4),a=(0,r.useBookings)(e),n=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,t.useState)('day'),k=(0,d.hasAnyTakings)(n,e),w=(0,d.dayRows)(n,a,e,s,14),f=(0,d.weekRows)(n,a,e,s,8),v=(0,d.averageSph)(w),$=(e,t,s,a,n)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${t}: ${'No takings entered'===a?'no takings entered':`spend per head ${a}`}, ${s}${n?`, ${n}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:t}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:s}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===a?h.colours.muted:h.colours.goldLight,size:'No takings entered'===a?13:16,children:a}),n?(0,u.jsx)(i.Muted,{center:!0,children:n}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:k?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:w.map(e=>({label:x(e.date),value:e.sph}))}),[...w].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),a=_r(_d[2]),n=e(a),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,t.useState)(320),[x,y]=(0,t.useState)(e.length);(0,t.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),k=Math.max(0,j-b),w=e.slice(k,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),T=e=>38+e*(f-76)/Math.max(1,w.length-1),S=e=>140-e/$*106,L=[];let D=[];w.forEach((e,t)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:t,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(n.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(a.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(n.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(a.Line,{x1:0,x2:f,y1:S($*e/4),y2:S($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,t)=>(0,u.jsx)(a.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},t)),w.map((e,t)=>(0,u.jsx)(s.default.Fragment,{children:null==e.value?(0,u.jsx)(a.Circle,{cx:T(t),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.Circle,{cx:T(t),cy:S(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(a.Text,{x:T(t),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},k+t))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:w.map((e,t)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},k+t))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===k,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1506,[34,102,797,794,874,1039,1507,821,1088,25]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1507,[13]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1508,[34,102,1354,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1509,[34,793,1088,25]); +__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.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1510,[5,1418,827,837,860,1511,1442,1481,1236,14,1271,987,1512,1514,1443,34,1126,1489,30,402,102,879,1291,794,874,891,867,881,1131,1260,858,821,1201,1088,1160,884,1459,869,1056,1176,863,861,25]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1511,[860,34,102,794,861,867,1175,874,869,821,25]); +__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1512,[987,34,281,236,102,1291,794,1268,1271,821,1513,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1513,[34,236,102,794,1268,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1514,[5,1418,34,102,794,867,1268,1269,1270,987,1271,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1515,[34,1225,1178,1226,1233,1088,1192,863,872,1025,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1516,[34,102,794,987,858,821,25]); +__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.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["Every booking and takeaway order gets a text (a phone number is needed to book) and an email if they gave one. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1517,[828,827,837,34,236,402,102,794,1238,874,1498,864,1240,1048,821,1057,1088,25]); +__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.OrderSheetSettings=function(){const e=(0,i.useOwner)(e=>e.site),u=(0,o.useSheets)(e),[c,m]=(0,l.useState)(null);return c?(0,p.jsxs)(s.Card,{children:[(0,p.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===c.id)?`Edit ${c.name}`:'New supplier'}),(0,p.jsx)(x,{rid:e,s:c,onDone:()=>m(null)})]}):(0,p.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,p.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,p.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,p.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,p.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,p.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,p.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,p.jsx)(s.Row,{wrap:!0,gap:8,children:(0,p.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var l=r(_d[0]),t=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),i=r(_d[4]),o=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]);const c=['online','phone','text','whatsapp','tbc'];function m({label:e,value:l,onChange:t}){return(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,p.jsx)(s.Chip,{label:e,selected:l.includes(n),onPress:()=>t(l.includes(n)?l.filter(e=>e!==n):[...l,n].sort())},e))})]})}function x({rid:e,s:t,onDone:i}){const d=(0,o.useOrderSheets)(e=>e.upsert),x=(0,o.useOrderSheets)(e=>e.remove),[b,f]=(0,l.useState)(t),[j,y]=(0,l.useState)(t.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[C,v]=(0,l.useState)(t.priceCapPerKg?(t.priceCapPerKg/100).toFixed(2):''),[w,T]=(0,l.useState)(!1),D=e=>f(l=>({...l,...e}));return(0,p.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,p.jsx)(s.Field,{label:"Supplier name",value:b.name,onChangeText:e=>D({name:e})}),(0,p.jsx)(s.Field,{label:"What they supply",value:b.goods,onChangeText:e=>D({goods:e})}),(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:c.map(e=>(0,p.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:b.method===e,onPress:()=>D({method:e})},e))})]}),'text'===b.method||'whatsapp'===b.method||'phone'===b.method?(0,p.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:b.number,keyboardType:"phone-pad",onChangeText:e=>D({number:e})}):null,'online'===b.method?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:b.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>D({url:e.trim()})}),(0,p.jsx)(s.Field,{label:"Button label",value:b.urlLabel??'',placeholder:"Open website",onChangeText:e=>D({urlLabel:e})})]}):null,(0,p.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:b.contact??'',onChangeText:e=>D({contact:e})}),(0,p.jsx)(m,{label:"Delivery days",value:b.deliveryDays,onChange:e=>D({deliveryDays:e})}),(0,p.jsx)(m,{label:"Order days (a reminder shows in the Head Chef app)",value:b.orderDays,onChange:e=>D({orderDays:e})}),(0,p.jsxs)(s.Row,{gap:10,children:[(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:b.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>D({cutoff:e})})}),(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Price cap \xa3/kg (optional)",value:C,keyboardType:"decimal-pad",onChangeText:v})})]}),(0,p.jsx)(s.Field,{label:"Reminder text (optional)",value:b.reminder,onChangeText:e=>D({reminder:e})}),(0,p.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:b.frequency,onChangeText:e=>D({frequency:e})}),b.priceCapPerKg||C?(0,p.jsx)(s.Field,{label:"Seller",value:b.seller,onChangeText:e=>D({seller:e})}):null,(0,p.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:y}),(0,p.jsx)(s.Field,{label:"Notes for the chef",value:b.notes,multiline:!0,onChangeText:e=>D({notes:e})}),(0,p.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,p.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const l=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,l)=>{const[n,s]=e.split('|').map(e=>e.trim()),i=t.items.find(e=>e.name===n);return{id:i?.id??`${b.id}-i${l}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*parseFloat(C.replace(/[\xa3,]/g,'')));d(e,{...b,items:l,priceCapPerKg:n>0?n:0,placeholder:b.placeholder&&'tbc'===b.method}),i()},disabled:!b.name.trim()}),(0,p.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:i}),w?(0,p.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{x(e,t.id),i()}}):(0,p.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>T(!0)})]})]})}},1518,[34,402,102,794,891,1031,867,1032,821,25]); +__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.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1519,[34,236,402,102,426,794,821,1376,873,1378,858,987,1379,1088,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1520,[835,984,1457,34,236,102,794,831,891,983,1031,985,987,1521,821,2,1182,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1521,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1522,[34,102,794,821,1438,1511,1088,25]); +__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.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1523,[827,1063,796,34,402,102,794,891,1473,1524,1525,1526,821,1088,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1524,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1525,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1526,[1527,1128,860,1528,1529,891,874,1029,1473,1524,1525,1531,1530,1533,1534,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1527,[1093,1092,1053]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1528,[984,1128,835,860,874,831,1029,983,985,1040,891,1095,882,863,861]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1529,[835,874,831,1029,891,1034,1044,1045,1010,1009,1039,13,1064,1065,1066,1035,1095,882,1105,1026,870,1530,1528]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1530,[835,979,1128,860,1161,1271,874,831,1029,1034,995,862,861,1105,1106,1026,1035,867,1531,1532]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1531,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1532,[839,846,849]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1533,[831,891,995,867,1530,1047,1098]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1534,[]); +__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.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"Staff hold the gold button, say what they need and let go. It sits at the top right in Managers, Head Chef, the Staff app (the full voice assistant, without team financial or HR information) and on the Display (no money, tips or HR either), never in the customer app. Tap it to type or open the Assistant. Replies and change confirmations are shown in text, never spoken. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts for you."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,r.useDrafts)(e=>e.drafts),u=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[j,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:r.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The voice helper and the Assistant save bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting. Try holding the voice button and saying \u201cadd blue roll to the Booker list\u201d."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!j,onClose:()=>y(null),title:'approved'===j?.status?'Approve this draft?':'Dismiss this draft?',children:j?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:j.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===j.status?`This marks it approved${v[j.d.kind]?` and opens ${v[j.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===j.status?'success':'danger',label:'approved'===j.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(j.d.id,j.status,o.replace(' (example)',''));const e=v[j.d.kind];y(null),'approved'===j.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const v={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1535,[34,379,102,794,821,1469,1531,1481,1532,1158,931,1490,1088,25]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1536,[34,796,102,794,861,1268,1537,1538,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1537,[861]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1538,[987,1537,1271]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_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]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1539,[34,102,794,874,1039,1540,979,13,1541,1050,821,1088,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1540,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(o){const{rid:u,date:c,bookings:f,cashUps:p,fields:v,soldOut:h}=o,b=f.filter(t=>t.restaurantId===u&&t.date===c),k=p.find(t=>t.rid===u&&t.date===c&&t.confirmedAt),y=p.find(n=>n.rid===u&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),N=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,O=(0,n.coversOn)(f,u,c),S=null==N||O<=0?null:Math.round(N/O*100)/100,_=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&_.set(n,(_.get(n)??0)+(t.partySize||0))}let w=null;for(const[t,n]of _)(!w||n>w.n)&&(w={hour:t,n:n});return{date:c,spendPerHead:s(S),covers:O,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(N),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(y?(0,t.grossOf)(y.vals)??(0,t.takings)(y.vals):null),busiestHour:w?`${String(w.hour).padStart(2,'0')}:00 \xb7 ${w.n} Covers`:'Not entered',soldOut:h.filter(Boolean),cashUp:v.map(t=>({label:t.label,value:k?l(k.vals[t.key],t.kind):'Not entered'}))}};var t=r(d[0]),n=r(d[1]);const s=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?s(t):String(t)},1541,[13,1507]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1542,[827,34,102,794,1543,1051,821,1544,1088,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1543,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1544,[1050,1051,976,933,987]); +__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.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1545,[34,281,236,102,794,827,821,987,1433,1205,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1546,[236]); +__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,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','voice','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1548,[]); +__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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1549,[34,283,364,236,402,295,102,426,36,797,827,796,794,1238,1388,1115,1473,1114,1112,1240,1253,979,891,1062,1481,2,987,821,1346,1550,1088,1493,1417,1180,1475,1477,1467,1459,1479,1546,1548,1556,1557,1558,1561,1564,25]); +__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.micAvailable=O,_e.NoShows=z,_e.CarApp=function(){(0,H.useCarViewport)();const{width:e,height:n}=(0,c.default)(),o=Math.max(320,A(e)),{role:d,today:u,now:h}=(0,w.useCtx)(3e4),[p,f]=(0,t.useState)(n),x=o,[y,I]=(0,t.useState)(null),[D,W]=(0,t.useState)(!1),[M,z]=(0,t.useState)(null),[V,F]=(0,t.useState)(!1),[G,Y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{O().then(z)},[]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==d&&T.useOwner.getState().setPreviewRole('owner')},[d]);const X=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,X);const q=(0,t.useCallback)(()=>W(!1),[]);(0,j.useBackLayer)(D,q);const J=e=>{W(!1),I({btn:e,page:e.pages[0].id})},K=(0,t.useCallback)((e,t)=>{const n=e=>R.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:n('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:n('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??R.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=n(t);return I(n=>({btn:e??n?.btn??R.CAR_BUTTONS[0],page:t}))}I(null)},[]),Q=x,Z=y?y.btn.label:'';return(0,L.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-p)>1&&f(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:o,maxWidth:'100%',overflow:'hidden'},children:[(0,L.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,L.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,L.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,L.jsx)(B.ParkedOnly,{small:o<1400}),(0,L.jsx)(N,{open:D,onPress:()=>W(!0)})]}),subHeader:(0,L.jsx)($,{onRota:()=>J(R.CAR_BUTTONS[0]),onAccount:()=>F(!0)})}),y?(0,L.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:Q,zIndex:40,backgroundColor:S.colours.bg},children:[(0,L.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${Z}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||X()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,L.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,L.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,L.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,L.jsx)(N,{testID:"car-menu-button-page",open:D,onPress:()=>W(!0)})})]}),y.btn.pages.length>1?(0,L.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,L.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?P:'transparent',alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,L.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:'assistant'===y.page&&!1===M?(0,L.jsx)(U,{}):(0,L.jsx)(_,{id:y.page,go:K},y.page)})]}):null]}),(0,L.jsx)(E,{visible:D,onClose:q,onPick:J,current:y?.btn.id,W:o,H:p}),V?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>F(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,L.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,L.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,L.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{F(!1),Y(!0)},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>F(!1),style:{minHeight:56}})]}):null,G?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>Y(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,L.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,L.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{Y(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>Y(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),c=e(r(_d[7])),d=r(_d[8]),u=e(d),h=r(_d[9]),b=r(_d[10]),p=r(_d[11]);r(_d[12]);var f=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),R=r(_d[26]),W=r(_d[27]),B=r(_d[28]),M=r(_d[29]),H=r(_d[30]),L=r(_d[31]);const P='rgba(201,162,74,0.14)';async function O(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}}function $({onRota:e,onAccount:n}){const o=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[c,d]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>d(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=o.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,L.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,L.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,L.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:n,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,L.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,L.jsx)(M.CarGameButton,{})]})}function z({go:e}){const{rid:t,now:n}=(0,w.useCtx)(3e4),o=(0,I.useBookings)(t),s=(0,D.ymd)(n),a=(0,D.ymd)(new Date(n.getTime()-24192e5)),c=o.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),d=o.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,L.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,L.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:c.length?`${c.length} no-show${1===c.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),d.length?(0,L.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),d.map(e=>(0,L.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,L.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,c.map(e=>(0,L.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,L.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,L.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function N({onPress:e,open:t,testID:n="car-menu-button"}){return(0,L.jsx)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:R.MENU_BUTTON,height:R.MENU_BUTTON,borderRadius:R.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,L.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,L.jsx)(d.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function E({visible:e,onClose:a,onPick:c,current:d,W:u,H:b}){const[p,f]=(0,t.useState)(0),m=(0,R.menuSizes)(u,b),x=p?Math.floor((p-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new n.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),n.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,L.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,L.jsx)(n.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,L.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,L.jsxs)(n.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,L.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,L.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,L.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,L.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>f(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:R.CAR_BUTTONS.map(e=>{const t=d===e.id;return(0,L.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>c(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,L.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:P,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(W.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,L.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U(){return(0,L.jsxs)(l.default,{testID:"car-no-mic",accessibilityLiveRegion:"polite",style:{gap:10,alignItems:'center',paddingVertical:24},children:[(0,L.jsx)(C.T,{center:!0,size:20,weight:"semibold",colour:S.colours.goldLight,children:"The Assistant needs the car\u2019s microphone"}),(0,L.jsx)(C.Muted,{center:!0,style:{maxWidth:520},children:"Sorry, this car\u2019s browser isn\u2019t letting the page use a microphone. For now, please use the Assistant in Managers on your phone."})]})}function _({id:e,go:t}){if('@bookings'===e)return(0,L.jsx)(f.Bookings,{go:t});if('@chat'===e)return(0,L.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,L.jsx)(z,{go:t});if('@orders'===e)return(0,L.jsx)(x.Orders,{});if('@forecast'===e)return(0,L.jsx)(y.Forecasts,{go:t});const n=(0,p.pageFor)(e);if(!n)return(0,L.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const o=n.C;return(0,L.jsx)(o,{go:t})}function A(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,n=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,n))}},1550,[34,283,364,236,402,295,102,426,797,796,1346,1459,1479,1417,1180,1477,1475,1088,1056,794,874,891,858,987,2,821,1551,1552,1553,1554,1555,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1551,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1552,[34,797,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1553,[34,102,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1554,[34,402,1182,1183,831,5,794,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1555,[34,236]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1556,[1551]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1557,[]); +__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.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1558,[34,402,102,426,827,794,1099,1062,1197,1143,1119,874,1039,891,1101,13,930,987,821,1417,1088,1459,1559,1548,1557,1560,25]); +__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,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1559,[34,402,295,102,794,821,25]); +__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.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1560,[34,102,797,794,821,1559,1557,25]); +__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.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1561,[34,281,402,102,797,794,874,891,1562,1000,1227,1466,821,1552,1088,1559,1563,1557,1560,1558,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1562,[846,849,839]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1563,[1000]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1564,[34,102,794,821,1565,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1565,[]); +__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.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:$,meId:V,me:Q}=(0,z.useCtx)(3e4);(0,m.useTipsPosted)(e,_);const Y=(0,z.useSignedIn)();(0,x.useSoldOutLink)(!0,(Y?.name??Q).replace(' (example)',''));const[ee,te]=(0,a.useState)({kind:'tab',tab:'home'}),[se,ae]=(0,a.useState)(''),oe=(0,a.useRef)(null);(0,a.useEffect)(()=>{(0,z.ensureAttendance)(_,$),(0,M.ensureChat)($)},[_]),globalThis.__ccNow=$.getTime();const ne=(0,a.useCallback)((e,t=null)=>{if('more'===e&&t){const e=q[t];return void te(e?{kind:'edit',id:e}:{kind:'page',id:t})}te('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,a.useEffect)(()=>(S.useVoiceNav.setState({go:ne}),()=>S.useVoiceNav.setState({go:null})),[ne]),(0,a.useEffect)(()=>{D.PITCH&&(globalThis.__pitchGo=ne,globalThis.__deskGo=e=>te(e))},[ne]),(0,E.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:Y?.id??'',name:Q,onOpen:e=>'bookings'===e?ne('bookings'):'chat'===e?ne('chat'):ne('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!Y}),(0,a.useEffect)(()=>((0,T.warmDesktopStt)(),(0,C.installVoiceKeys)()),[]);const re=(0,a.useMemo)(()=>[...G,...U].map(e=>e.s),[]);(0,a.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void oe.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=re[Number(e.key)-1];return void(t&&(e.preventDefault(),te(t)))}if('z'===t&&!Z(e.target)){const t=(0,W.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!Z(e.target)){const t=(0,W.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[re]);const ie=O.PAGES.filter(e=>(!e.can||e.can(f))&&!q[e.id]),le=(0,a.useMemo)(()=>{const e=se.trim().toLowerCase(),t={};return ie.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ie,se]),de=G.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ue=p.CAN.forecasts(f)?U:U.filter(e=>'rota'===e.s.id),ce='page'===ee.kind?(0,O.pageFor)(ee.id):void 0,be='tab'===ee.kind?G.find(e=>X(e.s,ee))?.label:'edit'===ee.kind?U.find(e=>X(e.s,ee))?.label:ce?.title,he='tab'===ee.kind?G.find(e=>X(e.s,ee))?.tip:'page'===ee.kind?`${ce?.sub??''}. Press ${(0,N.CMD)()}K to jump to any page, or hold Space and ask.`:'',ge=({label:e,s:t,n:s})=>{const a=X(t,ee);return(0,K.jsxs)(o.default,{accessibilityRole:"button",accessibilityState:{selected:a},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>te(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:a?A.colours.goldTint:e?A.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:a?A.colours.gold:'transparent'}),children:[(0,K.jsx)(g.T,{size:14,weight:a?'semibold':'regular',colour:a?A.colours.gold:A.colours.text,style:{flex:1},numberOfLines:1,children:e}),s?(0,K.jsxs)(g.T,{size:11,colour:A.colours.muted,children:[(0,N.CMD)(),s]}):null]})},fe=({t:e})=>(0,K.jsx)(g.T,{size:11,weight:"semibold",colour:A.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),pe='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,K.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:A.colours.bg},testID:"desktop-shell",children:[(0,K.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,K.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(g.Row,{gap:10,children:[(0,K.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(u.VenueName,{name:c.name}),(0,K.jsx)(g.Row,{gap:6,children:(0,K.jsx)(l.AppBadge,{label:pe})})]})]}),(0,K.jsx)(u.PoweredBy,{}),(0,K.jsx)(s.TextInput,{ref:oe,testID:"side-filter",value:se,onChangeText:ae,placeholder:`Find a page (${(0,N.CMD)()}K)`,placeholderTextColor:A.colours.muted,style:[g.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,K.jsxs)(n.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[se?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fe,{t:"Run the day"}),de.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:t+1},e.label)),(0,K.jsx)(fe,{t:"Drag-and-drop editors"}),ue.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:de.length+t+1},e.label))]}),Object.entries(le).map(([e,t])=>(0,K.jsxs)(r.default,{children:[(0,K.jsx)(fe,{t:e}),t.map(e=>(0,K.jsx)(ge,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{flex:1},children:[(0,K.jsx)(r.default,{testID:"desk-title",children:(0,K.jsx)(g.T,{size:24,weight:"bold",children:be??''})}),(0,K.jsxs)(g.Muted,{size:12,children:[Y?`Signed in as ${Y.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]}),(0,K.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(g.T,{size:15,weight:"bold",colour:A.colours.gold,children:"Talk to CoverCharge"}),(0,K.jsxs)(g.Muted,{size:12,children:["Hold Space, or ",(0,N.CMD)(),"\u21e7G"]})]}),(0,K.jsx)(v.VoiceSlot,{size:76})]}),(0,K.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[he?(0,K.jsx)(F.Tip,{children:he}):null,'edit'===ee.kind?(0,K.jsx)(J,{id:ee.id,rid:e,me:Q,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,K.jsxs)(n.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===ee.kind&&'home'===ee.tab?(0,K.jsx)(H.Dashboard,{go:ne}):null,'tab'===ee.kind&&'orders'===ee.tab?(0,K.jsx)(I.Orders,{}):null,'tab'===ee.kind&&'bookings'===ee.tab?(0,K.jsx)(R.Bookings,{}):null,'tab'===ee.kind&&'forecast'===ee.tab?(0,K.jsx)(P.Forecasts,{go:ne}):null,'tab'===ee.kind&&'chat'===ee.tab?(0,K.jsx)(M.Chat,{go:ne}):null,ce?(0,K.jsx)(ce.C,{go:ne}):'page'===ee.kind?(0,K.jsx)(g.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,K.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,K.jsx)(h.PrintHost,{rid:e}):null,'staff'!==f?(0,K.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Q,onOpen:e=>ne('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,K.jsx)(L.AssistantSheet,{}),(0,K.jsx)(B.OnboardingHost,{go:ne}),(0,K.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),s=_r(d[1]),a=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]),g=_r(d[12]),f=_r(d[13]),p=_r(d[14]),x=_r(d[15]),m=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),S=_r(d[22]),v=_r(d[23]),T=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),z=_r(d[31]),H=_r(d[32]),P=_r(d[33]),B=_r(d[34]),I=_r(d[35]),O=_r(d[36]);_r(d[37]);var _=_r(d[38]),N=_r(d[39]),W=_r(d[40]),$=_r(d[41]),V=_r(d[42]),F=_r(d[43]),K=_r(d[44]);const G=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Hold Space and say \u201chow many Covers tonight?\u201d for a quick answer without leaving this screen.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first. Say \u201cshow new orders\u201d to jump back any time.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber. Hold Space and say \u201caccept the 7 o\u2019clock\u201d.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],U=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],q={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},X=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),Z=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function J({id:e,rid:t,me:s,role:o,today:n,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,a.useState)(0),[h,p]=(0,a.useState)('');return'menu'===e?(0,K.jsx)($.MenuEditor,{rid:t,me:s,role:o}):'rota'===e?(0,K.jsx)(V.RotaEditor,{today:n}):'brand'===e?(0,K.jsx)(_.BrandEditor,{rid:t}):(0,K.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,K.jsxs)(F.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,N.CMD)(),"Z undoes, then Save."]}),h?(0,K.jsx)(g.T,{size:13,colour:A.colours.goldLight,children:h}):null,(0,K.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:A.colours.border,borderRadius:12,overflow:'hidden'},children:(0,K.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1566,[828,827,34,402,295,102,36,1361,873,1364,1238,1388,794,1029,891,979,1062,1473,1115,1114,1112,1567,1481,1157,931,1240,2,821,1493,1417,1180,1088,1435,1475,1467,1477,1459,1479,1568,1546,1570,1572,1574,1571,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1567,[846]); +__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.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1568,[34,295,102,1502,873,794,891,829,1460,821,1569,1570,1571,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1569,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1570,[34]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1571,[34,102,794,821,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1572,[827,34,102,794,876,831,979,981,982,861,882,1174,821,1569,1570,1571,1573,25]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1573,[891]); +__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.RotaEditor=function({today:e}){const y=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[$,j]=(0,t.useState)((0,i.mondayOfDate)(e)),[v,k]=(0,t.useState)(null),[w,D]=(0,t.useState)(''),B=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),O=b.map((e,t)=>(0,i.addDays)($,t)),P=(e,t,o)=>{e.preventDefault(),k(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=y.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=$&&e.date<=O[6]),I=T.filter(e=>!e.published||e.changed).length;return(0,p.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,p.jsx)(h.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,p.jsxs)(s.Row,{gap:8,children:[(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>j((0,i.addDays)($,-7))}),(0,p.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date($+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>j((0,i.addDays)($,7))}),(0,p.jsx)(d.default,{style:{flex:1}}),w?(0,p.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:w}):null,(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!B.canUndo,onPress:B.undo,testID:"rota-undo"}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!B.canRedo,onPress:B.redo,testID:"rota-redo"}),(0,p.jsx)(s.Button,{small:!0,label:I?`Publish (${I})`:'Published',disabled:!I,onPress:()=>{B.record('published the week');const e=i.useOwner.getState().publishWeek($);D(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,p.jsx)("div",{style:(0,h.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,p.jsxs)("div",{style:(0,h.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,p.jsx)("div",{style:(0,h.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),O.map((t,o)=>(0,p.jsxs)("div",{style:(0,h.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[b[o]," ",Number(t.slice(8))]},t)),y.map(e=>(0,p.jsxs)(o.default.Fragment,{children:[(0,p.jsxs)("div",{style:(0,h.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,p.jsx)("div",{style:(0,h.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,p.jsx)("div",{style:(0,h.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),O.map(t=>{const o=`${e.id}|${t}`,d=T.filter(o=>o.staffId===e.id&&o.date===t);return(0,p.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',k(o)},onDragLeave:()=>k(null),onDrop:o=>P(o,e.id,t),style:(0,h.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,p.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,h.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,p.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]),f=r(_d[9]),p=r(_d[10]);const b=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],x=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1574,[34,102,794,891,1091,821,1569,1570,1571,1573,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1575,[30,34,872,1576,25]); +__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1576,[1460,1577,828,997,1099,1511,1224,1055,1056,1512,1536,1514,1174,979,1016,1578,1013,2,1061,1062,1487,999,1039,1000,34,1176,1249,1253,1220,373,402,295,102,426,36,794,873,1157,891,821,1180,1417,1094,1112,1114,1108,1057,1040,1088,1505,1500,1520,1579,1426,1004,236,1255,1199,1205,1458,1219,1218,1474,1202,15,1225,1226,925,793,987,25]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1577,[34,102,794,1088,987,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1578,[236,1014]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1579,[860,34,102,794,891,1029,858,1091,1089,987,1090,5,1001,821,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1580,[30,34,872,25]); +__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1581,[1454,987,795,1411,1582,1026,30,1609,496,34,385,336,236,41,102,5,873,872,1611,36,874,1029,891,821,1426,1004,1024,1612,1613,1058,1614,1130,2,1039,999,1616,1379,25,1618,1619,1620,1621]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1582,[1583,1606,1608]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1583,[215,1584,1587,1601,1602,1603,1604,1605]); +__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1584,[215,1585]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1585,[1586]); +__d(function(g,r,i,a,m,e,d){},1586,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1587,[1588,215,1584,1601,1602]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1588,[1589,1590,1600]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1589,[1590,1594,1599]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1590,[215,372,1591,1595,1596,1597,1598,1594,1599]); +__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1591,[215,1592,339,280,1593,1594]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1592,[504]); +__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1593,[215,339]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1594,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1595,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1596,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1597,[1595]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1598,[]); +__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1599,[372,1593]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1600,[34,1590]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1601,[1588,215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1602,[1588,1601]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1603,[1584]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1604,[215,1584,1587,1585]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1605,[]); +__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1606,[215,54,1607]); +__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1607,[215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1608,[34,1583]); +__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]}})})},1609,[1610]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1610,[]); +__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1611,[34,41,102,426,794,873,1004,987,2,5,821,1551,1553,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1612,[990,883,882,987]); +__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1613,[828,796,827,34,1012,1461,1030,402,102,872,987,1014,1029,5,821,794,1357,976,2,25]); +__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1614,[5,796,827,34,385,283,364,380,236,402,295,426,102,1493,1157,2,797,1088,15,891,794,821,1526,932,1615,1524,1525,1481,1158,1491,931,1567,1534,25,277]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1615,[891,831,1029]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1616,[874,831,891,1039,15,1004,872,2,1617]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1617,[874,1039]); +__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1618,[]); +__d(function(o,s,e,p,c,t,d){"use strict";c.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1619,[]); +__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1620,[]); +__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1621,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1622,[30,34,872,25]); +__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1623,[1624]); +__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1624,[25,1625,591]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1625,[34,172]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1626,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1627,[25,499,34,270,651]); __r(501); __r(21); __r(0); \ No newline at end of file diff --git a/car-app/index.html b/car-app/index.html index 168cd9524feb5a06463926a0c7c4757cead88283..de8336b804838cd831854eefe0c5a19629eab7de 100644 --- a/car-app/index.html +++ b/car-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/car-app/owner.html b/car-app/owner.html index b525cc5997c47050e520061477a84cff07adf4b8..a984f3ab7db8cf58ebd54c6ff0a9a2335728b046 100644 --- a/car-app/owner.html +++ b/car-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/car-app/sw.js b/car-app/sw.js index 2ffbb116c805cb3f9fb6a3a183a3ccd54de2cb02..a8057f912dbc8b56ff7af51836b2b5f2a6bcba69 100644 --- a/car-app/sw.js +++ b/car-app/sw.js @@ -1,7 +1,7 @@ // Anchorage car screen service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-car-6c39b59886"; +const V = "cc-car-d37c962354"; const BASE = "/car-app/"; -const PRECACHE = ["/car-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/car-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/car-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/car-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/car-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/car-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/car-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/car-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/car-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/car-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/car-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/car-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/car-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/car-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/car-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/car-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/car-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/car-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/car-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/car-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/car-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/car-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/car-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/car-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/car-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/car-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/car-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/car-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/car-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/car-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/car-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/car-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/car-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/car-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/car-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/car-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/car-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/car-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/car-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/car-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/car-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/car-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/car-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/car-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/car-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/car-app/favicon.ico", "/car-app/index.html", "/car-app/_expo/static/js/web/bundle.js?v=6c39b59886be38a20bde38b8de76e03196eeb7ed42b4122571f0a7baacba9581"]; +const PRECACHE = ["/car-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/car-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/car-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/car-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/car-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/car-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/car-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/car-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/car-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/car-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/car-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/car-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/car-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/car-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/car-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/car-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/car-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/car-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/car-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/car-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/car-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/car-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/car-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/car-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/car-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/car-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/car-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/car-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/car-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/car-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/car-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/car-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/car-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/car-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/car-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/car-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/car-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/car-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/car-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/car-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/car-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/car-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/car-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/car-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/car-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/car-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/car-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/car-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/car-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/car-app/favicon.ico", "/car-app/index.html", "/car-app/_expo/static/js/web/bundle.js?v=d37c962354da6c27e6a47c941f3c1aad111a10e7523f4aa7f44d555d4e37ba13"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/chef-app/_expo/static/js/web/bundle.js b/chef-app/_expo/static/js/web/bundle.js index 50aecfad2211fc88a67a908af7b055c45952a538..b66a6b5bc75ead5ac7708852bd309cdeddb6cb11 100644 --- a/chef-app/_expo/static/js/web/bundle.js +++ b/chef-app/_expo/static/js/web/bundle.js @@ -23,11 +23,11 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_VENUE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PITCH_TEAM",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PITCH_TEXT",{enumerable:!0,get:function(){return o}}),e.pitchText=function(a,n=!1){let l=a;for(const[a,s]of o){if(n&&t.test(a.source.replace(/\\/g,'')))continue;a.test(l)?(a.lastIndex=0,l=l.replace(a,s)):a.lastIndex=0}return l};const a={name:'The Harbour Kitchen',tagline:'Harbourside seafood & seasonal plates',location:'12 Quay Street, Portmorran',phone:'01632 960 123',website:'harbourkitchen.example'},n={'st-tracy':{name:'Morgan',job:'Owner',hourlyPence:null,salaried:!0},'st-gordon':{name:'Alex',job:'General Manager',dept:'Management',hourlyPence:null,salaried:!0},'st-bisto':{name:'Ravi',job:'Head Chef',hourlyPence:null,salaried:!0},'st-agate':{name:'Priya',job:'Front of house supervisor',hourlyPence:1450},'st-lenny':{name:'Tom',job:'Commis Chef',hourlyPence:1325},'st-finn':{name:'Lewis',job:'Bar staff',hourlyPence:1290},'st-eilidh':{name:'Chloe',job:'Front of house',hourlyPence:1271},'st-emily':{name:'Ellie',job:'Front of house',hourlyPence:1271},'st-lillie':{name:'Jordan',job:'Kitchen porter (KP)',hourlyPence:1271},'st-jack':{name:'Sam',job:'Kitchen porter (KP)',hourlyPence:1271}},o=[['Harbour View, Dunure, South Ayrshire',a.location],['Harbour View, Dunure',a.location],['Harbour View mug','Harbour Kitchen mug'],['Harbour View','Quay Street'],['anchoragedunure.com',a.website],['01292 502826',a.phone],['Mini Anchors','Little Crew'],['The Anchorage',a.name],['Anchorage','Harbour Kitchen'],['ANCHORAGE','HARBOUR KITCHEN'],['South Ayrshire','the Firth coast'],['Ayrshire','the Firth coast'],['Dunure','Portmorran'],['Kittyfisher boat (Big Sean)','Coastal Fish Co'],['Kittyfisher','Coastal Fish Co'],['Big Sean','Coastal Fish Co'],['Example Fish Co.','Coastal Fish Co'],['Sample Dairy Ltd','Hillside Dairy'],['Sample Fruit & Veg','Fieldfare Veg'],['Mills milk','Hillside Dairy milk'],['Mills','Hillside Dairy'],['J. Pieroni & Sons','Fieldfare Veg'],["Pieroni's",'Fieldfare Veg'],['Pieroni','Fieldfare Veg'],['Alsons (drinks)','Drinks wholesaler'],['Alsons','the drinks wholesaler'],['Spes Bona','the deli wholesaler'],['Tarelgin','the butcher'],['Reids','the bakery'],['Reeds','the bakery'],['Example Butchers Ltd','Quayside Butchers'],['Example Dry Goods Wholesale','Dry goods wholesaler'],['Sample Brewing Co.','Harbourside Brewing'],['Example Cleaning Supplies','Cleaning supplies'],['Sample Packaging Ltd','Packaging supplier'],['Example Kitchen Repairs','Kitchen repairs'],['Preston','Ravi'],['Bisto','Ravi'],['Tracy','Morgan'],['James','Morgan'],['Gordon','Alex'],['Agate','Priya'],['Lenny','Tom'],['Finn','Lewis'],['Eilidh','Chloe'],['Emily','Ellie'],['Gabrielle','Ellie'],['Cameron Mc','Sam'],['Cameron','Sam'],['Lillie','Jordan'],['Lily','Jordan'],['Mia','Jordan'],['Jack','Sam'],['Harvey','Jordan'],['Anna','the supplier'],['(preview)',''],[' (example)','']].map(([a,n])=>[new RegExp(`${/^[A-Za-z]/.test(a)?'(?g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},23,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1522,1525]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1525,1528]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},25,[26]); __d(function(g,r,i,a,m,e,d){ /** @@ -41,8 +41,8 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},26,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},27,[28]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1052,1255,1256,1260,1262,1264,1271,1325,1326,1327,1328,1329,1330,1332,1333,1334,1335,1336,1337,1338,1339,1342,1409,1410,1411,1413,1459,1460,1521]); -__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,993,25]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1053,1256,1257,1261,1263,1265,1272,1326,1327,1328,1329,1330,1331,1333,1334,1335,1336,1339,1340,1341,1342,1345,1412,1413,1414,1416,1462,1463,1524]); +__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,994,25]); __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)},30,[31,32,782,783,785]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},31,[]); __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}},32,[33,692,487,708,557,709,770,761,764,774,647,645,650,562,560,591,465,467,204,205,775,472,473,462,460,569,556,639,659,776,658,162,151,547,433,777,780]); @@ -872,9 +872,9 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},789,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},790,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},791,[]); -__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1054,1055,1015,2,1056,1060,1061,1093,858,1098,1102,1103,1106,1107,1110,1111,1113,1114,1115,1144,1146,1091,34,373,236,402,295,426,102,36,873,1156,794,867,821,1087,1158,1164,1167,1168,1171,1185,1184,1186,1187,1190,1191,1198,1201,1204,1217,1218,1222,1223,925,1003,1224,1177,1225,1232,1237,1246,1239,1175,1248,1252,1219,874,1253,1173,987,1254,25]); +__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1055,1056,1016,2,1057,1061,1062,1094,858,1099,1103,1104,1107,1108,1111,1112,1114,1115,1116,1145,1147,1092,34,373,236,402,295,426,102,36,873,1157,794,867,821,1088,1159,1165,1168,1169,1172,1186,1185,1187,1188,1191,1192,1199,1202,1205,1218,1219,1223,1224,925,1004,1225,1178,1226,1233,1238,1247,1240,1176,1249,1253,1220,874,1254,1174,987,1255,25]); __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=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.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."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.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 CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};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]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(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 v(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 b(e){const{img:t,url:a}=await f(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),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.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()})}},793,[34,336,236,402,102,794,925,929,926,821,930,25]); -__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=D,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(H,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(x.default,{style:{flex:1},children:u}),s?(0,B.jsx)(x.default,{style:N.footer,children:(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=v,_e.Card=F,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(x.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:L?'center':'flex-start'}],children:(0,B.jsx)(D,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(x.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(D,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(D,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(x.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(D,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,p.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(D,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(D,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(x.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(D,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),x=e(_r(d[14])),p=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),L='display'!==S.APP_VARIANT;function D({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),x=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,p=f.default.flatten(t)||{},j=1===p.flex||1===p.flexGrow||'number'==typeof p.width||'left'===p.textAlign,k=c??(L&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,x,(0,W.webLine)(t,r),k&&'left'!==p.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(D,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(D,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(D,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??L});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(x.default,{style:N.brandBar,children:[(0,B.jsxs)(x.default,{style:N.row,children:[(0,B.jsx)(x.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(D,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(x.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(x.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function H(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(D,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function v({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],x={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:x,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(D,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(D,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function F({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(x.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(x.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(D,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(D,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,v.centreRow=!0;const V=()=>(0,B.jsx)(E,{kind:"example",title:"Allergens awaiting kitchen verification",children:"This allergen information has not been verified by the kitchen. Head chef sign-off is required. Always speak to staff about allergies."}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Card payments: not set up yet",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===F?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(L&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(x.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=L&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(x.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(x.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); +__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(v,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(p.default,{style:{flex:1},children:u}),s?(0,B.jsx)(p.default,{style:N.footer,children:(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=F,_e.Card=H,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:D?'center':'flex-start'}],children:(0,B.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,x.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),D='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(D&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??D});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(p.default,{style:N.brandBar,children:[(0,B.jsxs)(p.default,{style:N.row,children:[(0,B.jsx)(p.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function v(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function F({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function H({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,F.centreRow=!0;const V=({phone:e})=>(0,B.jsx)(E,{kind:"warn",title:"Allergies",children:"All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===H?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(D&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=D&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},795,[]); __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.GoldX=h,_e.GoldClose=j,Object.defineProperty(_e,"TEXT_ONLY_CLOSE",{enumerable:!0,get:function(){return x}}),_e.ToastClose=function({onPress:e,label:o="Close",testID:s,size:l="md",style:c,colour:h}){return x?(0,b.jsx)(t.default,{testID:s,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:[{minWidth:64,minHeight:48,alignItems:'center',justifyContent:'center',paddingHorizontal:8},c],children:(0,b.jsx)(u.Text,{style:{fontSize:16,color:h??n.colours.text},children:"Close"})}):(0,b.jsx)(j,{onPress:e,label:o,testID:s,size:l,style:c})},r(d[0]);var t=e(r(d[1])),o=e(r(d[2])),s=r(d[3]),l=e(s),n=r(d[4]),c=r(d[5]),u=r(d[6]),b=r(d[7]);function h({size:e=16,colour:t=n.colours.gold,stroke:o}){const c=o??(e>=20?2.4:2.2);return(0,b.jsx)(l.default,{width:e,height:e,viewBox:"0 0 24 24",accessible:!1,focusable:!1,pointerEvents:"none",children:(0,b.jsx)(s.Path,{d:"M6 6 L18 18 M18 6 L6 18",stroke:t,strokeWidth:Math.min(4,c*(24/e)),strokeLinecap:"round",fill:"none"})})}const f={sm:32,md:38,lg:46},y={sm:13,md:15,lg:18};function j({onPress:e,label:s="Close",testID:l,size:c="md",style:u,disabled:j,hint:x}){const C=f[c],I=Math.max(44,C+8);return(0,b.jsx)(t.default,{testID:l,accessibilityRole:"button",accessibilityLabel:s,accessibilityHint:x,disabled:j,onPress:e,dataSet:{goldClose:'1'},style:[{width:I,height:I,alignItems:'center',justifyContent:'center',flexShrink:0,opacity:j?.4:1},u],children:({pressed:e,hovered:t})=>(0,b.jsx)(o.default,{style:{width:C,height:C,borderRadius:C/2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:e||t?n.colours.gold:n.colours.accentBorder,backgroundColor:e?n.colours.goldTint:t?n.colours.accentBg:'rgba(0,0,0,0.18)'},children:(0,b.jsx)(h,{size:y[c],colour:e?n.colours.goldLight:n.colours.gold})})})}const x=['kirkton','abbotsford'].includes(c.VENUE_RID)},796,[34,402,102,797,821,5,827,25]); __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}},797,[798]); @@ -911,7 +911,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule? __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOUTERS_BG",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SOUTERS_SURFACE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SOUTERS_TYPE_SCALE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"soutersFont",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"soutersSurface",{enumerable:!0,get:function(){return f}}),e.soutersInk=function(o){if(!t.IS_SOUTERS)return o;const c=(0,n.normaliseHex)(o);return c?'#A4622E'===c?'#D9AD8A':(0,n.contrast)(c,u)<4.5?'#FFFFFF':o:o};var t=r(d[0]),n=r(d[1]);const u='#56152A',o='#43122F',c=.88,S=n=>t.IS_SOUTERS?Math.round(n*c*100)/100:n,f=n=>t.IS_SOUTERS?o:n},828,[5,829]); __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normaliseHex=n,e.hexToRgb=r,e.rgbToHex=o,e.hsvToRgb=s,Object.defineProperty(e,"hsvToHex",{enumerable:!0,get:function(){return a}}),e.hexToHsv=function(t){const{r:n,g:o,b:s}=r(t),a=n/255,c=o/255,u=s/255,i=Math.max(a,c,u),h=Math.min(a,c,u),l=i-h;let p=0;l&&(p=i===a?(c-u)/l%6:i===c?(u-a)/l+2:(a-c)/l+4);return{h:(60*p+360)%360,s:i?l/i:0,v:i}},e.luminance=c,e.contrast=u,e.shade=i,e.checkAccent=function(t,r,o,s){const a=n(t)??'#CFA45F',c=u(a,o),h=u(a,s),l=c>=h?o:s,p=[];Math.max(c,h)<4.5?p.push('Button text may be hard to read on this colour. We picked the clearer text colour for you, but a lighter or darker shade will read better.'):l===s&&p.push('This is a dark colour, so buttons use light text.');let b=a,d=0;for(;u(b,r)<4.5&&d<20;)b=i(a,.05*(d+1)),d++;b!==a&&p.push('This colour is hard to read on the dark background, so header text uses a lighter shade of it.');return{onAccent:l,accentText:b,tips:p}},e.pushRecent=function(t,r,o=8){const s=n(r);return s?[s,...(t??[]).filter(t=>t!==s)].slice(0,o):t??[]};const t=(t,n=0,r=1)=>Math.min(r,Math.max(n,t));function n(t){const n=t.trim().replace(/^#/,'');return/^[0-9a-fA-F]{3}$/.test(n)?'#'+n.split('').map(t=>t+t).join('').toUpperCase():/^[0-9a-fA-F]{6}$/.test(n)?'#'+n.toUpperCase():null}function r(t){const r=(n(t)??'#000000').slice(1);return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function o({r:n,g:r,b:o}){return'#'+[n,r,o].map(n=>Math.round(t(n,0,255)).toString(16).padStart(2,'0')).join('').toUpperCase()}function s({h:t,s:n,v:r}){const o=(t%360+360)%360/60,s=r*n,a=s*(1-Math.abs(o%2-1)),c=r-s,[u,i,h]=o<1?[s,a,0]:o<2?[a,s,0]:o<3?[0,s,a]:o<4?[0,a,s]:o<5?[a,0,s]:[s,0,a];return{r:255*(u+c),g:255*(i+c),b:255*(h+c)}}const a=t=>o(s(t));function c(t){const n=t=>{const n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)},{r:o,g:s,b:a}=r(t);return.2126*n(o)+.7152*n(s)+.0722*n(a)}function u(t,n){const r=c(t),o=c(n);return(Math.max(r,o)+.05)/(Math.min(r,o)+.05)}function i(t,n){const{r:s,g:a,b:c}=r(t),u=n>0?255:0,i=Math.abs(n);return o({r:s+(u-s)*i,g:a+(u-a)*i,b:c+(u-c)*i})}},829,[]); __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,"isEditable",{enumerable:!0,get:function(){return u}}),_e.hideKeyboard=s,_e.installKeyboardHide=f,_e.useTyping=function(){const[e,n]=t.default.useState(c);return t.default.useEffect(()=>{if(!o)return;f();const e=()=>setTimeout(()=>n(c()),0);return document.addEventListener('focusin',e,!0),document.addEventListener('focusout',e,!0),()=>{document.removeEventListener('focusin',e,!0),document.removeEventListener('focusout',e,!0)}},[]),e},_e.useVisibleArea=function(){const e=o?window.visualViewport:null,n=()=>e?{height:Math.round(e.height),top:Math.round(e.offsetTop)}:null,[u,c]=t.default.useState(n);return t.default.useEffect(()=>{if(!e)return;const t=()=>c(e=>{const t=n();return e&&t&&e.height===t.height&&e.top===t.top?e:t});return e.addEventListener('resize',t),e.addEventListener('scroll',t),()=>{e.removeEventListener('resize',t),e.removeEventListener('scroll',t)}},[]),u};var t=e(r(d[0])),n=e(r(d[1]));r(d[2]);const o='undefined'!=typeof document,u=e=>!!e&&'function'==typeof e.matches&&e.matches("input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]"),c=()=>!!o&&u(document.activeElement);function s(){try{n.default.dismiss()}catch{}o&&u(document.activeElement)&&document.activeElement.blur()}function a(){if(!o)return;const e=document.activeElement;if(u(e))try{e.scrollIntoView({block:'nearest',inline:'nearest'})}catch{}}let l=!1;function f(){o&&!l&&(l=!0,document.addEventListener('click',e=>{if(!c())return;const t=document.activeElement;if('function'!=typeof t.closest||!t.closest('[aria-modal="true"], [role="dialog"]'))return;const n=e.target;n&&!u(n)&&('function'==typeof n.closest&&n.closest('label, [data-keep-keyboard]')||s())},!0),document.addEventListener('focusin',e=>{u(e.target)&&setTimeout(a,300)},!0),window.visualViewport?.addEventListener('resize',()=>setTimeout(a,50)))}},830,[34,376,236]); -__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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 O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:u,phone:g,email:m})=>{const p=t(),b=p.basket,f=b.restaurantId,k=w(b,p.menu,p.customer.allergies),I=k.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,h=$(p.orders.filter(e=>e.restaurantId===f).map(e=>e.ref),S?'Q-':'T-',S?p.counters.table:p.counters.order),O=u?n(o,f,I+i):0,C=I+i,v={id:(0,y.uuid)(),ref:`${S?'Q':'T'}-${h}`,restaurantId:f,customerId:p.customer.id,customerName:p.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:k,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:u?C:0,status:'new',createdAt:a().toISOString(),allergies:p.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:g??p.customer.phone,email:m??p.customer.email}:{}};e(e=>({orders:[v,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:h}:{...e.counters,order:h}}));const A=k.filter(e=>e.overridden);return r(f,'order',`Order ${v.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${A.length?` \u2014 ALLERGY OVERRIDE on ${A.map(e=>e.name).join(', ')}`:''}`),v.allergies.length&&r(f,'allergy',`Allergies declared and confirmed by customer on ${v.ref}: ${v.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),c(v),v},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); +__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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,choiceIds:s.map(e=>e.id)}]})}const O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:n,tip:s,notes:i,phone:o,email:l,customerName:u})=>{const g=t(),m=g.basket,p=m.restaurantId,b=w(m,g.menu,g.customer.allergies),f=b.reduce((e,t)=>e+t.unitPrice*t.qty,0),k='table'===m.mode,I=$(g.orders.filter(e=>e.restaurantId===p).map(e=>e.ref),k?'Q-':'T-',k?g.counters.table:g.counters.order),S=!k,h=f+(S?0:s),O=(u??'').trim()||g.customer.name,C={id:(0,y.uuid)(),ref:`${k?'Q':'T'}-${I}`,restaurantId:p,customerId:g.customer.id,customerName:O,type:m.mode,tableNo:m.tableNo,slotTime:n,lines:b,subtotal:f,tip:S?0:s,giftCardApplied:0,giftCardCode:void 0,total:h,paid:0,status:S?'awaiting_payment':'new',createdAt:a().toISOString(),allergies:g.customer.allergies,readiness:{},notes:i,channel:'app',...'takeaway'===m.mode?{phone:o??g.customer.phone,email:l??g.customer.email}:{}};e(e=>({orders:[C,...e.orders],basket:{...e.basket,lines:[]},counters:k?{...e.counters,table:I}:{...e.counters,order:I}}));const v=b.filter(e=>e.overridden);return r(p,'order',`Order ${C.ref} placed (${k?`Table ${m.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),C.allergies.length&&r(p,'allergy',`Allergies declared and confirmed by customer on ${C.ref}: ${C.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),'awaiting_payment'!==C.status&&c(C),C},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WILDINGS_LOCATION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WILDINGS_ADDRESS",{enumerable:!0,get:function(){return t}}),e.withWildingsAddress=function(r){return'wildings'===r.id?{...r,location:n,address:t}:r},e.withWildingsQuestionnaireAddress=function(n,r){return'wildings'===n&&r?{...r,venue:{...r.venue,address:t}}:r};const n='Maidens, KA26 9NR',t='Maidens Road, Maidens, KA26 9NR'},832,[]); __d(function(g,r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sampleFingerprint=i,e.stripOwnerLiveSamples=function(n){const a={};for(const[s,o]of Object.entries(t.OWNER_SAMPLE_HASHES)){const t=n[s]||[];a[s]=t.filter(t=>!o.includes(i(t)))}a.chat=(n.chat||[]).filter(t=>!(0,s.isSeedChefChat)(t));const o=(n.changeRequests||[]).length-a.changeRequests.length;o&&(a.changesUsed=Math.max(0,(n.changesUsed||0)-o));return a},e.stripCoreLiveSamples=function(a){const c={...(0,n.stripCoreChefSamples)(a)};c.giftCards=(a.giftCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.giftCards.includes(i(s))),c.stampCards=(a.stampCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.stampCards.includes(i(s))),c.ratings=(a.ratings||[]).filter(t=>!(/^rt-[123]$/.test(t.id)&&(0,s.demoActor)(t.customerName))),i(a.customer)===t.LEGACY_CUSTOMER_HASH&&(c.customer={...a.customer,id:'',name:'',email:'',phone:'',allergies:[],allergyConsent:!1,referralCode:'',marketingOptIn:{}});return c.restaurants=(a.restaurants||[]).filter(t=>!('saltmarsh'===t.id&&['The Venue','Saltmarsh Bistro'].includes(t.name))),c.menu=(c.menu||a.menu||[]).filter(t=>'saltmarsh'!==t.restaurantId).map(t=>t.signOff?t:o(t)),c};var t=r(d[0]),s=r(d[1]),n=r(d[2]);const a=t=>Array.isArray(t)?t.map(a):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&'function'!=typeof t).sort(([t],[s])=>ts?1:0).map(([t,s])=>[t,a(s)])):t;function i(t){const s=JSON.stringify(a(t))??"null";let n=2166136261;for(let t=0;t>>0).toString(16)}const o=t=>Array.isArray(t)?t.map(o):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).map(([t,s])=>[t,'allergenNotes'===t&&'string'==typeof s&&/\(example\)/i.test(s)?'':o(s)])):t},833,[834,835,836]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"OWNER_SAMPLE_HASHES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CORE_SAMPLE_HASHES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"LEGACY_CUSTOMER_HASH",{enumerable:!0,get:function(){return b}});const c={referrals:["43f09bc0","c438fbad","96bf8c62","3399d421"],coats:["f51097ad","2f7efa3a"],merch:["ef6e14e","dbbc0999","dc233c1d"],merchOrders:["13b15512","bc27f242"],offers:["ad0fcde0","59e6c0cf"],photos:["53a60fd9","ab778a74","95de43cd"],changeRequests:["81c5be12","6819542c"],lost:["5bbf0d77","7d3aa9ed","850c049e"],campaigns:["9cdf8346","82150e7"],suppliers:["41df06e7","466e32ac","fa3d8eea","dfafa674","1e26fbd0","c195b120","5fc49e74","6aa8b0af","602fc2e4"],supplierOrders:["22636226","464d6a6a"]},f={giftCards:["b1bba36d","f029bc0e"],stampCards:["e7bedf6f","a3c8404d"]},b="4b1e9971"},834,[]); @@ -1067,546 +1067,549 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},984,[835]); __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 t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(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 u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{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}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},985,[984]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},986,[872,34,102,987,2,821,794,25]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return W.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return W.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return W.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return W.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return W.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return I.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return I.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return It}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ne.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ne.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ne.useOwner.getState().chatSeen(t,e)),Ft(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ne.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...St(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(le.PITCH)return pe.unlockCashUp(e,t,a);const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?oe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):oe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(le.PITCH)return pe.cashAudit(e);const t=Oe.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(ma.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=fa,i.readAccessLog=async function(){const e=Oe.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Oe.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return pa}}),i.uploadOrderLogo=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(pa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ga.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(pa).createSignedUrl(e,3600);if(t?.signedUrl)return ga.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(pa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return ma}}),i.claimInvite=Da,i.makeChromeHandover=async function(){const e=Oe.getState();if(le.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ue});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(le.PITCH||!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ue});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),Pe&&xa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Te();const t=await x.kv.get(ka,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Te(),await x.kv.get(Ia,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_WILDINGS||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Te(),await x.kv.remove(ka),await x.kv.remove(Ia),Ae({mode:'signin',perms:[]});try{await Ma()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Oe.getState().venueId;if(le.PITCH||!s||'staff'!==Oe.getState().kind)return{ok:!0};if(!(0,ie.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ka('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Da(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(le.PITCH)return pe.reissueInvite(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ka('staff_app_link_history',{p_venue:Oe.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ka('revoke_staff_app_link',{p_venue:Oe.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(le.PITCH)return pe.linkPhones();const e=Oe.getState().venueId;if(!e||'staff'!==Oe.getState().kind)return{};try{const t=await Ka('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(le.PITCH)return pe.resetPhone(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ka('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(le.PITCH)return pe.inviteStatus();const e=Oe.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:t,error:a}=await Re().rpc(o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_pairing_code':o.IS_GREENSIDE?'claim_greenside_pairing_code':o.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':o.IS_KIRKTON?'claim_kirkton_pairing_code':o.IS_WILDINGS?'claim_wildings_pairing_code':o.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':o.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await x.kv.set(ba,n),xa(),{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}`}}},i.carPairStart=async function(){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await x.kv.set(Ua,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ea(e)}}},i.carPairPoll=async function(e){try{Te();const t=e??await x.kv.get(Ua,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,G.carPairApproved)(n)){const e=(0,G.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await x.kv.get(ba,null);await x.kv.set(ba,e),await x.kv.remove(ka),O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||xa()}return'revoked'!==i&&'unknown'!==i||await Ta(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Te(),await Re().rpc('car_sign_out')}catch{}await Ta(),await Ma();try{await Re().auth.signOut({scope:'local'})}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ka('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ea(e)}}},i.carList=async function(){const e=Oe.getState().venueId;if(!e)return[];return(await Ka('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ka('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ea(e)}}},i.unpairDisplay=async function(){await x.kv.remove(ba),await Ma();try{await Re().auth.signOut()}catch{}Ae({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await x.kv.remove(ka),await x.kv.remove(Ia),await Ma();try{await Re().auth.signOut()}catch{}Ae({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.'})},i.wipeThisDevice=async function(e={}){try{await Ma()}catch{}try{(0,T.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${o.VENUE_RID}:`)):(0,I.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!o.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Na,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ka}}),i.mendSession=qa,i.startAppSync=async function(e=o.VENUE_RID){if(o.IS_ISOLATED_VENUE&&e!==o.VENUE_RID)return;if(Pe)return;Pe=!0,La=e,'customer'===Ue&&'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Te(),'customer'!==Ue){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ue&&(0,h.isAnchorage)(e)?[H.useStore,ne.useOwner,ae.useKitchen,se.useSafety,Y.useCardStore,m.useGpCalc,X.useOrderSheets,S.useSpecials,A.useHr]:[H.useStore,ne.useOwner,ae.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ue&&(0,h.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ae({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await vs(e)}catch{if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e))return void Ae({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,T.isSupabaseConfigured)())return void Ae({mode:'off'});j.mutationQueue.subscribe(()=>{const e=j.mutationQueue.waiting,t=e[0];Ae({pending:j.mutationQueue.pending.length,failed:j.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,L.describeWrite)(t)}: ${(0,L.plainReason)({...t.lastErr},'retry')}`:void 0})}),j.mutationQueue.onFailed(e=>Ae({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:j.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,L.describeWrite)(e),why:'conflict'===e.reason?(0,L.plainReason)({code:'conflict'},'refused'):(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Ke.push((0,N.onConnectivity)(e=>Ae({mode:e?Oe.getState().venueId?'live':Oe.getState().mode:Oe.getState().venueId?'offline':Oe.getState().mode}))),await Ba()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return za}}),i.stockSaveBlocker=Za,i.stockEventStatus=function(e){if(ze(e))return{state:'saved'};const t=j.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,L.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=Ya,i.saveStockEventsNow=Xa,i.bookingSaveBlocker=ts,i.resendUnsavedBookings=ns,i.saveBookingsNow=is,i.waitForBookingSave=function(e,t=12e3){if(!De())return Promise.resolve({state:'local'});const a=ts();if(a)return Promise.resolve({state:'refused',why:a});const s=as()[0]?.venueId??'',n=()=>es.some(t=>j.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=F.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,N.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(j.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(j.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||as().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||as().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=cs,i.tempLogState=function(){const e=ls()[0]?.venueId??'',t=ls().find(e=>'temp_readings'===e.spec.table),a=j.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!j.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values($.useTempSaves.getState().notSaved),i=se.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=fs,i.waitForTempSave=function(e,t,a=1e4){if(!De()||!ls().length)return Promise.resolve({state:'local'});const s=cs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ls()[0]?.venueId??'',i=ls().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>$.useTempSaves.getState().notSaved[(0,$.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>j.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=_s,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ts}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Es.get(a);if('customer'!==Ue||!(0,T.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Es.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ka('public_day',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:qe(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:qe(a.from_time),to:qe(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Es.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ts.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Es.get(a);e&&!e.ok&&Es.delete(a)}));const n=Es.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Oe.getState().venueId;if(!n||'staff'!==Oe.getState().kind)throw new Error('Connect to your venue first.');const i=await Ka('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});H.useStore.getState().updateRestaurant(e,{...i,id:e})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(fe),ge=t(r[60]),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]);const Re=()=>(0,E.getSupabase)();j.mutationQueue.setExecutor(q.executeMutation),(0,P.setClockServer)(()=>'staff'===Oe.getState().kind);const Oe=(0,U.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ae=e=>Oe.setState(e),Ce=e=>{const t=Oe.getState().perms;return t.includes('*')||t.includes(e)},De=()=>{const e=Oe.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Oe.subscribe(()=>(0,ve.setLiveData)(De()));let Ue=V.IS_CAR?'car':V.APP_VARIANT,Ee=!1;const Te=()=>{Ee||((0,x.setSyncNamespace)(Ue),Ee=!0)};let Ne=[],Ke=[],Pe=!1;const Me=()=>(new Date).toISOString().slice(0,10),xe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),qe=e=>e?e.slice(0,5):'',Le=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))):[],Be=e=>JSON.parse(JSON.stringify(e));function je(e,t){const a=xe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>H.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Be(e);if(t)return{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:Le(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,ie.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:Le(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Fe(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>H.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.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,ie.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Be(e.lines??[]),allergies:Le(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:Be(e.allergyChain??{}),readiness:Be(e.readiness??{}),allergy_ticks:Be(e.allergyTicks??{}),handover_check:e.handoverCheck?Be(e.handoverCheck):null,accepted:e.accepted?Be(e.accepted):null,doc:Be(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)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function $e(e){const t=xe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...J.useBlocks.getState().blocks,...J.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Oe.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:Be(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,J.blockClock)(t.from_time)??a?.from,n=(0,J.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>J.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>J.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let We=null,Qe='Main plan';function He(e){const t=e=>Be({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(z.useFloor.getState().plans[e]??(0,z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Ce('floor.manage')||Ce('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:We??(0,be.uuidFrom)(`plan:${a}`),venue_id:a,name:Qe||'Main plan',is_active:!0,...t(e),updated_by:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>(We=String(e.id),Qe=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,ke.withSeedBest)(e,t[0]):void 0;a&&z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ve(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Z.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Ce('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,ie.isUuid)(e.supplierId)?e.supplierId:(0,be.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),ot.get(t)??t)}:{}};var t},apply:(t,a)=>Z.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Ge=new Set,Je=new Set;j.mutationQueue.onDone(e=>{'stock_events'===e.table&&Je.add(e.rowKey)});const ze=e=>Je.has(e)||Ge.has(e),Ze=()=>Ce('*')||Ce('staff.manage')||Ce('recipes.edit')||Ce('recipes.signoff'),Ye=()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write'));function Xe(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Z.useShellStore.getState().events.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,ie.isUuid)(t.id)&&!!(Z.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('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,ie.isUuid)(e.undoes)&&(ze(e.undoes)||j.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Ge.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)=>Z.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function et(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Z.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={...Z.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Z.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Ge]}}}))},afterRead:()=>{Z.useShellStore.getState().server[e]||Z.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Ge]}}}))},subscribe:()=>()=>{}}}const tt=new Set;function at(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=H.useStore.getState().menu;return Y.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:t=>(0,ie.isUuid)(t.card.id)&&!((0,h.isAnchorage)(e)&&(0,h.isDemoCard)(t.card))&&!(0,h.isPlaceholderCard)(t.card),writable:()=>Ce('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,h.isAnchorage)(e)&&(s={...s,signOff:(0,h.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,h.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,h.isAnchorage)(e)&&(0,h.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,be.photoPath)(a,s),t=st(s.photo);t&&((0,Y.cachePhotoAs)(e,t),nt(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,be.cardToRow)(s,a);return{...i,...r,doc:Be({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,h.isPlaceholderCard)(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,signOff:(0,h.isAnchorage)(e)&&(0,h.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Ce('recipes.edit')&&t.length){const e=new Set(t);Y.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);Y.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&H.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&H.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=Y.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=H.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const st=e=>(0,Y.readLocalPhoto)(e);async function nt(e,t){if(!tt.has(e)){tt.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(be.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){tt.delete(e),Ae({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const it=new Map,rt=(0,U.create)(()=>({n:0}));(0,Y.setStoragePhotoResolver)(e=>{const t=it.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,T.isSupabaseConfigured)()&&'off'!==Oe.getState().mode?(t||(it.set(e,{url:'',at:Date.now()}),Re().storage.from(be.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(it.set(e,{url:t.signedUrl,at:Date.now()}),rt.setState(e=>({n:e.n+1})),Y.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const ot=new Map;const dt=(e,t)=>{const a=(0,ie.isUuid)(t)?t:(0,be.uuidFrom)(`sup:${e}:${t}`);return ot.set(a,t),a};function ut(e){return{name:'order_sheets',table:'suppliers',list:()=>X.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,h.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Ce('suppliers.manage'),toRow:(e,t)=>({id:dt(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:Be(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(ot.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>X.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>X.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,ie.isUuid)(e)?e:(0,be.uuidFrom)(`sup:${Oe.getState().venueId}:${e}`)})}}let ct=!1,lt=!1;const ft=new Map,pt=new Map,gt=new Map,mt=new Map,_t=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',St=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'},ht=(e,t)=>({...e,managerAccess:t}),yt=()=>({nickname:ct,display:lt}),wt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=ht({role:e.role,level:e.level??St(_t(e)).level},!0===e.managerAccess);return(0,B.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},yt())};const vt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},bt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},kt=e=>{const t=ne.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,d.isKitchenTeam)(t)},It=2e3;function Rt(e,t){return t||!e.length||e.length>=It?null:e=>(0,ie.isUuid)(e.id)}function Ot(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,Ce('rota.manage')):null,keepOnEmpty:()=>e&&!Ce('rota.manage'),list:()=>ne.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&ft.has(e.staffId)&&(Ce('rota.manage')||kt(e.staffId)),writable:()=>Ce('rota.manage')||Ce('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(vt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:bt(e.start),end_time:bt(e.end),published:!!e.published,doc:Be(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function At(){const e=xe(62),t=e=>Ce('rota.manage')||e.staffId===Oe.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ne.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&t(e),writable:()=>'staff'===Oe.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=xe(2)&&e.staffId===Oe.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Be(e.breaks??[]),break_mins:e.breakMins??0,doc:Be((0,y.privateAttendance)(o.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,y.privateAttendance)(o.VENUE_RID,{...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Ct(){const e=xe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.staffId===Oe.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Oe.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:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,ie.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:Be({...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Dt(e){ne.leaveRemote.decide=t=>!(!Ce('rota.manage')||!(0,ie.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(j.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Ke.push(()=>{ne.leaveRemote.decide=null})}function Ut(e){ne.timesheetRemote.send=(t,a)=>{if(!Ce('rota.manage')||!(0,ie.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return j.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:Be(s)}}),!0}const s=a;if('attendance_void'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return j.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:Be(s.breaks??[]),p_reason:n,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0},Ke.push(()=>{ne.timesheetRemote.send=null})}function Et(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>H.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Oe.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,ie.isUuid)(a)?a:(0,be.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,ie.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Be(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>H.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=>H.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Tt=e=>H.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Nt(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}));H.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Kt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=H.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Be({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Tt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Ce('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Mt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...Mt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Mt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Pt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Pt=t.feature_flags??{},Mt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Be({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}:{}})},apply:t=>{const a=t[0];a&&(H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,l.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Nt(e,a.events))},subscribe:e=>{const t=H.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Pt=null,Mt=null;const xt=()=>new Date(Date.now()-2592e6).toISOString(),qt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ft.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Lt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?(0,Se.dmId)(t[0],t[1]):null},Bt=()=>Oe.getState().perms.includes('*');function jt(){const e=()=>Oe.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ne.useOwner.getState().chat.filter(e=>(0,ie.isUuid)(e.id)).map(e=>Be({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=>!!qt(t.ch)&&(t.from===e()||Bt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('created_at',xt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=xt(),toRow:(e,t)=>{const a=qt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ft.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=Lt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?pt.get(String(e.from_staff)):'system';return s?Be({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ne.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?pt.get(String(t.from_staff)):'system',i=Lt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ne.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,Se.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,he.soundAllowed)())try{(0,he.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,b.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Ft(e,t,a){const s=Oe.getState();if(!_e.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ft.get(e),i='*'===t?'*':qt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function $t(e){const t=Oe.getState().staffRef,a=t?ft.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Lt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ne.useOwner.getState().chatMarkRead(t,i)}catch{}}function Wt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=C.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Be(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>C.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,D.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Qt(e){const t=xe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>C.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.reminderId)&&e.staffRef===Oe.getState().staffRef,writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>C.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Ht(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Vt=e=>null==e||''===e?null:Number(e),Gt=e=>e.filter(e=>!e.startsWith('data:')),Jt=()=>Ce('takings.view');function zt(e){const t=!Jt();return{name:'cash_ups',table:'cash_ups',list:()=>oe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,v.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,v.tradingDay)()&&!e.onServer),writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,v.tradingDay)()):e.gte('for_date',xe(400)),...t?{inWindow:e=>e.date===(0,v.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:Be(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({cashUps:Ht(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Zt(e){return{name:'sales_reports',table:'sales_reports',list:()=>oe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Be(e.vals),categories:e.categories,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({sales:Ht(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Yt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=oe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,oe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Be({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,oe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>oe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function Xt(e){return{name:'day_tips',table:'day_tips',list:()=>oe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',xe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>oe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ea(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>oe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Vt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>oe.useCashUp.setState(s=>({pot:Ht(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function ta(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=oe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Ce('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>oe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function aa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>re.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Be(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>re.useNotifs.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>re.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function sa(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=de.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Be(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>de.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ue.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Ht(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function na(e){const t=()=>Ce('venue.settings')||Ce('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>de.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,ie.isUuid)(a.id)&&(0,ie.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,de.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Oe.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Oe.getState().staffRef)||null,doc:Be(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ia(e){const t=xe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>de.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Be(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({history:Ht(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function ra(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=ce.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Be(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&ce.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,y.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>ce.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function oa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=ge.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,ge.libraryRowId)(e),kind:'library',doc:Be({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,ge.personRowId)(e,i),kind:'person',staffRef:i,doc:Be({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ne.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,me.canEditTasks)(t,a)},writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>ge.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,ge.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function da(e){const t=xe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>ge.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Oe.getState();return e.byRef===t.staffRef||Ce('staff.manage')},writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>ge.useDailyTasks.setState(s=>({ticks:Ht(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ua(e,t=!1){const a=xe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>ye.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind||Ce('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,be.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>ye.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>ye.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{we.autoSync.soldOutRead.add(e)}}}function ca(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>we.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:(0,be.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>we.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>we.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{we.autoSync.linksRead.add(e)}}}async function la(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&x.kv.get(a,!1):(x.kv.set(a,!0),!0)}catch{return x.kv.get(a,!1)}}async function fa(){const e=Oe.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();ma.setState({live:!!t?.push_live,known:!0})}catch{}}const pa='order-list-logos';const ga=new Map;const ma=(0,U.create)(()=>({live:!1,known:!1}));async function _a(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('reminders:ok',!1):(x.kv.set('reminders:ok',!0),!0)}catch{return x.kv.get('reminders:ok',!1)}}async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('chat:ok',!1):(x.kv.set('chat:ok',!0),!0)}catch{return x.kv.get('chat:ok',!1)}}const ha=(e,t)=>Be({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),ya='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function wa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>A.useHr.getState().questions.filter(t=>t.venue===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ha(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);A.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>A.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function va(e,t){const a=(t,a,s)=>{j.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(A.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(ya).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||A.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ha(e,t)))}catch{}}}),Ke.push(()=>{Object.assign(A.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ba='pair:v1',ka='staff:v1',Ia='staff:rejoin:v1';async function Ra(e){const t=o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_invite':o.IS_GREENSIDE?'claim_greenside_invite':o.IS_ABBOTSFORD?'claim_abbotsford_invite':o.IS_KIRKTON?'claim_kirkton_invite':o.IS_WILDINGS?'claim_wildings_invite':o.IS_KIRKMICHAEL?'claim_kirkmichael_invite':o.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ue,p_device:(0,O.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,O.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Oa(){if('display'===Ue||'customer'===Ue||le.PITCH)return'none';const e=await x.kv.get(Ia,null);if(!e)return'none';try{await Ca();const{data:t,error:a}=await Ra(e);if(a)return(0,I.inviteRefusal)(a.message)?(await x.kv.remove(Ia),await x.kv.remove(ka),'refused'):'offline';const s=t?.[0];return s?(await x.kv.set(ka,{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,displayName:s.display_name}),'ok'):(await x.kv.remove(Ia),'refused')}catch{return'offline'}}const Aa=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Ca(){Te();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ae({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 Da(e){if(le.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,I.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Ra(e);if(a){const e=(0,I.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,o.venueKey)(`cc-pending-invite:${Ue}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),await x.kv.set(Ia,e),Pe&&xa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ae({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ua='car:request:v1',Ea=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Ta(){await x.kv.remove(ba),await x.kv.remove(ka),await x.kv.remove(Ua),O.useSession.getState().meId&&O.useSession.getState().signOut()}async function Na(){if(!(0,T.isSupabaseConfigured)())return!1;try{return await Ca(),!0}catch{return!1}}const Ka=async(e,t={})=>{if(le.PITCH)return(0,fe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Pa=null;async function Ma(){for(const e of Ke)try{e()}catch{}Ke=[],Ne.forEach(e=>e.stop()),Ne=[],Pa&&(clearInterval(Pa),Pa=null)}async function xa(){await Ma(),await Ba()}async function qa(){if(!(0,T.isSupabaseConfigured)()||'customer'===Ue||le.PITCH)return!1;try{Te();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ue)return!1;if(!await x.kv.get(Ia,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Oa()&&(xa(),!0)}catch{return!1}}(0,u.setSessionMender)(qa);let La=o.VENUE_RID;async function Ba(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=La;try{if(Ae({mode:'connecting'}),await j.mutationQueue.load(),'customer'===Ue)return void await Ha(e);let t=await x.kv.get(ba,null),a=await x.kv.get(ka,null);if(V.IS_CAR&&!t&&a){const e=(0,G.migrateCarStaffIdentity)(a);e&&(t=e,await x.kv.set(ba,t)),await x.kv.remove(ka),a=null,O.useSession.getState().meId&&O.useSession.getState().signOut()}if(o.IS_ISOLATED_VENUE&&(t&&!(0,o.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,o.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ae({mode:'display'===Ue?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ue&&!V.IS_CAR&&a&&!s.session){const t=await Oa();if('offline'===t)return Ae({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{La===e&&xa()},6e4);'refused'===t&&a.staffRef&&O.useSession.getState().meId===a.staffRef&&O.useSession.getState().signOut(),a=await x.kv.get(ka,null),({data:s}=await Re().auth.getSession())}const n='display'===Ue||V.IS_CAR?t:a;if(!s.session||!n)return void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ka('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ue||V.IS_CAR?await x.kv.remove(ba):(await x.kv.remove(ka),await x.kv.remove(Ia)),'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId===n.staffRef&&O.useSession.getState().signOut(),void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ue?'This display was unpaired by a manager.':V.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,N.isOnline)()||/fetch|network/i.test(String(t?.message)))Ae({mode:'offline'});else if(Aa(t)&&'display'!==Ue){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Oa()&&setTimeout(()=>{La===e&&xa()},500)}i=Oe.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ae({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!V.IS_CAR&&'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId!==n.staffRef&&(O.useSession.getState().signIn(n.staffRef),ne.useOwner.setState({staffAs:n.staffRef})),V.IS_CAR&&(O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({previewRole:'owner'})),await Fa(n.venueId,e,n.kind)}catch(e){Ae({mode:'local',lastError:String(e?.message??e)})}}const ja=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','venue_reminders','reminder_done']);async function Fa(e,a,s){if(!(0,o.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||V.IS_CAR&&'device'===s;await _s(a),Ke.push(Us(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])gt.set(e.key,e.id),mt.set(e.id,e.key)}catch{}const i=[Kt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ne.useOwner.getState().staff.map(wt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Ce('staff.manage'),deletes:!1,revision:e=>(0,B.staffRevision)(e,yt()),toRow:(e,t)=>(0,B.staffRow)(e,t,yt(),e.managerAccess||e.ownerAccess?null:gt.get(_t(e))),fromRow:e=>{if(!e.external_ref)return null;ft.set(String(e.external_ref),String(e.id)),pt.set(String(e.id),String(e.external_ref)),Os.set(String(e.external_ref),e.avatar_path??null);const t=ht(St(mt.get(String(e.role_id))),!0===e.manager_access);return(0,B.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},yt())},apply:e=>ne.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=>ne.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ds()},onRemote:()=>{Ds()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ne.useOwner.getState(),t=te.useSetup.getState().sites[La]?.staffGrade??{};return e.staff.filter(e=>ft.has(e.id)).map(a=>Be({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=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ft.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=pt.get(String(e.staff_id));return t?Be({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=>ne.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=te.useSetup.getState().sites[La],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&&te.useSetup.getState().patch(La,{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=ne.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=te.useSetup.subscribe((t,a)=>{t.sites[La]?.staffGrade!==a.sites[La]?.staffGrade&&e()});return()=>{t(),a()}}},je(a,!1),je(a,!0),$e(a),He(a),Fe(a),Ve(a),Xe(a),et(a),ut(a),{name:'supplier_directory',table:'suppliers',list:()=>ne.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('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:Be(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ne.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId),writable:()=>Ce('suppliers.order')||Ce('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||Me(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Be(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},at(a),ks(a)];Ce('wages.view')&&i.push(Is(a)),n&&(i.push(Ot(!0),At(),Ct(),Et(a)),Ut(e)),n&&await la('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Oe.getState().staffRef&&'pending'===e.status||Ce('rota.manage')),writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Be(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),ja.add('staff_leave'),Dt(e));const d=n&&await Sa();if(_e.useChatSync.setState({synced:d,checked:!0}),Ke.push(()=>_e.useChatSync.setState({synced:!1})),d&&i.push(jt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(Se.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ft.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ft.get(e.id),include:e.include}),fromRow:e=>{const t=pt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>Se.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=>Se.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await la('hr_questions')&&(i.push(wa(a)),ja.add('hr_questions'),va(e,a)),'guest'!==s&&'customer'!==Ue&&await la('temp_readings')&&(i.push((0,W.tempUnitsSpec)(se.useSafety,Ze),(0,W.tempReadingsSpec)(se.useSafety,Ye)),ja.add('temp_units'),ja.add('temp_readings')),'guest'!==s&&await la('sold_out_items')?(i.push(ua(a,await la('sold_out_items','auto'))),ja.add('sold_out_items')):we.autoSync.soldOutRead.add(a),'guest'!==s&&await la('sold_out_links')?(i.push(ca(a)),ja.add('sold_out_links')):we.autoSync.linksRead.add(a),C.useReminders.getState().ensure(a),'guest'!==s&&await _a()&&(i.push(Wt(a)),n&&i.push(Qt(a))),re.useNotifs.getState().ensure(a),de.useOrderLists.getState().ensure(a),n){ct=await la('staff','nickname'),lt=await la('staff','display_clock');const[e,t,s,n]=await Promise.all([la('scheduled_notifications'),la('order_lists'),la('venue_clock_area'),la('daily_tasks')]);ge.useDailyTasks.getState().ensure(a),n&&(i.push(oa(a),da(a)),ja.add('daily_tasks'),ja.add('daily_task_ticks')),e&&(i.push(aa(a)),fa()),t&&i.push(sa(a),na(a),ia(a)),s&&i.push(ra(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&ja.add(n)}if('guest'!==s&&await la('day_tips')){i.push(Xt(a));for(const e of['day_tips','tips_pot_events','tips_settings'])ja.add(e);await la('tips_pot_events')&&i.push(ea(a),ta(a)),n&&(Jt()||(0,oe.forgetPastTakings)(a,(0,v.tradingDay)()),i.push(zt(a),Yt(a)),ja.add('cash_ups'),Jt()&&(i.push(Zt(a)),ja.add('sales_reports')),t(r[72])(r[71],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Ot(),At()),await la('scheduled_notifications')&&i.push(aa(a)));let u=!1;const c=()=>{if(V.IS_CAR&&n&&Ce('recipes.edit'))return!0;const e=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);return!!e&&e.active&&Ce('recipes.edit')&&(0,_.costsAllowedFor)(e)};n&&c()&&await la('ingredient_prices')&&(i.push((0,m.gpSyncSpec)('ing',c)),ja.add('ingredient_prices'),await la('card_costs')&&(i.push((0,m.gpSyncSpec)('card',c)),ja.add('card_costs')),await la('kitchen_deliveries')&&(i.push((0,m.gpSyncSpec)('del',c)),ja.add('kitchen_deliveries')),await la('kitchen_stock_counts')&&(i.push((0,m.gpSyncSpec)('count',c)),ja.add('kitchen_stock_counts'))),(0,Ie.specialsSyncOn)()&&'guest'!==s&&await la('specials_boards')&&(i.push((0,Ie.specialsBoardSpec)(a,()=>Ce('recipes.edit')||Ce('floor.manage')||Ce('*'))),ja.add('specials_boards'));const l={onActivity:()=>Ae({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ae({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ae({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Ka('whoami')??[]).some(t=>t.venue_id===e))return void(La===a&&xa());for(const a of Ne){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||F.useBookingSaves.getState().mark({id:t,table:e,why:ts()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||$.useTempSaves.getState().mark({id:t,table:e,why:cs(e)??'this screen could not send it'})}};Ne=i.map(t=>new Q.EntityBridge(t,e,l)),await Promise.all(Ne.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,N.isOnline)())try{const t=await Ka('whoami');if(!t?.some(t=>t.venue_id===e))return void(La===a&&xa())}catch(e){if(Aa(e)){if(V.IS_CAR)return void(La===a&&xa());const e=await Oa();return void('ok'!==e&&'refused'!==e||La===a&&xa())}}let t=0;for(const[a,s]of Ne.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(_e.useChatSync.getState().error&&_e.useChatSync.setState({error:void 0}),await $t(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&_e.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({mode:'live',lastSyncAt:e,lastServerAt:e}),j.mutationQueue.flush()}else Ae({mode:'offline'});if(!Ce('wages.view')){const e=Oe.getState().staffRef;ne.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const S=new Map;for(const e of Ne)S.set(e.spec.table,[...S.get(e.spec.table)??[],e]);const h=[...S.keys()].filter(e=>ja.has(e)).map(e=>({table:e,venueColumn:S.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,Q.venueChannel)(e,h,(e,t,a)=>{for(const s of S.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ae({lastSyncAt:s,lastServerAt:s})},e=>{Ae({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Ke.push(()=>{Re().removeChannel(w)}),Ke.push((0,N.onConnectivity)(e=>{e&&p()}));const b=Ne.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,K.superviseSync)({fastMs:Wa(Ue),readFast:async()=>{for(const e of b)await e.read()},readAll:p,flush:()=>{j.mutationQueue.flush()},wake:()=>{j.mutationQueue.retryNow()},restart:()=>{La===a&&xa()},realtime:()=>Oe.getState().realtime,lastServerAt:()=>{const e=Oe.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Aa,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>$a(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Ke.push(k.stop)}async function $a(e){const t=Oe.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ka('sync_heartbeat',{p_venue:e,p_device:(0,O.deviceId)()??'unknown',p_app:Ue,p_version:M.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Wa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Oe.getState(),queue:j.mutationQueue.pending.map(e=>e.table),failedTables:j.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),le.PITCH&&(window.__ccSyncPreview=e=>Ae(e)));const Qa='guest:sent:v1';async function Ha(e){Ae({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ka('public_venue',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!o.IS_ISOLATED_VENUE||t.id===o.VENUE_UUID)){Ae({venueId:t.id,venueName:t.name}),await _s(e);const a=t.app?.restaurant;a&&H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,l.withWildingsAddress)({...a,id:e}):t)})),Nt(e,t.app?.events)}await Va(e),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ae({mode:(0,N.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Va(e).catch(()=>{})},6e4);Ke.push(()=>clearInterval(t)),o.IS_ISOLATED_VENUE||await Ga(e)}async function Va(e){const t=await Ka('public_menu',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));Y.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&H.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))]}})}async function Ga(e){let t=await x.kv.get(Qa,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=H.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Na())return;for(const a of n)try{const s=(await Ka('guest_create_booking',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_booking:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(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&&H.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'},Ae({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ka('guest_create_takeaway',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_order:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ae({lastError:`Order: ${e?.message}`}))}await x.kv.set(Qa,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ka('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await x.kv.set(Qa,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ka('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));H.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 Ja(n)===Ja(e)?e:n})})),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ae({mode:(0,N.isOnline)()?Oe.getState().mode:'offline'})}finally{a=!1}}};Ke.push(H.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Pa=setInterval(()=>{n()},15e3),n()}const Ja=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),za={bridges:()=>Ne,restart:xa};function Za(){const e=Oe.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Ce('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function Ya(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(!e||Za())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(j.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function Xa(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}Ya();try{await j.mutationQueue.retryNow()}catch{}}Oe.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{Xa()},3e3)});const es=['bookings','walk_ins'];function ts(){const e=Oe.getState();return De()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const as=()=>Ne.filter(e=>es.includes(e.spec.table)),ss=e=>j.mutationQueue.failed.some(t=>es.includes(t.table)&&t.rowKey===e);function ns(e=!1){return ts()?0:as().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ss(t)&&!!F.useBookingSaves.getState().notSaved[t]),0)}async function is(e=!1){const t=ts();if(t)return t;for(const e of as())try{await e.read()}catch{}ns(e);try{await j.mutationQueue.retryNow()}catch{}return e&&rs(),null}function rs(){const e=as()[0]?.venueId??'',t=F.useBookingSaves.getState(),a=new Set(as().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ss(s)||es.some(t=>j.mutationQueue.hasPending(t,e,s))||t.clear(s)}j.mutationQueue.onFailed(e=>{es.includes(e.table)&&F.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{es.includes(e.table)&&F.useBookingSaves.getState().clear(e.rowKey)});let os=null;const ds=(e=2500)=>{os&&clearTimeout(os),os=setTimeout(()=>{os=null,is(!1)},e)};(0,N.onConnectivity)(e=>{e&&ds()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ds(3e3)});const us=['temp_readings','temp_units'];function cs(e="temp_readings"){const t=Oe.getState();return De()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ze()?'device'!==t.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ls=()=>Ne.filter(e=>us.includes(e.spec.table));async function fs(e=!1){const t=cs();if(t)return t;for(const e of ls())try{await e.read()}catch{}const a=ls()[0]?.venueId??'';for(const t of ls())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,j.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await j.mutationQueue.retryNow()}catch{}if(e){const e=$.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ls().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||j.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,$.tempKey)(t.table,t.id))}}return null}j.mutationQueue.onFailed(e=>{us.includes(e.table)&&$.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{us.includes(e.table)&&$.useTempSaves.getState().clear((0,$.tempKey)(e.table,e.rowKey))});let ps=null;const gs=(e=3e3)=>{ps&&clearTimeout(ps),ps=setTimeout(()=>{ps=null,fs(!1)},e)};(0,N.onConnectivity)(e=>{e&&gs()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&gs(3500)});const ms='golive:v1:';async function _s(e){'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)?await vs(e):(await x.kv.get(ms+e,!1)||await vs(e),await x.kv.get(ys+e,!1)||(ws(e),await x.kv.set(ys+e,!0)),await x.kv.get(Ss+e,!1)||(hs(),await x.kv.set(Ss+e,!0)))}const Ss='golive:v3:';function hs(){const e=e=>JSON.stringify(e).includes('(example)');try{ae.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ys='golive:v2:';function ws(e){const t=e=>JSON.stringify(e).includes('(example)');H.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)))})),ne.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 vs(e){if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)){const t=(0,p.stripCoreLiveSamples)(H.useStore.getState()),a=(0,ae.stripKitchenExamples)(ae.useKitchen.getState()),s=ne.useOwner.getState(),n=(0,p.stripOwnerLiveSamples)(s),i={accidents:se.useSafety.getState().accidents.filter(e=>!(0,se.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(H.useStore.getState(),t)&&(await(0,g.archiveChefCache)('core',H.useStore.getState()),H.useStore.setState(t)),r(ae.useKitchen.getState(),a)&&(await(0,g.archiveChefCache)('kitchen',ae.useKitchen.getState()),ae.useKitchen.setState(a)),r(s,n)&&(await(0,g.archiveChefCache)('owner',s),ne.useOwner.setState(n)),r(se.useSafety.getState(),i)&&(await(0,g.archiveChefCache)('safety',se.useSafety.getState()),se.useSafety.setState(i));const o=(0,A.stripHrSamples)(A.useHr.getState());r(A.useHr.getState(),o)&&(await(0,g.archiveChefCache)('hr',A.useHr.getState()),A.useHr.setState(o));const d=(0,m.stripGpSamples)(m.useGpCalc.getState());r(m.useGpCalc.getState(),d)&&(await(0,g.archiveChefCache)('gp',m.useGpCalc.getState()),m.useGpCalc.setState(d));const u=X.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,g.archiveChefCache)('order-sheets',u),X.useOrderSheets.setState(c));const l=Y.useCardStore.getState(),_={cards:l.cards.filter(e=>!(0,f.isLiveVenue)(e.restaurantId)||!(0,h.isDemoCard)(e)),log:l.log.filter(e=>!(0,h.demoActor)(e.by))};return r(l,_)&&(await(0,g.archiveChefCache)('recipe-cards',l),Y.useCardStore.setState(_)),void await x.kv.set(ms+e,!0)}const t=t=>t.restaurantId===e&&!(0,ie.isUuid)(t.id);H.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)))})),J.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,ie.isUuid)(t.id))})),z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ne.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,ie.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,ie.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,ie.isUuid)(e.id)),leave:e.leave.filter(e=>(0,ie.isUuid)(e.id)),swaps:[]}));try{ae.useKitchen.setState(e=>(0,ae.stripKitchenExamples)(e))}catch{}ne.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,ie.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId))}));try{se.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await x.kv.set(ms+e,!0)}const bs=(e,t)=>Be({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function ks(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(z.useFloor.getState().live[e]??{}).map(([e,t])=>bs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Oe.getState().kind||Ce('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:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>bs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>z.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=>z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Is(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(te.useSetup.getState().sites[e]?.grades??te.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:()=>Ce('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=te.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));te.useSetup.getState().patch(e,{grades:i})},subscribe:t=>te.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Rs='staff-avatars',Os=new Map;let As=!1;const Cs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ds(){if(!As){As=!0;try{for(const[e,t]of Os){const a=ee.useAvatars.getState().photos[e];if(!t){a?.path&&ee.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Oe.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Rs).download(t);if(n||!s)continue;const i=await Cs(s);i.startsWith('data:image/')&&ee.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{As=!1}}}function Us(e){const t=async()=>{const t=Oe.getState().staffRef,a=t?ft.get(t)??Oe.getState().staffUuid:void 0;if(!t||!a||'staff'!==Oe.getState().kind)return;const s=ee.useAvatars.getState().photos[t];try{const n=Os.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Rs).remove([t]).catch(()=>{})};if(!s){const e=!!ee.useAvatars.getState().clears?.[t];return e&&n&&(await Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}),Os.set(t,null),i(n)),void(e&&ee.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ae({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Rs).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ka('set_staff_avatar',{p_staff_ref:t,p_path:d}),Os.set(t,d),n!==d&&i(n),ee.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ae({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ee.useAvatars.getState().photos},s=ee.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Ce('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Oe.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Os.set(t,null),ee.useAvatars.getState().doneClear(t),Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Rs).remove([e])).catch(()=>{})}});return t(),s}const Es=new Map,Ts=(0,U.create)(()=>({n:0}))},987,[5,988,932,6,832,837,833,838,989,993,994,835,996,998,999,1000,1001,1002,13,1003,1005,1008,1009,846,933,976,1010,1011,1012,1015,977,1016,1014,1019,1013,1020,1021,1022,1023,831,872,1024,1025,1028,983,883,1030,926,927,1032,1033,891,870,1035,1038,1039,1040,1041,2,1042,1043,1044,1045,1046,1047,979,981,884,863,859,1048,1051,1052]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},989,[837,34,838,5,839,846,849,990,863,870,991,992]); -__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},990,[984]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},991,[990]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},992,[990,991]); -__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},993,[]); -__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},994,[835,837,838,5,839,846,849,995,831,884]); -__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'}}]},995,[]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},996,[6,997]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},997,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},998,[846]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},999,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1000,[846]); -__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1001,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1002,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1003,[839,846,849,5,872,1004,15,1002]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1004,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1005,[838,835,837,5,839,846,849,1006,870]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1007,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1008,[839,846,849,863,1009,870]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1009,[]); -__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)))},1010,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1011,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1012,[34,1013]); -__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1013,[1010,977,1014]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1014,[1010]); -__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.3.12.171'},1015,[]); -__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1016,[1017,1018,933,977,1013]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1018,[977]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1019,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1020,[846,849,839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1021,[846,849,839]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1022,[1023]); -__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1023,[1017,933,1010,977,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1024,[]); -__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1025,[860,839,870,846,849,858,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1026,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1027,[891,1003,1026]); -__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1028,[5,860,839,1029,846,849,859]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1029,[1007]); -__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1030,[837,838,5,839,846,849,1031]); -__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1031,[984]); -__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1032,[837,984,838,835,5,839,846,849]); -__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1033,[837,838,5,839,846,849,1034]); -__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1034,[]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1035,[839,846,849,863,1036,15,870,1037]); -__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1036,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1037,[]); -__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1038,[34,839,846,849,863,13,870]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1039,[839,846,849,863,1040,870,1037]); -__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1040,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1041,[5,996,839,846,849,997]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1042,[1038]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1043,[839,846,849,863,1044,870]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1044,[]); -__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},1045,[846]); -__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(':')}`},1046,[839,846,849]); -__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{}}},1047,[236,872]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1048,[994,1049,1050,976,933]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1049,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1050,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1051,[933,987,998]); -__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1052,[1053]); -__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1053,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1054,[34]); -__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1055,[34,236,402,102,846,821,794,1054,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1056,[34,102,794,1057,821,1058,25]); -__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1057,[827,34,379,236,402,102,821,987,1058,2,872,1015,5,796,797,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1058,[1059,933,987,872,236]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1059,[]); -__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1060,[827,796,34,402,102,794,821,1043,1044,1009,1000,870,891,25]); -__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1061,[828,1062,796,827,34,281,283,364,336,402,102,426,794,821,1038,831,13,1063,1064,1000,1074,1079,1080,1083,1084,1085,1092,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1062,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1063,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1064,[34,876,1065,1066,1063]); -__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1065,[839,846,849]); -__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1066,[6,1067,1068,1069,1070,1071,1072,1073,3]); -__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1067,[]); -__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1068,[]); -__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1069,[]); -__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1070,[]); -__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1071,[]); -__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1072,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1073,[1063]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1074,[236,933,987,1075]); -__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})},1075,[499,1076,1078,1077]); -__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1076,[499,1077,1078]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1077,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1078,[1077]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1079,[933,987]); -__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1080,[34,281,236,102,794,1038,13,1081,821,1082,25]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1081,[13]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1082,[]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1083,[827,2,34,102,794,821,1038,891,13,987,1000,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1084,[13]); -__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1085,[34,1062,281,402,102,794,1086,1087,1091,1092,821,25]); -__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1086,[34,402,102,794,821,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1087,[837,34,874,891,858,872,1024,987,1088,1003,15,1090]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1088,[1089]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1089,[1090]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1090,[858]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1091,[34,872,1092,858,987,933]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1092,[]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1093,[34,1094,891,1008,1009,1000,1046,831,1097]); -__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1094,[996,1041,891,997,1095,1096]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1095,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1096,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1097,[]); -__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1098,[34,986,402,102,1099,794,874,1100,858,1101,821,25]); -__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)'}})]})}},1099,[34,281,283,364,102,1047,821,25]); -__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1100,[861,859]); -__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1101,[34,402,102,794,1100,858,821,25]); -__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1102,[34,102,794,874,877,821,25]); -__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1103,[860,34,102,794,874,1025,1028,1104,1105,877,821,25]); -__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1104,[1028,859,1100]); -__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1105,[860,877]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1106,[860,34,102,794,874,983,891,1100,858,821,25]); -__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1107,[828,827,1055,34,336,379,236,402,102,794,821,1039,1040,1000,1108,1109,987,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1108,[1075,236]); -__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1109,[839,846,849]); -__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1110,[827,996,34,379,402,102,794,821,1035,1036,891,1039,1040,1041,997,1095,987,1058,1000,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1111,[34,1035,891,1039,1112,1008,831,1036,1000,1093]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1112,[846]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1113,[996,34,1041,891,831,997,1009,1095,1000,1094]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1114,[860,34,1000,874,1100,1047]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1115,[860,1116,34,102,794,874,1100,821,1117,1106,1118,1139,1142,1098,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1116,[34,102,14,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1117,[821]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1118,[34,102,1119,821,1120,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1119,[860,1104]); -__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1120,[1121,860,34,1122,987,1124,402,102,874,1028,1119,1123,821,858,794,1125,1025,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1121,[34,859,821,794,25]); -__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1122,[34,402,102,874,1123,1124,987,1020,821,1120,794,25]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1123,[860,1104]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1124,[281,236]); -__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1125,[827,1126,1127,860,867,14,1128,1129,34,859,402,102,872,1087,874,1130,1104,858,821,864,794,1028,1025,1131,1132,1137,1106,1100,1138,1123,1122,25]); -__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1126,[34,402,412,102,1127,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1127,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1128,[34,102,794,25]); -__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1129,[34,236,402,295,102,426,821,794,1000,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1130,[878,858,877]); -__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1131,[34,402,102,878,858,821,794,25]); -__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1132,[860,877,34,102,879,1133,1134,1136,794,874,1028,983,861,867,872,1100,821,25]); -__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1133,[34,402,821,794,25]); -__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1134,[828,860,1135,34,281,236,102,1028,1104,821,794,1106,859,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1136,[34,402,102,874,861,863,821,794,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1137,[1127,1119,1123]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1138,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1139,[1140,34,102,874,1028,1123,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1140,[34,102,874,1028,1119,1141,1123,821,1003,891,872,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1141,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1142,[34,1062,1126,102,874,1028,1025,876,872,1137,861,1003,891,1026,1119,821,858,1131,1116,1128,1143,14,1140,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1143,[34,102,874,872,1137,14,1124,821,794,25]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1144,[34,102,794,1062,1092,1145,1091,1085,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1145,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1146,[34,102,794,827,1033,891,835,1147,821,1148,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1147,[1034]); -__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1148,[34,402,102,1124,987,1149,1021,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1149,[933,976,1010,1018,1013,1016,1150,1151,1152,1153,1154,1155,977]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1150,[1018,933,1016]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1151,[1018,933,976,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1152,[1010,976,1151,1013,1016,1150]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1153,[933,977]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1154,[34,1013]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1155,[933]); -__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1156,[30,34,426,102,846,872,1087,1157,25]); -__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1157,[839,846,849]); -__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()},1158,[1159]); -__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1159,[1160,858,884]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1160,[1161,877,1162,878,858,884,1163]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1161,[858]); -__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'},1162,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1163,[858]); -__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1164,[978,34,835,402,102,874,891,1165,1160,794,821,1087,1158,1032,15,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1165,[34,102,794,874,1038,884,1166,831,13,1163,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1166,[34,884]); -__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1167,[34,402,102,794,867,821,1159,1158,1164,1032,25]); -__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1168,[34,402,102,794,874,1160,858,821,1169,1165,1164,25]); -__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1169,[828,34,283,364,236,102,426,797,794,827,821,1170,25]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1170,[]); -__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1171,[827,984,1172,835,860,1173,1174,34,402,295,102,794,874,882,1175,891,993,861,867,1178,858,821,1179,1112,1087,1159,1158,1180,869,1164,1032,925,1181,1003,987,1184,988,1097,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1172,[1158,984]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1173,[827,34,102,794,874,979,891,980,981,982,831,821,25]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1174,[]); -__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1175,[827,796,34,336,402,102,821,794,874,1176,1055,882,861,863,885,1108,1177,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1176,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1177,[827,796,34,336,236,402,102,794,831,989,861,990,993,891,1003,882,821,930,991,25]); -__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])},1178,[858]); -__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1179,[928,828,827,837,5,34,1055,336,402,102,794,891,858,821,1087,1024,925,1046,1045,987,1112,1097,25]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1180,[828,34,102,794,876,831,869,821,925,25]); -__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1181,[928,828,34,395,236,402,102,925,794,926,891,1182,927,831,5,1183,987,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1182,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1183,[933,976,987,977]); -__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1184,[34,402,102,794,891,988,1097,993,987,1090,858,1124,821,25]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1185,[1172,984,34,379,102,794,891,993,867,821,1087,1164,1032,1186,25]); -__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1186,[827,835,984,34,379,236,402,102,794,1030,983,985,867,1031,821,1164,25]); -__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1187,[984,872,34,986,1188,336,402,102,1189,794,985,983,1030,821,874,1100,858,1124,987,25]); -__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1188,[5,822,823,828,236,826]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1189,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1190,[827,1030,1172,984,34,402,102,794,891,867,821,1164,1032,25]); -__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1191,[827,34,402,102,794,796,989,874,863,990,991,821,930,1192,1196,1177,25]); -__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1193,[1194,933,987,872,2,1195,1074]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1194,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1195,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1196,[34,102,797,794,989,874,992,821,930,1177,1197,25]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1197,[]); -__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1198,[827,1199,34,402,102,426,794,891,867,858,821,1200,1087,1064,25]); -__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:d,accent:u,children:a,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:d?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:u??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:u??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,a]});return d?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:d,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const d=e.key===n,u=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.note??String(u)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:d?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(u?2:0,e.a/t*c),backgroundColor:d?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,d=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',u=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,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1200,[34,402,102,794,821,5,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1201,[860,1101,1098,1116,34,102,846,794,874,1100,878,877,858,821,1106,1202,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1202,[34,794,874,1203,25]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1203,[379]); -__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1204,[827,1062,1199,34,1205,236,402,426,102,1207,1208,1209,794,831,891,867,1063,821,930,1217,1200,1087,1064,1210,872,1211,1215,25]); -__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1205,[34,402,102,1206,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1206,[34,797,25]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1207,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1208,[34,102,794,827,891,867,1207,821,25]); -__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1209,[827,1207,34,402,102,794,925,891,1097,858,821,1200,1087,1210,872,1211,1212,1214,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1210,[1062,1084,1092]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1211,[34,102,794,891,1038,1062,1092,1086,1210,821,872,1209,1085,1087,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1212,[1063,1213]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1213,[1063,1207]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1214,[34,102,794,827,1062,1063,1212,1124,821,1215,25]); -__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1215,[1062,34,402,102,794,827,891,1213,1063,1216,1124,821,1204,1087,1207,1212,1064,25]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1216,[]); -__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1217,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1179,1200,1087,1064,1159,987,1038,1061,13,1084,1063,2,25]); -__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1218,[828,891,1219,1199,1005,1006,34,1012,1013,236,402,295,102,794,874,1097,1209,1181,1220,1089,5,1221,1160,867,858,821,1200,1179,1087,925,1041,996,997,1094,1000,1096,1165,1163,1212,1214,1090,25]); -__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1219,[827,34,402,102,794,821,891,831,876,1005,1006,25]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1220,[34,102,794,891,1089,821,1097,25]); -__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1221,[34,402,102,794,891,858,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1222,[34,102,794,891,821,1087,1090,1220,1097,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1223,[34,102,1087,821,794,25]); -__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1224,[827,1062,34,402,102,794,1033,821,930,25]); -__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1225,[827,796,1226,1148,835,891,34,336,402,102,794,1033,1034,821,925,930,1227,1230,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1226,[34,1033,891,835]); -__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1227,[828,1062,796,827,1226,835,891,34,336,402,102,797,794,925,1033,1034,1228,821,930,1229,25]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1228,[]); -__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1229,[831,891,5]); -__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1230,[34,1062,379,236,102,794,891,1033,1229,1034,1231,821,930,1226,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1231,[1034]); -__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1232,[34,402,102,794,994,861,995,821,930,1233,25]); -__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1233,[828,34,336,395,402,295,102,1234,794,994,861,995,858,821,1048,25,1236]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1234,[34,1235,102,861,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1235,[2,987]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1236,[]); -__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1237,[860,1057,34,236,402,102,797,874,821,794,1238,1129,1239,25]); -__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1238,[860,34,380,236,402,102,36,821,794,796,1129,874,25,277]); -__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1239,[1240,1241,1243,1242,1244,1047,1245]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1240,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1241,[839,5,846,849,872,1047,1242]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1242,[860,236,872,1240]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1243,[34,874,861,869,867,1241,1240]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1244,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1245,[34,1241,987,933]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1246,[34,402,102,426,874,861,821,794,1237,1129,1247,25]); -__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1247,[34,102,426,874,861,1239,1047,821,794,1129,25]); -__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1248,[34,236,402,102,879,794,821,1000,1249,1250,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1249,[872,6,933,976,1000,1239,1250]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1250,[839,1251,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1251,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1252,[34,872,1249]); -__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1253,[827,796,1226,835,984,34,931,1205,395,236,402,295,102,846,794,861,1034,867,882,1033,821,1164,1158,1185,932,25]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1254,[34,402,346,102,426,821,1206,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1255,[30,34,792,872,25]); -__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1256,[860,1126,877,30,34,1257,1001,102,14,1128,1137,794,861,867,1130,858,874,987,821,1203,864,1025,1028,1104,1132,1100,1258,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1257,[827,34,236,102,25]); -__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1258,[34,402,102,878,858,1062,1259,821,794,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1259,[1062]); -__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:"ok",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"})]})]})}},1260,[30,34,336,102,1234,1261,794,861,867,874,882,821,25]); -__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])},1261,[30,34,402,874,821,794,25]); -__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1262,[30,34,794,1263,874,1248,25]); -__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])},1263,[34,402,821,794,25]); -__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1264,[837,30,34,1265,794,867,874,821,1266,1270,25]); -__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:x=!0,onPaid:f,title:g="Pay"}){const y=(0,o.useGiftCards)(b).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),_=y.find(e=>e.code===m),v=_?Math.min(_.balance,p):0,R=p-v;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:g,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),x&&y.length>0?(0,h.jsxs)(l.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:!m,onPress:()=>w(void 0)}),y.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,h.jsxs)(l.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)})]}),v?(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.ok,children:["\u2212",(0,n.gbp)(v)]})]}):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)})]})]}),T?(0,h.jsx)(t.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),f({giftCardCode:m,giftApplied:v,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1265,[34,385,102,874,867,821,794,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1266,[34,102,794,867,1267,1268,1269,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1267,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1268,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1269,[933,987,1268]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1270,[846,933,976,987,2,1267]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),r=e(_r(_d[4])),o=e(_r(_d[5])),i=e(_r(_d[6])),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),b=e(c);_r(_d[10]);var h=e(_r(_d[11])),f=e(_r(_d[12])),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),S=_r(_d[20]),T=_r(_d[21]),I=_r(_d[22]),O=_r(_d[23]),R=_r(_d[24]),A=_r(_d[25]),B=_r(_d[26]),P=_r(_d[27]),C=_r(_d[28]),_=_r(_d[29]),v=_r(_d[30]),N=_r(_d[31]);const $=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let E=!1,M=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,u.useLocalSearchParams)(),d=(0,w.useRestaurant)(e),c=s.IS_QUEUED_VENUE?(0,N.jsx)(t.default,{}):s.IS_ABBOTSFORD?(0,N.jsx)(o.default,{}):s.IS_KIRKTON?(0,N.jsx)(i.default,{}):s.IS_GREENSIDE?(0,N.jsx)(r.default,{}):l.IsolatedCustomerHome&&(s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS)?(0,N.jsx)(l.IsolatedCustomerHome,{}):(0,N.jsx)(K,{});return s.IS_ABBOTSFORD||s.IS_KIRKTON||s.IS_WILDINGS||!d?.settings.hotel?.enabled?c:(0,N.jsx)(n.HotelRequestGate,{rid:e,hotel:d.settings.hotel,children:c})}function K(){const{rid:e}=(0,u.useLocalSearchParams)(),t=(0,w.useRestaurant)(e),l=(0,w.useMenu)(e),s=(0,w.useCustomer)(),n=(0,w.useBasket)(),r=(0,w.useStore)(e=>e.startBasket),o=(0,w.useNow)(3e4),[i,H]=(0,c.useState)('All'),[K,W]=(0,c.useState)(null),[G,F]=(0,c.useState)(!1),[U,Q]=(0,c.useState)(!1),[V,Y]=(0,c.useState)('takeaway'===$?'takeaway':'main');b.default.useEffect(()=>{$&&!E&&(E=!0,'book'===$?setTimeout(()=>u.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,w.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,v.guestServer)();b.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>u.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),b.default.useEffect(()=>{C.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>u.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,w.useOrderAtTable)(e);if(b.default.useEffect(()=>{te||n.restaurantId!==e||'table'!==n.mode||w.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,n.mode,n.restaurantId,e]),!t)return(0,N.jsx)(x.Screen,{title:"Not found",children:(0,N.jsx)(x.T,{children:"Restaurant not found."})});const le=te&&n.restaurantId===t.id&&'table'===n.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ae=e=>!(e.soldOut||!e.signOff||null===e.price),ne=l.filter(e=>('All'===i||e.section===i)&&('takeaway'!==V||ae(e))),re=(0,k.hoursFor)(t,o),oe=e=>()=>u.router.push(`/customer/${t.id}${e}`),ie=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),le&&r(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>Q(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:oe('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:oe('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:oe('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:oe('/refer')},{icon:'gift',label:'Gift cards',on:oe('/gift')},{icon:'alert',label:'My allergens',sub:s.allergies.length?`${s.allergies.length} declared`:'None declared',on:()=>u.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:s.marketingOptIn[t.id]?'Opted in':'Opt in',on:oe('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:oe('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:oe('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:oe('/feedback')},{icon:'hanger',label:'Lost property',on:oe('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:oe('/merch')}];return(0,N.jsxs)(x.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,N.jsxs)(x.Row,{children:[(0,N.jsx)(m.BasketButton,{}),(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>u.router.push('/customer/profile')})]}),children:[t.fictional?(0,N.jsx)(x.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,le?(0,N.jsx)(x.Banner,{kind:"success",title:`Ordering at ${(0,d.tableNumbers)(n.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,N.jsx)(x.Card,{children:(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(f.default,{style:{flex:1},children:[(0,N.jsx)(x.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,N.jsxs)(x.Muted,{children:[re?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,N.jsx)(x.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,N.jsx)(x.Row,{wrap:!0,gap:8,children:ie.slice(2,7).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,N.jsx)(f.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ie.map(e=>(0,N.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),le?(0,N.jsx)(x.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,N.jsx)(x.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,N.jsx)(x.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,N.jsx)(x.ExampleAllergenNotice,{}),(0,N.jsxs)(x.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,N.jsx)(f.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,N.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,N.jsx)(x.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,N.jsx)(f.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,N.jsx)(A.SpecialsTab,{rid:t.id,declared:s.allergies,now:o}):null,'takeaway'===V?(0,N.jsx)(x.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==V?(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,N.jsx)(x.Chip,{label:"All",selected:'All'===i,onPress:()=>H('All')}),se.map(e=>(0,N.jsx)(x.Chip,{label:e,selected:i===e,onPress:()=>H(e)},e))]}):null,'specials'!==V?se.filter(e=>('All'===i||e===i)&&ne.some(t=>t.section===e)).map(e=>(0,N.jsxs)(f.default,{style:{gap:10},children:[(0,N.jsx)(x.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),ne.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,s.allergies),o=e.soldOut||!e.signOff||null===e.price;return(0,N.jsxs)(x.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,N.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)},children:[(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,N.jsx)(x.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,N.jsx)(x.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,j.gbp)(e.price)})]}),(0,N.jsx)(x.Muted,{numberOfLines:2,children:e.description})]}),(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,N.jsx)(x.Badge,{kind:"ok",label:e},e)),e.special?(0,N.jsx)(x.Badge,{kind:"gold",label:"Special"}):null,e.soldOut?(0,N.jsx)(x.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,N.jsx)(x.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,N.jsx)(x.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,N.jsx)(x.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,N.jsx)(p.AllergenChips,{map:e.allergens,declared:s.allergies}),K===e.id?(0,N.jsx)(p.AllergenPanel,{item:e,map:e.allergens,declared:s.allergies}):null,(0,N.jsxs)(x.Row,{gap:8,children:[(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,N.jsx)(f.default,{style:{flex:1}}),(0,N.jsx)(x.Button,{small:!0,label:o?e.soldOut?'Sold out':'Not available online':'Choose',disabled:o,onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,N.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,N.jsx)(x.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,N.jsx)(x.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,N.jsx)(T.LauncherLine,{}),te?(0,N.jsxs)(x.Sheet,{visible:U,onClose:()=>Q(!1),title:"Order at your table",children:[(0,N.jsx)(x.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,N.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:`${(0,d.tableNumbers)(e)}`,onPress:()=>{Q(!1),r(t.id,'table',e)}},e))}),(0,N.jsx)(x.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1271,[1272,1281,5,1282,1283,1284,1287,860,30,34,236,402,102,1234,1261,794,861,867,878,874,821,1288,1248,872,891,1233,994,995,1003,1289,1270,25]); -__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1272,[34,379,794,873,1273,1274,1280,874,5,6,25]); -__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1273,[34,379,102,794,996,997,1095,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1274,[6,34,933,794,1275,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1275,[6,1062,1276,1277,1278,34,102,827,794,821,11,1279,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1277,[4,11]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1278,[11]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1279,[6,933]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1280,[34,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1281,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1282,[34,102,794,1275,25]); -__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1283,[34,379,933,794,873,1273,1275,4,25]); -__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1284,[34,379,794,1273,873,1274,8,1285,25]); -__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1285,[34,102,794,1286,25]); -__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1286,[]); -__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1287,[34,794,873,1273,1274,874,9,25]); -__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1288,[34,402,102,426,794,821,1206,25]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1289,[34,102,1290,794,874,1003,1267,1270,821,25]); -__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1290,[34,102,1291,821,25]); -__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1291,[1292]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1292,[34,797,1293,1322,1323,25]); -__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1293,[1294]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1294,[1295,1296,1319,1321]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1295,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1296,[1297,1298,1299,1300,1301,1302,1303,1304,1305,1308,1312,1309,1313]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1297,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1298,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1299,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1300,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1305,[1306]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1309,[1310,1311]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1310,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1311,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1314,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1315,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1317,[1309,1297]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1318,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1319,[1320]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1321,[1320]); -__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1322,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1323,[34,797,1324,25]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1324,[]); -__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1325,[30,34,794,874,891,25]); -__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1326,[837,30,34,102,1290,794,867,874,821,1289,1270,25]); -__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1327,[837,30,34,102,1265,794,874,891,867,858,821,1266,1270,25]); -__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1328,[837,30,34,794,874,891,858,821,1289,1270,25]); -__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1329,[837,30,34,794,874,891,821,1289,1270,25]); -__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1330,[30,34,794,858,1160,1331,874,821,25]); -__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}},1331,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1332,[30,1100,34,402,102,794,858,874,821,25]); -__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 l=_r(d[0]),t=_r(d[1]),n=_r(d[2]),s=e(n),a=_r(d[3]),o=_r(d[4]),r=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),p=_r(d[15]),k=_r(d[16]);function f(){const e=(0,y.useBasket)(),f=(0,y.useRestaurant)(e.restaurantId??void 0),w=(0,y.useAllMenu)(e.restaurantId??void 0),v=(0,y.useCustomer)(),C=(0,y.useOrders)(f?.id),S=(0,y.useStore)(e=>e.setLineQty),T=(0,y.useStore)(e=>e.overrideLine),B=(0,y.useStore)(e=>e.startBasket),P=(0,y.useNow)(15e3),[$,O]=(0,n.useState)(null),[I,M]=(0,n.useState)(!1),[N,F]=(0,n.useState)(''),[L]=(0,n.useState)(()=>(0,o.startForm)()),[R,z]=(0,n.useState)(''),[A,D]=(0,n.useState)(v.phone??''),[E,Y]=(0,n.useState)(v.email??''),[_,q]=(0,n.useState)(!1),H=(0,y.useOrderAtTable)(e.restaurantId??void 0);s.default.useEffect(()=>{H||'table'!==e.mode||y.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[H,e.mode]);const[G,K]=(0,n.useState)(null),[Q,J]=(0,n.useState)(!1),U=(0,n.useMemo)(()=>(0,j.linesFromBasket)(e,w,v.allergies),[e,w,v.allergies]);if(!f||!e.lines.length)return(0,k.jsxs)(u.Screen,{title:"Your basket",children:[(0,k.jsx)(u.Muted,{children:"Your basket is empty."}),(0,k.jsx)(u.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const V=H&&'table'===e.mode,W=(0,m.takeawaySlots)(f,C,P),X=U.reduce((e,l)=>e+l.unitPrice*l.qty,0),Z=U.some(e=>e.contains.length&&!e.overridden),ee=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff}),le=!V&&!$,te=!V&&f.settings.takeawayPaused,ne=(0,p.ukPhone)(A),se=!Z&&!ee.length&&I&&!le&&!te&&(V||ne.ok&&(0,p.emailOk)(E)),ae=async e=>{const l=await y.repo.orders.placeFromBasket({slotTime:V?void 0:$,tip:0,giftCardCode:e?.giftCardCode,notes:N,paidNow:!V,phone:V?void 0:ne.pretty,email:V?void 0:E.trim()||void 0});(0,o.rememberGuard)(l.id,(0,o.guardFor)({...L,hp:R})),q(!1),t.router.replace(`/customer/order/${l.id}`)},oe=e.lines.find(e=>e.key===G),re=oe?U[e.lines.indexOf(oe)]:void 0;return(0,k.jsxs)(u.Screen,{title:"Your basket",subtitle:`${f.name} \xb7 ${V?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,k.jsxs)(r.default,{style:{gap:8},children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.T,{weight:"semibold",children:"Subtotal"}),(0,k.jsx)(u.T,{weight:"bold",size:20,colour:x.colours.gold,children:(0,h.gbp)(X)})]}),Z?(0,k.jsx)(u.T,{size:14,colour:x.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):I?le&&!te?(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Choose a collection time."}):null:(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Confirm your allergies to continue."}),V?(0,k.jsx)(u.Button,{label:"Send order to the kitchen",disabled:!se,onPress:()=>ae(),testID:"send-table-order"}):(0,k.jsx)(u.Button,{label:`Continue to payment \xb7 ${(0,h.gbp)(X)}`,disabled:!se,onPress:()=>q(!0),testID:"checkout"})]}),children:[(V||e.tableNo,null),V?(0,k.jsx)(u.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,f.fictional?null:(0,k.jsx)(u.ExampleAllergenNotice,{}),U.map((l,t)=>{const n=e.lines[t],s=l.contains.length&&!l.overridden;return(0,k.jsxs)(u.Card,{highlight:l.contains.length?x.colours.red:l.may.length?x.colours.amber:void 0,children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(r.default,{style:{flex:1,paddingRight:8},children:[(0,k.jsx)(u.T,{weight:"semibold",children:l.name}),l.choices.length?(0,k.jsx)(u.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,k.jsxs)(u.Muted,{children:["Note: ",l.notes]}):null]}),(0,k.jsx)(u.T,{weight:"semibold",children:(0,h.gbp)(l.unitPrice*l.qty)})]}),s?(0,k.jsxs)(u.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:[(0,k.jsx)(u.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${v.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} (${(0,c.severityLabel)(e.severity)})`).join(', ')}.`}),(0,k.jsxs)(u.Row,{gap:8,style:{marginTop:6},children:[(0,k.jsx)(u.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{J(!1),K(n.key)}})]})]}):l.contains.length?(0,k.jsx)(u.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,k.jsx)(u.Banner,{kind:"warn",title:`May contain ${l.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ee.includes(n)?(0,k.jsx)(u.Badge,{kind:"amber",label:"No longer available online \u2014 please remove"}):null,(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Stepper,{value:n.qty,onChange:e=>S(n.key,e),min:1,label:l.name})]})]},n.key)}),(0,k.jsx)(u.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${f.id}`)}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsxs)(u.H2,{children:["Collection time \u2014 ",(0,b.niceDate)(P)]}),te?(0,k.jsx)(u.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===W.length?(0,k.jsx)(u.Banner,{kind:"warn",children:"No collection slots left today."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u.Muted,{children:["15-minute slots, max ",f.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:W.slice(0,16).map(e=>(0,k.jsx)(u.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>O(e.time.toISOString())},e.label))})]})]}),(0,k.jsxs)(u.Card,{highlight:I?void 0:x.colours.amber,children:[(0,k.jsx)(u.H2,{children:"Confirm allergies for this order"}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:v.allergies.length?v.allergies.map(e=>(0,k.jsx)(u.Badge,{kind:"red",label:`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`},e.allergen)):(0,k.jsx)(u.Muted,{children:"No allergies declared on your profile."})}),(0,k.jsx)(u.Toggle,{label:v.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:I,onChange:M}),(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsx)(u.H2,{children:"Your details"}),(0,k.jsx)(u.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:A,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!ne.ok&&A?(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:ne.error}):null,(0,k.jsx)(u.Field,{label:"Email (optional)",value:E,onChangeText:Y,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,p.emailOk)(E)?null:(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,k.jsx)(u.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,k.jsx)(u.Field,{label:"Order notes (optional)",value:N,onChangeText:F,placeholder:"e.g. cutlery please"}),V?(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>B(f.id,'takeaway')}):null,(0,k.jsx)(i.MockPay,{visible:_,onClose:()=>q(!1),amount:X,restaurantId:f.id,onPaid:e=>ae({giftCardCode:e.giftCardCode}),title:"Pay for your takeaway"}),(0,k.jsxs)(u.Sheet,{visible:!!oe,onClose:()=>K(null),title:"Allergy override",children:[re?(0,k.jsx)(u.Banner,{kind:"danger",title:`${re.name} contains ${re.contains.map(c.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,k.jsx)(u.Toggle,{label:"I understand and want to add it anyway",value:Q,onChange:J}),(0,k.jsx)(u.Button,{kind:"danger",disabled:!Q,label:"Confirm override",onPress:()=>{oe&&re&&T(oe.key,re.contains),K(null)}})]}),(0,k.jsx)(a.Honeypot,{value:R,onChange:z})]})}},1333,[860,30,34,1257,1001,102,1265,794,861,867,1130,858,874,831,821,864,25]); -__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1334,[30,34,102,1261,794,861,878,874,821,1288,5,25]); -__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 f}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},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]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,s.useLocalSearchParams)(),r=(0,b.useOrder)(e),f=(0,b.useRestaurant)(r?.restaurantId),[C,S]=(0,l.useState)(0),[k,T]=(0,l.useState)(''),[v,P]=(0,l.useState)(!1),[M,$]=(0,l.useState)(!1),[R,A]=(0,l.useState)(1),[I,N]=(0,l.useState)(0),[O,B]=(0,l.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(c.Screen,{title:"Order",children:(0,j.jsx)(c.T,{children:"Order not found."})});const H='takeaway'===r.type?x:w,_=Math.max(0,H.findIndex(([e])=>e===r.status)),D=Math.round(r.subtotal*I/100),F='table'===r.type?r.subtotal+(r.split?r.tip:D):r.total,q=F-r.paid,L=r.split?.ways??O,W=r.split?.paidShares??0,Y=Math.ceil(F/L),E='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(c.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,p.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(c.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Status"}),H.map(([e,t],s)=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=_?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(c.T,{weight:s===_?'semibold':'regular',colour:s<=_?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(c.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,p.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(c.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||E?null:(0,j.jsxs)(c.Row,{gap:8,children:[(0,j.jsx)(c.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>b.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(c.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>b.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(c.T,{children:(0,h.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(c.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(c.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(u.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Subtotal"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Of which gift card"}),(0,j.jsxs)(c.T,{colour:y.colours.ok,children:["\u2212",(0,h.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Tip"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.tip)})]}):null,(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.gold,children:(0,h.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(c.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(F)," \xb7 split ",L," way",L>1?'s':''," \xb7 ",(0,h.gbp)(Y)," each"]}),(0,j.jsxs)(c.T,{children:["Shares paid: ",W," of ",L," \xb7 remaining ",(0,h.gbp)(q)]}),L>1?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{children:"Shares to pay now"}),(0,j.jsx)(c.Stepper,{value:R,onChange:A,min:1,max:L-W,label:"shares"})]}):null,(0,j.jsx)(c.Button,{label:`Pay ${L>1?`${R} share${R>1?'s':''}`:'bill'} \xb7 ${(0,h.gbp)(Math.min(q,Y*R))}`,onPress:()=>$(!0),testID:"pay-bill"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(c.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(c.Chip,{label:e?`${e}%`:'No tip',selected:I===e,onPress:()=>N(e)},e))}),(0,j.jsx)(c.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(c.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(r.subtotal+D),O>1?` \xb7 ${(0,h.gbp)(Math.ceil((r.subtotal+D)/O))} each`:'']}),(0,j.jsx)(c.Button,{label:"Get the bill",onPress:()=>b.repo.orders.setSplit(r.id,O,D),testID:"get-bill"})]})]}):null,!E||r.rated||v?null:(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(c.H2,{children:"How was everything?"}),(0,j.jsxs)(c.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(i.Stars,{value:C,onChange:S}),C?(0,j.jsx)(c.Field,{label:"Anything to add? (optional)",value:k,onChangeText:T}):null,(0,j.jsx)(c.Button,{label:"Send feedback",disabled:!C,onPress:()=>{b.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:C,comment:k,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),P(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(c.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,E?(0,j.jsx)(c.Button,{kind:"secondary",label:"View stamp card",onPress:()=>s.router.push(`/customer/${f.id}/loyalty`)}):null,(0,j.jsx)(o.MockPay,{visible:M,onClose:()=>$(!1),amount:Math.min(q,Y*R),restaurantId:f.id,title:`Pay \u2014 ${(0,t.tableNumbers)(r.tableNo)}`,onPaid:e=>{b.repo.orders.payTable(r.id,{shares:R,giftCardCode:e.giftCardCode}),$(!1),A(1)}})]})}},1335,[860,30,34,102,1265,1263,794,861,867,858,874,821,25]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1336,[860,1270,30,34,102,794,861,867,858,874,879,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1337,[30,34,872,25]); -__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1338,[837,30,34,794,874,5,1270,25]); -__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1339,[30,34,794,1340,1174,1270,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1340,[827,860,34,102,794,861,867,1174,1341,874,821,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1341,[933,987,1174]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1342,[30,34,872,1343,1407,25]); -__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1343,[1161,796,5,6,1344,828,853,1121,860,1160,1345,1346,1347,1118,1142,1348,1349,1354,1355,1356,872,1357,1173,979,1129,1358,34,1098,1201,1047,1114,1156,1359,395,380,402,295,102,426,36,794,1248,1252,873,861,858,874,821,1117,891,1125,1087,1028,1104,1134,1360,1133,1361,1368,1370,1373,1376,1372,1377,1379,1380,1139,1122,1123,878,1384,1237,1385,1247,1239,1025,1390,1398,1399,1101,1141,1401,1402,1403,1097,1188,1404,1187,1180,869,1405,1406,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1345,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1346,[1026,1087]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1347,[34,102,1104,794,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1348,[860,34,102,794,874,1174,821,25]); -__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1349,[34,395,402,426,102,1290,794,1188,796,1028,1350,1351,1353,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1350,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1351,[34,395,402,295,412,102,426,796,794,821,1352,1353,25]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1352,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1353,[1024,872,1352,933,987]); -__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1354,[846]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1355,[828,34,379,395,402,102,794,1188,821,25]); -__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1356,[34,236,402,102,794,821,891,1003,858,1097,25]); -__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1357,[828,827,34,236,402,295,102,794,1173,874,979,831,981,982,872,980,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1358,[828,34,102,821,794,25]); -__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1359,[34,102,797,821,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1360,[]); -__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1361,[828,796,827,1121,860,1129,34,236,402,295,426,102,859,821,794,1362,1363,1028,891,1133,1365,987,872,25]); -__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1362,[828,860,34,1363,102,859,821,794,1134,1364,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1363,[859]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1364,[1363,859]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1365,[34,385,295,102,859,1366,1367,821,796,827,794,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1366,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1367,[1366,1024,872,933,987]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1368,[34,236,402,102,821,794,1188,1369,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1369,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1370,[828,860,1122,34,281,236,295,102,1135,874,1028,1104,14,858,1123,1371,821,794,1372,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1371,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1372,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1373,[5,828,34,283,336,236,402,102,426,821,873,794,1029,1000,1354,1374,2,1375,1376,874,858,25]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1374,[236]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1376,[34,846,933,987,1375]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1377,[860,14,1028,1378]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1378,[861]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1379,[34,102,797,821,25]); -__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1380,[1381,860,1122,1028,34,102,794,1125,874,1383,1377,1123,858,1120,1139,1140,1141,821,1346,25]); -__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1381,[34,379,402,102,874,1003,891,1026,1382,872,821,794,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1382,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1383,[1028,1104]); -__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1384,[1381,828,1122,827,860,1160,1118,1139,858,34,1106,236,402,295,102,794,1125,1372,874,1028,861,1116,1104,1331,821,1346,25]); -__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1385,[827,34,236,402,102,794,874,1028,1386,821,1387,1389,25]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1386,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1387,[846,874,1028,1386,1388,1389]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1388,[860]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1389,[236,1388]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1390,[860,34,1205,1188,402,102,1025,1028,878,858,821,794,1391,1394,25]); -__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1391,[1392,870,860,34,281,395,402,295,102,874,1025,1028,1393,858,821,1055,794,1394,1395,987,1346,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1392,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1393,[878,858,877]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1394,[5,1028,933,987]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1395,[846,933,987,1396,2,1397]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1396,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1397,[15]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1399,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1400,[1104]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1401,[860,1378]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1402,[34,402,102,794,1401,821,1359,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1403,[34,102,925,794,1188,858,821,25]); -__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1404,[34,1188,402,102,426,794,25]); -__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1405,[828,1062,827,2,1188,34,402,102,426,794,821,891,997,858,1000,1395,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1406,[34,1035,891,1008,831,1036,1000,1395,1093]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1407,[5,828,873,34,236,402,102,426,987,821,794,1354,1408,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1408,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1409,[30,34,872,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1410,[30,34,872,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1411,[30,34,1412,872,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1412,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1413,[30,34,872,1414,25]); -__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1414,[1415,1419,828,996,1098,1420,1223,1054,1055,1421,1423,1426,1173,979,1015,1428,1012,2,1060,1061,1429,998,1038,999,34,1175,1248,1252,1219,373,402,295,102,426,36,794,873,1156,891,821,1179,1430,1093,1111,1113,1107,1056,1039,1087,1438,1439,1440,1448,1449,1003,236,1254,1198,1204,1445,1218,1217,1458,1201,15,1224,1225,925,793,987,25]); -__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1415,[827,34,1047,395,102,1133,1134,1361,1390,794,1025,1028,858,821,1087,1029,1416,1417,1049,25]); -__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1416,[827,34,402,102,794,821,1028,5,1029,872,987,25]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1417,[34,102,794,1028,1418,859,821,1074,933,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1418,[]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1419,[34,102,794,1087,987,25]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1420,[860,34,102,794,861,867,1174,874,869,821,25]); -__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1421,[987,34,281,236,102,1290,794,1267,1270,821,1422,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1422,[34,236,102,794,1267,25]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1423,[34,796,102,794,861,1267,1424,1425,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1424,[861]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1425,[987,1424,1270]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1426,[5,1427,34,102,794,867,1267,1268,1269,987,1270,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1427,[34,794,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1428,[236,1013]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1429,[34,102,794,821,998,1051,987,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1430,[5,1427,1122,11,1431,827,837,1139,1140,1118,1142,1432,1137,1141,1401,1402,1087,1346,1026,1116,14,1143,1434,1248,1435,1390,1106,1100,1117,34,102,794,1359,874,861,867,858,1331,821,1200,1125,1028,1436,1086,1180,1437,1239,987,1202,1398,878,25]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1431,[6,34,102,794,987,1279,25]); -__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1432,[34,402,102,1433,987,933,821,794,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1433,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1434,[827,5,34,379,236,102,794,876,14,867,1031,933,821,1203,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1435,[34,402,1188,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1436,[34,102,874,1028,794,821,25]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1437,[34,102,879,874,864,821,794,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1438,[34,1391,1087,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1439,[860,34,102,1180,794,874,861,869,858,821,1200,1087,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1440,[835,984,1441,34,236,102,794,831,891,983,1030,985,987,1447,821,2,1181,25]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1441,[827,979,1160,987,797,1237,1239,34,281,379,236,402,102,426,879,794,874,1248,891,867,858,821,1200,1087,869,1442,1179,1445,1446,1159,1166,1165,1038,13,1163,1169,1229,25]); -__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1442,[927,796,831,828,837,878,1075,1443,34,993,336,379,236,402,102,794,874,891,858,821,1200,1087,1229,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1443,[499,1444]); -__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 t={}},1444,[]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1445,[827,34,1235,1055,870,379,402,102,794,891,867,858,821,1200,1087,1229,25]); -__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1446,[1015,34,402,102,794,891,821,1087,987,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1447,[]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1448,[860,34,102,794,891,1028,858,1090,1088,987,1089,5,1000,821,25]); -__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1449,[5,1450,1451,1452,1453,1454,34,236,41,102,872,1455,1003,821,1457,794,987,2,1096,1002,891,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1450,[34,102,873,794,5,6,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1451,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1452,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1453,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1454,[34,102,873,794,25]); -__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1455,[34,295,102,794,873,821,1456,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1456,[]); -__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1457,[929,828,34,1096,336,236,402,295,41,102,872,926,891,831,987,1003,15,793,821,925,794,25]); -__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1458,[1201,1098,1139,1116,34,402,102,794,891,858,821,1117,1187,1087,1198,1442,1180,876,1202,869,1200,925,1436,1028,860,1125,1217,1221,1097,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1459,[30,34,872,25]); -__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1460,[1461,987,795,1408,1463,1025,30,1490,496,34,385,336,236,41,102,5,873,872,1492,36,874,1028,891,821,1449,1003,1023,1495,1496,1057,1497,1129,2,1038,998,1515,1376,25,1517,1518,1519,1520]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1461,[2,827,34,236,383,102,794,1462,987,821,1204,1003,891,993,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1462,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1463,[1464,1487,1489]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1464,[215,1465,1468,1482,1483,1484,1485,1486]); -__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1465,[215,1466]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1466,[1467]); -__d(function(g,r,i,a,m,e,d){},1467,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1468,[1469,215,1465,1482,1483]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1469,[1470,1471,1481]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1470,[1471,1475,1480]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1471,[215,372,1472,1476,1477,1478,1479,1475,1480]); -__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1472,[215,1473,339,280,1474,1475]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1473,[504]); -__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1474,[215,339]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1475,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1476,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1477,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1478,[1476]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1479,[]); -__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1480,[372,1474]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1481,[34,1471]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1482,[1469,215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1483,[1469,1482]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1484,[1465]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1485,[215,1465,1468,1466]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1486,[]); -__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1487,[215,54,1488]); -__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1488,[215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1489,[34,1464]); -__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]}})})},1490,[1491]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1491,[]); -__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1492,[34,41,102,426,794,873,1003,987,2,5,821,1493,1494,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1493,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1494,[34,102,794,821,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1495,[989,883,882,987]); -__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1496,[828,796,827,34,1011,1416,1029,402,102,872,987,1013,1028,5,821,794,1354,976,2,25]); -__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1497,[5,796,827,34,385,283,364,380,236,402,295,426,102,1498,1156,2,797,1087,15,891,794,821,1499,932,1511,1507,1508,1512,1157,1513,931,1514,1510,25,277]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"useAssistantUi",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AssistantFab",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AssistantSheet",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"AssistantPage",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"AssistantSettings",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"AssistantPlanCard",{enumerable:!0,get:function(){return c}});const t=!1,n={getState:()=>({open:!1,setOpen:t=>{}})},u=()=>null,s=()=>null,l=()=>null,o=()=>null,c=()=>null},1498,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1499,[1500,1127,860,1501,1502,891,874,1028,1506,1507,1508,1504,1503,1509,1510,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1500,[1092,1091,1052]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1501,[984,1127,835,860,874,831,1028,983,985,1039,891,1094,882,863,861]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1502,[835,874,831,1028,891,1033,1043,1044,1009,1008,1038,13,1063,1064,1065,1034,1094,882,1104,1025,870,1503,1501]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1503,[835,979,1127,860,1160,1270,874,831,1028,1033,994,862,861,1104,1105,1025,1034,867,1504,1505]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1504,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1505,[839,846,849]); -__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1506,[828,34,283,364,236,402,102,846,794,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1507,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1508,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1509,[831,891,994,867,1503,1046,1097]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1510,[]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1511,[891,831,1028]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1512,[846]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1513,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1514,[846]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1515,[874,831,891,1038,15,1003,872,2,1516]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1516,[874,1038]); -__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1517,[]); -__d(function(e,o,s,p,c,t,d){"use strict";c.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1518,[]); -__d(function(o,e,s,p,f,t,d){"use strict";f.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1519,[]); -__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1520,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1521,[30,34,872,25]); -__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1522,[1523]); -__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1523,[25,1524,591]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1524,[34,172]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1525,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1526,[25,499,34,270,651]); +__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return Q.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return Q.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return Q.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return Q.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return Q.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ot}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ie.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ie.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ie.useOwner.getState().chatSeen(t,e)),$t(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ie.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...ht(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(fe.PITCH)return ge.unlockCashUp(e,t,a);const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?de.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):de.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(fe.PITCH)return ge.cashAudit(e);const t=Ae.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(_a.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=pa,i.readAccessLog=async function(){const e=Ae.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ae.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return ga}}),i.uploadOrderLogo=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(ga).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ma.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(ga).createSignedUrl(e,3600);if(t?.signedUrl)return ma.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(ga).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return _a}}),i.claimInvite=Ua,i.makeChromeHandover=async function(){const e=Ae.getState();if(fe.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ee});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(fe.PITCH||!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ee});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),Me&&qa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Ne();const t=await q.kv.get(Ia,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Ne(),await q.kv.get(Oa,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_WILDINGS||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Ne(),await q.kv.remove(Ia),await q.kv.remove(Oa),Ce({mode:'signin',perms:[]});try{await xa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ae.getState().venueId;if(fe.PITCH||!s||'staff'!==Ae.getState().kind)return{ok:!0};if(!(0,re.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Pa('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ua(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(fe.PITCH)return ge.reissueInvite(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Pa('staff_app_link_history',{p_venue:Ae.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Pa('revoke_staff_app_link',{p_venue:Ae.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(fe.PITCH)return ge.linkPhones();const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return{};try{const t=await Pa('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(fe.PITCH)return ge.resetPhone(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Number(await Pa('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(fe.PITCH)return ge.inviteStatus();const e=Ae.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:t,error:a}=await Re().rpc(d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_pairing_code':d.IS_GREENSIDE?'claim_greenside_pairing_code':d.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':d.IS_KIRKTON?'claim_kirkton_pairing_code':d.IS_WILDINGS?'claim_wildings_pairing_code':d.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':d.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await q.kv.set(ka,n),qa(),{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}`}}},i.carPairStart=async function(){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await q.kv.set(Ea,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ta(e)}}},i.carPairPoll=async function(e){try{Ne();const t=e??await q.kv.get(Ea,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,J.carPairApproved)(n)){const e=(0,J.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await q.kv.get(ka,null);await q.kv.set(ka,e),await q.kv.remove(Ia),A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||qa()}return'revoked'!==i&&'unknown'!==i||await Na(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Ne(),await Re().rpc('car_sign_out')}catch{}await Na(),await xa();try{await Re().auth.signOut({scope:'local'})}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Pa('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ta(e)}}},i.carList=async function(){const e=Ae.getState().venueId;if(!e)return[];return(await Pa('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Pa('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ta(e)}}},i.unpairDisplay=async function(){await q.kv.remove(ka),await xa();try{await Re().auth.signOut()}catch{}Ce({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await q.kv.remove(Ia),await q.kv.remove(Oa),await xa();try{await Re().auth.signOut()}catch{}Ce({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.'})},i.wipeThisDevice=async function(e={}){try{await xa()}catch{}try{(0,N.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${d.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!d.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Ka,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Pa}}),i.mendSession=La,i.startAppSync=async function(e=d.VENUE_RID){if(d.IS_ISOLATED_VENUE&&e!==d.VENUE_RID)return;if(Me)return;Me=!0,Ba=e,'customer'===Ee&&'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Ne(),'customer'!==Ee){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ee&&(0,y.isAnchorage)(e)?[V.useStore,ie.useOwner,se.useKitchen,ne.useSafety,X.useCardStore,_.useGpCalc,ee.useOrderSheets,h.useSpecials,C.useHr]:[V.useStore,ie.useOwner,se.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ee&&(0,y.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ce({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Os(e)}catch{if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e))return void Ce({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,N.isSupabaseConfigured)())return void Ce({mode:'off'});F.mutationQueue.subscribe(()=>{const e=F.mutationQueue.waiting,t=e[0];Ce({pending:F.mutationQueue.pending.length,failed:F.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,B.describeWrite)(t)}: ${(0,B.plainReason)({...t.lastErr},'retry')}`:void 0})}),F.mutationQueue.onFailed(e=>Ce({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:F.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,B.describeWrite)(e),why:'conflict'===e.reason?(0,B.plainReason)({code:'conflict'},'refused'):(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Pe.push((0,K.onConnectivity)(e=>Ce({mode:e?Ae.getState().venueId?'live':Ae.getState().mode:Ae.getState().venueId?'offline':Ae.getState().mode}))),await ja()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Qa}}),i.serverOrder=Za,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return Ya}}),i.nudgeGuestSync=function(){Xa?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return es}}),i.stockSaveBlocker=ts,i.stockEventStatus=function(e){if(Ze(e))return{state:'saved'};const t=F.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,B.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=as,i.saveStockEventsNow=ss,i.bookingSaveBlocker=is,i.resendUnsavedBookings=ds,i.saveBookingsNow=us,i.waitForBookingSave=function(e,t=12e3){if(!Ue())return Promise.resolve({state:'local'});const a=is();if(a)return Promise.resolve({state:'refused',why:a});const s=rs()[0]?.venueId??'',n=()=>ns.some(t=>F.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=$.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,K.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(F.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(F.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||rs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||rs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=gs,i.tempLogState=function(){const e=ms()[0]?.venueId??'',t=ms().find(e=>'temp_readings'===e.spec.table),a=F.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!F.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(W.useTempSaves.getState().notSaved),i=ne.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=_s,i.waitForTempSave=function(e,t,a=1e4){if(!Ue()||!ms().length)return Promise.resolve({state:'local'});const s=gs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ms()[0]?.venueId??'',i=ms().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>W.useTempSaves.getState().notSaved[(0,W.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>F.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=ws,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ms}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Ps.get(a);if('customer'!==Ee||!(0,N.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Ps.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Pa('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:Le(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:Le(a.from_time),to:Le(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Ps.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ms.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Ps.get(a);e&&!e.ok&&Ps.delete(a)}));const n=Ps.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ae.getState().venueId;if(!n||'staff'!==Ae.getState().kind)throw new Error('Connect to your venue first.');const i=await Pa('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});V.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return null;return(await Pa('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');await Pa('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),O=t(r[18]),R=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(pe),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]),Oe=t(r[71]);const Re=()=>(0,T.getSupabase)();F.mutationQueue.setExecutor(L.executeMutation),(0,M.setClockServer)(()=>'staff'===Ae.getState().kind);const Ae=(0,E.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ce=e=>Ae.setState(e),De=e=>{const t=Ae.getState().perms;return t.includes('*')||t.includes(e)},Ue=()=>{const e=Ae.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ae.subscribe(()=>(0,be.setLiveData)(Ue()));let Ee=G.IS_CAR?'car':G.APP_VARIANT,Te=!1;const Ne=()=>{Te||((0,q.setSyncNamespace)(Ee),Te=!0)};let Ke=[],Pe=[],Me=!1;const xe=()=>(new Date).toISOString().slice(0,10),qe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),Le=e=>e?e.slice(0,5):'',Be=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))):[],je=e=>JSON.parse(JSON.stringify(e));function Fe(e,t){const a=qe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>V.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=je(e);if(t)return{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:Be(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,re.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:Be(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function $e(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>V.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.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,re.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:je(e.lines??[]),allergies:Be(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:je(e.allergyChain??{}),readiness:je(e.readiness??{}),allergy_ticks:je(e.allergyTicks??{}),handover_check:e.handoverCheck?je(e.handoverCheck):null,accepted:e.accepted?je(e.accepted):null,doc:je(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)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function We(e){const t=qe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...z.useBlocks.getState().blocks,...z.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Ae.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:je(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,z.blockClock)(t.from_time)??a?.from,n=(0,z.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>z.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>z.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Qe=null,He='Main plan';function Ve(e){const t=e=>je({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(Z.useFloor.getState().plans[e]??(0,Z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>De('floor.manage')||De('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Qe??(0,ke.uuidFrom)(`plan:${a}`),venue_id:a,name:He||'Main plan',is_active:!0,...t(e),updated_by:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>(Qe=String(e.id),He=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,Ie.withSeedBest)(e,t[0]):void 0;a&&Z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>Z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ge(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Y.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>De('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,re.isUuid)(e.supplierId)?e.supplierId:(0,ke.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),dt.get(t)??t)}:{}};var t},apply:(t,a)=>Y.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Je=new Set,ze=new Set;F.mutationQueue.onDone(e=>{'stock_events'===e.table&&ze.add(e.rowKey)});const Ze=e=>ze.has(e)||Je.has(e),Ye=()=>De('*')||De('staff.manage')||De('recipes.edit')||De('recipes.signoff'),Xe=()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write'));function et(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Y.useShellStore.getState().events.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,re.isUuid)(t.id)&&!!(Y.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('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,re.isUuid)(e.undoes)&&(Ze(e.undoes)||F.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Je.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)=>Y.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function tt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Y.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={...Y.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Y.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Je]}}}))},afterRead:()=>{Y.useShellStore.getState().server[e]||Y.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Je]}}}))},subscribe:()=>()=>{}}}const at=new Set;function st(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=V.useStore.getState().menu;return X.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:t=>(0,re.isUuid)(t.card.id)&&!((0,y.isAnchorage)(e)&&(0,y.isDemoCard)(t.card))&&!(0,y.isPlaceholderCard)(t.card),writable:()=>De('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,y.isAnchorage)(e)&&(s={...s,signOff:(0,y.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,y.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,y.isAnchorage)(e)&&(0,y.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,ke.photoPath)(a,s),t=nt(s.photo);t&&((0,X.cachePhotoAs)(e,t),it(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,ke.cardToRow)(s,a);return{...i,...r,doc:je({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,y.isPlaceholderCard)(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,signOff:(0,y.isAnchorage)(e)&&(0,y.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!De('recipes.edit')&&t.length){const e=new Set(t);X.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);X.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&V.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&V.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=X.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=V.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const nt=e=>(0,X.readLocalPhoto)(e);async function it(e,t){if(!at.has(e)){at.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(ke.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){at.delete(e),Ce({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const rt=new Map,ot=(0,E.create)(()=>({n:0}));(0,X.setStoragePhotoResolver)(e=>{const t=rt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,N.isSupabaseConfigured)()&&'off'!==Ae.getState().mode?(t||(rt.set(e,{url:'',at:Date.now()}),Re().storage.from(ke.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(rt.set(e,{url:t.signedUrl,at:Date.now()}),ot.setState(e=>({n:e.n+1})),X.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const dt=new Map;const ut=(e,t)=>{const a=(0,re.isUuid)(t)?t:(0,ke.uuidFrom)(`sup:${e}:${t}`);return dt.set(a,t),a};function ct(e){return{name:'order_sheets',table:'suppliers',list:()=>ee.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,y.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>De('suppliers.manage'),toRow:(e,t)=>({id:ut(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:je(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(dt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ee.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ee.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,re.isUuid)(e)?e:(0,ke.uuidFrom)(`sup:${Ae.getState().venueId}:${e}`)})}}let lt=!1,ft=!1;const pt=new Map,gt=new Map,mt=new Map,_t=new Map,St=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ht=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'},yt=(e,t)=>({...e,managerAccess:t}),wt=()=>({nickname:lt,display:ft}),vt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=yt({role:e.role,level:e.level??ht(St(e)).level},!0===e.managerAccess);return(0,j.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},wt())};const bt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},kt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},It=e=>{const t=ie.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ot=2e3;function Rt(e,t){return t||!e.length||e.length>=Ot?null:e=>(0,re.isUuid)(e.id)}function At(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,De('rota.manage')):null,keepOnEmpty:()=>e&&!De('rota.manage'),list:()=>ie.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&pt.has(e.staffId)&&(De('rota.manage')||It(e.staffId)),writable:()=>De('rota.manage')||De('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(bt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:kt(e.start),end_time:kt(e.end),published:!!e.published,doc:je(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Ct(){const e=qe(62),t=e=>De('rota.manage')||e.staffId===Ae.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ie.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ae.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=qe(2)&&e.staffId===Ae.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:je(e.breaks??[]),break_mins:e.breakMins??0,doc:je((0,w.privateAttendance)(d.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,w.privateAttendance)(d.VENUE_RID,{...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Dt(){const e=qe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.staffId===Ae.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ae.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:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,re.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:je({...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Ut(e){ie.leaveRemote.decide=t=>!(!De('rota.manage')||!(0,re.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(F.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Pe.push(()=>{ie.leaveRemote.decide=null})}function Et(e){ie.timesheetRemote.send=(t,a)=>{if(!De('rota.manage')||!(0,re.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return F.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:je(s)}}),!0}const s=a;if('attendance_void'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return F.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:je(s.breaks??[]),p_reason:n,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0},Pe.push(()=>{ie.timesheetRemote.send=null})}function Tt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>V.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ae.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,re.isUuid)(a)?a:(0,ke.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,re.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:je(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>V.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=>V.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Nt=e=>V.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Kt(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}));V.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Pt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=V.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[je({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:Z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Nt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>De('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...xt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...xt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...xt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Mt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Mt=t.feature_flags??{},xt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),je({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}:{}})},apply:t=>{const a=t[0];a&&(V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&Z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Kt(e,a.events))},subscribe:e=>{const t=V.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=Z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Mt=null,xt=null;const qt=()=>new Date(Date.now()-2592e6).toISOString(),Lt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Bt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>gt.get(e));return 2===t.length&&t[0]&&t[1]?(0,he.dmId)(t[0],t[1]):null},jt=()=>Ae.getState().perms.includes('*');function Ft(){const e=()=>Ae.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ie.useOwner.getState().chat.filter(e=>(0,re.isUuid)(e.id)).map(e=>je({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=>!!Lt(t.ch)&&(t.from===e()||jt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('created_at',qt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=qt(),toRow:(e,t)=>{const a=Lt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:pt.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=Bt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?gt.get(String(e.from_staff)):'system';return s?je({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ie.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?gt.get(String(t.from_staff)):'system',i=Bt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ie.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,he.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,ye.soundAllowed)())try{(0,ye.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,k.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function $t(e,t,a){const s=Ae.getState();if(!Se.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=pt.get(e),i='*'===t?'*':Lt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Wt(e){const t=Ae.getState().staffRef,a=t?pt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Bt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ie.useOwner.getState().chatMarkRead(t,i)}catch{}}function Qt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=D.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:je(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>D.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,U.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Ht(e){const t=qe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>D.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.reminderId)&&e.staffRef===Ae.getState().staffRef,writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>D.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Vt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Gt=e=>null==e||''===e?null:Number(e),Jt=e=>e.filter(e=>!e.startsWith('data:')),zt=()=>De('takings.view');function Zt(e){const t=!zt();return{name:'cash_ups',table:'cash_ups',list:()=>de.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',qe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:je(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({cashUps:Vt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Yt(e){return{name:'sales_reports',table:'sales_reports',list:()=>de.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:je(e.vals),categories:e.categories,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({sales:Vt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Xt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=de.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,de.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:je({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,de.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>de.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ea(e){return{name:'day_tips',table:'day_tips',list:()=>de.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',qe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>de.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ta(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>de.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Gt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>de.useCashUp.setState(s=>({pot:Vt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function aa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=de.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>De('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>de.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function sa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>oe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:je(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>oe.useNotifs.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>oe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function na(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ue.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:je(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ue.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ce.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Vt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ia(e){const t=()=>De('venue.settings')||De('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ue.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,re.isUuid)(a.id)&&(0,re.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ue.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ae.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ae.getState().staffRef)||null,doc:je(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ra(e){const t=qe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ue.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:je(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({history:Vt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function oa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=le.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:je(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>De('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&le.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,w.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>le.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function da(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=me.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,me.libraryRowId)(e),kind:'library',doc:je({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,me.personRowId)(e,i),kind:'person',staffRef:i,doc:je({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ie.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,_e.canEditTasks)(t,a)},writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>me.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,me.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ua(e){const t=qe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>me.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ae.getState();return e.byRef===t.staffRef||De('staff.manage')},writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>me.useDailyTasks.setState(s=>({ticks:Vt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ca(e,t=!1){const a=qe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>we.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind||De('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,ke.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>we.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>we.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{ve.autoSync.soldOutRead.add(e)}}}function la(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>ve.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:(0,ke.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>ve.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>ve.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{ve.autoSync.linksRead.add(e)}}}async function fa(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&q.kv.get(a,!1):(q.kv.set(a,!0),!0)}catch{return q.kv.get(a,!1)}}async function pa(){const e=Ae.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();_a.setState({live:!!t?.push_live,known:!0})}catch{}}const ga='order-list-logos';const ma=new Map;const _a=(0,E.create)(()=>({live:!1,known:!1}));async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('reminders:ok',!1):(q.kv.set('reminders:ok',!0),!0)}catch{return q.kv.get('reminders:ok',!1)}}async function ha(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('chat:ok',!1):(q.kv.set('chat:ok',!0),!0)}catch{return q.kv.get('chat:ok',!1)}}const ya=(e,t)=>je({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),wa='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function va(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>C.useHr.getState().questions.filter(t=>t.venue===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ya(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);C.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>C.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function ba(e,t){const a=(t,a,s)=>{F.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(C.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(wa).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||C.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ya(e,t)))}catch{}}}),Pe.push(()=>{Object.assign(C.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ka='pair:v1',Ia='staff:v1',Oa='staff:rejoin:v1';async function Ra(e){const t=d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_invite':d.IS_GREENSIDE?'claim_greenside_invite':d.IS_ABBOTSFORD?'claim_abbotsford_invite':d.IS_KIRKTON?'claim_kirkton_invite':d.IS_WILDINGS?'claim_wildings_invite':d.IS_KIRKMICHAEL?'claim_kirkmichael_invite':d.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ee,p_device:(0,A.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,A.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Aa(){if('display'===Ee||'customer'===Ee||fe.PITCH)return'none';const e=await q.kv.get(Oa,null);if(!e)return'none';try{await Da();const{data:t,error:a}=await Ra(e);if(a)return(0,O.inviteRefusal)(a.message)?(await q.kv.remove(Oa),await q.kv.remove(Ia),'refused'):'offline';const s=t?.[0];return s?(await q.kv.set(Ia,{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,displayName:s.display_name}),'ok'):(await q.kv.remove(Oa),'refused')}catch{return'offline'}}const Ca=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Da(){Ne();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ce({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 Ua(e){if(fe.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Ra(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,d.venueKey)(`cc-pending-invite:${Ee}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),await q.kv.set(Oa,e),Me&&qa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ce({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ea='car:request:v1',Ta=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Na(){await q.kv.remove(ka),await q.kv.remove(Ia),await q.kv.remove(Ea),A.useSession.getState().meId&&A.useSession.getState().signOut()}async function Ka(){if(!(0,N.isSupabaseConfigured)())return!1;try{return await Da(),!0}catch{return!1}}const Pa=async(e,t={})=>{if(fe.PITCH)return(0,pe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Ma=null;async function xa(){for(const e of Pe)try{e()}catch{}Pe=[],Ke.forEach(e=>e.stop()),Ke=[],Ma&&(clearInterval(Ma),Ma=null)}async function qa(){await xa(),await ja()}async function La(){if(!(0,N.isSupabaseConfigured)()||'customer'===Ee||fe.PITCH)return!1;try{Ne();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ee)return!1;if(!await q.kv.get(Oa,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Aa()&&(qa(),!0)}catch{return!1}}(0,c.setSessionMender)(La);let Ba=d.VENUE_RID;async function ja(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Ba;try{if(Ce({mode:'connecting'}),await F.mutationQueue.load(),'customer'===Ee)return void await Va(e);let t=await q.kv.get(ka,null),a=await q.kv.get(Ia,null);if(G.IS_CAR&&!t&&a){const e=(0,J.migrateCarStaffIdentity)(a);e&&(t=e,await q.kv.set(ka,t)),await q.kv.remove(Ia),a=null,A.useSession.getState().meId&&A.useSession.getState().signOut()}if(d.IS_ISOLATED_VENUE&&(t&&!(0,d.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,d.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ce({mode:'display'===Ee?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ee&&!G.IS_CAR&&a&&!s.session){const t=await Aa();if('offline'===t)return Ce({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Ba===e&&qa()},6e4);'refused'===t&&a.staffRef&&A.useSession.getState().meId===a.staffRef&&A.useSession.getState().signOut(),a=await q.kv.get(Ia,null),({data:s}=await Re().auth.getSession())}const n='display'===Ee||G.IS_CAR?t:a;if(!s.session||!n)return void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Pa('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ee||G.IS_CAR?await q.kv.remove(ka):(await q.kv.remove(Ia),await q.kv.remove(Oa)),'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId===n.staffRef&&A.useSession.getState().signOut(),void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ee?'This display was unpaired by a manager.':G.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,K.isOnline)()||/fetch|network/i.test(String(t?.message)))Ce({mode:'offline'});else if(Ca(t)&&'display'!==Ee){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Aa()&&setTimeout(()=>{Ba===e&&qa()},500)}i=Ae.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ce({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!G.IS_CAR&&'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId!==n.staffRef&&(A.useSession.getState().signIn(n.staffRef),ie.useOwner.setState({staffAs:n.staffRef})),G.IS_CAR&&(A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({previewRole:'owner'})),await $a(n.venueId,e,n.kind)}catch(e){Ce({mode:'local',lastError:String(e?.message??e)})}}const Fa=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','venue_reminders','reminder_done']);async function $a(e,a,s){if(!(0,d.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||G.IS_CAR&&'device'===s;await ws(a),Pe.push(Ks(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])mt.set(e.key,e.id),_t.set(e.id,e.key)}catch{}const i=[Pt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ie.useOwner.getState().staff.map(vt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>De('staff.manage'),deletes:!1,revision:e=>(0,j.staffRevision)(e,wt()),toRow:(e,t)=>(0,j.staffRow)(e,t,wt(),e.managerAccess||e.ownerAccess?null:mt.get(St(e))),fromRow:e=>{if(!e.external_ref)return null;pt.set(String(e.external_ref),String(e.id)),gt.set(String(e.id),String(e.external_ref)),Us.set(String(e.external_ref),e.avatar_path??null);const t=yt(ht(_t.get(String(e.role_id))),!0===e.manager_access);return(0,j.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},wt())},apply:e=>ie.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=>ie.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ns()},onRemote:()=>{Ns()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ie.useOwner.getState(),t=ae.useSetup.getState().sites[Ba]?.staffGrade??{};return e.staff.filter(e=>pt.has(e.id)).map(a=>je({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=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:pt.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=gt.get(String(e.staff_id));return t?je({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=>ie.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=ae.useSetup.getState().sites[Ba],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&&ae.useSetup.getState().patch(Ba,{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=ie.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=ae.useSetup.subscribe((t,a)=>{t.sites[Ba]?.staffGrade!==a.sites[Ba]?.staffGrade&&e()});return()=>{t(),a()}}},Fe(a,!1),Fe(a,!0),We(a),Ve(a),$e(a),Ge(a),et(a),tt(a),ct(a),{name:'supplier_directory',table:'suppliers',list:()=>ie.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('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:je(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ie.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId),writable:()=>De('suppliers.order')||De('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||xe(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:je(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},st(a),As(a)];De('wages.view')&&i.push(Cs(a)),n&&(i.push(At(!0),Ct(),Dt(),Tt(a)),Et(e)),n&&await fa('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ae.getState().staffRef&&'pending'===e.status||De('rota.manage')),writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:je(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Fa.add('staff_leave'),Ut(e));const o=n&&await ha();if(Se.useChatSync.setState({synced:o,checked:!0}),Pe.push(()=>Se.useChatSync.setState({synced:!1})),o&&i.push(Ft(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(he.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:pt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:pt.get(e.id),include:e.include}),fromRow:e=>{const t=gt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>he.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=>he.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await fa('hr_questions')&&(i.push(va(a)),Fa.add('hr_questions'),ba(e,a)),'guest'!==s&&'customer'!==Ee&&await fa('temp_readings')&&(i.push((0,Q.tempUnitsSpec)(ne.useSafety,Ye),(0,Q.tempReadingsSpec)(ne.useSafety,Xe)),Fa.add('temp_units'),Fa.add('temp_readings')),'guest'!==s&&await fa('sold_out_items')?(i.push(ca(a,await fa('sold_out_items','auto'))),Fa.add('sold_out_items')):ve.autoSync.soldOutRead.add(a),'guest'!==s&&await fa('sold_out_links')?(i.push(la(a)),Fa.add('sold_out_links')):ve.autoSync.linksRead.add(a),D.useReminders.getState().ensure(a),'guest'!==s&&await Sa()&&(i.push(Qt(a)),n&&i.push(Ht(a))),oe.useNotifs.getState().ensure(a),ue.useOrderLists.getState().ensure(a),n){lt=await fa('staff','nickname'),ft=await fa('staff','display_clock');const[e,t,s,n]=await Promise.all([fa('scheduled_notifications'),fa('order_lists'),fa('venue_clock_area'),fa('daily_tasks')]);me.useDailyTasks.getState().ensure(a),n&&(i.push(da(a),ua(a)),Fa.add('daily_tasks'),Fa.add('daily_task_ticks')),e&&(i.push(sa(a)),pa()),t&&i.push(na(a),ia(a),ra(a)),s&&i.push(oa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Fa.add(n)}if('guest'!==s&&await fa('day_tips')){i.push(ea(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Fa.add(e);await fa('tips_pot_events')&&i.push(ta(a),aa(a)),n&&(zt()||(0,de.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(Zt(a),Xt(a)),Fa.add('cash_ups'),zt()&&(i.push(Yt(a)),Fa.add('sales_reports')),t(r[73])(r[72],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(At(),Ct()),await fa('scheduled_notifications')&&i.push(sa(a)));let u=!1;const c=()=>{if(G.IS_CAR&&n&&De('recipes.edit'))return!0;const e=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);return!!e&&e.active&&De('recipes.edit')&&(0,S.costsAllowedFor)(e)};n&&c()&&await fa('ingredient_prices')&&(i.push((0,_.gpSyncSpec)('ing',c)),Fa.add('ingredient_prices'),await fa('card_costs')&&(i.push((0,_.gpSyncSpec)('card',c)),Fa.add('card_costs')),await fa('kitchen_deliveries')&&(i.push((0,_.gpSyncSpec)('del',c)),Fa.add('kitchen_deliveries')),await fa('kitchen_stock_counts')&&(i.push((0,_.gpSyncSpec)('count',c)),Fa.add('kitchen_stock_counts'))),(0,Oe.specialsSyncOn)()&&'guest'!==s&&await fa('specials_boards')&&(i.push((0,Oe.specialsBoardSpec)(a,()=>De('recipes.edit')||De('floor.manage')||De('*'))),Fa.add('specials_boards'));const l={onActivity:()=>Ce({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ce({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ce({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Pa('whoami')??[]).some(t=>t.venue_id===e))return void(Ba===a&&qa());for(const a of Ke){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||$.useBookingSaves.getState().mark({id:t,table:e,why:is()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||W.useTempSaves.getState().mark({id:t,table:e,why:gs(e)??'this screen could not send it'})}};Ke=i.map(t=>new H.EntityBridge(t,e,l)),await Promise.all(Ke.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,K.isOnline)())try{const t=await Pa('whoami');if(!t?.some(t=>t.venue_id===e))return void(Ba===a&&qa())}catch(e){if(Ca(e)){if(G.IS_CAR)return void(Ba===a&&qa());const e=await Aa();return void('ok'!==e&&'refused'!==e||Ba===a&&qa())}}let t=0;for(const[a,s]of Ke.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(Se.useChatSync.getState().error&&Se.useChatSync.setState({error:void 0}),await Wt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&Se.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({mode:'live',lastSyncAt:e,lastServerAt:e}),F.mutationQueue.flush()}else Ce({mode:'offline'});if(!De('wages.view')){const e=Ae.getState().staffRef;ie.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const m=new Map;for(const e of Ke)m.set(e.spec.table,[...m.get(e.spec.table)??[],e]);const h=[...m.keys()].filter(e=>Fa.has(e)).map(e=>({table:e,venueColumn:m.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,H.venueChannel)(e,h,(e,t,a)=>{for(const s of m.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ce({lastSyncAt:s,lastServerAt:s})},e=>{Ce({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Pe.push(()=>{Re().removeChannel(w)}),Pe.push((0,K.onConnectivity)(e=>{e&&p()}));const v=Ke.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,P.superviseSync)({fastMs:Qa(Ee),readFast:async()=>{for(const e of v)await e.read()},readAll:p,flush:()=>{F.mutationQueue.flush()},wake:()=>{F.mutationQueue.retryNow()},restart:()=>{Ba===a&&qa()},realtime:()=>Ae.getState().realtime,lastServerAt:()=>{const e=Ae.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Ca,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>Wa(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Pe.push(k.stop)}async function Wa(e){const t=Ae.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Pa('sync_heartbeat',{p_venue:e,p_device:(0,A.deviceId)()??'unknown',p_app:Ee,p_version:x.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Qa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ae.getState(),queue:F.mutationQueue.pending.map(e=>e.table),failedTables:F.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),fe.PITCH&&(window.__ccSyncPreview=e=>Ce(e)));const Ha='guest:sent:v1';async function Va(e){Ce({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Pa('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!d.IS_ISOLATED_VENUE||t.id===d.VENUE_UUID)){Ce({venueId:t.id,venueName:t.name}),await ws(e);const a=t.app?.restaurant;a&&V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withWildingsAddress)({...a,id:e}):t)})),Kt(e,t.app?.events)}await Ga(e),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ce({mode:(0,K.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Ga(e).catch(()=>{})},6e4);Pe.push(()=>clearInterval(t)),d.IS_ISOLATED_VENUE||await Ja(e)}async function Ga(e){const t=await Pa('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));X.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&V.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))]}});try{const t=await Pa('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function Ja(e){let t=await q.kv.get(Ha,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=V.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Ka())return;for(const a of n)try{const s=(await Pa('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(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&&V.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'},Ce({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Pa('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(a.allergies)}}))?.[0];t={...t,[a.id]:'order'},s&&V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?Za(e,s):e)}))}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ce({lastError:`Order: ${s}`}),V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:Ya(s)}}:e)})))}await q.kv.set(Ha,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Pa('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await q.kv.set(Ha,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Pa('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));V.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=Za(e,a);return za(s)===za(e)?e:s})})),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ce({mode:(0,K.isOnline)()?Ae.getState().mode:'offline'})}finally{a=!1}}};Pe.push(V.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Ma=setInterval(()=>{n()},15e3),Xa=()=>{n()},n()}const za=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function Za(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const Ya=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let Xa=null;const es={bridges:()=>Ke,restart:qa};function ts(){const e=Ae.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!De('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function as(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(!e||ts())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(F.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function ss(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}as();try{await F.mutationQueue.retryNow()}catch{}}Ae.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{ss()},3e3)});const ns=['bookings','walk_ins'];function is(){const e=Ae.getState();return Ue()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const rs=()=>Ke.filter(e=>ns.includes(e.spec.table)),os=e=>F.mutationQueue.failed.some(t=>ns.includes(t.table)&&t.rowKey===e);function ds(e=!1){return is()?0:rs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&os(t)&&!!$.useBookingSaves.getState().notSaved[t]),0)}async function us(e=!1){const t=is();if(t)return t;for(const e of rs())try{await e.read()}catch{}ds(e);try{await F.mutationQueue.retryNow()}catch{}return e&&cs(),null}function cs(){const e=rs()[0]?.venueId??'',t=$.useBookingSaves.getState(),a=new Set(rs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||os(s)||ns.some(t=>F.mutationQueue.hasPending(t,e,s))||t.clear(s)}F.mutationQueue.onFailed(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().clear(e.rowKey)});let ls=null;const fs=(e=2500)=>{ls&&clearTimeout(ls),ls=setTimeout(()=>{ls=null,us(!1)},e)};(0,K.onConnectivity)(e=>{e&&fs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&fs(3e3)});const ps=['temp_readings','temp_units'];function gs(e="temp_readings"){const t=Ae.getState();return Ue()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ye()?'device'!==t.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ms=()=>Ke.filter(e=>ps.includes(e.spec.table));async function _s(e=!1){const t=gs();if(t)return t;for(const e of ms())try{await e.read()}catch{}const a=ms()[0]?.venueId??'';for(const t of ms())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,F.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await F.mutationQueue.retryNow()}catch{}if(e){const e=W.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ms().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||F.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,W.tempKey)(t.table,t.id))}}return null}F.mutationQueue.onFailed(e=>{ps.includes(e.table)&&W.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ps.includes(e.table)&&W.useTempSaves.getState().clear((0,W.tempKey)(e.table,e.rowKey))});let Ss=null;const hs=(e=3e3)=>{Ss&&clearTimeout(Ss),Ss=setTimeout(()=>{Ss=null,_s(!1)},e)};(0,K.onConnectivity)(e=>{e&&hs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3500)});const ys='golive:v1:';async function ws(e){'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)?await Os(e):(await q.kv.get(ys+e,!1)||await Os(e),await q.kv.get(ks+e,!1)||(Is(e),await q.kv.set(ks+e,!0)),await q.kv.get(vs+e,!1)||(bs(),await q.kv.set(vs+e,!0)))}const vs='golive:v3:';function bs(){const e=e=>JSON.stringify(e).includes('(example)');try{se.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ks='golive:v2:';function Is(e){const t=e=>JSON.stringify(e).includes('(example)');V.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)))})),ie.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 Os(e){if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)){const t=(0,g.stripCoreLiveSamples)(V.useStore.getState()),a=(0,se.stripKitchenExamples)(se.useKitchen.getState()),s=ie.useOwner.getState(),n=(0,g.stripOwnerLiveSamples)(s),i={accidents:ne.useSafety.getState().accidents.filter(e=>!(0,ne.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(V.useStore.getState(),t)&&(await(0,m.archiveChefCache)('core',V.useStore.getState()),V.useStore.setState(t)),r(se.useKitchen.getState(),a)&&(await(0,m.archiveChefCache)('kitchen',se.useKitchen.getState()),se.useKitchen.setState(a)),r(s,n)&&(await(0,m.archiveChefCache)('owner',s),ie.useOwner.setState(n)),r(ne.useSafety.getState(),i)&&(await(0,m.archiveChefCache)('safety',ne.useSafety.getState()),ne.useSafety.setState(i));const o=(0,C.stripHrSamples)(C.useHr.getState());r(C.useHr.getState(),o)&&(await(0,m.archiveChefCache)('hr',C.useHr.getState()),C.useHr.setState(o));const d=(0,_.stripGpSamples)(_.useGpCalc.getState());r(_.useGpCalc.getState(),d)&&(await(0,m.archiveChefCache)('gp',_.useGpCalc.getState()),_.useGpCalc.setState(d));const u=ee.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,m.archiveChefCache)('order-sheets',u),ee.useOrderSheets.setState(c));const l=X.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,p.isLiveVenue)(e.restaurantId)||!(0,y.isDemoCard)(e)),log:l.log.filter(e=>!(0,y.demoActor)(e.by))};return r(l,f)&&(await(0,m.archiveChefCache)('recipe-cards',l),X.useCardStore.setState(f)),void await q.kv.set(ys+e,!0)}const t=t=>t.restaurantId===e&&!(0,re.isUuid)(t.id);V.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)))})),z.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,re.isUuid)(t.id))})),Z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ie.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,re.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,re.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,re.isUuid)(e.id)),leave:e.leave.filter(e=>(0,re.isUuid)(e.id)),swaps:[]}));try{se.useKitchen.setState(e=>(0,se.stripKitchenExamples)(e))}catch{}ie.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,re.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId))}));try{ne.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await q.kv.set(ys+e,!0)}const Rs=(e,t)=>je({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function As(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(Z.useFloor.getState().live[e]??{}).map(([e,t])=>Rs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ae.getState().kind||De('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:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>Rs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>Z.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=>Z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Cs(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(ae.useSetup.getState().sites[e]?.grades??ae.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:()=>De('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=ae.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));ae.useSetup.getState().patch(e,{grades:i})},subscribe:t=>ae.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ds='staff-avatars',Us=new Map;let Es=!1;const Ts=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ns(){if(!Es){Es=!0;try{for(const[e,t]of Us){const a=te.useAvatars.getState().photos[e];if(!t){a?.path&&te.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ae.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Ds).download(t);if(n||!s)continue;const i=await Ts(s);i.startsWith('data:image/')&&te.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{Es=!1}}}function Ks(e){const t=async()=>{const t=Ae.getState().staffRef,a=t?pt.get(t)??Ae.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ae.getState().kind)return;const s=te.useAvatars.getState().photos[t];try{const n=Us.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Ds).remove([t]).catch(()=>{})};if(!s){const e=!!te.useAvatars.getState().clears?.[t];return e&&n&&(await Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}),Us.set(t,null),i(n)),void(e&&te.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ce({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Ds).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Pa('set_staff_avatar',{p_staff_ref:t,p_path:d}),Us.set(t,d),n!==d&&i(n),te.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ce({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:te.useAvatars.getState().photos},s=te.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),De('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ae.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Us.set(t,null),te.useAvatars.getState().doneClear(t),Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Ds).remove([e])).catch(()=>{})}});return t(),s}const Ps=new Map,Ms=(0,E.create)(()=>({n:0}))},987,[988,5,989,932,6,832,837,833,838,990,994,995,835,997,999,1000,1001,1002,1003,13,1004,1006,1009,1010,846,933,976,1011,1012,1013,1016,977,1017,1015,1020,1014,1021,1022,1023,1024,831,872,1025,1026,1029,983,883,1031,926,927,1033,1034,891,870,1036,1039,1040,1041,1042,2,1043,1044,1045,1046,1047,1048,979,981,884,863,859,1049,1052,1053]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},988,[846]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},990,[837,34,838,5,839,846,849,991,863,870,992,993]); +__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},991,[984]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},992,[991]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},993,[991,992]); +__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},994,[]); +__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},995,[835,837,838,5,839,846,849,996,831,884]); +__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'}}]},996,[]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},997,[6,998]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},999,[846]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},1000,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1001,[846]); +__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1002,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1003,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1004,[839,846,849,5,872,1005,15,1003]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1005,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1006,[838,835,837,5,839,846,849,1007,870]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1008,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1009,[839,846,849,863,1010,870]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1010,[]); +__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)))},1011,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1012,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1013,[34,1014]); +__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1014,[1011,977,1015]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1015,[1011]); +__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.3.12.172'},1016,[]); +__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1017,[1018,1019,933,977,1014]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1019,[977]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1020,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1021,[846,849,839]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1022,[846,849,839]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1023,[1024]); +__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1024,[1018,933,1011,977,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1025,[]); +__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1026,[860,839,870,846,849,858,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1028,[891,1004,1027]); +__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1029,[5,860,839,1030,846,849,859]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1030,[1008]); +__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1031,[837,838,5,839,846,849,1032]); +__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1032,[984]); +__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1033,[837,984,838,835,5,839,846,849]); +__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1034,[837,838,5,839,846,849,1035]); +__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1035,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1036,[839,846,849,863,1037,15,870,1038]); +__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1037,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1038,[]); +__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1039,[34,839,846,849,863,13,870]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1040,[839,846,849,863,1041,870,1038]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1041,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1042,[5,997,839,846,849,998]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1043,[1039]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1044,[839,846,849,863,1045,870]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1045,[]); +__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},1046,[846]); +__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(':')}`},1047,[839,846,849]); +__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{}}},1048,[236,872]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1049,[995,1050,1051,976,933]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1051,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1052,[933,987,999]); +__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1053,[1054]); +__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1054,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1055,[34]); +__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1056,[34,236,402,102,846,821,794,1055,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1057,[34,102,794,1058,821,1059,25]); +__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1058,[827,34,379,236,402,102,821,987,1059,2,872,1016,5,796,797,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1059,[1060,933,987,872,236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1060,[]); +__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1061,[827,796,34,402,102,794,821,1044,1045,1010,1001,870,891,25]); +__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1062,[828,1063,796,827,34,281,283,364,336,402,102,426,794,821,1039,831,13,1064,1065,1001,1075,1080,1081,1084,1085,1086,1093,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1063,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1064,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1065,[34,876,1066,1067,1064]); +__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1066,[839,846,849]); +__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1067,[6,1068,1069,1070,1071,1072,1073,1074,3]); +__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1068,[]); +__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1069,[]); +__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1070,[]); +__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1071,[]); +__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1072,[]); +__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1073,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1074,[1064]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1075,[236,933,987,1076]); +__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})},1076,[499,1077,1079,1078]); +__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1077,[499,1078,1079]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1078,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1079,[1078]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1080,[933,987]); +__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1081,[34,281,236,102,794,1039,13,1082,821,1083,25]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1082,[13]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1083,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1084,[827,2,34,102,794,821,1039,891,13,987,1001,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1085,[13]); +__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1086,[34,1063,281,402,102,794,1087,1088,1092,1093,821,25]); +__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1087,[34,402,102,794,821,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1088,[837,34,874,891,858,872,1025,987,1089,1004,15,1091]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1089,[1090]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1090,[1091]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1091,[858]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1092,[34,872,1093,858,987,933]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1093,[]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1094,[34,1095,891,1009,1010,1001,1047,831,1098]); +__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1095,[997,1042,891,998,1096,1097]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1096,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1097,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1098,[]); +__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1099,[34,986,402,102,1100,794,874,1101,858,1102,821,25]); +__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)'}})]})}},1100,[34,281,283,364,102,1048,821,25]); +__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1101,[861,859]); +__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1102,[34,402,102,794,1101,858,821,25]); +__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1103,[34,102,794,874,877,821,25]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1104,[860,34,102,794,874,1026,1029,1105,1106,877,821,25]); +__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1105,[1029,859,1101]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1106,[860,877]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1107,[860,34,102,794,874,983,891,1101,858,821,25]); +__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1108,[828,827,1056,34,336,379,236,402,102,794,821,1040,1041,1001,1109,1110,987,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1109,[1076,236]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1110,[839,846,849]); +__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1111,[827,997,34,379,402,102,794,821,1036,1037,891,1040,1041,1042,998,1096,987,1059,1001,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1112,[34,1036,891,1040,1113,1009,831,1037,1001,1094]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1113,[846]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1114,[997,34,1042,891,831,998,1010,1096,1001,1095]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1115,[860,34,1001,874,1101,1048]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1116,[860,1117,34,102,794,874,1101,821,1118,1107,1119,1140,1143,1099,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1117,[34,102,14,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1118,[821]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1119,[34,102,1120,821,1121,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1120,[860,1105]); +__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1121,[1122,860,34,1123,987,1125,402,102,874,1029,1120,1124,821,858,794,1126,1026,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1122,[34,859,821,794,25]); +__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1123,[34,402,102,874,1124,1125,987,1021,821,1121,794,25]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1124,[860,1105]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1125,[281,236]); +__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1126,[827,1127,1128,860,867,14,1129,1130,34,859,402,102,872,1088,874,1131,1105,858,821,864,794,1029,1026,1132,1133,1138,1107,1101,1139,1124,1123,25]); +__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1127,[34,402,412,102,1128,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1128,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1129,[34,102,794,25]); +__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1130,[34,236,402,295,102,426,821,794,1001,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1131,[878,858,877]); +__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1132,[34,402,102,878,858,821,794,25]); +__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1133,[860,877,34,102,879,1134,1135,1137,794,874,1029,983,861,867,872,1101,821,25]); +__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1134,[34,402,821,794,25]); +__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1135,[828,860,1136,34,281,236,102,1029,1105,821,794,1107,859,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1137,[34,402,102,874,861,863,821,794,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1138,[1128,1120,1124]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1139,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1140,[1141,34,102,874,1029,1124,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1141,[34,102,874,1029,1120,1142,1124,821,1004,891,872,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1142,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1143,[34,1063,1127,102,874,1029,1026,876,872,1138,861,1004,891,1027,1120,821,858,1132,1117,1129,1144,14,1141,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1144,[34,102,874,872,1138,14,1125,821,794,25]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1145,[34,102,794,1063,1093,1146,1092,1086,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1146,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1147,[34,102,794,827,1034,891,835,1148,821,1149,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1148,[1035]); +__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1149,[34,402,102,1125,987,1150,1022,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1150,[933,976,1011,1019,1014,1017,1151,1152,1153,1154,1155,1156,977]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1151,[1019,933,1017]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1152,[1019,933,976,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1153,[1011,976,1152,1014,1017,1151]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1154,[933,977]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1155,[34,1014]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1156,[933]); +__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1157,[30,34,426,102,846,872,1088,1158,25]); +__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1158,[839,846,849]); +__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()},1159,[1160]); +__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1160,[1161,858,884]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1161,[1162,877,1163,878,858,884,1164]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1162,[858]); +__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'},1163,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1164,[858]); +__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1165,[978,34,835,402,102,874,891,1166,1161,794,821,1088,1159,1033,15,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1166,[34,102,794,874,1039,884,1167,831,13,1164,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1167,[34,884]); +__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1168,[34,402,102,794,867,821,1160,1159,1165,1033,25]); +__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1169,[34,402,102,794,874,1161,858,821,1170,1166,1165,25]); +__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1170,[828,34,283,364,236,102,426,797,794,827,821,1171,25]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1171,[]); +__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1172,[827,984,1173,835,860,1174,1175,34,402,295,102,794,874,882,1176,891,994,861,867,1179,858,821,1180,1113,1088,1160,1159,1181,869,1165,1033,925,1182,1004,987,1185,989,1098,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1173,[1159,984]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1174,[827,34,102,794,874,979,891,980,981,982,831,821,25]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1175,[]); +__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1176,[827,796,34,336,402,102,821,794,874,1177,1056,882,861,863,885,1109,1178,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1177,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1178,[827,796,34,336,236,402,102,794,831,990,861,991,994,891,1004,882,821,930,992,25]); +__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])},1179,[858]); +__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1180,[928,828,827,837,5,34,1056,336,402,102,794,891,858,821,1088,1025,925,1047,1046,987,1113,1098,25]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1181,[828,34,102,794,876,831,869,821,925,25]); +__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1182,[928,828,34,395,236,402,102,925,794,926,891,1183,927,831,5,1184,987,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1183,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1184,[933,976,987,977]); +__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1185,[34,402,102,794,891,989,1098,994,987,1091,858,1125,821,25]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1186,[1173,984,34,379,102,794,891,994,867,821,1088,1165,1033,1187,25]); +__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1187,[827,835,984,34,379,236,402,102,794,1031,983,985,867,1032,821,1165,25]); +__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1188,[984,872,34,986,1189,336,402,102,1190,794,985,983,1031,821,874,1101,858,1125,987,25]); +__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1189,[5,822,823,828,236,826]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1190,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1191,[827,1031,1173,984,34,402,102,794,891,867,821,1165,1033,25]); +__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1192,[827,34,402,102,794,796,990,874,863,991,992,821,930,1193,1197,1178,25]); +__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1194,[1195,933,987,872,2,1196,1075]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1195,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1196,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1197,[34,102,797,794,990,874,993,821,930,1178,1198,25]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1198,[]); +__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1199,[827,1200,34,402,102,426,794,891,867,858,821,1201,1088,1065,25]); +__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1201,[34,402,102,794,821,5,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1202,[860,1102,1099,1117,34,102,846,794,874,1101,878,877,858,821,1107,1203,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1203,[34,794,874,1204,25]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1204,[379]); +__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1205,[827,1063,1200,34,1206,236,402,426,102,1208,1209,1210,794,831,891,867,1064,821,930,1218,1201,1088,1065,1211,872,1212,1216,25]); +__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1206,[34,402,102,1207,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1207,[34,797,25]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1208,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1209,[34,102,794,827,891,867,1208,821,25]); +__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1210,[827,1208,34,402,102,794,925,891,1098,858,821,1201,1088,1211,872,1212,1213,1215,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1211,[1063,1085,1093]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1212,[34,102,794,891,1039,1063,1093,1087,1211,821,872,1210,1086,1088,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1213,[1064,1214]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1214,[1064,1208]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1215,[34,102,794,827,1063,1064,1213,1125,821,1216,25]); +__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1216,[1063,34,402,102,794,827,891,1214,1064,1217,1125,821,1205,1088,1208,1213,1065,25]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1217,[]); +__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1218,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1180,1201,1088,1065,1160,987,1039,1062,13,1085,1064,2,25]); +__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1219,[828,891,1220,1200,1006,1007,34,1013,1014,236,402,295,102,794,874,1098,1210,1182,1221,1090,5,1222,1161,867,858,821,1201,1180,1088,925,1042,997,998,1095,1001,1097,1166,1164,1213,1215,1091,25]); +__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1220,[827,34,402,102,794,821,891,831,876,1006,1007,25]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1221,[34,102,794,891,1090,821,1098,25]); +__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1222,[34,402,102,794,891,858,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1223,[34,102,794,891,821,1088,1091,1221,1098,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1224,[34,102,1088,821,794,25]); +__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1225,[827,1063,34,402,102,794,1034,821,930,25]); +__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1226,[827,796,1227,1149,835,891,34,336,402,102,794,1034,1035,821,925,930,1228,1231,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1227,[34,1034,891,835]); +__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1228,[828,1063,796,827,1227,835,891,34,336,402,102,797,794,925,1034,1035,1229,821,930,1230,25]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1229,[]); +__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1230,[831,891,5]); +__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1231,[34,1063,379,236,102,794,891,1034,1230,1035,1232,821,930,1227,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1232,[1035]); +__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1233,[34,402,102,794,995,861,996,821,930,1234,25]); +__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1234,[828,34,336,395,402,295,102,1235,794,995,861,996,858,821,1049,25,1237]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1235,[34,1236,102,861,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1236,[2,987]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1237,[]); +__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1238,[860,1058,34,236,402,102,797,874,821,794,1239,1130,1240,25]); +__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1239,[860,34,380,236,402,102,36,821,794,796,1130,874,25,277]); +__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1240,[1241,1242,1244,1243,1245,1048,1246]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1241,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1242,[839,5,846,849,872,1048,1243]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1243,[860,236,872,1241]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1244,[34,874,861,869,867,1242,1241]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1245,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1246,[34,1242,987,933]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1247,[34,402,102,426,874,861,821,794,1238,1130,1248,25]); +__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1248,[34,102,426,874,861,1240,1048,821,794,1130,25]); +__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1249,[34,236,402,102,879,794,821,1001,1250,1251,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1250,[872,6,933,976,1001,1240,1251]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1251,[839,1252,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1252,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1253,[34,872,1250]); +__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1254,[827,796,1227,835,984,34,931,1206,395,236,402,295,102,846,794,861,1035,867,882,1034,821,1165,1159,1186,932,25]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1255,[34,402,346,102,426,821,1207,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1256,[30,34,792,872,25]); +__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1257,[860,1127,877,30,34,1258,1002,102,14,1129,1138,794,861,867,1131,858,874,987,821,1204,864,1026,1029,1105,1133,1101,1259,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1258,[827,34,236,102,25]); +__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1259,[34,402,102,878,858,1063,1260,821,794,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1260,[1063]); +__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 b}});var n=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),a=e(_r(_d[3])),l=e(_r(_d[4])),r=_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]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,t.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),x=(0,h.useMenu)(e).find(e=>e.id===b),y=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===x?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,n.useTakeawayMenu)(n=>n.byVenue[e]),S=(0,h.useStore)(n=>n.basket.restaurantId===e&&'table'===n.basket.mode),[C,B]=(0,s.useState)(()=>(x?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,s.useState)(1),[P,T]=(0,s.useState)(''),[L,O]=(0,s.useState)(!1),[D,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[q,_]=(0,s.useState)(!1),N=(0,s.useMemo)(()=>x?(0,c.effectiveAllergens)(x,C):{},[x,C]);if(!j||!x)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(N,y.allergies),Y=(x.price??0)+(x.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,n)=>e+n.priceDelta,0),z=S||j.fictional?'on':(0,n.takeawayAvail)(x,w),F=x.soldOut||!x.signOff||null===x.price||'on'!==z,Q=(e,n)=>{const t=x.optionGroups.find(n=>n.id===e);B(e=>{const s=t.choices.map(e=>e.id);return t.multi?e.includes(n)?e.filter(e=>e!==n):[...e,n]:e.includes(n)&&!t.required?e.filter(e=>e!==n):[...e.filter(e=>!s.includes(e)),n]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:x.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),_(!0)};return(0,f.jsxs)(d.Screen,{title:x.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(a.default,{testID:"dish-photo",source:k,accessibilityLabel:`${x.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===x.price?x.priceNote:(0,u.gbp)(Y)}),x.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:x.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(x.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(n=>(0,f.jsx)(d.Chip,{label:n.label,sub:n.priceDelta?`+${(0,u.gbp)(n.priceDelta)}`:void 0,selected:C.includes(n.id),onPress:()=>Q(e.id,n.id)},n.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:x,map:N,declared:y.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:x.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&x.signOff&&null!==x.price?'This dish isn\u2019t on the takeaway menu. You can have it when you eat in.':x.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(l.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${x.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1261,[988,30,34,336,102,1235,1262,794,861,867,874,882,821,25]); +__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])},1262,[30,34,402,874,821,794,25]); +__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1263,[30,34,794,1264,874,1249,25]); +__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])},1264,[34,402,821,794,25]); +__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1265,[837,30,34,1266,794,867,874,821,1267,1271,25]); +__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:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1266,[34,385,102,874,867,821,794,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1267,[34,102,794,867,1268,1269,1270,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1268,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1269,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1270,[933,987,1269]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1271,[846,933,976,987,2,1268]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),I=_r(_d[23]),O=_r(_d[24]),R=_r(_d[25]),A=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),C=_r(_d[29]),_=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const M=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let $=!1,E=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,k.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,k.useRestaurant)(e),l=(0,k.useMenu)(e),a=(0,k.useCustomer)(),s=(0,k.useBasket)(),n=(0,k.useStore)(e=>e.startBasket),o=(0,k.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[U,V]=(0,u.useState)(!1),[Q,Y]=(0,u.useState)('takeaway'===M?'takeaway':'main');c.default.useEffect(()=>{M&&!$&&($=!0,'book'===M?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,k.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>d.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{C.START_LOYALTY_CODE&&!E&&(E=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,k.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||k.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=l.filter(e=>!('All'!==r&&e.section!==r||'takeaway'===Q&&'off'===ne(e))),re=(0,j.hoursFor)(t,o),ie=e=>()=>d.router.push(`/customer/${t.id}${e}`),de=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>V(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:ie('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:ie('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:ie('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:ie('/refer')},{icon:'gift',label:'Gift cards',on:ie('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:ie('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:ie('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:ie('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:ie('/feedback')},{icon:'hanger',label:'Lost property',on:ie('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:ie('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[re?`Kitchen today ${(0,j.kitchenHoursOn)(t,o)[0]}\u2013${(0,j.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:de.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:de.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=Q===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===Q?(0,v.jsx)(A.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===Q?(0,v.jsx)(m.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==Q?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==Q||oe.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==Q?se.filter(e=>('All'===r||e===r)&&oe.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),oe.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?'Not on the takeaway menu':'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:U,onClose:()=>V(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{V(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1272,[1273,1282,5,1283,1284,1285,1288,860,30,34,236,402,102,1235,1262,794,861,867,878,874,988,821,1289,1249,872,891,1234,995,996,1004,1290,1271,25]); +__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1273,[34,379,794,873,1274,1275,1281,874,5,6,25]); +__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1274,[34,379,102,794,997,998,1096,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1275,[6,34,933,794,1276,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1276,[6,1063,1277,1278,1279,34,102,827,794,821,11,1280,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1278,[4,11]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1279,[11]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1280,[6,933]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1281,[34,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1282,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1283,[34,102,794,1276,25]); +__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1284,[34,379,933,794,873,1274,1276,4,25]); +__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1285,[34,379,794,1274,873,1275,8,1286,25]); +__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1286,[34,102,794,1287,25]); +__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1287,[]); +__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1288,[34,794,873,1274,1275,874,9,25]); +__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1289,[34,402,102,426,794,821,1207,25]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1290,[34,102,1291,794,874,1004,1268,1271,821,25]); +__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1291,[34,102,1292,821,25]); +__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1292,[1293]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1293,[34,797,1294,1323,1324,25]); +__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1294,[1295]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1295,[1296,1297,1320,1322]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1296,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1297,[1298,1299,1300,1301,1302,1303,1304,1305,1306,1309,1313,1310,1314]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1298,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1299,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1300,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1301,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1306,[1307]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1310,[1311,1312]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1311,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1312,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1315,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1316,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1318,[1310,1298]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1319,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1320,[1321]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1322,[1321]); +__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1323,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1324,[34,797,1325,25]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1325,[]); +__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1326,[30,34,794,874,891,25]); +__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1327,[837,30,34,102,1291,794,867,874,821,1290,1271,25]); +__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1328,[837,30,34,102,1266,794,874,891,867,858,821,1267,1271,25]); +__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1329,[837,30,34,794,874,891,858,821,1290,1271,25]); +__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1330,[837,30,34,794,874,891,821,1290,1271,25]); +__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1331,[30,34,794,858,1161,1332,874,821,25]); +__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}},1332,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1333,[30,1101,34,402,102,794,858,874,821,25]); +__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 v}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),o=_r(d[3]),r=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),k=_r(d[15]),p=_r(d[16]),f=_r(d[17]);function v(){const e=(0,b.useBasket)(),v=(0,b.useRestaurant)(e.restaurantId??void 0),w=(0,b.useAllMenu)(e.restaurantId??void 0),C=(0,b.useCustomer)(),S=(0,b.useOrders)(v?.id),T=(0,b.useStore)(e=>e.setLineQty),B=(0,b.useStore)(e=>e.overrideLine),P=(0,b.useStore)(e=>e.startBasket),I=(0,b.useNow)(15e3),[O,$]=(0,a.useState)(null),[N,M]=(0,a.useState)(!1),[F,L]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,r.startForm)()),[A,R]=(0,a.useState)(''),[Y,D]=(0,a.useState)(C.phone??''),[E,_]=(0,a.useState)(C.email??''),[q,H]=(0,a.useState)(C.name&&'Guest'!==C.name?C.name:''),[G,V]=(0,a.useState)(!1),K=(0,b.useOrderAtTable)(e.restaurantId??void 0),Q=(0,p.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{K||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[K,e.mode]);const[U,J]=(0,a.useState)(null),[W,X]=(0,a.useState)(!1),Z=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,w,C.allergies),[e,w,C.allergies]);if(!v||!e.lines.length)return(0,f.jsxs)(i.Screen,{title:"Your basket",children:[(0,f.jsx)(i.Muted,{children:"Your basket is empty."}),(0,f.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ee=K&&'table'===e.mode,le=(0,h.takeawaySlots)(v,S,I),te=Z.reduce((e,l)=>e+l.unitPrice*l.qty,0),ae=Z.some(e=>e.contains.length&&!e.overridden),ne=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ee&&'on'!==(0,p.takeawayAvail)(l,Q)}),oe=!ee&&!O,re=!ee&&v.settings.takeawayPaused,se=(0,x.ukPhone)(Y),ie=q.trim().length>=2&&'guest'!==q.trim().toLowerCase(),de=ee||(0,p.takesCardTakeaway)(v,k.IS_ISOLATED_VENUE),ue=!G&&de&&!ae&&!ne.length&&N&&!oe&&!re&&(ee||ie&&se.ok&&(0,x.emailOk)(E)),ce=async()=>{V(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ee?void 0:O,tip:0,notes:F,phone:ee?void 0:se.pretty,email:ee?void 0:E.trim()||void 0,customerName:ee?void 0:q.trim()});(0,r.rememberGuard)(e.id,(0,r.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{V(!1)}},he=e.lines.find(e=>e.key===U),me=he?Z[e.lines.indexOf(he)]:void 0;return(0,f.jsxs)(i.Screen,{title:"Your basket",subtitle:`${v.name} \xb7 ${ee?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,f.jsx)(i.T,{weight:"bold",size:20,colour:j.colours.gold,children:(0,c.gbp)(te)})]}),de?ae?(0,f.jsx)(i.T,{size:14,colour:j.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):N?oe&&!re?(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Choose a collection time."}):ee||ie?ee||se.ok?null:(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your mobile number."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your name for the order."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Confirm your allergies to continue."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ee?(0,f.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!ue,onPress:()=>ce(),testID:"send-table-order"}):(0,f.jsx)(i.Button,{label:G?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(te)}`,disabled:!ue,onPress:()=>ce(),testID:"checkout"}),ee?null:(0,f.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ee||e.tableNo,null),ee?(0,f.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,v.fictional?null:(0,f.jsx)(i.AllergenNotice,{phone:v.phone}),Z.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,f.jsxs)(i.Card,{highlight:l.contains.length?j.colours.red:l.may.length?j.colours.amber:void 0,children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,f.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,f.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,f.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,f.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,f.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,f.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${C.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,f.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{X(!1),J(a.key)}})]})]}):l.contains.length?(0,f.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,f.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ne.includes(a)?(0,f.jsx)(i.Badge,{kind:"amber",label:!ee&&Q&&w.find(e=>e.id===a.itemId)&&'sold-out'===(0,p.takeawayAvail)(w.find(e=>e.id===a.itemId),Q)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Stepper,{value:a.qty,onChange:e=>T(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${v.id}`)}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(I)]}),re?(0,f.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===le.length?(0,f.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(i.Muted,{children:["15-minute slots, max ",v.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:le.slice(0,16).map(e=>(0,f.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:O===e.time.toISOString(),onPress:()=>$(e.time.toISOString())},e.label))})]})]}),(0,f.jsxs)(i.Card,{highlight:N?void 0:j.colours.amber,children:[(0,f.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:C.allergies.length?C.allergies.map(e=>(0,f.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,f.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,f.jsx)(i.Toggle,{label:C.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:N,onChange:M}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.H2,{children:"Your details"}),(0,f.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:q,onChangeText:H,autoComplete:"name",placeholder:"e.g. Sam Smith"}),q&&!ie?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"Please add your name."}):null,(0,f.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:Y,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!se.ok&&Y?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:se.error}):null,(0,f.jsx)(i.Field,{label:"Email (optional)",value:E,onChangeText:_,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,x.emailOk)(E)?null:(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,f.jsx)(i.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,f.jsx)(i.Field,{label:"Order notes (optional)",value:F,onChangeText:L,placeholder:"e.g. cutlery please"}),ee?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>P(v.id,'takeaway')}):null,(0,f.jsxs)(i.Sheet,{visible:!!he,onClose:()=>J(null),title:"Allergy override",children:[me?(0,f.jsx)(i.Banner,{kind:"danger",title:`${me.name} contains ${me.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,f.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:W,onChange:X}),(0,f.jsx)(i.Button,{kind:"danger",disabled:!W,label:"Confirm override",onPress:()=>{he&&me&&B(he.key,me.contains),J(null)}})]}),(0,f.jsx)(o.Honeypot,{value:A,onChange:R})]})}},1334,[860,30,34,1258,1002,102,794,861,867,1131,858,874,831,821,864,5,988,25]); +__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1335,[30,34,102,1262,794,861,878,874,821,1289,5,25]); +__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 f}});var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1336,[860,30,34,102,1264,794,861,867,858,874,821,1337,25]); +__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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1337,[34,371,379,236,30,794,867,821,988,1338,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1338,[933,987]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1339,[860,1271,30,34,102,794,861,867,858,874,879,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1340,[30,34,872,25]); +__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1341,[837,30,34,794,874,5,1271,25]); +__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1342,[30,34,794,1343,1175,1271,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1343,[827,860,34,102,794,861,867,1175,1344,874,821,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1344,[933,987,1175]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1345,[30,34,872,1346,1410,25]); +__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1346,[1162,796,5,6,1347,828,853,1122,860,1161,1348,1349,1350,1119,1143,1351,1352,1357,1358,1359,872,1360,1174,979,1130,1361,34,1099,1202,1048,1115,1157,1362,395,380,402,295,102,426,36,794,1249,1253,873,861,858,874,821,1118,891,1126,1088,1029,1105,1135,1363,1134,1364,1371,1373,1376,1379,1375,1380,1382,1383,1140,1123,1124,878,1387,1238,1388,1248,1240,1026,1393,1401,1402,1102,1142,1404,1405,1406,1098,1189,1407,1188,1181,869,1408,1409,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1348,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1349,[1027,1088]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1350,[34,102,1105,794,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1351,[860,34,102,794,874,1175,821,25]); +__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1352,[34,395,402,426,102,1291,794,1189,796,1029,1353,1354,1356,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1353,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1354,[34,395,402,295,412,102,426,796,794,821,1355,1356,25]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1355,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1356,[1025,872,1355,933,987]); +__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1357,[846]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1358,[828,34,379,395,402,102,794,1189,821,25]); +__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1359,[34,236,402,102,794,821,891,1004,858,1098,25]); +__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1360,[828,827,34,236,402,295,102,794,1174,874,979,831,981,982,872,980,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1361,[828,34,102,821,794,25]); +__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1362,[34,102,797,821,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1363,[]); +__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1364,[828,796,827,1122,860,1130,34,236,402,295,426,102,859,821,794,1365,1366,1029,891,1134,1368,987,872,25]); +__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1365,[828,860,34,1366,102,859,821,794,1135,1367,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1366,[859]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1367,[1366,859]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1368,[34,385,295,102,859,1369,1370,821,796,827,794,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1369,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[1369,1025,872,933,987]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[34,236,402,102,821,794,1189,1372,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[828,860,1123,34,281,236,295,102,1136,874,1029,1105,14,858,1124,1374,821,794,1375,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1376,[5,828,34,283,336,236,402,102,426,821,873,794,1030,1001,1357,1377,2,1378,1379,874,858,25]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1377,[236]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1379,[34,846,933,987,1378]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1380,[860,14,1029,1381]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1381,[861]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1382,[34,102,797,821,25]); +__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1383,[1384,860,1123,1029,34,102,794,1126,874,1386,1380,1124,858,1121,1140,1141,1142,821,1349,25]); +__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1384,[34,379,402,102,874,1004,891,1027,1385,872,821,794,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1385,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1386,[1029,1105]); +__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1387,[1384,828,1123,827,860,1161,1119,1140,858,34,1107,236,402,295,102,794,1126,1375,874,1029,861,1117,1105,1332,821,1349,25]); +__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1388,[827,34,236,402,102,794,874,1029,1389,821,1390,1392,25]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1389,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1390,[846,874,1029,1389,1391,1392]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1391,[860]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1392,[236,1391]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1393,[860,34,1206,1189,402,102,1026,1029,878,858,821,794,1394,1397,25]); +__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1394,[1395,870,860,34,281,395,402,295,102,874,1026,1029,1396,858,821,1056,794,1397,1398,987,1349,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1395,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1396,[878,858,877]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1397,[5,1029,933,987]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1398,[846,933,987,1399,2,1400]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1399,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1400,[15]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1402,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1403,[1105]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1404,[860,1381]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1405,[34,402,102,794,1404,821,1362,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1406,[34,102,925,794,1189,858,821,25]); +__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1407,[34,1189,402,102,426,794,25]); +__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1408,[828,1063,827,2,1189,34,402,102,426,794,821,891,998,858,1001,1398,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[34,1036,891,1009,831,1037,1001,1398,1094]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[5,828,873,34,236,402,102,426,987,821,794,1357,1411,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1412,[30,34,872,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1413,[30,34,872,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1414,[30,34,1415,872,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1415,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1416,[30,34,872,1417,25]); +__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1417,[1418,1422,828,997,1099,1423,1224,1055,1056,1424,1426,1429,1174,979,1016,1431,1013,2,1061,1062,1432,999,1039,1000,34,1176,1249,1253,1220,373,402,295,102,426,36,794,873,1157,891,821,1180,1433,1094,1112,1114,1108,1057,1040,1088,1441,1442,1443,1451,1452,1004,236,1255,1199,1205,1448,1219,1218,1461,1202,15,1225,1226,925,793,987,25]); +__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1418,[827,34,1048,395,102,1134,1135,1364,1393,794,1026,1029,858,821,1088,1030,1419,1420,1050,25]); +__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1419,[827,34,402,102,794,821,1029,5,1030,872,987,25]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1420,[34,102,794,1029,1421,859,821,1075,933,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1421,[]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1422,[34,102,794,1088,987,25]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1423,[860,34,102,794,861,867,1175,874,869,821,25]); +__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1424,[987,34,281,236,102,1291,794,1268,1271,821,1425,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1425,[34,236,102,794,1268,25]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1426,[34,796,102,794,861,1268,1427,1428,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1427,[861]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1428,[987,1427,1271]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1429,[5,1430,34,102,794,867,1268,1269,1270,987,1271,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1430,[34,794,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1431,[236,1014]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1432,[34,102,794,821,999,1052,987,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1433,[5,1430,1123,11,1434,827,837,1140,1141,1119,1143,1435,1138,1142,1404,1405,1088,1349,1027,1117,14,1144,1437,1249,1438,1393,1107,1101,1118,34,102,794,1362,874,861,867,858,1332,821,1201,1126,1029,1439,1087,1181,1440,1240,987,1203,1401,878,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1434,[6,34,102,794,987,1280,25]); +__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1435,[34,402,102,1436,987,933,821,794,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1436,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1437,[827,5,34,379,236,102,794,876,14,867,1032,933,821,1204,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1438,[34,402,1189,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1439,[34,102,874,1029,794,821,25]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1440,[34,102,879,874,864,821,794,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1441,[34,1394,1088,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1442,[860,34,102,1181,794,874,861,869,858,821,1201,1088,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1443,[835,984,1444,34,236,102,794,831,891,983,1031,985,987,1450,821,2,1182,25]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1444,[827,979,1161,987,797,1238,1240,34,281,379,236,402,102,426,879,794,874,1249,891,867,858,821,1201,1088,869,1445,1180,1448,1449,1160,1167,1166,1039,13,1164,1170,1230,25]); +__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1445,[927,796,831,828,837,878,1076,1446,34,994,336,379,236,402,102,794,874,891,858,821,1201,1088,1230,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1446,[499,1447]); +__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 t={}},1447,[]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1448,[827,34,1236,1056,870,379,402,102,794,891,867,858,821,1201,1088,1230,25]); +__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1449,[1016,34,402,102,794,891,821,1088,987,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1450,[]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1451,[860,34,102,794,891,1029,858,1091,1089,987,1090,5,1001,821,25]); +__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1452,[5,1453,1454,1455,1456,1457,34,236,41,102,872,1458,1004,821,1460,794,987,2,1097,1003,891,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1453,[34,102,873,794,5,6,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1454,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1455,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1456,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1457,[34,102,873,794,25]); +__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1458,[34,295,102,794,873,821,1459,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1459,[]); +__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1460,[929,828,34,1097,336,236,402,295,41,102,872,926,891,831,987,1004,15,793,821,925,794,25]); +__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1461,[1202,1099,1140,1117,34,402,102,794,891,858,821,1118,1188,1088,1199,1445,1181,876,1203,869,1201,925,1439,1029,860,1126,1218,1222,1098,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1462,[30,34,872,25]); +__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1463,[1464,987,795,1411,1466,1026,30,1493,496,34,385,336,236,41,102,5,873,872,1495,36,874,1029,891,821,1452,1004,1024,1498,1499,1058,1500,1130,2,1039,999,1518,1379,25,1520,1521,1522,1523]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1464,[2,827,34,236,383,102,794,1465,987,821,1205,1004,891,994,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1465,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1466,[1467,1490,1492]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1467,[215,1468,1471,1485,1486,1487,1488,1489]); +__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1468,[215,1469]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1469,[1470]); +__d(function(g,r,i,a,m,e,d){},1470,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1471,[1472,215,1468,1485,1486]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1472,[1473,1474,1484]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1473,[1474,1478,1483]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1474,[215,372,1475,1479,1480,1481,1482,1478,1483]); +__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1475,[215,1476,339,280,1477,1478]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1476,[504]); +__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1477,[215,339]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1478,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1479,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1480,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1481,[1479]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1482,[]); +__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1483,[372,1477]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1484,[34,1474]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1485,[1472,215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1486,[1472,1485]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1487,[1468]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1488,[215,1468,1471,1469]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1489,[]); +__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1490,[215,54,1491]); +__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1491,[215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1492,[34,1467]); +__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]}})})},1493,[1494]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1494,[]); +__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1495,[34,41,102,426,794,873,1004,987,2,5,821,1496,1497,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1496,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1497,[34,102,794,821,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1498,[990,883,882,987]); +__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1499,[828,796,827,34,1012,1419,1030,402,102,872,987,1014,1029,5,821,794,1357,976,2,25]); +__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1500,[5,796,827,34,385,283,364,380,236,402,295,426,102,1501,1157,2,797,1088,15,891,794,821,1502,932,1514,1510,1511,1515,1158,1516,931,1517,1513,25,277]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"useAssistantUi",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AssistantFab",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AssistantSheet",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"AssistantPage",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"AssistantSettings",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"AssistantPlanCard",{enumerable:!0,get:function(){return c}});const t=!1,n={getState:()=>({open:!1,setOpen:t=>{}})},u=()=>null,s=()=>null,l=()=>null,o=()=>null,c=()=>null},1501,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1502,[1503,1128,860,1504,1505,891,874,1029,1509,1510,1511,1507,1506,1512,1513,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1503,[1093,1092,1053]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1504,[984,1128,835,860,874,831,1029,983,985,1040,891,1095,882,863,861]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1505,[835,874,831,1029,891,1034,1044,1045,1010,1009,1039,13,1064,1065,1066,1035,1095,882,1105,1026,870,1506,1504]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1506,[835,979,1128,860,1161,1271,874,831,1029,1034,995,862,861,1105,1106,1026,1035,867,1507,1508]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1507,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1508,[839,846,849]); +__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1509,[828,34,283,364,236,402,102,846,794,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1510,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1511,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1512,[831,891,995,867,1506,1047,1098]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1513,[]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1514,[891,831,1029]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1515,[846]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1516,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1517,[846]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1518,[874,831,891,1039,15,1004,872,2,1519]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1519,[874,1039]); +__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1520,[]); +__d(function(e,o,s,p,c,t,d){"use strict";c.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1521,[]); +__d(function(o,e,s,p,f,t,d){"use strict";f.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1522,[]); +__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1523,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1524,[30,34,872,25]); +__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1525,[1526]); +__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1526,[25,1527,591]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1527,[34,172]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1528,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1529,[25,499,34,270,651]); __r(501); __r(21); __r(0); \ No newline at end of file diff --git a/chef-app/admin.html b/chef-app/admin.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/admin.html +++ b/chef-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer.html b/chef-app/customer.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer.html +++ b/chef-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage.html b/chef-app/customer/anchorage.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage.html +++ b/chef-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/book.html b/chef-app/customer/anchorage/book.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/book.html +++ b/chef-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/feedback.html b/chef-app/customer/anchorage/feedback.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/feedback.html +++ b/chef-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/gift.html b/chef-app/customer/anchorage/gift.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/gift.html +++ b/chef-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/lost.html b/chef-app/customer/anchorage/lost.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/lost.html +++ b/chef-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/loyalty.html b/chef-app/customer/anchorage/loyalty.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/loyalty.html +++ b/chef-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/merch.html b/chef-app/customer/anchorage/merch.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/merch.html +++ b/chef-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/offers.html b/chef-app/customer/anchorage/offers.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/offers.html +++ b/chef-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/refer.html b/chef-app/customer/anchorage/refer.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/refer.html +++ b/chef-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/waitlist.html b/chef-app/customer/anchorage/waitlist.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/waitlist.html +++ b/chef-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/anchorage/whatson.html b/chef-app/customer/anchorage/whatson.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/anchorage/whatson.html +++ b/chef-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/basket.html b/chef-app/customer/basket.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/basket.html +++ b/chef-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/customer/profile.html b/chef-app/customer/profile.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/customer/profile.html +++ b/chef-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/demo.html b/chef-app/demo.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/demo.html +++ b/chef-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/display.html b/chef-app/display.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/display.html +++ b/chef-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/index.html b/chef-app/index.html index fe17dd3d8ec9e99aabe953b20be269213fd5e70b..e5c8dbe019f86f307b25d0722c72c1c5b3ef8d17 100644 --- a/chef-app/index.html +++ b/chef-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/kitchen.html b/chef-app/kitchen.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/kitchen.html +++ b/chef-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/owner.html b/chef-app/owner.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/owner.html +++ b/chef-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/staff.html b/chef-app/staff.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/staff.html +++ b/chef-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/chef-app/sw.js b/chef-app/sw.js index f48329ead9916e56ad8587950770134db1a48c34..28b242ade2ab0e3a4e151bd7d99f7c1719f1cdf9 100644 --- a/chef-app/sw.js +++ b/chef-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Head Chef service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-chef-1f5ecf9b11"; +const V = "cc-chef-4f9b93df3a"; const BASE = "/chef-app/"; -const PRECACHE = ["/chef-app/apple-touch-icon.png", "/chef-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/chef-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/chef-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/chef-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/chef-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/chef-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/chef-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/chef-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/chef-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/chef-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/chef-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/chef-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/chef-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/chef-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/chef-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/chef-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/chef-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/chef-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/chef-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/chef-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/chef-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/chef-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/chef-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/chef-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/chef-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/chef-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/chef-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/chef-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/chef-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/chef-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/chef-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/chef-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/chef-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/chef-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/chef-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/chef-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/chef-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/chef-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/chef-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/chef-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/chef-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/chef-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/chef-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/chef-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/chef-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/chef-app/brand-logo.png", "/chef-app/favicon.ico", "/chef-app/icon-192.png", "/chef-app/icon-512.png", "/chef-app/icon-maskable-192.png", "/chef-app/icon-maskable-512.png", "/chef-app/manifest.webmanifest", "/chef-app/index.html", "/chef-app/_expo/static/js/web/bundle.js?v=1f5ecf9b115d6c4f169238e0bc3ac40b8eddf2df35931879f78f3708da082a93"]; +const PRECACHE = ["/chef-app/apple-touch-icon.png", "/chef-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/chef-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/chef-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/chef-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/chef-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/chef-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/chef-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/chef-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/chef-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/chef-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/chef-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/chef-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/chef-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/chef-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/chef-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/chef-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/chef-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/chef-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/chef-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/chef-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/chef-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/chef-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/chef-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/chef-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/chef-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/chef-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/chef-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/chef-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/chef-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/chef-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/chef-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/chef-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/chef-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/chef-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/chef-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/chef-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/chef-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/chef-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/chef-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/chef-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/chef-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/chef-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/chef-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/chef-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/chef-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/chef-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/chef-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/chef-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/chef-app/brand-logo.png", "/chef-app/favicon.ico", "/chef-app/icon-192.png", "/chef-app/icon-512.png", "/chef-app/icon-maskable-192.png", "/chef-app/icon-maskable-512.png", "/chef-app/manifest.webmanifest", "/chef-app/index.html", "/chef-app/_expo/static/js/web/bundle.js?v=4f9b93df3af3ffffd2a241242d62e0d661603c4d753bad83223883abaf888816"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/chef-app/team.html b/chef-app/team.html index 014b6a0e56aaeef71887a11d976d13923a561762..db351411f8a8b8c915cbbf9569395887e6b46f34 100644 --- a/chef-app/team.html +++ b/chef-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/_expo/static/js/web/bundle.js b/customer-app/_expo/static/js/web/bundle.js index 1f7f327b46293a873b9f8342c316cc7619b0d796..dc2d3b26efb0983e5b3af80968bde411b92e76f6 100644 --- a/customer-app/_expo/static/js/web/bundle.js +++ b/customer-app/_expo/static/js/web/bundle.js @@ -23,11 +23,11 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_VENUE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PITCH_TEAM",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PITCH_TEXT",{enumerable:!0,get:function(){return o}}),e.pitchText=function(a,n=!1){let l=a;for(const[a,s]of o){if(n&&t.test(a.source.replace(/\\/g,'')))continue;a.test(l)?(a.lastIndex=0,l=l.replace(a,s)):a.lastIndex=0}return l};const a={name:'The Harbour Kitchen',tagline:'Harbourside seafood & seasonal plates',location:'12 Quay Street, Portmorran',phone:'01632 960 123',website:'harbourkitchen.example'},n={'st-tracy':{name:'Morgan',job:'Owner',hourlyPence:null,salaried:!0},'st-gordon':{name:'Alex',job:'General Manager',dept:'Management',hourlyPence:null,salaried:!0},'st-bisto':{name:'Ravi',job:'Head Chef',hourlyPence:null,salaried:!0},'st-agate':{name:'Priya',job:'Front of house supervisor',hourlyPence:1450},'st-lenny':{name:'Tom',job:'Commis Chef',hourlyPence:1325},'st-finn':{name:'Lewis',job:'Bar staff',hourlyPence:1290},'st-eilidh':{name:'Chloe',job:'Front of house',hourlyPence:1271},'st-emily':{name:'Ellie',job:'Front of house',hourlyPence:1271},'st-lillie':{name:'Jordan',job:'Kitchen porter (KP)',hourlyPence:1271},'st-jack':{name:'Sam',job:'Kitchen porter (KP)',hourlyPence:1271}},o=[['Harbour View, Dunure, South Ayrshire',a.location],['Harbour View, Dunure',a.location],['Harbour View mug','Harbour Kitchen mug'],['Harbour View','Quay Street'],['anchoragedunure.com',a.website],['01292 502826',a.phone],['Mini Anchors','Little Crew'],['The Anchorage',a.name],['Anchorage','Harbour Kitchen'],['ANCHORAGE','HARBOUR KITCHEN'],['South Ayrshire','the Firth coast'],['Ayrshire','the Firth coast'],['Dunure','Portmorran'],['Kittyfisher boat (Big Sean)','Coastal Fish Co'],['Kittyfisher','Coastal Fish Co'],['Big Sean','Coastal Fish Co'],['Example Fish Co.','Coastal Fish Co'],['Sample Dairy Ltd','Hillside Dairy'],['Sample Fruit & Veg','Fieldfare Veg'],['Mills milk','Hillside Dairy milk'],['Mills','Hillside Dairy'],['J. Pieroni & Sons','Fieldfare Veg'],["Pieroni's",'Fieldfare Veg'],['Pieroni','Fieldfare Veg'],['Alsons (drinks)','Drinks wholesaler'],['Alsons','the drinks wholesaler'],['Spes Bona','the deli wholesaler'],['Tarelgin','the butcher'],['Reids','the bakery'],['Reeds','the bakery'],['Example Butchers Ltd','Quayside Butchers'],['Example Dry Goods Wholesale','Dry goods wholesaler'],['Sample Brewing Co.','Harbourside Brewing'],['Example Cleaning Supplies','Cleaning supplies'],['Sample Packaging Ltd','Packaging supplier'],['Example Kitchen Repairs','Kitchen repairs'],['Preston','Ravi'],['Bisto','Ravi'],['Tracy','Morgan'],['James','Morgan'],['Gordon','Alex'],['Agate','Priya'],['Lenny','Tom'],['Finn','Lewis'],['Eilidh','Chloe'],['Emily','Ellie'],['Gabrielle','Ellie'],['Cameron Mc','Sam'],['Cameron','Sam'],['Lillie','Jordan'],['Lily','Jordan'],['Mia','Jordan'],['Jack','Sam'],['Harvey','Jordan'],['Anna','the supplier'],['(preview)',''],[' (example)','']].map(([a,n])=>[new RegExp(`${/^[A-Za-z]/.test(a)?'(?g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},23,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1495,1498]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1498,1501]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},25,[26]); __d(function(g,r,i,a,m,e,d){ /** @@ -41,8 +41,8 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},26,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},27,[28]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1052,1240,1241,1245,1249,1251,1258,1314,1315,1316,1317,1318,1319,1321,1322,1323,1324,1325,1326,1327,1328,1331,1398,1399,1400,1402,1449,1450,1494]); -__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,993,25]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1053,1241,1242,1246,1250,1252,1259,1315,1316,1317,1318,1319,1320,1322,1323,1324,1325,1328,1329,1330,1331,1334,1401,1402,1403,1405,1452,1453,1497]); +__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,994,25]); __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)},30,[31,32,782,783,785]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},31,[]); __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}},32,[33,692,487,708,557,709,770,761,764,774,647,645,650,562,560,591,465,467,204,205,775,472,473,462,460,569,556,639,659,776,658,162,151,547,433,777,780]); @@ -872,9 +872,9 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},789,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},790,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},791,[]); -__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1054,1055,1015,2,1056,1060,1061,1093,858,1098,1102,1103,1106,1107,1110,1111,1113,1114,1115,1144,1146,1091,34,373,236,402,295,426,102,36,873,1156,794,867,821,1087,1158,1164,1167,1168,1171,1185,1184,1186,1187,1190,1191,1192,1195,1198,1211,1212,1216,1217,925,1003,1218,1177,1219,1220,1221,1230,1223,1175,1232,1236,1213,874,1237,1173,987,1239,25]); +__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1055,1056,1016,2,1057,1061,1062,1094,858,1099,1103,1104,1107,1108,1111,1112,1114,1115,1116,1145,1147,1092,34,373,236,402,295,426,102,36,873,1157,794,867,821,1088,1159,1165,1168,1169,1172,1186,1185,1187,1188,1191,1192,1193,1196,1199,1212,1213,1217,1218,925,1004,1219,1178,1220,1221,1222,1231,1224,1176,1233,1237,1214,874,1238,1174,987,1240,25]); __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=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.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."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.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 CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};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]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(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 v(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 b(e){const{img:t,url:a}=await f(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),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.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()})}},793,[34,336,236,402,102,794,925,929,926,821,930,25]); -__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=D,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(H,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(x.default,{style:{flex:1},children:u}),s?(0,B.jsx)(x.default,{style:N.footer,children:(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=v,_e.Card=F,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(x.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:L?'center':'flex-start'}],children:(0,B.jsx)(D,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(x.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(D,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(D,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(x.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(D,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,p.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(D,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(D,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(x.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(D,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),x=e(_r(d[14])),p=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),L='display'!==S.APP_VARIANT;function D({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),x=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,p=f.default.flatten(t)||{},j=1===p.flex||1===p.flexGrow||'number'==typeof p.width||'left'===p.textAlign,k=c??(L&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,x,(0,W.webLine)(t,r),k&&'left'!==p.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(D,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(D,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(D,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??L});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(x.default,{style:N.brandBar,children:[(0,B.jsxs)(x.default,{style:N.row,children:[(0,B.jsx)(x.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(D,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(x.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(x.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function H(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(D,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function v({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],x={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:x,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(D,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(D,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function F({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(x.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(x.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(D,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(D,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,v.centreRow=!0;const V=()=>(0,B.jsx)(E,{kind:"example",title:"Allergens awaiting kitchen verification",children:"This allergen information has not been verified by the kitchen. Head chef sign-off is required. Always speak to staff about allergies."}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Card payments: not set up yet",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===F?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(L&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(x.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=L&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(x.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(x.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); +__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(v,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(p.default,{style:{flex:1},children:u}),s?(0,B.jsx)(p.default,{style:N.footer,children:(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=F,_e.Card=H,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:D?'center':'flex-start'}],children:(0,B.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,x.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),D='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(D&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??D});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(p.default,{style:N.brandBar,children:[(0,B.jsxs)(p.default,{style:N.row,children:[(0,B.jsx)(p.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function v(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function F({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function H({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,F.centreRow=!0;const V=({phone:e})=>(0,B.jsx)(E,{kind:"warn",title:"Allergies",children:"All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===H?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(D&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=D&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},795,[]); __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.GoldX=h,_e.GoldClose=j,Object.defineProperty(_e,"TEXT_ONLY_CLOSE",{enumerable:!0,get:function(){return x}}),_e.ToastClose=function({onPress:e,label:o="Close",testID:s,size:l="md",style:c,colour:h}){return x?(0,b.jsx)(t.default,{testID:s,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:[{minWidth:64,minHeight:48,alignItems:'center',justifyContent:'center',paddingHorizontal:8},c],children:(0,b.jsx)(u.Text,{style:{fontSize:16,color:h??n.colours.text},children:"Close"})}):(0,b.jsx)(j,{onPress:e,label:o,testID:s,size:l,style:c})},r(d[0]);var t=e(r(d[1])),o=e(r(d[2])),s=r(d[3]),l=e(s),n=r(d[4]),c=r(d[5]),u=r(d[6]),b=r(d[7]);function h({size:e=16,colour:t=n.colours.gold,stroke:o}){const c=o??(e>=20?2.4:2.2);return(0,b.jsx)(l.default,{width:e,height:e,viewBox:"0 0 24 24",accessible:!1,focusable:!1,pointerEvents:"none",children:(0,b.jsx)(s.Path,{d:"M6 6 L18 18 M18 6 L6 18",stroke:t,strokeWidth:Math.min(4,c*(24/e)),strokeLinecap:"round",fill:"none"})})}const f={sm:32,md:38,lg:46},y={sm:13,md:15,lg:18};function j({onPress:e,label:s="Close",testID:l,size:c="md",style:u,disabled:j,hint:x}){const C=f[c],I=Math.max(44,C+8);return(0,b.jsx)(t.default,{testID:l,accessibilityRole:"button",accessibilityLabel:s,accessibilityHint:x,disabled:j,onPress:e,dataSet:{goldClose:'1'},style:[{width:I,height:I,alignItems:'center',justifyContent:'center',flexShrink:0,opacity:j?.4:1},u],children:({pressed:e,hovered:t})=>(0,b.jsx)(o.default,{style:{width:C,height:C,borderRadius:C/2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:e||t?n.colours.gold:n.colours.accentBorder,backgroundColor:e?n.colours.goldTint:t?n.colours.accentBg:'rgba(0,0,0,0.18)'},children:(0,b.jsx)(h,{size:y[c],colour:e?n.colours.goldLight:n.colours.gold})})})}const x=['kirkton','abbotsford'].includes(c.VENUE_RID)},796,[34,402,102,797,821,5,827,25]); __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}},797,[798]); @@ -911,7 +911,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule? __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOUTERS_BG",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SOUTERS_SURFACE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SOUTERS_TYPE_SCALE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"soutersFont",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"soutersSurface",{enumerable:!0,get:function(){return f}}),e.soutersInk=function(o){if(!t.IS_SOUTERS)return o;const c=(0,n.normaliseHex)(o);return c?'#A4622E'===c?'#D9AD8A':(0,n.contrast)(c,u)<4.5?'#FFFFFF':o:o};var t=r(d[0]),n=r(d[1]);const u='#56152A',o='#43122F',c=.88,S=n=>t.IS_SOUTERS?Math.round(n*c*100)/100:n,f=n=>t.IS_SOUTERS?o:n},828,[5,829]); __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normaliseHex=n,e.hexToRgb=r,e.rgbToHex=o,e.hsvToRgb=s,Object.defineProperty(e,"hsvToHex",{enumerable:!0,get:function(){return a}}),e.hexToHsv=function(t){const{r:n,g:o,b:s}=r(t),a=n/255,c=o/255,u=s/255,i=Math.max(a,c,u),h=Math.min(a,c,u),l=i-h;let p=0;l&&(p=i===a?(c-u)/l%6:i===c?(u-a)/l+2:(a-c)/l+4);return{h:(60*p+360)%360,s:i?l/i:0,v:i}},e.luminance=c,e.contrast=u,e.shade=i,e.checkAccent=function(t,r,o,s){const a=n(t)??'#CFA45F',c=u(a,o),h=u(a,s),l=c>=h?o:s,p=[];Math.max(c,h)<4.5?p.push('Button text may be hard to read on this colour. We picked the clearer text colour for you, but a lighter or darker shade will read better.'):l===s&&p.push('This is a dark colour, so buttons use light text.');let b=a,d=0;for(;u(b,r)<4.5&&d<20;)b=i(a,.05*(d+1)),d++;b!==a&&p.push('This colour is hard to read on the dark background, so header text uses a lighter shade of it.');return{onAccent:l,accentText:b,tips:p}},e.pushRecent=function(t,r,o=8){const s=n(r);return s?[s,...(t??[]).filter(t=>t!==s)].slice(0,o):t??[]};const t=(t,n=0,r=1)=>Math.min(r,Math.max(n,t));function n(t){const n=t.trim().replace(/^#/,'');return/^[0-9a-fA-F]{3}$/.test(n)?'#'+n.split('').map(t=>t+t).join('').toUpperCase():/^[0-9a-fA-F]{6}$/.test(n)?'#'+n.toUpperCase():null}function r(t){const r=(n(t)??'#000000').slice(1);return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function o({r:n,g:r,b:o}){return'#'+[n,r,o].map(n=>Math.round(t(n,0,255)).toString(16).padStart(2,'0')).join('').toUpperCase()}function s({h:t,s:n,v:r}){const o=(t%360+360)%360/60,s=r*n,a=s*(1-Math.abs(o%2-1)),c=r-s,[u,i,h]=o<1?[s,a,0]:o<2?[a,s,0]:o<3?[0,s,a]:o<4?[0,a,s]:o<5?[a,0,s]:[s,0,a];return{r:255*(u+c),g:255*(i+c),b:255*(h+c)}}const a=t=>o(s(t));function c(t){const n=t=>{const n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)},{r:o,g:s,b:a}=r(t);return.2126*n(o)+.7152*n(s)+.0722*n(a)}function u(t,n){const r=c(t),o=c(n);return(Math.max(r,o)+.05)/(Math.min(r,o)+.05)}function i(t,n){const{r:s,g:a,b:c}=r(t),u=n>0?255:0,i=Math.abs(n);return o({r:s+(u-s)*i,g:a+(u-a)*i,b:c+(u-c)*i})}},829,[]); __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,"isEditable",{enumerable:!0,get:function(){return u}}),_e.hideKeyboard=s,_e.installKeyboardHide=f,_e.useTyping=function(){const[e,n]=t.default.useState(c);return t.default.useEffect(()=>{if(!o)return;f();const e=()=>setTimeout(()=>n(c()),0);return document.addEventListener('focusin',e,!0),document.addEventListener('focusout',e,!0),()=>{document.removeEventListener('focusin',e,!0),document.removeEventListener('focusout',e,!0)}},[]),e},_e.useVisibleArea=function(){const e=o?window.visualViewport:null,n=()=>e?{height:Math.round(e.height),top:Math.round(e.offsetTop)}:null,[u,c]=t.default.useState(n);return t.default.useEffect(()=>{if(!e)return;const t=()=>c(e=>{const t=n();return e&&t&&e.height===t.height&&e.top===t.top?e:t});return e.addEventListener('resize',t),e.addEventListener('scroll',t),()=>{e.removeEventListener('resize',t),e.removeEventListener('scroll',t)}},[]),u};var t=e(r(d[0])),n=e(r(d[1]));r(d[2]);const o='undefined'!=typeof document,u=e=>!!e&&'function'==typeof e.matches&&e.matches("input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]"),c=()=>!!o&&u(document.activeElement);function s(){try{n.default.dismiss()}catch{}o&&u(document.activeElement)&&document.activeElement.blur()}function a(){if(!o)return;const e=document.activeElement;if(u(e))try{e.scrollIntoView({block:'nearest',inline:'nearest'})}catch{}}let l=!1;function f(){o&&!l&&(l=!0,document.addEventListener('click',e=>{if(!c())return;const t=document.activeElement;if('function'!=typeof t.closest||!t.closest('[aria-modal="true"], [role="dialog"]'))return;const n=e.target;n&&!u(n)&&('function'==typeof n.closest&&n.closest('label, [data-keep-keyboard]')||s())},!0),document.addEventListener('focusin',e=>{u(e.target)&&setTimeout(a,300)},!0),window.visualViewport?.addEventListener('resize',()=>setTimeout(a,50)))}},830,[34,376,236]); -__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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 O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:u,phone:g,email:m})=>{const p=t(),b=p.basket,f=b.restaurantId,k=w(b,p.menu,p.customer.allergies),I=k.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,h=$(p.orders.filter(e=>e.restaurantId===f).map(e=>e.ref),S?'Q-':'T-',S?p.counters.table:p.counters.order),O=u?n(o,f,I+i):0,C=I+i,v={id:(0,y.uuid)(),ref:`${S?'Q':'T'}-${h}`,restaurantId:f,customerId:p.customer.id,customerName:p.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:k,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:u?C:0,status:'new',createdAt:a().toISOString(),allergies:p.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:g??p.customer.phone,email:m??p.customer.email}:{}};e(e=>({orders:[v,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:h}:{...e.counters,order:h}}));const A=k.filter(e=>e.overridden);return r(f,'order',`Order ${v.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${A.length?` \u2014 ALLERGY OVERRIDE on ${A.map(e=>e.name).join(', ')}`:''}`),v.allergies.length&&r(f,'allergy',`Allergies declared and confirmed by customer on ${v.ref}: ${v.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),c(v),v},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); +__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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,choiceIds:s.map(e=>e.id)}]})}const O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:n,tip:s,notes:i,phone:o,email:l,customerName:u})=>{const g=t(),m=g.basket,p=m.restaurantId,b=w(m,g.menu,g.customer.allergies),f=b.reduce((e,t)=>e+t.unitPrice*t.qty,0),k='table'===m.mode,I=$(g.orders.filter(e=>e.restaurantId===p).map(e=>e.ref),k?'Q-':'T-',k?g.counters.table:g.counters.order),S=!k,h=f+(S?0:s),O=(u??'').trim()||g.customer.name,C={id:(0,y.uuid)(),ref:`${k?'Q':'T'}-${I}`,restaurantId:p,customerId:g.customer.id,customerName:O,type:m.mode,tableNo:m.tableNo,slotTime:n,lines:b,subtotal:f,tip:S?0:s,giftCardApplied:0,giftCardCode:void 0,total:h,paid:0,status:S?'awaiting_payment':'new',createdAt:a().toISOString(),allergies:g.customer.allergies,readiness:{},notes:i,channel:'app',...'takeaway'===m.mode?{phone:o??g.customer.phone,email:l??g.customer.email}:{}};e(e=>({orders:[C,...e.orders],basket:{...e.basket,lines:[]},counters:k?{...e.counters,table:I}:{...e.counters,order:I}}));const v=b.filter(e=>e.overridden);return r(p,'order',`Order ${C.ref} placed (${k?`Table ${m.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),C.allergies.length&&r(p,'allergy',`Allergies declared and confirmed by customer on ${C.ref}: ${C.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),'awaiting_payment'!==C.status&&c(C),C},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WILDINGS_LOCATION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WILDINGS_ADDRESS",{enumerable:!0,get:function(){return t}}),e.withWildingsAddress=function(r){return'wildings'===r.id?{...r,location:n,address:t}:r},e.withWildingsQuestionnaireAddress=function(n,r){return'wildings'===n&&r?{...r,venue:{...r.venue,address:t}}:r};const n='Maidens, KA26 9NR',t='Maidens Road, Maidens, KA26 9NR'},832,[]); __d(function(g,r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sampleFingerprint=i,e.stripOwnerLiveSamples=function(n){const a={};for(const[s,o]of Object.entries(t.OWNER_SAMPLE_HASHES)){const t=n[s]||[];a[s]=t.filter(t=>!o.includes(i(t)))}a.chat=(n.chat||[]).filter(t=>!(0,s.isSeedChefChat)(t));const o=(n.changeRequests||[]).length-a.changeRequests.length;o&&(a.changesUsed=Math.max(0,(n.changesUsed||0)-o));return a},e.stripCoreLiveSamples=function(a){const c={...(0,n.stripCoreChefSamples)(a)};c.giftCards=(a.giftCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.giftCards.includes(i(s))),c.stampCards=(a.stampCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.stampCards.includes(i(s))),c.ratings=(a.ratings||[]).filter(t=>!(/^rt-[123]$/.test(t.id)&&(0,s.demoActor)(t.customerName))),i(a.customer)===t.LEGACY_CUSTOMER_HASH&&(c.customer={...a.customer,id:'',name:'',email:'',phone:'',allergies:[],allergyConsent:!1,referralCode:'',marketingOptIn:{}});return c.restaurants=(a.restaurants||[]).filter(t=>!('saltmarsh'===t.id&&['The Venue','Saltmarsh Bistro'].includes(t.name))),c.menu=(c.menu||a.menu||[]).filter(t=>'saltmarsh'!==t.restaurantId).map(t=>t.signOff?t:o(t)),c};var t=r(d[0]),s=r(d[1]),n=r(d[2]);const a=t=>Array.isArray(t)?t.map(a):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&'function'!=typeof t).sort(([t],[s])=>ts?1:0).map(([t,s])=>[t,a(s)])):t;function i(t){const s=JSON.stringify(a(t))??"null";let n=2166136261;for(let t=0;t>>0).toString(16)}const o=t=>Array.isArray(t)?t.map(o):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).map(([t,s])=>[t,'allergenNotes'===t&&'string'==typeof s&&/\(example\)/i.test(s)?'':o(s)])):t},833,[834,835,836]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"OWNER_SAMPLE_HASHES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CORE_SAMPLE_HASHES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"LEGACY_CUSTOMER_HASH",{enumerable:!0,get:function(){return b}});const c={referrals:["43f09bc0","c438fbad","96bf8c62","3399d421"],coats:["f51097ad","2f7efa3a"],merch:["ef6e14e","dbbc0999","dc233c1d"],merchOrders:["13b15512","bc27f242"],offers:["ad0fcde0","59e6c0cf"],photos:["53a60fd9","ab778a74","95de43cd"],changeRequests:["81c5be12","6819542c"],lost:["5bbf0d77","7d3aa9ed","850c049e"],campaigns:["9cdf8346","82150e7"],suppliers:["41df06e7","466e32ac","fa3d8eea","dfafa674","1e26fbd0","c195b120","5fc49e74","6aa8b0af","602fc2e4"],supplierOrders:["22636226","464d6a6a"]},f={giftCards:["b1bba36d","f029bc0e"],stampCards:["e7bedf6f","a3c8404d"]},b="4b1e9971"},834,[]); @@ -1067,519 +1067,522 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},984,[835]); __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 t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(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 u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{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}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},985,[984]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},986,[872,34,102,987,2,821,794,25]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return W.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return W.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return W.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return W.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return W.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return I.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return I.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return It}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ne.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ne.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ne.useOwner.getState().chatSeen(t,e)),Ft(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ne.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...St(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(le.PITCH)return pe.unlockCashUp(e,t,a);const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?oe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):oe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(le.PITCH)return pe.cashAudit(e);const t=Oe.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(ma.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=fa,i.readAccessLog=async function(){const e=Oe.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Oe.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return pa}}),i.uploadOrderLogo=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(pa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ga.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(pa).createSignedUrl(e,3600);if(t?.signedUrl)return ga.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(pa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return ma}}),i.claimInvite=Da,i.makeChromeHandover=async function(){const e=Oe.getState();if(le.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ue});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(le.PITCH||!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ue});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),Pe&&xa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Te();const t=await x.kv.get(ka,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Te(),await x.kv.get(Ia,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_WILDINGS||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Te(),await x.kv.remove(ka),await x.kv.remove(Ia),Ae({mode:'signin',perms:[]});try{await Ma()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Oe.getState().venueId;if(le.PITCH||!s||'staff'!==Oe.getState().kind)return{ok:!0};if(!(0,ie.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ka('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Da(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(le.PITCH)return pe.reissueInvite(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ka('staff_app_link_history',{p_venue:Oe.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ka('revoke_staff_app_link',{p_venue:Oe.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(le.PITCH)return pe.linkPhones();const e=Oe.getState().venueId;if(!e||'staff'!==Oe.getState().kind)return{};try{const t=await Ka('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(le.PITCH)return pe.resetPhone(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ka('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(le.PITCH)return pe.inviteStatus();const e=Oe.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:t,error:a}=await Re().rpc(o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_pairing_code':o.IS_GREENSIDE?'claim_greenside_pairing_code':o.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':o.IS_KIRKTON?'claim_kirkton_pairing_code':o.IS_WILDINGS?'claim_wildings_pairing_code':o.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':o.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await x.kv.set(ba,n),xa(),{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}`}}},i.carPairStart=async function(){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await x.kv.set(Ua,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ea(e)}}},i.carPairPoll=async function(e){try{Te();const t=e??await x.kv.get(Ua,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,G.carPairApproved)(n)){const e=(0,G.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await x.kv.get(ba,null);await x.kv.set(ba,e),await x.kv.remove(ka),O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||xa()}return'revoked'!==i&&'unknown'!==i||await Ta(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Te(),await Re().rpc('car_sign_out')}catch{}await Ta(),await Ma();try{await Re().auth.signOut({scope:'local'})}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ka('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ea(e)}}},i.carList=async function(){const e=Oe.getState().venueId;if(!e)return[];return(await Ka('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ka('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ea(e)}}},i.unpairDisplay=async function(){await x.kv.remove(ba),await Ma();try{await Re().auth.signOut()}catch{}Ae({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await x.kv.remove(ka),await x.kv.remove(Ia),await Ma();try{await Re().auth.signOut()}catch{}Ae({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.'})},i.wipeThisDevice=async function(e={}){try{await Ma()}catch{}try{(0,T.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${o.VENUE_RID}:`)):(0,I.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!o.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Na,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ka}}),i.mendSession=qa,i.startAppSync=async function(e=o.VENUE_RID){if(o.IS_ISOLATED_VENUE&&e!==o.VENUE_RID)return;if(Pe)return;Pe=!0,La=e,'customer'===Ue&&'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Te(),'customer'!==Ue){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ue&&(0,h.isAnchorage)(e)?[H.useStore,ne.useOwner,ae.useKitchen,se.useSafety,Y.useCardStore,m.useGpCalc,X.useOrderSheets,S.useSpecials,A.useHr]:[H.useStore,ne.useOwner,ae.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ue&&(0,h.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ae({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await vs(e)}catch{if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e))return void Ae({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,T.isSupabaseConfigured)())return void Ae({mode:'off'});j.mutationQueue.subscribe(()=>{const e=j.mutationQueue.waiting,t=e[0];Ae({pending:j.mutationQueue.pending.length,failed:j.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,L.describeWrite)(t)}: ${(0,L.plainReason)({...t.lastErr},'retry')}`:void 0})}),j.mutationQueue.onFailed(e=>Ae({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:j.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,L.describeWrite)(e),why:'conflict'===e.reason?(0,L.plainReason)({code:'conflict'},'refused'):(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Ke.push((0,N.onConnectivity)(e=>Ae({mode:e?Oe.getState().venueId?'live':Oe.getState().mode:Oe.getState().venueId?'offline':Oe.getState().mode}))),await Ba()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return za}}),i.stockSaveBlocker=Za,i.stockEventStatus=function(e){if(ze(e))return{state:'saved'};const t=j.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,L.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=Ya,i.saveStockEventsNow=Xa,i.bookingSaveBlocker=ts,i.resendUnsavedBookings=ns,i.saveBookingsNow=is,i.waitForBookingSave=function(e,t=12e3){if(!De())return Promise.resolve({state:'local'});const a=ts();if(a)return Promise.resolve({state:'refused',why:a});const s=as()[0]?.venueId??'',n=()=>es.some(t=>j.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=F.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,N.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(j.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(j.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||as().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||as().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=cs,i.tempLogState=function(){const e=ls()[0]?.venueId??'',t=ls().find(e=>'temp_readings'===e.spec.table),a=j.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!j.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values($.useTempSaves.getState().notSaved),i=se.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=fs,i.waitForTempSave=function(e,t,a=1e4){if(!De()||!ls().length)return Promise.resolve({state:'local'});const s=cs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ls()[0]?.venueId??'',i=ls().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>$.useTempSaves.getState().notSaved[(0,$.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>j.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=_s,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ts}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Es.get(a);if('customer'!==Ue||!(0,T.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Es.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ka('public_day',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:qe(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:qe(a.from_time),to:qe(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Es.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ts.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Es.get(a);e&&!e.ok&&Es.delete(a)}));const n=Es.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Oe.getState().venueId;if(!n||'staff'!==Oe.getState().kind)throw new Error('Connect to your venue first.');const i=await Ka('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});H.useStore.getState().updateRestaurant(e,{...i,id:e})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(fe),ge=t(r[60]),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]);const Re=()=>(0,E.getSupabase)();j.mutationQueue.setExecutor(q.executeMutation),(0,P.setClockServer)(()=>'staff'===Oe.getState().kind);const Oe=(0,U.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ae=e=>Oe.setState(e),Ce=e=>{const t=Oe.getState().perms;return t.includes('*')||t.includes(e)},De=()=>{const e=Oe.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Oe.subscribe(()=>(0,ve.setLiveData)(De()));let Ue=V.IS_CAR?'car':V.APP_VARIANT,Ee=!1;const Te=()=>{Ee||((0,x.setSyncNamespace)(Ue),Ee=!0)};let Ne=[],Ke=[],Pe=!1;const Me=()=>(new Date).toISOString().slice(0,10),xe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),qe=e=>e?e.slice(0,5):'',Le=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))):[],Be=e=>JSON.parse(JSON.stringify(e));function je(e,t){const a=xe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>H.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Be(e);if(t)return{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:Le(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,ie.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:Le(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Fe(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>H.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.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,ie.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Be(e.lines??[]),allergies:Le(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:Be(e.allergyChain??{}),readiness:Be(e.readiness??{}),allergy_ticks:Be(e.allergyTicks??{}),handover_check:e.handoverCheck?Be(e.handoverCheck):null,accepted:e.accepted?Be(e.accepted):null,doc:Be(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)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function $e(e){const t=xe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...J.useBlocks.getState().blocks,...J.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Oe.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:Be(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,J.blockClock)(t.from_time)??a?.from,n=(0,J.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>J.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>J.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let We=null,Qe='Main plan';function He(e){const t=e=>Be({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(z.useFloor.getState().plans[e]??(0,z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Ce('floor.manage')||Ce('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:We??(0,be.uuidFrom)(`plan:${a}`),venue_id:a,name:Qe||'Main plan',is_active:!0,...t(e),updated_by:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>(We=String(e.id),Qe=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,ke.withSeedBest)(e,t[0]):void 0;a&&z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ve(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Z.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Ce('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,ie.isUuid)(e.supplierId)?e.supplierId:(0,be.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),ot.get(t)??t)}:{}};var t},apply:(t,a)=>Z.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Ge=new Set,Je=new Set;j.mutationQueue.onDone(e=>{'stock_events'===e.table&&Je.add(e.rowKey)});const ze=e=>Je.has(e)||Ge.has(e),Ze=()=>Ce('*')||Ce('staff.manage')||Ce('recipes.edit')||Ce('recipes.signoff'),Ye=()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write'));function Xe(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Z.useShellStore.getState().events.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,ie.isUuid)(t.id)&&!!(Z.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('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,ie.isUuid)(e.undoes)&&(ze(e.undoes)||j.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Ge.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)=>Z.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function et(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Z.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={...Z.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Z.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Ge]}}}))},afterRead:()=>{Z.useShellStore.getState().server[e]||Z.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Ge]}}}))},subscribe:()=>()=>{}}}const tt=new Set;function at(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=H.useStore.getState().menu;return Y.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:t=>(0,ie.isUuid)(t.card.id)&&!((0,h.isAnchorage)(e)&&(0,h.isDemoCard)(t.card))&&!(0,h.isPlaceholderCard)(t.card),writable:()=>Ce('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,h.isAnchorage)(e)&&(s={...s,signOff:(0,h.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,h.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,h.isAnchorage)(e)&&(0,h.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,be.photoPath)(a,s),t=st(s.photo);t&&((0,Y.cachePhotoAs)(e,t),nt(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,be.cardToRow)(s,a);return{...i,...r,doc:Be({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,h.isPlaceholderCard)(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,signOff:(0,h.isAnchorage)(e)&&(0,h.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Ce('recipes.edit')&&t.length){const e=new Set(t);Y.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);Y.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&H.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&H.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=Y.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=H.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const st=e=>(0,Y.readLocalPhoto)(e);async function nt(e,t){if(!tt.has(e)){tt.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(be.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){tt.delete(e),Ae({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const it=new Map,rt=(0,U.create)(()=>({n:0}));(0,Y.setStoragePhotoResolver)(e=>{const t=it.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,T.isSupabaseConfigured)()&&'off'!==Oe.getState().mode?(t||(it.set(e,{url:'',at:Date.now()}),Re().storage.from(be.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(it.set(e,{url:t.signedUrl,at:Date.now()}),rt.setState(e=>({n:e.n+1})),Y.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const ot=new Map;const dt=(e,t)=>{const a=(0,ie.isUuid)(t)?t:(0,be.uuidFrom)(`sup:${e}:${t}`);return ot.set(a,t),a};function ut(e){return{name:'order_sheets',table:'suppliers',list:()=>X.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,h.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Ce('suppliers.manage'),toRow:(e,t)=>({id:dt(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:Be(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(ot.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>X.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>X.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,ie.isUuid)(e)?e:(0,be.uuidFrom)(`sup:${Oe.getState().venueId}:${e}`)})}}let ct=!1,lt=!1;const ft=new Map,pt=new Map,gt=new Map,mt=new Map,_t=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',St=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'},ht=(e,t)=>({...e,managerAccess:t}),yt=()=>({nickname:ct,display:lt}),wt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=ht({role:e.role,level:e.level??St(_t(e)).level},!0===e.managerAccess);return(0,B.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},yt())};const vt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},bt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},kt=e=>{const t=ne.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,d.isKitchenTeam)(t)},It=2e3;function Rt(e,t){return t||!e.length||e.length>=It?null:e=>(0,ie.isUuid)(e.id)}function Ot(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,Ce('rota.manage')):null,keepOnEmpty:()=>e&&!Ce('rota.manage'),list:()=>ne.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&ft.has(e.staffId)&&(Ce('rota.manage')||kt(e.staffId)),writable:()=>Ce('rota.manage')||Ce('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(vt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:bt(e.start),end_time:bt(e.end),published:!!e.published,doc:Be(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function At(){const e=xe(62),t=e=>Ce('rota.manage')||e.staffId===Oe.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ne.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&t(e),writable:()=>'staff'===Oe.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=xe(2)&&e.staffId===Oe.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Be(e.breaks??[]),break_mins:e.breakMins??0,doc:Be((0,y.privateAttendance)(o.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,y.privateAttendance)(o.VENUE_RID,{...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Ct(){const e=xe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.staffId===Oe.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Oe.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:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,ie.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:Be({...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Dt(e){ne.leaveRemote.decide=t=>!(!Ce('rota.manage')||!(0,ie.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(j.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Ke.push(()=>{ne.leaveRemote.decide=null})}function Ut(e){ne.timesheetRemote.send=(t,a)=>{if(!Ce('rota.manage')||!(0,ie.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return j.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:Be(s)}}),!0}const s=a;if('attendance_void'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return j.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:Be(s.breaks??[]),p_reason:n,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0},Ke.push(()=>{ne.timesheetRemote.send=null})}function Et(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>H.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Oe.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,ie.isUuid)(a)?a:(0,be.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,ie.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Be(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>H.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=>H.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Tt=e=>H.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Nt(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}));H.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Kt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=H.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Be({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Tt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Ce('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Mt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...Mt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Mt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Pt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Pt=t.feature_flags??{},Mt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Be({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}:{}})},apply:t=>{const a=t[0];a&&(H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,l.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Nt(e,a.events))},subscribe:e=>{const t=H.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Pt=null,Mt=null;const xt=()=>new Date(Date.now()-2592e6).toISOString(),qt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ft.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Lt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?(0,Se.dmId)(t[0],t[1]):null},Bt=()=>Oe.getState().perms.includes('*');function jt(){const e=()=>Oe.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ne.useOwner.getState().chat.filter(e=>(0,ie.isUuid)(e.id)).map(e=>Be({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=>!!qt(t.ch)&&(t.from===e()||Bt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('created_at',xt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=xt(),toRow:(e,t)=>{const a=qt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ft.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=Lt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?pt.get(String(e.from_staff)):'system';return s?Be({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ne.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?pt.get(String(t.from_staff)):'system',i=Lt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ne.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,Se.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,he.soundAllowed)())try{(0,he.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,b.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Ft(e,t,a){const s=Oe.getState();if(!_e.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ft.get(e),i='*'===t?'*':qt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function $t(e){const t=Oe.getState().staffRef,a=t?ft.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Lt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ne.useOwner.getState().chatMarkRead(t,i)}catch{}}function Wt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=C.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Be(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>C.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,D.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Qt(e){const t=xe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>C.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.reminderId)&&e.staffRef===Oe.getState().staffRef,writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>C.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Ht(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Vt=e=>null==e||''===e?null:Number(e),Gt=e=>e.filter(e=>!e.startsWith('data:')),Jt=()=>Ce('takings.view');function zt(e){const t=!Jt();return{name:'cash_ups',table:'cash_ups',list:()=>oe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,v.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,v.tradingDay)()&&!e.onServer),writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,v.tradingDay)()):e.gte('for_date',xe(400)),...t?{inWindow:e=>e.date===(0,v.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:Be(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({cashUps:Ht(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Zt(e){return{name:'sales_reports',table:'sales_reports',list:()=>oe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Be(e.vals),categories:e.categories,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({sales:Ht(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Yt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=oe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,oe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Be({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,oe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>oe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function Xt(e){return{name:'day_tips',table:'day_tips',list:()=>oe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',xe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>oe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ea(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>oe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Vt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>oe.useCashUp.setState(s=>({pot:Ht(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function ta(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=oe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Ce('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>oe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function aa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>re.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Be(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>re.useNotifs.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>re.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function sa(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=de.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Be(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>de.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ue.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Ht(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function na(e){const t=()=>Ce('venue.settings')||Ce('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>de.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,ie.isUuid)(a.id)&&(0,ie.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,de.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Oe.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Oe.getState().staffRef)||null,doc:Be(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ia(e){const t=xe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>de.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Be(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({history:Ht(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function ra(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=ce.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Be(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&ce.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,y.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>ce.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function oa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=ge.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,ge.libraryRowId)(e),kind:'library',doc:Be({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,ge.personRowId)(e,i),kind:'person',staffRef:i,doc:Be({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ne.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,me.canEditTasks)(t,a)},writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>ge.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,ge.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function da(e){const t=xe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>ge.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Oe.getState();return e.byRef===t.staffRef||Ce('staff.manage')},writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>ge.useDailyTasks.setState(s=>({ticks:Ht(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ua(e,t=!1){const a=xe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>ye.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind||Ce('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,be.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>ye.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>ye.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{we.autoSync.soldOutRead.add(e)}}}function ca(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>we.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:(0,be.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>we.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>we.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{we.autoSync.linksRead.add(e)}}}async function la(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&x.kv.get(a,!1):(x.kv.set(a,!0),!0)}catch{return x.kv.get(a,!1)}}async function fa(){const e=Oe.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();ma.setState({live:!!t?.push_live,known:!0})}catch{}}const pa='order-list-logos';const ga=new Map;const ma=(0,U.create)(()=>({live:!1,known:!1}));async function _a(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('reminders:ok',!1):(x.kv.set('reminders:ok',!0),!0)}catch{return x.kv.get('reminders:ok',!1)}}async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('chat:ok',!1):(x.kv.set('chat:ok',!0),!0)}catch{return x.kv.get('chat:ok',!1)}}const ha=(e,t)=>Be({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),ya='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function wa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>A.useHr.getState().questions.filter(t=>t.venue===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ha(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);A.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>A.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function va(e,t){const a=(t,a,s)=>{j.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(A.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(ya).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||A.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ha(e,t)))}catch{}}}),Ke.push(()=>{Object.assign(A.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ba='pair:v1',ka='staff:v1',Ia='staff:rejoin:v1';async function Ra(e){const t=o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_invite':o.IS_GREENSIDE?'claim_greenside_invite':o.IS_ABBOTSFORD?'claim_abbotsford_invite':o.IS_KIRKTON?'claim_kirkton_invite':o.IS_WILDINGS?'claim_wildings_invite':o.IS_KIRKMICHAEL?'claim_kirkmichael_invite':o.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ue,p_device:(0,O.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,O.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Oa(){if('display'===Ue||'customer'===Ue||le.PITCH)return'none';const e=await x.kv.get(Ia,null);if(!e)return'none';try{await Ca();const{data:t,error:a}=await Ra(e);if(a)return(0,I.inviteRefusal)(a.message)?(await x.kv.remove(Ia),await x.kv.remove(ka),'refused'):'offline';const s=t?.[0];return s?(await x.kv.set(ka,{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,displayName:s.display_name}),'ok'):(await x.kv.remove(Ia),'refused')}catch{return'offline'}}const Aa=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Ca(){Te();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ae({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 Da(e){if(le.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,I.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Ra(e);if(a){const e=(0,I.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,o.venueKey)(`cc-pending-invite:${Ue}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),await x.kv.set(Ia,e),Pe&&xa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ae({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ua='car:request:v1',Ea=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Ta(){await x.kv.remove(ba),await x.kv.remove(ka),await x.kv.remove(Ua),O.useSession.getState().meId&&O.useSession.getState().signOut()}async function Na(){if(!(0,T.isSupabaseConfigured)())return!1;try{return await Ca(),!0}catch{return!1}}const Ka=async(e,t={})=>{if(le.PITCH)return(0,fe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Pa=null;async function Ma(){for(const e of Ke)try{e()}catch{}Ke=[],Ne.forEach(e=>e.stop()),Ne=[],Pa&&(clearInterval(Pa),Pa=null)}async function xa(){await Ma(),await Ba()}async function qa(){if(!(0,T.isSupabaseConfigured)()||'customer'===Ue||le.PITCH)return!1;try{Te();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ue)return!1;if(!await x.kv.get(Ia,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Oa()&&(xa(),!0)}catch{return!1}}(0,u.setSessionMender)(qa);let La=o.VENUE_RID;async function Ba(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=La;try{if(Ae({mode:'connecting'}),await j.mutationQueue.load(),'customer'===Ue)return void await Ha(e);let t=await x.kv.get(ba,null),a=await x.kv.get(ka,null);if(V.IS_CAR&&!t&&a){const e=(0,G.migrateCarStaffIdentity)(a);e&&(t=e,await x.kv.set(ba,t)),await x.kv.remove(ka),a=null,O.useSession.getState().meId&&O.useSession.getState().signOut()}if(o.IS_ISOLATED_VENUE&&(t&&!(0,o.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,o.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ae({mode:'display'===Ue?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ue&&!V.IS_CAR&&a&&!s.session){const t=await Oa();if('offline'===t)return Ae({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{La===e&&xa()},6e4);'refused'===t&&a.staffRef&&O.useSession.getState().meId===a.staffRef&&O.useSession.getState().signOut(),a=await x.kv.get(ka,null),({data:s}=await Re().auth.getSession())}const n='display'===Ue||V.IS_CAR?t:a;if(!s.session||!n)return void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ka('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ue||V.IS_CAR?await x.kv.remove(ba):(await x.kv.remove(ka),await x.kv.remove(Ia)),'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId===n.staffRef&&O.useSession.getState().signOut(),void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ue?'This display was unpaired by a manager.':V.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,N.isOnline)()||/fetch|network/i.test(String(t?.message)))Ae({mode:'offline'});else if(Aa(t)&&'display'!==Ue){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Oa()&&setTimeout(()=>{La===e&&xa()},500)}i=Oe.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ae({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!V.IS_CAR&&'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId!==n.staffRef&&(O.useSession.getState().signIn(n.staffRef),ne.useOwner.setState({staffAs:n.staffRef})),V.IS_CAR&&(O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({previewRole:'owner'})),await Fa(n.venueId,e,n.kind)}catch(e){Ae({mode:'local',lastError:String(e?.message??e)})}}const ja=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','venue_reminders','reminder_done']);async function Fa(e,a,s){if(!(0,o.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||V.IS_CAR&&'device'===s;await _s(a),Ke.push(Us(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])gt.set(e.key,e.id),mt.set(e.id,e.key)}catch{}const i=[Kt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ne.useOwner.getState().staff.map(wt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Ce('staff.manage'),deletes:!1,revision:e=>(0,B.staffRevision)(e,yt()),toRow:(e,t)=>(0,B.staffRow)(e,t,yt(),e.managerAccess||e.ownerAccess?null:gt.get(_t(e))),fromRow:e=>{if(!e.external_ref)return null;ft.set(String(e.external_ref),String(e.id)),pt.set(String(e.id),String(e.external_ref)),Os.set(String(e.external_ref),e.avatar_path??null);const t=ht(St(mt.get(String(e.role_id))),!0===e.manager_access);return(0,B.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},yt())},apply:e=>ne.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=>ne.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ds()},onRemote:()=>{Ds()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ne.useOwner.getState(),t=te.useSetup.getState().sites[La]?.staffGrade??{};return e.staff.filter(e=>ft.has(e.id)).map(a=>Be({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=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ft.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=pt.get(String(e.staff_id));return t?Be({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=>ne.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=te.useSetup.getState().sites[La],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&&te.useSetup.getState().patch(La,{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=ne.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=te.useSetup.subscribe((t,a)=>{t.sites[La]?.staffGrade!==a.sites[La]?.staffGrade&&e()});return()=>{t(),a()}}},je(a,!1),je(a,!0),$e(a),He(a),Fe(a),Ve(a),Xe(a),et(a),ut(a),{name:'supplier_directory',table:'suppliers',list:()=>ne.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('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:Be(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ne.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId),writable:()=>Ce('suppliers.order')||Ce('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||Me(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Be(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},at(a),ks(a)];Ce('wages.view')&&i.push(Is(a)),n&&(i.push(Ot(!0),At(),Ct(),Et(a)),Ut(e)),n&&await la('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Oe.getState().staffRef&&'pending'===e.status||Ce('rota.manage')),writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Be(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),ja.add('staff_leave'),Dt(e));const d=n&&await Sa();if(_e.useChatSync.setState({synced:d,checked:!0}),Ke.push(()=>_e.useChatSync.setState({synced:!1})),d&&i.push(jt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(Se.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ft.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ft.get(e.id),include:e.include}),fromRow:e=>{const t=pt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>Se.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=>Se.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await la('hr_questions')&&(i.push(wa(a)),ja.add('hr_questions'),va(e,a)),'guest'!==s&&'customer'!==Ue&&await la('temp_readings')&&(i.push((0,W.tempUnitsSpec)(se.useSafety,Ze),(0,W.tempReadingsSpec)(se.useSafety,Ye)),ja.add('temp_units'),ja.add('temp_readings')),'guest'!==s&&await la('sold_out_items')?(i.push(ua(a,await la('sold_out_items','auto'))),ja.add('sold_out_items')):we.autoSync.soldOutRead.add(a),'guest'!==s&&await la('sold_out_links')?(i.push(ca(a)),ja.add('sold_out_links')):we.autoSync.linksRead.add(a),C.useReminders.getState().ensure(a),'guest'!==s&&await _a()&&(i.push(Wt(a)),n&&i.push(Qt(a))),re.useNotifs.getState().ensure(a),de.useOrderLists.getState().ensure(a),n){ct=await la('staff','nickname'),lt=await la('staff','display_clock');const[e,t,s,n]=await Promise.all([la('scheduled_notifications'),la('order_lists'),la('venue_clock_area'),la('daily_tasks')]);ge.useDailyTasks.getState().ensure(a),n&&(i.push(oa(a),da(a)),ja.add('daily_tasks'),ja.add('daily_task_ticks')),e&&(i.push(aa(a)),fa()),t&&i.push(sa(a),na(a),ia(a)),s&&i.push(ra(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&ja.add(n)}if('guest'!==s&&await la('day_tips')){i.push(Xt(a));for(const e of['day_tips','tips_pot_events','tips_settings'])ja.add(e);await la('tips_pot_events')&&i.push(ea(a),ta(a)),n&&(Jt()||(0,oe.forgetPastTakings)(a,(0,v.tradingDay)()),i.push(zt(a),Yt(a)),ja.add('cash_ups'),Jt()&&(i.push(Zt(a)),ja.add('sales_reports')),t(r[72])(r[71],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Ot(),At()),await la('scheduled_notifications')&&i.push(aa(a)));let u=!1;const c=()=>{if(V.IS_CAR&&n&&Ce('recipes.edit'))return!0;const e=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);return!!e&&e.active&&Ce('recipes.edit')&&(0,_.costsAllowedFor)(e)};n&&c()&&await la('ingredient_prices')&&(i.push((0,m.gpSyncSpec)('ing',c)),ja.add('ingredient_prices'),await la('card_costs')&&(i.push((0,m.gpSyncSpec)('card',c)),ja.add('card_costs')),await la('kitchen_deliveries')&&(i.push((0,m.gpSyncSpec)('del',c)),ja.add('kitchen_deliveries')),await la('kitchen_stock_counts')&&(i.push((0,m.gpSyncSpec)('count',c)),ja.add('kitchen_stock_counts'))),(0,Ie.specialsSyncOn)()&&'guest'!==s&&await la('specials_boards')&&(i.push((0,Ie.specialsBoardSpec)(a,()=>Ce('recipes.edit')||Ce('floor.manage')||Ce('*'))),ja.add('specials_boards'));const l={onActivity:()=>Ae({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ae({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ae({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Ka('whoami')??[]).some(t=>t.venue_id===e))return void(La===a&&xa());for(const a of Ne){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||F.useBookingSaves.getState().mark({id:t,table:e,why:ts()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||$.useTempSaves.getState().mark({id:t,table:e,why:cs(e)??'this screen could not send it'})}};Ne=i.map(t=>new Q.EntityBridge(t,e,l)),await Promise.all(Ne.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,N.isOnline)())try{const t=await Ka('whoami');if(!t?.some(t=>t.venue_id===e))return void(La===a&&xa())}catch(e){if(Aa(e)){if(V.IS_CAR)return void(La===a&&xa());const e=await Oa();return void('ok'!==e&&'refused'!==e||La===a&&xa())}}let t=0;for(const[a,s]of Ne.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(_e.useChatSync.getState().error&&_e.useChatSync.setState({error:void 0}),await $t(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&_e.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({mode:'live',lastSyncAt:e,lastServerAt:e}),j.mutationQueue.flush()}else Ae({mode:'offline'});if(!Ce('wages.view')){const e=Oe.getState().staffRef;ne.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const S=new Map;for(const e of Ne)S.set(e.spec.table,[...S.get(e.spec.table)??[],e]);const h=[...S.keys()].filter(e=>ja.has(e)).map(e=>({table:e,venueColumn:S.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,Q.venueChannel)(e,h,(e,t,a)=>{for(const s of S.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ae({lastSyncAt:s,lastServerAt:s})},e=>{Ae({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Ke.push(()=>{Re().removeChannel(w)}),Ke.push((0,N.onConnectivity)(e=>{e&&p()}));const b=Ne.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,K.superviseSync)({fastMs:Wa(Ue),readFast:async()=>{for(const e of b)await e.read()},readAll:p,flush:()=>{j.mutationQueue.flush()},wake:()=>{j.mutationQueue.retryNow()},restart:()=>{La===a&&xa()},realtime:()=>Oe.getState().realtime,lastServerAt:()=>{const e=Oe.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Aa,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>$a(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Ke.push(k.stop)}async function $a(e){const t=Oe.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ka('sync_heartbeat',{p_venue:e,p_device:(0,O.deviceId)()??'unknown',p_app:Ue,p_version:M.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Wa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Oe.getState(),queue:j.mutationQueue.pending.map(e=>e.table),failedTables:j.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),le.PITCH&&(window.__ccSyncPreview=e=>Ae(e)));const Qa='guest:sent:v1';async function Ha(e){Ae({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ka('public_venue',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!o.IS_ISOLATED_VENUE||t.id===o.VENUE_UUID)){Ae({venueId:t.id,venueName:t.name}),await _s(e);const a=t.app?.restaurant;a&&H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,l.withWildingsAddress)({...a,id:e}):t)})),Nt(e,t.app?.events)}await Va(e),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ae({mode:(0,N.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Va(e).catch(()=>{})},6e4);Ke.push(()=>clearInterval(t)),o.IS_ISOLATED_VENUE||await Ga(e)}async function Va(e){const t=await Ka('public_menu',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));Y.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&H.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))]}})}async function Ga(e){let t=await x.kv.get(Qa,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=H.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Na())return;for(const a of n)try{const s=(await Ka('guest_create_booking',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_booking:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(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&&H.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'},Ae({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ka('guest_create_takeaway',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_order:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ae({lastError:`Order: ${e?.message}`}))}await x.kv.set(Qa,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ka('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await x.kv.set(Qa,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ka('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));H.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 Ja(n)===Ja(e)?e:n})})),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ae({mode:(0,N.isOnline)()?Oe.getState().mode:'offline'})}finally{a=!1}}};Ke.push(H.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Pa=setInterval(()=>{n()},15e3),n()}const Ja=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),za={bridges:()=>Ne,restart:xa};function Za(){const e=Oe.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Ce('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function Ya(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(!e||Za())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(j.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function Xa(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}Ya();try{await j.mutationQueue.retryNow()}catch{}}Oe.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{Xa()},3e3)});const es=['bookings','walk_ins'];function ts(){const e=Oe.getState();return De()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const as=()=>Ne.filter(e=>es.includes(e.spec.table)),ss=e=>j.mutationQueue.failed.some(t=>es.includes(t.table)&&t.rowKey===e);function ns(e=!1){return ts()?0:as().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ss(t)&&!!F.useBookingSaves.getState().notSaved[t]),0)}async function is(e=!1){const t=ts();if(t)return t;for(const e of as())try{await e.read()}catch{}ns(e);try{await j.mutationQueue.retryNow()}catch{}return e&&rs(),null}function rs(){const e=as()[0]?.venueId??'',t=F.useBookingSaves.getState(),a=new Set(as().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ss(s)||es.some(t=>j.mutationQueue.hasPending(t,e,s))||t.clear(s)}j.mutationQueue.onFailed(e=>{es.includes(e.table)&&F.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{es.includes(e.table)&&F.useBookingSaves.getState().clear(e.rowKey)});let os=null;const ds=(e=2500)=>{os&&clearTimeout(os),os=setTimeout(()=>{os=null,is(!1)},e)};(0,N.onConnectivity)(e=>{e&&ds()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ds(3e3)});const us=['temp_readings','temp_units'];function cs(e="temp_readings"){const t=Oe.getState();return De()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ze()?'device'!==t.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ls=()=>Ne.filter(e=>us.includes(e.spec.table));async function fs(e=!1){const t=cs();if(t)return t;for(const e of ls())try{await e.read()}catch{}const a=ls()[0]?.venueId??'';for(const t of ls())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,j.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await j.mutationQueue.retryNow()}catch{}if(e){const e=$.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ls().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||j.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,$.tempKey)(t.table,t.id))}}return null}j.mutationQueue.onFailed(e=>{us.includes(e.table)&&$.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{us.includes(e.table)&&$.useTempSaves.getState().clear((0,$.tempKey)(e.table,e.rowKey))});let ps=null;const gs=(e=3e3)=>{ps&&clearTimeout(ps),ps=setTimeout(()=>{ps=null,fs(!1)},e)};(0,N.onConnectivity)(e=>{e&&gs()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&gs(3500)});const ms='golive:v1:';async function _s(e){'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)?await vs(e):(await x.kv.get(ms+e,!1)||await vs(e),await x.kv.get(ys+e,!1)||(ws(e),await x.kv.set(ys+e,!0)),await x.kv.get(Ss+e,!1)||(hs(),await x.kv.set(Ss+e,!0)))}const Ss='golive:v3:';function hs(){const e=e=>JSON.stringify(e).includes('(example)');try{ae.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ys='golive:v2:';function ws(e){const t=e=>JSON.stringify(e).includes('(example)');H.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)))})),ne.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 vs(e){if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)){const t=(0,p.stripCoreLiveSamples)(H.useStore.getState()),a=(0,ae.stripKitchenExamples)(ae.useKitchen.getState()),s=ne.useOwner.getState(),n=(0,p.stripOwnerLiveSamples)(s),i={accidents:se.useSafety.getState().accidents.filter(e=>!(0,se.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(H.useStore.getState(),t)&&(await(0,g.archiveChefCache)('core',H.useStore.getState()),H.useStore.setState(t)),r(ae.useKitchen.getState(),a)&&(await(0,g.archiveChefCache)('kitchen',ae.useKitchen.getState()),ae.useKitchen.setState(a)),r(s,n)&&(await(0,g.archiveChefCache)('owner',s),ne.useOwner.setState(n)),r(se.useSafety.getState(),i)&&(await(0,g.archiveChefCache)('safety',se.useSafety.getState()),se.useSafety.setState(i));const o=(0,A.stripHrSamples)(A.useHr.getState());r(A.useHr.getState(),o)&&(await(0,g.archiveChefCache)('hr',A.useHr.getState()),A.useHr.setState(o));const d=(0,m.stripGpSamples)(m.useGpCalc.getState());r(m.useGpCalc.getState(),d)&&(await(0,g.archiveChefCache)('gp',m.useGpCalc.getState()),m.useGpCalc.setState(d));const u=X.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,g.archiveChefCache)('order-sheets',u),X.useOrderSheets.setState(c));const l=Y.useCardStore.getState(),_={cards:l.cards.filter(e=>!(0,f.isLiveVenue)(e.restaurantId)||!(0,h.isDemoCard)(e)),log:l.log.filter(e=>!(0,h.demoActor)(e.by))};return r(l,_)&&(await(0,g.archiveChefCache)('recipe-cards',l),Y.useCardStore.setState(_)),void await x.kv.set(ms+e,!0)}const t=t=>t.restaurantId===e&&!(0,ie.isUuid)(t.id);H.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)))})),J.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,ie.isUuid)(t.id))})),z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ne.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,ie.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,ie.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,ie.isUuid)(e.id)),leave:e.leave.filter(e=>(0,ie.isUuid)(e.id)),swaps:[]}));try{ae.useKitchen.setState(e=>(0,ae.stripKitchenExamples)(e))}catch{}ne.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,ie.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId))}));try{se.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await x.kv.set(ms+e,!0)}const bs=(e,t)=>Be({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function ks(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(z.useFloor.getState().live[e]??{}).map(([e,t])=>bs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Oe.getState().kind||Ce('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:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>bs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>z.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=>z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Is(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(te.useSetup.getState().sites[e]?.grades??te.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:()=>Ce('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=te.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));te.useSetup.getState().patch(e,{grades:i})},subscribe:t=>te.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Rs='staff-avatars',Os=new Map;let As=!1;const Cs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ds(){if(!As){As=!0;try{for(const[e,t]of Os){const a=ee.useAvatars.getState().photos[e];if(!t){a?.path&&ee.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Oe.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Rs).download(t);if(n||!s)continue;const i=await Cs(s);i.startsWith('data:image/')&&ee.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{As=!1}}}function Us(e){const t=async()=>{const t=Oe.getState().staffRef,a=t?ft.get(t)??Oe.getState().staffUuid:void 0;if(!t||!a||'staff'!==Oe.getState().kind)return;const s=ee.useAvatars.getState().photos[t];try{const n=Os.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Rs).remove([t]).catch(()=>{})};if(!s){const e=!!ee.useAvatars.getState().clears?.[t];return e&&n&&(await Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}),Os.set(t,null),i(n)),void(e&&ee.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ae({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Rs).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ka('set_staff_avatar',{p_staff_ref:t,p_path:d}),Os.set(t,d),n!==d&&i(n),ee.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ae({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ee.useAvatars.getState().photos},s=ee.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Ce('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Oe.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Os.set(t,null),ee.useAvatars.getState().doneClear(t),Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Rs).remove([e])).catch(()=>{})}});return t(),s}const Es=new Map,Ts=(0,U.create)(()=>({n:0}))},987,[5,988,932,6,832,837,833,838,989,993,994,835,996,998,999,1000,1001,1002,13,1003,1005,1008,1009,846,933,976,1010,1011,1012,1015,977,1016,1014,1019,1013,1020,1021,1022,1023,831,872,1024,1025,1028,983,883,1030,926,927,1032,1033,891,870,1035,1038,1039,1040,1041,2,1042,1043,1044,1045,1046,1047,979,981,884,863,859,1048,1051,1052]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},989,[837,34,838,5,839,846,849,990,863,870,991,992]); -__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},990,[984]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},991,[990]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},992,[990,991]); -__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},993,[]); -__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},994,[835,837,838,5,839,846,849,995,831,884]); -__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'}}]},995,[]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},996,[6,997]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},997,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},998,[846]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},999,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1000,[846]); -__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1001,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1002,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1003,[839,846,849,5,872,1004,15,1002]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1004,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1005,[838,835,837,5,839,846,849,1006,870]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1007,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1008,[839,846,849,863,1009,870]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1009,[]); -__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)))},1010,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1011,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1012,[34,1013]); -__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1013,[1010,977,1014]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1014,[1010]); -__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.3.12.171'},1015,[]); -__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1016,[1017,1018,933,977,1013]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1018,[977]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1019,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1020,[846,849,839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1021,[846,849,839]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1022,[1023]); -__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1023,[1017,933,1010,977,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1024,[]); -__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1025,[860,839,870,846,849,858,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1026,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1027,[891,1003,1026]); -__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1028,[5,860,839,1029,846,849,859]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1029,[1007]); -__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1030,[837,838,5,839,846,849,1031]); -__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1031,[984]); -__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1032,[837,984,838,835,5,839,846,849]); -__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1033,[837,838,5,839,846,849,1034]); -__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1034,[]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1035,[839,846,849,863,1036,15,870,1037]); -__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1036,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1037,[]); -__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1038,[34,839,846,849,863,13,870]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1039,[839,846,849,863,1040,870,1037]); -__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1040,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1041,[5,996,839,846,849,997]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1042,[1038]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1043,[839,846,849,863,1044,870]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1044,[]); -__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},1045,[846]); -__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(':')}`},1046,[839,846,849]); -__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{}}},1047,[236,872]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1048,[994,1049,1050,976,933]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1049,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1050,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1051,[933,987,998]); -__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1052,[1053]); -__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1053,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1054,[34]); -__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1055,[34,236,402,102,846,821,794,1054,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1056,[34,102,794,1057,821,1058,25]); -__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1057,[827,34,379,236,402,102,821,987,1058,2,872,1015,5,796,797,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1058,[1059,933,987,872,236]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1059,[]); -__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1060,[827,796,34,402,102,794,821,1043,1044,1009,1000,870,891,25]); -__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1061,[828,1062,796,827,34,281,283,364,336,402,102,426,794,821,1038,831,13,1063,1064,1000,1074,1079,1080,1083,1084,1085,1092,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1062,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1063,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1064,[34,876,1065,1066,1063]); -__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1065,[839,846,849]); -__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1066,[6,1067,1068,1069,1070,1071,1072,1073,3]); -__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1067,[]); -__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1068,[]); -__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1069,[]); -__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1070,[]); -__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1071,[]); -__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1072,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1073,[1063]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1074,[236,933,987,1075]); -__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})},1075,[499,1076,1078,1077]); -__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1076,[499,1077,1078]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1077,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1078,[1077]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1079,[933,987]); -__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1080,[34,281,236,102,794,1038,13,1081,821,1082,25]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1081,[13]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1082,[]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1083,[827,2,34,102,794,821,1038,891,13,987,1000,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1084,[13]); -__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1085,[34,1062,281,402,102,794,1086,1087,1091,1092,821,25]); -__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1086,[34,402,102,794,821,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1087,[837,34,874,891,858,872,1024,987,1088,1003,15,1090]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1088,[1089]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1089,[1090]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1090,[858]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1091,[34,872,1092,858,987,933]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1092,[]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1093,[34,1094,891,1008,1009,1000,1046,831,1097]); -__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1094,[996,1041,891,997,1095,1096]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1095,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1096,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1097,[]); -__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1098,[34,986,402,102,1099,794,874,1100,858,1101,821,25]); -__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)'}})]})}},1099,[34,281,283,364,102,1047,821,25]); -__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1100,[861,859]); -__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1101,[34,402,102,794,1100,858,821,25]); -__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1102,[34,102,794,874,877,821,25]); -__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1103,[860,34,102,794,874,1025,1028,1104,1105,877,821,25]); -__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1104,[1028,859,1100]); -__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1105,[860,877]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1106,[860,34,102,794,874,983,891,1100,858,821,25]); -__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1107,[828,827,1055,34,336,379,236,402,102,794,821,1039,1040,1000,1108,1109,987,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1108,[1075,236]); -__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1109,[839,846,849]); -__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1110,[827,996,34,379,402,102,794,821,1035,1036,891,1039,1040,1041,997,1095,987,1058,1000,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1111,[34,1035,891,1039,1112,1008,831,1036,1000,1093]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1112,[846]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1113,[996,34,1041,891,831,997,1009,1095,1000,1094]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1114,[860,34,1000,874,1100,1047]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1115,[860,1116,34,102,794,874,1100,821,1117,1106,1118,1139,1142,1098,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1116,[34,102,14,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1117,[821]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1118,[34,102,1119,821,1120,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1119,[860,1104]); -__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1120,[1121,860,34,1122,987,1124,402,102,874,1028,1119,1123,821,858,794,1125,1025,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1121,[34,859,821,794,25]); -__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1122,[34,402,102,874,1123,1124,987,1020,821,1120,794,25]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1123,[860,1104]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1124,[281,236]); -__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1125,[827,1126,1127,860,867,14,1128,1129,34,859,402,102,872,1087,874,1130,1104,858,821,864,794,1028,1025,1131,1132,1137,1106,1100,1138,1123,1122,25]); -__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1126,[34,402,412,102,1127,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1127,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1128,[34,102,794,25]); -__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1129,[34,236,402,295,102,426,821,794,1000,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1130,[878,858,877]); -__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1131,[34,402,102,878,858,821,794,25]); -__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1132,[860,877,34,102,879,1133,1134,1136,794,874,1028,983,861,867,872,1100,821,25]); -__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1133,[34,402,821,794,25]); -__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1134,[828,860,1135,34,281,236,102,1028,1104,821,794,1106,859,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1136,[34,402,102,874,861,863,821,794,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1137,[1127,1119,1123]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1138,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1139,[1140,34,102,874,1028,1123,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1140,[34,102,874,1028,1119,1141,1123,821,1003,891,872,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1141,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1142,[34,1062,1126,102,874,1028,1025,876,872,1137,861,1003,891,1026,1119,821,858,1131,1116,1128,1143,14,1140,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1143,[34,102,874,872,1137,14,1124,821,794,25]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1144,[34,102,794,1062,1092,1145,1091,1085,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1145,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1146,[34,102,794,827,1033,891,835,1147,821,1148,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1147,[1034]); -__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1148,[34,402,102,1124,987,1149,1021,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1149,[933,976,1010,1018,1013,1016,1150,1151,1152,1153,1154,1155,977]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1150,[1018,933,1016]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1151,[1018,933,976,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1152,[1010,976,1151,1013,1016,1150]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1153,[933,977]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1154,[34,1013]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1155,[933]); -__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1156,[30,34,426,102,846,872,1087,1157,25]); -__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1157,[839,846,849]); -__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()},1158,[1159]); -__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1159,[1160,858,884]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1160,[1161,877,1162,878,858,884,1163]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1161,[858]); -__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'},1162,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1163,[858]); -__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1164,[978,34,835,402,102,874,891,1165,1160,794,821,1087,1158,1032,15,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1165,[34,102,794,874,1038,884,1166,831,13,1163,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1166,[34,884]); -__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1167,[34,402,102,794,867,821,1159,1158,1164,1032,25]); -__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1168,[34,402,102,794,874,1160,858,821,1169,1165,1164,25]); -__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1169,[828,34,283,364,236,102,426,797,794,827,821,1170,25]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1170,[]); -__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1171,[827,984,1172,835,860,1173,1174,34,402,295,102,794,874,882,1175,891,993,861,867,1178,858,821,1179,1112,1087,1159,1158,1180,869,1164,1032,925,1181,1003,987,1184,988,1097,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1172,[1158,984]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1173,[827,34,102,794,874,979,891,980,981,982,831,821,25]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1174,[]); -__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1175,[827,796,34,336,402,102,821,794,874,1176,1055,882,861,863,885,1108,1177,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1176,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1177,[]); -__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])},1178,[858]); -__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1179,[928,828,827,837,5,34,1055,336,402,102,794,891,858,821,1087,1024,925,1046,1045,987,1112,1097,25]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1180,[828,34,102,794,876,831,869,821,925,25]); -__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1181,[928,828,34,395,236,402,102,925,794,926,891,1182,927,831,5,1183,987,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1182,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1183,[933,976,987,977]); -__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1184,[34,402,102,794,891,988,1097,993,987,1090,858,1124,821,25]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1185,[1172,984,34,379,102,794,891,993,867,821,1087,1164,1032,1186,25]); -__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1186,[827,835,984,34,379,236,402,102,794,1030,983,985,867,1031,821,1164,25]); -__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1187,[984,872,34,986,1188,336,402,102,1189,794,985,983,1030,821,874,1100,858,1124,987,25]); -__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1188,[5,822,823,828,236,826]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1189,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1190,[827,1030,1172,984,34,402,102,794,891,867,821,1164,1032,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1191,[]); -__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1192,[827,1193,34,402,102,426,794,891,867,858,821,1194,1087,1064,25]); -__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:d,accent:u,children:a,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:d?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:u??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:u??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,a]});return d?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:d,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const d=e.key===n,u=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.note??String(u)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:d?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(u?2:0,e.a/t*c),backgroundColor:d?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,d=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',u=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,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1194,[34,402,102,794,821,5,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1195,[860,1101,1098,1116,34,102,846,794,874,1100,878,877,858,821,1106,1196,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1196,[34,794,874,1197,25]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1197,[379]); -__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1198,[827,1062,1193,34,1199,236,402,426,102,1201,1202,1203,794,831,891,867,1063,821,930,1211,1194,1087,1064,1204,872,1205,1209,25]); -__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1199,[34,402,102,1200,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1200,[34,797,25]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1201,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1202,[34,102,794,827,891,867,1201,821,25]); -__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1203,[827,1201,34,402,102,794,925,891,1097,858,821,1194,1087,1204,872,1205,1206,1208,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1204,[1062,1084,1092]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1205,[34,102,794,891,1038,1062,1092,1086,1204,821,872,1203,1085,1087,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1206,[1063,1207]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1207,[1063,1201]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1208,[34,102,794,827,1062,1063,1206,1124,821,1209,25]); -__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1209,[1062,34,402,102,794,827,891,1207,1063,1210,1124,821,1198,1087,1201,1206,1064,25]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1210,[]); -__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1211,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1179,1194,1087,1064,1159,987,1038,1061,13,1084,1063,2,25]); -__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1212,[828,891,1213,1193,1005,1006,34,1012,1013,236,402,295,102,794,874,1097,1203,1181,1214,1089,5,1215,1160,867,858,821,1194,1179,1087,925,1041,996,997,1094,1000,1096,1165,1163,1206,1208,1090,25]); -__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1213,[827,34,402,102,794,821,891,831,876,1005,1006,25]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1214,[34,102,794,891,1089,821,1097,25]); -__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1215,[34,402,102,794,891,858,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1216,[34,102,794,891,821,1087,1090,1214,1097,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1217,[34,102,1087,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1218,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1219,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1220,[]); -__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1221,[860,1057,34,236,402,102,797,874,821,794,1222,1129,1223,25]); -__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1222,[860,34,380,236,402,102,36,821,794,796,1129,874,25,277]); -__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1223,[1224,1225,1227,1226,1228,1047,1229]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1224,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1225,[839,5,846,849,872,1047,1226]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1226,[860,236,872,1224]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1227,[34,874,861,869,867,1225,1224]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1228,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1229,[34,1225,987,933]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1230,[34,402,102,426,874,861,821,794,1221,1129,1231,25]); -__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1231,[34,102,426,874,861,1223,1047,821,794,1129,25]); -__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1232,[34,236,402,102,879,794,821,1000,1233,1234,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1233,[872,6,933,976,1000,1223,1234]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1234,[839,1235,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1235,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1236,[34,872,1233]); -__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1237,[827,796,1238,835,984,34,931,1199,395,236,402,295,102,846,794,861,1034,867,882,1033,821,1164,1158,1185,932,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1238,[34,1033,891,835]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1239,[34,402,346,102,426,821,1200,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1240,[30,34,792,872,25]); -__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1241,[860,1126,877,30,34,1242,1001,102,14,1128,1137,794,861,867,1130,858,874,987,821,1197,864,1025,1028,1104,1132,1100,1243,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1242,[827,34,236,102,25]); -__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1243,[34,402,102,878,858,1062,1244,821,794,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1244,[1062]); -__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:"ok",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"})]})]})}},1245,[30,34,336,102,1246,1248,794,861,867,874,882,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1246,[34,1247,102,861,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1247,[2,987]); -__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])},1248,[30,34,402,874,821,794,25]); -__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1249,[30,34,794,1250,874,1232,25]); -__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])},1250,[34,402,821,794,25]); -__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1251,[837,30,34,1252,794,867,874,821,1253,1257,25]); -__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:x=!0,onPaid:f,title:g="Pay"}){const y=(0,o.useGiftCards)(b).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),_=y.find(e=>e.code===m),v=_?Math.min(_.balance,p):0,R=p-v;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:g,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),x&&y.length>0?(0,h.jsxs)(l.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:!m,onPress:()=>w(void 0)}),y.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,h.jsxs)(l.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)})]}),v?(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.ok,children:["\u2212",(0,n.gbp)(v)]})]}):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)})]})]}),T?(0,h.jsx)(t.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),f({giftCardCode:m,giftApplied:v,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1252,[34,385,102,874,867,821,794,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1253,[34,102,794,867,1254,1255,1256,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1254,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1255,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1256,[933,987,1255]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1257,[846,933,976,987,2,1254]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),r=e(_r(_d[4])),o=e(_r(_d[5])),i=e(_r(_d[6])),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),b=e(c);_r(_d[10]);var h=e(_r(_d[11])),f=e(_r(_d[12])),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),S=_r(_d[20]),T=_r(_d[21]),I=_r(_d[22]),O=_r(_d[23]),R=_r(_d[24]),A=_r(_d[25]),B=_r(_d[26]),P=_r(_d[27]),C=_r(_d[28]),_=_r(_d[29]),v=_r(_d[30]),N=_r(_d[31]);const $=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let E=!1,M=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,u.useLocalSearchParams)(),d=(0,w.useRestaurant)(e),c=s.IS_QUEUED_VENUE?(0,N.jsx)(t.default,{}):s.IS_ABBOTSFORD?(0,N.jsx)(o.default,{}):s.IS_KIRKTON?(0,N.jsx)(i.default,{}):s.IS_GREENSIDE?(0,N.jsx)(r.default,{}):l.IsolatedCustomerHome&&(s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS)?(0,N.jsx)(l.IsolatedCustomerHome,{}):(0,N.jsx)(K,{});return s.IS_ABBOTSFORD||s.IS_KIRKTON||s.IS_WILDINGS||!d?.settings.hotel?.enabled?c:(0,N.jsx)(n.HotelRequestGate,{rid:e,hotel:d.settings.hotel,children:c})}function K(){const{rid:e}=(0,u.useLocalSearchParams)(),t=(0,w.useRestaurant)(e),l=(0,w.useMenu)(e),s=(0,w.useCustomer)(),n=(0,w.useBasket)(),r=(0,w.useStore)(e=>e.startBasket),o=(0,w.useNow)(3e4),[i,H]=(0,c.useState)('All'),[K,W]=(0,c.useState)(null),[G,F]=(0,c.useState)(!1),[U,Q]=(0,c.useState)(!1),[V,Y]=(0,c.useState)('takeaway'===$?'takeaway':'main');b.default.useEffect(()=>{$&&!E&&(E=!0,'book'===$?setTimeout(()=>u.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,w.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,v.guestServer)();b.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>u.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),b.default.useEffect(()=>{C.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>u.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,w.useOrderAtTable)(e);if(b.default.useEffect(()=>{te||n.restaurantId!==e||'table'!==n.mode||w.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,n.mode,n.restaurantId,e]),!t)return(0,N.jsx)(x.Screen,{title:"Not found",children:(0,N.jsx)(x.T,{children:"Restaurant not found."})});const le=te&&n.restaurantId===t.id&&'table'===n.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ae=e=>!(e.soldOut||!e.signOff||null===e.price),ne=l.filter(e=>('All'===i||e.section===i)&&('takeaway'!==V||ae(e))),re=(0,k.hoursFor)(t,o),oe=e=>()=>u.router.push(`/customer/${t.id}${e}`),ie=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),le&&r(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>Q(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:oe('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:oe('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:oe('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:oe('/refer')},{icon:'gift',label:'Gift cards',on:oe('/gift')},{icon:'alert',label:'My allergens',sub:s.allergies.length?`${s.allergies.length} declared`:'None declared',on:()=>u.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:s.marketingOptIn[t.id]?'Opted in':'Opt in',on:oe('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:oe('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:oe('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:oe('/feedback')},{icon:'hanger',label:'Lost property',on:oe('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:oe('/merch')}];return(0,N.jsxs)(x.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,N.jsxs)(x.Row,{children:[(0,N.jsx)(m.BasketButton,{}),(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>u.router.push('/customer/profile')})]}),children:[t.fictional?(0,N.jsx)(x.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,le?(0,N.jsx)(x.Banner,{kind:"success",title:`Ordering at ${(0,d.tableNumbers)(n.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,N.jsx)(x.Card,{children:(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(f.default,{style:{flex:1},children:[(0,N.jsx)(x.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,N.jsxs)(x.Muted,{children:[re?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,N.jsx)(x.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,N.jsx)(x.Row,{wrap:!0,gap:8,children:ie.slice(2,7).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,N.jsx)(f.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ie.map(e=>(0,N.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),le?(0,N.jsx)(x.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,N.jsx)(x.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,N.jsx)(x.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,N.jsx)(x.ExampleAllergenNotice,{}),(0,N.jsxs)(x.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,N.jsx)(f.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,N.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,N.jsx)(x.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,N.jsx)(f.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,N.jsx)(A.SpecialsTab,{rid:t.id,declared:s.allergies,now:o}):null,'takeaway'===V?(0,N.jsx)(x.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==V?(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,N.jsx)(x.Chip,{label:"All",selected:'All'===i,onPress:()=>H('All')}),se.map(e=>(0,N.jsx)(x.Chip,{label:e,selected:i===e,onPress:()=>H(e)},e))]}):null,'specials'!==V?se.filter(e=>('All'===i||e===i)&&ne.some(t=>t.section===e)).map(e=>(0,N.jsxs)(f.default,{style:{gap:10},children:[(0,N.jsx)(x.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),ne.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,s.allergies),o=e.soldOut||!e.signOff||null===e.price;return(0,N.jsxs)(x.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,N.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)},children:[(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,N.jsx)(x.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,N.jsx)(x.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,j.gbp)(e.price)})]}),(0,N.jsx)(x.Muted,{numberOfLines:2,children:e.description})]}),(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,N.jsx)(x.Badge,{kind:"ok",label:e},e)),e.special?(0,N.jsx)(x.Badge,{kind:"gold",label:"Special"}):null,e.soldOut?(0,N.jsx)(x.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,N.jsx)(x.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,N.jsx)(x.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,N.jsx)(x.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,N.jsx)(p.AllergenChips,{map:e.allergens,declared:s.allergies}),K===e.id?(0,N.jsx)(p.AllergenPanel,{item:e,map:e.allergens,declared:s.allergies}):null,(0,N.jsxs)(x.Row,{gap:8,children:[(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,N.jsx)(f.default,{style:{flex:1}}),(0,N.jsx)(x.Button,{small:!0,label:o?e.soldOut?'Sold out':'Not available online':'Choose',disabled:o,onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,N.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,N.jsx)(x.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,N.jsx)(x.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,N.jsx)(T.LauncherLine,{}),te?(0,N.jsxs)(x.Sheet,{visible:U,onClose:()=>Q(!1),title:"Order at your table",children:[(0,N.jsx)(x.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,N.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:`${(0,d.tableNumbers)(e)}`,onPress:()=>{Q(!1),r(t.id,'table',e)}},e))}),(0,N.jsx)(x.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1258,[1259,1268,5,1269,1270,1271,1274,860,30,34,236,402,102,1246,1248,794,861,867,878,874,821,1275,1232,872,891,1276,994,995,1003,1278,1257,25]); -__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1259,[34,379,794,873,1260,1261,1267,874,5,6,25]); -__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1260,[34,379,102,794,996,997,1095,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1261,[6,34,933,794,1262,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1262,[6,1062,1263,1264,1265,34,102,827,794,821,11,1266,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1264,[4,11]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1265,[11]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1266,[6,933]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1267,[34,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1268,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1269,[34,102,794,1262,25]); -__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1270,[34,379,933,794,873,1260,1262,4,25]); -__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1271,[34,379,794,1260,873,1261,8,1272,25]); -__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1272,[34,102,794,1273,25]); -__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1273,[]); -__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1274,[34,794,873,1260,1261,874,9,25]); -__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1275,[34,402,102,426,794,821,1200,25]); -__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1276,[828,34,336,395,402,295,102,1246,794,994,861,995,858,821,1048,25,1277]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1277,[]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1278,[34,102,1279,794,874,1003,1254,1257,821,25]); -__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1279,[34,102,1280,821,25]); -__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1280,[1281]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1281,[34,797,1282,1311,1312,25]); -__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1282,[1283]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1283,[1284,1285,1308,1310]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1284,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1285,[1286,1287,1288,1289,1290,1291,1292,1293,1294,1297,1301,1298,1302]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1286,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1287,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1288,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1289,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1294,[1295]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1298,[1299,1300]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1299,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1300,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1303,[1298]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1304,[1298]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1306,[1298,1286]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1307,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1308,[1309]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1310,[1309]); -__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1311,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1312,[34,797,1313,25]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1313,[]); -__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1314,[30,34,794,874,891,25]); -__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1315,[837,30,34,102,1279,794,867,874,821,1278,1257,25]); -__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1316,[837,30,34,102,1252,794,874,891,867,858,821,1253,1257,25]); -__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1317,[837,30,34,794,874,891,858,821,1278,1257,25]); -__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1318,[837,30,34,794,874,891,821,1278,1257,25]); -__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1319,[30,34,794,858,1160,1320,874,821,25]); -__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}},1320,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1321,[30,1100,34,402,102,794,858,874,821,25]); -__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 l=_r(d[0]),t=_r(d[1]),n=_r(d[2]),s=e(n),a=_r(d[3]),o=_r(d[4]),r=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),p=_r(d[15]),k=_r(d[16]);function f(){const e=(0,y.useBasket)(),f=(0,y.useRestaurant)(e.restaurantId??void 0),w=(0,y.useAllMenu)(e.restaurantId??void 0),v=(0,y.useCustomer)(),C=(0,y.useOrders)(f?.id),S=(0,y.useStore)(e=>e.setLineQty),T=(0,y.useStore)(e=>e.overrideLine),B=(0,y.useStore)(e=>e.startBasket),P=(0,y.useNow)(15e3),[$,O]=(0,n.useState)(null),[I,M]=(0,n.useState)(!1),[N,F]=(0,n.useState)(''),[L]=(0,n.useState)(()=>(0,o.startForm)()),[R,z]=(0,n.useState)(''),[A,D]=(0,n.useState)(v.phone??''),[E,Y]=(0,n.useState)(v.email??''),[_,q]=(0,n.useState)(!1),H=(0,y.useOrderAtTable)(e.restaurantId??void 0);s.default.useEffect(()=>{H||'table'!==e.mode||y.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[H,e.mode]);const[G,K]=(0,n.useState)(null),[Q,J]=(0,n.useState)(!1),U=(0,n.useMemo)(()=>(0,j.linesFromBasket)(e,w,v.allergies),[e,w,v.allergies]);if(!f||!e.lines.length)return(0,k.jsxs)(u.Screen,{title:"Your basket",children:[(0,k.jsx)(u.Muted,{children:"Your basket is empty."}),(0,k.jsx)(u.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const V=H&&'table'===e.mode,W=(0,m.takeawaySlots)(f,C,P),X=U.reduce((e,l)=>e+l.unitPrice*l.qty,0),Z=U.some(e=>e.contains.length&&!e.overridden),ee=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff}),le=!V&&!$,te=!V&&f.settings.takeawayPaused,ne=(0,p.ukPhone)(A),se=!Z&&!ee.length&&I&&!le&&!te&&(V||ne.ok&&(0,p.emailOk)(E)),ae=async e=>{const l=await y.repo.orders.placeFromBasket({slotTime:V?void 0:$,tip:0,giftCardCode:e?.giftCardCode,notes:N,paidNow:!V,phone:V?void 0:ne.pretty,email:V?void 0:E.trim()||void 0});(0,o.rememberGuard)(l.id,(0,o.guardFor)({...L,hp:R})),q(!1),t.router.replace(`/customer/order/${l.id}`)},oe=e.lines.find(e=>e.key===G),re=oe?U[e.lines.indexOf(oe)]:void 0;return(0,k.jsxs)(u.Screen,{title:"Your basket",subtitle:`${f.name} \xb7 ${V?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,k.jsxs)(r.default,{style:{gap:8},children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.T,{weight:"semibold",children:"Subtotal"}),(0,k.jsx)(u.T,{weight:"bold",size:20,colour:x.colours.gold,children:(0,h.gbp)(X)})]}),Z?(0,k.jsx)(u.T,{size:14,colour:x.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):I?le&&!te?(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Choose a collection time."}):null:(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Confirm your allergies to continue."}),V?(0,k.jsx)(u.Button,{label:"Send order to the kitchen",disabled:!se,onPress:()=>ae(),testID:"send-table-order"}):(0,k.jsx)(u.Button,{label:`Continue to payment \xb7 ${(0,h.gbp)(X)}`,disabled:!se,onPress:()=>q(!0),testID:"checkout"})]}),children:[(V||e.tableNo,null),V?(0,k.jsx)(u.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,f.fictional?null:(0,k.jsx)(u.ExampleAllergenNotice,{}),U.map((l,t)=>{const n=e.lines[t],s=l.contains.length&&!l.overridden;return(0,k.jsxs)(u.Card,{highlight:l.contains.length?x.colours.red:l.may.length?x.colours.amber:void 0,children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(r.default,{style:{flex:1,paddingRight:8},children:[(0,k.jsx)(u.T,{weight:"semibold",children:l.name}),l.choices.length?(0,k.jsx)(u.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,k.jsxs)(u.Muted,{children:["Note: ",l.notes]}):null]}),(0,k.jsx)(u.T,{weight:"semibold",children:(0,h.gbp)(l.unitPrice*l.qty)})]}),s?(0,k.jsxs)(u.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:[(0,k.jsx)(u.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${v.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} (${(0,c.severityLabel)(e.severity)})`).join(', ')}.`}),(0,k.jsxs)(u.Row,{gap:8,style:{marginTop:6},children:[(0,k.jsx)(u.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{J(!1),K(n.key)}})]})]}):l.contains.length?(0,k.jsx)(u.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,k.jsx)(u.Banner,{kind:"warn",title:`May contain ${l.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ee.includes(n)?(0,k.jsx)(u.Badge,{kind:"amber",label:"No longer available online \u2014 please remove"}):null,(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Stepper,{value:n.qty,onChange:e=>S(n.key,e),min:1,label:l.name})]})]},n.key)}),(0,k.jsx)(u.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${f.id}`)}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsxs)(u.H2,{children:["Collection time \u2014 ",(0,b.niceDate)(P)]}),te?(0,k.jsx)(u.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===W.length?(0,k.jsx)(u.Banner,{kind:"warn",children:"No collection slots left today."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u.Muted,{children:["15-minute slots, max ",f.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:W.slice(0,16).map(e=>(0,k.jsx)(u.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>O(e.time.toISOString())},e.label))})]})]}),(0,k.jsxs)(u.Card,{highlight:I?void 0:x.colours.amber,children:[(0,k.jsx)(u.H2,{children:"Confirm allergies for this order"}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:v.allergies.length?v.allergies.map(e=>(0,k.jsx)(u.Badge,{kind:"red",label:`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`},e.allergen)):(0,k.jsx)(u.Muted,{children:"No allergies declared on your profile."})}),(0,k.jsx)(u.Toggle,{label:v.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:I,onChange:M}),(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsx)(u.H2,{children:"Your details"}),(0,k.jsx)(u.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:A,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!ne.ok&&A?(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:ne.error}):null,(0,k.jsx)(u.Field,{label:"Email (optional)",value:E,onChangeText:Y,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,p.emailOk)(E)?null:(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,k.jsx)(u.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,k.jsx)(u.Field,{label:"Order notes (optional)",value:N,onChangeText:F,placeholder:"e.g. cutlery please"}),V?(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>B(f.id,'takeaway')}):null,(0,k.jsx)(i.MockPay,{visible:_,onClose:()=>q(!1),amount:X,restaurantId:f.id,onPaid:e=>ae({giftCardCode:e.giftCardCode}),title:"Pay for your takeaway"}),(0,k.jsxs)(u.Sheet,{visible:!!oe,onClose:()=>K(null),title:"Allergy override",children:[re?(0,k.jsx)(u.Banner,{kind:"danger",title:`${re.name} contains ${re.contains.map(c.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,k.jsx)(u.Toggle,{label:"I understand and want to add it anyway",value:Q,onChange:J}),(0,k.jsx)(u.Button,{kind:"danger",disabled:!Q,label:"Confirm override",onPress:()=>{oe&&re&&T(oe.key,re.contains),K(null)}})]}),(0,k.jsx)(a.Honeypot,{value:R,onChange:z})]})}},1322,[860,30,34,1242,1001,102,1252,794,861,867,1130,858,874,831,821,864,25]); -__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1323,[30,34,102,1248,794,861,878,874,821,1275,5,25]); -__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 f}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},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]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,s.useLocalSearchParams)(),r=(0,b.useOrder)(e),f=(0,b.useRestaurant)(r?.restaurantId),[C,S]=(0,l.useState)(0),[k,T]=(0,l.useState)(''),[v,P]=(0,l.useState)(!1),[M,$]=(0,l.useState)(!1),[R,A]=(0,l.useState)(1),[I,N]=(0,l.useState)(0),[O,B]=(0,l.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(c.Screen,{title:"Order",children:(0,j.jsx)(c.T,{children:"Order not found."})});const H='takeaway'===r.type?x:w,_=Math.max(0,H.findIndex(([e])=>e===r.status)),D=Math.round(r.subtotal*I/100),F='table'===r.type?r.subtotal+(r.split?r.tip:D):r.total,q=F-r.paid,L=r.split?.ways??O,W=r.split?.paidShares??0,Y=Math.ceil(F/L),E='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(c.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,p.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(c.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Status"}),H.map(([e,t],s)=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=_?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(c.T,{weight:s===_?'semibold':'regular',colour:s<=_?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(c.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,p.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(c.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||E?null:(0,j.jsxs)(c.Row,{gap:8,children:[(0,j.jsx)(c.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>b.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(c.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>b.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(c.T,{children:(0,h.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(c.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(c.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(u.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Subtotal"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Of which gift card"}),(0,j.jsxs)(c.T,{colour:y.colours.ok,children:["\u2212",(0,h.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Tip"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.tip)})]}):null,(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.gold,children:(0,h.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(c.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(F)," \xb7 split ",L," way",L>1?'s':''," \xb7 ",(0,h.gbp)(Y)," each"]}),(0,j.jsxs)(c.T,{children:["Shares paid: ",W," of ",L," \xb7 remaining ",(0,h.gbp)(q)]}),L>1?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{children:"Shares to pay now"}),(0,j.jsx)(c.Stepper,{value:R,onChange:A,min:1,max:L-W,label:"shares"})]}):null,(0,j.jsx)(c.Button,{label:`Pay ${L>1?`${R} share${R>1?'s':''}`:'bill'} \xb7 ${(0,h.gbp)(Math.min(q,Y*R))}`,onPress:()=>$(!0),testID:"pay-bill"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(c.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(c.Chip,{label:e?`${e}%`:'No tip',selected:I===e,onPress:()=>N(e)},e))}),(0,j.jsx)(c.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(c.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(r.subtotal+D),O>1?` \xb7 ${(0,h.gbp)(Math.ceil((r.subtotal+D)/O))} each`:'']}),(0,j.jsx)(c.Button,{label:"Get the bill",onPress:()=>b.repo.orders.setSplit(r.id,O,D),testID:"get-bill"})]})]}):null,!E||r.rated||v?null:(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(c.H2,{children:"How was everything?"}),(0,j.jsxs)(c.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(i.Stars,{value:C,onChange:S}),C?(0,j.jsx)(c.Field,{label:"Anything to add? (optional)",value:k,onChangeText:T}):null,(0,j.jsx)(c.Button,{label:"Send feedback",disabled:!C,onPress:()=>{b.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:C,comment:k,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),P(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(c.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,E?(0,j.jsx)(c.Button,{kind:"secondary",label:"View stamp card",onPress:()=>s.router.push(`/customer/${f.id}/loyalty`)}):null,(0,j.jsx)(o.MockPay,{visible:M,onClose:()=>$(!1),amount:Math.min(q,Y*R),restaurantId:f.id,title:`Pay \u2014 ${(0,t.tableNumbers)(r.tableNo)}`,onPaid:e=>{b.repo.orders.payTable(r.id,{shares:R,giftCardCode:e.giftCardCode}),$(!1),A(1)}})]})}},1324,[860,30,34,102,1252,1250,794,861,867,858,874,821,25]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1325,[860,1257,30,34,102,794,861,867,858,874,879,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1326,[30,34,872,25]); -__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1327,[837,30,34,794,874,5,1257,25]); -__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1328,[30,34,794,1329,1174,1257,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1329,[827,860,34,102,794,861,867,1174,1330,874,821,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1330,[933,987,1174]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1331,[30,34,872,1332,1396,25]); -__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1332,[1161,796,5,6,1333,828,853,1121,860,1160,1334,1335,1336,1118,1142,1337,1338,1343,1344,1345,872,1346,1173,979,1129,1347,34,1098,1195,1047,1114,1156,1348,395,380,402,295,102,426,36,794,1232,1236,873,861,858,874,821,1117,891,1125,1087,1028,1104,1134,1349,1133,1350,1357,1359,1362,1365,1361,1366,1368,1369,1139,1122,1123,878,1373,1221,1374,1231,1223,1025,1379,1387,1388,1101,1141,1390,1391,1392,1097,1188,1393,1187,1180,869,1394,1395,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1334,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1335,[1026,1087]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1336,[34,102,1104,794,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1337,[860,34,102,794,874,1174,821,25]); -__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1338,[34,395,402,426,102,1279,794,1188,796,1028,1339,1340,1342,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1339,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1340,[34,395,402,295,412,102,426,796,794,821,1341,1342,25]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1341,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1342,[1024,872,1341,933,987]); -__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1343,[846]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1344,[828,34,379,395,402,102,794,1188,821,25]); -__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1345,[34,236,402,102,794,821,891,1003,858,1097,25]); -__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1346,[828,827,34,236,402,295,102,794,1173,874,979,831,981,982,872,980,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1347,[828,34,102,821,794,25]); -__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1348,[34,102,797,821,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1349,[]); -__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1350,[828,796,827,1121,860,1129,34,236,402,295,426,102,859,821,794,1351,1352,1028,891,1133,1354,987,872,25]); -__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1351,[828,860,34,1352,102,859,821,794,1134,1353,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1352,[859]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1353,[1352,859]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1354,[34,385,295,102,859,1355,1356,821,796,827,794,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1355,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1356,[1355,1024,872,933,987]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1357,[34,236,402,102,821,794,1188,1358,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1358,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1359,[828,860,1122,34,281,236,295,102,1135,874,1028,1104,14,858,1123,1360,821,794,1361,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1360,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1361,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1362,[5,828,34,283,336,236,402,102,426,821,873,794,1029,1000,1343,1363,2,1364,1365,874,858,25]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1363,[236]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1365,[34,846,933,987,1364]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1366,[860,14,1028,1367]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1367,[861]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1368,[34,102,797,821,25]); -__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1369,[1370,860,1122,1028,34,102,794,1125,874,1372,1366,1123,858,1120,1139,1140,1141,821,1335,25]); -__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1370,[34,379,402,102,874,1003,891,1026,1371,872,821,794,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1371,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1372,[1028,1104]); -__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1373,[1370,828,1122,827,860,1160,1118,1139,858,34,1106,236,402,295,102,794,1125,1361,874,1028,861,1116,1104,1320,821,1335,25]); -__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1374,[827,34,236,402,102,794,874,1028,1375,821,1376,1378,25]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1375,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1376,[846,874,1028,1375,1377,1378]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1377,[860]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1378,[236,1377]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1379,[860,34,1199,1188,402,102,1025,1028,878,858,821,794,1380,1383,25]); -__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1380,[1381,870,860,34,281,395,402,295,102,874,1025,1028,1382,858,821,1055,794,1383,1384,987,1335,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1381,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1382,[878,858,877]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1383,[5,1028,933,987]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1384,[846,933,987,1385,2,1386]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1385,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1386,[15]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1388,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1389,[1104]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1390,[860,1367]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1391,[34,402,102,794,1390,821,1348,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1392,[34,102,925,794,1188,858,821,25]); -__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1393,[34,1188,402,102,426,794,25]); -__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1394,[828,1062,827,2,1188,34,402,102,426,794,821,891,997,858,1000,1384,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1395,[34,1035,891,1008,831,1036,1000,1384,1093]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1396,[5,828,873,34,236,402,102,426,987,821,794,1343,1397,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1397,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1398,[30,34,872,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1399,[30,34,872,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1400,[30,34,1401,872,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1401,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1402,[30,34,872,1403,25]); -__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1403,[1404,1408,828,996,1098,1409,1217,1054,1055,1410,1412,1415,1173,979,1015,1417,1012,2,1060,1061,1418,998,1038,999,34,1175,1232,1236,1213,373,402,295,102,426,36,794,873,1156,891,821,1179,1419,1093,1111,1113,1107,1056,1039,1087,1427,1428,1429,1438,1439,1003,236,1239,1192,1198,1435,1212,1211,1448,1195,15,1218,1219,925,793,987,25]); -__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1404,[827,34,1047,395,102,1133,1134,1350,1379,794,1025,1028,858,821,1087,1029,1405,1406,1049,25]); -__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1405,[827,34,402,102,794,821,1028,5,1029,872,987,25]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1406,[34,102,794,1028,1407,859,821,1074,933,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1407,[]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1408,[34,102,794,1087,987,25]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1409,[860,34,102,794,861,867,1174,874,869,821,25]); -__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1410,[987,34,281,236,102,1279,794,1254,1257,821,1411,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1411,[34,236,102,794,1254,25]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1412,[34,796,102,794,861,1254,1413,1414,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1413,[861]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1414,[987,1413,1257]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1415,[5,1416,34,102,794,867,1254,1255,1256,987,1257,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1416,[34,794,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1417,[236,1013]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1418,[34,102,794,821,998,1051,987,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1419,[5,1416,1122,11,1420,827,837,1139,1140,1118,1142,1421,1137,1141,1390,1391,1087,1335,1026,1116,14,1143,1423,1232,1424,1379,1106,1100,1117,34,102,794,1348,874,861,867,858,1320,821,1194,1125,1028,1425,1086,1180,1426,1223,987,1196,1387,878,25]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1420,[6,34,102,794,987,1266,25]); -__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1421,[34,402,102,1422,987,933,821,794,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1422,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1423,[827,5,34,379,236,102,794,876,14,867,1031,933,821,1197,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1424,[34,402,1188,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1425,[34,102,874,1028,794,821,25]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1426,[34,102,879,874,864,821,794,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1427,[34,1380,1087,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1428,[860,34,102,1180,794,874,861,869,858,821,1194,1087,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1429,[835,984,1430,34,236,102,794,831,891,983,1030,985,987,1437,821,2,1181,25]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1430,[827,979,1160,987,797,1221,1223,34,281,379,236,402,102,426,879,794,874,1232,891,867,858,821,1194,1087,869,1431,1179,1435,1436,1159,1166,1165,1038,13,1163,1169,1434,25]); -__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1431,[927,796,831,828,837,878,1075,1432,34,993,336,379,236,402,102,794,874,891,858,821,1194,1087,1434,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1432,[499,1433]); -__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 t={}},1433,[]); -__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1434,[831,891,5]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1435,[827,34,1247,1055,870,379,402,102,794,891,867,858,821,1194,1087,1434,25]); -__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1436,[1015,34,402,102,794,891,821,1087,987,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1437,[]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1438,[860,34,102,794,891,1028,858,1090,1088,987,1089,5,1000,821,25]); -__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1439,[5,1440,1441,1442,1443,1444,34,236,41,102,872,1445,1003,821,1447,794,987,2,1096,1002,891,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1440,[34,102,873,794,5,6,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1441,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1442,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1443,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1444,[34,102,873,794,25]); -__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1445,[34,295,102,794,873,821,1446,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1446,[]); -__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1447,[929,828,34,1096,336,236,402,295,41,102,872,926,891,831,987,1003,15,793,821,925,794,25]); -__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1448,[1195,1098,1139,1116,34,402,102,794,891,858,821,1117,1187,1087,1192,1431,1180,876,1196,869,1194,925,1425,1028,860,1125,1211,1215,1097,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1449,[30,34,872,25]); -__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1450,[1451,987,795,1397,1453,1025,30,1480,496,34,385,336,236,41,102,5,873,872,1482,36,874,1028,891,821,1439,1003,1023,1485,1486,1057,1487,1129,2,1038,998,1488,1365,25,1490,1491,1492,1493]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1451,[2,827,34,236,383,102,794,1452,987,821,1198,1003,891,993,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1452,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1453,[1454,1477,1479]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1454,[215,1455,1458,1472,1473,1474,1475,1476]); -__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1455,[215,1456]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1456,[1457]); -__d(function(g,r,i,a,m,e,d){},1457,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1458,[1459,215,1455,1472,1473]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1459,[1460,1461,1471]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1460,[1461,1465,1470]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1461,[215,372,1462,1466,1467,1468,1469,1465,1470]); -__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1462,[215,1463,339,280,1464,1465]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1463,[504]); -__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1464,[215,339]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1465,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1466,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1467,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1468,[1466]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1469,[]); -__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1470,[372,1464]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1471,[34,1461]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1472,[1459,215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1473,[1459,1472]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1474,[1455]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1475,[215,1455,1458,1456]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1476,[]); -__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1477,[215,54,1478]); -__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1478,[215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1479,[34,1454]); -__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]}})})},1480,[1481]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1481,[]); -__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1482,[34,41,102,426,794,873,1003,987,2,5,821,1483,1484,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1483,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1484,[34,102,794,821,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1485,[989,883,882,987]); -__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1486,[828,796,827,34,1011,1405,1029,402,102,872,987,1013,1028,5,821,794,1343,976,2,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.VoiceHost=function(){return null}},1487,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1488,[874,831,891,1038,15,1003,872,2,1489]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1489,[874,1038]); -__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1490,[]); -__d(function(o,s,e,p,t,c,d){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1491,[]); -__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1492,[]); -__d(function(o,s,e,p,t,d,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1493,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1494,[30,34,872,25]); -__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1495,[1496]); -__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1496,[25,1497,591]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1497,[34,172]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1498,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1499,[25,499,34,270,651]); +__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return Q.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return Q.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return Q.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return Q.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return Q.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ot}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ie.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ie.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ie.useOwner.getState().chatSeen(t,e)),$t(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ie.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...ht(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(fe.PITCH)return ge.unlockCashUp(e,t,a);const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?de.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):de.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(fe.PITCH)return ge.cashAudit(e);const t=Ae.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(_a.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=pa,i.readAccessLog=async function(){const e=Ae.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ae.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return ga}}),i.uploadOrderLogo=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(ga).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ma.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(ga).createSignedUrl(e,3600);if(t?.signedUrl)return ma.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(ga).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return _a}}),i.claimInvite=Ua,i.makeChromeHandover=async function(){const e=Ae.getState();if(fe.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ee});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(fe.PITCH||!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ee});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),Me&&qa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Ne();const t=await q.kv.get(Ia,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Ne(),await q.kv.get(Oa,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_WILDINGS||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Ne(),await q.kv.remove(Ia),await q.kv.remove(Oa),Ce({mode:'signin',perms:[]});try{await xa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ae.getState().venueId;if(fe.PITCH||!s||'staff'!==Ae.getState().kind)return{ok:!0};if(!(0,re.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Pa('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ua(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(fe.PITCH)return ge.reissueInvite(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Pa('staff_app_link_history',{p_venue:Ae.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Pa('revoke_staff_app_link',{p_venue:Ae.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(fe.PITCH)return ge.linkPhones();const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return{};try{const t=await Pa('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(fe.PITCH)return ge.resetPhone(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Number(await Pa('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(fe.PITCH)return ge.inviteStatus();const e=Ae.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:t,error:a}=await Re().rpc(d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_pairing_code':d.IS_GREENSIDE?'claim_greenside_pairing_code':d.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':d.IS_KIRKTON?'claim_kirkton_pairing_code':d.IS_WILDINGS?'claim_wildings_pairing_code':d.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':d.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await q.kv.set(ka,n),qa(),{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}`}}},i.carPairStart=async function(){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await q.kv.set(Ea,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ta(e)}}},i.carPairPoll=async function(e){try{Ne();const t=e??await q.kv.get(Ea,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,J.carPairApproved)(n)){const e=(0,J.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await q.kv.get(ka,null);await q.kv.set(ka,e),await q.kv.remove(Ia),A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||qa()}return'revoked'!==i&&'unknown'!==i||await Na(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Ne(),await Re().rpc('car_sign_out')}catch{}await Na(),await xa();try{await Re().auth.signOut({scope:'local'})}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Pa('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ta(e)}}},i.carList=async function(){const e=Ae.getState().venueId;if(!e)return[];return(await Pa('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Pa('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ta(e)}}},i.unpairDisplay=async function(){await q.kv.remove(ka),await xa();try{await Re().auth.signOut()}catch{}Ce({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await q.kv.remove(Ia),await q.kv.remove(Oa),await xa();try{await Re().auth.signOut()}catch{}Ce({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.'})},i.wipeThisDevice=async function(e={}){try{await xa()}catch{}try{(0,N.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${d.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!d.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Ka,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Pa}}),i.mendSession=La,i.startAppSync=async function(e=d.VENUE_RID){if(d.IS_ISOLATED_VENUE&&e!==d.VENUE_RID)return;if(Me)return;Me=!0,Ba=e,'customer'===Ee&&'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Ne(),'customer'!==Ee){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ee&&(0,y.isAnchorage)(e)?[V.useStore,ie.useOwner,se.useKitchen,ne.useSafety,X.useCardStore,_.useGpCalc,ee.useOrderSheets,h.useSpecials,C.useHr]:[V.useStore,ie.useOwner,se.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ee&&(0,y.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ce({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Os(e)}catch{if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e))return void Ce({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,N.isSupabaseConfigured)())return void Ce({mode:'off'});F.mutationQueue.subscribe(()=>{const e=F.mutationQueue.waiting,t=e[0];Ce({pending:F.mutationQueue.pending.length,failed:F.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,B.describeWrite)(t)}: ${(0,B.plainReason)({...t.lastErr},'retry')}`:void 0})}),F.mutationQueue.onFailed(e=>Ce({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:F.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,B.describeWrite)(e),why:'conflict'===e.reason?(0,B.plainReason)({code:'conflict'},'refused'):(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Pe.push((0,K.onConnectivity)(e=>Ce({mode:e?Ae.getState().venueId?'live':Ae.getState().mode:Ae.getState().venueId?'offline':Ae.getState().mode}))),await ja()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Qa}}),i.serverOrder=Za,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return Ya}}),i.nudgeGuestSync=function(){Xa?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return es}}),i.stockSaveBlocker=ts,i.stockEventStatus=function(e){if(Ze(e))return{state:'saved'};const t=F.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,B.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=as,i.saveStockEventsNow=ss,i.bookingSaveBlocker=is,i.resendUnsavedBookings=ds,i.saveBookingsNow=us,i.waitForBookingSave=function(e,t=12e3){if(!Ue())return Promise.resolve({state:'local'});const a=is();if(a)return Promise.resolve({state:'refused',why:a});const s=rs()[0]?.venueId??'',n=()=>ns.some(t=>F.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=$.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,K.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(F.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(F.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||rs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||rs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=gs,i.tempLogState=function(){const e=ms()[0]?.venueId??'',t=ms().find(e=>'temp_readings'===e.spec.table),a=F.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!F.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(W.useTempSaves.getState().notSaved),i=ne.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=_s,i.waitForTempSave=function(e,t,a=1e4){if(!Ue()||!ms().length)return Promise.resolve({state:'local'});const s=gs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ms()[0]?.venueId??'',i=ms().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>W.useTempSaves.getState().notSaved[(0,W.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>F.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=ws,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ms}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Ps.get(a);if('customer'!==Ee||!(0,N.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Ps.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Pa('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:Le(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:Le(a.from_time),to:Le(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Ps.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ms.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Ps.get(a);e&&!e.ok&&Ps.delete(a)}));const n=Ps.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ae.getState().venueId;if(!n||'staff'!==Ae.getState().kind)throw new Error('Connect to your venue first.');const i=await Pa('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});V.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return null;return(await Pa('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');await Pa('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),O=t(r[18]),R=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(pe),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]),Oe=t(r[71]);const Re=()=>(0,T.getSupabase)();F.mutationQueue.setExecutor(L.executeMutation),(0,M.setClockServer)(()=>'staff'===Ae.getState().kind);const Ae=(0,E.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ce=e=>Ae.setState(e),De=e=>{const t=Ae.getState().perms;return t.includes('*')||t.includes(e)},Ue=()=>{const e=Ae.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ae.subscribe(()=>(0,be.setLiveData)(Ue()));let Ee=G.IS_CAR?'car':G.APP_VARIANT,Te=!1;const Ne=()=>{Te||((0,q.setSyncNamespace)(Ee),Te=!0)};let Ke=[],Pe=[],Me=!1;const xe=()=>(new Date).toISOString().slice(0,10),qe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),Le=e=>e?e.slice(0,5):'',Be=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))):[],je=e=>JSON.parse(JSON.stringify(e));function Fe(e,t){const a=qe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>V.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=je(e);if(t)return{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:Be(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,re.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:Be(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function $e(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>V.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.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,re.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:je(e.lines??[]),allergies:Be(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:je(e.allergyChain??{}),readiness:je(e.readiness??{}),allergy_ticks:je(e.allergyTicks??{}),handover_check:e.handoverCheck?je(e.handoverCheck):null,accepted:e.accepted?je(e.accepted):null,doc:je(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)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function We(e){const t=qe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...z.useBlocks.getState().blocks,...z.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Ae.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:je(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,z.blockClock)(t.from_time)??a?.from,n=(0,z.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>z.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>z.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Qe=null,He='Main plan';function Ve(e){const t=e=>je({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(Z.useFloor.getState().plans[e]??(0,Z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>De('floor.manage')||De('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Qe??(0,ke.uuidFrom)(`plan:${a}`),venue_id:a,name:He||'Main plan',is_active:!0,...t(e),updated_by:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>(Qe=String(e.id),He=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,Ie.withSeedBest)(e,t[0]):void 0;a&&Z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>Z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ge(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Y.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>De('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,re.isUuid)(e.supplierId)?e.supplierId:(0,ke.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),dt.get(t)??t)}:{}};var t},apply:(t,a)=>Y.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Je=new Set,ze=new Set;F.mutationQueue.onDone(e=>{'stock_events'===e.table&&ze.add(e.rowKey)});const Ze=e=>ze.has(e)||Je.has(e),Ye=()=>De('*')||De('staff.manage')||De('recipes.edit')||De('recipes.signoff'),Xe=()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write'));function et(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Y.useShellStore.getState().events.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,re.isUuid)(t.id)&&!!(Y.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('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,re.isUuid)(e.undoes)&&(Ze(e.undoes)||F.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Je.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)=>Y.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function tt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Y.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={...Y.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Y.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Je]}}}))},afterRead:()=>{Y.useShellStore.getState().server[e]||Y.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Je]}}}))},subscribe:()=>()=>{}}}const at=new Set;function st(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=V.useStore.getState().menu;return X.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:t=>(0,re.isUuid)(t.card.id)&&!((0,y.isAnchorage)(e)&&(0,y.isDemoCard)(t.card))&&!(0,y.isPlaceholderCard)(t.card),writable:()=>De('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,y.isAnchorage)(e)&&(s={...s,signOff:(0,y.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,y.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,y.isAnchorage)(e)&&(0,y.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,ke.photoPath)(a,s),t=nt(s.photo);t&&((0,X.cachePhotoAs)(e,t),it(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,ke.cardToRow)(s,a);return{...i,...r,doc:je({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,y.isPlaceholderCard)(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,signOff:(0,y.isAnchorage)(e)&&(0,y.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!De('recipes.edit')&&t.length){const e=new Set(t);X.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);X.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&V.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&V.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=X.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=V.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const nt=e=>(0,X.readLocalPhoto)(e);async function it(e,t){if(!at.has(e)){at.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(ke.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){at.delete(e),Ce({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const rt=new Map,ot=(0,E.create)(()=>({n:0}));(0,X.setStoragePhotoResolver)(e=>{const t=rt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,N.isSupabaseConfigured)()&&'off'!==Ae.getState().mode?(t||(rt.set(e,{url:'',at:Date.now()}),Re().storage.from(ke.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(rt.set(e,{url:t.signedUrl,at:Date.now()}),ot.setState(e=>({n:e.n+1})),X.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const dt=new Map;const ut=(e,t)=>{const a=(0,re.isUuid)(t)?t:(0,ke.uuidFrom)(`sup:${e}:${t}`);return dt.set(a,t),a};function ct(e){return{name:'order_sheets',table:'suppliers',list:()=>ee.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,y.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>De('suppliers.manage'),toRow:(e,t)=>({id:ut(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:je(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(dt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ee.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ee.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,re.isUuid)(e)?e:(0,ke.uuidFrom)(`sup:${Ae.getState().venueId}:${e}`)})}}let lt=!1,ft=!1;const pt=new Map,gt=new Map,mt=new Map,_t=new Map,St=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ht=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'},yt=(e,t)=>({...e,managerAccess:t}),wt=()=>({nickname:lt,display:ft}),vt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=yt({role:e.role,level:e.level??ht(St(e)).level},!0===e.managerAccess);return(0,j.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},wt())};const bt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},kt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},It=e=>{const t=ie.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ot=2e3;function Rt(e,t){return t||!e.length||e.length>=Ot?null:e=>(0,re.isUuid)(e.id)}function At(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,De('rota.manage')):null,keepOnEmpty:()=>e&&!De('rota.manage'),list:()=>ie.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&pt.has(e.staffId)&&(De('rota.manage')||It(e.staffId)),writable:()=>De('rota.manage')||De('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(bt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:kt(e.start),end_time:kt(e.end),published:!!e.published,doc:je(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Ct(){const e=qe(62),t=e=>De('rota.manage')||e.staffId===Ae.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ie.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ae.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=qe(2)&&e.staffId===Ae.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:je(e.breaks??[]),break_mins:e.breakMins??0,doc:je((0,w.privateAttendance)(d.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,w.privateAttendance)(d.VENUE_RID,{...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Dt(){const e=qe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.staffId===Ae.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ae.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:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,re.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:je({...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Ut(e){ie.leaveRemote.decide=t=>!(!De('rota.manage')||!(0,re.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(F.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Pe.push(()=>{ie.leaveRemote.decide=null})}function Et(e){ie.timesheetRemote.send=(t,a)=>{if(!De('rota.manage')||!(0,re.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return F.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:je(s)}}),!0}const s=a;if('attendance_void'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return F.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:je(s.breaks??[]),p_reason:n,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0},Pe.push(()=>{ie.timesheetRemote.send=null})}function Tt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>V.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ae.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,re.isUuid)(a)?a:(0,ke.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,re.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:je(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>V.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=>V.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Nt=e=>V.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Kt(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}));V.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Pt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=V.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[je({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:Z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Nt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>De('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...xt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...xt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...xt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Mt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Mt=t.feature_flags??{},xt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),je({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}:{}})},apply:t=>{const a=t[0];a&&(V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&Z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Kt(e,a.events))},subscribe:e=>{const t=V.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=Z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Mt=null,xt=null;const qt=()=>new Date(Date.now()-2592e6).toISOString(),Lt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Bt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>gt.get(e));return 2===t.length&&t[0]&&t[1]?(0,he.dmId)(t[0],t[1]):null},jt=()=>Ae.getState().perms.includes('*');function Ft(){const e=()=>Ae.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ie.useOwner.getState().chat.filter(e=>(0,re.isUuid)(e.id)).map(e=>je({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=>!!Lt(t.ch)&&(t.from===e()||jt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('created_at',qt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=qt(),toRow:(e,t)=>{const a=Lt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:pt.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=Bt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?gt.get(String(e.from_staff)):'system';return s?je({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ie.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?gt.get(String(t.from_staff)):'system',i=Bt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ie.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,he.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,ye.soundAllowed)())try{(0,ye.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,k.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function $t(e,t,a){const s=Ae.getState();if(!Se.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=pt.get(e),i='*'===t?'*':Lt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Wt(e){const t=Ae.getState().staffRef,a=t?pt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Bt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ie.useOwner.getState().chatMarkRead(t,i)}catch{}}function Qt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=D.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:je(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>D.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,U.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Ht(e){const t=qe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>D.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.reminderId)&&e.staffRef===Ae.getState().staffRef,writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>D.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Vt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Gt=e=>null==e||''===e?null:Number(e),Jt=e=>e.filter(e=>!e.startsWith('data:')),zt=()=>De('takings.view');function Zt(e){const t=!zt();return{name:'cash_ups',table:'cash_ups',list:()=>de.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',qe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:je(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({cashUps:Vt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Yt(e){return{name:'sales_reports',table:'sales_reports',list:()=>de.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:je(e.vals),categories:e.categories,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({sales:Vt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Xt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=de.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,de.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:je({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,de.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>de.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ea(e){return{name:'day_tips',table:'day_tips',list:()=>de.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',qe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>de.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ta(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>de.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Gt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>de.useCashUp.setState(s=>({pot:Vt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function aa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=de.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>De('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>de.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function sa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>oe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:je(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>oe.useNotifs.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>oe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function na(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ue.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:je(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ue.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ce.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Vt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ia(e){const t=()=>De('venue.settings')||De('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ue.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,re.isUuid)(a.id)&&(0,re.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ue.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ae.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ae.getState().staffRef)||null,doc:je(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ra(e){const t=qe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ue.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:je(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({history:Vt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function oa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=le.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:je(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>De('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&le.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,w.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>le.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function da(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=me.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,me.libraryRowId)(e),kind:'library',doc:je({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,me.personRowId)(e,i),kind:'person',staffRef:i,doc:je({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ie.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,_e.canEditTasks)(t,a)},writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>me.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,me.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ua(e){const t=qe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>me.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ae.getState();return e.byRef===t.staffRef||De('staff.manage')},writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>me.useDailyTasks.setState(s=>({ticks:Vt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ca(e,t=!1){const a=qe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>we.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind||De('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,ke.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>we.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>we.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{ve.autoSync.soldOutRead.add(e)}}}function la(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>ve.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:(0,ke.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>ve.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>ve.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{ve.autoSync.linksRead.add(e)}}}async function fa(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&q.kv.get(a,!1):(q.kv.set(a,!0),!0)}catch{return q.kv.get(a,!1)}}async function pa(){const e=Ae.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();_a.setState({live:!!t?.push_live,known:!0})}catch{}}const ga='order-list-logos';const ma=new Map;const _a=(0,E.create)(()=>({live:!1,known:!1}));async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('reminders:ok',!1):(q.kv.set('reminders:ok',!0),!0)}catch{return q.kv.get('reminders:ok',!1)}}async function ha(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('chat:ok',!1):(q.kv.set('chat:ok',!0),!0)}catch{return q.kv.get('chat:ok',!1)}}const ya=(e,t)=>je({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),wa='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function va(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>C.useHr.getState().questions.filter(t=>t.venue===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ya(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);C.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>C.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function ba(e,t){const a=(t,a,s)=>{F.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(C.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(wa).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||C.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ya(e,t)))}catch{}}}),Pe.push(()=>{Object.assign(C.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ka='pair:v1',Ia='staff:v1',Oa='staff:rejoin:v1';async function Ra(e){const t=d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_invite':d.IS_GREENSIDE?'claim_greenside_invite':d.IS_ABBOTSFORD?'claim_abbotsford_invite':d.IS_KIRKTON?'claim_kirkton_invite':d.IS_WILDINGS?'claim_wildings_invite':d.IS_KIRKMICHAEL?'claim_kirkmichael_invite':d.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ee,p_device:(0,A.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,A.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Aa(){if('display'===Ee||'customer'===Ee||fe.PITCH)return'none';const e=await q.kv.get(Oa,null);if(!e)return'none';try{await Da();const{data:t,error:a}=await Ra(e);if(a)return(0,O.inviteRefusal)(a.message)?(await q.kv.remove(Oa),await q.kv.remove(Ia),'refused'):'offline';const s=t?.[0];return s?(await q.kv.set(Ia,{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,displayName:s.display_name}),'ok'):(await q.kv.remove(Oa),'refused')}catch{return'offline'}}const Ca=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Da(){Ne();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ce({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 Ua(e){if(fe.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Ra(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,d.venueKey)(`cc-pending-invite:${Ee}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),await q.kv.set(Oa,e),Me&&qa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ce({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ea='car:request:v1',Ta=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Na(){await q.kv.remove(ka),await q.kv.remove(Ia),await q.kv.remove(Ea),A.useSession.getState().meId&&A.useSession.getState().signOut()}async function Ka(){if(!(0,N.isSupabaseConfigured)())return!1;try{return await Da(),!0}catch{return!1}}const Pa=async(e,t={})=>{if(fe.PITCH)return(0,pe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Ma=null;async function xa(){for(const e of Pe)try{e()}catch{}Pe=[],Ke.forEach(e=>e.stop()),Ke=[],Ma&&(clearInterval(Ma),Ma=null)}async function qa(){await xa(),await ja()}async function La(){if(!(0,N.isSupabaseConfigured)()||'customer'===Ee||fe.PITCH)return!1;try{Ne();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ee)return!1;if(!await q.kv.get(Oa,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Aa()&&(qa(),!0)}catch{return!1}}(0,c.setSessionMender)(La);let Ba=d.VENUE_RID;async function ja(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Ba;try{if(Ce({mode:'connecting'}),await F.mutationQueue.load(),'customer'===Ee)return void await Va(e);let t=await q.kv.get(ka,null),a=await q.kv.get(Ia,null);if(G.IS_CAR&&!t&&a){const e=(0,J.migrateCarStaffIdentity)(a);e&&(t=e,await q.kv.set(ka,t)),await q.kv.remove(Ia),a=null,A.useSession.getState().meId&&A.useSession.getState().signOut()}if(d.IS_ISOLATED_VENUE&&(t&&!(0,d.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,d.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ce({mode:'display'===Ee?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ee&&!G.IS_CAR&&a&&!s.session){const t=await Aa();if('offline'===t)return Ce({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Ba===e&&qa()},6e4);'refused'===t&&a.staffRef&&A.useSession.getState().meId===a.staffRef&&A.useSession.getState().signOut(),a=await q.kv.get(Ia,null),({data:s}=await Re().auth.getSession())}const n='display'===Ee||G.IS_CAR?t:a;if(!s.session||!n)return void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Pa('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ee||G.IS_CAR?await q.kv.remove(ka):(await q.kv.remove(Ia),await q.kv.remove(Oa)),'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId===n.staffRef&&A.useSession.getState().signOut(),void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ee?'This display was unpaired by a manager.':G.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,K.isOnline)()||/fetch|network/i.test(String(t?.message)))Ce({mode:'offline'});else if(Ca(t)&&'display'!==Ee){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Aa()&&setTimeout(()=>{Ba===e&&qa()},500)}i=Ae.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ce({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!G.IS_CAR&&'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId!==n.staffRef&&(A.useSession.getState().signIn(n.staffRef),ie.useOwner.setState({staffAs:n.staffRef})),G.IS_CAR&&(A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({previewRole:'owner'})),await $a(n.venueId,e,n.kind)}catch(e){Ce({mode:'local',lastError:String(e?.message??e)})}}const Fa=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','venue_reminders','reminder_done']);async function $a(e,a,s){if(!(0,d.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||G.IS_CAR&&'device'===s;await ws(a),Pe.push(Ks(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])mt.set(e.key,e.id),_t.set(e.id,e.key)}catch{}const i=[Pt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ie.useOwner.getState().staff.map(vt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>De('staff.manage'),deletes:!1,revision:e=>(0,j.staffRevision)(e,wt()),toRow:(e,t)=>(0,j.staffRow)(e,t,wt(),e.managerAccess||e.ownerAccess?null:mt.get(St(e))),fromRow:e=>{if(!e.external_ref)return null;pt.set(String(e.external_ref),String(e.id)),gt.set(String(e.id),String(e.external_ref)),Us.set(String(e.external_ref),e.avatar_path??null);const t=yt(ht(_t.get(String(e.role_id))),!0===e.manager_access);return(0,j.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},wt())},apply:e=>ie.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=>ie.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ns()},onRemote:()=>{Ns()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ie.useOwner.getState(),t=ae.useSetup.getState().sites[Ba]?.staffGrade??{};return e.staff.filter(e=>pt.has(e.id)).map(a=>je({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=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:pt.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=gt.get(String(e.staff_id));return t?je({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=>ie.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=ae.useSetup.getState().sites[Ba],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&&ae.useSetup.getState().patch(Ba,{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=ie.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=ae.useSetup.subscribe((t,a)=>{t.sites[Ba]?.staffGrade!==a.sites[Ba]?.staffGrade&&e()});return()=>{t(),a()}}},Fe(a,!1),Fe(a,!0),We(a),Ve(a),$e(a),Ge(a),et(a),tt(a),ct(a),{name:'supplier_directory',table:'suppliers',list:()=>ie.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('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:je(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ie.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId),writable:()=>De('suppliers.order')||De('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||xe(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:je(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},st(a),As(a)];De('wages.view')&&i.push(Cs(a)),n&&(i.push(At(!0),Ct(),Dt(),Tt(a)),Et(e)),n&&await fa('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ae.getState().staffRef&&'pending'===e.status||De('rota.manage')),writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:je(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Fa.add('staff_leave'),Ut(e));const o=n&&await ha();if(Se.useChatSync.setState({synced:o,checked:!0}),Pe.push(()=>Se.useChatSync.setState({synced:!1})),o&&i.push(Ft(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(he.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:pt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:pt.get(e.id),include:e.include}),fromRow:e=>{const t=gt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>he.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=>he.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await fa('hr_questions')&&(i.push(va(a)),Fa.add('hr_questions'),ba(e,a)),'guest'!==s&&'customer'!==Ee&&await fa('temp_readings')&&(i.push((0,Q.tempUnitsSpec)(ne.useSafety,Ye),(0,Q.tempReadingsSpec)(ne.useSafety,Xe)),Fa.add('temp_units'),Fa.add('temp_readings')),'guest'!==s&&await fa('sold_out_items')?(i.push(ca(a,await fa('sold_out_items','auto'))),Fa.add('sold_out_items')):ve.autoSync.soldOutRead.add(a),'guest'!==s&&await fa('sold_out_links')?(i.push(la(a)),Fa.add('sold_out_links')):ve.autoSync.linksRead.add(a),D.useReminders.getState().ensure(a),'guest'!==s&&await Sa()&&(i.push(Qt(a)),n&&i.push(Ht(a))),oe.useNotifs.getState().ensure(a),ue.useOrderLists.getState().ensure(a),n){lt=await fa('staff','nickname'),ft=await fa('staff','display_clock');const[e,t,s,n]=await Promise.all([fa('scheduled_notifications'),fa('order_lists'),fa('venue_clock_area'),fa('daily_tasks')]);me.useDailyTasks.getState().ensure(a),n&&(i.push(da(a),ua(a)),Fa.add('daily_tasks'),Fa.add('daily_task_ticks')),e&&(i.push(sa(a)),pa()),t&&i.push(na(a),ia(a),ra(a)),s&&i.push(oa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Fa.add(n)}if('guest'!==s&&await fa('day_tips')){i.push(ea(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Fa.add(e);await fa('tips_pot_events')&&i.push(ta(a),aa(a)),n&&(zt()||(0,de.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(Zt(a),Xt(a)),Fa.add('cash_ups'),zt()&&(i.push(Yt(a)),Fa.add('sales_reports')),t(r[73])(r[72],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(At(),Ct()),await fa('scheduled_notifications')&&i.push(sa(a)));let u=!1;const c=()=>{if(G.IS_CAR&&n&&De('recipes.edit'))return!0;const e=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);return!!e&&e.active&&De('recipes.edit')&&(0,S.costsAllowedFor)(e)};n&&c()&&await fa('ingredient_prices')&&(i.push((0,_.gpSyncSpec)('ing',c)),Fa.add('ingredient_prices'),await fa('card_costs')&&(i.push((0,_.gpSyncSpec)('card',c)),Fa.add('card_costs')),await fa('kitchen_deliveries')&&(i.push((0,_.gpSyncSpec)('del',c)),Fa.add('kitchen_deliveries')),await fa('kitchen_stock_counts')&&(i.push((0,_.gpSyncSpec)('count',c)),Fa.add('kitchen_stock_counts'))),(0,Oe.specialsSyncOn)()&&'guest'!==s&&await fa('specials_boards')&&(i.push((0,Oe.specialsBoardSpec)(a,()=>De('recipes.edit')||De('floor.manage')||De('*'))),Fa.add('specials_boards'));const l={onActivity:()=>Ce({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ce({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ce({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Pa('whoami')??[]).some(t=>t.venue_id===e))return void(Ba===a&&qa());for(const a of Ke){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||$.useBookingSaves.getState().mark({id:t,table:e,why:is()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||W.useTempSaves.getState().mark({id:t,table:e,why:gs(e)??'this screen could not send it'})}};Ke=i.map(t=>new H.EntityBridge(t,e,l)),await Promise.all(Ke.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,K.isOnline)())try{const t=await Pa('whoami');if(!t?.some(t=>t.venue_id===e))return void(Ba===a&&qa())}catch(e){if(Ca(e)){if(G.IS_CAR)return void(Ba===a&&qa());const e=await Aa();return void('ok'!==e&&'refused'!==e||Ba===a&&qa())}}let t=0;for(const[a,s]of Ke.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(Se.useChatSync.getState().error&&Se.useChatSync.setState({error:void 0}),await Wt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&Se.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({mode:'live',lastSyncAt:e,lastServerAt:e}),F.mutationQueue.flush()}else Ce({mode:'offline'});if(!De('wages.view')){const e=Ae.getState().staffRef;ie.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const m=new Map;for(const e of Ke)m.set(e.spec.table,[...m.get(e.spec.table)??[],e]);const h=[...m.keys()].filter(e=>Fa.has(e)).map(e=>({table:e,venueColumn:m.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,H.venueChannel)(e,h,(e,t,a)=>{for(const s of m.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ce({lastSyncAt:s,lastServerAt:s})},e=>{Ce({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Pe.push(()=>{Re().removeChannel(w)}),Pe.push((0,K.onConnectivity)(e=>{e&&p()}));const v=Ke.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,P.superviseSync)({fastMs:Qa(Ee),readFast:async()=>{for(const e of v)await e.read()},readAll:p,flush:()=>{F.mutationQueue.flush()},wake:()=>{F.mutationQueue.retryNow()},restart:()=>{Ba===a&&qa()},realtime:()=>Ae.getState().realtime,lastServerAt:()=>{const e=Ae.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Ca,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>Wa(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Pe.push(k.stop)}async function Wa(e){const t=Ae.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Pa('sync_heartbeat',{p_venue:e,p_device:(0,A.deviceId)()??'unknown',p_app:Ee,p_version:x.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Qa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ae.getState(),queue:F.mutationQueue.pending.map(e=>e.table),failedTables:F.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),fe.PITCH&&(window.__ccSyncPreview=e=>Ce(e)));const Ha='guest:sent:v1';async function Va(e){Ce({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Pa('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!d.IS_ISOLATED_VENUE||t.id===d.VENUE_UUID)){Ce({venueId:t.id,venueName:t.name}),await ws(e);const a=t.app?.restaurant;a&&V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withWildingsAddress)({...a,id:e}):t)})),Kt(e,t.app?.events)}await Ga(e),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ce({mode:(0,K.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Ga(e).catch(()=>{})},6e4);Pe.push(()=>clearInterval(t)),d.IS_ISOLATED_VENUE||await Ja(e)}async function Ga(e){const t=await Pa('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));X.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&V.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))]}});try{const t=await Pa('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function Ja(e){let t=await q.kv.get(Ha,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=V.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Ka())return;for(const a of n)try{const s=(await Pa('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(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&&V.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'},Ce({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Pa('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(a.allergies)}}))?.[0];t={...t,[a.id]:'order'},s&&V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?Za(e,s):e)}))}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ce({lastError:`Order: ${s}`}),V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:Ya(s)}}:e)})))}await q.kv.set(Ha,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Pa('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await q.kv.set(Ha,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Pa('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));V.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=Za(e,a);return za(s)===za(e)?e:s})})),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ce({mode:(0,K.isOnline)()?Ae.getState().mode:'offline'})}finally{a=!1}}};Pe.push(V.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Ma=setInterval(()=>{n()},15e3),Xa=()=>{n()},n()}const za=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function Za(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const Ya=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let Xa=null;const es={bridges:()=>Ke,restart:qa};function ts(){const e=Ae.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!De('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function as(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(!e||ts())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(F.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function ss(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}as();try{await F.mutationQueue.retryNow()}catch{}}Ae.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{ss()},3e3)});const ns=['bookings','walk_ins'];function is(){const e=Ae.getState();return Ue()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const rs=()=>Ke.filter(e=>ns.includes(e.spec.table)),os=e=>F.mutationQueue.failed.some(t=>ns.includes(t.table)&&t.rowKey===e);function ds(e=!1){return is()?0:rs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&os(t)&&!!$.useBookingSaves.getState().notSaved[t]),0)}async function us(e=!1){const t=is();if(t)return t;for(const e of rs())try{await e.read()}catch{}ds(e);try{await F.mutationQueue.retryNow()}catch{}return e&&cs(),null}function cs(){const e=rs()[0]?.venueId??'',t=$.useBookingSaves.getState(),a=new Set(rs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||os(s)||ns.some(t=>F.mutationQueue.hasPending(t,e,s))||t.clear(s)}F.mutationQueue.onFailed(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().clear(e.rowKey)});let ls=null;const fs=(e=2500)=>{ls&&clearTimeout(ls),ls=setTimeout(()=>{ls=null,us(!1)},e)};(0,K.onConnectivity)(e=>{e&&fs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&fs(3e3)});const ps=['temp_readings','temp_units'];function gs(e="temp_readings"){const t=Ae.getState();return Ue()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ye()?'device'!==t.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ms=()=>Ke.filter(e=>ps.includes(e.spec.table));async function _s(e=!1){const t=gs();if(t)return t;for(const e of ms())try{await e.read()}catch{}const a=ms()[0]?.venueId??'';for(const t of ms())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,F.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await F.mutationQueue.retryNow()}catch{}if(e){const e=W.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ms().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||F.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,W.tempKey)(t.table,t.id))}}return null}F.mutationQueue.onFailed(e=>{ps.includes(e.table)&&W.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ps.includes(e.table)&&W.useTempSaves.getState().clear((0,W.tempKey)(e.table,e.rowKey))});let Ss=null;const hs=(e=3e3)=>{Ss&&clearTimeout(Ss),Ss=setTimeout(()=>{Ss=null,_s(!1)},e)};(0,K.onConnectivity)(e=>{e&&hs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3500)});const ys='golive:v1:';async function ws(e){'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)?await Os(e):(await q.kv.get(ys+e,!1)||await Os(e),await q.kv.get(ks+e,!1)||(Is(e),await q.kv.set(ks+e,!0)),await q.kv.get(vs+e,!1)||(bs(),await q.kv.set(vs+e,!0)))}const vs='golive:v3:';function bs(){const e=e=>JSON.stringify(e).includes('(example)');try{se.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ks='golive:v2:';function Is(e){const t=e=>JSON.stringify(e).includes('(example)');V.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)))})),ie.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 Os(e){if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)){const t=(0,g.stripCoreLiveSamples)(V.useStore.getState()),a=(0,se.stripKitchenExamples)(se.useKitchen.getState()),s=ie.useOwner.getState(),n=(0,g.stripOwnerLiveSamples)(s),i={accidents:ne.useSafety.getState().accidents.filter(e=>!(0,ne.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(V.useStore.getState(),t)&&(await(0,m.archiveChefCache)('core',V.useStore.getState()),V.useStore.setState(t)),r(se.useKitchen.getState(),a)&&(await(0,m.archiveChefCache)('kitchen',se.useKitchen.getState()),se.useKitchen.setState(a)),r(s,n)&&(await(0,m.archiveChefCache)('owner',s),ie.useOwner.setState(n)),r(ne.useSafety.getState(),i)&&(await(0,m.archiveChefCache)('safety',ne.useSafety.getState()),ne.useSafety.setState(i));const o=(0,C.stripHrSamples)(C.useHr.getState());r(C.useHr.getState(),o)&&(await(0,m.archiveChefCache)('hr',C.useHr.getState()),C.useHr.setState(o));const d=(0,_.stripGpSamples)(_.useGpCalc.getState());r(_.useGpCalc.getState(),d)&&(await(0,m.archiveChefCache)('gp',_.useGpCalc.getState()),_.useGpCalc.setState(d));const u=ee.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,m.archiveChefCache)('order-sheets',u),ee.useOrderSheets.setState(c));const l=X.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,p.isLiveVenue)(e.restaurantId)||!(0,y.isDemoCard)(e)),log:l.log.filter(e=>!(0,y.demoActor)(e.by))};return r(l,f)&&(await(0,m.archiveChefCache)('recipe-cards',l),X.useCardStore.setState(f)),void await q.kv.set(ys+e,!0)}const t=t=>t.restaurantId===e&&!(0,re.isUuid)(t.id);V.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)))})),z.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,re.isUuid)(t.id))})),Z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ie.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,re.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,re.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,re.isUuid)(e.id)),leave:e.leave.filter(e=>(0,re.isUuid)(e.id)),swaps:[]}));try{se.useKitchen.setState(e=>(0,se.stripKitchenExamples)(e))}catch{}ie.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,re.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId))}));try{ne.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await q.kv.set(ys+e,!0)}const Rs=(e,t)=>je({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function As(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(Z.useFloor.getState().live[e]??{}).map(([e,t])=>Rs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ae.getState().kind||De('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:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>Rs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>Z.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=>Z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Cs(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(ae.useSetup.getState().sites[e]?.grades??ae.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:()=>De('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=ae.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));ae.useSetup.getState().patch(e,{grades:i})},subscribe:t=>ae.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ds='staff-avatars',Us=new Map;let Es=!1;const Ts=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ns(){if(!Es){Es=!0;try{for(const[e,t]of Us){const a=te.useAvatars.getState().photos[e];if(!t){a?.path&&te.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ae.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Ds).download(t);if(n||!s)continue;const i=await Ts(s);i.startsWith('data:image/')&&te.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{Es=!1}}}function Ks(e){const t=async()=>{const t=Ae.getState().staffRef,a=t?pt.get(t)??Ae.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ae.getState().kind)return;const s=te.useAvatars.getState().photos[t];try{const n=Us.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Ds).remove([t]).catch(()=>{})};if(!s){const e=!!te.useAvatars.getState().clears?.[t];return e&&n&&(await Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}),Us.set(t,null),i(n)),void(e&&te.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ce({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Ds).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Pa('set_staff_avatar',{p_staff_ref:t,p_path:d}),Us.set(t,d),n!==d&&i(n),te.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ce({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:te.useAvatars.getState().photos},s=te.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),De('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ae.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Us.set(t,null),te.useAvatars.getState().doneClear(t),Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Ds).remove([e])).catch(()=>{})}});return t(),s}const Ps=new Map,Ms=(0,E.create)(()=>({n:0}))},987,[988,5,989,932,6,832,837,833,838,990,994,995,835,997,999,1000,1001,1002,1003,13,1004,1006,1009,1010,846,933,976,1011,1012,1013,1016,977,1017,1015,1020,1014,1021,1022,1023,1024,831,872,1025,1026,1029,983,883,1031,926,927,1033,1034,891,870,1036,1039,1040,1041,1042,2,1043,1044,1045,1046,1047,1048,979,981,884,863,859,1049,1052,1053]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},988,[846]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},990,[837,34,838,5,839,846,849,991,863,870,992,993]); +__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},991,[984]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},992,[991]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},993,[991,992]); +__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},994,[]); +__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},995,[835,837,838,5,839,846,849,996,831,884]); +__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'}}]},996,[]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},997,[6,998]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},999,[846]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},1000,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1001,[846]); +__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1002,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1003,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1004,[839,846,849,5,872,1005,15,1003]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1005,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1006,[838,835,837,5,839,846,849,1007,870]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1008,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1009,[839,846,849,863,1010,870]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1010,[]); +__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)))},1011,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1012,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1013,[34,1014]); +__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1014,[1011,977,1015]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1015,[1011]); +__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.3.12.172'},1016,[]); +__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1017,[1018,1019,933,977,1014]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1019,[977]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1020,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1021,[846,849,839]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1022,[846,849,839]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1023,[1024]); +__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1024,[1018,933,1011,977,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1025,[]); +__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1026,[860,839,870,846,849,858,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1028,[891,1004,1027]); +__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1029,[5,860,839,1030,846,849,859]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1030,[1008]); +__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1031,[837,838,5,839,846,849,1032]); +__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1032,[984]); +__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1033,[837,984,838,835,5,839,846,849]); +__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1034,[837,838,5,839,846,849,1035]); +__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1035,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1036,[839,846,849,863,1037,15,870,1038]); +__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1037,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1038,[]); +__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1039,[34,839,846,849,863,13,870]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1040,[839,846,849,863,1041,870,1038]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1041,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1042,[5,997,839,846,849,998]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1043,[1039]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1044,[839,846,849,863,1045,870]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1045,[]); +__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},1046,[846]); +__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(':')}`},1047,[839,846,849]); +__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{}}},1048,[236,872]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1049,[995,1050,1051,976,933]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1051,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1052,[933,987,999]); +__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1053,[1054]); +__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1054,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1055,[34]); +__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1056,[34,236,402,102,846,821,794,1055,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1057,[34,102,794,1058,821,1059,25]); +__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1058,[827,34,379,236,402,102,821,987,1059,2,872,1016,5,796,797,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1059,[1060,933,987,872,236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1060,[]); +__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1061,[827,796,34,402,102,794,821,1044,1045,1010,1001,870,891,25]); +__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1062,[828,1063,796,827,34,281,283,364,336,402,102,426,794,821,1039,831,13,1064,1065,1001,1075,1080,1081,1084,1085,1086,1093,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1063,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1064,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1065,[34,876,1066,1067,1064]); +__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1066,[839,846,849]); +__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1067,[6,1068,1069,1070,1071,1072,1073,1074,3]); +__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1068,[]); +__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1069,[]); +__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1070,[]); +__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1071,[]); +__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1072,[]); +__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1073,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1074,[1064]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1075,[236,933,987,1076]); +__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})},1076,[499,1077,1079,1078]); +__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1077,[499,1078,1079]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1078,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1079,[1078]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1080,[933,987]); +__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1081,[34,281,236,102,794,1039,13,1082,821,1083,25]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1082,[13]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1083,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1084,[827,2,34,102,794,821,1039,891,13,987,1001,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1085,[13]); +__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1086,[34,1063,281,402,102,794,1087,1088,1092,1093,821,25]); +__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1087,[34,402,102,794,821,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1088,[837,34,874,891,858,872,1025,987,1089,1004,15,1091]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1089,[1090]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1090,[1091]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1091,[858]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1092,[34,872,1093,858,987,933]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1093,[]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1094,[34,1095,891,1009,1010,1001,1047,831,1098]); +__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1095,[997,1042,891,998,1096,1097]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1096,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1097,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1098,[]); +__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1099,[34,986,402,102,1100,794,874,1101,858,1102,821,25]); +__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)'}})]})}},1100,[34,281,283,364,102,1048,821,25]); +__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1101,[861,859]); +__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1102,[34,402,102,794,1101,858,821,25]); +__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1103,[34,102,794,874,877,821,25]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1104,[860,34,102,794,874,1026,1029,1105,1106,877,821,25]); +__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1105,[1029,859,1101]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1106,[860,877]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1107,[860,34,102,794,874,983,891,1101,858,821,25]); +__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1108,[828,827,1056,34,336,379,236,402,102,794,821,1040,1041,1001,1109,1110,987,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1109,[1076,236]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1110,[839,846,849]); +__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1111,[827,997,34,379,402,102,794,821,1036,1037,891,1040,1041,1042,998,1096,987,1059,1001,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1112,[34,1036,891,1040,1113,1009,831,1037,1001,1094]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1113,[846]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1114,[997,34,1042,891,831,998,1010,1096,1001,1095]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1115,[860,34,1001,874,1101,1048]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1116,[860,1117,34,102,794,874,1101,821,1118,1107,1119,1140,1143,1099,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1117,[34,102,14,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1118,[821]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1119,[34,102,1120,821,1121,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1120,[860,1105]); +__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1121,[1122,860,34,1123,987,1125,402,102,874,1029,1120,1124,821,858,794,1126,1026,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1122,[34,859,821,794,25]); +__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1123,[34,402,102,874,1124,1125,987,1021,821,1121,794,25]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1124,[860,1105]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1125,[281,236]); +__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1126,[827,1127,1128,860,867,14,1129,1130,34,859,402,102,872,1088,874,1131,1105,858,821,864,794,1029,1026,1132,1133,1138,1107,1101,1139,1124,1123,25]); +__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1127,[34,402,412,102,1128,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1128,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1129,[34,102,794,25]); +__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1130,[34,236,402,295,102,426,821,794,1001,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1131,[878,858,877]); +__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1132,[34,402,102,878,858,821,794,25]); +__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1133,[860,877,34,102,879,1134,1135,1137,794,874,1029,983,861,867,872,1101,821,25]); +__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1134,[34,402,821,794,25]); +__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1135,[828,860,1136,34,281,236,102,1029,1105,821,794,1107,859,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1137,[34,402,102,874,861,863,821,794,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1138,[1128,1120,1124]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1139,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1140,[1141,34,102,874,1029,1124,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1141,[34,102,874,1029,1120,1142,1124,821,1004,891,872,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1142,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1143,[34,1063,1127,102,874,1029,1026,876,872,1138,861,1004,891,1027,1120,821,858,1132,1117,1129,1144,14,1141,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1144,[34,102,874,872,1138,14,1125,821,794,25]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1145,[34,102,794,1063,1093,1146,1092,1086,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1146,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1147,[34,102,794,827,1034,891,835,1148,821,1149,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1148,[1035]); +__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1149,[34,402,102,1125,987,1150,1022,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1150,[933,976,1011,1019,1014,1017,1151,1152,1153,1154,1155,1156,977]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1151,[1019,933,1017]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1152,[1019,933,976,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1153,[1011,976,1152,1014,1017,1151]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1154,[933,977]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1155,[34,1014]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1156,[933]); +__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1157,[30,34,426,102,846,872,1088,1158,25]); +__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1158,[839,846,849]); +__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()},1159,[1160]); +__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1160,[1161,858,884]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1161,[1162,877,1163,878,858,884,1164]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1162,[858]); +__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'},1163,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1164,[858]); +__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1165,[978,34,835,402,102,874,891,1166,1161,794,821,1088,1159,1033,15,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1166,[34,102,794,874,1039,884,1167,831,13,1164,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1167,[34,884]); +__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1168,[34,402,102,794,867,821,1160,1159,1165,1033,25]); +__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1169,[34,402,102,794,874,1161,858,821,1170,1166,1165,25]); +__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1170,[828,34,283,364,236,102,426,797,794,827,821,1171,25]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1171,[]); +__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1172,[827,984,1173,835,860,1174,1175,34,402,295,102,794,874,882,1176,891,994,861,867,1179,858,821,1180,1113,1088,1160,1159,1181,869,1165,1033,925,1182,1004,987,1185,989,1098,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1173,[1159,984]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1174,[827,34,102,794,874,979,891,980,981,982,831,821,25]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1175,[]); +__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1176,[827,796,34,336,402,102,821,794,874,1177,1056,882,861,863,885,1109,1178,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1177,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1178,[]); +__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])},1179,[858]); +__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1180,[928,828,827,837,5,34,1056,336,402,102,794,891,858,821,1088,1025,925,1047,1046,987,1113,1098,25]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1181,[828,34,102,794,876,831,869,821,925,25]); +__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1182,[928,828,34,395,236,402,102,925,794,926,891,1183,927,831,5,1184,987,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1183,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1184,[933,976,987,977]); +__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1185,[34,402,102,794,891,989,1098,994,987,1091,858,1125,821,25]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1186,[1173,984,34,379,102,794,891,994,867,821,1088,1165,1033,1187,25]); +__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1187,[827,835,984,34,379,236,402,102,794,1031,983,985,867,1032,821,1165,25]); +__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1188,[984,872,34,986,1189,336,402,102,1190,794,985,983,1031,821,874,1101,858,1125,987,25]); +__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1189,[5,822,823,828,236,826]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1190,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1191,[827,1031,1173,984,34,402,102,794,891,867,821,1165,1033,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1192,[]); +__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1193,[827,1194,34,402,102,426,794,891,867,858,821,1195,1088,1065,25]); +__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1195,[34,402,102,794,821,5,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1196,[860,1102,1099,1117,34,102,846,794,874,1101,878,877,858,821,1107,1197,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1197,[34,794,874,1198,25]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1198,[379]); +__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1199,[827,1063,1194,34,1200,236,402,426,102,1202,1203,1204,794,831,891,867,1064,821,930,1212,1195,1088,1065,1205,872,1206,1210,25]); +__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1200,[34,402,102,1201,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1201,[34,797,25]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1202,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1203,[34,102,794,827,891,867,1202,821,25]); +__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1204,[827,1202,34,402,102,794,925,891,1098,858,821,1195,1088,1205,872,1206,1207,1209,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1205,[1063,1085,1093]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1206,[34,102,794,891,1039,1063,1093,1087,1205,821,872,1204,1086,1088,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1207,[1064,1208]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1208,[1064,1202]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1209,[34,102,794,827,1063,1064,1207,1125,821,1210,25]); +__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1210,[1063,34,402,102,794,827,891,1208,1064,1211,1125,821,1199,1088,1202,1207,1065,25]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1211,[]); +__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1212,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1180,1195,1088,1065,1160,987,1039,1062,13,1085,1064,2,25]); +__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1213,[828,891,1214,1194,1006,1007,34,1013,1014,236,402,295,102,794,874,1098,1204,1182,1215,1090,5,1216,1161,867,858,821,1195,1180,1088,925,1042,997,998,1095,1001,1097,1166,1164,1207,1209,1091,25]); +__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1214,[827,34,402,102,794,821,891,831,876,1006,1007,25]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1215,[34,102,794,891,1090,821,1098,25]); +__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1216,[34,402,102,794,891,858,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1217,[34,102,794,891,821,1088,1091,1215,1098,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1218,[34,102,1088,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1219,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1220,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1221,[]); +__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1222,[860,1058,34,236,402,102,797,874,821,794,1223,1130,1224,25]); +__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1223,[860,34,380,236,402,102,36,821,794,796,1130,874,25,277]); +__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1224,[1225,1226,1228,1227,1229,1048,1230]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1225,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1226,[839,5,846,849,872,1048,1227]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1227,[860,236,872,1225]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1228,[34,874,861,869,867,1226,1225]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1229,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1230,[34,1226,987,933]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1231,[34,402,102,426,874,861,821,794,1222,1130,1232,25]); +__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1232,[34,102,426,874,861,1224,1048,821,794,1130,25]); +__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1233,[34,236,402,102,879,794,821,1001,1234,1235,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1234,[872,6,933,976,1001,1224,1235]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1235,[839,1236,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1236,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1237,[34,872,1234]); +__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1238,[827,796,1239,835,984,34,931,1200,395,236,402,295,102,846,794,861,1035,867,882,1034,821,1165,1159,1186,932,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1239,[34,1034,891,835]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1240,[34,402,346,102,426,821,1201,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1241,[30,34,792,872,25]); +__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1242,[860,1127,877,30,34,1243,1002,102,14,1129,1138,794,861,867,1131,858,874,987,821,1198,864,1026,1029,1105,1133,1101,1244,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1243,[827,34,236,102,25]); +__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1244,[34,402,102,878,858,1063,1245,821,794,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1245,[1063]); +__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 b}});var n=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),a=e(_r(_d[3])),l=e(_r(_d[4])),r=_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]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,t.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),x=(0,h.useMenu)(e).find(e=>e.id===b),y=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===x?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,n.useTakeawayMenu)(n=>n.byVenue[e]),S=(0,h.useStore)(n=>n.basket.restaurantId===e&&'table'===n.basket.mode),[C,B]=(0,s.useState)(()=>(x?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,s.useState)(1),[P,T]=(0,s.useState)(''),[L,O]=(0,s.useState)(!1),[D,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[q,_]=(0,s.useState)(!1),N=(0,s.useMemo)(()=>x?(0,c.effectiveAllergens)(x,C):{},[x,C]);if(!j||!x)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(N,y.allergies),Y=(x.price??0)+(x.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,n)=>e+n.priceDelta,0),z=S||j.fictional?'on':(0,n.takeawayAvail)(x,w),F=x.soldOut||!x.signOff||null===x.price||'on'!==z,Q=(e,n)=>{const t=x.optionGroups.find(n=>n.id===e);B(e=>{const s=t.choices.map(e=>e.id);return t.multi?e.includes(n)?e.filter(e=>e!==n):[...e,n]:e.includes(n)&&!t.required?e.filter(e=>e!==n):[...e.filter(e=>!s.includes(e)),n]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:x.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),_(!0)};return(0,f.jsxs)(d.Screen,{title:x.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(a.default,{testID:"dish-photo",source:k,accessibilityLabel:`${x.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===x.price?x.priceNote:(0,u.gbp)(Y)}),x.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:x.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(x.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(n=>(0,f.jsx)(d.Chip,{label:n.label,sub:n.priceDelta?`+${(0,u.gbp)(n.priceDelta)}`:void 0,selected:C.includes(n.id),onPress:()=>Q(e.id,n.id)},n.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:x,map:N,declared:y.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:x.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&x.signOff&&null!==x.price?'This dish isn\u2019t on the takeaway menu. You can have it when you eat in.':x.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(l.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${x.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1246,[988,30,34,336,102,1247,1249,794,861,867,874,882,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1247,[34,1248,102,861,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1248,[2,987]); +__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])},1249,[30,34,402,874,821,794,25]); +__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1250,[30,34,794,1251,874,1233,25]); +__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])},1251,[34,402,821,794,25]); +__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1252,[837,30,34,1253,794,867,874,821,1254,1258,25]); +__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:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1253,[34,385,102,874,867,821,794,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1254,[34,102,794,867,1255,1256,1257,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1255,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1256,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1257,[933,987,1256]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1258,[846,933,976,987,2,1255]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),I=_r(_d[23]),O=_r(_d[24]),R=_r(_d[25]),A=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),C=_r(_d[29]),_=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const M=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let $=!1,E=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,k.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,k.useRestaurant)(e),l=(0,k.useMenu)(e),a=(0,k.useCustomer)(),s=(0,k.useBasket)(),n=(0,k.useStore)(e=>e.startBasket),o=(0,k.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[U,V]=(0,u.useState)(!1),[Q,Y]=(0,u.useState)('takeaway'===M?'takeaway':'main');c.default.useEffect(()=>{M&&!$&&($=!0,'book'===M?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,k.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>d.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{C.START_LOYALTY_CODE&&!E&&(E=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,k.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||k.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=l.filter(e=>!('All'!==r&&e.section!==r||'takeaway'===Q&&'off'===ne(e))),re=(0,j.hoursFor)(t,o),ie=e=>()=>d.router.push(`/customer/${t.id}${e}`),de=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>V(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:ie('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:ie('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:ie('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:ie('/refer')},{icon:'gift',label:'Gift cards',on:ie('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:ie('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:ie('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:ie('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:ie('/feedback')},{icon:'hanger',label:'Lost property',on:ie('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:ie('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[re?`Kitchen today ${(0,j.kitchenHoursOn)(t,o)[0]}\u2013${(0,j.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:de.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:de.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=Q===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===Q?(0,v.jsx)(A.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===Q?(0,v.jsx)(m.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==Q?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==Q||oe.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==Q?se.filter(e=>('All'===r||e===r)&&oe.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),oe.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?'Not on the takeaway menu':'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:U,onClose:()=>V(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{V(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1259,[1260,1269,5,1270,1271,1272,1275,860,30,34,236,402,102,1247,1249,794,861,867,878,874,988,821,1276,1233,872,891,1277,995,996,1004,1279,1258,25]); +__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1260,[34,379,794,873,1261,1262,1268,874,5,6,25]); +__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1261,[34,379,102,794,997,998,1096,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1262,[6,34,933,794,1263,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1263,[6,1063,1264,1265,1266,34,102,827,794,821,11,1267,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1265,[4,11]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1266,[11]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1267,[6,933]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1268,[34,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1269,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1270,[34,102,794,1263,25]); +__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1271,[34,379,933,794,873,1261,1263,4,25]); +__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1272,[34,379,794,1261,873,1262,8,1273,25]); +__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1273,[34,102,794,1274,25]); +__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1274,[]); +__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1275,[34,794,873,1261,1262,874,9,25]); +__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1276,[34,402,102,426,794,821,1201,25]); +__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1277,[828,34,336,395,402,295,102,1247,794,995,861,996,858,821,1049,25,1278]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1278,[]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1279,[34,102,1280,794,874,1004,1255,1258,821,25]); +__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1280,[34,102,1281,821,25]); +__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1281,[1282]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1282,[34,797,1283,1312,1313,25]); +__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1283,[1284]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1284,[1285,1286,1309,1311]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1285,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1286,[1287,1288,1289,1290,1291,1292,1293,1294,1295,1298,1302,1299,1303]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1287,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1288,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1289,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1290,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1295,[1296]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1299,[1300,1301]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1300,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1301,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1304,[1299]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1305,[1299]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1307,[1299,1287]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1308,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1309,[1310]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1311,[1310]); +__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1312,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1313,[34,797,1314,25]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1314,[]); +__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1315,[30,34,794,874,891,25]); +__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1316,[837,30,34,102,1280,794,867,874,821,1279,1258,25]); +__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1317,[837,30,34,102,1253,794,874,891,867,858,821,1254,1258,25]); +__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1318,[837,30,34,794,874,891,858,821,1279,1258,25]); +__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1319,[837,30,34,794,874,891,821,1279,1258,25]); +__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1320,[30,34,794,858,1161,1321,874,821,25]); +__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}},1321,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1322,[30,1101,34,402,102,794,858,874,821,25]); +__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 v}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),o=_r(d[3]),r=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),k=_r(d[15]),p=_r(d[16]),f=_r(d[17]);function v(){const e=(0,b.useBasket)(),v=(0,b.useRestaurant)(e.restaurantId??void 0),w=(0,b.useAllMenu)(e.restaurantId??void 0),C=(0,b.useCustomer)(),S=(0,b.useOrders)(v?.id),T=(0,b.useStore)(e=>e.setLineQty),B=(0,b.useStore)(e=>e.overrideLine),P=(0,b.useStore)(e=>e.startBasket),I=(0,b.useNow)(15e3),[O,$]=(0,a.useState)(null),[N,M]=(0,a.useState)(!1),[F,L]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,r.startForm)()),[A,R]=(0,a.useState)(''),[Y,D]=(0,a.useState)(C.phone??''),[E,_]=(0,a.useState)(C.email??''),[q,H]=(0,a.useState)(C.name&&'Guest'!==C.name?C.name:''),[G,V]=(0,a.useState)(!1),K=(0,b.useOrderAtTable)(e.restaurantId??void 0),Q=(0,p.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{K||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[K,e.mode]);const[U,J]=(0,a.useState)(null),[W,X]=(0,a.useState)(!1),Z=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,w,C.allergies),[e,w,C.allergies]);if(!v||!e.lines.length)return(0,f.jsxs)(i.Screen,{title:"Your basket",children:[(0,f.jsx)(i.Muted,{children:"Your basket is empty."}),(0,f.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ee=K&&'table'===e.mode,le=(0,h.takeawaySlots)(v,S,I),te=Z.reduce((e,l)=>e+l.unitPrice*l.qty,0),ae=Z.some(e=>e.contains.length&&!e.overridden),ne=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ee&&'on'!==(0,p.takeawayAvail)(l,Q)}),oe=!ee&&!O,re=!ee&&v.settings.takeawayPaused,se=(0,x.ukPhone)(Y),ie=q.trim().length>=2&&'guest'!==q.trim().toLowerCase(),de=ee||(0,p.takesCardTakeaway)(v,k.IS_ISOLATED_VENUE),ue=!G&&de&&!ae&&!ne.length&&N&&!oe&&!re&&(ee||ie&&se.ok&&(0,x.emailOk)(E)),ce=async()=>{V(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ee?void 0:O,tip:0,notes:F,phone:ee?void 0:se.pretty,email:ee?void 0:E.trim()||void 0,customerName:ee?void 0:q.trim()});(0,r.rememberGuard)(e.id,(0,r.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{V(!1)}},he=e.lines.find(e=>e.key===U),me=he?Z[e.lines.indexOf(he)]:void 0;return(0,f.jsxs)(i.Screen,{title:"Your basket",subtitle:`${v.name} \xb7 ${ee?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,f.jsx)(i.T,{weight:"bold",size:20,colour:j.colours.gold,children:(0,c.gbp)(te)})]}),de?ae?(0,f.jsx)(i.T,{size:14,colour:j.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):N?oe&&!re?(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Choose a collection time."}):ee||ie?ee||se.ok?null:(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your mobile number."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your name for the order."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Confirm your allergies to continue."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ee?(0,f.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!ue,onPress:()=>ce(),testID:"send-table-order"}):(0,f.jsx)(i.Button,{label:G?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(te)}`,disabled:!ue,onPress:()=>ce(),testID:"checkout"}),ee?null:(0,f.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ee||e.tableNo,null),ee?(0,f.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,v.fictional?null:(0,f.jsx)(i.AllergenNotice,{phone:v.phone}),Z.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,f.jsxs)(i.Card,{highlight:l.contains.length?j.colours.red:l.may.length?j.colours.amber:void 0,children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,f.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,f.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,f.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,f.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,f.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,f.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${C.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,f.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{X(!1),J(a.key)}})]})]}):l.contains.length?(0,f.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,f.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ne.includes(a)?(0,f.jsx)(i.Badge,{kind:"amber",label:!ee&&Q&&w.find(e=>e.id===a.itemId)&&'sold-out'===(0,p.takeawayAvail)(w.find(e=>e.id===a.itemId),Q)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Stepper,{value:a.qty,onChange:e=>T(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${v.id}`)}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(I)]}),re?(0,f.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===le.length?(0,f.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(i.Muted,{children:["15-minute slots, max ",v.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:le.slice(0,16).map(e=>(0,f.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:O===e.time.toISOString(),onPress:()=>$(e.time.toISOString())},e.label))})]})]}),(0,f.jsxs)(i.Card,{highlight:N?void 0:j.colours.amber,children:[(0,f.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:C.allergies.length?C.allergies.map(e=>(0,f.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,f.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,f.jsx)(i.Toggle,{label:C.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:N,onChange:M}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.H2,{children:"Your details"}),(0,f.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:q,onChangeText:H,autoComplete:"name",placeholder:"e.g. Sam Smith"}),q&&!ie?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"Please add your name."}):null,(0,f.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:Y,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!se.ok&&Y?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:se.error}):null,(0,f.jsx)(i.Field,{label:"Email (optional)",value:E,onChangeText:_,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,x.emailOk)(E)?null:(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,f.jsx)(i.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,f.jsx)(i.Field,{label:"Order notes (optional)",value:F,onChangeText:L,placeholder:"e.g. cutlery please"}),ee?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>P(v.id,'takeaway')}):null,(0,f.jsxs)(i.Sheet,{visible:!!he,onClose:()=>J(null),title:"Allergy override",children:[me?(0,f.jsx)(i.Banner,{kind:"danger",title:`${me.name} contains ${me.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,f.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:W,onChange:X}),(0,f.jsx)(i.Button,{kind:"danger",disabled:!W,label:"Confirm override",onPress:()=>{he&&me&&B(he.key,me.contains),J(null)}})]}),(0,f.jsx)(o.Honeypot,{value:A,onChange:R})]})}},1323,[860,30,34,1243,1002,102,794,861,867,1131,858,874,831,821,864,5,988,25]); +__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1324,[30,34,102,1249,794,861,878,874,821,1276,5,25]); +__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 f}});var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1325,[860,30,34,102,1251,794,861,867,858,874,821,1326,25]); +__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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1326,[34,371,379,236,30,794,867,821,988,1327,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1327,[933,987]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1328,[860,1258,30,34,102,794,861,867,858,874,879,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1329,[30,34,872,25]); +__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1330,[837,30,34,794,874,5,1258,25]); +__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1331,[30,34,794,1332,1175,1258,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1332,[827,860,34,102,794,861,867,1175,1333,874,821,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1333,[933,987,1175]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1334,[30,34,872,1335,1399,25]); +__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1335,[1162,796,5,6,1336,828,853,1122,860,1161,1337,1338,1339,1119,1143,1340,1341,1346,1347,1348,872,1349,1174,979,1130,1350,34,1099,1196,1048,1115,1157,1351,395,380,402,295,102,426,36,794,1233,1237,873,861,858,874,821,1118,891,1126,1088,1029,1105,1135,1352,1134,1353,1360,1362,1365,1368,1364,1369,1371,1372,1140,1123,1124,878,1376,1222,1377,1232,1224,1026,1382,1390,1391,1102,1142,1393,1394,1395,1098,1189,1396,1188,1181,869,1397,1398,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1337,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1338,[1027,1088]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1339,[34,102,1105,794,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1340,[860,34,102,794,874,1175,821,25]); +__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1341,[34,395,402,426,102,1280,794,1189,796,1029,1342,1343,1345,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1342,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1343,[34,395,402,295,412,102,426,796,794,821,1344,1345,25]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1344,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1345,[1025,872,1344,933,987]); +__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1346,[846]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1347,[828,34,379,395,402,102,794,1189,821,25]); +__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1348,[34,236,402,102,794,821,891,1004,858,1098,25]); +__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1349,[828,827,34,236,402,295,102,794,1174,874,979,831,981,982,872,980,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1350,[828,34,102,821,794,25]); +__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1351,[34,102,797,821,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1352,[]); +__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1353,[828,796,827,1122,860,1130,34,236,402,295,426,102,859,821,794,1354,1355,1029,891,1134,1357,987,872,25]); +__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1354,[828,860,34,1355,102,859,821,794,1135,1356,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1355,[859]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1356,[1355,859]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1357,[34,385,295,102,859,1358,1359,821,796,827,794,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1358,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1359,[1358,1025,872,933,987]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1360,[34,236,402,102,821,794,1189,1361,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1361,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1362,[828,860,1123,34,281,236,295,102,1136,874,1029,1105,14,858,1124,1363,821,794,1364,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1363,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1364,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1365,[5,828,34,283,336,236,402,102,426,821,873,794,1030,1001,1346,1366,2,1367,1368,874,858,25]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1366,[236]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1368,[34,846,933,987,1367]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1369,[860,14,1029,1370]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1370,[861]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1371,[34,102,797,821,25]); +__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1372,[1373,860,1123,1029,34,102,794,1126,874,1375,1369,1124,858,1121,1140,1141,1142,821,1338,25]); +__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1373,[34,379,402,102,874,1004,891,1027,1374,872,821,794,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1374,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1375,[1029,1105]); +__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1376,[1373,828,1123,827,860,1161,1119,1140,858,34,1107,236,402,295,102,794,1126,1364,874,1029,861,1117,1105,1321,821,1338,25]); +__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1377,[827,34,236,402,102,794,874,1029,1378,821,1379,1381,25]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1378,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1379,[846,874,1029,1378,1380,1381]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1380,[860]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1381,[236,1380]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1382,[860,34,1200,1189,402,102,1026,1029,878,858,821,794,1383,1386,25]); +__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1383,[1384,870,860,34,281,395,402,295,102,874,1026,1029,1385,858,821,1056,794,1386,1387,987,1338,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1384,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1385,[878,858,877]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1386,[5,1029,933,987]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1387,[846,933,987,1388,2,1389]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1388,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1389,[15]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1391,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1392,[1105]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1393,[860,1370]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1394,[34,402,102,794,1393,821,1351,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1395,[34,102,925,794,1189,858,821,25]); +__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1396,[34,1189,402,102,426,794,25]); +__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1397,[828,1063,827,2,1189,34,402,102,426,794,821,891,998,858,1001,1387,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1398,[34,1036,891,1009,831,1037,1001,1387,1094]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1399,[5,828,873,34,236,402,102,426,987,821,794,1346,1400,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1400,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1401,[30,34,872,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1402,[30,34,872,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1403,[30,34,1404,872,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1404,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1405,[30,34,872,1406,25]); +__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1406,[1407,1411,828,997,1099,1412,1218,1055,1056,1413,1415,1418,1174,979,1016,1420,1013,2,1061,1062,1421,999,1039,1000,34,1176,1233,1237,1214,373,402,295,102,426,36,794,873,1157,891,821,1180,1422,1094,1112,1114,1108,1057,1040,1088,1430,1431,1432,1441,1442,1004,236,1240,1193,1199,1438,1213,1212,1451,1196,15,1219,1220,925,793,987,25]); +__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1407,[827,34,1048,395,102,1134,1135,1353,1382,794,1026,1029,858,821,1088,1030,1408,1409,1050,25]); +__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1408,[827,34,402,102,794,821,1029,5,1030,872,987,25]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1409,[34,102,794,1029,1410,859,821,1075,933,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1410,[]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1411,[34,102,794,1088,987,25]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1412,[860,34,102,794,861,867,1175,874,869,821,25]); +__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1413,[987,34,281,236,102,1280,794,1255,1258,821,1414,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1414,[34,236,102,794,1255,25]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1415,[34,796,102,794,861,1255,1416,1417,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1416,[861]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1417,[987,1416,1258]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1418,[5,1419,34,102,794,867,1255,1256,1257,987,1258,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1419,[34,794,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1420,[236,1014]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1421,[34,102,794,821,999,1052,987,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1422,[5,1419,1123,11,1423,827,837,1140,1141,1119,1143,1424,1138,1142,1393,1394,1088,1338,1027,1117,14,1144,1426,1233,1427,1382,1107,1101,1118,34,102,794,1351,874,861,867,858,1321,821,1195,1126,1029,1428,1087,1181,1429,1224,987,1197,1390,878,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1423,[6,34,102,794,987,1267,25]); +__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1424,[34,402,102,1425,987,933,821,794,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1425,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1426,[827,5,34,379,236,102,794,876,14,867,1032,933,821,1198,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1427,[34,402,1189,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1428,[34,102,874,1029,794,821,25]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1429,[34,102,879,874,864,821,794,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1430,[34,1383,1088,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1431,[860,34,102,1181,794,874,861,869,858,821,1195,1088,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1432,[835,984,1433,34,236,102,794,831,891,983,1031,985,987,1440,821,2,1182,25]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1433,[827,979,1161,987,797,1222,1224,34,281,379,236,402,102,426,879,794,874,1233,891,867,858,821,1195,1088,869,1434,1180,1438,1439,1160,1167,1166,1039,13,1164,1170,1437,25]); +__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1434,[927,796,831,828,837,878,1076,1435,34,994,336,379,236,402,102,794,874,891,858,821,1195,1088,1437,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1435,[499,1436]); +__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 t={}},1436,[]); +__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1437,[831,891,5]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1438,[827,34,1248,1056,870,379,402,102,794,891,867,858,821,1195,1088,1437,25]); +__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1439,[1016,34,402,102,794,891,821,1088,987,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1440,[]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1441,[860,34,102,794,891,1029,858,1091,1089,987,1090,5,1001,821,25]); +__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1442,[5,1443,1444,1445,1446,1447,34,236,41,102,872,1448,1004,821,1450,794,987,2,1097,1003,891,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1443,[34,102,873,794,5,6,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1444,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1445,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1446,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1447,[34,102,873,794,25]); +__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1448,[34,295,102,794,873,821,1449,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1449,[]); +__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1450,[929,828,34,1097,336,236,402,295,41,102,872,926,891,831,987,1004,15,793,821,925,794,25]); +__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1451,[1196,1099,1140,1117,34,402,102,794,891,858,821,1118,1188,1088,1193,1434,1181,876,1197,869,1195,925,1428,1029,860,1126,1212,1216,1098,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1452,[30,34,872,25]); +__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1453,[1454,987,795,1400,1456,1026,30,1483,496,34,385,336,236,41,102,5,873,872,1485,36,874,1029,891,821,1442,1004,1024,1488,1489,1058,1490,1130,2,1039,999,1491,1368,25,1493,1494,1495,1496]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1454,[2,827,34,236,383,102,794,1455,987,821,1199,1004,891,994,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1455,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1456,[1457,1480,1482]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1457,[215,1458,1461,1475,1476,1477,1478,1479]); +__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1458,[215,1459]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1459,[1460]); +__d(function(g,r,i,a,m,e,d){},1460,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1461,[1462,215,1458,1475,1476]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1462,[1463,1464,1474]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1463,[1464,1468,1473]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1464,[215,372,1465,1469,1470,1471,1472,1468,1473]); +__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1465,[215,1466,339,280,1467,1468]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1466,[504]); +__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1467,[215,339]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1468,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1469,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1470,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1471,[1469]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1472,[]); +__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1473,[372,1467]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1474,[34,1464]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1475,[1462,215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1476,[1462,1475]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1477,[1458]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1478,[215,1458,1461,1459]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1479,[]); +__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1480,[215,54,1481]); +__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1481,[215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1482,[34,1457]); +__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]}})})},1483,[1484]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1484,[]); +__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1485,[34,41,102,426,794,873,1004,987,2,5,821,1486,1487,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1486,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1487,[34,102,794,821,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1488,[990,883,882,987]); +__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1489,[828,796,827,34,1012,1408,1030,402,102,872,987,1014,1029,5,821,794,1346,976,2,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.VoiceHost=function(){return null}},1490,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1491,[874,831,891,1039,15,1004,872,2,1492]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1492,[874,1039]); +__d(function(e,o,s,p,t,a,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1493,[]); +__d(function(o,s,e,p,t,c,d){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1494,[]); +__d(function(o,s,e,p,t,d,f){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1495,[]); +__d(function(o,s,e,p,t,d,n){"use strict";t.exports="/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1496,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1497,[30,34,872,25]); +__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1498,[1499]); +__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1499,[25,1500,591]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1500,[34,172]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1501,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1502,[25,499,34,270,651]); __r(501); __r(21); __r(0); \ No newline at end of file diff --git a/customer-app/admin.html b/customer-app/admin.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/admin.html +++ b/customer-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer.html b/customer-app/customer.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer.html +++ b/customer-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage.html b/customer-app/customer/anchorage.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage.html +++ b/customer-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/book.html b/customer-app/customer/anchorage/book.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/book.html +++ b/customer-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/feedback.html b/customer-app/customer/anchorage/feedback.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/feedback.html +++ b/customer-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/gift.html b/customer-app/customer/anchorage/gift.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/gift.html +++ b/customer-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/lost.html b/customer-app/customer/anchorage/lost.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/lost.html +++ b/customer-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/loyalty.html b/customer-app/customer/anchorage/loyalty.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/loyalty.html +++ b/customer-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/merch.html b/customer-app/customer/anchorage/merch.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/merch.html +++ b/customer-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/offers.html b/customer-app/customer/anchorage/offers.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/offers.html +++ b/customer-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/refer.html b/customer-app/customer/anchorage/refer.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/refer.html +++ b/customer-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/waitlist.html b/customer-app/customer/anchorage/waitlist.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/waitlist.html +++ b/customer-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/anchorage/whatson.html b/customer-app/customer/anchorage/whatson.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/anchorage/whatson.html +++ b/customer-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/basket.html b/customer-app/customer/basket.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/basket.html +++ b/customer-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/customer/profile.html b/customer-app/customer/profile.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/customer/profile.html +++ b/customer-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/demo.html b/customer-app/demo.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/demo.html +++ b/customer-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/display.html b/customer-app/display.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/display.html +++ b/customer-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/index.html b/customer-app/index.html index 4ab645132f40460abea23c741d43a63da2aba0cd..b4f1b77fdace46efbd9e4fedcd6c4e54dfa46e15 100644 --- a/customer-app/index.html +++ b/customer-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/kitchen.html b/customer-app/kitchen.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/kitchen.html +++ b/customer-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/owner.html b/customer-app/owner.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/owner.html +++ b/customer-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/staff.html b/customer-app/staff.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/staff.html +++ b/customer-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/customer-app/sw.js b/customer-app/sw.js index 9c65da7918485354f7839d04b151cef3306e5663..135487e69edab2310aad5f366c8263ae4cedaf7a 100644 --- a/customer-app/sw.js +++ b/customer-app/sw.js @@ -1,7 +1,7 @@ // Anchorage service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-customer-25ebcdfecd"; +const V = "cc-customer-37a6fc17fc"; const BASE = "/customer-app/"; -const PRECACHE = ["/customer-app/apple-touch-icon.png", "/customer-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/customer-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/customer-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/customer-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/customer-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/customer-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/customer-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/customer-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/customer-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/customer-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/customer-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/customer-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/customer-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/customer-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/customer-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/customer-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/customer-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/customer-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/customer-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/customer-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/customer-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/customer-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/customer-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/customer-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/customer-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/customer-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/customer-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/customer-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/customer-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/customer-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/customer-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/customer-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/customer-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/customer-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/customer-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/customer-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/customer-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/customer-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/customer-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/customer-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/customer-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/customer-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/customer-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/customer-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/customer-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/customer-app/brand-logo.png", "/customer-app/favicon.ico", "/customer-app/icon-192.png", "/customer-app/icon-512.png", "/customer-app/icon-maskable-192.png", "/customer-app/icon-maskable-512.png", "/customer-app/manifest.webmanifest", "/customer-app/index.html", "/customer-app/_expo/static/js/web/bundle.js?v=25ebcdfecd32d336d0353b0c80d8290359ec9682e489b4966c41f768cd1c2b36"]; +const PRECACHE = ["/customer-app/apple-touch-icon.png", "/customer-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/customer-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/customer-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/customer-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/customer-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/customer-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/customer-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/customer-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/customer-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/customer-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/customer-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/customer-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/customer-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/customer-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/customer-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/customer-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/customer-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/customer-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/customer-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/customer-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/customer-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/customer-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/customer-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/customer-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/customer-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/customer-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/customer-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/customer-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/customer-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/customer-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/customer-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/customer-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/customer-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/customer-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/customer-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/customer-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/customer-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/customer-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/customer-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/customer-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/customer-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/customer-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/customer-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/customer-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/customer-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/customer-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/customer-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/customer-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/customer-app/brand-logo.png", "/customer-app/favicon.ico", "/customer-app/icon-192.png", "/customer-app/icon-512.png", "/customer-app/icon-maskable-192.png", "/customer-app/icon-maskable-512.png", "/customer-app/manifest.webmanifest", "/customer-app/index.html", "/customer-app/_expo/static/js/web/bundle.js?v=37a6fc17fc964c08b48d94a27802fa311059983270982e660b40ddb4188490a6"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/customer-app/team.html b/customer-app/team.html index 817c0bd221503d4105abe5709298438342251004..2c4e2e97d9e9ac9526e10fdc6ffb22c92a4d9dab 100644 --- a/customer-app/team.html +++ b/customer-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/_expo/static/js/web/bundle.js b/display-app/_expo/static/js/web/bundle.js index a3a6645312358105f6bc5369896baca276075890..6eee5daa7ba25fc045b8a2be8883994b145aa5dc 100644 --- a/display-app/_expo/static/js/web/bundle.js +++ b/display-app/_expo/static/js/web/bundle.js @@ -23,11 +23,11 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_VENUE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PITCH_TEAM",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PITCH_TEXT",{enumerable:!0,get:function(){return o}}),e.pitchText=function(a,n=!1){let l=a;for(const[a,s]of o){if(n&&t.test(a.source.replace(/\\/g,'')))continue;a.test(l)?(a.lastIndex=0,l=l.replace(a,s)):a.lastIndex=0}return l};const a={name:'The Harbour Kitchen',tagline:'Harbourside seafood & seasonal plates',location:'12 Quay Street, Portmorran',phone:'01632 960 123',website:'harbourkitchen.example'},n={'st-tracy':{name:'Morgan',job:'Owner',hourlyPence:null,salaried:!0},'st-gordon':{name:'Alex',job:'General Manager',dept:'Management',hourlyPence:null,salaried:!0},'st-bisto':{name:'Ravi',job:'Head Chef',hourlyPence:null,salaried:!0},'st-agate':{name:'Priya',job:'Front of house supervisor',hourlyPence:1450},'st-lenny':{name:'Tom',job:'Commis Chef',hourlyPence:1325},'st-finn':{name:'Lewis',job:'Bar staff',hourlyPence:1290},'st-eilidh':{name:'Chloe',job:'Front of house',hourlyPence:1271},'st-emily':{name:'Ellie',job:'Front of house',hourlyPence:1271},'st-lillie':{name:'Jordan',job:'Kitchen porter (KP)',hourlyPence:1271},'st-jack':{name:'Sam',job:'Kitchen porter (KP)',hourlyPence:1271}},o=[['Harbour View, Dunure, South Ayrshire',a.location],['Harbour View, Dunure',a.location],['Harbour View mug','Harbour Kitchen mug'],['Harbour View','Quay Street'],['anchoragedunure.com',a.website],['01292 502826',a.phone],['Mini Anchors','Little Crew'],['The Anchorage',a.name],['Anchorage','Harbour Kitchen'],['ANCHORAGE','HARBOUR KITCHEN'],['South Ayrshire','the Firth coast'],['Ayrshire','the Firth coast'],['Dunure','Portmorran'],['Kittyfisher boat (Big Sean)','Coastal Fish Co'],['Kittyfisher','Coastal Fish Co'],['Big Sean','Coastal Fish Co'],['Example Fish Co.','Coastal Fish Co'],['Sample Dairy Ltd','Hillside Dairy'],['Sample Fruit & Veg','Fieldfare Veg'],['Mills milk','Hillside Dairy milk'],['Mills','Hillside Dairy'],['J. Pieroni & Sons','Fieldfare Veg'],["Pieroni's",'Fieldfare Veg'],['Pieroni','Fieldfare Veg'],['Alsons (drinks)','Drinks wholesaler'],['Alsons','the drinks wholesaler'],['Spes Bona','the deli wholesaler'],['Tarelgin','the butcher'],['Reids','the bakery'],['Reeds','the bakery'],['Example Butchers Ltd','Quayside Butchers'],['Example Dry Goods Wholesale','Dry goods wholesaler'],['Sample Brewing Co.','Harbourside Brewing'],['Example Cleaning Supplies','Cleaning supplies'],['Sample Packaging Ltd','Packaging supplier'],['Example Kitchen Repairs','Kitchen repairs'],['Preston','Ravi'],['Bisto','Ravi'],['Tracy','Morgan'],['James','Morgan'],['Gordon','Alex'],['Agate','Priya'],['Lenny','Tom'],['Finn','Lewis'],['Eilidh','Chloe'],['Emily','Ellie'],['Gabrielle','Ellie'],['Cameron Mc','Sam'],['Cameron','Sam'],['Lillie','Jordan'],['Lily','Jordan'],['Mia','Jordan'],['Jack','Sam'],['Harvey','Jordan'],['Anna','the supplier'],['(preview)',''],[' (example)','']].map(([a,n])=>[new RegExp(`${/^[A-Za-z]/.test(a)?'(?g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},23,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1512,1515]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1515,1518]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},25,[26]); __d(function(g,r,i,a,m,e,d){ /** @@ -41,8 +41,8 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},26,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},27,[28]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1052,1240,1241,1245,1249,1251,1258,1314,1315,1316,1317,1318,1319,1321,1322,1323,1324,1325,1326,1327,1328,1331,1398,1399,1400,1402,1449,1450,1511]); -__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,993,25]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1053,1241,1242,1246,1250,1252,1259,1315,1316,1317,1318,1319,1320,1322,1323,1324,1325,1328,1329,1330,1331,1334,1401,1402,1403,1405,1452,1453,1514]); +__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,994,25]); __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)},30,[31,32,782,783,785]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},31,[]); __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}},32,[33,692,487,708,557,709,770,761,764,774,647,645,650,562,560,591,465,467,204,205,775,472,473,462,460,569,556,639,659,776,658,162,151,547,433,777,780]); @@ -872,9 +872,9 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},789,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},790,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},791,[]); -__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1054,1055,1015,2,1056,1060,1061,1093,858,1098,1102,1103,1106,1107,1110,1111,1113,1114,1115,1144,1146,1091,34,373,236,402,295,426,102,36,873,1156,794,867,821,1087,1158,1164,1167,1168,1171,1185,1184,1186,1187,1190,1191,1192,1195,1198,1211,1212,1216,1217,925,1003,1218,1177,1219,1220,1221,1230,1223,1175,1232,1236,1213,874,1237,1173,987,1239,25]); +__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1055,1056,1016,2,1057,1061,1062,1094,858,1099,1103,1104,1107,1108,1111,1112,1114,1115,1116,1145,1147,1092,34,373,236,402,295,426,102,36,873,1157,794,867,821,1088,1159,1165,1168,1169,1172,1186,1185,1187,1188,1191,1192,1193,1196,1199,1212,1213,1217,1218,925,1004,1219,1178,1220,1221,1222,1231,1224,1176,1233,1237,1214,874,1238,1174,987,1240,25]); __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=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.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."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.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 CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};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]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(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 v(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 b(e){const{img:t,url:a}=await f(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),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.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()})}},793,[34,336,236,402,102,794,925,929,926,821,930,25]); -__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=D,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(H,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(x.default,{style:{flex:1},children:u}),s?(0,B.jsx)(x.default,{style:N.footer,children:(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=v,_e.Card=F,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(x.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:L?'center':'flex-start'}],children:(0,B.jsx)(D,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(x.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(D,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(D,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(x.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(D,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,p.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(D,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(D,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(x.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(D,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),x=e(_r(d[14])),p=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),L='display'!==S.APP_VARIANT;function D({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),x=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,p=f.default.flatten(t)||{},j=1===p.flex||1===p.flexGrow||'number'==typeof p.width||'left'===p.textAlign,k=c??(L&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,x,(0,W.webLine)(t,r),k&&'left'!==p.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(D,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(D,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(D,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??L});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(x.default,{style:N.brandBar,children:[(0,B.jsxs)(x.default,{style:N.row,children:[(0,B.jsx)(x.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(D,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(x.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(x.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function H(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(D,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function v({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],x={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:x,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(D,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(D,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function F({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(x.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(x.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(D,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(D,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,v.centreRow=!0;const V=()=>(0,B.jsx)(E,{kind:"example",title:"Allergens awaiting kitchen verification",children:"This allergen information has not been verified by the kitchen. Head chef sign-off is required. Always speak to staff about allergies."}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Card payments: not set up yet",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===F?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(L&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(x.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=L&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(x.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(x.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); +__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(v,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(p.default,{style:{flex:1},children:u}),s?(0,B.jsx)(p.default,{style:N.footer,children:(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=F,_e.Card=H,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:D?'center':'flex-start'}],children:(0,B.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,x.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),D='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(D&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??D});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(p.default,{style:N.brandBar,children:[(0,B.jsxs)(p.default,{style:N.row,children:[(0,B.jsx)(p.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function v(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function F({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function H({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,F.centreRow=!0;const V=({phone:e})=>(0,B.jsx)(E,{kind:"warn",title:"Allergies",children:"All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===H?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(D&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=D&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},795,[]); __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.GoldX=h,_e.GoldClose=j,Object.defineProperty(_e,"TEXT_ONLY_CLOSE",{enumerable:!0,get:function(){return x}}),_e.ToastClose=function({onPress:e,label:o="Close",testID:s,size:l="md",style:c,colour:h}){return x?(0,b.jsx)(t.default,{testID:s,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:[{minWidth:64,minHeight:48,alignItems:'center',justifyContent:'center',paddingHorizontal:8},c],children:(0,b.jsx)(u.Text,{style:{fontSize:16,color:h??n.colours.text},children:"Close"})}):(0,b.jsx)(j,{onPress:e,label:o,testID:s,size:l,style:c})},r(d[0]);var t=e(r(d[1])),o=e(r(d[2])),s=r(d[3]),l=e(s),n=r(d[4]),c=r(d[5]),u=r(d[6]),b=r(d[7]);function h({size:e=16,colour:t=n.colours.gold,stroke:o}){const c=o??(e>=20?2.4:2.2);return(0,b.jsx)(l.default,{width:e,height:e,viewBox:"0 0 24 24",accessible:!1,focusable:!1,pointerEvents:"none",children:(0,b.jsx)(s.Path,{d:"M6 6 L18 18 M18 6 L6 18",stroke:t,strokeWidth:Math.min(4,c*(24/e)),strokeLinecap:"round",fill:"none"})})}const f={sm:32,md:38,lg:46},y={sm:13,md:15,lg:18};function j({onPress:e,label:s="Close",testID:l,size:c="md",style:u,disabled:j,hint:x}){const C=f[c],I=Math.max(44,C+8);return(0,b.jsx)(t.default,{testID:l,accessibilityRole:"button",accessibilityLabel:s,accessibilityHint:x,disabled:j,onPress:e,dataSet:{goldClose:'1'},style:[{width:I,height:I,alignItems:'center',justifyContent:'center',flexShrink:0,opacity:j?.4:1},u],children:({pressed:e,hovered:t})=>(0,b.jsx)(o.default,{style:{width:C,height:C,borderRadius:C/2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:e||t?n.colours.gold:n.colours.accentBorder,backgroundColor:e?n.colours.goldTint:t?n.colours.accentBg:'rgba(0,0,0,0.18)'},children:(0,b.jsx)(h,{size:y[c],colour:e?n.colours.goldLight:n.colours.gold})})})}const x=['kirkton','abbotsford'].includes(c.VENUE_RID)},796,[34,402,102,797,821,5,827,25]); __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}},797,[798]); @@ -911,7 +911,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule? __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOUTERS_BG",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SOUTERS_SURFACE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SOUTERS_TYPE_SCALE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"soutersFont",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"soutersSurface",{enumerable:!0,get:function(){return f}}),e.soutersInk=function(o){if(!t.IS_SOUTERS)return o;const c=(0,n.normaliseHex)(o);return c?'#A4622E'===c?'#D9AD8A':(0,n.contrast)(c,u)<4.5?'#FFFFFF':o:o};var t=r(d[0]),n=r(d[1]);const u='#56152A',o='#43122F',c=.88,S=n=>t.IS_SOUTERS?Math.round(n*c*100)/100:n,f=n=>t.IS_SOUTERS?o:n},828,[5,829]); __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normaliseHex=n,e.hexToRgb=r,e.rgbToHex=o,e.hsvToRgb=s,Object.defineProperty(e,"hsvToHex",{enumerable:!0,get:function(){return a}}),e.hexToHsv=function(t){const{r:n,g:o,b:s}=r(t),a=n/255,c=o/255,u=s/255,i=Math.max(a,c,u),h=Math.min(a,c,u),l=i-h;let p=0;l&&(p=i===a?(c-u)/l%6:i===c?(u-a)/l+2:(a-c)/l+4);return{h:(60*p+360)%360,s:i?l/i:0,v:i}},e.luminance=c,e.contrast=u,e.shade=i,e.checkAccent=function(t,r,o,s){const a=n(t)??'#CFA45F',c=u(a,o),h=u(a,s),l=c>=h?o:s,p=[];Math.max(c,h)<4.5?p.push('Button text may be hard to read on this colour. We picked the clearer text colour for you, but a lighter or darker shade will read better.'):l===s&&p.push('This is a dark colour, so buttons use light text.');let b=a,d=0;for(;u(b,r)<4.5&&d<20;)b=i(a,.05*(d+1)),d++;b!==a&&p.push('This colour is hard to read on the dark background, so header text uses a lighter shade of it.');return{onAccent:l,accentText:b,tips:p}},e.pushRecent=function(t,r,o=8){const s=n(r);return s?[s,...(t??[]).filter(t=>t!==s)].slice(0,o):t??[]};const t=(t,n=0,r=1)=>Math.min(r,Math.max(n,t));function n(t){const n=t.trim().replace(/^#/,'');return/^[0-9a-fA-F]{3}$/.test(n)?'#'+n.split('').map(t=>t+t).join('').toUpperCase():/^[0-9a-fA-F]{6}$/.test(n)?'#'+n.toUpperCase():null}function r(t){const r=(n(t)??'#000000').slice(1);return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function o({r:n,g:r,b:o}){return'#'+[n,r,o].map(n=>Math.round(t(n,0,255)).toString(16).padStart(2,'0')).join('').toUpperCase()}function s({h:t,s:n,v:r}){const o=(t%360+360)%360/60,s=r*n,a=s*(1-Math.abs(o%2-1)),c=r-s,[u,i,h]=o<1?[s,a,0]:o<2?[a,s,0]:o<3?[0,s,a]:o<4?[0,a,s]:o<5?[a,0,s]:[s,0,a];return{r:255*(u+c),g:255*(i+c),b:255*(h+c)}}const a=t=>o(s(t));function c(t){const n=t=>{const n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)},{r:o,g:s,b:a}=r(t);return.2126*n(o)+.7152*n(s)+.0722*n(a)}function u(t,n){const r=c(t),o=c(n);return(Math.max(r,o)+.05)/(Math.min(r,o)+.05)}function i(t,n){const{r:s,g:a,b:c}=r(t),u=n>0?255:0,i=Math.abs(n);return o({r:s+(u-s)*i,g:a+(u-a)*i,b:c+(u-c)*i})}},829,[]); __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,"isEditable",{enumerable:!0,get:function(){return u}}),_e.hideKeyboard=s,_e.installKeyboardHide=f,_e.useTyping=function(){const[e,n]=t.default.useState(c);return t.default.useEffect(()=>{if(!o)return;f();const e=()=>setTimeout(()=>n(c()),0);return document.addEventListener('focusin',e,!0),document.addEventListener('focusout',e,!0),()=>{document.removeEventListener('focusin',e,!0),document.removeEventListener('focusout',e,!0)}},[]),e},_e.useVisibleArea=function(){const e=o?window.visualViewport:null,n=()=>e?{height:Math.round(e.height),top:Math.round(e.offsetTop)}:null,[u,c]=t.default.useState(n);return t.default.useEffect(()=>{if(!e)return;const t=()=>c(e=>{const t=n();return e&&t&&e.height===t.height&&e.top===t.top?e:t});return e.addEventListener('resize',t),e.addEventListener('scroll',t),()=>{e.removeEventListener('resize',t),e.removeEventListener('scroll',t)}},[]),u};var t=e(r(d[0])),n=e(r(d[1]));r(d[2]);const o='undefined'!=typeof document,u=e=>!!e&&'function'==typeof e.matches&&e.matches("input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]"),c=()=>!!o&&u(document.activeElement);function s(){try{n.default.dismiss()}catch{}o&&u(document.activeElement)&&document.activeElement.blur()}function a(){if(!o)return;const e=document.activeElement;if(u(e))try{e.scrollIntoView({block:'nearest',inline:'nearest'})}catch{}}let l=!1;function f(){o&&!l&&(l=!0,document.addEventListener('click',e=>{if(!c())return;const t=document.activeElement;if('function'!=typeof t.closest||!t.closest('[aria-modal="true"], [role="dialog"]'))return;const n=e.target;n&&!u(n)&&('function'==typeof n.closest&&n.closest('label, [data-keep-keyboard]')||s())},!0),document.addEventListener('focusin',e=>{u(e.target)&&setTimeout(a,300)},!0),window.visualViewport?.addEventListener('resize',()=>setTimeout(a,50)))}},830,[34,376,236]); -__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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 O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:u,phone:g,email:m})=>{const p=t(),b=p.basket,f=b.restaurantId,k=w(b,p.menu,p.customer.allergies),I=k.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,h=$(p.orders.filter(e=>e.restaurantId===f).map(e=>e.ref),S?'Q-':'T-',S?p.counters.table:p.counters.order),O=u?n(o,f,I+i):0,C=I+i,v={id:(0,y.uuid)(),ref:`${S?'Q':'T'}-${h}`,restaurantId:f,customerId:p.customer.id,customerName:p.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:k,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:u?C:0,status:'new',createdAt:a().toISOString(),allergies:p.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:g??p.customer.phone,email:m??p.customer.email}:{}};e(e=>({orders:[v,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:h}:{...e.counters,order:h}}));const A=k.filter(e=>e.overridden);return r(f,'order',`Order ${v.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${A.length?` \u2014 ALLERGY OVERRIDE on ${A.map(e=>e.name).join(', ')}`:''}`),v.allergies.length&&r(f,'allergy',`Allergies declared and confirmed by customer on ${v.ref}: ${v.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),c(v),v},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); +__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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,choiceIds:s.map(e=>e.id)}]})}const O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:n,tip:s,notes:i,phone:o,email:l,customerName:u})=>{const g=t(),m=g.basket,p=m.restaurantId,b=w(m,g.menu,g.customer.allergies),f=b.reduce((e,t)=>e+t.unitPrice*t.qty,0),k='table'===m.mode,I=$(g.orders.filter(e=>e.restaurantId===p).map(e=>e.ref),k?'Q-':'T-',k?g.counters.table:g.counters.order),S=!k,h=f+(S?0:s),O=(u??'').trim()||g.customer.name,C={id:(0,y.uuid)(),ref:`${k?'Q':'T'}-${I}`,restaurantId:p,customerId:g.customer.id,customerName:O,type:m.mode,tableNo:m.tableNo,slotTime:n,lines:b,subtotal:f,tip:S?0:s,giftCardApplied:0,giftCardCode:void 0,total:h,paid:0,status:S?'awaiting_payment':'new',createdAt:a().toISOString(),allergies:g.customer.allergies,readiness:{},notes:i,channel:'app',...'takeaway'===m.mode?{phone:o??g.customer.phone,email:l??g.customer.email}:{}};e(e=>({orders:[C,...e.orders],basket:{...e.basket,lines:[]},counters:k?{...e.counters,table:I}:{...e.counters,order:I}}));const v=b.filter(e=>e.overridden);return r(p,'order',`Order ${C.ref} placed (${k?`Table ${m.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),C.allergies.length&&r(p,'allergy',`Allergies declared and confirmed by customer on ${C.ref}: ${C.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),'awaiting_payment'!==C.status&&c(C),C},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WILDINGS_LOCATION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WILDINGS_ADDRESS",{enumerable:!0,get:function(){return t}}),e.withWildingsAddress=function(r){return'wildings'===r.id?{...r,location:n,address:t}:r},e.withWildingsQuestionnaireAddress=function(n,r){return'wildings'===n&&r?{...r,venue:{...r.venue,address:t}}:r};const n='Maidens, KA26 9NR',t='Maidens Road, Maidens, KA26 9NR'},832,[]); __d(function(g,r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sampleFingerprint=i,e.stripOwnerLiveSamples=function(n){const a={};for(const[s,o]of Object.entries(t.OWNER_SAMPLE_HASHES)){const t=n[s]||[];a[s]=t.filter(t=>!o.includes(i(t)))}a.chat=(n.chat||[]).filter(t=>!(0,s.isSeedChefChat)(t));const o=(n.changeRequests||[]).length-a.changeRequests.length;o&&(a.changesUsed=Math.max(0,(n.changesUsed||0)-o));return a},e.stripCoreLiveSamples=function(a){const c={...(0,n.stripCoreChefSamples)(a)};c.giftCards=(a.giftCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.giftCards.includes(i(s))),c.stampCards=(a.stampCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.stampCards.includes(i(s))),c.ratings=(a.ratings||[]).filter(t=>!(/^rt-[123]$/.test(t.id)&&(0,s.demoActor)(t.customerName))),i(a.customer)===t.LEGACY_CUSTOMER_HASH&&(c.customer={...a.customer,id:'',name:'',email:'',phone:'',allergies:[],allergyConsent:!1,referralCode:'',marketingOptIn:{}});return c.restaurants=(a.restaurants||[]).filter(t=>!('saltmarsh'===t.id&&['The Venue','Saltmarsh Bistro'].includes(t.name))),c.menu=(c.menu||a.menu||[]).filter(t=>'saltmarsh'!==t.restaurantId).map(t=>t.signOff?t:o(t)),c};var t=r(d[0]),s=r(d[1]),n=r(d[2]);const a=t=>Array.isArray(t)?t.map(a):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&'function'!=typeof t).sort(([t],[s])=>ts?1:0).map(([t,s])=>[t,a(s)])):t;function i(t){const s=JSON.stringify(a(t))??"null";let n=2166136261;for(let t=0;t>>0).toString(16)}const o=t=>Array.isArray(t)?t.map(o):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).map(([t,s])=>[t,'allergenNotes'===t&&'string'==typeof s&&/\(example\)/i.test(s)?'':o(s)])):t},833,[834,835,836]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"OWNER_SAMPLE_HASHES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CORE_SAMPLE_HASHES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"LEGACY_CUSTOMER_HASH",{enumerable:!0,get:function(){return b}});const c={referrals:["43f09bc0","c438fbad","96bf8c62","3399d421"],coats:["f51097ad","2f7efa3a"],merch:["ef6e14e","dbbc0999","dc233c1d"],merchOrders:["13b15512","bc27f242"],offers:["ad0fcde0","59e6c0cf"],photos:["53a60fd9","ab778a74","95de43cd"],changeRequests:["81c5be12","6819542c"],lost:["5bbf0d77","7d3aa9ed","850c049e"],campaigns:["9cdf8346","82150e7"],suppliers:["41df06e7","466e32ac","fa3d8eea","dfafa674","1e26fbd0","c195b120","5fc49e74","6aa8b0af","602fc2e4"],supplierOrders:["22636226","464d6a6a"]},f={giftCards:["b1bba36d","f029bc0e"],stampCards:["e7bedf6f","a3c8404d"]},b="4b1e9971"},834,[]); @@ -1067,536 +1067,539 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},984,[835]); __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 t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(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 u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{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}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},985,[984]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},986,[872,34,102,987,2,821,794,25]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return W.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return W.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return W.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return W.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return W.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return I.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return I.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return It}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ne.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ne.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ne.useOwner.getState().chatSeen(t,e)),Ft(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ne.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...St(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(le.PITCH)return pe.unlockCashUp(e,t,a);const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?oe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):oe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(le.PITCH)return pe.cashAudit(e);const t=Oe.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(ma.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=fa,i.readAccessLog=async function(){const e=Oe.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Oe.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return pa}}),i.uploadOrderLogo=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(pa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ga.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(pa).createSignedUrl(e,3600);if(t?.signedUrl)return ga.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(pa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return ma}}),i.claimInvite=Da,i.makeChromeHandover=async function(){const e=Oe.getState();if(le.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ue});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(le.PITCH||!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ue});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),Pe&&xa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Te();const t=await x.kv.get(ka,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Te(),await x.kv.get(Ia,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_WILDINGS||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Te(),await x.kv.remove(ka),await x.kv.remove(Ia),Ae({mode:'signin',perms:[]});try{await Ma()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Oe.getState().venueId;if(le.PITCH||!s||'staff'!==Oe.getState().kind)return{ok:!0};if(!(0,ie.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ka('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Da(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(le.PITCH)return pe.reissueInvite(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ka('staff_app_link_history',{p_venue:Oe.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ka('revoke_staff_app_link',{p_venue:Oe.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(le.PITCH)return pe.linkPhones();const e=Oe.getState().venueId;if(!e||'staff'!==Oe.getState().kind)return{};try{const t=await Ka('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(le.PITCH)return pe.resetPhone(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ka('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(le.PITCH)return pe.inviteStatus();const e=Oe.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:t,error:a}=await Re().rpc(o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_pairing_code':o.IS_GREENSIDE?'claim_greenside_pairing_code':o.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':o.IS_KIRKTON?'claim_kirkton_pairing_code':o.IS_WILDINGS?'claim_wildings_pairing_code':o.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':o.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await x.kv.set(ba,n),xa(),{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}`}}},i.carPairStart=async function(){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await x.kv.set(Ua,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ea(e)}}},i.carPairPoll=async function(e){try{Te();const t=e??await x.kv.get(Ua,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,G.carPairApproved)(n)){const e=(0,G.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await x.kv.get(ba,null);await x.kv.set(ba,e),await x.kv.remove(ka),O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||xa()}return'revoked'!==i&&'unknown'!==i||await Ta(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Te(),await Re().rpc('car_sign_out')}catch{}await Ta(),await Ma();try{await Re().auth.signOut({scope:'local'})}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ka('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ea(e)}}},i.carList=async function(){const e=Oe.getState().venueId;if(!e)return[];return(await Ka('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ka('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ea(e)}}},i.unpairDisplay=async function(){await x.kv.remove(ba),await Ma();try{await Re().auth.signOut()}catch{}Ae({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await x.kv.remove(ka),await x.kv.remove(Ia),await Ma();try{await Re().auth.signOut()}catch{}Ae({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.'})},i.wipeThisDevice=async function(e={}){try{await Ma()}catch{}try{(0,T.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${o.VENUE_RID}:`)):(0,I.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!o.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Na,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ka}}),i.mendSession=qa,i.startAppSync=async function(e=o.VENUE_RID){if(o.IS_ISOLATED_VENUE&&e!==o.VENUE_RID)return;if(Pe)return;Pe=!0,La=e,'customer'===Ue&&'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Te(),'customer'!==Ue){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ue&&(0,h.isAnchorage)(e)?[H.useStore,ne.useOwner,ae.useKitchen,se.useSafety,Y.useCardStore,m.useGpCalc,X.useOrderSheets,S.useSpecials,A.useHr]:[H.useStore,ne.useOwner,ae.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ue&&(0,h.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ae({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await vs(e)}catch{if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e))return void Ae({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,T.isSupabaseConfigured)())return void Ae({mode:'off'});j.mutationQueue.subscribe(()=>{const e=j.mutationQueue.waiting,t=e[0];Ae({pending:j.mutationQueue.pending.length,failed:j.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,L.describeWrite)(t)}: ${(0,L.plainReason)({...t.lastErr},'retry')}`:void 0})}),j.mutationQueue.onFailed(e=>Ae({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:j.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,L.describeWrite)(e),why:'conflict'===e.reason?(0,L.plainReason)({code:'conflict'},'refused'):(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Ke.push((0,N.onConnectivity)(e=>Ae({mode:e?Oe.getState().venueId?'live':Oe.getState().mode:Oe.getState().venueId?'offline':Oe.getState().mode}))),await Ba()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return za}}),i.stockSaveBlocker=Za,i.stockEventStatus=function(e){if(ze(e))return{state:'saved'};const t=j.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,L.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=Ya,i.saveStockEventsNow=Xa,i.bookingSaveBlocker=ts,i.resendUnsavedBookings=ns,i.saveBookingsNow=is,i.waitForBookingSave=function(e,t=12e3){if(!De())return Promise.resolve({state:'local'});const a=ts();if(a)return Promise.resolve({state:'refused',why:a});const s=as()[0]?.venueId??'',n=()=>es.some(t=>j.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=F.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,N.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(j.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(j.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||as().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||as().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=cs,i.tempLogState=function(){const e=ls()[0]?.venueId??'',t=ls().find(e=>'temp_readings'===e.spec.table),a=j.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!j.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values($.useTempSaves.getState().notSaved),i=se.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=fs,i.waitForTempSave=function(e,t,a=1e4){if(!De()||!ls().length)return Promise.resolve({state:'local'});const s=cs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ls()[0]?.venueId??'',i=ls().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>$.useTempSaves.getState().notSaved[(0,$.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>j.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=_s,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ts}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Es.get(a);if('customer'!==Ue||!(0,T.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Es.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ka('public_day',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:qe(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:qe(a.from_time),to:qe(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Es.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ts.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Es.get(a);e&&!e.ok&&Es.delete(a)}));const n=Es.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Oe.getState().venueId;if(!n||'staff'!==Oe.getState().kind)throw new Error('Connect to your venue first.');const i=await Ka('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});H.useStore.getState().updateRestaurant(e,{...i,id:e})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(fe),ge=t(r[60]),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]);const Re=()=>(0,E.getSupabase)();j.mutationQueue.setExecutor(q.executeMutation),(0,P.setClockServer)(()=>'staff'===Oe.getState().kind);const Oe=(0,U.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ae=e=>Oe.setState(e),Ce=e=>{const t=Oe.getState().perms;return t.includes('*')||t.includes(e)},De=()=>{const e=Oe.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Oe.subscribe(()=>(0,ve.setLiveData)(De()));let Ue=V.IS_CAR?'car':V.APP_VARIANT,Ee=!1;const Te=()=>{Ee||((0,x.setSyncNamespace)(Ue),Ee=!0)};let Ne=[],Ke=[],Pe=!1;const Me=()=>(new Date).toISOString().slice(0,10),xe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),qe=e=>e?e.slice(0,5):'',Le=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))):[],Be=e=>JSON.parse(JSON.stringify(e));function je(e,t){const a=xe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>H.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Be(e);if(t)return{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:Le(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,ie.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:Le(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Fe(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>H.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.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,ie.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Be(e.lines??[]),allergies:Le(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:Be(e.allergyChain??{}),readiness:Be(e.readiness??{}),allergy_ticks:Be(e.allergyTicks??{}),handover_check:e.handoverCheck?Be(e.handoverCheck):null,accepted:e.accepted?Be(e.accepted):null,doc:Be(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)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function $e(e){const t=xe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...J.useBlocks.getState().blocks,...J.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Oe.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:Be(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,J.blockClock)(t.from_time)??a?.from,n=(0,J.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>J.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>J.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let We=null,Qe='Main plan';function He(e){const t=e=>Be({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(z.useFloor.getState().plans[e]??(0,z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Ce('floor.manage')||Ce('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:We??(0,be.uuidFrom)(`plan:${a}`),venue_id:a,name:Qe||'Main plan',is_active:!0,...t(e),updated_by:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>(We=String(e.id),Qe=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,ke.withSeedBest)(e,t[0]):void 0;a&&z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ve(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Z.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Ce('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,ie.isUuid)(e.supplierId)?e.supplierId:(0,be.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),ot.get(t)??t)}:{}};var t},apply:(t,a)=>Z.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Ge=new Set,Je=new Set;j.mutationQueue.onDone(e=>{'stock_events'===e.table&&Je.add(e.rowKey)});const ze=e=>Je.has(e)||Ge.has(e),Ze=()=>Ce('*')||Ce('staff.manage')||Ce('recipes.edit')||Ce('recipes.signoff'),Ye=()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write'));function Xe(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Z.useShellStore.getState().events.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,ie.isUuid)(t.id)&&!!(Z.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('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,ie.isUuid)(e.undoes)&&(ze(e.undoes)||j.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Ge.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)=>Z.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function et(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Z.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={...Z.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Z.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Ge]}}}))},afterRead:()=>{Z.useShellStore.getState().server[e]||Z.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Ge]}}}))},subscribe:()=>()=>{}}}const tt=new Set;function at(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=H.useStore.getState().menu;return Y.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:t=>(0,ie.isUuid)(t.card.id)&&!((0,h.isAnchorage)(e)&&(0,h.isDemoCard)(t.card))&&!(0,h.isPlaceholderCard)(t.card),writable:()=>Ce('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,h.isAnchorage)(e)&&(s={...s,signOff:(0,h.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,h.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,h.isAnchorage)(e)&&(0,h.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,be.photoPath)(a,s),t=st(s.photo);t&&((0,Y.cachePhotoAs)(e,t),nt(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,be.cardToRow)(s,a);return{...i,...r,doc:Be({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,h.isPlaceholderCard)(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,signOff:(0,h.isAnchorage)(e)&&(0,h.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Ce('recipes.edit')&&t.length){const e=new Set(t);Y.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);Y.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&H.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&H.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=Y.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=H.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const st=e=>(0,Y.readLocalPhoto)(e);async function nt(e,t){if(!tt.has(e)){tt.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(be.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){tt.delete(e),Ae({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const it=new Map,rt=(0,U.create)(()=>({n:0}));(0,Y.setStoragePhotoResolver)(e=>{const t=it.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,T.isSupabaseConfigured)()&&'off'!==Oe.getState().mode?(t||(it.set(e,{url:'',at:Date.now()}),Re().storage.from(be.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(it.set(e,{url:t.signedUrl,at:Date.now()}),rt.setState(e=>({n:e.n+1})),Y.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const ot=new Map;const dt=(e,t)=>{const a=(0,ie.isUuid)(t)?t:(0,be.uuidFrom)(`sup:${e}:${t}`);return ot.set(a,t),a};function ut(e){return{name:'order_sheets',table:'suppliers',list:()=>X.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,h.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Ce('suppliers.manage'),toRow:(e,t)=>({id:dt(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:Be(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(ot.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>X.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>X.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,ie.isUuid)(e)?e:(0,be.uuidFrom)(`sup:${Oe.getState().venueId}:${e}`)})}}let ct=!1,lt=!1;const ft=new Map,pt=new Map,gt=new Map,mt=new Map,_t=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',St=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'},ht=(e,t)=>({...e,managerAccess:t}),yt=()=>({nickname:ct,display:lt}),wt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=ht({role:e.role,level:e.level??St(_t(e)).level},!0===e.managerAccess);return(0,B.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},yt())};const vt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},bt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},kt=e=>{const t=ne.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,d.isKitchenTeam)(t)},It=2e3;function Rt(e,t){return t||!e.length||e.length>=It?null:e=>(0,ie.isUuid)(e.id)}function Ot(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,Ce('rota.manage')):null,keepOnEmpty:()=>e&&!Ce('rota.manage'),list:()=>ne.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&ft.has(e.staffId)&&(Ce('rota.manage')||kt(e.staffId)),writable:()=>Ce('rota.manage')||Ce('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(vt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:bt(e.start),end_time:bt(e.end),published:!!e.published,doc:Be(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function At(){const e=xe(62),t=e=>Ce('rota.manage')||e.staffId===Oe.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ne.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&t(e),writable:()=>'staff'===Oe.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=xe(2)&&e.staffId===Oe.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Be(e.breaks??[]),break_mins:e.breakMins??0,doc:Be((0,y.privateAttendance)(o.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,y.privateAttendance)(o.VENUE_RID,{...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Ct(){const e=xe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.staffId===Oe.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Oe.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:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,ie.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:Be({...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Dt(e){ne.leaveRemote.decide=t=>!(!Ce('rota.manage')||!(0,ie.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(j.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Ke.push(()=>{ne.leaveRemote.decide=null})}function Ut(e){ne.timesheetRemote.send=(t,a)=>{if(!Ce('rota.manage')||!(0,ie.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return j.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:Be(s)}}),!0}const s=a;if('attendance_void'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return j.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:Be(s.breaks??[]),p_reason:n,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0},Ke.push(()=>{ne.timesheetRemote.send=null})}function Et(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>H.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Oe.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,ie.isUuid)(a)?a:(0,be.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,ie.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Be(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>H.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=>H.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Tt=e=>H.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Nt(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}));H.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Kt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=H.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Be({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Tt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Ce('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Mt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...Mt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Mt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Pt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Pt=t.feature_flags??{},Mt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Be({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}:{}})},apply:t=>{const a=t[0];a&&(H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,l.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Nt(e,a.events))},subscribe:e=>{const t=H.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Pt=null,Mt=null;const xt=()=>new Date(Date.now()-2592e6).toISOString(),qt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ft.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Lt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?(0,Se.dmId)(t[0],t[1]):null},Bt=()=>Oe.getState().perms.includes('*');function jt(){const e=()=>Oe.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ne.useOwner.getState().chat.filter(e=>(0,ie.isUuid)(e.id)).map(e=>Be({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=>!!qt(t.ch)&&(t.from===e()||Bt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('created_at',xt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=xt(),toRow:(e,t)=>{const a=qt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ft.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=Lt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?pt.get(String(e.from_staff)):'system';return s?Be({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ne.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?pt.get(String(t.from_staff)):'system',i=Lt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ne.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,Se.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,he.soundAllowed)())try{(0,he.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,b.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Ft(e,t,a){const s=Oe.getState();if(!_e.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ft.get(e),i='*'===t?'*':qt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function $t(e){const t=Oe.getState().staffRef,a=t?ft.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Lt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ne.useOwner.getState().chatMarkRead(t,i)}catch{}}function Wt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=C.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Be(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>C.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,D.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Qt(e){const t=xe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>C.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.reminderId)&&e.staffRef===Oe.getState().staffRef,writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>C.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Ht(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Vt=e=>null==e||''===e?null:Number(e),Gt=e=>e.filter(e=>!e.startsWith('data:')),Jt=()=>Ce('takings.view');function zt(e){const t=!Jt();return{name:'cash_ups',table:'cash_ups',list:()=>oe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,v.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,v.tradingDay)()&&!e.onServer),writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,v.tradingDay)()):e.gte('for_date',xe(400)),...t?{inWindow:e=>e.date===(0,v.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:Be(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({cashUps:Ht(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Zt(e){return{name:'sales_reports',table:'sales_reports',list:()=>oe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Be(e.vals),categories:e.categories,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({sales:Ht(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Yt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=oe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,oe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Be({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,oe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>oe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function Xt(e){return{name:'day_tips',table:'day_tips',list:()=>oe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',xe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>oe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ea(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>oe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Vt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>oe.useCashUp.setState(s=>({pot:Ht(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function ta(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=oe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Ce('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>oe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function aa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>re.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Be(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>re.useNotifs.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>re.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function sa(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=de.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Be(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>de.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ue.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Ht(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function na(e){const t=()=>Ce('venue.settings')||Ce('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>de.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,ie.isUuid)(a.id)&&(0,ie.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,de.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Oe.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Oe.getState().staffRef)||null,doc:Be(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ia(e){const t=xe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>de.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Be(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({history:Ht(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function ra(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=ce.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Be(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&ce.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,y.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>ce.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function oa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=ge.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,ge.libraryRowId)(e),kind:'library',doc:Be({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,ge.personRowId)(e,i),kind:'person',staffRef:i,doc:Be({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ne.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,me.canEditTasks)(t,a)},writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>ge.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,ge.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function da(e){const t=xe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>ge.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Oe.getState();return e.byRef===t.staffRef||Ce('staff.manage')},writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>ge.useDailyTasks.setState(s=>({ticks:Ht(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ua(e,t=!1){const a=xe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>ye.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind||Ce('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,be.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>ye.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>ye.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{we.autoSync.soldOutRead.add(e)}}}function ca(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>we.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:(0,be.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>we.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>we.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{we.autoSync.linksRead.add(e)}}}async function la(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&x.kv.get(a,!1):(x.kv.set(a,!0),!0)}catch{return x.kv.get(a,!1)}}async function fa(){const e=Oe.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();ma.setState({live:!!t?.push_live,known:!0})}catch{}}const pa='order-list-logos';const ga=new Map;const ma=(0,U.create)(()=>({live:!1,known:!1}));async function _a(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('reminders:ok',!1):(x.kv.set('reminders:ok',!0),!0)}catch{return x.kv.get('reminders:ok',!1)}}async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('chat:ok',!1):(x.kv.set('chat:ok',!0),!0)}catch{return x.kv.get('chat:ok',!1)}}const ha=(e,t)=>Be({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),ya='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function wa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>A.useHr.getState().questions.filter(t=>t.venue===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ha(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);A.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>A.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function va(e,t){const a=(t,a,s)=>{j.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(A.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(ya).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||A.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ha(e,t)))}catch{}}}),Ke.push(()=>{Object.assign(A.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ba='pair:v1',ka='staff:v1',Ia='staff:rejoin:v1';async function Ra(e){const t=o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_invite':o.IS_GREENSIDE?'claim_greenside_invite':o.IS_ABBOTSFORD?'claim_abbotsford_invite':o.IS_KIRKTON?'claim_kirkton_invite':o.IS_WILDINGS?'claim_wildings_invite':o.IS_KIRKMICHAEL?'claim_kirkmichael_invite':o.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ue,p_device:(0,O.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,O.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Oa(){if('display'===Ue||'customer'===Ue||le.PITCH)return'none';const e=await x.kv.get(Ia,null);if(!e)return'none';try{await Ca();const{data:t,error:a}=await Ra(e);if(a)return(0,I.inviteRefusal)(a.message)?(await x.kv.remove(Ia),await x.kv.remove(ka),'refused'):'offline';const s=t?.[0];return s?(await x.kv.set(ka,{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,displayName:s.display_name}),'ok'):(await x.kv.remove(Ia),'refused')}catch{return'offline'}}const Aa=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Ca(){Te();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ae({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 Da(e){if(le.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,I.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Ra(e);if(a){const e=(0,I.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,o.venueKey)(`cc-pending-invite:${Ue}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),await x.kv.set(Ia,e),Pe&&xa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ae({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ua='car:request:v1',Ea=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Ta(){await x.kv.remove(ba),await x.kv.remove(ka),await x.kv.remove(Ua),O.useSession.getState().meId&&O.useSession.getState().signOut()}async function Na(){if(!(0,T.isSupabaseConfigured)())return!1;try{return await Ca(),!0}catch{return!1}}const Ka=async(e,t={})=>{if(le.PITCH)return(0,fe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Pa=null;async function Ma(){for(const e of Ke)try{e()}catch{}Ke=[],Ne.forEach(e=>e.stop()),Ne=[],Pa&&(clearInterval(Pa),Pa=null)}async function xa(){await Ma(),await Ba()}async function qa(){if(!(0,T.isSupabaseConfigured)()||'customer'===Ue||le.PITCH)return!1;try{Te();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ue)return!1;if(!await x.kv.get(Ia,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Oa()&&(xa(),!0)}catch{return!1}}(0,u.setSessionMender)(qa);let La=o.VENUE_RID;async function Ba(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=La;try{if(Ae({mode:'connecting'}),await j.mutationQueue.load(),'customer'===Ue)return void await Ha(e);let t=await x.kv.get(ba,null),a=await x.kv.get(ka,null);if(V.IS_CAR&&!t&&a){const e=(0,G.migrateCarStaffIdentity)(a);e&&(t=e,await x.kv.set(ba,t)),await x.kv.remove(ka),a=null,O.useSession.getState().meId&&O.useSession.getState().signOut()}if(o.IS_ISOLATED_VENUE&&(t&&!(0,o.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,o.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ae({mode:'display'===Ue?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ue&&!V.IS_CAR&&a&&!s.session){const t=await Oa();if('offline'===t)return Ae({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{La===e&&xa()},6e4);'refused'===t&&a.staffRef&&O.useSession.getState().meId===a.staffRef&&O.useSession.getState().signOut(),a=await x.kv.get(ka,null),({data:s}=await Re().auth.getSession())}const n='display'===Ue||V.IS_CAR?t:a;if(!s.session||!n)return void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ka('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ue||V.IS_CAR?await x.kv.remove(ba):(await x.kv.remove(ka),await x.kv.remove(Ia)),'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId===n.staffRef&&O.useSession.getState().signOut(),void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ue?'This display was unpaired by a manager.':V.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,N.isOnline)()||/fetch|network/i.test(String(t?.message)))Ae({mode:'offline'});else if(Aa(t)&&'display'!==Ue){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Oa()&&setTimeout(()=>{La===e&&xa()},500)}i=Oe.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ae({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!V.IS_CAR&&'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId!==n.staffRef&&(O.useSession.getState().signIn(n.staffRef),ne.useOwner.setState({staffAs:n.staffRef})),V.IS_CAR&&(O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({previewRole:'owner'})),await Fa(n.venueId,e,n.kind)}catch(e){Ae({mode:'local',lastError:String(e?.message??e)})}}const ja=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','venue_reminders','reminder_done']);async function Fa(e,a,s){if(!(0,o.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||V.IS_CAR&&'device'===s;await _s(a),Ke.push(Us(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])gt.set(e.key,e.id),mt.set(e.id,e.key)}catch{}const i=[Kt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ne.useOwner.getState().staff.map(wt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Ce('staff.manage'),deletes:!1,revision:e=>(0,B.staffRevision)(e,yt()),toRow:(e,t)=>(0,B.staffRow)(e,t,yt(),e.managerAccess||e.ownerAccess?null:gt.get(_t(e))),fromRow:e=>{if(!e.external_ref)return null;ft.set(String(e.external_ref),String(e.id)),pt.set(String(e.id),String(e.external_ref)),Os.set(String(e.external_ref),e.avatar_path??null);const t=ht(St(mt.get(String(e.role_id))),!0===e.manager_access);return(0,B.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},yt())},apply:e=>ne.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=>ne.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ds()},onRemote:()=>{Ds()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ne.useOwner.getState(),t=te.useSetup.getState().sites[La]?.staffGrade??{};return e.staff.filter(e=>ft.has(e.id)).map(a=>Be({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=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ft.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=pt.get(String(e.staff_id));return t?Be({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=>ne.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=te.useSetup.getState().sites[La],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&&te.useSetup.getState().patch(La,{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=ne.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=te.useSetup.subscribe((t,a)=>{t.sites[La]?.staffGrade!==a.sites[La]?.staffGrade&&e()});return()=>{t(),a()}}},je(a,!1),je(a,!0),$e(a),He(a),Fe(a),Ve(a),Xe(a),et(a),ut(a),{name:'supplier_directory',table:'suppliers',list:()=>ne.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('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:Be(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ne.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId),writable:()=>Ce('suppliers.order')||Ce('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||Me(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Be(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},at(a),ks(a)];Ce('wages.view')&&i.push(Is(a)),n&&(i.push(Ot(!0),At(),Ct(),Et(a)),Ut(e)),n&&await la('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Oe.getState().staffRef&&'pending'===e.status||Ce('rota.manage')),writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Be(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),ja.add('staff_leave'),Dt(e));const d=n&&await Sa();if(_e.useChatSync.setState({synced:d,checked:!0}),Ke.push(()=>_e.useChatSync.setState({synced:!1})),d&&i.push(jt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(Se.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ft.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ft.get(e.id),include:e.include}),fromRow:e=>{const t=pt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>Se.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=>Se.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await la('hr_questions')&&(i.push(wa(a)),ja.add('hr_questions'),va(e,a)),'guest'!==s&&'customer'!==Ue&&await la('temp_readings')&&(i.push((0,W.tempUnitsSpec)(se.useSafety,Ze),(0,W.tempReadingsSpec)(se.useSafety,Ye)),ja.add('temp_units'),ja.add('temp_readings')),'guest'!==s&&await la('sold_out_items')?(i.push(ua(a,await la('sold_out_items','auto'))),ja.add('sold_out_items')):we.autoSync.soldOutRead.add(a),'guest'!==s&&await la('sold_out_links')?(i.push(ca(a)),ja.add('sold_out_links')):we.autoSync.linksRead.add(a),C.useReminders.getState().ensure(a),'guest'!==s&&await _a()&&(i.push(Wt(a)),n&&i.push(Qt(a))),re.useNotifs.getState().ensure(a),de.useOrderLists.getState().ensure(a),n){ct=await la('staff','nickname'),lt=await la('staff','display_clock');const[e,t,s,n]=await Promise.all([la('scheduled_notifications'),la('order_lists'),la('venue_clock_area'),la('daily_tasks')]);ge.useDailyTasks.getState().ensure(a),n&&(i.push(oa(a),da(a)),ja.add('daily_tasks'),ja.add('daily_task_ticks')),e&&(i.push(aa(a)),fa()),t&&i.push(sa(a),na(a),ia(a)),s&&i.push(ra(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&ja.add(n)}if('guest'!==s&&await la('day_tips')){i.push(Xt(a));for(const e of['day_tips','tips_pot_events','tips_settings'])ja.add(e);await la('tips_pot_events')&&i.push(ea(a),ta(a)),n&&(Jt()||(0,oe.forgetPastTakings)(a,(0,v.tradingDay)()),i.push(zt(a),Yt(a)),ja.add('cash_ups'),Jt()&&(i.push(Zt(a)),ja.add('sales_reports')),t(r[72])(r[71],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Ot(),At()),await la('scheduled_notifications')&&i.push(aa(a)));let u=!1;const c=()=>{if(V.IS_CAR&&n&&Ce('recipes.edit'))return!0;const e=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);return!!e&&e.active&&Ce('recipes.edit')&&(0,_.costsAllowedFor)(e)};n&&c()&&await la('ingredient_prices')&&(i.push((0,m.gpSyncSpec)('ing',c)),ja.add('ingredient_prices'),await la('card_costs')&&(i.push((0,m.gpSyncSpec)('card',c)),ja.add('card_costs')),await la('kitchen_deliveries')&&(i.push((0,m.gpSyncSpec)('del',c)),ja.add('kitchen_deliveries')),await la('kitchen_stock_counts')&&(i.push((0,m.gpSyncSpec)('count',c)),ja.add('kitchen_stock_counts'))),(0,Ie.specialsSyncOn)()&&'guest'!==s&&await la('specials_boards')&&(i.push((0,Ie.specialsBoardSpec)(a,()=>Ce('recipes.edit')||Ce('floor.manage')||Ce('*'))),ja.add('specials_boards'));const l={onActivity:()=>Ae({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ae({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ae({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Ka('whoami')??[]).some(t=>t.venue_id===e))return void(La===a&&xa());for(const a of Ne){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||F.useBookingSaves.getState().mark({id:t,table:e,why:ts()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||$.useTempSaves.getState().mark({id:t,table:e,why:cs(e)??'this screen could not send it'})}};Ne=i.map(t=>new Q.EntityBridge(t,e,l)),await Promise.all(Ne.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,N.isOnline)())try{const t=await Ka('whoami');if(!t?.some(t=>t.venue_id===e))return void(La===a&&xa())}catch(e){if(Aa(e)){if(V.IS_CAR)return void(La===a&&xa());const e=await Oa();return void('ok'!==e&&'refused'!==e||La===a&&xa())}}let t=0;for(const[a,s]of Ne.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(_e.useChatSync.getState().error&&_e.useChatSync.setState({error:void 0}),await $t(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&_e.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({mode:'live',lastSyncAt:e,lastServerAt:e}),j.mutationQueue.flush()}else Ae({mode:'offline'});if(!Ce('wages.view')){const e=Oe.getState().staffRef;ne.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const S=new Map;for(const e of Ne)S.set(e.spec.table,[...S.get(e.spec.table)??[],e]);const h=[...S.keys()].filter(e=>ja.has(e)).map(e=>({table:e,venueColumn:S.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,Q.venueChannel)(e,h,(e,t,a)=>{for(const s of S.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ae({lastSyncAt:s,lastServerAt:s})},e=>{Ae({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Ke.push(()=>{Re().removeChannel(w)}),Ke.push((0,N.onConnectivity)(e=>{e&&p()}));const b=Ne.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,K.superviseSync)({fastMs:Wa(Ue),readFast:async()=>{for(const e of b)await e.read()},readAll:p,flush:()=>{j.mutationQueue.flush()},wake:()=>{j.mutationQueue.retryNow()},restart:()=>{La===a&&xa()},realtime:()=>Oe.getState().realtime,lastServerAt:()=>{const e=Oe.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Aa,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>$a(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Ke.push(k.stop)}async function $a(e){const t=Oe.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ka('sync_heartbeat',{p_venue:e,p_device:(0,O.deviceId)()??'unknown',p_app:Ue,p_version:M.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Wa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Oe.getState(),queue:j.mutationQueue.pending.map(e=>e.table),failedTables:j.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),le.PITCH&&(window.__ccSyncPreview=e=>Ae(e)));const Qa='guest:sent:v1';async function Ha(e){Ae({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ka('public_venue',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!o.IS_ISOLATED_VENUE||t.id===o.VENUE_UUID)){Ae({venueId:t.id,venueName:t.name}),await _s(e);const a=t.app?.restaurant;a&&H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,l.withWildingsAddress)({...a,id:e}):t)})),Nt(e,t.app?.events)}await Va(e),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ae({mode:(0,N.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Va(e).catch(()=>{})},6e4);Ke.push(()=>clearInterval(t)),o.IS_ISOLATED_VENUE||await Ga(e)}async function Va(e){const t=await Ka('public_menu',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));Y.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&H.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))]}})}async function Ga(e){let t=await x.kv.get(Qa,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=H.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Na())return;for(const a of n)try{const s=(await Ka('guest_create_booking',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_booking:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(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&&H.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'},Ae({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ka('guest_create_takeaway',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_order:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ae({lastError:`Order: ${e?.message}`}))}await x.kv.set(Qa,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ka('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await x.kv.set(Qa,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ka('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));H.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 Ja(n)===Ja(e)?e:n})})),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ae({mode:(0,N.isOnline)()?Oe.getState().mode:'offline'})}finally{a=!1}}};Ke.push(H.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Pa=setInterval(()=>{n()},15e3),n()}const Ja=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),za={bridges:()=>Ne,restart:xa};function Za(){const e=Oe.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Ce('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function Ya(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(!e||Za())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(j.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function Xa(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}Ya();try{await j.mutationQueue.retryNow()}catch{}}Oe.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{Xa()},3e3)});const es=['bookings','walk_ins'];function ts(){const e=Oe.getState();return De()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const as=()=>Ne.filter(e=>es.includes(e.spec.table)),ss=e=>j.mutationQueue.failed.some(t=>es.includes(t.table)&&t.rowKey===e);function ns(e=!1){return ts()?0:as().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ss(t)&&!!F.useBookingSaves.getState().notSaved[t]),0)}async function is(e=!1){const t=ts();if(t)return t;for(const e of as())try{await e.read()}catch{}ns(e);try{await j.mutationQueue.retryNow()}catch{}return e&&rs(),null}function rs(){const e=as()[0]?.venueId??'',t=F.useBookingSaves.getState(),a=new Set(as().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ss(s)||es.some(t=>j.mutationQueue.hasPending(t,e,s))||t.clear(s)}j.mutationQueue.onFailed(e=>{es.includes(e.table)&&F.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{es.includes(e.table)&&F.useBookingSaves.getState().clear(e.rowKey)});let os=null;const ds=(e=2500)=>{os&&clearTimeout(os),os=setTimeout(()=>{os=null,is(!1)},e)};(0,N.onConnectivity)(e=>{e&&ds()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ds(3e3)});const us=['temp_readings','temp_units'];function cs(e="temp_readings"){const t=Oe.getState();return De()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ze()?'device'!==t.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ls=()=>Ne.filter(e=>us.includes(e.spec.table));async function fs(e=!1){const t=cs();if(t)return t;for(const e of ls())try{await e.read()}catch{}const a=ls()[0]?.venueId??'';for(const t of ls())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,j.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await j.mutationQueue.retryNow()}catch{}if(e){const e=$.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ls().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||j.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,$.tempKey)(t.table,t.id))}}return null}j.mutationQueue.onFailed(e=>{us.includes(e.table)&&$.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{us.includes(e.table)&&$.useTempSaves.getState().clear((0,$.tempKey)(e.table,e.rowKey))});let ps=null;const gs=(e=3e3)=>{ps&&clearTimeout(ps),ps=setTimeout(()=>{ps=null,fs(!1)},e)};(0,N.onConnectivity)(e=>{e&&gs()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&gs(3500)});const ms='golive:v1:';async function _s(e){'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)?await vs(e):(await x.kv.get(ms+e,!1)||await vs(e),await x.kv.get(ys+e,!1)||(ws(e),await x.kv.set(ys+e,!0)),await x.kv.get(Ss+e,!1)||(hs(),await x.kv.set(Ss+e,!0)))}const Ss='golive:v3:';function hs(){const e=e=>JSON.stringify(e).includes('(example)');try{ae.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ys='golive:v2:';function ws(e){const t=e=>JSON.stringify(e).includes('(example)');H.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)))})),ne.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 vs(e){if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)){const t=(0,p.stripCoreLiveSamples)(H.useStore.getState()),a=(0,ae.stripKitchenExamples)(ae.useKitchen.getState()),s=ne.useOwner.getState(),n=(0,p.stripOwnerLiveSamples)(s),i={accidents:se.useSafety.getState().accidents.filter(e=>!(0,se.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(H.useStore.getState(),t)&&(await(0,g.archiveChefCache)('core',H.useStore.getState()),H.useStore.setState(t)),r(ae.useKitchen.getState(),a)&&(await(0,g.archiveChefCache)('kitchen',ae.useKitchen.getState()),ae.useKitchen.setState(a)),r(s,n)&&(await(0,g.archiveChefCache)('owner',s),ne.useOwner.setState(n)),r(se.useSafety.getState(),i)&&(await(0,g.archiveChefCache)('safety',se.useSafety.getState()),se.useSafety.setState(i));const o=(0,A.stripHrSamples)(A.useHr.getState());r(A.useHr.getState(),o)&&(await(0,g.archiveChefCache)('hr',A.useHr.getState()),A.useHr.setState(o));const d=(0,m.stripGpSamples)(m.useGpCalc.getState());r(m.useGpCalc.getState(),d)&&(await(0,g.archiveChefCache)('gp',m.useGpCalc.getState()),m.useGpCalc.setState(d));const u=X.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,g.archiveChefCache)('order-sheets',u),X.useOrderSheets.setState(c));const l=Y.useCardStore.getState(),_={cards:l.cards.filter(e=>!(0,f.isLiveVenue)(e.restaurantId)||!(0,h.isDemoCard)(e)),log:l.log.filter(e=>!(0,h.demoActor)(e.by))};return r(l,_)&&(await(0,g.archiveChefCache)('recipe-cards',l),Y.useCardStore.setState(_)),void await x.kv.set(ms+e,!0)}const t=t=>t.restaurantId===e&&!(0,ie.isUuid)(t.id);H.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)))})),J.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,ie.isUuid)(t.id))})),z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ne.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,ie.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,ie.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,ie.isUuid)(e.id)),leave:e.leave.filter(e=>(0,ie.isUuid)(e.id)),swaps:[]}));try{ae.useKitchen.setState(e=>(0,ae.stripKitchenExamples)(e))}catch{}ne.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,ie.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId))}));try{se.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await x.kv.set(ms+e,!0)}const bs=(e,t)=>Be({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function ks(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(z.useFloor.getState().live[e]??{}).map(([e,t])=>bs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Oe.getState().kind||Ce('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:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>bs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>z.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=>z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Is(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(te.useSetup.getState().sites[e]?.grades??te.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:()=>Ce('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=te.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));te.useSetup.getState().patch(e,{grades:i})},subscribe:t=>te.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Rs='staff-avatars',Os=new Map;let As=!1;const Cs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ds(){if(!As){As=!0;try{for(const[e,t]of Os){const a=ee.useAvatars.getState().photos[e];if(!t){a?.path&&ee.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Oe.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Rs).download(t);if(n||!s)continue;const i=await Cs(s);i.startsWith('data:image/')&&ee.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{As=!1}}}function Us(e){const t=async()=>{const t=Oe.getState().staffRef,a=t?ft.get(t)??Oe.getState().staffUuid:void 0;if(!t||!a||'staff'!==Oe.getState().kind)return;const s=ee.useAvatars.getState().photos[t];try{const n=Os.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Rs).remove([t]).catch(()=>{})};if(!s){const e=!!ee.useAvatars.getState().clears?.[t];return e&&n&&(await Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}),Os.set(t,null),i(n)),void(e&&ee.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ae({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Rs).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ka('set_staff_avatar',{p_staff_ref:t,p_path:d}),Os.set(t,d),n!==d&&i(n),ee.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ae({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ee.useAvatars.getState().photos},s=ee.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Ce('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Oe.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Os.set(t,null),ee.useAvatars.getState().doneClear(t),Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Rs).remove([e])).catch(()=>{})}});return t(),s}const Es=new Map,Ts=(0,U.create)(()=>({n:0}))},987,[5,988,932,6,832,837,833,838,989,993,994,835,996,998,999,1000,1001,1002,13,1003,1005,1008,1009,846,933,976,1010,1011,1012,1015,977,1016,1014,1019,1013,1020,1021,1022,1023,831,872,1024,1025,1028,983,883,1030,926,927,1032,1033,891,870,1035,1038,1039,1040,1041,2,1042,1043,1044,1045,1046,1047,979,981,884,863,859,1048,1051,1052]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},989,[837,34,838,5,839,846,849,990,863,870,991,992]); -__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},990,[984]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},991,[990]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},992,[990,991]); -__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},993,[]); -__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},994,[835,837,838,5,839,846,849,995,831,884]); -__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'}}]},995,[]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},996,[6,997]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},997,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},998,[846]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},999,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1000,[846]); -__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1001,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1002,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1003,[839,846,849,5,872,1004,15,1002]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1004,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1005,[838,835,837,5,839,846,849,1006,870]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1007,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1008,[839,846,849,863,1009,870]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1009,[]); -__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)))},1010,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1011,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1012,[34,1013]); -__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1013,[1010,977,1014]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1014,[1010]); -__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.3.12.171'},1015,[]); -__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1016,[1017,1018,933,977,1013]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1018,[977]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1019,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1020,[846,849,839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1021,[846,849,839]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1022,[1023]); -__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1023,[1017,933,1010,977,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1024,[]); -__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1025,[860,839,870,846,849,858,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1026,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1027,[891,1003,1026]); -__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1028,[5,860,839,1029,846,849,859]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1029,[1007]); -__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1030,[837,838,5,839,846,849,1031]); -__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1031,[984]); -__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1032,[837,984,838,835,5,839,846,849]); -__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1033,[837,838,5,839,846,849,1034]); -__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1034,[]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1035,[839,846,849,863,1036,15,870,1037]); -__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1036,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1037,[]); -__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1038,[34,839,846,849,863,13,870]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1039,[839,846,849,863,1040,870,1037]); -__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1040,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1041,[5,996,839,846,849,997]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1042,[1038]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1043,[839,846,849,863,1044,870]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1044,[]); -__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},1045,[846]); -__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(':')}`},1046,[839,846,849]); -__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{}}},1047,[236,872]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1048,[994,1049,1050,976,933]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1049,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1050,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1051,[933,987,998]); -__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1052,[1053]); -__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1053,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1054,[34]); -__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1055,[34,236,402,102,846,821,794,1054,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1056,[34,102,794,1057,821,1058,25]); -__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1057,[827,34,379,236,402,102,821,987,1058,2,872,1015,5,796,797,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1058,[1059,933,987,872,236]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1059,[]); -__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1060,[827,796,34,402,102,794,821,1043,1044,1009,1000,870,891,25]); -__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1061,[828,1062,796,827,34,281,283,364,336,402,102,426,794,821,1038,831,13,1063,1064,1000,1074,1079,1080,1083,1084,1085,1092,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1062,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1063,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1064,[34,876,1065,1066,1063]); -__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1065,[839,846,849]); -__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1066,[6,1067,1068,1069,1070,1071,1072,1073,3]); -__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1067,[]); -__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1068,[]); -__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1069,[]); -__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1070,[]); -__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1071,[]); -__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1072,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1073,[1063]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1074,[236,933,987,1075]); -__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})},1075,[499,1076,1078,1077]); -__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1076,[499,1077,1078]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1077,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1078,[1077]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1079,[933,987]); -__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1080,[34,281,236,102,794,1038,13,1081,821,1082,25]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1081,[13]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1082,[]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1083,[827,2,34,102,794,821,1038,891,13,987,1000,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1084,[13]); -__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1085,[34,1062,281,402,102,794,1086,1087,1091,1092,821,25]); -__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1086,[34,402,102,794,821,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1087,[837,34,874,891,858,872,1024,987,1088,1003,15,1090]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1088,[1089]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1089,[1090]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1090,[858]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1091,[34,872,1092,858,987,933]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1092,[]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1093,[34,1094,891,1008,1009,1000,1046,831,1097]); -__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1094,[996,1041,891,997,1095,1096]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1095,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1096,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1097,[]); -__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1098,[34,986,402,102,1099,794,874,1100,858,1101,821,25]); -__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)'}})]})}},1099,[34,281,283,364,102,1047,821,25]); -__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1100,[861,859]); -__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1101,[34,402,102,794,1100,858,821,25]); -__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1102,[34,102,794,874,877,821,25]); -__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1103,[860,34,102,794,874,1025,1028,1104,1105,877,821,25]); -__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1104,[1028,859,1100]); -__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1105,[860,877]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1106,[860,34,102,794,874,983,891,1100,858,821,25]); -__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1107,[828,827,1055,34,336,379,236,402,102,794,821,1039,1040,1000,1108,1109,987,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1108,[1075,236]); -__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1109,[839,846,849]); -__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1110,[827,996,34,379,402,102,794,821,1035,1036,891,1039,1040,1041,997,1095,987,1058,1000,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1111,[34,1035,891,1039,1112,1008,831,1036,1000,1093]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1112,[846]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1113,[996,34,1041,891,831,997,1009,1095,1000,1094]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1114,[860,34,1000,874,1100,1047]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1115,[860,1116,34,102,794,874,1100,821,1117,1106,1118,1139,1142,1098,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1116,[34,102,14,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1117,[821]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1118,[34,102,1119,821,1120,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1119,[860,1104]); -__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1120,[1121,860,34,1122,987,1124,402,102,874,1028,1119,1123,821,858,794,1125,1025,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1121,[34,859,821,794,25]); -__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1122,[34,402,102,874,1123,1124,987,1020,821,1120,794,25]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1123,[860,1104]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1124,[281,236]); -__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1125,[827,1126,1127,860,867,14,1128,1129,34,859,402,102,872,1087,874,1130,1104,858,821,864,794,1028,1025,1131,1132,1137,1106,1100,1138,1123,1122,25]); -__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1126,[34,402,412,102,1127,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1127,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1128,[34,102,794,25]); -__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1129,[34,236,402,295,102,426,821,794,1000,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1130,[878,858,877]); -__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1131,[34,402,102,878,858,821,794,25]); -__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1132,[860,877,34,102,879,1133,1134,1136,794,874,1028,983,861,867,872,1100,821,25]); -__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1133,[34,402,821,794,25]); -__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1134,[828,860,1135,34,281,236,102,1028,1104,821,794,1106,859,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1136,[34,402,102,874,861,863,821,794,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1137,[1127,1119,1123]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1138,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1139,[1140,34,102,874,1028,1123,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1140,[34,102,874,1028,1119,1141,1123,821,1003,891,872,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1141,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1142,[34,1062,1126,102,874,1028,1025,876,872,1137,861,1003,891,1026,1119,821,858,1131,1116,1128,1143,14,1140,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1143,[34,102,874,872,1137,14,1124,821,794,25]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1144,[34,102,794,1062,1092,1145,1091,1085,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1145,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1146,[34,102,794,827,1033,891,835,1147,821,1148,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1147,[1034]); -__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1148,[34,402,102,1124,987,1149,1021,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1149,[933,976,1010,1018,1013,1016,1150,1151,1152,1153,1154,1155,977]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1150,[1018,933,1016]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1151,[1018,933,976,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1152,[1010,976,1151,1013,1016,1150]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1153,[933,977]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1154,[34,1013]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1155,[933]); -__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1156,[30,34,426,102,846,872,1087,1157,25]); -__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1157,[839,846,849]); -__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()},1158,[1159]); -__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1159,[1160,858,884]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1160,[1161,877,1162,878,858,884,1163]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1161,[858]); -__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'},1162,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1163,[858]); -__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1164,[978,34,835,402,102,874,891,1165,1160,794,821,1087,1158,1032,15,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1165,[34,102,794,874,1038,884,1166,831,13,1163,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1166,[34,884]); -__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1167,[34,402,102,794,867,821,1159,1158,1164,1032,25]); -__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1168,[34,402,102,794,874,1160,858,821,1169,1165,1164,25]); -__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1169,[828,34,283,364,236,102,426,797,794,827,821,1170,25]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1170,[]); -__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1171,[827,984,1172,835,860,1173,1174,34,402,295,102,794,874,882,1175,891,993,861,867,1178,858,821,1179,1112,1087,1159,1158,1180,869,1164,1032,925,1181,1003,987,1184,988,1097,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1172,[1158,984]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1173,[827,34,102,794,874,979,891,980,981,982,831,821,25]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1174,[]); -__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1175,[827,796,34,336,402,102,821,794,874,1176,1055,882,861,863,885,1108,1177,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1176,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1177,[]); -__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])},1178,[858]); -__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1179,[928,828,827,837,5,34,1055,336,402,102,794,891,858,821,1087,1024,925,1046,1045,987,1112,1097,25]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1180,[828,34,102,794,876,831,869,821,925,25]); -__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1181,[928,828,34,395,236,402,102,925,794,926,891,1182,927,831,5,1183,987,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1182,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1183,[933,976,987,977]); -__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1184,[34,402,102,794,891,988,1097,993,987,1090,858,1124,821,25]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1185,[1172,984,34,379,102,794,891,993,867,821,1087,1164,1032,1186,25]); -__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1186,[827,835,984,34,379,236,402,102,794,1030,983,985,867,1031,821,1164,25]); -__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1187,[984,872,34,986,1188,336,402,102,1189,794,985,983,1030,821,874,1100,858,1124,987,25]); -__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1188,[5,822,823,828,236,826]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1189,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1190,[827,1030,1172,984,34,402,102,794,891,867,821,1164,1032,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1191,[]); -__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1192,[827,1193,34,402,102,426,794,891,867,858,821,1194,1087,1064,25]); -__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:d,accent:u,children:a,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:d?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:u??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:u??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,a]});return d?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:d,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const d=e.key===n,u=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.note??String(u)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:d?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(u?2:0,e.a/t*c),backgroundColor:d?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,d=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',u=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,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1194,[34,402,102,794,821,5,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1195,[860,1101,1098,1116,34,102,846,794,874,1100,878,877,858,821,1106,1196,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1196,[34,794,874,1197,25]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1197,[379]); -__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1198,[827,1062,1193,34,1199,236,402,426,102,1201,1202,1203,794,831,891,867,1063,821,930,1211,1194,1087,1064,1204,872,1205,1209,25]); -__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1199,[34,402,102,1200,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1200,[34,797,25]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1201,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1202,[34,102,794,827,891,867,1201,821,25]); -__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1203,[827,1201,34,402,102,794,925,891,1097,858,821,1194,1087,1204,872,1205,1206,1208,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1204,[1062,1084,1092]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1205,[34,102,794,891,1038,1062,1092,1086,1204,821,872,1203,1085,1087,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1206,[1063,1207]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1207,[1063,1201]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1208,[34,102,794,827,1062,1063,1206,1124,821,1209,25]); -__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1209,[1062,34,402,102,794,827,891,1207,1063,1210,1124,821,1198,1087,1201,1206,1064,25]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1210,[]); -__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1211,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1179,1194,1087,1064,1159,987,1038,1061,13,1084,1063,2,25]); -__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1212,[828,891,1213,1193,1005,1006,34,1012,1013,236,402,295,102,794,874,1097,1203,1181,1214,1089,5,1215,1160,867,858,821,1194,1179,1087,925,1041,996,997,1094,1000,1096,1165,1163,1206,1208,1090,25]); -__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1213,[827,34,402,102,794,821,891,831,876,1005,1006,25]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1214,[34,102,794,891,1089,821,1097,25]); -__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1215,[34,402,102,794,891,858,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1216,[34,102,794,891,821,1087,1090,1214,1097,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1217,[34,102,1087,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1218,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1219,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1220,[]); -__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1221,[860,1057,34,236,402,102,797,874,821,794,1222,1129,1223,25]); -__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1222,[860,34,380,236,402,102,36,821,794,796,1129,874,25,277]); -__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1223,[1224,1225,1227,1226,1228,1047,1229]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1224,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1225,[839,5,846,849,872,1047,1226]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1226,[860,236,872,1224]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1227,[34,874,861,869,867,1225,1224]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1228,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1229,[34,1225,987,933]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1230,[34,402,102,426,874,861,821,794,1221,1129,1231,25]); -__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1231,[34,102,426,874,861,1223,1047,821,794,1129,25]); -__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1232,[34,236,402,102,879,794,821,1000,1233,1234,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1233,[872,6,933,976,1000,1223,1234]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1234,[839,1235,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1235,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1236,[34,872,1233]); -__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1237,[827,796,1238,835,984,34,931,1199,395,236,402,295,102,846,794,861,1034,867,882,1033,821,1164,1158,1185,932,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1238,[34,1033,891,835]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1239,[34,402,346,102,426,821,1200,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1240,[30,34,792,872,25]); -__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1241,[860,1126,877,30,34,1242,1001,102,14,1128,1137,794,861,867,1130,858,874,987,821,1197,864,1025,1028,1104,1132,1100,1243,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1242,[827,34,236,102,25]); -__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1243,[34,402,102,878,858,1062,1244,821,794,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1244,[1062]); -__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:"ok",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"})]})]})}},1245,[30,34,336,102,1246,1248,794,861,867,874,882,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1246,[34,1247,102,861,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1247,[2,987]); -__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])},1248,[30,34,402,874,821,794,25]); -__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1249,[30,34,794,1250,874,1232,25]); -__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])},1250,[34,402,821,794,25]); -__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1251,[837,30,34,1252,794,867,874,821,1253,1257,25]); -__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:x=!0,onPaid:f,title:g="Pay"}){const y=(0,o.useGiftCards)(b).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),_=y.find(e=>e.code===m),v=_?Math.min(_.balance,p):0,R=p-v;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:g,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),x&&y.length>0?(0,h.jsxs)(l.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:!m,onPress:()=>w(void 0)}),y.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,h.jsxs)(l.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)})]}),v?(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.ok,children:["\u2212",(0,n.gbp)(v)]})]}):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)})]})]}),T?(0,h.jsx)(t.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),f({giftCardCode:m,giftApplied:v,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1252,[34,385,102,874,867,821,794,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1253,[34,102,794,867,1254,1255,1256,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1254,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1255,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1256,[933,987,1255]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1257,[846,933,976,987,2,1254]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),r=e(_r(_d[4])),o=e(_r(_d[5])),i=e(_r(_d[6])),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),b=e(c);_r(_d[10]);var h=e(_r(_d[11])),f=e(_r(_d[12])),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),S=_r(_d[20]),T=_r(_d[21]),I=_r(_d[22]),O=_r(_d[23]),R=_r(_d[24]),A=_r(_d[25]),B=_r(_d[26]),P=_r(_d[27]),C=_r(_d[28]),_=_r(_d[29]),v=_r(_d[30]),N=_r(_d[31]);const $=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let E=!1,M=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,u.useLocalSearchParams)(),d=(0,w.useRestaurant)(e),c=s.IS_QUEUED_VENUE?(0,N.jsx)(t.default,{}):s.IS_ABBOTSFORD?(0,N.jsx)(o.default,{}):s.IS_KIRKTON?(0,N.jsx)(i.default,{}):s.IS_GREENSIDE?(0,N.jsx)(r.default,{}):l.IsolatedCustomerHome&&(s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS)?(0,N.jsx)(l.IsolatedCustomerHome,{}):(0,N.jsx)(K,{});return s.IS_ABBOTSFORD||s.IS_KIRKTON||s.IS_WILDINGS||!d?.settings.hotel?.enabled?c:(0,N.jsx)(n.HotelRequestGate,{rid:e,hotel:d.settings.hotel,children:c})}function K(){const{rid:e}=(0,u.useLocalSearchParams)(),t=(0,w.useRestaurant)(e),l=(0,w.useMenu)(e),s=(0,w.useCustomer)(),n=(0,w.useBasket)(),r=(0,w.useStore)(e=>e.startBasket),o=(0,w.useNow)(3e4),[i,H]=(0,c.useState)('All'),[K,W]=(0,c.useState)(null),[G,F]=(0,c.useState)(!1),[U,Q]=(0,c.useState)(!1),[V,Y]=(0,c.useState)('takeaway'===$?'takeaway':'main');b.default.useEffect(()=>{$&&!E&&(E=!0,'book'===$?setTimeout(()=>u.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,w.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,v.guestServer)();b.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>u.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),b.default.useEffect(()=>{C.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>u.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,w.useOrderAtTable)(e);if(b.default.useEffect(()=>{te||n.restaurantId!==e||'table'!==n.mode||w.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,n.mode,n.restaurantId,e]),!t)return(0,N.jsx)(x.Screen,{title:"Not found",children:(0,N.jsx)(x.T,{children:"Restaurant not found."})});const le=te&&n.restaurantId===t.id&&'table'===n.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ae=e=>!(e.soldOut||!e.signOff||null===e.price),ne=l.filter(e=>('All'===i||e.section===i)&&('takeaway'!==V||ae(e))),re=(0,k.hoursFor)(t,o),oe=e=>()=>u.router.push(`/customer/${t.id}${e}`),ie=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),le&&r(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>Q(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:oe('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:oe('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:oe('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:oe('/refer')},{icon:'gift',label:'Gift cards',on:oe('/gift')},{icon:'alert',label:'My allergens',sub:s.allergies.length?`${s.allergies.length} declared`:'None declared',on:()=>u.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:s.marketingOptIn[t.id]?'Opted in':'Opt in',on:oe('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:oe('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:oe('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:oe('/feedback')},{icon:'hanger',label:'Lost property',on:oe('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:oe('/merch')}];return(0,N.jsxs)(x.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,N.jsxs)(x.Row,{children:[(0,N.jsx)(m.BasketButton,{}),(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>u.router.push('/customer/profile')})]}),children:[t.fictional?(0,N.jsx)(x.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,le?(0,N.jsx)(x.Banner,{kind:"success",title:`Ordering at ${(0,d.tableNumbers)(n.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,N.jsx)(x.Card,{children:(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(f.default,{style:{flex:1},children:[(0,N.jsx)(x.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,N.jsxs)(x.Muted,{children:[re?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,N.jsx)(x.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,N.jsx)(x.Row,{wrap:!0,gap:8,children:ie.slice(2,7).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,N.jsx)(f.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ie.map(e=>(0,N.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),le?(0,N.jsx)(x.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,N.jsx)(x.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,N.jsx)(x.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,N.jsx)(x.ExampleAllergenNotice,{}),(0,N.jsxs)(x.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,N.jsx)(f.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,N.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,N.jsx)(x.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,N.jsx)(f.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,N.jsx)(A.SpecialsTab,{rid:t.id,declared:s.allergies,now:o}):null,'takeaway'===V?(0,N.jsx)(x.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==V?(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,N.jsx)(x.Chip,{label:"All",selected:'All'===i,onPress:()=>H('All')}),se.map(e=>(0,N.jsx)(x.Chip,{label:e,selected:i===e,onPress:()=>H(e)},e))]}):null,'specials'!==V?se.filter(e=>('All'===i||e===i)&&ne.some(t=>t.section===e)).map(e=>(0,N.jsxs)(f.default,{style:{gap:10},children:[(0,N.jsx)(x.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),ne.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,s.allergies),o=e.soldOut||!e.signOff||null===e.price;return(0,N.jsxs)(x.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,N.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)},children:[(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,N.jsx)(x.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,N.jsx)(x.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,j.gbp)(e.price)})]}),(0,N.jsx)(x.Muted,{numberOfLines:2,children:e.description})]}),(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,N.jsx)(x.Badge,{kind:"ok",label:e},e)),e.special?(0,N.jsx)(x.Badge,{kind:"gold",label:"Special"}):null,e.soldOut?(0,N.jsx)(x.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,N.jsx)(x.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,N.jsx)(x.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,N.jsx)(x.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,N.jsx)(p.AllergenChips,{map:e.allergens,declared:s.allergies}),K===e.id?(0,N.jsx)(p.AllergenPanel,{item:e,map:e.allergens,declared:s.allergies}):null,(0,N.jsxs)(x.Row,{gap:8,children:[(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,N.jsx)(f.default,{style:{flex:1}}),(0,N.jsx)(x.Button,{small:!0,label:o?e.soldOut?'Sold out':'Not available online':'Choose',disabled:o,onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,N.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,N.jsx)(x.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,N.jsx)(x.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,N.jsx)(T.LauncherLine,{}),te?(0,N.jsxs)(x.Sheet,{visible:U,onClose:()=>Q(!1),title:"Order at your table",children:[(0,N.jsx)(x.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,N.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:`${(0,d.tableNumbers)(e)}`,onPress:()=>{Q(!1),r(t.id,'table',e)}},e))}),(0,N.jsx)(x.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1258,[1259,1268,5,1269,1270,1271,1274,860,30,34,236,402,102,1246,1248,794,861,867,878,874,821,1275,1232,872,891,1276,994,995,1003,1278,1257,25]); -__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1259,[34,379,794,873,1260,1261,1267,874,5,6,25]); -__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1260,[34,379,102,794,996,997,1095,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1261,[6,34,933,794,1262,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1262,[6,1062,1263,1264,1265,34,102,827,794,821,11,1266,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1264,[4,11]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1265,[11]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1266,[6,933]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1267,[34,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1268,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1269,[34,102,794,1262,25]); -__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1270,[34,379,933,794,873,1260,1262,4,25]); -__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1271,[34,379,794,1260,873,1261,8,1272,25]); -__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1272,[34,102,794,1273,25]); -__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1273,[]); -__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1274,[34,794,873,1260,1261,874,9,25]); -__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1275,[34,402,102,426,794,821,1200,25]); -__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1276,[828,34,336,395,402,295,102,1246,794,994,861,995,858,821,1048,25,1277]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1277,[]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1278,[34,102,1279,794,874,1003,1254,1257,821,25]); -__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1279,[34,102,1280,821,25]); -__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1280,[1281]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1281,[34,797,1282,1311,1312,25]); -__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1282,[1283]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1283,[1284,1285,1308,1310]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1284,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1285,[1286,1287,1288,1289,1290,1291,1292,1293,1294,1297,1301,1298,1302]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1286,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1287,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1288,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1289,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1294,[1295]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1298,[1299,1300]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1299,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1300,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1303,[1298]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1304,[1298]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1306,[1298,1286]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1307,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1308,[1309]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1310,[1309]); -__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1311,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1312,[34,797,1313,25]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1313,[]); -__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1314,[30,34,794,874,891,25]); -__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1315,[837,30,34,102,1279,794,867,874,821,1278,1257,25]); -__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1316,[837,30,34,102,1252,794,874,891,867,858,821,1253,1257,25]); -__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1317,[837,30,34,794,874,891,858,821,1278,1257,25]); -__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1318,[837,30,34,794,874,891,821,1278,1257,25]); -__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1319,[30,34,794,858,1160,1320,874,821,25]); -__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}},1320,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1321,[30,1100,34,402,102,794,858,874,821,25]); -__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 l=_r(d[0]),t=_r(d[1]),n=_r(d[2]),s=e(n),a=_r(d[3]),o=_r(d[4]),r=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),p=_r(d[15]),k=_r(d[16]);function f(){const e=(0,y.useBasket)(),f=(0,y.useRestaurant)(e.restaurantId??void 0),w=(0,y.useAllMenu)(e.restaurantId??void 0),v=(0,y.useCustomer)(),C=(0,y.useOrders)(f?.id),S=(0,y.useStore)(e=>e.setLineQty),T=(0,y.useStore)(e=>e.overrideLine),B=(0,y.useStore)(e=>e.startBasket),P=(0,y.useNow)(15e3),[$,O]=(0,n.useState)(null),[I,M]=(0,n.useState)(!1),[N,F]=(0,n.useState)(''),[L]=(0,n.useState)(()=>(0,o.startForm)()),[R,z]=(0,n.useState)(''),[A,D]=(0,n.useState)(v.phone??''),[E,Y]=(0,n.useState)(v.email??''),[_,q]=(0,n.useState)(!1),H=(0,y.useOrderAtTable)(e.restaurantId??void 0);s.default.useEffect(()=>{H||'table'!==e.mode||y.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[H,e.mode]);const[G,K]=(0,n.useState)(null),[Q,J]=(0,n.useState)(!1),U=(0,n.useMemo)(()=>(0,j.linesFromBasket)(e,w,v.allergies),[e,w,v.allergies]);if(!f||!e.lines.length)return(0,k.jsxs)(u.Screen,{title:"Your basket",children:[(0,k.jsx)(u.Muted,{children:"Your basket is empty."}),(0,k.jsx)(u.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const V=H&&'table'===e.mode,W=(0,m.takeawaySlots)(f,C,P),X=U.reduce((e,l)=>e+l.unitPrice*l.qty,0),Z=U.some(e=>e.contains.length&&!e.overridden),ee=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff}),le=!V&&!$,te=!V&&f.settings.takeawayPaused,ne=(0,p.ukPhone)(A),se=!Z&&!ee.length&&I&&!le&&!te&&(V||ne.ok&&(0,p.emailOk)(E)),ae=async e=>{const l=await y.repo.orders.placeFromBasket({slotTime:V?void 0:$,tip:0,giftCardCode:e?.giftCardCode,notes:N,paidNow:!V,phone:V?void 0:ne.pretty,email:V?void 0:E.trim()||void 0});(0,o.rememberGuard)(l.id,(0,o.guardFor)({...L,hp:R})),q(!1),t.router.replace(`/customer/order/${l.id}`)},oe=e.lines.find(e=>e.key===G),re=oe?U[e.lines.indexOf(oe)]:void 0;return(0,k.jsxs)(u.Screen,{title:"Your basket",subtitle:`${f.name} \xb7 ${V?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,k.jsxs)(r.default,{style:{gap:8},children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.T,{weight:"semibold",children:"Subtotal"}),(0,k.jsx)(u.T,{weight:"bold",size:20,colour:x.colours.gold,children:(0,h.gbp)(X)})]}),Z?(0,k.jsx)(u.T,{size:14,colour:x.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):I?le&&!te?(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Choose a collection time."}):null:(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Confirm your allergies to continue."}),V?(0,k.jsx)(u.Button,{label:"Send order to the kitchen",disabled:!se,onPress:()=>ae(),testID:"send-table-order"}):(0,k.jsx)(u.Button,{label:`Continue to payment \xb7 ${(0,h.gbp)(X)}`,disabled:!se,onPress:()=>q(!0),testID:"checkout"})]}),children:[(V||e.tableNo,null),V?(0,k.jsx)(u.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,f.fictional?null:(0,k.jsx)(u.ExampleAllergenNotice,{}),U.map((l,t)=>{const n=e.lines[t],s=l.contains.length&&!l.overridden;return(0,k.jsxs)(u.Card,{highlight:l.contains.length?x.colours.red:l.may.length?x.colours.amber:void 0,children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(r.default,{style:{flex:1,paddingRight:8},children:[(0,k.jsx)(u.T,{weight:"semibold",children:l.name}),l.choices.length?(0,k.jsx)(u.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,k.jsxs)(u.Muted,{children:["Note: ",l.notes]}):null]}),(0,k.jsx)(u.T,{weight:"semibold",children:(0,h.gbp)(l.unitPrice*l.qty)})]}),s?(0,k.jsxs)(u.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:[(0,k.jsx)(u.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${v.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} (${(0,c.severityLabel)(e.severity)})`).join(', ')}.`}),(0,k.jsxs)(u.Row,{gap:8,style:{marginTop:6},children:[(0,k.jsx)(u.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{J(!1),K(n.key)}})]})]}):l.contains.length?(0,k.jsx)(u.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,k.jsx)(u.Banner,{kind:"warn",title:`May contain ${l.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ee.includes(n)?(0,k.jsx)(u.Badge,{kind:"amber",label:"No longer available online \u2014 please remove"}):null,(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Stepper,{value:n.qty,onChange:e=>S(n.key,e),min:1,label:l.name})]})]},n.key)}),(0,k.jsx)(u.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${f.id}`)}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsxs)(u.H2,{children:["Collection time \u2014 ",(0,b.niceDate)(P)]}),te?(0,k.jsx)(u.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===W.length?(0,k.jsx)(u.Banner,{kind:"warn",children:"No collection slots left today."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u.Muted,{children:["15-minute slots, max ",f.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:W.slice(0,16).map(e=>(0,k.jsx)(u.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>O(e.time.toISOString())},e.label))})]})]}),(0,k.jsxs)(u.Card,{highlight:I?void 0:x.colours.amber,children:[(0,k.jsx)(u.H2,{children:"Confirm allergies for this order"}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:v.allergies.length?v.allergies.map(e=>(0,k.jsx)(u.Badge,{kind:"red",label:`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`},e.allergen)):(0,k.jsx)(u.Muted,{children:"No allergies declared on your profile."})}),(0,k.jsx)(u.Toggle,{label:v.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:I,onChange:M}),(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsx)(u.H2,{children:"Your details"}),(0,k.jsx)(u.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:A,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!ne.ok&&A?(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:ne.error}):null,(0,k.jsx)(u.Field,{label:"Email (optional)",value:E,onChangeText:Y,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,p.emailOk)(E)?null:(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,k.jsx)(u.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,k.jsx)(u.Field,{label:"Order notes (optional)",value:N,onChangeText:F,placeholder:"e.g. cutlery please"}),V?(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>B(f.id,'takeaway')}):null,(0,k.jsx)(i.MockPay,{visible:_,onClose:()=>q(!1),amount:X,restaurantId:f.id,onPaid:e=>ae({giftCardCode:e.giftCardCode}),title:"Pay for your takeaway"}),(0,k.jsxs)(u.Sheet,{visible:!!oe,onClose:()=>K(null),title:"Allergy override",children:[re?(0,k.jsx)(u.Banner,{kind:"danger",title:`${re.name} contains ${re.contains.map(c.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,k.jsx)(u.Toggle,{label:"I understand and want to add it anyway",value:Q,onChange:J}),(0,k.jsx)(u.Button,{kind:"danger",disabled:!Q,label:"Confirm override",onPress:()=>{oe&&re&&T(oe.key,re.contains),K(null)}})]}),(0,k.jsx)(a.Honeypot,{value:R,onChange:z})]})}},1322,[860,30,34,1242,1001,102,1252,794,861,867,1130,858,874,831,821,864,25]); -__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1323,[30,34,102,1248,794,861,878,874,821,1275,5,25]); -__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 f}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},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]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,s.useLocalSearchParams)(),r=(0,b.useOrder)(e),f=(0,b.useRestaurant)(r?.restaurantId),[C,S]=(0,l.useState)(0),[k,T]=(0,l.useState)(''),[v,P]=(0,l.useState)(!1),[M,$]=(0,l.useState)(!1),[R,A]=(0,l.useState)(1),[I,N]=(0,l.useState)(0),[O,B]=(0,l.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(c.Screen,{title:"Order",children:(0,j.jsx)(c.T,{children:"Order not found."})});const H='takeaway'===r.type?x:w,_=Math.max(0,H.findIndex(([e])=>e===r.status)),D=Math.round(r.subtotal*I/100),F='table'===r.type?r.subtotal+(r.split?r.tip:D):r.total,q=F-r.paid,L=r.split?.ways??O,W=r.split?.paidShares??0,Y=Math.ceil(F/L),E='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(c.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,p.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(c.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Status"}),H.map(([e,t],s)=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=_?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(c.T,{weight:s===_?'semibold':'regular',colour:s<=_?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(c.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,p.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(c.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||E?null:(0,j.jsxs)(c.Row,{gap:8,children:[(0,j.jsx)(c.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>b.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(c.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>b.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(c.T,{children:(0,h.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(c.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(c.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(u.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Subtotal"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Of which gift card"}),(0,j.jsxs)(c.T,{colour:y.colours.ok,children:["\u2212",(0,h.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Tip"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.tip)})]}):null,(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.gold,children:(0,h.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(c.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(F)," \xb7 split ",L," way",L>1?'s':''," \xb7 ",(0,h.gbp)(Y)," each"]}),(0,j.jsxs)(c.T,{children:["Shares paid: ",W," of ",L," \xb7 remaining ",(0,h.gbp)(q)]}),L>1?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{children:"Shares to pay now"}),(0,j.jsx)(c.Stepper,{value:R,onChange:A,min:1,max:L-W,label:"shares"})]}):null,(0,j.jsx)(c.Button,{label:`Pay ${L>1?`${R} share${R>1?'s':''}`:'bill'} \xb7 ${(0,h.gbp)(Math.min(q,Y*R))}`,onPress:()=>$(!0),testID:"pay-bill"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(c.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(c.Chip,{label:e?`${e}%`:'No tip',selected:I===e,onPress:()=>N(e)},e))}),(0,j.jsx)(c.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(c.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(r.subtotal+D),O>1?` \xb7 ${(0,h.gbp)(Math.ceil((r.subtotal+D)/O))} each`:'']}),(0,j.jsx)(c.Button,{label:"Get the bill",onPress:()=>b.repo.orders.setSplit(r.id,O,D),testID:"get-bill"})]})]}):null,!E||r.rated||v?null:(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(c.H2,{children:"How was everything?"}),(0,j.jsxs)(c.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(i.Stars,{value:C,onChange:S}),C?(0,j.jsx)(c.Field,{label:"Anything to add? (optional)",value:k,onChangeText:T}):null,(0,j.jsx)(c.Button,{label:"Send feedback",disabled:!C,onPress:()=>{b.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:C,comment:k,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),P(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(c.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,E?(0,j.jsx)(c.Button,{kind:"secondary",label:"View stamp card",onPress:()=>s.router.push(`/customer/${f.id}/loyalty`)}):null,(0,j.jsx)(o.MockPay,{visible:M,onClose:()=>$(!1),amount:Math.min(q,Y*R),restaurantId:f.id,title:`Pay \u2014 ${(0,t.tableNumbers)(r.tableNo)}`,onPaid:e=>{b.repo.orders.payTable(r.id,{shares:R,giftCardCode:e.giftCardCode}),$(!1),A(1)}})]})}},1324,[860,30,34,102,1252,1250,794,861,867,858,874,821,25]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1325,[860,1257,30,34,102,794,861,867,858,874,879,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1326,[30,34,872,25]); -__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1327,[837,30,34,794,874,5,1257,25]); -__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1328,[30,34,794,1329,1174,1257,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1329,[827,860,34,102,794,861,867,1174,1330,874,821,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1330,[933,987,1174]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1331,[30,34,872,1332,1396,25]); -__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1332,[1161,796,5,6,1333,828,853,1121,860,1160,1334,1335,1336,1118,1142,1337,1338,1343,1344,1345,872,1346,1173,979,1129,1347,34,1098,1195,1047,1114,1156,1348,395,380,402,295,102,426,36,794,1232,1236,873,861,858,874,821,1117,891,1125,1087,1028,1104,1134,1349,1133,1350,1357,1359,1362,1365,1361,1366,1368,1369,1139,1122,1123,878,1373,1221,1374,1231,1223,1025,1379,1387,1388,1101,1141,1390,1391,1392,1097,1188,1393,1187,1180,869,1394,1395,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1334,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1335,[1026,1087]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1336,[34,102,1104,794,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1337,[860,34,102,794,874,1174,821,25]); -__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1338,[34,395,402,426,102,1279,794,1188,796,1028,1339,1340,1342,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1339,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1340,[34,395,402,295,412,102,426,796,794,821,1341,1342,25]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1341,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1342,[1024,872,1341,933,987]); -__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1343,[846]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1344,[828,34,379,395,402,102,794,1188,821,25]); -__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1345,[34,236,402,102,794,821,891,1003,858,1097,25]); -__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1346,[828,827,34,236,402,295,102,794,1173,874,979,831,981,982,872,980,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1347,[828,34,102,821,794,25]); -__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1348,[34,102,797,821,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1349,[]); -__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1350,[828,796,827,1121,860,1129,34,236,402,295,426,102,859,821,794,1351,1352,1028,891,1133,1354,987,872,25]); -__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1351,[828,860,34,1352,102,859,821,794,1134,1353,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1352,[859]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1353,[1352,859]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1354,[34,385,295,102,859,1355,1356,821,796,827,794,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1355,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1356,[1355,1024,872,933,987]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1357,[34,236,402,102,821,794,1188,1358,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1358,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1359,[828,860,1122,34,281,236,295,102,1135,874,1028,1104,14,858,1123,1360,821,794,1361,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1360,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1361,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1362,[5,828,34,283,336,236,402,102,426,821,873,794,1029,1000,1343,1363,2,1364,1365,874,858,25]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1363,[236]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1365,[34,846,933,987,1364]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1366,[860,14,1028,1367]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1367,[861]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1368,[34,102,797,821,25]); -__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1369,[1370,860,1122,1028,34,102,794,1125,874,1372,1366,1123,858,1120,1139,1140,1141,821,1335,25]); -__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1370,[34,379,402,102,874,1003,891,1026,1371,872,821,794,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1371,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1372,[1028,1104]); -__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1373,[1370,828,1122,827,860,1160,1118,1139,858,34,1106,236,402,295,102,794,1125,1361,874,1028,861,1116,1104,1320,821,1335,25]); -__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1374,[827,34,236,402,102,794,874,1028,1375,821,1376,1378,25]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1375,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1376,[846,874,1028,1375,1377,1378]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1377,[860]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1378,[236,1377]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1379,[860,34,1199,1188,402,102,1025,1028,878,858,821,794,1380,1383,25]); -__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1380,[1381,870,860,34,281,395,402,295,102,874,1025,1028,1382,858,821,1055,794,1383,1384,987,1335,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1381,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1382,[878,858,877]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1383,[5,1028,933,987]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1384,[846,933,987,1385,2,1386]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1385,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1386,[15]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1388,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1389,[1104]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1390,[860,1367]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1391,[34,402,102,794,1390,821,1348,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1392,[34,102,925,794,1188,858,821,25]); -__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1393,[34,1188,402,102,426,794,25]); -__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1394,[828,1062,827,2,1188,34,402,102,426,794,821,891,997,858,1000,1384,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1395,[34,1035,891,1008,831,1036,1000,1384,1093]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1396,[5,828,873,34,236,402,102,426,987,821,794,1343,1397,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1397,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1398,[30,34,872,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1399,[30,34,872,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1400,[30,34,1401,872,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1401,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1402,[30,34,872,1403,25]); -__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1403,[1404,1408,828,996,1098,1409,1217,1054,1055,1410,1412,1415,1173,979,1015,1417,1012,2,1060,1061,1418,998,1038,999,34,1175,1232,1236,1213,373,402,295,102,426,36,794,873,1156,891,821,1179,1419,1093,1111,1113,1107,1056,1039,1087,1427,1428,1429,1438,1439,1003,236,1239,1192,1198,1435,1212,1211,1448,1195,15,1218,1219,925,793,987,25]); -__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1404,[827,34,1047,395,102,1133,1134,1350,1379,794,1025,1028,858,821,1087,1029,1405,1406,1049,25]); -__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1405,[827,34,402,102,794,821,1028,5,1029,872,987,25]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1406,[34,102,794,1028,1407,859,821,1074,933,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1407,[]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1408,[34,102,794,1087,987,25]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1409,[860,34,102,794,861,867,1174,874,869,821,25]); -__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1410,[987,34,281,236,102,1279,794,1254,1257,821,1411,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1411,[34,236,102,794,1254,25]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1412,[34,796,102,794,861,1254,1413,1414,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1413,[861]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1414,[987,1413,1257]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1415,[5,1416,34,102,794,867,1254,1255,1256,987,1257,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1416,[34,794,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1417,[236,1013]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1418,[34,102,794,821,998,1051,987,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1419,[5,1416,1122,11,1420,827,837,1139,1140,1118,1142,1421,1137,1141,1390,1391,1087,1335,1026,1116,14,1143,1423,1232,1424,1379,1106,1100,1117,34,102,794,1348,874,861,867,858,1320,821,1194,1125,1028,1425,1086,1180,1426,1223,987,1196,1387,878,25]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1420,[6,34,102,794,987,1266,25]); -__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1421,[34,402,102,1422,987,933,821,794,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1422,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1423,[827,5,34,379,236,102,794,876,14,867,1031,933,821,1197,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1424,[34,402,1188,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1425,[34,102,874,1028,794,821,25]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1426,[34,102,879,874,864,821,794,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1427,[34,1380,1087,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1428,[860,34,102,1180,794,874,861,869,858,821,1194,1087,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1429,[835,984,1430,34,236,102,794,831,891,983,1030,985,987,1437,821,2,1181,25]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1430,[827,979,1160,987,797,1221,1223,34,281,379,236,402,102,426,879,794,874,1232,891,867,858,821,1194,1087,869,1431,1179,1435,1436,1159,1166,1165,1038,13,1163,1169,1434,25]); -__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1431,[927,796,831,828,837,878,1075,1432,34,993,336,379,236,402,102,794,874,891,858,821,1194,1087,1434,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1432,[499,1433]); -__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 t={}},1433,[]); -__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1434,[831,891,5]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1435,[827,34,1247,1055,870,379,402,102,794,891,867,858,821,1194,1087,1434,25]); -__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1436,[1015,34,402,102,794,891,821,1087,987,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1437,[]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1438,[860,34,102,794,891,1028,858,1090,1088,987,1089,5,1000,821,25]); -__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1439,[5,1440,1441,1442,1443,1444,34,236,41,102,872,1445,1003,821,1447,794,987,2,1096,1002,891,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1440,[34,102,873,794,5,6,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1441,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1442,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1443,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1444,[34,102,873,794,25]); -__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1445,[34,295,102,794,873,821,1446,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1446,[]); -__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1447,[929,828,34,1096,336,236,402,295,41,102,872,926,891,831,987,1003,15,793,821,925,794,25]); -__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1448,[1195,1098,1139,1116,34,402,102,794,891,858,821,1117,1187,1087,1192,1431,1180,876,1196,869,1194,925,1425,1028,860,1125,1211,1215,1097,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1449,[30,34,872,25]); -__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1450,[1451,987,795,1397,1453,1025,30,1480,496,34,385,336,236,41,102,5,873,872,1482,36,874,1028,891,821,1439,1003,1023,1485,1486,1057,1487,1129,2,1038,998,1505,1365,25,1507,1508,1509,1510]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1451,[2,827,34,236,383,102,794,1452,987,821,1198,1003,891,993,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1452,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1453,[1454,1477,1479]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1454,[215,1455,1458,1472,1473,1474,1475,1476]); -__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1455,[215,1456]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1456,[1457]); -__d(function(g,r,i,a,m,e,d){},1457,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1458,[1459,215,1455,1472,1473]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1459,[1460,1461,1471]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1460,[1461,1465,1470]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1461,[215,372,1462,1466,1467,1468,1469,1465,1470]); -__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1462,[215,1463,339,280,1464,1465]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1463,[504]); -__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1464,[215,339]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1465,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1466,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1467,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1468,[1466]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1469,[]); -__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1470,[372,1464]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1471,[34,1461]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1472,[1459,215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1473,[1459,1472]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1474,[1455]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1475,[215,1455,1458,1456]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1476,[]); -__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1477,[215,54,1478]); -__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1478,[215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1479,[34,1454]); -__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]}})})},1480,[1481]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1481,[]); -__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1482,[34,41,102,426,794,873,1003,987,2,5,821,1483,1484,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1483,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1484,[34,102,794,821,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1485,[989,883,882,987]); -__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1486,[828,796,827,34,1011,1405,1029,402,102,872,987,1013,1028,5,821,794,1343,976,2,25]); -__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1487,[5,796,827,34,385,283,364,380,236,402,295,426,102,1488,1156,2,797,1087,15,891,794,821,1489,932,1501,1497,1498,1502,1157,1503,931,1504,1500,25,277]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"useAssistantUi",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AssistantFab",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AssistantSheet",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"AssistantPage",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"AssistantSettings",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"AssistantPlanCard",{enumerable:!0,get:function(){return c}});const t=!1,n={getState:()=>({open:!1,setOpen:t=>{}})},u=()=>null,s=()=>null,l=()=>null,o=()=>null,c=()=>null},1488,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1489,[1490,1127,860,1491,1492,891,874,1028,1496,1497,1498,1494,1493,1499,1500,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1490,[1092,1091,1052]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1491,[984,1127,835,860,874,831,1028,983,985,1039,891,1094,882,863,861]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1492,[835,874,831,1028,891,1033,1043,1044,1009,1008,1038,13,1063,1064,1065,1034,1094,882,1104,1025,870,1493,1491]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1493,[835,979,1127,860,1160,1257,874,831,1028,1033,994,862,861,1104,1105,1025,1034,867,1494,1495]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1494,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1495,[839,846,849]); -__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1496,[828,34,283,364,236,402,102,846,794,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1497,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1498,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1499,[831,891,994,867,1493,1046,1097]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1500,[]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1501,[891,831,1028]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1502,[846]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1503,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1504,[846]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1505,[874,831,891,1038,15,1003,872,2,1506]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1506,[874,1038]); -__d(function(e,s,o,p,t,a,n){"use strict";t.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1507,[]); -__d(function(s,o,p,e,d,t,c){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1508,[]); -__d(function(o,s,p,e,d,t,f){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1509,[]); -__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1510,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1511,[30,34,872,25]); -__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1512,[1513]); -__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1513,[25,1514,591]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1514,[34,172]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1515,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1516,[25,499,34,270,651]); +__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return Q.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return Q.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return Q.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return Q.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return Q.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ot}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ie.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ie.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ie.useOwner.getState().chatSeen(t,e)),$t(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ie.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...ht(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(fe.PITCH)return ge.unlockCashUp(e,t,a);const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?de.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):de.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(fe.PITCH)return ge.cashAudit(e);const t=Ae.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(_a.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=pa,i.readAccessLog=async function(){const e=Ae.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ae.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return ga}}),i.uploadOrderLogo=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(ga).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ma.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(ga).createSignedUrl(e,3600);if(t?.signedUrl)return ma.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(ga).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return _a}}),i.claimInvite=Ua,i.makeChromeHandover=async function(){const e=Ae.getState();if(fe.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ee});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(fe.PITCH||!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ee});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),Me&&qa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Ne();const t=await q.kv.get(Ia,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Ne(),await q.kv.get(Oa,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_WILDINGS||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Ne(),await q.kv.remove(Ia),await q.kv.remove(Oa),Ce({mode:'signin',perms:[]});try{await xa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ae.getState().venueId;if(fe.PITCH||!s||'staff'!==Ae.getState().kind)return{ok:!0};if(!(0,re.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Pa('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ua(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(fe.PITCH)return ge.reissueInvite(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Pa('staff_app_link_history',{p_venue:Ae.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Pa('revoke_staff_app_link',{p_venue:Ae.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(fe.PITCH)return ge.linkPhones();const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return{};try{const t=await Pa('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(fe.PITCH)return ge.resetPhone(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Number(await Pa('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(fe.PITCH)return ge.inviteStatus();const e=Ae.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:t,error:a}=await Re().rpc(d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_pairing_code':d.IS_GREENSIDE?'claim_greenside_pairing_code':d.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':d.IS_KIRKTON?'claim_kirkton_pairing_code':d.IS_WILDINGS?'claim_wildings_pairing_code':d.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':d.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await q.kv.set(ka,n),qa(),{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}`}}},i.carPairStart=async function(){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await q.kv.set(Ea,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ta(e)}}},i.carPairPoll=async function(e){try{Ne();const t=e??await q.kv.get(Ea,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,J.carPairApproved)(n)){const e=(0,J.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await q.kv.get(ka,null);await q.kv.set(ka,e),await q.kv.remove(Ia),A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||qa()}return'revoked'!==i&&'unknown'!==i||await Na(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Ne(),await Re().rpc('car_sign_out')}catch{}await Na(),await xa();try{await Re().auth.signOut({scope:'local'})}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Pa('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ta(e)}}},i.carList=async function(){const e=Ae.getState().venueId;if(!e)return[];return(await Pa('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Pa('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ta(e)}}},i.unpairDisplay=async function(){await q.kv.remove(ka),await xa();try{await Re().auth.signOut()}catch{}Ce({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await q.kv.remove(Ia),await q.kv.remove(Oa),await xa();try{await Re().auth.signOut()}catch{}Ce({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.'})},i.wipeThisDevice=async function(e={}){try{await xa()}catch{}try{(0,N.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${d.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!d.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Ka,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Pa}}),i.mendSession=La,i.startAppSync=async function(e=d.VENUE_RID){if(d.IS_ISOLATED_VENUE&&e!==d.VENUE_RID)return;if(Me)return;Me=!0,Ba=e,'customer'===Ee&&'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Ne(),'customer'!==Ee){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ee&&(0,y.isAnchorage)(e)?[V.useStore,ie.useOwner,se.useKitchen,ne.useSafety,X.useCardStore,_.useGpCalc,ee.useOrderSheets,h.useSpecials,C.useHr]:[V.useStore,ie.useOwner,se.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ee&&(0,y.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ce({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Os(e)}catch{if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e))return void Ce({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,N.isSupabaseConfigured)())return void Ce({mode:'off'});F.mutationQueue.subscribe(()=>{const e=F.mutationQueue.waiting,t=e[0];Ce({pending:F.mutationQueue.pending.length,failed:F.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,B.describeWrite)(t)}: ${(0,B.plainReason)({...t.lastErr},'retry')}`:void 0})}),F.mutationQueue.onFailed(e=>Ce({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:F.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,B.describeWrite)(e),why:'conflict'===e.reason?(0,B.plainReason)({code:'conflict'},'refused'):(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Pe.push((0,K.onConnectivity)(e=>Ce({mode:e?Ae.getState().venueId?'live':Ae.getState().mode:Ae.getState().venueId?'offline':Ae.getState().mode}))),await ja()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Qa}}),i.serverOrder=Za,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return Ya}}),i.nudgeGuestSync=function(){Xa?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return es}}),i.stockSaveBlocker=ts,i.stockEventStatus=function(e){if(Ze(e))return{state:'saved'};const t=F.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,B.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=as,i.saveStockEventsNow=ss,i.bookingSaveBlocker=is,i.resendUnsavedBookings=ds,i.saveBookingsNow=us,i.waitForBookingSave=function(e,t=12e3){if(!Ue())return Promise.resolve({state:'local'});const a=is();if(a)return Promise.resolve({state:'refused',why:a});const s=rs()[0]?.venueId??'',n=()=>ns.some(t=>F.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=$.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,K.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(F.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(F.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||rs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||rs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=gs,i.tempLogState=function(){const e=ms()[0]?.venueId??'',t=ms().find(e=>'temp_readings'===e.spec.table),a=F.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!F.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(W.useTempSaves.getState().notSaved),i=ne.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=_s,i.waitForTempSave=function(e,t,a=1e4){if(!Ue()||!ms().length)return Promise.resolve({state:'local'});const s=gs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ms()[0]?.venueId??'',i=ms().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>W.useTempSaves.getState().notSaved[(0,W.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>F.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=ws,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ms}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Ps.get(a);if('customer'!==Ee||!(0,N.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Ps.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Pa('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:Le(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:Le(a.from_time),to:Le(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Ps.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ms.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Ps.get(a);e&&!e.ok&&Ps.delete(a)}));const n=Ps.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ae.getState().venueId;if(!n||'staff'!==Ae.getState().kind)throw new Error('Connect to your venue first.');const i=await Pa('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});V.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return null;return(await Pa('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');await Pa('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),O=t(r[18]),R=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(pe),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]),Oe=t(r[71]);const Re=()=>(0,T.getSupabase)();F.mutationQueue.setExecutor(L.executeMutation),(0,M.setClockServer)(()=>'staff'===Ae.getState().kind);const Ae=(0,E.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ce=e=>Ae.setState(e),De=e=>{const t=Ae.getState().perms;return t.includes('*')||t.includes(e)},Ue=()=>{const e=Ae.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ae.subscribe(()=>(0,be.setLiveData)(Ue()));let Ee=G.IS_CAR?'car':G.APP_VARIANT,Te=!1;const Ne=()=>{Te||((0,q.setSyncNamespace)(Ee),Te=!0)};let Ke=[],Pe=[],Me=!1;const xe=()=>(new Date).toISOString().slice(0,10),qe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),Le=e=>e?e.slice(0,5):'',Be=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))):[],je=e=>JSON.parse(JSON.stringify(e));function Fe(e,t){const a=qe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>V.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=je(e);if(t)return{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:Be(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,re.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:Be(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function $e(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>V.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.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,re.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:je(e.lines??[]),allergies:Be(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:je(e.allergyChain??{}),readiness:je(e.readiness??{}),allergy_ticks:je(e.allergyTicks??{}),handover_check:e.handoverCheck?je(e.handoverCheck):null,accepted:e.accepted?je(e.accepted):null,doc:je(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)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function We(e){const t=qe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...z.useBlocks.getState().blocks,...z.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Ae.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:je(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,z.blockClock)(t.from_time)??a?.from,n=(0,z.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>z.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>z.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Qe=null,He='Main plan';function Ve(e){const t=e=>je({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(Z.useFloor.getState().plans[e]??(0,Z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>De('floor.manage')||De('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Qe??(0,ke.uuidFrom)(`plan:${a}`),venue_id:a,name:He||'Main plan',is_active:!0,...t(e),updated_by:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>(Qe=String(e.id),He=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,Ie.withSeedBest)(e,t[0]):void 0;a&&Z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>Z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ge(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Y.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>De('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,re.isUuid)(e.supplierId)?e.supplierId:(0,ke.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),dt.get(t)??t)}:{}};var t},apply:(t,a)=>Y.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Je=new Set,ze=new Set;F.mutationQueue.onDone(e=>{'stock_events'===e.table&&ze.add(e.rowKey)});const Ze=e=>ze.has(e)||Je.has(e),Ye=()=>De('*')||De('staff.manage')||De('recipes.edit')||De('recipes.signoff'),Xe=()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write'));function et(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Y.useShellStore.getState().events.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,re.isUuid)(t.id)&&!!(Y.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('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,re.isUuid)(e.undoes)&&(Ze(e.undoes)||F.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Je.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)=>Y.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function tt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Y.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={...Y.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Y.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Je]}}}))},afterRead:()=>{Y.useShellStore.getState().server[e]||Y.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Je]}}}))},subscribe:()=>()=>{}}}const at=new Set;function st(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=V.useStore.getState().menu;return X.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:t=>(0,re.isUuid)(t.card.id)&&!((0,y.isAnchorage)(e)&&(0,y.isDemoCard)(t.card))&&!(0,y.isPlaceholderCard)(t.card),writable:()=>De('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,y.isAnchorage)(e)&&(s={...s,signOff:(0,y.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,y.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,y.isAnchorage)(e)&&(0,y.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,ke.photoPath)(a,s),t=nt(s.photo);t&&((0,X.cachePhotoAs)(e,t),it(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,ke.cardToRow)(s,a);return{...i,...r,doc:je({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,y.isPlaceholderCard)(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,signOff:(0,y.isAnchorage)(e)&&(0,y.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!De('recipes.edit')&&t.length){const e=new Set(t);X.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);X.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&V.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&V.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=X.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=V.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const nt=e=>(0,X.readLocalPhoto)(e);async function it(e,t){if(!at.has(e)){at.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(ke.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){at.delete(e),Ce({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const rt=new Map,ot=(0,E.create)(()=>({n:0}));(0,X.setStoragePhotoResolver)(e=>{const t=rt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,N.isSupabaseConfigured)()&&'off'!==Ae.getState().mode?(t||(rt.set(e,{url:'',at:Date.now()}),Re().storage.from(ke.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(rt.set(e,{url:t.signedUrl,at:Date.now()}),ot.setState(e=>({n:e.n+1})),X.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const dt=new Map;const ut=(e,t)=>{const a=(0,re.isUuid)(t)?t:(0,ke.uuidFrom)(`sup:${e}:${t}`);return dt.set(a,t),a};function ct(e){return{name:'order_sheets',table:'suppliers',list:()=>ee.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,y.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>De('suppliers.manage'),toRow:(e,t)=>({id:ut(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:je(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(dt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ee.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ee.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,re.isUuid)(e)?e:(0,ke.uuidFrom)(`sup:${Ae.getState().venueId}:${e}`)})}}let lt=!1,ft=!1;const pt=new Map,gt=new Map,mt=new Map,_t=new Map,St=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ht=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'},yt=(e,t)=>({...e,managerAccess:t}),wt=()=>({nickname:lt,display:ft}),vt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=yt({role:e.role,level:e.level??ht(St(e)).level},!0===e.managerAccess);return(0,j.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},wt())};const bt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},kt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},It=e=>{const t=ie.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ot=2e3;function Rt(e,t){return t||!e.length||e.length>=Ot?null:e=>(0,re.isUuid)(e.id)}function At(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,De('rota.manage')):null,keepOnEmpty:()=>e&&!De('rota.manage'),list:()=>ie.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&pt.has(e.staffId)&&(De('rota.manage')||It(e.staffId)),writable:()=>De('rota.manage')||De('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(bt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:kt(e.start),end_time:kt(e.end),published:!!e.published,doc:je(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Ct(){const e=qe(62),t=e=>De('rota.manage')||e.staffId===Ae.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ie.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ae.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=qe(2)&&e.staffId===Ae.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:je(e.breaks??[]),break_mins:e.breakMins??0,doc:je((0,w.privateAttendance)(d.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,w.privateAttendance)(d.VENUE_RID,{...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Dt(){const e=qe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.staffId===Ae.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ae.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:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,re.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:je({...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Ut(e){ie.leaveRemote.decide=t=>!(!De('rota.manage')||!(0,re.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(F.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Pe.push(()=>{ie.leaveRemote.decide=null})}function Et(e){ie.timesheetRemote.send=(t,a)=>{if(!De('rota.manage')||!(0,re.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return F.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:je(s)}}),!0}const s=a;if('attendance_void'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return F.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:je(s.breaks??[]),p_reason:n,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0},Pe.push(()=>{ie.timesheetRemote.send=null})}function Tt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>V.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ae.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,re.isUuid)(a)?a:(0,ke.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,re.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:je(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>V.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=>V.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Nt=e=>V.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Kt(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}));V.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Pt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=V.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[je({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:Z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Nt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>De('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...xt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...xt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...xt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Mt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Mt=t.feature_flags??{},xt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),je({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}:{}})},apply:t=>{const a=t[0];a&&(V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&Z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Kt(e,a.events))},subscribe:e=>{const t=V.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=Z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Mt=null,xt=null;const qt=()=>new Date(Date.now()-2592e6).toISOString(),Lt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Bt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>gt.get(e));return 2===t.length&&t[0]&&t[1]?(0,he.dmId)(t[0],t[1]):null},jt=()=>Ae.getState().perms.includes('*');function Ft(){const e=()=>Ae.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ie.useOwner.getState().chat.filter(e=>(0,re.isUuid)(e.id)).map(e=>je({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=>!!Lt(t.ch)&&(t.from===e()||jt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('created_at',qt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=qt(),toRow:(e,t)=>{const a=Lt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:pt.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=Bt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?gt.get(String(e.from_staff)):'system';return s?je({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ie.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?gt.get(String(t.from_staff)):'system',i=Bt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ie.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,he.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,ye.soundAllowed)())try{(0,ye.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,k.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function $t(e,t,a){const s=Ae.getState();if(!Se.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=pt.get(e),i='*'===t?'*':Lt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Wt(e){const t=Ae.getState().staffRef,a=t?pt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Bt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ie.useOwner.getState().chatMarkRead(t,i)}catch{}}function Qt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=D.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:je(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>D.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,U.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Ht(e){const t=qe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>D.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.reminderId)&&e.staffRef===Ae.getState().staffRef,writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>D.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Vt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Gt=e=>null==e||''===e?null:Number(e),Jt=e=>e.filter(e=>!e.startsWith('data:')),zt=()=>De('takings.view');function Zt(e){const t=!zt();return{name:'cash_ups',table:'cash_ups',list:()=>de.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',qe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:je(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({cashUps:Vt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Yt(e){return{name:'sales_reports',table:'sales_reports',list:()=>de.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:je(e.vals),categories:e.categories,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({sales:Vt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Xt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=de.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,de.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:je({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,de.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>de.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ea(e){return{name:'day_tips',table:'day_tips',list:()=>de.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',qe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>de.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ta(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>de.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Gt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>de.useCashUp.setState(s=>({pot:Vt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function aa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=de.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>De('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>de.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function sa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>oe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:je(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>oe.useNotifs.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>oe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function na(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ue.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:je(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ue.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ce.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Vt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ia(e){const t=()=>De('venue.settings')||De('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ue.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,re.isUuid)(a.id)&&(0,re.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ue.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ae.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ae.getState().staffRef)||null,doc:je(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ra(e){const t=qe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ue.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:je(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({history:Vt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function oa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=le.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:je(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>De('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&le.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,w.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>le.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function da(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=me.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,me.libraryRowId)(e),kind:'library',doc:je({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,me.personRowId)(e,i),kind:'person',staffRef:i,doc:je({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ie.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,_e.canEditTasks)(t,a)},writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>me.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,me.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ua(e){const t=qe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>me.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ae.getState();return e.byRef===t.staffRef||De('staff.manage')},writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>me.useDailyTasks.setState(s=>({ticks:Vt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ca(e,t=!1){const a=qe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>we.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind||De('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,ke.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>we.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>we.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{ve.autoSync.soldOutRead.add(e)}}}function la(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>ve.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:(0,ke.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>ve.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>ve.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{ve.autoSync.linksRead.add(e)}}}async function fa(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&q.kv.get(a,!1):(q.kv.set(a,!0),!0)}catch{return q.kv.get(a,!1)}}async function pa(){const e=Ae.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();_a.setState({live:!!t?.push_live,known:!0})}catch{}}const ga='order-list-logos';const ma=new Map;const _a=(0,E.create)(()=>({live:!1,known:!1}));async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('reminders:ok',!1):(q.kv.set('reminders:ok',!0),!0)}catch{return q.kv.get('reminders:ok',!1)}}async function ha(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('chat:ok',!1):(q.kv.set('chat:ok',!0),!0)}catch{return q.kv.get('chat:ok',!1)}}const ya=(e,t)=>je({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),wa='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function va(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>C.useHr.getState().questions.filter(t=>t.venue===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ya(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);C.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>C.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function ba(e,t){const a=(t,a,s)=>{F.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(C.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(wa).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||C.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ya(e,t)))}catch{}}}),Pe.push(()=>{Object.assign(C.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ka='pair:v1',Ia='staff:v1',Oa='staff:rejoin:v1';async function Ra(e){const t=d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_invite':d.IS_GREENSIDE?'claim_greenside_invite':d.IS_ABBOTSFORD?'claim_abbotsford_invite':d.IS_KIRKTON?'claim_kirkton_invite':d.IS_WILDINGS?'claim_wildings_invite':d.IS_KIRKMICHAEL?'claim_kirkmichael_invite':d.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ee,p_device:(0,A.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,A.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Aa(){if('display'===Ee||'customer'===Ee||fe.PITCH)return'none';const e=await q.kv.get(Oa,null);if(!e)return'none';try{await Da();const{data:t,error:a}=await Ra(e);if(a)return(0,O.inviteRefusal)(a.message)?(await q.kv.remove(Oa),await q.kv.remove(Ia),'refused'):'offline';const s=t?.[0];return s?(await q.kv.set(Ia,{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,displayName:s.display_name}),'ok'):(await q.kv.remove(Oa),'refused')}catch{return'offline'}}const Ca=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Da(){Ne();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ce({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 Ua(e){if(fe.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Ra(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,d.venueKey)(`cc-pending-invite:${Ee}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),await q.kv.set(Oa,e),Me&&qa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ce({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ea='car:request:v1',Ta=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Na(){await q.kv.remove(ka),await q.kv.remove(Ia),await q.kv.remove(Ea),A.useSession.getState().meId&&A.useSession.getState().signOut()}async function Ka(){if(!(0,N.isSupabaseConfigured)())return!1;try{return await Da(),!0}catch{return!1}}const Pa=async(e,t={})=>{if(fe.PITCH)return(0,pe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Ma=null;async function xa(){for(const e of Pe)try{e()}catch{}Pe=[],Ke.forEach(e=>e.stop()),Ke=[],Ma&&(clearInterval(Ma),Ma=null)}async function qa(){await xa(),await ja()}async function La(){if(!(0,N.isSupabaseConfigured)()||'customer'===Ee||fe.PITCH)return!1;try{Ne();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ee)return!1;if(!await q.kv.get(Oa,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Aa()&&(qa(),!0)}catch{return!1}}(0,c.setSessionMender)(La);let Ba=d.VENUE_RID;async function ja(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Ba;try{if(Ce({mode:'connecting'}),await F.mutationQueue.load(),'customer'===Ee)return void await Va(e);let t=await q.kv.get(ka,null),a=await q.kv.get(Ia,null);if(G.IS_CAR&&!t&&a){const e=(0,J.migrateCarStaffIdentity)(a);e&&(t=e,await q.kv.set(ka,t)),await q.kv.remove(Ia),a=null,A.useSession.getState().meId&&A.useSession.getState().signOut()}if(d.IS_ISOLATED_VENUE&&(t&&!(0,d.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,d.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ce({mode:'display'===Ee?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ee&&!G.IS_CAR&&a&&!s.session){const t=await Aa();if('offline'===t)return Ce({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Ba===e&&qa()},6e4);'refused'===t&&a.staffRef&&A.useSession.getState().meId===a.staffRef&&A.useSession.getState().signOut(),a=await q.kv.get(Ia,null),({data:s}=await Re().auth.getSession())}const n='display'===Ee||G.IS_CAR?t:a;if(!s.session||!n)return void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Pa('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ee||G.IS_CAR?await q.kv.remove(ka):(await q.kv.remove(Ia),await q.kv.remove(Oa)),'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId===n.staffRef&&A.useSession.getState().signOut(),void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ee?'This display was unpaired by a manager.':G.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,K.isOnline)()||/fetch|network/i.test(String(t?.message)))Ce({mode:'offline'});else if(Ca(t)&&'display'!==Ee){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Aa()&&setTimeout(()=>{Ba===e&&qa()},500)}i=Ae.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ce({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!G.IS_CAR&&'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId!==n.staffRef&&(A.useSession.getState().signIn(n.staffRef),ie.useOwner.setState({staffAs:n.staffRef})),G.IS_CAR&&(A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({previewRole:'owner'})),await $a(n.venueId,e,n.kind)}catch(e){Ce({mode:'local',lastError:String(e?.message??e)})}}const Fa=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','venue_reminders','reminder_done']);async function $a(e,a,s){if(!(0,d.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||G.IS_CAR&&'device'===s;await ws(a),Pe.push(Ks(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])mt.set(e.key,e.id),_t.set(e.id,e.key)}catch{}const i=[Pt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ie.useOwner.getState().staff.map(vt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>De('staff.manage'),deletes:!1,revision:e=>(0,j.staffRevision)(e,wt()),toRow:(e,t)=>(0,j.staffRow)(e,t,wt(),e.managerAccess||e.ownerAccess?null:mt.get(St(e))),fromRow:e=>{if(!e.external_ref)return null;pt.set(String(e.external_ref),String(e.id)),gt.set(String(e.id),String(e.external_ref)),Us.set(String(e.external_ref),e.avatar_path??null);const t=yt(ht(_t.get(String(e.role_id))),!0===e.manager_access);return(0,j.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},wt())},apply:e=>ie.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=>ie.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ns()},onRemote:()=>{Ns()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ie.useOwner.getState(),t=ae.useSetup.getState().sites[Ba]?.staffGrade??{};return e.staff.filter(e=>pt.has(e.id)).map(a=>je({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=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:pt.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=gt.get(String(e.staff_id));return t?je({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=>ie.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=ae.useSetup.getState().sites[Ba],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&&ae.useSetup.getState().patch(Ba,{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=ie.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=ae.useSetup.subscribe((t,a)=>{t.sites[Ba]?.staffGrade!==a.sites[Ba]?.staffGrade&&e()});return()=>{t(),a()}}},Fe(a,!1),Fe(a,!0),We(a),Ve(a),$e(a),Ge(a),et(a),tt(a),ct(a),{name:'supplier_directory',table:'suppliers',list:()=>ie.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('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:je(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ie.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId),writable:()=>De('suppliers.order')||De('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||xe(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:je(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},st(a),As(a)];De('wages.view')&&i.push(Cs(a)),n&&(i.push(At(!0),Ct(),Dt(),Tt(a)),Et(e)),n&&await fa('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ae.getState().staffRef&&'pending'===e.status||De('rota.manage')),writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:je(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Fa.add('staff_leave'),Ut(e));const o=n&&await ha();if(Se.useChatSync.setState({synced:o,checked:!0}),Pe.push(()=>Se.useChatSync.setState({synced:!1})),o&&i.push(Ft(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(he.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:pt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:pt.get(e.id),include:e.include}),fromRow:e=>{const t=gt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>he.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=>he.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await fa('hr_questions')&&(i.push(va(a)),Fa.add('hr_questions'),ba(e,a)),'guest'!==s&&'customer'!==Ee&&await fa('temp_readings')&&(i.push((0,Q.tempUnitsSpec)(ne.useSafety,Ye),(0,Q.tempReadingsSpec)(ne.useSafety,Xe)),Fa.add('temp_units'),Fa.add('temp_readings')),'guest'!==s&&await fa('sold_out_items')?(i.push(ca(a,await fa('sold_out_items','auto'))),Fa.add('sold_out_items')):ve.autoSync.soldOutRead.add(a),'guest'!==s&&await fa('sold_out_links')?(i.push(la(a)),Fa.add('sold_out_links')):ve.autoSync.linksRead.add(a),D.useReminders.getState().ensure(a),'guest'!==s&&await Sa()&&(i.push(Qt(a)),n&&i.push(Ht(a))),oe.useNotifs.getState().ensure(a),ue.useOrderLists.getState().ensure(a),n){lt=await fa('staff','nickname'),ft=await fa('staff','display_clock');const[e,t,s,n]=await Promise.all([fa('scheduled_notifications'),fa('order_lists'),fa('venue_clock_area'),fa('daily_tasks')]);me.useDailyTasks.getState().ensure(a),n&&(i.push(da(a),ua(a)),Fa.add('daily_tasks'),Fa.add('daily_task_ticks')),e&&(i.push(sa(a)),pa()),t&&i.push(na(a),ia(a),ra(a)),s&&i.push(oa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Fa.add(n)}if('guest'!==s&&await fa('day_tips')){i.push(ea(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Fa.add(e);await fa('tips_pot_events')&&i.push(ta(a),aa(a)),n&&(zt()||(0,de.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(Zt(a),Xt(a)),Fa.add('cash_ups'),zt()&&(i.push(Yt(a)),Fa.add('sales_reports')),t(r[73])(r[72],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(At(),Ct()),await fa('scheduled_notifications')&&i.push(sa(a)));let u=!1;const c=()=>{if(G.IS_CAR&&n&&De('recipes.edit'))return!0;const e=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);return!!e&&e.active&&De('recipes.edit')&&(0,S.costsAllowedFor)(e)};n&&c()&&await fa('ingredient_prices')&&(i.push((0,_.gpSyncSpec)('ing',c)),Fa.add('ingredient_prices'),await fa('card_costs')&&(i.push((0,_.gpSyncSpec)('card',c)),Fa.add('card_costs')),await fa('kitchen_deliveries')&&(i.push((0,_.gpSyncSpec)('del',c)),Fa.add('kitchen_deliveries')),await fa('kitchen_stock_counts')&&(i.push((0,_.gpSyncSpec)('count',c)),Fa.add('kitchen_stock_counts'))),(0,Oe.specialsSyncOn)()&&'guest'!==s&&await fa('specials_boards')&&(i.push((0,Oe.specialsBoardSpec)(a,()=>De('recipes.edit')||De('floor.manage')||De('*'))),Fa.add('specials_boards'));const l={onActivity:()=>Ce({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ce({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ce({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Pa('whoami')??[]).some(t=>t.venue_id===e))return void(Ba===a&&qa());for(const a of Ke){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||$.useBookingSaves.getState().mark({id:t,table:e,why:is()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||W.useTempSaves.getState().mark({id:t,table:e,why:gs(e)??'this screen could not send it'})}};Ke=i.map(t=>new H.EntityBridge(t,e,l)),await Promise.all(Ke.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,K.isOnline)())try{const t=await Pa('whoami');if(!t?.some(t=>t.venue_id===e))return void(Ba===a&&qa())}catch(e){if(Ca(e)){if(G.IS_CAR)return void(Ba===a&&qa());const e=await Aa();return void('ok'!==e&&'refused'!==e||Ba===a&&qa())}}let t=0;for(const[a,s]of Ke.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(Se.useChatSync.getState().error&&Se.useChatSync.setState({error:void 0}),await Wt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&Se.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({mode:'live',lastSyncAt:e,lastServerAt:e}),F.mutationQueue.flush()}else Ce({mode:'offline'});if(!De('wages.view')){const e=Ae.getState().staffRef;ie.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const m=new Map;for(const e of Ke)m.set(e.spec.table,[...m.get(e.spec.table)??[],e]);const h=[...m.keys()].filter(e=>Fa.has(e)).map(e=>({table:e,venueColumn:m.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,H.venueChannel)(e,h,(e,t,a)=>{for(const s of m.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ce({lastSyncAt:s,lastServerAt:s})},e=>{Ce({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Pe.push(()=>{Re().removeChannel(w)}),Pe.push((0,K.onConnectivity)(e=>{e&&p()}));const v=Ke.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,P.superviseSync)({fastMs:Qa(Ee),readFast:async()=>{for(const e of v)await e.read()},readAll:p,flush:()=>{F.mutationQueue.flush()},wake:()=>{F.mutationQueue.retryNow()},restart:()=>{Ba===a&&qa()},realtime:()=>Ae.getState().realtime,lastServerAt:()=>{const e=Ae.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Ca,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>Wa(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Pe.push(k.stop)}async function Wa(e){const t=Ae.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Pa('sync_heartbeat',{p_venue:e,p_device:(0,A.deviceId)()??'unknown',p_app:Ee,p_version:x.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Qa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ae.getState(),queue:F.mutationQueue.pending.map(e=>e.table),failedTables:F.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),fe.PITCH&&(window.__ccSyncPreview=e=>Ce(e)));const Ha='guest:sent:v1';async function Va(e){Ce({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Pa('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!d.IS_ISOLATED_VENUE||t.id===d.VENUE_UUID)){Ce({venueId:t.id,venueName:t.name}),await ws(e);const a=t.app?.restaurant;a&&V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withWildingsAddress)({...a,id:e}):t)})),Kt(e,t.app?.events)}await Ga(e),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ce({mode:(0,K.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Ga(e).catch(()=>{})},6e4);Pe.push(()=>clearInterval(t)),d.IS_ISOLATED_VENUE||await Ja(e)}async function Ga(e){const t=await Pa('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));X.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&V.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))]}});try{const t=await Pa('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function Ja(e){let t=await q.kv.get(Ha,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=V.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Ka())return;for(const a of n)try{const s=(await Pa('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(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&&V.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'},Ce({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Pa('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(a.allergies)}}))?.[0];t={...t,[a.id]:'order'},s&&V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?Za(e,s):e)}))}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ce({lastError:`Order: ${s}`}),V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:Ya(s)}}:e)})))}await q.kv.set(Ha,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Pa('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await q.kv.set(Ha,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Pa('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));V.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=Za(e,a);return za(s)===za(e)?e:s})})),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ce({mode:(0,K.isOnline)()?Ae.getState().mode:'offline'})}finally{a=!1}}};Pe.push(V.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Ma=setInterval(()=>{n()},15e3),Xa=()=>{n()},n()}const za=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function Za(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const Ya=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let Xa=null;const es={bridges:()=>Ke,restart:qa};function ts(){const e=Ae.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!De('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function as(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(!e||ts())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(F.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function ss(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}as();try{await F.mutationQueue.retryNow()}catch{}}Ae.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{ss()},3e3)});const ns=['bookings','walk_ins'];function is(){const e=Ae.getState();return Ue()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const rs=()=>Ke.filter(e=>ns.includes(e.spec.table)),os=e=>F.mutationQueue.failed.some(t=>ns.includes(t.table)&&t.rowKey===e);function ds(e=!1){return is()?0:rs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&os(t)&&!!$.useBookingSaves.getState().notSaved[t]),0)}async function us(e=!1){const t=is();if(t)return t;for(const e of rs())try{await e.read()}catch{}ds(e);try{await F.mutationQueue.retryNow()}catch{}return e&&cs(),null}function cs(){const e=rs()[0]?.venueId??'',t=$.useBookingSaves.getState(),a=new Set(rs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||os(s)||ns.some(t=>F.mutationQueue.hasPending(t,e,s))||t.clear(s)}F.mutationQueue.onFailed(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().clear(e.rowKey)});let ls=null;const fs=(e=2500)=>{ls&&clearTimeout(ls),ls=setTimeout(()=>{ls=null,us(!1)},e)};(0,K.onConnectivity)(e=>{e&&fs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&fs(3e3)});const ps=['temp_readings','temp_units'];function gs(e="temp_readings"){const t=Ae.getState();return Ue()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ye()?'device'!==t.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ms=()=>Ke.filter(e=>ps.includes(e.spec.table));async function _s(e=!1){const t=gs();if(t)return t;for(const e of ms())try{await e.read()}catch{}const a=ms()[0]?.venueId??'';for(const t of ms())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,F.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await F.mutationQueue.retryNow()}catch{}if(e){const e=W.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ms().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||F.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,W.tempKey)(t.table,t.id))}}return null}F.mutationQueue.onFailed(e=>{ps.includes(e.table)&&W.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ps.includes(e.table)&&W.useTempSaves.getState().clear((0,W.tempKey)(e.table,e.rowKey))});let Ss=null;const hs=(e=3e3)=>{Ss&&clearTimeout(Ss),Ss=setTimeout(()=>{Ss=null,_s(!1)},e)};(0,K.onConnectivity)(e=>{e&&hs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3500)});const ys='golive:v1:';async function ws(e){'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)?await Os(e):(await q.kv.get(ys+e,!1)||await Os(e),await q.kv.get(ks+e,!1)||(Is(e),await q.kv.set(ks+e,!0)),await q.kv.get(vs+e,!1)||(bs(),await q.kv.set(vs+e,!0)))}const vs='golive:v3:';function bs(){const e=e=>JSON.stringify(e).includes('(example)');try{se.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ks='golive:v2:';function Is(e){const t=e=>JSON.stringify(e).includes('(example)');V.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)))})),ie.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 Os(e){if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)){const t=(0,g.stripCoreLiveSamples)(V.useStore.getState()),a=(0,se.stripKitchenExamples)(se.useKitchen.getState()),s=ie.useOwner.getState(),n=(0,g.stripOwnerLiveSamples)(s),i={accidents:ne.useSafety.getState().accidents.filter(e=>!(0,ne.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(V.useStore.getState(),t)&&(await(0,m.archiveChefCache)('core',V.useStore.getState()),V.useStore.setState(t)),r(se.useKitchen.getState(),a)&&(await(0,m.archiveChefCache)('kitchen',se.useKitchen.getState()),se.useKitchen.setState(a)),r(s,n)&&(await(0,m.archiveChefCache)('owner',s),ie.useOwner.setState(n)),r(ne.useSafety.getState(),i)&&(await(0,m.archiveChefCache)('safety',ne.useSafety.getState()),ne.useSafety.setState(i));const o=(0,C.stripHrSamples)(C.useHr.getState());r(C.useHr.getState(),o)&&(await(0,m.archiveChefCache)('hr',C.useHr.getState()),C.useHr.setState(o));const d=(0,_.stripGpSamples)(_.useGpCalc.getState());r(_.useGpCalc.getState(),d)&&(await(0,m.archiveChefCache)('gp',_.useGpCalc.getState()),_.useGpCalc.setState(d));const u=ee.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,m.archiveChefCache)('order-sheets',u),ee.useOrderSheets.setState(c));const l=X.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,p.isLiveVenue)(e.restaurantId)||!(0,y.isDemoCard)(e)),log:l.log.filter(e=>!(0,y.demoActor)(e.by))};return r(l,f)&&(await(0,m.archiveChefCache)('recipe-cards',l),X.useCardStore.setState(f)),void await q.kv.set(ys+e,!0)}const t=t=>t.restaurantId===e&&!(0,re.isUuid)(t.id);V.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)))})),z.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,re.isUuid)(t.id))})),Z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ie.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,re.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,re.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,re.isUuid)(e.id)),leave:e.leave.filter(e=>(0,re.isUuid)(e.id)),swaps:[]}));try{se.useKitchen.setState(e=>(0,se.stripKitchenExamples)(e))}catch{}ie.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,re.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId))}));try{ne.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await q.kv.set(ys+e,!0)}const Rs=(e,t)=>je({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function As(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(Z.useFloor.getState().live[e]??{}).map(([e,t])=>Rs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ae.getState().kind||De('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:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>Rs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>Z.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=>Z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Cs(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(ae.useSetup.getState().sites[e]?.grades??ae.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:()=>De('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=ae.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));ae.useSetup.getState().patch(e,{grades:i})},subscribe:t=>ae.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ds='staff-avatars',Us=new Map;let Es=!1;const Ts=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ns(){if(!Es){Es=!0;try{for(const[e,t]of Us){const a=te.useAvatars.getState().photos[e];if(!t){a?.path&&te.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ae.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Ds).download(t);if(n||!s)continue;const i=await Ts(s);i.startsWith('data:image/')&&te.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{Es=!1}}}function Ks(e){const t=async()=>{const t=Ae.getState().staffRef,a=t?pt.get(t)??Ae.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ae.getState().kind)return;const s=te.useAvatars.getState().photos[t];try{const n=Us.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Ds).remove([t]).catch(()=>{})};if(!s){const e=!!te.useAvatars.getState().clears?.[t];return e&&n&&(await Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}),Us.set(t,null),i(n)),void(e&&te.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ce({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Ds).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Pa('set_staff_avatar',{p_staff_ref:t,p_path:d}),Us.set(t,d),n!==d&&i(n),te.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ce({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:te.useAvatars.getState().photos},s=te.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),De('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ae.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Us.set(t,null),te.useAvatars.getState().doneClear(t),Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Ds).remove([e])).catch(()=>{})}});return t(),s}const Ps=new Map,Ms=(0,E.create)(()=>({n:0}))},987,[988,5,989,932,6,832,837,833,838,990,994,995,835,997,999,1000,1001,1002,1003,13,1004,1006,1009,1010,846,933,976,1011,1012,1013,1016,977,1017,1015,1020,1014,1021,1022,1023,1024,831,872,1025,1026,1029,983,883,1031,926,927,1033,1034,891,870,1036,1039,1040,1041,1042,2,1043,1044,1045,1046,1047,1048,979,981,884,863,859,1049,1052,1053]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},988,[846]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},990,[837,34,838,5,839,846,849,991,863,870,992,993]); +__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},991,[984]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},992,[991]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},993,[991,992]); +__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},994,[]); +__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},995,[835,837,838,5,839,846,849,996,831,884]); +__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'}}]},996,[]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},997,[6,998]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},999,[846]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},1000,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1001,[846]); +__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1002,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1003,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1004,[839,846,849,5,872,1005,15,1003]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1005,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1006,[838,835,837,5,839,846,849,1007,870]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1008,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1009,[839,846,849,863,1010,870]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1010,[]); +__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)))},1011,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1012,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1013,[34,1014]); +__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1014,[1011,977,1015]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1015,[1011]); +__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.3.12.172'},1016,[]); +__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1017,[1018,1019,933,977,1014]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1019,[977]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1020,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1021,[846,849,839]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1022,[846,849,839]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1023,[1024]); +__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1024,[1018,933,1011,977,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1025,[]); +__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1026,[860,839,870,846,849,858,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1028,[891,1004,1027]); +__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1029,[5,860,839,1030,846,849,859]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1030,[1008]); +__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1031,[837,838,5,839,846,849,1032]); +__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1032,[984]); +__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1033,[837,984,838,835,5,839,846,849]); +__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1034,[837,838,5,839,846,849,1035]); +__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1035,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1036,[839,846,849,863,1037,15,870,1038]); +__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1037,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1038,[]); +__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1039,[34,839,846,849,863,13,870]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1040,[839,846,849,863,1041,870,1038]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1041,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1042,[5,997,839,846,849,998]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1043,[1039]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1044,[839,846,849,863,1045,870]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1045,[]); +__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},1046,[846]); +__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(':')}`},1047,[839,846,849]); +__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{}}},1048,[236,872]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1049,[995,1050,1051,976,933]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1051,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1052,[933,987,999]); +__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1053,[1054]); +__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1054,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1055,[34]); +__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1056,[34,236,402,102,846,821,794,1055,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1057,[34,102,794,1058,821,1059,25]); +__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1058,[827,34,379,236,402,102,821,987,1059,2,872,1016,5,796,797,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1059,[1060,933,987,872,236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1060,[]); +__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1061,[827,796,34,402,102,794,821,1044,1045,1010,1001,870,891,25]); +__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1062,[828,1063,796,827,34,281,283,364,336,402,102,426,794,821,1039,831,13,1064,1065,1001,1075,1080,1081,1084,1085,1086,1093,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1063,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1064,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1065,[34,876,1066,1067,1064]); +__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1066,[839,846,849]); +__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1067,[6,1068,1069,1070,1071,1072,1073,1074,3]); +__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1068,[]); +__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1069,[]); +__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1070,[]); +__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1071,[]); +__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1072,[]); +__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1073,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1074,[1064]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1075,[236,933,987,1076]); +__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})},1076,[499,1077,1079,1078]); +__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1077,[499,1078,1079]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1078,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1079,[1078]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1080,[933,987]); +__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1081,[34,281,236,102,794,1039,13,1082,821,1083,25]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1082,[13]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1083,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1084,[827,2,34,102,794,821,1039,891,13,987,1001,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1085,[13]); +__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1086,[34,1063,281,402,102,794,1087,1088,1092,1093,821,25]); +__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1087,[34,402,102,794,821,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1088,[837,34,874,891,858,872,1025,987,1089,1004,15,1091]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1089,[1090]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1090,[1091]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1091,[858]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1092,[34,872,1093,858,987,933]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1093,[]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1094,[34,1095,891,1009,1010,1001,1047,831,1098]); +__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1095,[997,1042,891,998,1096,1097]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1096,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1097,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1098,[]); +__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1099,[34,986,402,102,1100,794,874,1101,858,1102,821,25]); +__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)'}})]})}},1100,[34,281,283,364,102,1048,821,25]); +__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1101,[861,859]); +__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1102,[34,402,102,794,1101,858,821,25]); +__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1103,[34,102,794,874,877,821,25]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1104,[860,34,102,794,874,1026,1029,1105,1106,877,821,25]); +__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1105,[1029,859,1101]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1106,[860,877]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1107,[860,34,102,794,874,983,891,1101,858,821,25]); +__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1108,[828,827,1056,34,336,379,236,402,102,794,821,1040,1041,1001,1109,1110,987,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1109,[1076,236]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1110,[839,846,849]); +__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1111,[827,997,34,379,402,102,794,821,1036,1037,891,1040,1041,1042,998,1096,987,1059,1001,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1112,[34,1036,891,1040,1113,1009,831,1037,1001,1094]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1113,[846]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1114,[997,34,1042,891,831,998,1010,1096,1001,1095]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1115,[860,34,1001,874,1101,1048]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1116,[860,1117,34,102,794,874,1101,821,1118,1107,1119,1140,1143,1099,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1117,[34,102,14,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1118,[821]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1119,[34,102,1120,821,1121,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1120,[860,1105]); +__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1121,[1122,860,34,1123,987,1125,402,102,874,1029,1120,1124,821,858,794,1126,1026,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1122,[34,859,821,794,25]); +__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1123,[34,402,102,874,1124,1125,987,1021,821,1121,794,25]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1124,[860,1105]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1125,[281,236]); +__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1126,[827,1127,1128,860,867,14,1129,1130,34,859,402,102,872,1088,874,1131,1105,858,821,864,794,1029,1026,1132,1133,1138,1107,1101,1139,1124,1123,25]); +__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1127,[34,402,412,102,1128,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1128,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1129,[34,102,794,25]); +__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1130,[34,236,402,295,102,426,821,794,1001,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1131,[878,858,877]); +__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1132,[34,402,102,878,858,821,794,25]); +__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1133,[860,877,34,102,879,1134,1135,1137,794,874,1029,983,861,867,872,1101,821,25]); +__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1134,[34,402,821,794,25]); +__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1135,[828,860,1136,34,281,236,102,1029,1105,821,794,1107,859,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1137,[34,402,102,874,861,863,821,794,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1138,[1128,1120,1124]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1139,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1140,[1141,34,102,874,1029,1124,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1141,[34,102,874,1029,1120,1142,1124,821,1004,891,872,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1142,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1143,[34,1063,1127,102,874,1029,1026,876,872,1138,861,1004,891,1027,1120,821,858,1132,1117,1129,1144,14,1141,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1144,[34,102,874,872,1138,14,1125,821,794,25]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1145,[34,102,794,1063,1093,1146,1092,1086,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1146,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1147,[34,102,794,827,1034,891,835,1148,821,1149,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1148,[1035]); +__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1149,[34,402,102,1125,987,1150,1022,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1150,[933,976,1011,1019,1014,1017,1151,1152,1153,1154,1155,1156,977]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1151,[1019,933,1017]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1152,[1019,933,976,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1153,[1011,976,1152,1014,1017,1151]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1154,[933,977]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1155,[34,1014]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1156,[933]); +__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1157,[30,34,426,102,846,872,1088,1158,25]); +__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1158,[839,846,849]); +__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()},1159,[1160]); +__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1160,[1161,858,884]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1161,[1162,877,1163,878,858,884,1164]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1162,[858]); +__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'},1163,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1164,[858]); +__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1165,[978,34,835,402,102,874,891,1166,1161,794,821,1088,1159,1033,15,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1166,[34,102,794,874,1039,884,1167,831,13,1164,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1167,[34,884]); +__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1168,[34,402,102,794,867,821,1160,1159,1165,1033,25]); +__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1169,[34,402,102,794,874,1161,858,821,1170,1166,1165,25]); +__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1170,[828,34,283,364,236,102,426,797,794,827,821,1171,25]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1171,[]); +__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1172,[827,984,1173,835,860,1174,1175,34,402,295,102,794,874,882,1176,891,994,861,867,1179,858,821,1180,1113,1088,1160,1159,1181,869,1165,1033,925,1182,1004,987,1185,989,1098,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1173,[1159,984]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1174,[827,34,102,794,874,979,891,980,981,982,831,821,25]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1175,[]); +__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1176,[827,796,34,336,402,102,821,794,874,1177,1056,882,861,863,885,1109,1178,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1177,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1178,[]); +__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])},1179,[858]); +__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1180,[928,828,827,837,5,34,1056,336,402,102,794,891,858,821,1088,1025,925,1047,1046,987,1113,1098,25]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1181,[828,34,102,794,876,831,869,821,925,25]); +__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1182,[928,828,34,395,236,402,102,925,794,926,891,1183,927,831,5,1184,987,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1183,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1184,[933,976,987,977]); +__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1185,[34,402,102,794,891,989,1098,994,987,1091,858,1125,821,25]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1186,[1173,984,34,379,102,794,891,994,867,821,1088,1165,1033,1187,25]); +__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1187,[827,835,984,34,379,236,402,102,794,1031,983,985,867,1032,821,1165,25]); +__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1188,[984,872,34,986,1189,336,402,102,1190,794,985,983,1031,821,874,1101,858,1125,987,25]); +__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1189,[5,822,823,828,236,826]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1190,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1191,[827,1031,1173,984,34,402,102,794,891,867,821,1165,1033,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1192,[]); +__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1193,[827,1194,34,402,102,426,794,891,867,858,821,1195,1088,1065,25]); +__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1195,[34,402,102,794,821,5,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1196,[860,1102,1099,1117,34,102,846,794,874,1101,878,877,858,821,1107,1197,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1197,[34,794,874,1198,25]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1198,[379]); +__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1199,[827,1063,1194,34,1200,236,402,426,102,1202,1203,1204,794,831,891,867,1064,821,930,1212,1195,1088,1065,1205,872,1206,1210,25]); +__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1200,[34,402,102,1201,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1201,[34,797,25]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1202,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1203,[34,102,794,827,891,867,1202,821,25]); +__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1204,[827,1202,34,402,102,794,925,891,1098,858,821,1195,1088,1205,872,1206,1207,1209,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1205,[1063,1085,1093]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1206,[34,102,794,891,1039,1063,1093,1087,1205,821,872,1204,1086,1088,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1207,[1064,1208]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1208,[1064,1202]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1209,[34,102,794,827,1063,1064,1207,1125,821,1210,25]); +__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1210,[1063,34,402,102,794,827,891,1208,1064,1211,1125,821,1199,1088,1202,1207,1065,25]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1211,[]); +__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1212,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1180,1195,1088,1065,1160,987,1039,1062,13,1085,1064,2,25]); +__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1213,[828,891,1214,1194,1006,1007,34,1013,1014,236,402,295,102,794,874,1098,1204,1182,1215,1090,5,1216,1161,867,858,821,1195,1180,1088,925,1042,997,998,1095,1001,1097,1166,1164,1207,1209,1091,25]); +__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1214,[827,34,402,102,794,821,891,831,876,1006,1007,25]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1215,[34,102,794,891,1090,821,1098,25]); +__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1216,[34,402,102,794,891,858,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1217,[34,102,794,891,821,1088,1091,1215,1098,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1218,[34,102,1088,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.AccidentBook=function(n){return null}},1219,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MissedBanner=function(n){return null},e.HaccpLog=function(n){return null}},1220,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1221,[]); +__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1222,[860,1058,34,236,402,102,797,874,821,794,1223,1130,1224,25]); +__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1223,[860,34,380,236,402,102,36,821,794,796,1130,874,25,277]); +__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1224,[1225,1226,1228,1227,1229,1048,1230]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1225,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1226,[839,5,846,849,872,1048,1227]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1227,[860,236,872,1225]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1228,[34,874,861,869,867,1226,1225]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1229,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1230,[34,1226,987,933]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1231,[34,402,102,426,874,861,821,794,1222,1130,1232,25]); +__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1232,[34,102,426,874,861,1224,1048,821,794,1130,25]); +__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1233,[34,236,402,102,879,794,821,1001,1234,1235,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1234,[872,6,933,976,1001,1224,1235]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1235,[839,1236,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1236,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1237,[34,872,1234]); +__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1238,[827,796,1239,835,984,34,931,1200,395,236,402,295,102,846,794,861,1035,867,882,1034,821,1165,1159,1186,932,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1239,[34,1034,891,835]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1240,[34,402,346,102,426,821,1201,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1241,[30,34,792,872,25]); +__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1242,[860,1127,877,30,34,1243,1002,102,14,1129,1138,794,861,867,1131,858,874,987,821,1198,864,1026,1029,1105,1133,1101,1244,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1243,[827,34,236,102,25]); +__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1244,[34,402,102,878,858,1063,1245,821,794,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1245,[1063]); +__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 b}});var n=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),a=e(_r(_d[3])),l=e(_r(_d[4])),r=_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]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,t.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),x=(0,h.useMenu)(e).find(e=>e.id===b),y=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===x?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,n.useTakeawayMenu)(n=>n.byVenue[e]),S=(0,h.useStore)(n=>n.basket.restaurantId===e&&'table'===n.basket.mode),[C,B]=(0,s.useState)(()=>(x?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,s.useState)(1),[P,T]=(0,s.useState)(''),[L,O]=(0,s.useState)(!1),[D,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[q,_]=(0,s.useState)(!1),N=(0,s.useMemo)(()=>x?(0,c.effectiveAllergens)(x,C):{},[x,C]);if(!j||!x)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(N,y.allergies),Y=(x.price??0)+(x.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,n)=>e+n.priceDelta,0),z=S||j.fictional?'on':(0,n.takeawayAvail)(x,w),F=x.soldOut||!x.signOff||null===x.price||'on'!==z,Q=(e,n)=>{const t=x.optionGroups.find(n=>n.id===e);B(e=>{const s=t.choices.map(e=>e.id);return t.multi?e.includes(n)?e.filter(e=>e!==n):[...e,n]:e.includes(n)&&!t.required?e.filter(e=>e!==n):[...e.filter(e=>!s.includes(e)),n]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:x.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),_(!0)};return(0,f.jsxs)(d.Screen,{title:x.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(a.default,{testID:"dish-photo",source:k,accessibilityLabel:`${x.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===x.price?x.priceNote:(0,u.gbp)(Y)}),x.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:x.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(x.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(n=>(0,f.jsx)(d.Chip,{label:n.label,sub:n.priceDelta?`+${(0,u.gbp)(n.priceDelta)}`:void 0,selected:C.includes(n.id),onPress:()=>Q(e.id,n.id)},n.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:x,map:N,declared:y.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:x.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&x.signOff&&null!==x.price?'This dish isn\u2019t on the takeaway menu. You can have it when you eat in.':x.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(l.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${x.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1246,[988,30,34,336,102,1247,1249,794,861,867,874,882,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1247,[34,1248,102,861,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1248,[2,987]); +__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])},1249,[30,34,402,874,821,794,25]); +__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1250,[30,34,794,1251,874,1233,25]); +__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])},1251,[34,402,821,794,25]); +__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1252,[837,30,34,1253,794,867,874,821,1254,1258,25]); +__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:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1253,[34,385,102,874,867,821,794,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1254,[34,102,794,867,1255,1256,1257,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1255,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1256,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1257,[933,987,1256]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1258,[846,933,976,987,2,1255]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),I=_r(_d[23]),O=_r(_d[24]),R=_r(_d[25]),A=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),C=_r(_d[29]),_=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const M=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let $=!1,E=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,k.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,k.useRestaurant)(e),l=(0,k.useMenu)(e),a=(0,k.useCustomer)(),s=(0,k.useBasket)(),n=(0,k.useStore)(e=>e.startBasket),o=(0,k.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[U,V]=(0,u.useState)(!1),[Q,Y]=(0,u.useState)('takeaway'===M?'takeaway':'main');c.default.useEffect(()=>{M&&!$&&($=!0,'book'===M?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,k.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>d.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{C.START_LOYALTY_CODE&&!E&&(E=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,k.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||k.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=l.filter(e=>!('All'!==r&&e.section!==r||'takeaway'===Q&&'off'===ne(e))),re=(0,j.hoursFor)(t,o),ie=e=>()=>d.router.push(`/customer/${t.id}${e}`),de=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>V(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:ie('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:ie('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:ie('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:ie('/refer')},{icon:'gift',label:'Gift cards',on:ie('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:ie('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:ie('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:ie('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:ie('/feedback')},{icon:'hanger',label:'Lost property',on:ie('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:ie('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[re?`Kitchen today ${(0,j.kitchenHoursOn)(t,o)[0]}\u2013${(0,j.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:de.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:de.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=Q===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===Q?(0,v.jsx)(A.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===Q?(0,v.jsx)(m.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==Q?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==Q||oe.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==Q?se.filter(e=>('All'===r||e===r)&&oe.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),oe.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?'Not on the takeaway menu':'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:U,onClose:()=>V(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{V(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1259,[1260,1269,5,1270,1271,1272,1275,860,30,34,236,402,102,1247,1249,794,861,867,878,874,988,821,1276,1233,872,891,1277,995,996,1004,1279,1258,25]); +__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1260,[34,379,794,873,1261,1262,1268,874,5,6,25]); +__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1261,[34,379,102,794,997,998,1096,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1262,[6,34,933,794,1263,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1263,[6,1063,1264,1265,1266,34,102,827,794,821,11,1267,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1265,[4,11]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1266,[11]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1267,[6,933]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1268,[34,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1269,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1270,[34,102,794,1263,25]); +__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1271,[34,379,933,794,873,1261,1263,4,25]); +__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1272,[34,379,794,1261,873,1262,8,1273,25]); +__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1273,[34,102,794,1274,25]); +__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1274,[]); +__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1275,[34,794,873,1261,1262,874,9,25]); +__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1276,[34,402,102,426,794,821,1201,25]); +__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1277,[828,34,336,395,402,295,102,1247,794,995,861,996,858,821,1049,25,1278]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1278,[]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1279,[34,102,1280,794,874,1004,1255,1258,821,25]); +__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1280,[34,102,1281,821,25]); +__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1281,[1282]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1282,[34,797,1283,1312,1313,25]); +__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1283,[1284]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1284,[1285,1286,1309,1311]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1285,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1286,[1287,1288,1289,1290,1291,1292,1293,1294,1295,1298,1302,1299,1303]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1287,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1288,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1289,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1290,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1295,[1296]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1299,[1300,1301]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1300,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1301,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1304,[1299]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1305,[1299]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1307,[1299,1287]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1308,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1309,[1310]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1311,[1310]); +__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1312,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1313,[34,797,1314,25]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1314,[]); +__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1315,[30,34,794,874,891,25]); +__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1316,[837,30,34,102,1280,794,867,874,821,1279,1258,25]); +__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1317,[837,30,34,102,1253,794,874,891,867,858,821,1254,1258,25]); +__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1318,[837,30,34,794,874,891,858,821,1279,1258,25]); +__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1319,[837,30,34,794,874,891,821,1279,1258,25]); +__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1320,[30,34,794,858,1161,1321,874,821,25]); +__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}},1321,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1322,[30,1101,34,402,102,794,858,874,821,25]); +__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 v}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),o=_r(d[3]),r=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),k=_r(d[15]),p=_r(d[16]),f=_r(d[17]);function v(){const e=(0,b.useBasket)(),v=(0,b.useRestaurant)(e.restaurantId??void 0),w=(0,b.useAllMenu)(e.restaurantId??void 0),C=(0,b.useCustomer)(),S=(0,b.useOrders)(v?.id),T=(0,b.useStore)(e=>e.setLineQty),B=(0,b.useStore)(e=>e.overrideLine),P=(0,b.useStore)(e=>e.startBasket),I=(0,b.useNow)(15e3),[O,$]=(0,a.useState)(null),[N,M]=(0,a.useState)(!1),[F,L]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,r.startForm)()),[A,R]=(0,a.useState)(''),[Y,D]=(0,a.useState)(C.phone??''),[E,_]=(0,a.useState)(C.email??''),[q,H]=(0,a.useState)(C.name&&'Guest'!==C.name?C.name:''),[G,V]=(0,a.useState)(!1),K=(0,b.useOrderAtTable)(e.restaurantId??void 0),Q=(0,p.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{K||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[K,e.mode]);const[U,J]=(0,a.useState)(null),[W,X]=(0,a.useState)(!1),Z=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,w,C.allergies),[e,w,C.allergies]);if(!v||!e.lines.length)return(0,f.jsxs)(i.Screen,{title:"Your basket",children:[(0,f.jsx)(i.Muted,{children:"Your basket is empty."}),(0,f.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ee=K&&'table'===e.mode,le=(0,h.takeawaySlots)(v,S,I),te=Z.reduce((e,l)=>e+l.unitPrice*l.qty,0),ae=Z.some(e=>e.contains.length&&!e.overridden),ne=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ee&&'on'!==(0,p.takeawayAvail)(l,Q)}),oe=!ee&&!O,re=!ee&&v.settings.takeawayPaused,se=(0,x.ukPhone)(Y),ie=q.trim().length>=2&&'guest'!==q.trim().toLowerCase(),de=ee||(0,p.takesCardTakeaway)(v,k.IS_ISOLATED_VENUE),ue=!G&&de&&!ae&&!ne.length&&N&&!oe&&!re&&(ee||ie&&se.ok&&(0,x.emailOk)(E)),ce=async()=>{V(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ee?void 0:O,tip:0,notes:F,phone:ee?void 0:se.pretty,email:ee?void 0:E.trim()||void 0,customerName:ee?void 0:q.trim()});(0,r.rememberGuard)(e.id,(0,r.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{V(!1)}},he=e.lines.find(e=>e.key===U),me=he?Z[e.lines.indexOf(he)]:void 0;return(0,f.jsxs)(i.Screen,{title:"Your basket",subtitle:`${v.name} \xb7 ${ee?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,f.jsx)(i.T,{weight:"bold",size:20,colour:j.colours.gold,children:(0,c.gbp)(te)})]}),de?ae?(0,f.jsx)(i.T,{size:14,colour:j.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):N?oe&&!re?(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Choose a collection time."}):ee||ie?ee||se.ok?null:(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your mobile number."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your name for the order."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Confirm your allergies to continue."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ee?(0,f.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!ue,onPress:()=>ce(),testID:"send-table-order"}):(0,f.jsx)(i.Button,{label:G?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(te)}`,disabled:!ue,onPress:()=>ce(),testID:"checkout"}),ee?null:(0,f.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ee||e.tableNo,null),ee?(0,f.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,v.fictional?null:(0,f.jsx)(i.AllergenNotice,{phone:v.phone}),Z.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,f.jsxs)(i.Card,{highlight:l.contains.length?j.colours.red:l.may.length?j.colours.amber:void 0,children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,f.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,f.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,f.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,f.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,f.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,f.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${C.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,f.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{X(!1),J(a.key)}})]})]}):l.contains.length?(0,f.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,f.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ne.includes(a)?(0,f.jsx)(i.Badge,{kind:"amber",label:!ee&&Q&&w.find(e=>e.id===a.itemId)&&'sold-out'===(0,p.takeawayAvail)(w.find(e=>e.id===a.itemId),Q)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Stepper,{value:a.qty,onChange:e=>T(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${v.id}`)}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(I)]}),re?(0,f.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===le.length?(0,f.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(i.Muted,{children:["15-minute slots, max ",v.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:le.slice(0,16).map(e=>(0,f.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:O===e.time.toISOString(),onPress:()=>$(e.time.toISOString())},e.label))})]})]}),(0,f.jsxs)(i.Card,{highlight:N?void 0:j.colours.amber,children:[(0,f.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:C.allergies.length?C.allergies.map(e=>(0,f.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,f.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,f.jsx)(i.Toggle,{label:C.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:N,onChange:M}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.H2,{children:"Your details"}),(0,f.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:q,onChangeText:H,autoComplete:"name",placeholder:"e.g. Sam Smith"}),q&&!ie?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"Please add your name."}):null,(0,f.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:Y,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!se.ok&&Y?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:se.error}):null,(0,f.jsx)(i.Field,{label:"Email (optional)",value:E,onChangeText:_,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,x.emailOk)(E)?null:(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,f.jsx)(i.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,f.jsx)(i.Field,{label:"Order notes (optional)",value:F,onChangeText:L,placeholder:"e.g. cutlery please"}),ee?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>P(v.id,'takeaway')}):null,(0,f.jsxs)(i.Sheet,{visible:!!he,onClose:()=>J(null),title:"Allergy override",children:[me?(0,f.jsx)(i.Banner,{kind:"danger",title:`${me.name} contains ${me.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,f.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:W,onChange:X}),(0,f.jsx)(i.Button,{kind:"danger",disabled:!W,label:"Confirm override",onPress:()=>{he&&me&&B(he.key,me.contains),J(null)}})]}),(0,f.jsx)(o.Honeypot,{value:A,onChange:R})]})}},1323,[860,30,34,1243,1002,102,794,861,867,1131,858,874,831,821,864,5,988,25]); +__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1324,[30,34,102,1249,794,861,878,874,821,1276,5,25]); +__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 f}});var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1325,[860,30,34,102,1251,794,861,867,858,874,821,1326,25]); +__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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1326,[34,371,379,236,30,794,867,821,988,1327,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1327,[933,987]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1328,[860,1258,30,34,102,794,861,867,858,874,879,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1329,[30,34,872,25]); +__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1330,[837,30,34,794,874,5,1258,25]); +__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1331,[30,34,794,1332,1175,1258,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1332,[827,860,34,102,794,861,867,1175,1333,874,821,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1333,[933,987,1175]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1334,[30,34,872,1335,1399,25]); +__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1335,[1162,796,5,6,1336,828,853,1122,860,1161,1337,1338,1339,1119,1143,1340,1341,1346,1347,1348,872,1349,1174,979,1130,1350,34,1099,1196,1048,1115,1157,1351,395,380,402,295,102,426,36,794,1233,1237,873,861,858,874,821,1118,891,1126,1088,1029,1105,1135,1352,1134,1353,1360,1362,1365,1368,1364,1369,1371,1372,1140,1123,1124,878,1376,1222,1377,1232,1224,1026,1382,1390,1391,1102,1142,1393,1394,1395,1098,1189,1396,1188,1181,869,1397,1398,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1337,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1338,[1027,1088]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1339,[34,102,1105,794,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1340,[860,34,102,794,874,1175,821,25]); +__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1341,[34,395,402,426,102,1280,794,1189,796,1029,1342,1343,1345,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1342,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1343,[34,395,402,295,412,102,426,796,794,821,1344,1345,25]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1344,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1345,[1025,872,1344,933,987]); +__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1346,[846]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1347,[828,34,379,395,402,102,794,1189,821,25]); +__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1348,[34,236,402,102,794,821,891,1004,858,1098,25]); +__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1349,[828,827,34,236,402,295,102,794,1174,874,979,831,981,982,872,980,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1350,[828,34,102,821,794,25]); +__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1351,[34,102,797,821,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1352,[]); +__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1353,[828,796,827,1122,860,1130,34,236,402,295,426,102,859,821,794,1354,1355,1029,891,1134,1357,987,872,25]); +__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1354,[828,860,34,1355,102,859,821,794,1135,1356,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1355,[859]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1356,[1355,859]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1357,[34,385,295,102,859,1358,1359,821,796,827,794,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1358,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1359,[1358,1025,872,933,987]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1360,[34,236,402,102,821,794,1189,1361,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1361,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1362,[828,860,1123,34,281,236,295,102,1136,874,1029,1105,14,858,1124,1363,821,794,1364,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1363,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1364,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1365,[5,828,34,283,336,236,402,102,426,821,873,794,1030,1001,1346,1366,2,1367,1368,874,858,25]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1366,[236]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1368,[34,846,933,987,1367]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1369,[860,14,1029,1370]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1370,[861]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1371,[34,102,797,821,25]); +__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1372,[1373,860,1123,1029,34,102,794,1126,874,1375,1369,1124,858,1121,1140,1141,1142,821,1338,25]); +__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1373,[34,379,402,102,874,1004,891,1027,1374,872,821,794,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1374,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1375,[1029,1105]); +__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1376,[1373,828,1123,827,860,1161,1119,1140,858,34,1107,236,402,295,102,794,1126,1364,874,1029,861,1117,1105,1321,821,1338,25]); +__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1377,[827,34,236,402,102,794,874,1029,1378,821,1379,1381,25]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1378,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1379,[846,874,1029,1378,1380,1381]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1380,[860]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1381,[236,1380]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1382,[860,34,1200,1189,402,102,1026,1029,878,858,821,794,1383,1386,25]); +__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1383,[1384,870,860,34,281,395,402,295,102,874,1026,1029,1385,858,821,1056,794,1386,1387,987,1338,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1384,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1385,[878,858,877]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1386,[5,1029,933,987]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1387,[846,933,987,1388,2,1389]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1388,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1389,[15]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1391,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1392,[1105]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1393,[860,1370]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1394,[34,402,102,794,1393,821,1351,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1395,[34,102,925,794,1189,858,821,25]); +__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1396,[34,1189,402,102,426,794,25]); +__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1397,[828,1063,827,2,1189,34,402,102,426,794,821,891,998,858,1001,1387,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1398,[34,1036,891,1009,831,1037,1001,1387,1094]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1399,[5,828,873,34,236,402,102,426,987,821,794,1346,1400,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1400,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1401,[30,34,872,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1402,[30,34,872,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1403,[30,34,1404,872,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1404,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1405,[30,34,872,1406,25]); +__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1406,[1407,1411,828,997,1099,1412,1218,1055,1056,1413,1415,1418,1174,979,1016,1420,1013,2,1061,1062,1421,999,1039,1000,34,1176,1233,1237,1214,373,402,295,102,426,36,794,873,1157,891,821,1180,1422,1094,1112,1114,1108,1057,1040,1088,1430,1431,1432,1441,1442,1004,236,1240,1193,1199,1438,1213,1212,1451,1196,15,1219,1220,925,793,987,25]); +__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1407,[827,34,1048,395,102,1134,1135,1353,1382,794,1026,1029,858,821,1088,1030,1408,1409,1050,25]); +__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1408,[827,34,402,102,794,821,1029,5,1030,872,987,25]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1409,[34,102,794,1029,1410,859,821,1075,933,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1410,[]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1411,[34,102,794,1088,987,25]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1412,[860,34,102,794,861,867,1175,874,869,821,25]); +__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1413,[987,34,281,236,102,1280,794,1255,1258,821,1414,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1414,[34,236,102,794,1255,25]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1415,[34,796,102,794,861,1255,1416,1417,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1416,[861]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1417,[987,1416,1258]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1418,[5,1419,34,102,794,867,1255,1256,1257,987,1258,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1419,[34,794,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1420,[236,1014]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1421,[34,102,794,821,999,1052,987,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1422,[5,1419,1123,11,1423,827,837,1140,1141,1119,1143,1424,1138,1142,1393,1394,1088,1338,1027,1117,14,1144,1426,1233,1427,1382,1107,1101,1118,34,102,794,1351,874,861,867,858,1321,821,1195,1126,1029,1428,1087,1181,1429,1224,987,1197,1390,878,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1423,[6,34,102,794,987,1267,25]); +__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1424,[34,402,102,1425,987,933,821,794,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1425,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1426,[827,5,34,379,236,102,794,876,14,867,1032,933,821,1198,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1427,[34,402,1189,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1428,[34,102,874,1029,794,821,25]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1429,[34,102,879,874,864,821,794,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1430,[34,1383,1088,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1431,[860,34,102,1181,794,874,861,869,858,821,1195,1088,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1432,[835,984,1433,34,236,102,794,831,891,983,1031,985,987,1440,821,2,1182,25]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1433,[827,979,1161,987,797,1222,1224,34,281,379,236,402,102,426,879,794,874,1233,891,867,858,821,1195,1088,869,1434,1180,1438,1439,1160,1167,1166,1039,13,1164,1170,1437,25]); +__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1434,[927,796,831,828,837,878,1076,1435,34,994,336,379,236,402,102,794,874,891,858,821,1195,1088,1437,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1435,[499,1436]); +__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 t={}},1436,[]); +__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1437,[831,891,5]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1438,[827,34,1248,1056,870,379,402,102,794,891,867,858,821,1195,1088,1437,25]); +__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1439,[1016,34,402,102,794,891,821,1088,987,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1440,[]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1441,[860,34,102,794,891,1029,858,1091,1089,987,1090,5,1001,821,25]); +__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1442,[5,1443,1444,1445,1446,1447,34,236,41,102,872,1448,1004,821,1450,794,987,2,1097,1003,891,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1443,[34,102,873,794,5,6,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1444,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1445,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1446,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1447,[34,102,873,794,25]); +__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1448,[34,295,102,794,873,821,1449,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1449,[]); +__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1450,[929,828,34,1097,336,236,402,295,41,102,872,926,891,831,987,1004,15,793,821,925,794,25]); +__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1451,[1196,1099,1140,1117,34,402,102,794,891,858,821,1118,1188,1088,1193,1434,1181,876,1197,869,1195,925,1428,1029,860,1126,1212,1216,1098,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1452,[30,34,872,25]); +__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1453,[1454,987,795,1400,1456,1026,30,1483,496,34,385,336,236,41,102,5,873,872,1485,36,874,1029,891,821,1442,1004,1024,1488,1489,1058,1490,1130,2,1039,999,1508,1368,25,1510,1511,1512,1513]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1454,[2,827,34,236,383,102,794,1455,987,821,1199,1004,891,994,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1455,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1456,[1457,1480,1482]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1457,[215,1458,1461,1475,1476,1477,1478,1479]); +__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1458,[215,1459]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1459,[1460]); +__d(function(g,r,i,a,m,e,d){},1460,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1461,[1462,215,1458,1475,1476]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1462,[1463,1464,1474]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1463,[1464,1468,1473]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1464,[215,372,1465,1469,1470,1471,1472,1468,1473]); +__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1465,[215,1466,339,280,1467,1468]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1466,[504]); +__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1467,[215,339]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1468,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1469,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1470,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1471,[1469]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1472,[]); +__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1473,[372,1467]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1474,[34,1464]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1475,[1462,215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1476,[1462,1475]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1477,[1458]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1478,[215,1458,1461,1459]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1479,[]); +__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1480,[215,54,1481]); +__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1481,[215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1482,[34,1457]); +__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]}})})},1483,[1484]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1484,[]); +__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1485,[34,41,102,426,794,873,1004,987,2,5,821,1486,1487,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1486,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1487,[34,102,794,821,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1488,[990,883,882,987]); +__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1489,[828,796,827,34,1012,1408,1030,402,102,872,987,1014,1029,5,821,794,1346,976,2,25]); +__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1490,[5,796,827,34,385,283,364,380,236,402,295,426,102,1491,1157,2,797,1088,15,891,794,821,1492,932,1504,1500,1501,1505,1158,1506,931,1507,1503,25,277]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"useAssistantUi",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AssistantFab",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AssistantSheet",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"AssistantPage",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"AssistantSettings",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"AssistantPlanCard",{enumerable:!0,get:function(){return c}});const t=!1,n={getState:()=>({open:!1,setOpen:t=>{}})},u=()=>null,s=()=>null,l=()=>null,o=()=>null,c=()=>null},1491,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1492,[1493,1128,860,1494,1495,891,874,1029,1499,1500,1501,1497,1496,1502,1503,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1493,[1093,1092,1053]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1494,[984,1128,835,860,874,831,1029,983,985,1040,891,1095,882,863,861]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1495,[835,874,831,1029,891,1034,1044,1045,1010,1009,1039,13,1064,1065,1066,1035,1095,882,1105,1026,870,1496,1494]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1496,[835,979,1128,860,1161,1258,874,831,1029,1034,995,862,861,1105,1106,1026,1035,867,1497,1498]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1497,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1498,[839,846,849]); +__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1499,[828,34,283,364,236,402,102,846,794,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1500,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1501,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1502,[831,891,995,867,1496,1047,1098]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1503,[]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1504,[891,831,1029]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1505,[846]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1506,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1507,[846]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1508,[874,831,891,1039,15,1004,872,2,1509]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1509,[874,1039]); +__d(function(e,s,o,p,t,a,n){"use strict";t.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1510,[]); +__d(function(s,o,p,e,d,t,c){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1511,[]); +__d(function(o,s,p,e,d,t,f){"use strict";d.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1512,[]); +__d(function(o,s,p,d,e,t,n){"use strict";e.exports="/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1513,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1514,[30,34,872,25]); +__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1515,[1516]); +__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1516,[25,1517,591]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1517,[34,172]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1518,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1519,[25,499,34,270,651]); __r(501); __r(21); __r(0); \ No newline at end of file diff --git a/display-app/admin.html b/display-app/admin.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/admin.html +++ b/display-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer.html b/display-app/customer.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer.html +++ b/display-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage.html b/display-app/customer/anchorage.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage.html +++ b/display-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/book.html b/display-app/customer/anchorage/book.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/book.html +++ b/display-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/feedback.html b/display-app/customer/anchorage/feedback.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/feedback.html +++ b/display-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/gift.html b/display-app/customer/anchorage/gift.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/gift.html +++ b/display-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/lost.html b/display-app/customer/anchorage/lost.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/lost.html +++ b/display-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/loyalty.html b/display-app/customer/anchorage/loyalty.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/loyalty.html +++ b/display-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/merch.html b/display-app/customer/anchorage/merch.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/merch.html +++ b/display-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/offers.html b/display-app/customer/anchorage/offers.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/offers.html +++ b/display-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/refer.html b/display-app/customer/anchorage/refer.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/refer.html +++ b/display-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/waitlist.html b/display-app/customer/anchorage/waitlist.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/waitlist.html +++ b/display-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/anchorage/whatson.html b/display-app/customer/anchorage/whatson.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/anchorage/whatson.html +++ b/display-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/basket.html b/display-app/customer/basket.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/basket.html +++ b/display-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/customer/profile.html b/display-app/customer/profile.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/customer/profile.html +++ b/display-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/demo.html b/display-app/demo.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/demo.html +++ b/display-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/display.html b/display-app/display.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/display.html +++ b/display-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/index.html b/display-app/index.html index d0ec01d33aa2cdeca4db48bd19d9b61e2d10de14..db1a4c45317fb1b9bef2aaf07219d8f5c44abdbd 100644 --- a/display-app/index.html +++ b/display-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/kitchen.html b/display-app/kitchen.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/kitchen.html +++ b/display-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/owner.html b/display-app/owner.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/owner.html +++ b/display-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/staff.html b/display-app/staff.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/staff.html +++ b/display-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/display-app/sw.js b/display-app/sw.js index bb88c88d1cc9a0bafa7fe1c808401ae437786976..8d8ebc78a33b611fbede8cc28d6aa7d67d1a6ef3 100644 --- a/display-app/sw.js +++ b/display-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Display service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-display-d5fef31ce5"; +const V = "cc-display-d297460ee8"; const BASE = "/display-app/"; -const PRECACHE = ["/display-app/apple-touch-icon.png", "/display-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/display-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/display-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/display-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/display-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/display-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/display-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/display-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/display-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/display-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/display-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/display-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/display-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/display-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/display-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/display-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/display-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/display-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/display-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/display-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/display-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/display-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/display-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/display-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/display-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/display-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/display-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/display-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/display-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/display-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/display-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/display-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/display-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/display-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/display-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/display-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/display-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/display-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/display-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/display-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/display-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/display-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/display-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/display-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/display-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/display-app/brand-logo.png", "/display-app/favicon.ico", "/display-app/icon-192.png", "/display-app/icon-512.png", "/display-app/icon-maskable-192.png", "/display-app/icon-maskable-512.png", "/display-app/manifest.webmanifest", "/display-app/index.html", "/display-app/_expo/static/js/web/bundle.js?v=d5fef31ce53702284c388b3ab8f7db14ec1d3b9a59f8efa5ef721b81119a54d0"]; +const PRECACHE = ["/display-app/apple-touch-icon.png", "/display-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/display-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/display-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/display-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/display-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/display-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/display-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/display-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/display-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/display-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/display-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/display-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/display-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/display-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/display-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/display-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/display-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/display-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/display-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/display-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/display-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/display-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/display-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/display-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/display-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/display-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/display-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/display-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/display-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/display-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/display-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/display-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/display-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/display-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/display-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/display-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/display-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/display-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/display-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/display-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/display-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/display-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/display-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/display-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/display-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/display-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/display-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/display-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/display-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/display-app/brand-logo.png", "/display-app/favicon.ico", "/display-app/icon-192.png", "/display-app/icon-512.png", "/display-app/icon-maskable-192.png", "/display-app/icon-maskable-512.png", "/display-app/manifest.webmanifest", "/display-app/index.html", "/display-app/_expo/static/js/web/bundle.js?v=d297460ee8af8c134d0bf4fb97c0154ae208b0e8f843968a4d5619d60059d438"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/display-app/team.html b/display-app/team.html index cfdab3a80dc348b5cdf39f1d0583252aaa26cac3..0e16e64e656b1f64e07b7953d3cd7be5adfe502e 100644 --- a/display-app/team.html +++ b/display-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/index.html b/index.html index 98357e11d6770c286df60a0ec3663bdd4aff2bc5..dda103ebbff2e6d858ffc87735deae2280c16303 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ -Cover Charge: try the apps (v0.3.12.171) +Cover Charge: try the apps (v0.3.12.172) @@ -63,7 +63,7 @@ footer{margin-top:28px;color:var(--muted);font-size:.8rem;text-align:center} Cover Charge logo

covercharge

All in one restaurant booking app

-

Cover Charge: try the apps (v0.3.12.171)

+

Cover Charge: try the apps (v0.3.12.172)

The Anchorage, Harbour View, Dunure

@@ -129,7 +129,7 @@ footer{margin-top:28px;color:var(--muted);font-size:.8rem;text-align:center}
-

Cover Charge v0.3.12.171

+

Cover Charge v0.3.12.172

diff --git a/owner-app/_expo/static/js/web/bundle.js b/owner-app/_expo/static/js/web/bundle.js index 3b8afc1d1ba06be783564a0e6545b83dae148b94..95c52728c95e39d1e2f60ea83b620c228105c925 100644 --- a/owner-app/_expo/static/js/web/bundle.js +++ b/owner-app/_expo/static/js/web/bundle.js @@ -23,11 +23,11 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_VENUE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PITCH_TEAM",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PITCH_TEXT",{enumerable:!0,get:function(){return o}}),e.pitchText=function(a,n=!1){let l=a;for(const[a,s]of o){if(n&&t.test(a.source.replace(/\\/g,'')))continue;a.test(l)?(a.lastIndex=0,l=l.replace(a,s)):a.lastIndex=0}return l};const a={name:'The Harbour Kitchen',tagline:'Harbourside seafood & seasonal plates',location:'12 Quay Street, Portmorran',phone:'01632 960 123',website:'harbourkitchen.example'},n={'st-tracy':{name:'Morgan',job:'Owner',hourlyPence:null,salaried:!0},'st-gordon':{name:'Alex',job:'General Manager',dept:'Management',hourlyPence:null,salaried:!0},'st-bisto':{name:'Ravi',job:'Head Chef',hourlyPence:null,salaried:!0},'st-agate':{name:'Priya',job:'Front of house supervisor',hourlyPence:1450},'st-lenny':{name:'Tom',job:'Commis Chef',hourlyPence:1325},'st-finn':{name:'Lewis',job:'Bar staff',hourlyPence:1290},'st-eilidh':{name:'Chloe',job:'Front of house',hourlyPence:1271},'st-emily':{name:'Ellie',job:'Front of house',hourlyPence:1271},'st-lillie':{name:'Jordan',job:'Kitchen porter (KP)',hourlyPence:1271},'st-jack':{name:'Sam',job:'Kitchen porter (KP)',hourlyPence:1271}},o=[['Harbour View, Dunure, South Ayrshire',a.location],['Harbour View, Dunure',a.location],['Harbour View mug','Harbour Kitchen mug'],['Harbour View','Quay Street'],['anchoragedunure.com',a.website],['01292 502826',a.phone],['Mini Anchors','Little Crew'],['The Anchorage',a.name],['Anchorage','Harbour Kitchen'],['ANCHORAGE','HARBOUR KITCHEN'],['South Ayrshire','the Firth coast'],['Ayrshire','the Firth coast'],['Dunure','Portmorran'],['Kittyfisher boat (Big Sean)','Coastal Fish Co'],['Kittyfisher','Coastal Fish Co'],['Big Sean','Coastal Fish Co'],['Example Fish Co.','Coastal Fish Co'],['Sample Dairy Ltd','Hillside Dairy'],['Sample Fruit & Veg','Fieldfare Veg'],['Mills milk','Hillside Dairy milk'],['Mills','Hillside Dairy'],['J. Pieroni & Sons','Fieldfare Veg'],["Pieroni's",'Fieldfare Veg'],['Pieroni','Fieldfare Veg'],['Alsons (drinks)','Drinks wholesaler'],['Alsons','the drinks wholesaler'],['Spes Bona','the deli wholesaler'],['Tarelgin','the butcher'],['Reids','the bakery'],['Reeds','the bakery'],['Example Butchers Ltd','Quayside Butchers'],['Example Dry Goods Wholesale','Dry goods wholesaler'],['Sample Brewing Co.','Harbourside Brewing'],['Example Cleaning Supplies','Cleaning supplies'],['Sample Packaging Ltd','Packaging supplier'],['Example Kitchen Repairs','Kitchen repairs'],['Preston','Ravi'],['Bisto','Ravi'],['Tracy','Morgan'],['James','Morgan'],['Gordon','Alex'],['Agate','Priya'],['Lenny','Tom'],['Finn','Lewis'],['Eilidh','Chloe'],['Emily','Ellie'],['Gabrielle','Ellie'],['Cameron Mc','Sam'],['Cameron','Sam'],['Lillie','Jordan'],['Lily','Jordan'],['Mia','Jordan'],['Jack','Sam'],['Harvey','Jordan'],['Anna','the supplier'],['(preview)',''],[' (example)','']].map(([a,n])=>[new RegExp(`${/^[A-Za-z]/.test(a)?'(?g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},23,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1619,1622]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1623,1626]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},25,[26]); __d(function(g,r,i,a,m,e,d){ /** @@ -41,8 +41,8 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},26,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},27,[28]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1052,1255,1256,1260,1262,1264,1271,1325,1326,1327,1328,1329,1330,1332,1333,1334,1335,1336,1337,1338,1339,1342,1409,1410,1411,1571,1576,1577,1618]); -__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,993,25]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1053,1256,1257,1261,1263,1265,1272,1326,1327,1328,1329,1330,1331,1333,1334,1335,1336,1339,1340,1341,1342,1345,1412,1413,1414,1575,1580,1581,1622]); +__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,994,25]); __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)},30,[31,32,782,783,785]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},31,[]); __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}},32,[33,692,487,708,557,709,770,761,764,774,647,645,650,562,560,591,465,467,204,205,775,472,473,462,460,569,556,639,659,776,658,162,151,547,433,777,780]); @@ -872,9 +872,9 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},789,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},790,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},791,[]); -__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1054,1055,1015,2,1056,1060,1061,1093,858,1098,1102,1103,1106,1107,1110,1111,1113,1114,1115,1144,1146,1091,34,373,236,402,295,426,102,36,873,1156,794,867,821,1087,1158,1164,1167,1168,1171,1185,1184,1186,1187,1190,1191,1198,1201,1204,1217,1218,1222,1223,925,1003,1224,1177,1225,1232,1237,1246,1239,1175,1248,1252,1219,874,1253,1173,987,1254,25]); +__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1055,1056,1016,2,1057,1061,1062,1094,858,1099,1103,1104,1107,1108,1111,1112,1114,1115,1116,1145,1147,1092,34,373,236,402,295,426,102,36,873,1157,794,867,821,1088,1159,1165,1168,1169,1172,1186,1185,1187,1188,1191,1192,1199,1202,1205,1218,1219,1223,1224,925,1004,1225,1178,1226,1233,1238,1247,1240,1176,1249,1253,1220,874,1254,1174,987,1255,25]); __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=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.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."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.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 CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};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]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(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 v(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 b(e){const{img:t,url:a}=await f(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),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.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()})}},793,[34,336,236,402,102,794,925,929,926,821,930,25]); -__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=D,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(H,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(x.default,{style:{flex:1},children:u}),s?(0,B.jsx)(x.default,{style:N.footer,children:(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=v,_e.Card=F,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(x.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:L?'center':'flex-start'}],children:(0,B.jsx)(D,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(x.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(D,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(D,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(x.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(D,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,p.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(D,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(D,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(x.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(D,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),x=e(_r(d[14])),p=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),L='display'!==S.APP_VARIANT;function D({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),x=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,p=f.default.flatten(t)||{},j=1===p.flex||1===p.flexGrow||'number'==typeof p.width||'left'===p.textAlign,k=c??(L&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,x,(0,W.webLine)(t,r),k&&'left'!==p.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(D,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(D,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(D,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??L});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(x.default,{style:N.brandBar,children:[(0,B.jsxs)(x.default,{style:N.row,children:[(0,B.jsx)(x.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(D,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(x.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(x.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function H(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(D,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function v({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],x={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:x,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(D,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(D,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function F({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(x.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(x.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(D,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(D,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,v.centreRow=!0;const V=()=>(0,B.jsx)(E,{kind:"example",title:"Allergens awaiting kitchen verification",children:"This allergen information has not been verified by the kitchen. Head chef sign-off is required. Always speak to staff about allergies."}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Card payments: not set up yet",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===F?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(L&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(x.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=L&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(x.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(x.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); +__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(v,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(p.default,{style:{flex:1},children:u}),s?(0,B.jsx)(p.default,{style:N.footer,children:(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=F,_e.Card=H,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:D?'center':'flex-start'}],children:(0,B.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,x.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),D='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(D&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??D});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(p.default,{style:N.brandBar,children:[(0,B.jsxs)(p.default,{style:N.row,children:[(0,B.jsx)(p.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function v(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function F({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function H({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,F.centreRow=!0;const V=({phone:e})=>(0,B.jsx)(E,{kind:"warn",title:"Allergies",children:"All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===H?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(D&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=D&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},795,[]); __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.GoldX=h,_e.GoldClose=j,Object.defineProperty(_e,"TEXT_ONLY_CLOSE",{enumerable:!0,get:function(){return x}}),_e.ToastClose=function({onPress:e,label:o="Close",testID:s,size:l="md",style:c,colour:h}){return x?(0,b.jsx)(t.default,{testID:s,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:[{minWidth:64,minHeight:48,alignItems:'center',justifyContent:'center',paddingHorizontal:8},c],children:(0,b.jsx)(u.Text,{style:{fontSize:16,color:h??n.colours.text},children:"Close"})}):(0,b.jsx)(j,{onPress:e,label:o,testID:s,size:l,style:c})},r(d[0]);var t=e(r(d[1])),o=e(r(d[2])),s=r(d[3]),l=e(s),n=r(d[4]),c=r(d[5]),u=r(d[6]),b=r(d[7]);function h({size:e=16,colour:t=n.colours.gold,stroke:o}){const c=o??(e>=20?2.4:2.2);return(0,b.jsx)(l.default,{width:e,height:e,viewBox:"0 0 24 24",accessible:!1,focusable:!1,pointerEvents:"none",children:(0,b.jsx)(s.Path,{d:"M6 6 L18 18 M18 6 L6 18",stroke:t,strokeWidth:Math.min(4,c*(24/e)),strokeLinecap:"round",fill:"none"})})}const f={sm:32,md:38,lg:46},y={sm:13,md:15,lg:18};function j({onPress:e,label:s="Close",testID:l,size:c="md",style:u,disabled:j,hint:x}){const C=f[c],I=Math.max(44,C+8);return(0,b.jsx)(t.default,{testID:l,accessibilityRole:"button",accessibilityLabel:s,accessibilityHint:x,disabled:j,onPress:e,dataSet:{goldClose:'1'},style:[{width:I,height:I,alignItems:'center',justifyContent:'center',flexShrink:0,opacity:j?.4:1},u],children:({pressed:e,hovered:t})=>(0,b.jsx)(o.default,{style:{width:C,height:C,borderRadius:C/2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:e||t?n.colours.gold:n.colours.accentBorder,backgroundColor:e?n.colours.goldTint:t?n.colours.accentBg:'rgba(0,0,0,0.18)'},children:(0,b.jsx)(h,{size:y[c],colour:e?n.colours.goldLight:n.colours.gold})})})}const x=['kirkton','abbotsford'].includes(c.VENUE_RID)},796,[34,402,102,797,821,5,827,25]); __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}},797,[798]); @@ -911,7 +911,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule? __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOUTERS_BG",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SOUTERS_SURFACE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SOUTERS_TYPE_SCALE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"soutersFont",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"soutersSurface",{enumerable:!0,get:function(){return f}}),e.soutersInk=function(o){if(!t.IS_SOUTERS)return o;const c=(0,n.normaliseHex)(o);return c?'#A4622E'===c?'#D9AD8A':(0,n.contrast)(c,u)<4.5?'#FFFFFF':o:o};var t=r(d[0]),n=r(d[1]);const u='#56152A',o='#43122F',c=.88,S=n=>t.IS_SOUTERS?Math.round(n*c*100)/100:n,f=n=>t.IS_SOUTERS?o:n},828,[5,829]); __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normaliseHex=n,e.hexToRgb=r,e.rgbToHex=o,e.hsvToRgb=s,Object.defineProperty(e,"hsvToHex",{enumerable:!0,get:function(){return a}}),e.hexToHsv=function(t){const{r:n,g:o,b:s}=r(t),a=n/255,c=o/255,u=s/255,i=Math.max(a,c,u),h=Math.min(a,c,u),l=i-h;let p=0;l&&(p=i===a?(c-u)/l%6:i===c?(u-a)/l+2:(a-c)/l+4);return{h:(60*p+360)%360,s:i?l/i:0,v:i}},e.luminance=c,e.contrast=u,e.shade=i,e.checkAccent=function(t,r,o,s){const a=n(t)??'#CFA45F',c=u(a,o),h=u(a,s),l=c>=h?o:s,p=[];Math.max(c,h)<4.5?p.push('Button text may be hard to read on this colour. We picked the clearer text colour for you, but a lighter or darker shade will read better.'):l===s&&p.push('This is a dark colour, so buttons use light text.');let b=a,d=0;for(;u(b,r)<4.5&&d<20;)b=i(a,.05*(d+1)),d++;b!==a&&p.push('This colour is hard to read on the dark background, so header text uses a lighter shade of it.');return{onAccent:l,accentText:b,tips:p}},e.pushRecent=function(t,r,o=8){const s=n(r);return s?[s,...(t??[]).filter(t=>t!==s)].slice(0,o):t??[]};const t=(t,n=0,r=1)=>Math.min(r,Math.max(n,t));function n(t){const n=t.trim().replace(/^#/,'');return/^[0-9a-fA-F]{3}$/.test(n)?'#'+n.split('').map(t=>t+t).join('').toUpperCase():/^[0-9a-fA-F]{6}$/.test(n)?'#'+n.toUpperCase():null}function r(t){const r=(n(t)??'#000000').slice(1);return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function o({r:n,g:r,b:o}){return'#'+[n,r,o].map(n=>Math.round(t(n,0,255)).toString(16).padStart(2,'0')).join('').toUpperCase()}function s({h:t,s:n,v:r}){const o=(t%360+360)%360/60,s=r*n,a=s*(1-Math.abs(o%2-1)),c=r-s,[u,i,h]=o<1?[s,a,0]:o<2?[a,s,0]:o<3?[0,s,a]:o<4?[0,a,s]:o<5?[a,0,s]:[s,0,a];return{r:255*(u+c),g:255*(i+c),b:255*(h+c)}}const a=t=>o(s(t));function c(t){const n=t=>{const n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)},{r:o,g:s,b:a}=r(t);return.2126*n(o)+.7152*n(s)+.0722*n(a)}function u(t,n){const r=c(t),o=c(n);return(Math.max(r,o)+.05)/(Math.min(r,o)+.05)}function i(t,n){const{r:s,g:a,b:c}=r(t),u=n>0?255:0,i=Math.abs(n);return o({r:s+(u-s)*i,g:a+(u-a)*i,b:c+(u-c)*i})}},829,[]); __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,"isEditable",{enumerable:!0,get:function(){return u}}),_e.hideKeyboard=s,_e.installKeyboardHide=f,_e.useTyping=function(){const[e,n]=t.default.useState(c);return t.default.useEffect(()=>{if(!o)return;f();const e=()=>setTimeout(()=>n(c()),0);return document.addEventListener('focusin',e,!0),document.addEventListener('focusout',e,!0),()=>{document.removeEventListener('focusin',e,!0),document.removeEventListener('focusout',e,!0)}},[]),e},_e.useVisibleArea=function(){const e=o?window.visualViewport:null,n=()=>e?{height:Math.round(e.height),top:Math.round(e.offsetTop)}:null,[u,c]=t.default.useState(n);return t.default.useEffect(()=>{if(!e)return;const t=()=>c(e=>{const t=n();return e&&t&&e.height===t.height&&e.top===t.top?e:t});return e.addEventListener('resize',t),e.addEventListener('scroll',t),()=>{e.removeEventListener('resize',t),e.removeEventListener('scroll',t)}},[]),u};var t=e(r(d[0])),n=e(r(d[1]));r(d[2]);const o='undefined'!=typeof document,u=e=>!!e&&'function'==typeof e.matches&&e.matches("input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]"),c=()=>!!o&&u(document.activeElement);function s(){try{n.default.dismiss()}catch{}o&&u(document.activeElement)&&document.activeElement.blur()}function a(){if(!o)return;const e=document.activeElement;if(u(e))try{e.scrollIntoView({block:'nearest',inline:'nearest'})}catch{}}let l=!1;function f(){o&&!l&&(l=!0,document.addEventListener('click',e=>{if(!c())return;const t=document.activeElement;if('function'!=typeof t.closest||!t.closest('[aria-modal="true"], [role="dialog"]'))return;const n=e.target;n&&!u(n)&&('function'==typeof n.closest&&n.closest('label, [data-keep-keyboard]')||s())},!0),document.addEventListener('focusin',e=>{u(e.target)&&setTimeout(a,300)},!0),window.visualViewport?.addEventListener('resize',()=>setTimeout(a,50)))}},830,[34,376,236]); -__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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 O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:u,phone:g,email:m})=>{const p=t(),b=p.basket,f=b.restaurantId,k=w(b,p.menu,p.customer.allergies),I=k.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,h=$(p.orders.filter(e=>e.restaurantId===f).map(e=>e.ref),S?'Q-':'T-',S?p.counters.table:p.counters.order),O=u?n(o,f,I+i):0,C=I+i,v={id:(0,y.uuid)(),ref:`${S?'Q':'T'}-${h}`,restaurantId:f,customerId:p.customer.id,customerName:p.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:k,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:u?C:0,status:'new',createdAt:a().toISOString(),allergies:p.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:g??p.customer.phone,email:m??p.customer.email}:{}};e(e=>({orders:[v,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:h}:{...e.counters,order:h}}));const A=k.filter(e=>e.overridden);return r(f,'order',`Order ${v.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${A.length?` \u2014 ALLERGY OVERRIDE on ${A.map(e=>e.name).join(', ')}`:''}`),v.allergies.length&&r(f,'allergy',`Allergies declared and confirmed by customer on ${v.ref}: ${v.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),c(v),v},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); +__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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,choiceIds:s.map(e=>e.id)}]})}const O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:n,tip:s,notes:i,phone:o,email:l,customerName:u})=>{const g=t(),m=g.basket,p=m.restaurantId,b=w(m,g.menu,g.customer.allergies),f=b.reduce((e,t)=>e+t.unitPrice*t.qty,0),k='table'===m.mode,I=$(g.orders.filter(e=>e.restaurantId===p).map(e=>e.ref),k?'Q-':'T-',k?g.counters.table:g.counters.order),S=!k,h=f+(S?0:s),O=(u??'').trim()||g.customer.name,C={id:(0,y.uuid)(),ref:`${k?'Q':'T'}-${I}`,restaurantId:p,customerId:g.customer.id,customerName:O,type:m.mode,tableNo:m.tableNo,slotTime:n,lines:b,subtotal:f,tip:S?0:s,giftCardApplied:0,giftCardCode:void 0,total:h,paid:0,status:S?'awaiting_payment':'new',createdAt:a().toISOString(),allergies:g.customer.allergies,readiness:{},notes:i,channel:'app',...'takeaway'===m.mode?{phone:o??g.customer.phone,email:l??g.customer.email}:{}};e(e=>({orders:[C,...e.orders],basket:{...e.basket,lines:[]},counters:k?{...e.counters,table:I}:{...e.counters,order:I}}));const v=b.filter(e=>e.overridden);return r(p,'order',`Order ${C.ref} placed (${k?`Table ${m.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),C.allergies.length&&r(p,'allergy',`Allergies declared and confirmed by customer on ${C.ref}: ${C.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),'awaiting_payment'!==C.status&&c(C),C},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WILDINGS_LOCATION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WILDINGS_ADDRESS",{enumerable:!0,get:function(){return t}}),e.withWildingsAddress=function(r){return'wildings'===r.id?{...r,location:n,address:t}:r},e.withWildingsQuestionnaireAddress=function(n,r){return'wildings'===n&&r?{...r,venue:{...r.venue,address:t}}:r};const n='Maidens, KA26 9NR',t='Maidens Road, Maidens, KA26 9NR'},832,[]); __d(function(g,r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sampleFingerprint=i,e.stripOwnerLiveSamples=function(n){const a={};for(const[s,o]of Object.entries(t.OWNER_SAMPLE_HASHES)){const t=n[s]||[];a[s]=t.filter(t=>!o.includes(i(t)))}a.chat=(n.chat||[]).filter(t=>!(0,s.isSeedChefChat)(t));const o=(n.changeRequests||[]).length-a.changeRequests.length;o&&(a.changesUsed=Math.max(0,(n.changesUsed||0)-o));return a},e.stripCoreLiveSamples=function(a){const c={...(0,n.stripCoreChefSamples)(a)};c.giftCards=(a.giftCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.giftCards.includes(i(s))),c.stampCards=(a.stampCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.stampCards.includes(i(s))),c.ratings=(a.ratings||[]).filter(t=>!(/^rt-[123]$/.test(t.id)&&(0,s.demoActor)(t.customerName))),i(a.customer)===t.LEGACY_CUSTOMER_HASH&&(c.customer={...a.customer,id:'',name:'',email:'',phone:'',allergies:[],allergyConsent:!1,referralCode:'',marketingOptIn:{}});return c.restaurants=(a.restaurants||[]).filter(t=>!('saltmarsh'===t.id&&['The Venue','Saltmarsh Bistro'].includes(t.name))),c.menu=(c.menu||a.menu||[]).filter(t=>'saltmarsh'!==t.restaurantId).map(t=>t.signOff?t:o(t)),c};var t=r(d[0]),s=r(d[1]),n=r(d[2]);const a=t=>Array.isArray(t)?t.map(a):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&'function'!=typeof t).sort(([t],[s])=>ts?1:0).map(([t,s])=>[t,a(s)])):t;function i(t){const s=JSON.stringify(a(t))??"null";let n=2166136261;for(let t=0;t>>0).toString(16)}const o=t=>Array.isArray(t)?t.map(o):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).map(([t,s])=>[t,'allergenNotes'===t&&'string'==typeof s&&/\(example\)/i.test(s)?'':o(s)])):t},833,[834,835,836]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"OWNER_SAMPLE_HASHES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CORE_SAMPLE_HASHES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"LEGACY_CUSTOMER_HASH",{enumerable:!0,get:function(){return b}});const c={referrals:["43f09bc0","c438fbad","96bf8c62","3399d421"],coats:["f51097ad","2f7efa3a"],merch:["ef6e14e","dbbc0999","dc233c1d"],merchOrders:["13b15512","bc27f242"],offers:["ad0fcde0","59e6c0cf"],photos:["53a60fd9","ab778a74","95de43cd"],changeRequests:["81c5be12","6819542c"],lost:["5bbf0d77","7d3aa9ed","850c049e"],campaigns:["9cdf8346","82150e7"],suppliers:["41df06e7","466e32ac","fa3d8eea","dfafa674","1e26fbd0","c195b120","5fc49e74","6aa8b0af","602fc2e4"],supplierOrders:["22636226","464d6a6a"]},f={giftCards:["b1bba36d","f029bc0e"],stampCards:["e7bedf6f","a3c8404d"]},b="4b1e9971"},834,[]); @@ -1067,643 +1067,647 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},984,[835]); __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 t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(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 u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{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}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},985,[984]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},986,[872,34,102,987,2,821,794,25]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return W.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return W.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return W.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return W.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return W.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return I.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return I.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return It}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ne.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ne.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ne.useOwner.getState().chatSeen(t,e)),Ft(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ne.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...St(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(le.PITCH)return pe.unlockCashUp(e,t,a);const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?oe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):oe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(le.PITCH)return pe.cashAudit(e);const t=Oe.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(ma.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=fa,i.readAccessLog=async function(){const e=Oe.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Oe.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return pa}}),i.uploadOrderLogo=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(pa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ga.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(pa).createSignedUrl(e,3600);if(t?.signedUrl)return ga.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(pa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return ma}}),i.claimInvite=Da,i.makeChromeHandover=async function(){const e=Oe.getState();if(le.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ue});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(le.PITCH||!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ue});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),Pe&&xa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Te();const t=await x.kv.get(ka,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Te(),await x.kv.get(Ia,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_WILDINGS||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Te(),await x.kv.remove(ka),await x.kv.remove(Ia),Ae({mode:'signin',perms:[]});try{await Ma()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Oe.getState().venueId;if(le.PITCH||!s||'staff'!==Oe.getState().kind)return{ok:!0};if(!(0,ie.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ka('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Da(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(le.PITCH)return pe.reissueInvite(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ka('staff_app_link_history',{p_venue:Oe.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ka('revoke_staff_app_link',{p_venue:Oe.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(le.PITCH)return pe.linkPhones();const e=Oe.getState().venueId;if(!e||'staff'!==Oe.getState().kind)return{};try{const t=await Ka('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(le.PITCH)return pe.resetPhone(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ka('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(le.PITCH)return pe.inviteStatus();const e=Oe.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:t,error:a}=await Re().rpc(o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_pairing_code':o.IS_GREENSIDE?'claim_greenside_pairing_code':o.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':o.IS_KIRKTON?'claim_kirkton_pairing_code':o.IS_WILDINGS?'claim_wildings_pairing_code':o.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':o.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await x.kv.set(ba,n),xa(),{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}`}}},i.carPairStart=async function(){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await x.kv.set(Ua,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ea(e)}}},i.carPairPoll=async function(e){try{Te();const t=e??await x.kv.get(Ua,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,G.carPairApproved)(n)){const e=(0,G.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await x.kv.get(ba,null);await x.kv.set(ba,e),await x.kv.remove(ka),O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||xa()}return'revoked'!==i&&'unknown'!==i||await Ta(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Te(),await Re().rpc('car_sign_out')}catch{}await Ta(),await Ma();try{await Re().auth.signOut({scope:'local'})}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ka('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ea(e)}}},i.carList=async function(){const e=Oe.getState().venueId;if(!e)return[];return(await Ka('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ka('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ea(e)}}},i.unpairDisplay=async function(){await x.kv.remove(ba),await Ma();try{await Re().auth.signOut()}catch{}Ae({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await x.kv.remove(ka),await x.kv.remove(Ia),await Ma();try{await Re().auth.signOut()}catch{}Ae({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.'})},i.wipeThisDevice=async function(e={}){try{await Ma()}catch{}try{(0,T.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${o.VENUE_RID}:`)):(0,I.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!o.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Na,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ka}}),i.mendSession=qa,i.startAppSync=async function(e=o.VENUE_RID){if(o.IS_ISOLATED_VENUE&&e!==o.VENUE_RID)return;if(Pe)return;Pe=!0,La=e,'customer'===Ue&&'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Te(),'customer'!==Ue){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ue&&(0,h.isAnchorage)(e)?[H.useStore,ne.useOwner,ae.useKitchen,se.useSafety,Y.useCardStore,m.useGpCalc,X.useOrderSheets,S.useSpecials,A.useHr]:[H.useStore,ne.useOwner,ae.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ue&&(0,h.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ae({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await vs(e)}catch{if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e))return void Ae({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,T.isSupabaseConfigured)())return void Ae({mode:'off'});j.mutationQueue.subscribe(()=>{const e=j.mutationQueue.waiting,t=e[0];Ae({pending:j.mutationQueue.pending.length,failed:j.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,L.describeWrite)(t)}: ${(0,L.plainReason)({...t.lastErr},'retry')}`:void 0})}),j.mutationQueue.onFailed(e=>Ae({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:j.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,L.describeWrite)(e),why:'conflict'===e.reason?(0,L.plainReason)({code:'conflict'},'refused'):(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Ke.push((0,N.onConnectivity)(e=>Ae({mode:e?Oe.getState().venueId?'live':Oe.getState().mode:Oe.getState().venueId?'offline':Oe.getState().mode}))),await Ba()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return za}}),i.stockSaveBlocker=Za,i.stockEventStatus=function(e){if(ze(e))return{state:'saved'};const t=j.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,L.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=Ya,i.saveStockEventsNow=Xa,i.bookingSaveBlocker=ts,i.resendUnsavedBookings=ns,i.saveBookingsNow=is,i.waitForBookingSave=function(e,t=12e3){if(!De())return Promise.resolve({state:'local'});const a=ts();if(a)return Promise.resolve({state:'refused',why:a});const s=as()[0]?.venueId??'',n=()=>es.some(t=>j.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=F.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,N.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(j.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(j.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||as().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||as().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=cs,i.tempLogState=function(){const e=ls()[0]?.venueId??'',t=ls().find(e=>'temp_readings'===e.spec.table),a=j.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!j.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values($.useTempSaves.getState().notSaved),i=se.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=fs,i.waitForTempSave=function(e,t,a=1e4){if(!De()||!ls().length)return Promise.resolve({state:'local'});const s=cs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ls()[0]?.venueId??'',i=ls().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>$.useTempSaves.getState().notSaved[(0,$.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>j.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=_s,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ts}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Es.get(a);if('customer'!==Ue||!(0,T.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Es.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ka('public_day',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:qe(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:qe(a.from_time),to:qe(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Es.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ts.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Es.get(a);e&&!e.ok&&Es.delete(a)}));const n=Es.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Oe.getState().venueId;if(!n||'staff'!==Oe.getState().kind)throw new Error('Connect to your venue first.');const i=await Ka('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});H.useStore.getState().updateRestaurant(e,{...i,id:e})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(fe),ge=t(r[60]),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]);const Re=()=>(0,E.getSupabase)();j.mutationQueue.setExecutor(q.executeMutation),(0,P.setClockServer)(()=>'staff'===Oe.getState().kind);const Oe=(0,U.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ae=e=>Oe.setState(e),Ce=e=>{const t=Oe.getState().perms;return t.includes('*')||t.includes(e)},De=()=>{const e=Oe.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Oe.subscribe(()=>(0,ve.setLiveData)(De()));let Ue=V.IS_CAR?'car':V.APP_VARIANT,Ee=!1;const Te=()=>{Ee||((0,x.setSyncNamespace)(Ue),Ee=!0)};let Ne=[],Ke=[],Pe=!1;const Me=()=>(new Date).toISOString().slice(0,10),xe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),qe=e=>e?e.slice(0,5):'',Le=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))):[],Be=e=>JSON.parse(JSON.stringify(e));function je(e,t){const a=xe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>H.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Be(e);if(t)return{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:Le(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,ie.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:Le(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Fe(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>H.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.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,ie.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Be(e.lines??[]),allergies:Le(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:Be(e.allergyChain??{}),readiness:Be(e.readiness??{}),allergy_ticks:Be(e.allergyTicks??{}),handover_check:e.handoverCheck?Be(e.handoverCheck):null,accepted:e.accepted?Be(e.accepted):null,doc:Be(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)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function $e(e){const t=xe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...J.useBlocks.getState().blocks,...J.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Oe.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:Be(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,J.blockClock)(t.from_time)??a?.from,n=(0,J.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>J.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>J.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let We=null,Qe='Main plan';function He(e){const t=e=>Be({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(z.useFloor.getState().plans[e]??(0,z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Ce('floor.manage')||Ce('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:We??(0,be.uuidFrom)(`plan:${a}`),venue_id:a,name:Qe||'Main plan',is_active:!0,...t(e),updated_by:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>(We=String(e.id),Qe=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,ke.withSeedBest)(e,t[0]):void 0;a&&z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ve(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Z.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Ce('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,ie.isUuid)(e.supplierId)?e.supplierId:(0,be.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),ot.get(t)??t)}:{}};var t},apply:(t,a)=>Z.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Ge=new Set,Je=new Set;j.mutationQueue.onDone(e=>{'stock_events'===e.table&&Je.add(e.rowKey)});const ze=e=>Je.has(e)||Ge.has(e),Ze=()=>Ce('*')||Ce('staff.manage')||Ce('recipes.edit')||Ce('recipes.signoff'),Ye=()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write'));function Xe(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Z.useShellStore.getState().events.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,ie.isUuid)(t.id)&&!!(Z.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('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,ie.isUuid)(e.undoes)&&(ze(e.undoes)||j.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Ge.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)=>Z.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function et(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Z.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={...Z.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Z.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Ge]}}}))},afterRead:()=>{Z.useShellStore.getState().server[e]||Z.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Ge]}}}))},subscribe:()=>()=>{}}}const tt=new Set;function at(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=H.useStore.getState().menu;return Y.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:t=>(0,ie.isUuid)(t.card.id)&&!((0,h.isAnchorage)(e)&&(0,h.isDemoCard)(t.card))&&!(0,h.isPlaceholderCard)(t.card),writable:()=>Ce('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,h.isAnchorage)(e)&&(s={...s,signOff:(0,h.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,h.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,h.isAnchorage)(e)&&(0,h.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,be.photoPath)(a,s),t=st(s.photo);t&&((0,Y.cachePhotoAs)(e,t),nt(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,be.cardToRow)(s,a);return{...i,...r,doc:Be({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,h.isPlaceholderCard)(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,signOff:(0,h.isAnchorage)(e)&&(0,h.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Ce('recipes.edit')&&t.length){const e=new Set(t);Y.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);Y.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&H.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&H.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=Y.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=H.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const st=e=>(0,Y.readLocalPhoto)(e);async function nt(e,t){if(!tt.has(e)){tt.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(be.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){tt.delete(e),Ae({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const it=new Map,rt=(0,U.create)(()=>({n:0}));(0,Y.setStoragePhotoResolver)(e=>{const t=it.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,T.isSupabaseConfigured)()&&'off'!==Oe.getState().mode?(t||(it.set(e,{url:'',at:Date.now()}),Re().storage.from(be.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(it.set(e,{url:t.signedUrl,at:Date.now()}),rt.setState(e=>({n:e.n+1})),Y.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const ot=new Map;const dt=(e,t)=>{const a=(0,ie.isUuid)(t)?t:(0,be.uuidFrom)(`sup:${e}:${t}`);return ot.set(a,t),a};function ut(e){return{name:'order_sheets',table:'suppliers',list:()=>X.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,h.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Ce('suppliers.manage'),toRow:(e,t)=>({id:dt(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:Be(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(ot.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>X.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>X.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,ie.isUuid)(e)?e:(0,be.uuidFrom)(`sup:${Oe.getState().venueId}:${e}`)})}}let ct=!1,lt=!1;const ft=new Map,pt=new Map,gt=new Map,mt=new Map,_t=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',St=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'},ht=(e,t)=>({...e,managerAccess:t}),yt=()=>({nickname:ct,display:lt}),wt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=ht({role:e.role,level:e.level??St(_t(e)).level},!0===e.managerAccess);return(0,B.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},yt())};const vt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},bt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},kt=e=>{const t=ne.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,d.isKitchenTeam)(t)},It=2e3;function Rt(e,t){return t||!e.length||e.length>=It?null:e=>(0,ie.isUuid)(e.id)}function Ot(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,Ce('rota.manage')):null,keepOnEmpty:()=>e&&!Ce('rota.manage'),list:()=>ne.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&ft.has(e.staffId)&&(Ce('rota.manage')||kt(e.staffId)),writable:()=>Ce('rota.manage')||Ce('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(vt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:bt(e.start),end_time:bt(e.end),published:!!e.published,doc:Be(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function At(){const e=xe(62),t=e=>Ce('rota.manage')||e.staffId===Oe.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ne.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&t(e),writable:()=>'staff'===Oe.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=xe(2)&&e.staffId===Oe.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Be(e.breaks??[]),break_mins:e.breakMins??0,doc:Be((0,y.privateAttendance)(o.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,y.privateAttendance)(o.VENUE_RID,{...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Ct(){const e=xe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.staffId===Oe.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Oe.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:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,ie.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:Be({...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Dt(e){ne.leaveRemote.decide=t=>!(!Ce('rota.manage')||!(0,ie.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(j.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Ke.push(()=>{ne.leaveRemote.decide=null})}function Ut(e){ne.timesheetRemote.send=(t,a)=>{if(!Ce('rota.manage')||!(0,ie.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return j.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:Be(s)}}),!0}const s=a;if('attendance_void'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return j.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:Be(s.breaks??[]),p_reason:n,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0},Ke.push(()=>{ne.timesheetRemote.send=null})}function Et(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>H.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Oe.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,ie.isUuid)(a)?a:(0,be.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,ie.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Be(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>H.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=>H.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Tt=e=>H.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Nt(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}));H.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Kt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=H.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Be({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Tt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Ce('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Mt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...Mt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Mt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Pt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Pt=t.feature_flags??{},Mt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Be({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}:{}})},apply:t=>{const a=t[0];a&&(H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,l.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Nt(e,a.events))},subscribe:e=>{const t=H.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Pt=null,Mt=null;const xt=()=>new Date(Date.now()-2592e6).toISOString(),qt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ft.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Lt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?(0,Se.dmId)(t[0],t[1]):null},Bt=()=>Oe.getState().perms.includes('*');function jt(){const e=()=>Oe.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ne.useOwner.getState().chat.filter(e=>(0,ie.isUuid)(e.id)).map(e=>Be({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=>!!qt(t.ch)&&(t.from===e()||Bt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('created_at',xt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=xt(),toRow:(e,t)=>{const a=qt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ft.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=Lt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?pt.get(String(e.from_staff)):'system';return s?Be({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ne.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?pt.get(String(t.from_staff)):'system',i=Lt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ne.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,Se.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,he.soundAllowed)())try{(0,he.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,b.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Ft(e,t,a){const s=Oe.getState();if(!_e.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ft.get(e),i='*'===t?'*':qt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function $t(e){const t=Oe.getState().staffRef,a=t?ft.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Lt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ne.useOwner.getState().chatMarkRead(t,i)}catch{}}function Wt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=C.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Be(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>C.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,D.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Qt(e){const t=xe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>C.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.reminderId)&&e.staffRef===Oe.getState().staffRef,writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>C.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Ht(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Vt=e=>null==e||''===e?null:Number(e),Gt=e=>e.filter(e=>!e.startsWith('data:')),Jt=()=>Ce('takings.view');function zt(e){const t=!Jt();return{name:'cash_ups',table:'cash_ups',list:()=>oe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,v.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,v.tradingDay)()&&!e.onServer),writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,v.tradingDay)()):e.gte('for_date',xe(400)),...t?{inWindow:e=>e.date===(0,v.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:Be(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({cashUps:Ht(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Zt(e){return{name:'sales_reports',table:'sales_reports',list:()=>oe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Be(e.vals),categories:e.categories,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({sales:Ht(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Yt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=oe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,oe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Be({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,oe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>oe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function Xt(e){return{name:'day_tips',table:'day_tips',list:()=>oe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',xe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>oe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ea(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>oe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Vt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>oe.useCashUp.setState(s=>({pot:Ht(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function ta(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=oe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Ce('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>oe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function aa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>re.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Be(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>re.useNotifs.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>re.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function sa(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=de.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Be(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>de.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ue.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Ht(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function na(e){const t=()=>Ce('venue.settings')||Ce('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>de.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,ie.isUuid)(a.id)&&(0,ie.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,de.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Oe.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Oe.getState().staffRef)||null,doc:Be(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ia(e){const t=xe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>de.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Be(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({history:Ht(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function ra(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=ce.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Be(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&ce.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,y.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>ce.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function oa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=ge.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,ge.libraryRowId)(e),kind:'library',doc:Be({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,ge.personRowId)(e,i),kind:'person',staffRef:i,doc:Be({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ne.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,me.canEditTasks)(t,a)},writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>ge.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,ge.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function da(e){const t=xe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>ge.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Oe.getState();return e.byRef===t.staffRef||Ce('staff.manage')},writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>ge.useDailyTasks.setState(s=>({ticks:Ht(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ua(e,t=!1){const a=xe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>ye.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind||Ce('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,be.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>ye.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>ye.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{we.autoSync.soldOutRead.add(e)}}}function ca(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>we.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:(0,be.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>we.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>we.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{we.autoSync.linksRead.add(e)}}}async function la(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&x.kv.get(a,!1):(x.kv.set(a,!0),!0)}catch{return x.kv.get(a,!1)}}async function fa(){const e=Oe.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();ma.setState({live:!!t?.push_live,known:!0})}catch{}}const pa='order-list-logos';const ga=new Map;const ma=(0,U.create)(()=>({live:!1,known:!1}));async function _a(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('reminders:ok',!1):(x.kv.set('reminders:ok',!0),!0)}catch{return x.kv.get('reminders:ok',!1)}}async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('chat:ok',!1):(x.kv.set('chat:ok',!0),!0)}catch{return x.kv.get('chat:ok',!1)}}const ha=(e,t)=>Be({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),ya='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function wa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>A.useHr.getState().questions.filter(t=>t.venue===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ha(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);A.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>A.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function va(e,t){const a=(t,a,s)=>{j.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(A.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(ya).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||A.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ha(e,t)))}catch{}}}),Ke.push(()=>{Object.assign(A.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ba='pair:v1',ka='staff:v1',Ia='staff:rejoin:v1';async function Ra(e){const t=o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_invite':o.IS_GREENSIDE?'claim_greenside_invite':o.IS_ABBOTSFORD?'claim_abbotsford_invite':o.IS_KIRKTON?'claim_kirkton_invite':o.IS_WILDINGS?'claim_wildings_invite':o.IS_KIRKMICHAEL?'claim_kirkmichael_invite':o.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ue,p_device:(0,O.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,O.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Oa(){if('display'===Ue||'customer'===Ue||le.PITCH)return'none';const e=await x.kv.get(Ia,null);if(!e)return'none';try{await Ca();const{data:t,error:a}=await Ra(e);if(a)return(0,I.inviteRefusal)(a.message)?(await x.kv.remove(Ia),await x.kv.remove(ka),'refused'):'offline';const s=t?.[0];return s?(await x.kv.set(ka,{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,displayName:s.display_name}),'ok'):(await x.kv.remove(Ia),'refused')}catch{return'offline'}}const Aa=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Ca(){Te();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ae({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 Da(e){if(le.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,I.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Ra(e);if(a){const e=(0,I.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,o.venueKey)(`cc-pending-invite:${Ue}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),await x.kv.set(Ia,e),Pe&&xa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ae({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ua='car:request:v1',Ea=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Ta(){await x.kv.remove(ba),await x.kv.remove(ka),await x.kv.remove(Ua),O.useSession.getState().meId&&O.useSession.getState().signOut()}async function Na(){if(!(0,T.isSupabaseConfigured)())return!1;try{return await Ca(),!0}catch{return!1}}const Ka=async(e,t={})=>{if(le.PITCH)return(0,fe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Pa=null;async function Ma(){for(const e of Ke)try{e()}catch{}Ke=[],Ne.forEach(e=>e.stop()),Ne=[],Pa&&(clearInterval(Pa),Pa=null)}async function xa(){await Ma(),await Ba()}async function qa(){if(!(0,T.isSupabaseConfigured)()||'customer'===Ue||le.PITCH)return!1;try{Te();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ue)return!1;if(!await x.kv.get(Ia,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Oa()&&(xa(),!0)}catch{return!1}}(0,u.setSessionMender)(qa);let La=o.VENUE_RID;async function Ba(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=La;try{if(Ae({mode:'connecting'}),await j.mutationQueue.load(),'customer'===Ue)return void await Ha(e);let t=await x.kv.get(ba,null),a=await x.kv.get(ka,null);if(V.IS_CAR&&!t&&a){const e=(0,G.migrateCarStaffIdentity)(a);e&&(t=e,await x.kv.set(ba,t)),await x.kv.remove(ka),a=null,O.useSession.getState().meId&&O.useSession.getState().signOut()}if(o.IS_ISOLATED_VENUE&&(t&&!(0,o.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,o.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ae({mode:'display'===Ue?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ue&&!V.IS_CAR&&a&&!s.session){const t=await Oa();if('offline'===t)return Ae({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{La===e&&xa()},6e4);'refused'===t&&a.staffRef&&O.useSession.getState().meId===a.staffRef&&O.useSession.getState().signOut(),a=await x.kv.get(ka,null),({data:s}=await Re().auth.getSession())}const n='display'===Ue||V.IS_CAR?t:a;if(!s.session||!n)return void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ka('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ue||V.IS_CAR?await x.kv.remove(ba):(await x.kv.remove(ka),await x.kv.remove(Ia)),'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId===n.staffRef&&O.useSession.getState().signOut(),void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ue?'This display was unpaired by a manager.':V.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,N.isOnline)()||/fetch|network/i.test(String(t?.message)))Ae({mode:'offline'});else if(Aa(t)&&'display'!==Ue){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Oa()&&setTimeout(()=>{La===e&&xa()},500)}i=Oe.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ae({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!V.IS_CAR&&'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId!==n.staffRef&&(O.useSession.getState().signIn(n.staffRef),ne.useOwner.setState({staffAs:n.staffRef})),V.IS_CAR&&(O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({previewRole:'owner'})),await Fa(n.venueId,e,n.kind)}catch(e){Ae({mode:'local',lastError:String(e?.message??e)})}}const ja=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','venue_reminders','reminder_done']);async function Fa(e,a,s){if(!(0,o.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||V.IS_CAR&&'device'===s;await _s(a),Ke.push(Us(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])gt.set(e.key,e.id),mt.set(e.id,e.key)}catch{}const i=[Kt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ne.useOwner.getState().staff.map(wt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Ce('staff.manage'),deletes:!1,revision:e=>(0,B.staffRevision)(e,yt()),toRow:(e,t)=>(0,B.staffRow)(e,t,yt(),e.managerAccess||e.ownerAccess?null:gt.get(_t(e))),fromRow:e=>{if(!e.external_ref)return null;ft.set(String(e.external_ref),String(e.id)),pt.set(String(e.id),String(e.external_ref)),Os.set(String(e.external_ref),e.avatar_path??null);const t=ht(St(mt.get(String(e.role_id))),!0===e.manager_access);return(0,B.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},yt())},apply:e=>ne.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=>ne.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ds()},onRemote:()=>{Ds()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ne.useOwner.getState(),t=te.useSetup.getState().sites[La]?.staffGrade??{};return e.staff.filter(e=>ft.has(e.id)).map(a=>Be({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=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ft.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=pt.get(String(e.staff_id));return t?Be({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=>ne.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=te.useSetup.getState().sites[La],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&&te.useSetup.getState().patch(La,{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=ne.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=te.useSetup.subscribe((t,a)=>{t.sites[La]?.staffGrade!==a.sites[La]?.staffGrade&&e()});return()=>{t(),a()}}},je(a,!1),je(a,!0),$e(a),He(a),Fe(a),Ve(a),Xe(a),et(a),ut(a),{name:'supplier_directory',table:'suppliers',list:()=>ne.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('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:Be(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ne.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId),writable:()=>Ce('suppliers.order')||Ce('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||Me(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Be(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},at(a),ks(a)];Ce('wages.view')&&i.push(Is(a)),n&&(i.push(Ot(!0),At(),Ct(),Et(a)),Ut(e)),n&&await la('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Oe.getState().staffRef&&'pending'===e.status||Ce('rota.manage')),writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Be(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),ja.add('staff_leave'),Dt(e));const d=n&&await Sa();if(_e.useChatSync.setState({synced:d,checked:!0}),Ke.push(()=>_e.useChatSync.setState({synced:!1})),d&&i.push(jt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(Se.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ft.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ft.get(e.id),include:e.include}),fromRow:e=>{const t=pt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>Se.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=>Se.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await la('hr_questions')&&(i.push(wa(a)),ja.add('hr_questions'),va(e,a)),'guest'!==s&&'customer'!==Ue&&await la('temp_readings')&&(i.push((0,W.tempUnitsSpec)(se.useSafety,Ze),(0,W.tempReadingsSpec)(se.useSafety,Ye)),ja.add('temp_units'),ja.add('temp_readings')),'guest'!==s&&await la('sold_out_items')?(i.push(ua(a,await la('sold_out_items','auto'))),ja.add('sold_out_items')):we.autoSync.soldOutRead.add(a),'guest'!==s&&await la('sold_out_links')?(i.push(ca(a)),ja.add('sold_out_links')):we.autoSync.linksRead.add(a),C.useReminders.getState().ensure(a),'guest'!==s&&await _a()&&(i.push(Wt(a)),n&&i.push(Qt(a))),re.useNotifs.getState().ensure(a),de.useOrderLists.getState().ensure(a),n){ct=await la('staff','nickname'),lt=await la('staff','display_clock');const[e,t,s,n]=await Promise.all([la('scheduled_notifications'),la('order_lists'),la('venue_clock_area'),la('daily_tasks')]);ge.useDailyTasks.getState().ensure(a),n&&(i.push(oa(a),da(a)),ja.add('daily_tasks'),ja.add('daily_task_ticks')),e&&(i.push(aa(a)),fa()),t&&i.push(sa(a),na(a),ia(a)),s&&i.push(ra(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&ja.add(n)}if('guest'!==s&&await la('day_tips')){i.push(Xt(a));for(const e of['day_tips','tips_pot_events','tips_settings'])ja.add(e);await la('tips_pot_events')&&i.push(ea(a),ta(a)),n&&(Jt()||(0,oe.forgetPastTakings)(a,(0,v.tradingDay)()),i.push(zt(a),Yt(a)),ja.add('cash_ups'),Jt()&&(i.push(Zt(a)),ja.add('sales_reports')),t(r[72])(r[71],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Ot(),At()),await la('scheduled_notifications')&&i.push(aa(a)));let u=!1;const c=()=>{if(V.IS_CAR&&n&&Ce('recipes.edit'))return!0;const e=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);return!!e&&e.active&&Ce('recipes.edit')&&(0,_.costsAllowedFor)(e)};n&&c()&&await la('ingredient_prices')&&(i.push((0,m.gpSyncSpec)('ing',c)),ja.add('ingredient_prices'),await la('card_costs')&&(i.push((0,m.gpSyncSpec)('card',c)),ja.add('card_costs')),await la('kitchen_deliveries')&&(i.push((0,m.gpSyncSpec)('del',c)),ja.add('kitchen_deliveries')),await la('kitchen_stock_counts')&&(i.push((0,m.gpSyncSpec)('count',c)),ja.add('kitchen_stock_counts'))),(0,Ie.specialsSyncOn)()&&'guest'!==s&&await la('specials_boards')&&(i.push((0,Ie.specialsBoardSpec)(a,()=>Ce('recipes.edit')||Ce('floor.manage')||Ce('*'))),ja.add('specials_boards'));const l={onActivity:()=>Ae({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ae({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ae({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Ka('whoami')??[]).some(t=>t.venue_id===e))return void(La===a&&xa());for(const a of Ne){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||F.useBookingSaves.getState().mark({id:t,table:e,why:ts()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||$.useTempSaves.getState().mark({id:t,table:e,why:cs(e)??'this screen could not send it'})}};Ne=i.map(t=>new Q.EntityBridge(t,e,l)),await Promise.all(Ne.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,N.isOnline)())try{const t=await Ka('whoami');if(!t?.some(t=>t.venue_id===e))return void(La===a&&xa())}catch(e){if(Aa(e)){if(V.IS_CAR)return void(La===a&&xa());const e=await Oa();return void('ok'!==e&&'refused'!==e||La===a&&xa())}}let t=0;for(const[a,s]of Ne.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(_e.useChatSync.getState().error&&_e.useChatSync.setState({error:void 0}),await $t(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&_e.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({mode:'live',lastSyncAt:e,lastServerAt:e}),j.mutationQueue.flush()}else Ae({mode:'offline'});if(!Ce('wages.view')){const e=Oe.getState().staffRef;ne.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const S=new Map;for(const e of Ne)S.set(e.spec.table,[...S.get(e.spec.table)??[],e]);const h=[...S.keys()].filter(e=>ja.has(e)).map(e=>({table:e,venueColumn:S.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,Q.venueChannel)(e,h,(e,t,a)=>{for(const s of S.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ae({lastSyncAt:s,lastServerAt:s})},e=>{Ae({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Ke.push(()=>{Re().removeChannel(w)}),Ke.push((0,N.onConnectivity)(e=>{e&&p()}));const b=Ne.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,K.superviseSync)({fastMs:Wa(Ue),readFast:async()=>{for(const e of b)await e.read()},readAll:p,flush:()=>{j.mutationQueue.flush()},wake:()=>{j.mutationQueue.retryNow()},restart:()=>{La===a&&xa()},realtime:()=>Oe.getState().realtime,lastServerAt:()=>{const e=Oe.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Aa,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>$a(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Ke.push(k.stop)}async function $a(e){const t=Oe.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ka('sync_heartbeat',{p_venue:e,p_device:(0,O.deviceId)()??'unknown',p_app:Ue,p_version:M.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Wa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Oe.getState(),queue:j.mutationQueue.pending.map(e=>e.table),failedTables:j.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),le.PITCH&&(window.__ccSyncPreview=e=>Ae(e)));const Qa='guest:sent:v1';async function Ha(e){Ae({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ka('public_venue',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!o.IS_ISOLATED_VENUE||t.id===o.VENUE_UUID)){Ae({venueId:t.id,venueName:t.name}),await _s(e);const a=t.app?.restaurant;a&&H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,l.withWildingsAddress)({...a,id:e}):t)})),Nt(e,t.app?.events)}await Va(e),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ae({mode:(0,N.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Va(e).catch(()=>{})},6e4);Ke.push(()=>clearInterval(t)),o.IS_ISOLATED_VENUE||await Ga(e)}async function Va(e){const t=await Ka('public_menu',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));Y.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&H.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))]}})}async function Ga(e){let t=await x.kv.get(Qa,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=H.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Na())return;for(const a of n)try{const s=(await Ka('guest_create_booking',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_booking:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(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&&H.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'},Ae({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ka('guest_create_takeaway',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_order:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ae({lastError:`Order: ${e?.message}`}))}await x.kv.set(Qa,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ka('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await x.kv.set(Qa,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ka('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));H.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 Ja(n)===Ja(e)?e:n})})),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ae({mode:(0,N.isOnline)()?Oe.getState().mode:'offline'})}finally{a=!1}}};Ke.push(H.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Pa=setInterval(()=>{n()},15e3),n()}const Ja=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),za={bridges:()=>Ne,restart:xa};function Za(){const e=Oe.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Ce('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function Ya(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(!e||Za())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(j.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function Xa(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}Ya();try{await j.mutationQueue.retryNow()}catch{}}Oe.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{Xa()},3e3)});const es=['bookings','walk_ins'];function ts(){const e=Oe.getState();return De()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const as=()=>Ne.filter(e=>es.includes(e.spec.table)),ss=e=>j.mutationQueue.failed.some(t=>es.includes(t.table)&&t.rowKey===e);function ns(e=!1){return ts()?0:as().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ss(t)&&!!F.useBookingSaves.getState().notSaved[t]),0)}async function is(e=!1){const t=ts();if(t)return t;for(const e of as())try{await e.read()}catch{}ns(e);try{await j.mutationQueue.retryNow()}catch{}return e&&rs(),null}function rs(){const e=as()[0]?.venueId??'',t=F.useBookingSaves.getState(),a=new Set(as().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ss(s)||es.some(t=>j.mutationQueue.hasPending(t,e,s))||t.clear(s)}j.mutationQueue.onFailed(e=>{es.includes(e.table)&&F.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{es.includes(e.table)&&F.useBookingSaves.getState().clear(e.rowKey)});let os=null;const ds=(e=2500)=>{os&&clearTimeout(os),os=setTimeout(()=>{os=null,is(!1)},e)};(0,N.onConnectivity)(e=>{e&&ds()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ds(3e3)});const us=['temp_readings','temp_units'];function cs(e="temp_readings"){const t=Oe.getState();return De()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ze()?'device'!==t.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ls=()=>Ne.filter(e=>us.includes(e.spec.table));async function fs(e=!1){const t=cs();if(t)return t;for(const e of ls())try{await e.read()}catch{}const a=ls()[0]?.venueId??'';for(const t of ls())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,j.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await j.mutationQueue.retryNow()}catch{}if(e){const e=$.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ls().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||j.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,$.tempKey)(t.table,t.id))}}return null}j.mutationQueue.onFailed(e=>{us.includes(e.table)&&$.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{us.includes(e.table)&&$.useTempSaves.getState().clear((0,$.tempKey)(e.table,e.rowKey))});let ps=null;const gs=(e=3e3)=>{ps&&clearTimeout(ps),ps=setTimeout(()=>{ps=null,fs(!1)},e)};(0,N.onConnectivity)(e=>{e&&gs()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&gs(3500)});const ms='golive:v1:';async function _s(e){'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)?await vs(e):(await x.kv.get(ms+e,!1)||await vs(e),await x.kv.get(ys+e,!1)||(ws(e),await x.kv.set(ys+e,!0)),await x.kv.get(Ss+e,!1)||(hs(),await x.kv.set(Ss+e,!0)))}const Ss='golive:v3:';function hs(){const e=e=>JSON.stringify(e).includes('(example)');try{ae.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ys='golive:v2:';function ws(e){const t=e=>JSON.stringify(e).includes('(example)');H.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)))})),ne.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 vs(e){if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)){const t=(0,p.stripCoreLiveSamples)(H.useStore.getState()),a=(0,ae.stripKitchenExamples)(ae.useKitchen.getState()),s=ne.useOwner.getState(),n=(0,p.stripOwnerLiveSamples)(s),i={accidents:se.useSafety.getState().accidents.filter(e=>!(0,se.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(H.useStore.getState(),t)&&(await(0,g.archiveChefCache)('core',H.useStore.getState()),H.useStore.setState(t)),r(ae.useKitchen.getState(),a)&&(await(0,g.archiveChefCache)('kitchen',ae.useKitchen.getState()),ae.useKitchen.setState(a)),r(s,n)&&(await(0,g.archiveChefCache)('owner',s),ne.useOwner.setState(n)),r(se.useSafety.getState(),i)&&(await(0,g.archiveChefCache)('safety',se.useSafety.getState()),se.useSafety.setState(i));const o=(0,A.stripHrSamples)(A.useHr.getState());r(A.useHr.getState(),o)&&(await(0,g.archiveChefCache)('hr',A.useHr.getState()),A.useHr.setState(o));const d=(0,m.stripGpSamples)(m.useGpCalc.getState());r(m.useGpCalc.getState(),d)&&(await(0,g.archiveChefCache)('gp',m.useGpCalc.getState()),m.useGpCalc.setState(d));const u=X.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,g.archiveChefCache)('order-sheets',u),X.useOrderSheets.setState(c));const l=Y.useCardStore.getState(),_={cards:l.cards.filter(e=>!(0,f.isLiveVenue)(e.restaurantId)||!(0,h.isDemoCard)(e)),log:l.log.filter(e=>!(0,h.demoActor)(e.by))};return r(l,_)&&(await(0,g.archiveChefCache)('recipe-cards',l),Y.useCardStore.setState(_)),void await x.kv.set(ms+e,!0)}const t=t=>t.restaurantId===e&&!(0,ie.isUuid)(t.id);H.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)))})),J.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,ie.isUuid)(t.id))})),z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ne.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,ie.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,ie.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,ie.isUuid)(e.id)),leave:e.leave.filter(e=>(0,ie.isUuid)(e.id)),swaps:[]}));try{ae.useKitchen.setState(e=>(0,ae.stripKitchenExamples)(e))}catch{}ne.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,ie.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId))}));try{se.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await x.kv.set(ms+e,!0)}const bs=(e,t)=>Be({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function ks(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(z.useFloor.getState().live[e]??{}).map(([e,t])=>bs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Oe.getState().kind||Ce('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:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>bs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>z.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=>z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Is(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(te.useSetup.getState().sites[e]?.grades??te.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:()=>Ce('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=te.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));te.useSetup.getState().patch(e,{grades:i})},subscribe:t=>te.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Rs='staff-avatars',Os=new Map;let As=!1;const Cs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ds(){if(!As){As=!0;try{for(const[e,t]of Os){const a=ee.useAvatars.getState().photos[e];if(!t){a?.path&&ee.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Oe.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Rs).download(t);if(n||!s)continue;const i=await Cs(s);i.startsWith('data:image/')&&ee.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{As=!1}}}function Us(e){const t=async()=>{const t=Oe.getState().staffRef,a=t?ft.get(t)??Oe.getState().staffUuid:void 0;if(!t||!a||'staff'!==Oe.getState().kind)return;const s=ee.useAvatars.getState().photos[t];try{const n=Os.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Rs).remove([t]).catch(()=>{})};if(!s){const e=!!ee.useAvatars.getState().clears?.[t];return e&&n&&(await Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}),Os.set(t,null),i(n)),void(e&&ee.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ae({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Rs).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ka('set_staff_avatar',{p_staff_ref:t,p_path:d}),Os.set(t,d),n!==d&&i(n),ee.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ae({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ee.useAvatars.getState().photos},s=ee.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Ce('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Oe.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Os.set(t,null),ee.useAvatars.getState().doneClear(t),Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Rs).remove([e])).catch(()=>{})}});return t(),s}const Es=new Map,Ts=(0,U.create)(()=>({n:0}))},987,[5,988,932,6,832,837,833,838,989,993,994,835,996,998,999,1000,1001,1002,13,1003,1005,1008,1009,846,933,976,1010,1011,1012,1015,977,1016,1014,1019,1013,1020,1021,1022,1023,831,872,1024,1025,1028,983,883,1030,926,927,1032,1033,891,870,1035,1038,1039,1040,1041,2,1042,1043,1044,1045,1046,1047,979,981,884,863,859,1048,1051,1052]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},989,[837,34,838,5,839,846,849,990,863,870,991,992]); -__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},990,[984]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},991,[990]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},992,[990,991]); -__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},993,[]); -__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},994,[835,837,838,5,839,846,849,995,831,884]); -__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'}}]},995,[]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},996,[6,997]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},997,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},998,[846]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},999,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1000,[846]); -__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1001,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1002,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1003,[839,846,849,5,872,1004,15,1002]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1004,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1005,[838,835,837,5,839,846,849,1006,870]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1007,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1008,[839,846,849,863,1009,870]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1009,[]); -__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)))},1010,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1011,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1012,[34,1013]); -__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1013,[1010,977,1014]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1014,[1010]); -__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.3.12.171'},1015,[]); -__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1016,[1017,1018,933,977,1013]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1018,[977]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1019,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1020,[846,849,839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1021,[846,849,839]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1022,[1023]); -__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1023,[1017,933,1010,977,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1024,[]); -__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1025,[860,839,870,846,849,858,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1026,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1027,[891,1003,1026]); -__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1028,[5,860,839,1029,846,849,859]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1029,[1007]); -__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1030,[837,838,5,839,846,849,1031]); -__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1031,[984]); -__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1032,[837,984,838,835,5,839,846,849]); -__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1033,[837,838,5,839,846,849,1034]); -__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1034,[]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1035,[839,846,849,863,1036,15,870,1037]); -__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1036,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1037,[]); -__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1038,[34,839,846,849,863,13,870]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1039,[839,846,849,863,1040,870,1037]); -__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1040,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1041,[5,996,839,846,849,997]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1042,[1038]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1043,[839,846,849,863,1044,870]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1044,[]); -__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},1045,[846]); -__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(':')}`},1046,[839,846,849]); -__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{}}},1047,[236,872]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1048,[994,1049,1050,976,933]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1049,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1050,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1051,[933,987,998]); -__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1052,[1053]); -__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1053,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1054,[34]); -__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1055,[34,236,402,102,846,821,794,1054,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1056,[34,102,794,1057,821,1058,25]); -__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1057,[827,34,379,236,402,102,821,987,1058,2,872,1015,5,796,797,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1058,[1059,933,987,872,236]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1059,[]); -__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1060,[827,796,34,402,102,794,821,1043,1044,1009,1000,870,891,25]); -__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1061,[828,1062,796,827,34,281,283,364,336,402,102,426,794,821,1038,831,13,1063,1064,1000,1074,1079,1080,1083,1084,1085,1092,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1062,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1063,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1064,[34,876,1065,1066,1063]); -__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1065,[839,846,849]); -__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1066,[6,1067,1068,1069,1070,1071,1072,1073,3]); -__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1067,[]); -__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1068,[]); -__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1069,[]); -__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1070,[]); -__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1071,[]); -__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1072,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1073,[1063]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1074,[236,933,987,1075]); -__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})},1075,[499,1076,1078,1077]); -__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1076,[499,1077,1078]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1077,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1078,[1077]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1079,[933,987]); -__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1080,[34,281,236,102,794,1038,13,1081,821,1082,25]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1081,[13]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1082,[]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1083,[827,2,34,102,794,821,1038,891,13,987,1000,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1084,[13]); -__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1085,[34,1062,281,402,102,794,1086,1087,1091,1092,821,25]); -__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1086,[34,402,102,794,821,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1087,[837,34,874,891,858,872,1024,987,1088,1003,15,1090]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1088,[1089]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1089,[1090]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1090,[858]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1091,[34,872,1092,858,987,933]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1092,[]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1093,[34,1094,891,1008,1009,1000,1046,831,1097]); -__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1094,[996,1041,891,997,1095,1096]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1095,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1096,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1097,[]); -__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1098,[34,986,402,102,1099,794,874,1100,858,1101,821,25]); -__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)'}})]})}},1099,[34,281,283,364,102,1047,821,25]); -__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1100,[861,859]); -__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1101,[34,402,102,794,1100,858,821,25]); -__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1102,[34,102,794,874,877,821,25]); -__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1103,[860,34,102,794,874,1025,1028,1104,1105,877,821,25]); -__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1104,[1028,859,1100]); -__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1105,[860,877]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1106,[860,34,102,794,874,983,891,1100,858,821,25]); -__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1107,[828,827,1055,34,336,379,236,402,102,794,821,1039,1040,1000,1108,1109,987,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1108,[1075,236]); -__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1109,[839,846,849]); -__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1110,[827,996,34,379,402,102,794,821,1035,1036,891,1039,1040,1041,997,1095,987,1058,1000,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1111,[34,1035,891,1039,1112,1008,831,1036,1000,1093]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1112,[846]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1113,[996,34,1041,891,831,997,1009,1095,1000,1094]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1114,[860,34,1000,874,1100,1047]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1115,[860,1116,34,102,794,874,1100,821,1117,1106,1118,1139,1142,1098,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1116,[34,102,14,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1117,[821]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1118,[34,102,1119,821,1120,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1119,[860,1104]); -__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1120,[1121,860,34,1122,987,1124,402,102,874,1028,1119,1123,821,858,794,1125,1025,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1121,[34,859,821,794,25]); -__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1122,[34,402,102,874,1123,1124,987,1020,821,1120,794,25]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1123,[860,1104]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1124,[281,236]); -__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1125,[827,1126,1127,860,867,14,1128,1129,34,859,402,102,872,1087,874,1130,1104,858,821,864,794,1028,1025,1131,1132,1137,1106,1100,1138,1123,1122,25]); -__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1126,[34,402,412,102,1127,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1127,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1128,[34,102,794,25]); -__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1129,[34,236,402,295,102,426,821,794,1000,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1130,[878,858,877]); -__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1131,[34,402,102,878,858,821,794,25]); -__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1132,[860,877,34,102,879,1133,1134,1136,794,874,1028,983,861,867,872,1100,821,25]); -__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1133,[34,402,821,794,25]); -__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1134,[828,860,1135,34,281,236,102,1028,1104,821,794,1106,859,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1136,[34,402,102,874,861,863,821,794,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1137,[1127,1119,1123]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1138,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1139,[1140,34,102,874,1028,1123,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1140,[34,102,874,1028,1119,1141,1123,821,1003,891,872,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1141,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1142,[34,1062,1126,102,874,1028,1025,876,872,1137,861,1003,891,1026,1119,821,858,1131,1116,1128,1143,14,1140,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1143,[34,102,874,872,1137,14,1124,821,794,25]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1144,[34,102,794,1062,1092,1145,1091,1085,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1145,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1146,[34,102,794,827,1033,891,835,1147,821,1148,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1147,[1034]); -__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1148,[34,402,102,1124,987,1149,1021,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1149,[933,976,1010,1018,1013,1016,1150,1151,1152,1153,1154,1155,977]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1150,[1018,933,1016]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1151,[1018,933,976,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1152,[1010,976,1151,1013,1016,1150]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1153,[933,977]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1154,[34,1013]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1155,[933]); -__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1156,[30,34,426,102,846,872,1087,1157,25]); -__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1157,[839,846,849]); -__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()},1158,[1159]); -__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1159,[1160,858,884]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1160,[1161,877,1162,878,858,884,1163]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1161,[858]); -__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'},1162,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1163,[858]); -__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1164,[978,34,835,402,102,874,891,1165,1160,794,821,1087,1158,1032,15,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1165,[34,102,794,874,1038,884,1166,831,13,1163,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1166,[34,884]); -__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1167,[34,402,102,794,867,821,1159,1158,1164,1032,25]); -__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1168,[34,402,102,794,874,1160,858,821,1169,1165,1164,25]); -__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1169,[828,34,283,364,236,102,426,797,794,827,821,1170,25]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1170,[]); -__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1171,[827,984,1172,835,860,1173,1174,34,402,295,102,794,874,882,1175,891,993,861,867,1178,858,821,1179,1112,1087,1159,1158,1180,869,1164,1032,925,1181,1003,987,1184,988,1097,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1172,[1158,984]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1173,[827,34,102,794,874,979,891,980,981,982,831,821,25]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1174,[]); -__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1175,[827,796,34,336,402,102,821,794,874,1176,1055,882,861,863,885,1108,1177,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1176,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1177,[827,796,34,336,236,402,102,794,831,989,861,990,993,891,1003,882,821,930,991,25]); -__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])},1178,[858]); -__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1179,[928,828,827,837,5,34,1055,336,402,102,794,891,858,821,1087,1024,925,1046,1045,987,1112,1097,25]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1180,[828,34,102,794,876,831,869,821,925,25]); -__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1181,[928,828,34,395,236,402,102,925,794,926,891,1182,927,831,5,1183,987,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1182,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1183,[933,976,987,977]); -__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1184,[34,402,102,794,891,988,1097,993,987,1090,858,1124,821,25]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1185,[1172,984,34,379,102,794,891,993,867,821,1087,1164,1032,1186,25]); -__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1186,[827,835,984,34,379,236,402,102,794,1030,983,985,867,1031,821,1164,25]); -__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1187,[984,872,34,986,1188,336,402,102,1189,794,985,983,1030,821,874,1100,858,1124,987,25]); -__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1188,[5,822,823,828,236,826]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1189,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1190,[827,1030,1172,984,34,402,102,794,891,867,821,1164,1032,25]); -__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1191,[827,34,402,102,794,796,989,874,863,990,991,821,930,1192,1196,1177,25]); -__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1193,[1194,933,987,872,2,1195,1074]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1194,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1195,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1196,[34,102,797,794,989,874,992,821,930,1177,1197,25]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1197,[]); -__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1198,[827,1199,34,402,102,426,794,891,867,858,821,1200,1087,1064,25]); -__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:d,accent:u,children:a,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:d?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:u??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:u??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,a]});return d?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:d,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const d=e.key===n,u=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.note??String(u)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:d?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(u?2:0,e.a/t*c),backgroundColor:d?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,d=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',u=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,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1200,[34,402,102,794,821,5,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1201,[860,1101,1098,1116,34,102,846,794,874,1100,878,877,858,821,1106,1202,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1202,[34,794,874,1203,25]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1203,[379]); -__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1204,[827,1062,1199,34,1205,236,402,426,102,1207,1208,1209,794,831,891,867,1063,821,930,1217,1200,1087,1064,1210,872,1211,1215,25]); -__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1205,[34,402,102,1206,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1206,[34,797,25]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1207,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1208,[34,102,794,827,891,867,1207,821,25]); -__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1209,[827,1207,34,402,102,794,925,891,1097,858,821,1200,1087,1210,872,1211,1212,1214,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1210,[1062,1084,1092]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1211,[34,102,794,891,1038,1062,1092,1086,1210,821,872,1209,1085,1087,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1212,[1063,1213]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1213,[1063,1207]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1214,[34,102,794,827,1062,1063,1212,1124,821,1215,25]); -__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1215,[1062,34,402,102,794,827,891,1213,1063,1216,1124,821,1204,1087,1207,1212,1064,25]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1216,[]); -__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1217,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1179,1200,1087,1064,1159,987,1038,1061,13,1084,1063,2,25]); -__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1218,[828,891,1219,1199,1005,1006,34,1012,1013,236,402,295,102,794,874,1097,1209,1181,1220,1089,5,1221,1160,867,858,821,1200,1179,1087,925,1041,996,997,1094,1000,1096,1165,1163,1212,1214,1090,25]); -__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1219,[827,34,402,102,794,821,891,831,876,1005,1006,25]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1220,[34,102,794,891,1089,821,1097,25]); -__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1221,[34,402,102,794,891,858,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1222,[34,102,794,891,821,1087,1090,1220,1097,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1223,[34,102,1087,821,794,25]); -__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1224,[827,1062,34,402,102,794,1033,821,930,25]); -__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1225,[827,796,1226,1148,835,891,34,336,402,102,794,1033,1034,821,925,930,1227,1230,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1226,[34,1033,891,835]); -__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1227,[828,1062,796,827,1226,835,891,34,336,402,102,797,794,925,1033,1034,1228,821,930,1229,25]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1228,[]); -__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1229,[831,891,5]); -__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1230,[34,1062,379,236,102,794,891,1033,1229,1034,1231,821,930,1226,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1231,[1034]); -__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1232,[34,402,102,794,994,861,995,821,930,1233,25]); -__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1233,[828,34,336,395,402,295,102,1234,794,994,861,995,858,821,1048,25,1236]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1234,[34,1235,102,861,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1235,[2,987]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1236,[]); -__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1237,[860,1057,34,236,402,102,797,874,821,794,1238,1129,1239,25]); -__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1238,[860,34,380,236,402,102,36,821,794,796,1129,874,25,277]); -__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1239,[1240,1241,1243,1242,1244,1047,1245]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1240,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1241,[839,5,846,849,872,1047,1242]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1242,[860,236,872,1240]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1243,[34,874,861,869,867,1241,1240]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1244,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1245,[34,1241,987,933]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1246,[34,402,102,426,874,861,821,794,1237,1129,1247,25]); -__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1247,[34,102,426,874,861,1239,1047,821,794,1129,25]); -__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1248,[34,236,402,102,879,794,821,1000,1249,1250,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1249,[872,6,933,976,1000,1239,1250]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1250,[839,1251,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1251,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1252,[34,872,1249]); -__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1253,[827,796,1226,835,984,34,931,1205,395,236,402,295,102,846,794,861,1034,867,882,1033,821,1164,1158,1185,932,25]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1254,[34,402,346,102,426,821,1206,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1255,[30,34,792,872,25]); -__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1256,[860,1126,877,30,34,1257,1001,102,14,1128,1137,794,861,867,1130,858,874,987,821,1203,864,1025,1028,1104,1132,1100,1258,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1257,[827,34,236,102,25]); -__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1258,[34,402,102,878,858,1062,1259,821,794,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1259,[1062]); -__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:"ok",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"})]})]})}},1260,[30,34,336,102,1234,1261,794,861,867,874,882,821,25]); -__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])},1261,[30,34,402,874,821,794,25]); -__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1262,[30,34,794,1263,874,1248,25]); -__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])},1263,[34,402,821,794,25]); -__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1264,[837,30,34,1265,794,867,874,821,1266,1270,25]); -__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:x=!0,onPaid:f,title:g="Pay"}){const y=(0,o.useGiftCards)(b).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),_=y.find(e=>e.code===m),v=_?Math.min(_.balance,p):0,R=p-v;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:g,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),x&&y.length>0?(0,h.jsxs)(l.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:!m,onPress:()=>w(void 0)}),y.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,h.jsxs)(l.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)})]}),v?(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.ok,children:["\u2212",(0,n.gbp)(v)]})]}):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)})]})]}),T?(0,h.jsx)(t.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),f({giftCardCode:m,giftApplied:v,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1265,[34,385,102,874,867,821,794,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1266,[34,102,794,867,1267,1268,1269,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1267,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1268,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1269,[933,987,1268]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1270,[846,933,976,987,2,1267]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),r=e(_r(_d[4])),o=e(_r(_d[5])),i=e(_r(_d[6])),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),b=e(c);_r(_d[10]);var h=e(_r(_d[11])),f=e(_r(_d[12])),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),S=_r(_d[20]),T=_r(_d[21]),I=_r(_d[22]),O=_r(_d[23]),R=_r(_d[24]),A=_r(_d[25]),B=_r(_d[26]),P=_r(_d[27]),C=_r(_d[28]),_=_r(_d[29]),v=_r(_d[30]),N=_r(_d[31]);const $=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let E=!1,M=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,u.useLocalSearchParams)(),d=(0,w.useRestaurant)(e),c=s.IS_QUEUED_VENUE?(0,N.jsx)(t.default,{}):s.IS_ABBOTSFORD?(0,N.jsx)(o.default,{}):s.IS_KIRKTON?(0,N.jsx)(i.default,{}):s.IS_GREENSIDE?(0,N.jsx)(r.default,{}):l.IsolatedCustomerHome&&(s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS)?(0,N.jsx)(l.IsolatedCustomerHome,{}):(0,N.jsx)(K,{});return s.IS_ABBOTSFORD||s.IS_KIRKTON||s.IS_WILDINGS||!d?.settings.hotel?.enabled?c:(0,N.jsx)(n.HotelRequestGate,{rid:e,hotel:d.settings.hotel,children:c})}function K(){const{rid:e}=(0,u.useLocalSearchParams)(),t=(0,w.useRestaurant)(e),l=(0,w.useMenu)(e),s=(0,w.useCustomer)(),n=(0,w.useBasket)(),r=(0,w.useStore)(e=>e.startBasket),o=(0,w.useNow)(3e4),[i,H]=(0,c.useState)('All'),[K,W]=(0,c.useState)(null),[G,F]=(0,c.useState)(!1),[U,Q]=(0,c.useState)(!1),[V,Y]=(0,c.useState)('takeaway'===$?'takeaway':'main');b.default.useEffect(()=>{$&&!E&&(E=!0,'book'===$?setTimeout(()=>u.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,w.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,v.guestServer)();b.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>u.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),b.default.useEffect(()=>{C.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>u.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,w.useOrderAtTable)(e);if(b.default.useEffect(()=>{te||n.restaurantId!==e||'table'!==n.mode||w.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,n.mode,n.restaurantId,e]),!t)return(0,N.jsx)(x.Screen,{title:"Not found",children:(0,N.jsx)(x.T,{children:"Restaurant not found."})});const le=te&&n.restaurantId===t.id&&'table'===n.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ae=e=>!(e.soldOut||!e.signOff||null===e.price),ne=l.filter(e=>('All'===i||e.section===i)&&('takeaway'!==V||ae(e))),re=(0,k.hoursFor)(t,o),oe=e=>()=>u.router.push(`/customer/${t.id}${e}`),ie=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),le&&r(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>Q(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:oe('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:oe('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:oe('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:oe('/refer')},{icon:'gift',label:'Gift cards',on:oe('/gift')},{icon:'alert',label:'My allergens',sub:s.allergies.length?`${s.allergies.length} declared`:'None declared',on:()=>u.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:s.marketingOptIn[t.id]?'Opted in':'Opt in',on:oe('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:oe('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:oe('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:oe('/feedback')},{icon:'hanger',label:'Lost property',on:oe('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:oe('/merch')}];return(0,N.jsxs)(x.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,N.jsxs)(x.Row,{children:[(0,N.jsx)(m.BasketButton,{}),(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>u.router.push('/customer/profile')})]}),children:[t.fictional?(0,N.jsx)(x.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,le?(0,N.jsx)(x.Banner,{kind:"success",title:`Ordering at ${(0,d.tableNumbers)(n.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,N.jsx)(x.Card,{children:(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(f.default,{style:{flex:1},children:[(0,N.jsx)(x.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,N.jsxs)(x.Muted,{children:[re?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,N.jsx)(x.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,N.jsx)(x.Row,{wrap:!0,gap:8,children:ie.slice(2,7).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,N.jsx)(f.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ie.map(e=>(0,N.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),le?(0,N.jsx)(x.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,N.jsx)(x.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,N.jsx)(x.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,N.jsx)(x.ExampleAllergenNotice,{}),(0,N.jsxs)(x.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,N.jsx)(f.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,N.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,N.jsx)(x.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,N.jsx)(f.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,N.jsx)(A.SpecialsTab,{rid:t.id,declared:s.allergies,now:o}):null,'takeaway'===V?(0,N.jsx)(x.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==V?(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,N.jsx)(x.Chip,{label:"All",selected:'All'===i,onPress:()=>H('All')}),se.map(e=>(0,N.jsx)(x.Chip,{label:e,selected:i===e,onPress:()=>H(e)},e))]}):null,'specials'!==V?se.filter(e=>('All'===i||e===i)&&ne.some(t=>t.section===e)).map(e=>(0,N.jsxs)(f.default,{style:{gap:10},children:[(0,N.jsx)(x.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),ne.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,s.allergies),o=e.soldOut||!e.signOff||null===e.price;return(0,N.jsxs)(x.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,N.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)},children:[(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,N.jsx)(x.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,N.jsx)(x.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,j.gbp)(e.price)})]}),(0,N.jsx)(x.Muted,{numberOfLines:2,children:e.description})]}),(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,N.jsx)(x.Badge,{kind:"ok",label:e},e)),e.special?(0,N.jsx)(x.Badge,{kind:"gold",label:"Special"}):null,e.soldOut?(0,N.jsx)(x.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,N.jsx)(x.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,N.jsx)(x.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,N.jsx)(x.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,N.jsx)(p.AllergenChips,{map:e.allergens,declared:s.allergies}),K===e.id?(0,N.jsx)(p.AllergenPanel,{item:e,map:e.allergens,declared:s.allergies}):null,(0,N.jsxs)(x.Row,{gap:8,children:[(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,N.jsx)(f.default,{style:{flex:1}}),(0,N.jsx)(x.Button,{small:!0,label:o?e.soldOut?'Sold out':'Not available online':'Choose',disabled:o,onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,N.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,N.jsx)(x.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,N.jsx)(x.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,N.jsx)(T.LauncherLine,{}),te?(0,N.jsxs)(x.Sheet,{visible:U,onClose:()=>Q(!1),title:"Order at your table",children:[(0,N.jsx)(x.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,N.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:`${(0,d.tableNumbers)(e)}`,onPress:()=>{Q(!1),r(t.id,'table',e)}},e))}),(0,N.jsx)(x.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1271,[1272,1281,5,1282,1283,1284,1287,860,30,34,236,402,102,1234,1261,794,861,867,878,874,821,1288,1248,872,891,1233,994,995,1003,1289,1270,25]); -__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1272,[34,379,794,873,1273,1274,1280,874,5,6,25]); -__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1273,[34,379,102,794,996,997,1095,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1274,[6,34,933,794,1275,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1275,[6,1062,1276,1277,1278,34,102,827,794,821,11,1279,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1277,[4,11]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1278,[11]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1279,[6,933]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1280,[34,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1281,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1282,[34,102,794,1275,25]); -__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1283,[34,379,933,794,873,1273,1275,4,25]); -__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1284,[34,379,794,1273,873,1274,8,1285,25]); -__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1285,[34,102,794,1286,25]); -__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1286,[]); -__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1287,[34,794,873,1273,1274,874,9,25]); -__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1288,[34,402,102,426,794,821,1206,25]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1289,[34,102,1290,794,874,1003,1267,1270,821,25]); -__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1290,[34,102,1291,821,25]); -__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1291,[1292]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1292,[34,797,1293,1322,1323,25]); -__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1293,[1294]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1294,[1295,1296,1319,1321]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1295,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1296,[1297,1298,1299,1300,1301,1302,1303,1304,1305,1308,1312,1309,1313]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1297,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1298,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1299,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1300,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1305,[1306]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1309,[1310,1311]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1310,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1311,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1314,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1315,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1317,[1309,1297]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1318,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1319,[1320]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1321,[1320]); -__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1322,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1323,[34,797,1324,25]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1324,[]); -__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1325,[30,34,794,874,891,25]); -__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1326,[837,30,34,102,1290,794,867,874,821,1289,1270,25]); -__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1327,[837,30,34,102,1265,794,874,891,867,858,821,1266,1270,25]); -__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1328,[837,30,34,794,874,891,858,821,1289,1270,25]); -__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1329,[837,30,34,794,874,891,821,1289,1270,25]); -__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1330,[30,34,794,858,1160,1331,874,821,25]); -__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}},1331,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1332,[30,1100,34,402,102,794,858,874,821,25]); -__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 l=_r(d[0]),t=_r(d[1]),n=_r(d[2]),s=e(n),a=_r(d[3]),o=_r(d[4]),r=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),p=_r(d[15]),k=_r(d[16]);function f(){const e=(0,y.useBasket)(),f=(0,y.useRestaurant)(e.restaurantId??void 0),w=(0,y.useAllMenu)(e.restaurantId??void 0),v=(0,y.useCustomer)(),C=(0,y.useOrders)(f?.id),S=(0,y.useStore)(e=>e.setLineQty),T=(0,y.useStore)(e=>e.overrideLine),B=(0,y.useStore)(e=>e.startBasket),P=(0,y.useNow)(15e3),[$,O]=(0,n.useState)(null),[I,M]=(0,n.useState)(!1),[N,F]=(0,n.useState)(''),[L]=(0,n.useState)(()=>(0,o.startForm)()),[R,z]=(0,n.useState)(''),[A,D]=(0,n.useState)(v.phone??''),[E,Y]=(0,n.useState)(v.email??''),[_,q]=(0,n.useState)(!1),H=(0,y.useOrderAtTable)(e.restaurantId??void 0);s.default.useEffect(()=>{H||'table'!==e.mode||y.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[H,e.mode]);const[G,K]=(0,n.useState)(null),[Q,J]=(0,n.useState)(!1),U=(0,n.useMemo)(()=>(0,j.linesFromBasket)(e,w,v.allergies),[e,w,v.allergies]);if(!f||!e.lines.length)return(0,k.jsxs)(u.Screen,{title:"Your basket",children:[(0,k.jsx)(u.Muted,{children:"Your basket is empty."}),(0,k.jsx)(u.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const V=H&&'table'===e.mode,W=(0,m.takeawaySlots)(f,C,P),X=U.reduce((e,l)=>e+l.unitPrice*l.qty,0),Z=U.some(e=>e.contains.length&&!e.overridden),ee=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff}),le=!V&&!$,te=!V&&f.settings.takeawayPaused,ne=(0,p.ukPhone)(A),se=!Z&&!ee.length&&I&&!le&&!te&&(V||ne.ok&&(0,p.emailOk)(E)),ae=async e=>{const l=await y.repo.orders.placeFromBasket({slotTime:V?void 0:$,tip:0,giftCardCode:e?.giftCardCode,notes:N,paidNow:!V,phone:V?void 0:ne.pretty,email:V?void 0:E.trim()||void 0});(0,o.rememberGuard)(l.id,(0,o.guardFor)({...L,hp:R})),q(!1),t.router.replace(`/customer/order/${l.id}`)},oe=e.lines.find(e=>e.key===G),re=oe?U[e.lines.indexOf(oe)]:void 0;return(0,k.jsxs)(u.Screen,{title:"Your basket",subtitle:`${f.name} \xb7 ${V?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,k.jsxs)(r.default,{style:{gap:8},children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.T,{weight:"semibold",children:"Subtotal"}),(0,k.jsx)(u.T,{weight:"bold",size:20,colour:x.colours.gold,children:(0,h.gbp)(X)})]}),Z?(0,k.jsx)(u.T,{size:14,colour:x.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):I?le&&!te?(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Choose a collection time."}):null:(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Confirm your allergies to continue."}),V?(0,k.jsx)(u.Button,{label:"Send order to the kitchen",disabled:!se,onPress:()=>ae(),testID:"send-table-order"}):(0,k.jsx)(u.Button,{label:`Continue to payment \xb7 ${(0,h.gbp)(X)}`,disabled:!se,onPress:()=>q(!0),testID:"checkout"})]}),children:[(V||e.tableNo,null),V?(0,k.jsx)(u.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,f.fictional?null:(0,k.jsx)(u.ExampleAllergenNotice,{}),U.map((l,t)=>{const n=e.lines[t],s=l.contains.length&&!l.overridden;return(0,k.jsxs)(u.Card,{highlight:l.contains.length?x.colours.red:l.may.length?x.colours.amber:void 0,children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(r.default,{style:{flex:1,paddingRight:8},children:[(0,k.jsx)(u.T,{weight:"semibold",children:l.name}),l.choices.length?(0,k.jsx)(u.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,k.jsxs)(u.Muted,{children:["Note: ",l.notes]}):null]}),(0,k.jsx)(u.T,{weight:"semibold",children:(0,h.gbp)(l.unitPrice*l.qty)})]}),s?(0,k.jsxs)(u.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:[(0,k.jsx)(u.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${v.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} (${(0,c.severityLabel)(e.severity)})`).join(', ')}.`}),(0,k.jsxs)(u.Row,{gap:8,style:{marginTop:6},children:[(0,k.jsx)(u.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{J(!1),K(n.key)}})]})]}):l.contains.length?(0,k.jsx)(u.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,k.jsx)(u.Banner,{kind:"warn",title:`May contain ${l.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ee.includes(n)?(0,k.jsx)(u.Badge,{kind:"amber",label:"No longer available online \u2014 please remove"}):null,(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Stepper,{value:n.qty,onChange:e=>S(n.key,e),min:1,label:l.name})]})]},n.key)}),(0,k.jsx)(u.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${f.id}`)}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsxs)(u.H2,{children:["Collection time \u2014 ",(0,b.niceDate)(P)]}),te?(0,k.jsx)(u.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===W.length?(0,k.jsx)(u.Banner,{kind:"warn",children:"No collection slots left today."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u.Muted,{children:["15-minute slots, max ",f.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:W.slice(0,16).map(e=>(0,k.jsx)(u.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>O(e.time.toISOString())},e.label))})]})]}),(0,k.jsxs)(u.Card,{highlight:I?void 0:x.colours.amber,children:[(0,k.jsx)(u.H2,{children:"Confirm allergies for this order"}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:v.allergies.length?v.allergies.map(e=>(0,k.jsx)(u.Badge,{kind:"red",label:`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`},e.allergen)):(0,k.jsx)(u.Muted,{children:"No allergies declared on your profile."})}),(0,k.jsx)(u.Toggle,{label:v.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:I,onChange:M}),(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsx)(u.H2,{children:"Your details"}),(0,k.jsx)(u.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:A,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!ne.ok&&A?(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:ne.error}):null,(0,k.jsx)(u.Field,{label:"Email (optional)",value:E,onChangeText:Y,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,p.emailOk)(E)?null:(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,k.jsx)(u.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,k.jsx)(u.Field,{label:"Order notes (optional)",value:N,onChangeText:F,placeholder:"e.g. cutlery please"}),V?(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>B(f.id,'takeaway')}):null,(0,k.jsx)(i.MockPay,{visible:_,onClose:()=>q(!1),amount:X,restaurantId:f.id,onPaid:e=>ae({giftCardCode:e.giftCardCode}),title:"Pay for your takeaway"}),(0,k.jsxs)(u.Sheet,{visible:!!oe,onClose:()=>K(null),title:"Allergy override",children:[re?(0,k.jsx)(u.Banner,{kind:"danger",title:`${re.name} contains ${re.contains.map(c.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,k.jsx)(u.Toggle,{label:"I understand and want to add it anyway",value:Q,onChange:J}),(0,k.jsx)(u.Button,{kind:"danger",disabled:!Q,label:"Confirm override",onPress:()=>{oe&&re&&T(oe.key,re.contains),K(null)}})]}),(0,k.jsx)(a.Honeypot,{value:R,onChange:z})]})}},1333,[860,30,34,1257,1001,102,1265,794,861,867,1130,858,874,831,821,864,25]); -__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1334,[30,34,102,1261,794,861,878,874,821,1288,5,25]); -__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 f}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},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]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,s.useLocalSearchParams)(),r=(0,b.useOrder)(e),f=(0,b.useRestaurant)(r?.restaurantId),[C,S]=(0,l.useState)(0),[k,T]=(0,l.useState)(''),[v,P]=(0,l.useState)(!1),[M,$]=(0,l.useState)(!1),[R,A]=(0,l.useState)(1),[I,N]=(0,l.useState)(0),[O,B]=(0,l.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(c.Screen,{title:"Order",children:(0,j.jsx)(c.T,{children:"Order not found."})});const H='takeaway'===r.type?x:w,_=Math.max(0,H.findIndex(([e])=>e===r.status)),D=Math.round(r.subtotal*I/100),F='table'===r.type?r.subtotal+(r.split?r.tip:D):r.total,q=F-r.paid,L=r.split?.ways??O,W=r.split?.paidShares??0,Y=Math.ceil(F/L),E='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(c.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,p.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(c.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Status"}),H.map(([e,t],s)=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=_?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(c.T,{weight:s===_?'semibold':'regular',colour:s<=_?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(c.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,p.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(c.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||E?null:(0,j.jsxs)(c.Row,{gap:8,children:[(0,j.jsx)(c.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>b.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(c.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>b.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(c.T,{children:(0,h.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(c.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(c.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(u.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Subtotal"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Of which gift card"}),(0,j.jsxs)(c.T,{colour:y.colours.ok,children:["\u2212",(0,h.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Tip"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.tip)})]}):null,(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.gold,children:(0,h.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(c.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(F)," \xb7 split ",L," way",L>1?'s':''," \xb7 ",(0,h.gbp)(Y)," each"]}),(0,j.jsxs)(c.T,{children:["Shares paid: ",W," of ",L," \xb7 remaining ",(0,h.gbp)(q)]}),L>1?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{children:"Shares to pay now"}),(0,j.jsx)(c.Stepper,{value:R,onChange:A,min:1,max:L-W,label:"shares"})]}):null,(0,j.jsx)(c.Button,{label:`Pay ${L>1?`${R} share${R>1?'s':''}`:'bill'} \xb7 ${(0,h.gbp)(Math.min(q,Y*R))}`,onPress:()=>$(!0),testID:"pay-bill"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(c.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(c.Chip,{label:e?`${e}%`:'No tip',selected:I===e,onPress:()=>N(e)},e))}),(0,j.jsx)(c.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(c.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(r.subtotal+D),O>1?` \xb7 ${(0,h.gbp)(Math.ceil((r.subtotal+D)/O))} each`:'']}),(0,j.jsx)(c.Button,{label:"Get the bill",onPress:()=>b.repo.orders.setSplit(r.id,O,D),testID:"get-bill"})]})]}):null,!E||r.rated||v?null:(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(c.H2,{children:"How was everything?"}),(0,j.jsxs)(c.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(i.Stars,{value:C,onChange:S}),C?(0,j.jsx)(c.Field,{label:"Anything to add? (optional)",value:k,onChangeText:T}):null,(0,j.jsx)(c.Button,{label:"Send feedback",disabled:!C,onPress:()=>{b.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:C,comment:k,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),P(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(c.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,E?(0,j.jsx)(c.Button,{kind:"secondary",label:"View stamp card",onPress:()=>s.router.push(`/customer/${f.id}/loyalty`)}):null,(0,j.jsx)(o.MockPay,{visible:M,onClose:()=>$(!1),amount:Math.min(q,Y*R),restaurantId:f.id,title:`Pay \u2014 ${(0,t.tableNumbers)(r.tableNo)}`,onPaid:e=>{b.repo.orders.payTable(r.id,{shares:R,giftCardCode:e.giftCardCode}),$(!1),A(1)}})]})}},1335,[860,30,34,102,1265,1263,794,861,867,858,874,821,25]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1336,[860,1270,30,34,102,794,861,867,858,874,879,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1337,[30,34,872,25]); -__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1338,[837,30,34,794,874,5,1270,25]); -__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1339,[30,34,794,1340,1174,1270,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1340,[827,860,34,102,794,861,867,1174,1341,874,821,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1341,[933,987,1174]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1342,[30,34,872,1343,1407,25]); -__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1343,[1161,796,5,6,1344,828,853,1121,860,1160,1345,1346,1347,1118,1142,1348,1349,1354,1355,1356,872,1357,1173,979,1129,1358,34,1098,1201,1047,1114,1156,1359,395,380,402,295,102,426,36,794,1248,1252,873,861,858,874,821,1117,891,1125,1087,1028,1104,1134,1360,1133,1361,1368,1370,1373,1376,1372,1377,1379,1380,1139,1122,1123,878,1384,1237,1385,1247,1239,1025,1390,1398,1399,1101,1141,1401,1402,1403,1097,1188,1404,1187,1180,869,1405,1406,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1345,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1346,[1026,1087]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1347,[34,102,1104,794,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1348,[860,34,102,794,874,1174,821,25]); -__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1349,[34,395,402,426,102,1290,794,1188,796,1028,1350,1351,1353,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1350,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1351,[34,395,402,295,412,102,426,796,794,821,1352,1353,25]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1352,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1353,[1024,872,1352,933,987]); -__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1354,[846]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1355,[828,34,379,395,402,102,794,1188,821,25]); -__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1356,[34,236,402,102,794,821,891,1003,858,1097,25]); -__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1357,[828,827,34,236,402,295,102,794,1173,874,979,831,981,982,872,980,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1358,[828,34,102,821,794,25]); -__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1359,[34,102,797,821,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1360,[]); -__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1361,[828,796,827,1121,860,1129,34,236,402,295,426,102,859,821,794,1362,1363,1028,891,1133,1365,987,872,25]); -__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1362,[828,860,34,1363,102,859,821,794,1134,1364,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1363,[859]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1364,[1363,859]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1365,[34,385,295,102,859,1366,1367,821,796,827,794,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1366,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1367,[1366,1024,872,933,987]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1368,[34,236,402,102,821,794,1188,1369,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1369,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1370,[828,860,1122,34,281,236,295,102,1135,874,1028,1104,14,858,1123,1371,821,794,1372,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1371,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1372,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1373,[5,828,34,283,336,236,402,102,426,821,873,794,1029,1000,1354,1374,2,1375,1376,874,858,25]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1374,[236]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1376,[34,846,933,987,1375]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1377,[860,14,1028,1378]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1378,[861]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1379,[34,102,797,821,25]); -__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1380,[1381,860,1122,1028,34,102,794,1125,874,1383,1377,1123,858,1120,1139,1140,1141,821,1346,25]); -__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1381,[34,379,402,102,874,1003,891,1026,1382,872,821,794,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1382,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1383,[1028,1104]); -__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1384,[1381,828,1122,827,860,1160,1118,1139,858,34,1106,236,402,295,102,794,1125,1372,874,1028,861,1116,1104,1331,821,1346,25]); -__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1385,[827,34,236,402,102,794,874,1028,1386,821,1387,1389,25]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1386,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1387,[846,874,1028,1386,1388,1389]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1388,[860]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1389,[236,1388]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1390,[860,34,1205,1188,402,102,1025,1028,878,858,821,794,1391,1394,25]); -__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1391,[1392,870,860,34,281,395,402,295,102,874,1025,1028,1393,858,821,1055,794,1394,1395,987,1346,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1392,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1393,[878,858,877]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1394,[5,1028,933,987]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1395,[846,933,987,1396,2,1397]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1396,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1397,[15]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1399,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1400,[1104]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1401,[860,1378]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1402,[34,402,102,794,1401,821,1359,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1403,[34,102,925,794,1188,858,821,25]); -__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1404,[34,1188,402,102,426,794,25]); -__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1405,[828,1062,827,2,1188,34,402,102,426,794,821,891,997,858,1000,1395,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1406,[34,1035,891,1008,831,1036,1000,1395,1093]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1407,[5,828,873,34,236,402,102,426,987,821,794,1354,1408,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1408,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1409,[30,34,872,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1410,[30,34,872,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1411,[30,34,1412,872,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1412,[34,872,1413,1546,25]); -__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,"canSignOffHours",{enumerable:!0,get:function(){return he}}),_e.barTabsFor=me,_e.signOffSpeech=be,_e.OwnerApp=function(){return H.IS_OWNER_DESKTOP?(0,ue.jsx)(de.DesktopGate,{phone:(0,ue.jsx)(xe,{})}):(0,le.isDesktop)()?(0,ue.jsx)(ce.DesktopShell,{}):(0,ue.jsx)(xe,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),j=_r(d[14]),w=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=e(_r(d[20])),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),I=_r(d[24]),L=_r(d[25]),O=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]),$=_r(d[32]);_r(d[33]);var D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),z=_r(d[39]),F=_r(d[40]),U=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]),Y=_r(d[45]);_r(d[46]);var J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]),de=_r(d[60]),ce=_r(d[61]),ue=_r(d[62]);const fe=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ge=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],he=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function me(e,t){return ge.filter(t=>!t.can||t.can(e)).map(e=>'orders'===e.id&&t?{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'}:'forecast'===e.id?{id:'rota',label:'Rota',icon:'rota'}:e)}function be(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const pe={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function xe(){const{rid:e,r:le,role:de,today:ce,now:xe,meId:je,me:we}=(0,_.useCtx)(3e4);(0,b.useTipsPosted)(e,ce,'staff'!==de);const Se=(0,_.useSignedIn)();(0,c.useSoldOutLink)(!0,(Se?.name??we).replace(' (example)',''));const ye=(0,I.useOrders)(e),[Ae,ke]=(0,j.useState)('home'),[Re,Ce]=(0,j.useState)(null),[ve,Te]=(0,j.useState)(!1),Ie=(0,n.useLiveVenue)(),[Le,Oe]=(0,j.useState)(!1),Ee=(0,j.useRef)(null);(0,j.useEffect)(()=>{(0,_.ensureAttendance)(ce,xe),(0,Q.ensureChat)(xe)},[ce]),globalThis.__ccNow=xe.getTime();const Be=(0,Q.useChatUnread)().total,Pe=(0,j.useRef)({t:'home',s:null});Pe.current={t:Ae,s:Re};const Ne=(0,j.useRef)([]),$e=(0,l.useScrollMemory)(Ee),De=(0,j.useCallback)((e,t=null)=>{const s=Pe.current;s.t===e&&s.s===t||(Ne.current=[...Ne.current,{...s,y:$e.leave()}].slice(-30),$e.restore(0)),ke(e),Ce(t)},[]),Me=(0,j.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Pe.current;let t=Ne.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Ne.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return $e.leave(),ke(s.t),Ce(s.s),$e.restore(s.y??0),!0},[]);(0,u.useWebBack)(Me);const He=(0,u.useInnerBackShown)();(0,j.useEffect)(()=>(re.useVoiceNav.setState({go:De}),()=>re.useVoiceNav.setState({go:null})),[De]),(0,j.useEffect)(()=>{f.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchOwner=L.useOwner)},[De]),(0,j.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Me);return()=>e.remove()},[Me]),(0,j.useEffect)(()=>{const e=ge.find(e=>e.id===Ae);e?.can&&!e.can(de)&&De('home');const t=(0,K.pageFor)(Re);t?.can&&!t.can(de)&&Ce(null)},[de]);const We='more'===Ae?(0,K.pageFor)(Re):void 0,Ve=ye.filter(e=>(0,B.LIVE)(e)&&'new'===e.status).length,{unread:ze,list:Fe,read:Ue}=(0,J.useNotifications)();(0,se.useAlertWatcher)(e,{nag:'staff'!==de}),(0,oe.useReviewAlerts)(e),(0,ne.useScheduledNotices)({rid:e,staffId:Se?.id??'',name:we,onOpen:e=>'bookings'===e?De('bookings'):'chat'===e?De('chat'):De('more',e)}),(0,ae.useOffRotaAlerts)({enabled:'staff'!==de&&!!Se});const qe=Se?.role??de,Ge='owner'===qe?'OWNER':'manager'===qe?'MANAGER':'STAFF',Ke=(0,se.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,se.isUnread)(t,s)&&!(0,se.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),Ye=(0,se.useAlerts)(t=>t.todoSeen[e]),Je=Math.max(0,ze-Fe.filter(e=>!Ue[e.id]&&(Ye??[]).includes(e.id)).length)+Ke;(0,se.useAlertSeenSync)(e),(0,j.useEffect)(()=>{G.useShellBadges.setState({notifCount:Je})},[Je]);const Qe=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Xe=he(de),Ze=(0,r.useOutstanding)(),et=Ze.days.length+Ze.requests,tt=me(de,Xe),st='more'===Ae&&'signoff'===Re?'signoff':'more'===Ae&&'rota'===Re?'rota':'forecast'===Ae||'orders'===Ae&&Xe?'more':Ae,ot=t.IS_ISOLATED_VENUE?[{id:e,name:le.name,place:le.location||le.address||''}]:fe,rt=ot.find(t=>t.id===e)??ot[0],nt=Se?.ownerAccess&&'owner'!==Se.role?'owner privileges':Se?.managerAccess&&'staff'===Se.role?'manager privileges':'',at=(0,M.ownerHomeLayout)(de,Se);(0,k.default)().width;return(0,ue.jsxs)(C.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,ue.jsxs)(R.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,ue.jsxs)(R.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>De('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,ue.jsx)(y.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:Je?`Notifications, ${Je} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>De('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),Je?(0,ue.jsx)(R.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(v.T,{size:10,weight:"bold",children:Je})}):null]})}),(0,ue.jsx)(Z.VoiceSlot,{size:44})]}),(0,ue.jsx)(R.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ue.jsx)(R.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,ue.jsx)(y.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${we}. Account and role${nt?`, ${nt}`:''}`,disabled:'owner'!==H.APP_VARIANT,onPress:()=>Oe(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ue.jsxs)(v.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ue.jsx)(P.StaffAvatar,{id:je,size:24,ring:!1}),(0,ue.jsxs)(R.default,{style:{flexShrink:1},children:[(0,ue.jsxs)(v.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[Se?`${we} \xb7 ${Se.level??L.ROLE_LABEL[Se.role]}`:`${we} \xb7 ${L.ROLE_LABEL[de]}`,'owner'===H.APP_VARIANT?' \u25be':'']}),nt?(0,ue.jsx)(v.Muted,{center:!1,size:10,numberOfLines:1,children:nt}):null]})]})})})}),(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>Te(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,ue.jsx)(T.VenueHeaderBlock,{rid:e,name:le.name,badge:Ge,place:`${'staff'===de?'Staff preview \xb7 ':'Managers \xb7 '}${rt.place}`})}),de!==(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner')&&'owner'===H.APP_VARIANT?(0,ue.jsx)(y.default,{onPress:()=>L.useOwner.getState().setPreviewRole(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,ue.jsx)(v.T,{size:12,colour:O.colours.gold,children:'staff'===de?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[de].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`})}):null]}),(0,ue.jsxs)(A.default,{ref:Ee,...$e.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ue.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Re||He),onBack:Me,title:We?We.title:'bookings'===Ae&&'waitlist'===Re?'Waitlist':'staff'===de&&'home'===Ae?'Staff app preview':pe[Ae]}),'home'===Ae&&Se&&'staff'===Se.role&&'owner'===H.APP_VARIANT?(0,ue.jsxs)(R.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,ue.jsx)(v.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,ue.jsx)(v.Button,{label:"Clock in and my shifts",onPress:()=>De('more','clock')})]}):null,'home'!==Ae||at?null:(0,ue.jsx)(a.WhoBar,{}),'home'===Ae&&!at&&Se?(0,ue.jsx)(ie.MyShiftCard,{go:De}):null,'home'===Ae&&!at&&Se?(0,ue.jsx)(h.MyTasksToday,{rid:e,staffId:Se.id,name:Se.name,onShift:(0,p.shiftNow)(Se.id,Date.now()).on}):null,'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TodaysTipsCard,{rid:e,today:ce}),'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TipsPotCard,{rid:e,today:ce}),'home'===Ae?'staff'===de?(0,ue.jsx)(z.StaffHome,{go:De}):(0,ue.jsx)(D.Dashboard,{go:De,ownerHome:at}):null,'orders'===Ae?(0,ue.jsx)(Y.Orders,{}):null,'bookings'===Ae?(0,ue.jsx)(E.Bookings,{go:De,only:'waitlist'===Re?'waitlist':void 0}):null,'forecast'===Ae?(0,ue.jsx)(F.Forecasts,{go:De}):null,'chat'===Ae?(0,ue.jsx)(Q.Chat,{go:De}):null,'more'===Ae?We?(0,ue.jsx)(We.C,{go:De}):(0,ue.jsx)(K.MoreMenu,{go:De}):null]}),(0,ue.jsx)(x.SeatAllergenReminder,{rid:e}),'staff'!==de?(0,ue.jsx)(te.PrintHost,{rid:e}):null,'staff'!==de?(0,ue.jsx)(ee.AlertHost,{variant:"managers",rid:e,me:we,onOpen:e=>De('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,ue.jsx)(X.AssistantSheet,{}),(0,ue.jsx)(q.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:st,onPress:e=>'signoff'===e?De('more','signoff'):'rota'===e?De('more','rota'):De(e),tabs:tt.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?be(Ze.days.length,Ze.requests):'more'===e.id&&Xe&&Ve?`More, ${Ve} new order${Ve>1?'s':''} in Orders`:void 0,badge:'chat'===e.id&&Be?{text:String(Be),bg:O.colours.red}:'bookings'===e.id&&Qe?{text:String(Qe),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&Ve?{text:String(Ve),bg:O.colours.red}:'signoff'===e.id&&et?{text:String(et),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Xe&&Ve?{text:String(Ve),bg:O.colours.red,testID:'more-orders-badge'}:null}))}),(0,ue.jsx)(S.default,{visible:ve,transparent:!0,animationType:"fade",onRequestClose:()=>Te(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Te(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Your venues"}),ot.filter(e=>!Ie||'saltmarsh'!==e.id).map(t=>(0,ue.jsx)(y.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),Te(!1),De('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,ue.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(v.T,{weight:"medium",children:t.name}),(0,ue.jsx)(v.Muted,{children:t.place})]}),t.id===e?(0,ue.jsx)(v.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,ue.jsx)(v.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${le.name}.`:Ie?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,ue.jsx)(S.default,{visible:Le,transparent:!0,animationType:"fade",onRequestClose:()=>Oe(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Oe(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[Se?(0,ue.jsxs)(v.Row,{gap:10,children:[(0,ue.jsx)(P.StaffAvatar,{id:Se.id,size:44}),(0,ue.jsxs)(R.default,{style:{flex:1},children:[(0,ue.jsxs)(v.T,{weight:"semibold",children:["Signed in as ",Se.name]}),(0,ue.jsx)(v.Muted,{children:(0,$.levelJob)(Se.level??L.ROLE_LABEL[Se.role],Se.job)})]})]}):(0,ue.jsxs)(R.default,{style:{gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,ue.jsx)(v.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,ue.jsx)(N.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!Se?null:(0,ue.jsx)(v.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,$.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,ue.jsx)(v.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!Se||(0,_.clampRole)(e,Se.ownerAccess?'owner':Se.managerAccess?'manager':Se.role)===e).map(e=>(0,ue.jsx)(v.Button,{kind:e===de?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),Oe(!1)}},e))]})})}),(0,ue.jsx)(W.OnboardingHost,{go:De}),(0,ue.jsx)(V.CoachHost,{})]})}},1413,[5,828,987,1209,1235,1223,1054,979,1055,2,1060,1061,1093,1114,34,373,395,402,295,426,102,36,794,873,874,891,821,1414,1200,1087,925,1423,1003,236,1432,13,872,1464,1470,1471,1472,1206,1254,1473,1456,1474,1475,1454,1179,1489,1156,1237,1385,1239,1252,1477,1111,1113,1222,1542,1543,1562,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1414,[5,1415,1122,11,1416,827,837,1139,1140,1118,1142,1417,1137,1141,1401,1402,1087,1346,1026,1116,14,1143,1419,1248,1420,1390,1106,1100,1117,34,102,794,1359,874,861,867,858,1331,821,1200,1125,1028,1421,1086,1180,1422,1239,987,1202,1398,878,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1415,[34,794,25]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1416,[6,34,102,794,987,1279,25]); -__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1417,[34,402,102,1418,987,933,821,794,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1418,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1419,[827,5,34,379,236,102,794,876,14,867,1031,933,821,1203,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1420,[34,402,1188,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1421,[34,102,874,1028,794,821,25]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1422,[34,102,879,874,864,821,794,25]); -__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1423,[5,1424,1425,1426,1427,1428,34,236,41,102,872,1429,1003,821,1431,794,987,2,1096,1002,891,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1424,[34,102,873,794,5,6,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1425,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1426,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1427,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1428,[34,102,873,794,25]); -__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1429,[34,295,102,794,873,821,1430,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1430,[]); -__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1431,[929,828,34,1096,336,236,402,295,41,102,872,926,891,831,987,1003,15,793,821,925,794,25]); -__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.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:b,now:F,role:oe,me:ae,today:ne}=(0,A.useCtx)(5e3),ie=(0,p.useOrders)(n),re=(0,p.useBookings)(n),de=(0,p.useWaitlist)(n),ue=(0,p.useEvents)(n),ge=(0,p.useRatings)(n),xe=(0,k.useOwner)(e=>e.staff),ye=(0,k.useOwner)(e=>(0,k.liveAttendance)(e.attendance)),be=(0,k.useOwner)(e=>e.shifts),fe=(0,L.useRealHistory)(n,F),me=(0,o.useMemo)(()=>(0,t.forecastToday)(b,re,ie,ue,F,fe??void 0),[b,re,ie,ue,fe,F.getTime()/6e4|0]),je=(0,N.useExamples)(),pe=(0,P.useCashUp)(e=>e.cashUps),ke=re.filter(e=>e.date===ne),we=ie.filter(D.LIVE),$e=de.filter(e=>'waiting'===e.status||'notified'===e.status),ve=ke.filter(e=>['seated','finished'].includes((0,I.shownStatus)(e))).reduce((e,s)=>e+s.partySize,0),Ce=(0,te.coversSplit)(ke,ne),Ie=Ce.walkIns,Te=Ce.bookings,Be=we.filter(e=>(0,q.chainNeedsAction)(e,re)),De=ke.filter(e=>['confirmed','seated'].includes(e.status)&&(0,q.bookingNeedsAction)(e,we)),Ae=we.flatMap(e=>(0,v.readinessFor)(e,b,F).map(s=>({...s,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Se=me.nextHour,Le=(0,D.busyLevel)(Se?.coversHigh??0,me.busy.busy),Ne=(0,D.restOfDayLevel)(me,b),Pe=ie.filter(e=>e.paid>0&&!!e.createdAt&&(0,C.ymd)(new Date(e.createdAt))===ne).reduce((e,s)=>e+s.paid,0),Me=(0,H.tradingDay)(F),Fe=je?(0,S.revenueHistory)(b,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Oe=je?{today:186e3+Pe,last:Fe?{date:(0,C.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,W.takingsToday)(pe,n,Me,Pe),Re=k.CAN.takings(oe)&&(!(0,R.isLive)()||(0,R.can)('takings.view')),He=(0,o.useMemo)(()=>(0,S.insights)(b,re,ie,ue,ge,F,ve),[b.id,re.length,ge.length,ve]),We=((0,A.weekday)(F),ye.filter(e=>e.date===ne&&e.in&&!e.out)),Ee=(0,J.useFrontDoor)(ne),ze=(0,h.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,r.useTravelDay)('owner',ne),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,M.canSeeMonthTakings)(oe,qe,{inStaffApp:Ye,live:(0,R.isLive)()}),Qe=(0,O.homeSetupNagsHidden)(n),Ve=(0,k.useOwner)(e=>e.socialPosts.reduce((e,s)=>e+('awaiting approval'===s.status?1:0),0)),[Xe,Ze]=(0,o.useState)(!1),Je=ae.replace(' (example)',''),es=k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(r.DayView,{rid:n,day:Ue,today:ne,app:"owner"})]}):a?(0,le.jsxs)(m.default,{style:{gap:12},testID:"owner-home",children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Re&&Oe.show?(0,le.jsx)(j.Row,{wrap:!0,gap:10,children:(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})})}):null,(0,le.jsx)(X.TodaysTipsCard,{rid:n,today:ne}),(0,le.jsx)(X.TipsPotCard,{rid:n,today:ne}),k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),qe&&'owner'!==qe.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,le.jsx)(V.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,Z.shiftNow)(qe.id,Date.now()).on}):null,k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]}):(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,Re&&Oe.show?(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=de,_e.MonthTakingsCard=ce,_e.WalkInSplitCard=he;var s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),o=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),y=_r(_d[12]),b=e(_r(_d[13])),f=e(_r(_d[14])),m=e(_r(_d[15])),j=_r(_d[16]),p=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),I=_r(_d[23]),T=_r(_d[24]),B=_r(_d[25]),D=_r(_d[26]),A=_r(_d[27]),S=_r(_d[28]),L=_r(_d[29]),N=_r(_d[30]),P=_r(_d[31]),M=_r(_d[32]),F=_r(_d[33]),O=_r(_d[34]),R=_r(_d[35]),H=_r(_d[36]),W=_r(_d[37]),E=_r(_d[38]),z=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),q=_r(_d[42]),Y=_r(_d[43]),_=_r(_d[44]),K=_r(_d[45]),Q=_r(_d[46]),V=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),se=_r(_d[52]),te=_r(_d[53]),le=_r(_d[54]);const oe=18,ae=18,ne=150,ie=34;function re(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const s=e.length,t=[],l=[];for(let l=0;l9){const n=3/Math.sqrt(a);l[e]=n*s*t[e],l[e+1]=n*o*t[e]}}let o=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let t=0;toe+(s-1)/Math.max(1,e-1)*t,o=[1,5,10,15,20,25].filter(s=>s=36)&&a.push(e);for(;a.length&&l(e)-l(a[a.length-1])<36;)a.pop();return[...a,e]}function ce({rid:e,today:s}){const t=(0,P.useCashUp)(e=>e.cashUps),[l,i]=(0,o.useState)(s.slice(0,7)),[r,d]=(0,o.useState)(0),[c,u]=(0,o.useState)(null),h=(0,o.useMemo)(()=>(0,M.monthTakings)(t,e,l,s),[t,e,l,s]),x=(0,o.useMemo)(()=>(0,M.firstTakingsMonth)(t,e),[t,e]),y=!!x&&xoe+(e-1)/Math.max(1,k-1)*w,I=e=>$-e/v*128,T=[];h.days.forEach((e,s)=>{if('recorded'!==e.state)return;const t={x:C(e.day),y:I(e.value)};s&&'recorded'===h.days[s-1].state?T[T.length-1].push(t):T.push([t])});const D=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),S=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===s):void 0)??A??D[D.length-1],L=e=>{const s=D.findIndex(e=>e.date===S?.date),t=D[Math.max(0,Math.min(D.length-1,s+e))];t&&(u(t.date),b.default.announceForAccessibility?.(N(t)))},N=e=>`${(0,M.longDay)(e.date)}, ${'recorded'===e.state?(0,M.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,O=h.current?`so far in ${h.month}`:`in ${h.month} ${l.slice(0,4)}`,R=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,M.monthName)((0,M.addMonths)(l,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,H=h.recorded?`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. ${(0,M.poundsWhole)(h.total)} ${O}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,M.longDay)(h.best.date)}, ${(0,M.poundsWhole)(h.best.value)}.${R?` ${R.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,W=r?de(k,r):[],E=(e,s,t,o,a)=>(0,le.jsx)(f.default,{testID:a,accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{disabled:!t},disabled:!t,onPress:()=>{i((0,M.addMonths)(l,o)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:t?e?.6:1:.25}),children:(0,le.jsx)(j.T,{size:24,colour:B.colours.gold,center:!0,children:e})});return(0,le.jsx)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(m.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),y||p?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[E('\u2039',`Previous month, ${(0,M.monthName)((0,M.addMonths)(l,-1))}`,y,-1,'mt-prev'),(0,le.jsxs)(j.T,{center:!0,colour:B.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",l.slice(0,4)]}),E('\u203a',`Next month, ${(0,M.monthName)((0,M.addMonths)(l,1))}`,p,1,'mt-next')]}):null,(0,le.jsx)(m.default,{accessible:!0,accessibilityLabel:H,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(j.T,{size:38,weight:"bold",colour:B.colours.gold,center:!0,testID:"mt-total",children:(0,M.poundsWhole)(h.total)}),(0,le.jsx)(j.T,{center:!0,colour:B.colours.goldLight,children:O}),(0,le.jsxs)(j.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,M.shortDay)(h.best.date)," \xb7 ",(0,M.poundsWhole)(h.best.value)]}),R?(0,le.jsx)(j.Muted,{center:!0,testID:"mt-vs",children:R}):null]}):(0,le.jsx)(j.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(m.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(m.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ne,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ne,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:oe,y1:$,x2:r-ae,y2:$,stroke:B.colours.hairline,strokeWidth:1}),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:`${re(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${s}`)),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:re(e),stroke:B.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${s}`)),T.filter(e=>1===e.length).map((e,s)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:B.colours.gold},`s${s}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:C(e.day),cy:$,r:2,fill:"none",stroke:B.colours.muted,strokeWidth:1},e.date)),S&&'recorded'===S.state?(0,le.jsx)(a.Line,{x1:C(S.day),y1:10,x2:C(S.day),y2:$,stroke:B.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===s);return(0,le.jsx)(a.Circle,{cx:C(e.day),cy:'recorded'===e.state?I(e.value):$,r:4.5,fill:B.colours.gold,stroke:B.colours.surface,strokeWidth:1.5})})():null,S&&'recorded'===S.state&&S.date!==s?(0,le.jsx)(a.Circle,{cx:C(S.day),cy:I(S.value),r:5,fill:B.colours.surface,stroke:B.colours.gold,strokeWidth:2}):null]}):null,r?D.map(e=>(0,le.jsx)(f.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:N(e),accessibilityState:{selected:S?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ne,left:C(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(m.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:W.map(e=>(0,le.jsx)(j.T,{size:F.AXIS_FONT,colour:B.colours.muted,style:{position:'absolute',left:C(e)-17,width:ie,top:0,textAlign:'center'},children:String(e)},e))})]}),S&&D.length?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(f.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:D[0]?.date===S.date,onPress:()=>L(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[0]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(m.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:N(S),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(j.Muted,{center:!0,children:S.date===s?`Today \xb7 ${(0,M.shortDay)(S.date)}`:(0,M.shortDay)(S.date)}),(0,le.jsx)(j.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===S.state?B.colours.goldLight:B.colours.muted,children:'recorded'===S.state?(0,M.poundsWhole)(S.value):'pending'===S.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(f.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:D[D.length-1]?.date===S.date,onPress:()=>L(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[D.length-1]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(j.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ue='#3A2F1E';function he({split:e}){return(0,le.jsx)(j.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(m.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(j.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(m.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",colour:B.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(m.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ue,borderWidth:1,borderColor:B.colours.gold},children:[(0,le.jsx)(m.default,{style:{width:`${e.walkInPct}%`,backgroundColor:B.colours.gold}}),(0,le.jsx)(m.default,{style:{flex:1,backgroundColor:ue}})]})]})]})})}},1432,[860,1160,1433,34,797,1098,1201,1102,1103,1420,1346,877,1106,281,402,102,794,874,891,1209,861,1178,858,1100,881,821,1200,1087,1159,1165,1166,1038,13,1170,927,987,999,1442,1443,1169,1444,1180,869,1447,1204,1223,1222,1060,1061,1093,1125,1390,1173,1345,25]); -__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.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:z}=(0,R.useCtx)(6e4),V=z.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsxs)(j.Muted,{size:12,children:["Uses: ",e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')," from the counted stock. Held from the Display count and shown as \u201cReserved\u201d."]})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),De=J.hourOverrides??[],Re=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:D.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),Re?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:Re}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!Re,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),De.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:De.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...De.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),ze=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,$e]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{$e(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From a party of"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from party size"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:D.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)($.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:ze,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:D.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:D.colours.accentBorder,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:D.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:D.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,R.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:D.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:D.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:D.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),D=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),z=_r(_d[31]),I=_r(_d[32]),$=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:D.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?D.colours.red:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:D.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:D.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:D.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:D.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,z.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:D.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1433,[1161,1062,5,1415,827,1434,1435,1437,1438,1439,1219,1060,1061,1038,1043,34,402,102,794,14,1440,831,878,1100,877,821,1087,874,1203,1008,1009,891,1441,1385,1028,1110,1035,1163,980,25]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1434,[827,34,102,794,1160,877,821,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1435,[860,34,236,102,794,874,1028,1174,1270,987,1341,1436,25]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1436,[860,1294]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1437,[34,102,794,1028,1350,821,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1438,[34,102,794,1028,858,1393,5,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1439,[]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1440,[34,1062,102,821,794,1267,1270,25]); -__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1441,[34,102,794,1028,1363,821,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1442,[]); -__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},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])},1443,[34,402,102,794,821,1169,1442,25]); -__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1444,[927,796,831,828,837,878,1075,1445,34,993,336,379,236,402,102,794,874,891,858,821,1200,1087,1229,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1445,[499,1446]); -__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 t={}},1446,[]); -__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.ProgressBar=D,_e.useSetupDone=O,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,C.useCtx)(6e4),n=O(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=f.SETUP_STEPS.findIndex(e=>e.id===a),s=f.SETUP_STEPS[e+1]?.id??null;return(0,E.jsx)(L,{id:a,wizard:!0,onBack:()=>l(e>0?f.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=f.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,E.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{gap:12,children:[(0,E.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(m.T,{size:20,weight:"bold",colour:S.colours.gold,children:["Set up ",t.name]}),(0,E.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,E.jsx)(D,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,E.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,E.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:S.colours.border,backgroundColor:S.colours.surface,overflow:'hidden'},children:f.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,E.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:S.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,E.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?S.colours.gold:'transparent',borderWidth:1.5,borderColor:t?S.colours.gold:S.colours.border},children:(0,E.jsx)(m.T,{weight:"bold",colour:t?S.colours.onGold:S.colours.muted,children:t?'\u2713':s+1})}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"medium",children:e.title}),(0,E.jsx)(m.Muted,{children:e.sub}),o.length?(0,E.jsxs)(m.T,{size:13,colour:S.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,E.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=L,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return W}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,C.useCtx)(6e4),t=O(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,E.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:"Finish setting up"}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]}),(0,E.jsx)(D,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,E.jsxs)(m.Muted,{size:13,children:["Next: ",f.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]);const M=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],R=[1,2,3,4,5,6,0],I=/^([01]\d|2[0-3]):[0-5]\d$/,$=e=>{const s=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(s)&&s>0?Math.round(100*s):null},B=e=>f.SETUP_STEPS.findIndex(s=>s.id===e)+1;function D({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,E.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,E.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:S.colours.gold,borderRadius:5}})}),(0,E.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function O(e){const s=(0,f.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=f.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:f.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function L({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,C.useCtx)(6e4),l=O(a),r=l.prog,d=(0,i.useLiveVenue)(),u=f.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=_[e];return(0,E.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(m.T,{size:12,weight:"semibold",colour:S.colours.gold,children:["STEP ",B(e)," OF ",f.SETUP_STEPS.length]}),s&&o?(0,E.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,E.jsx)(m.T,{size:13,colour:S.colours.muted,children:"All steps"})}):null]}),(0,E.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,E.jsx)(D,{done:r.done,total:r.total})]}),(0,E.jsx)(b,{rid:a,done:(t="Saved.")=>{f.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,E.jsx)(m.Banner,{kind:"success",title:p}):null,(0,E.jsx)(N,{rid:a,id:e,title:u.title,onDone:x}),s?(0,E.jsxs)(m.Row,{gap:10,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,E.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const A=({wizard:e,onPress:s,disabled:t,label:n})=>(0,E.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const F=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function U({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,C.useHourly)(),d=(0,f.useSiteSetup)(e),u=(0,f.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,w.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,f.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),T(null)},z=!!p?.id&&(M=p.id,k.ROSTER.some(e=>e.id===M));var M;const R=p?$(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=R||z&&!p.wage);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,E.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,E.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?S.colours.gold:S.colours.border,backgroundColor:s?'#1d1a14':S.colours.surface}),children:[(0,E.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"semibold",children:e.name}),(0,E.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,f.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,E.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,f.accessOf)(e.level,e.role)})]},e.id))}),y?(0,E.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:S.colours.gold},children:(0,E.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,E.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,E.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,E.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,E.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,E.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Access level"}),(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:f.ACCESS_LEVELS.map(e=>(0,E.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,E.jsxs)(m.Muted,{size:13,children:["Uses the ",f.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Pay"}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,E.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,E.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,E.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,E.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,w.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,E.jsx)(m.Field,{label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=R&&R<1271?(0,E.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,E.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,E.jsxs)(m.Row,{gap:8,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,E.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),f.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:f.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=R&&s.setRate(t,R);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),f.useSetup.getState().patch(e,{staffGrade:o}),f.useSetup.getState().setLook(t,p.look),T(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,E.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,E.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(F(d.grades[0]?.id??'')),T(null)}}),(0,E.jsx)(A,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const _={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,f.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,E.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,E.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,E.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,E.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':'anchorage'===e?'The Anchorage logo in black and gold.':'greenside'===e?'The Greenside Restaurant logo.':'abbotsford'===e?'The Abbotsford Hotel logo.':'kirkton'===e?'The Kirkton Inn logo.':'wildings'===e?'The Wildings Hotel & Restaurant logo.':'kirkmichael'===e?'The Kirkmichael Arms logo.':'souters'===e?'The Souter\u2019s Inn logo.':'Placeholder initials.'," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,E.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,E.jsx)(P.OrderAtTableCard,{rid:e,compact:!0}),u?(0,E.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,E.jsx)(A,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,C.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=R.filter(e=>{const s=n[e];return s&&(!I.test(s[0])||!I.test(s[1]))});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),M.map((e,s)=>{const t=R[s],l=n[t];return(0,E.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:S.colours.border,paddingTop:s?6:0},children:[(0,E.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,E.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"to"}),(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,E.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,E.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries(R.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,E.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,E.jsx)(A,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,y.usePlan)(e),o=(0,y.planCounts)(n);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.TablePlan,{startStep:"areas"}),(0,E.jsx)(A,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,E.jsx)(U,{...e,payList:!0})]})},staff:U,permissions:function({done:e,wizard:s}){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(z.PermissionsScreen,{}),(0,E.jsx)(A,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,f.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,E.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,E.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,E.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,E.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,E.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,E.jsx)(A,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),a=(0,f.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,T.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,E.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,E.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:S.colours.border,padding:10},children:(0,E.jsx)(m.T,{size:14,colour:S.colours.goldLight,children:i})}),(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,T.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,E.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,E.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,E.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,E.jsx)(A,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),f.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,C.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,E.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,E.jsx)(A,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},W=e=>function(){return(0,E.jsx)(L,{id:e})};function N({rid:e,id:s,title:t,onDone:n}){const o=O(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,E.jsxs)(g.default,{style:{gap:4},children:[(0,E.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),f.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,E.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,E.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1447,[929,928,828,827,1075,1448,1449,1450,1451,1453,34,402,102,873,925,794,874,891,1028,927,15,867,821,1087,1454,1457,1461,1462,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1448,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1449,[34,987]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1450,[34,846,987]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1451,[2,827,34,236,383,102,794,1452,987,821,1204,1003,891,993,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1452,[]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1453,[34,402,794,987,821,1451,25]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1454,[827,979,1160,987,797,1237,1239,34,281,379,236,402,102,426,879,794,874,1248,891,867,858,821,1200,1087,869,1444,1179,1455,1456,1159,1166,1165,1038,13,1163,1169,1229,25]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1455,[827,34,1235,1055,870,379,402,102,794,891,867,858,821,1200,1087,1229,25]); -__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1456,[1015,34,402,102,794,891,821,1087,987,25]); -__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1457,[827,34,1047,395,102,1133,1134,1361,1390,794,1025,1028,858,821,1087,1029,1458,1459,1049,25]); -__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1458,[827,34,402,102,794,821,1028,5,1029,872,987,25]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1459,[34,102,794,1028,1460,859,821,1074,933,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1460,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1461,[5,1415,34,102,794,874,891,25]); -__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.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1462,[34,281,402,102,794,821,999,1463,25]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1463,[933,987,891,872,999]); -__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.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=M,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=M(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',O[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:O[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withWildingsQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function M(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const O={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from Bidfood or Booker? Add them here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1464,[832,1206,34,281,283,364,395,236,295,102,36,794,873,876,891,1028,1065,1066,5,859,1063,1073,821,872,1087,1465,1468,25]); -__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.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1465,[827,34,379,402,295,102,794,1466,1467,821,1464,1087,891,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1466,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1467,[839,846,849]); -__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.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1468,[34,402,102,794,876,1467,1028,859,1469,1073,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1469,[]); -__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1470,[828,34,283,364,236,402,102,846,794,821,25]); -__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1471,[1201,1098,1139,1116,34,402,102,794,891,858,821,1117,1187,1087,1198,1444,1180,876,1202,869,1200,925,1421,1028,860,1125,1217,1221,1097,25]); -__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.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1472,[34,1100,102,426,794,874,1162,1160,877,858,821,891,1200,1087,1169,1165,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1473,[846]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=P,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,x]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)).slice(0,8),R=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),A=R.filter(e=>'due'===e.state||'overdue'===e.state),M=R.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,B.jsxs)(o.default,{style:{gap:12},children:[(0,B.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),b?(0,B.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,B.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,B.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,B.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,B.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,B.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===A.length?(0,B.jsx)(i.Muted,{children:"Nothing due right now."}):null,A.map(e=>(0,B.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,y.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,B.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,B.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,B.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),M.map(e=>(0,B.jsxs)(i.Muted,{children:[(0,y.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,y.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,B.jsx)(k.SectionHead,{title:"Live orders",right:(0,B.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,B.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,B.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,B.jsx)(P,{o:e},e.id)),v.length?(0,B.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,B.jsx)(i.Card,{style:{opacity:.7},children:(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,B.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,B.jsx)(O,{onClose:e=>{h(!1),e&&x(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),x=_r(d[13]),y=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]);const R={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function O({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),y=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,R]=(0,r.useState)(''),[O,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[N,$]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,F]=(0,r.useState)(''),[_,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,x.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries(N).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(y.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.ukPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(_),J=K.length>0&&Y&&(Q?O.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(y.map(e=>e.section)));return(0,B.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,B.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,B.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,B.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,B.jsx)(i.Field,{label:"Table number",value:O,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,B.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:R,placeholder:"e.g. Mrs Reid"}),Q?null:(0,B.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:F,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,B.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,B.jsx)(i.Field,{label:"Email (optional)",value:_,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too"}),'phone'===T?(0,B.jsxs)(o.default,{style:{gap:4},children:[(0,B.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,B.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,B.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,B.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),y.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,B.jsxs)(o.default,{style:{flex:1},children:[(0,B.jsx)(i.T,{size:15,children:e.name}),(0,B.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,B.jsx)(i.Stepper,{value:N[e.id]??0,min:0,max:20,label:e.name,onChange:t=>$({...N,[e.id]:t})})]},e.id)),(0,B.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,B.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,B.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,B.jsx)(l.GreensideCashOnly,{}):(0,B.jsx)(i.Banner,{kind:"demo",title:"Card payments: not set up yet",children:"Pay on collection or at the table. Nothing is charged in the app."}),(0,B.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?O.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:_.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${O.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function P({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),x=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,B.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,B.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,y.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",R[e.channel??(e.type,'app')]," \xb7 ",(0,y.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,B.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,B.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,B.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,B.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,B.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,B.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,y.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,B.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,B.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,B.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,B.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,B.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:x,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,B.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,B.jsx)(i.Button,{small:!0,kind:"ghost",label:"Reject",onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1474,[5,1415,860,1385,34,102,794,874,876,881,861,867,1178,1130,858,821,1200,1087,1179,1180,869,1422,864,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return pe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),b=_r(d[9]),h=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),E=_r(d[18]),N=_r(d[19]),P=_r(d[20]),W=_r(d[21]),A=_r(d[22]),R=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),G=_r(d[27]),B=(e=G)&&e.__esModule?e:{default:e},x=_r(d[28]),D=_r(d[29]),I=_r(d[30]),L=_r(d[31]),H=_r(d[32]),_=_r(d[33]),F=_r(d[34]),V=_r(d[35]),Q=_r(d[36]),q=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),K=_r(d[41]),z=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),ae=_r(d[49]),se=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),de=_r(d[55]),ue=_r(d[56]),le=_r(d[57]),ge=_r(d[58]),ce=_r(d[59]);const pe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},be=e=>n.CAN.manage(e);(0,y.register)([{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>be(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:be,C:R.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:w.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:be,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>be(e)&&!r.IS_CAR,badge:'NEW',C:P.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:be,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:be,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',badge:'NEW',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:be,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:be,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:be,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:be,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:b.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:be,badge:'NEW',C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:h.PLAN_SUB,group:'Account',can:n.CAN.billing,C:h.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',badge:'NEW',C:T.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',badge:'NEW',C:W.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:W.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',badge:'NEW',can:be,C:A.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:W.Timesheets}]),(0,y.register)([{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:M.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:M.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',badge:'NEW',can:be,C:E.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',badge:'NEW',can:be,C:N.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'Photo of the cash up sheet, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',badge:'NEW',can:be,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:M.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:M.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:M.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:be,C:M.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:be,C:M.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:be,C:M.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:be,C:M.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:be,C:M.ReviewEmailSettings},{id:'compliance',title:'Daily checks & allergen log',sub:'Fridge temps, opening checks, audit log',group:'Compliance',C:M.Compliance},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:M.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:be,badge:'NEW',C:M.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:M.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:O.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>pe(),C:O.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:be,C:O.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:be,C:O.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:O.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:be,C:O.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:be,C:O.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:be,C:O.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:be,C:O.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:O.TabletPreview}]);const he=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',badge:'NEW',C:()=>B.default.createElement(D.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:x.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',badge:'NEW',can:he,C:x.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',badge:'NEW',can:he,C:D.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',badge:'NEW',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:I.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',badge:'NEW',C:L.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:be,C:L.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:be,badge:'NEW',C:L.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:be,badge:'NEW',C:H.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:be,badge:'NEW',C:H.DisplaySettingsPage}]);const fe=e=>'owner'===e||'manager'===e;_.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:fe,badge:'NEW',C:_.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off, voice, connected services',group:'Account',can:fe,C:_.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',badge:'NEW',can:e=>'owner'===e&&!r.IS_CAR,C:V.CarScreen}]);const ye=e=>'owner'===e||'manager'===e,me=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Ce=e=>ye(e)&&me();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ye,badge:'NEW',C:F.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Prices},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning, allergen checks; filters; CSV and print for the EHO',group:'Compliance',can:ye,badge:'NEW',C:F.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ye,badge:'NEW',C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',badge:'NEW',C:F.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:be,badge:'NEW',C:Q.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:be,badge:'NEW',C:Q.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:be,badge:'NEW',C:Q.Outbox}]);const Se=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Se,badge:'NEW',C:U.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Se,badge:'NEW',C:q.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Se,badge:'NEW',C:Y.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Se,badge:'NEW',C:j.OrderSheetSettings},...K.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Se,C:(0,q.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Se,badge:'NEW',C:z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Se,badge:'NEW',C:$.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:be,badge:'NEW',C:$.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Se,badge:'NEW',C:$.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Se,badge:'NEW',C:J.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:be,badge:'NEW',C:X.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:be,badge:'NEW',C:X.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:be,badge:'NEW',C:X.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:be,badge:'NEW',C:Z.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:be,badge:'NEW',C:ee.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:be,badge:'NEW',C:ae.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, Booker and Bidfood lists, offers, events and specials the voice helper prepared; nothing is sent',group:'Run the day',can:be,badge:'NEW',C:se.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift, left by voice or typing',group:'Run the day',badge:'NEW',C:se.ShiftNotesPage},{id:'voice',title:'Voice helper',sub:'Hold-to-talk input, text-only replies, who gets it and microphone privacy',group:'Settings',can:be,badge:'NEW',C:se.VoiceSettingsPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ie.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update',group:'Compliance',can:ye,badge:'NEW',C:function(){return B.default.createElement(re.FoodSafetyCard,null)}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ne.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ye,badge:'NEW',C:function(){const{rid:e,today:t}=(0,oe.useCtx)(6e4);return B.default.createElement(ne.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',badge:'NEW',C:function(){const{rid:e,me:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:be,badge:'NEW',C:te.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',badge:'NEW',C:function(){const{me:e,role:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(ue.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:be,C:le.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:be,C:ge.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,badge:'NEW',C:ce.UseOnComputerPage}])},1475,[837,1085,872,1476,891,1003,993,831,881,1478,1485,1495,1456,1496,1497,1499,1500,1472,1501,1502,1504,1218,1209,1474,1505,1454,1506,34,1217,1198,1455,1444,1457,1489,1511,1512,1513,1447,1433,1461,1514,927,1515,1516,1518,1204,1464,1519,1385,1465,1531,1107,1110,1087,1219,1173,1532,1535,1538,1541]); -__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,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return k}}),_e.DashCorners=I,_e.ServiceBoard=function(){const{role:e}=(0,j.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,D.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,D.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,D.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,D.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,D.jsx)(I,{onLeave:y}),(0,D.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,D.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,D.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,D.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,D.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,D.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?w((0,D.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]),D=r(d[16]);const k=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function C({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,D.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,D.jsxs)(s.default,{children:[(0,D.jsx)(p.Icon,{name:t,colour:h.colours.gold}),u?(0,D.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,D.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function I({onLeave:e}){const t=(0,x.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>y.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,D.jsx)(C,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,D.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,D.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:k.filter(e=>'left'===e.side).map(n)}),(0,D.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[k.filter(e=>'right'===e.side).map(n),(0,D.jsx)(C,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')}),(0,D.jsx)(f.VoiceSlot,{size:44,layer:1})]})]})}function w(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[17]);return t(e,document.body)}},1476,[34,395,236,402,102,36,794,1055,1343,891,821,1156,1477,1206,1473,1087,25,277]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1477,[846]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, take a picture of the taking sheet and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1478,[827,1453,34,867,102,794,891,821,1087,925,926,1479,987,1000,1060,1451,1480,1481,1483,1026,1484,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1479,[]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1480,[827,34,102,794,821,891,1395,1405,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1481,[34,102,794,1482,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1482,[846,933,987,2]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1483,[34,102,794,821,998,1051,987,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1484,[933,987]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_VOICE_LINE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_SUPPLIER_LINE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DONE_FOR_YOU",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"doneForYouLine",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return v}}),_e.PlanBilling=function(){const{now:e,role:n,rid:b}=(0,p.useCtx)(6e4),j=(0,c.trialStatus)((0,l.defaultSimStart)(),e),[x,w]=(0,s.useState)(!1);return u.CAN.billing(n)?x?(0,y.jsx)(M,{onBack:()=>w(!1)}):(0,y.jsxs)(i.default,{style:{gap:10},children:[(0,y.jsx)(o.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,y.jsx)(t.VoiceUsageCard,{rid:b,now:e}),(0,y.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,y.jsxs)(i.default,{testID:"plan-founding",children:[(0,y.jsx)(o.T,{size:12,weight:"semibold",colour:h.colours.goldMuted,children:"FOUNDING OFFER \xb7 FIRST 50 VENUES"}),(0,y.jsxs)(o.T,{size:30,weight:"bold",children:["\xa349",(0,y.jsx)(o.T,{size:14,colour:h.colours.muted,children:" a month + VAT if applicable, per venue"})]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,y.jsx)(o.Badge,{kind:"gold",label:"Every Full Restaurant Pro feature"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"One month free"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"\xa349 net locked in"})]}),(0,y.jsx)(o.Muted,{children:"Early adopter price for the first 50 venues: every Full Restaurant Pro App feature, including the owner's dashboard and admin and the voice Assistant. \xa349 net stays locked in while your subscription stays active."}),(0,y.jsxs)(o.T,{size:13,testID:"plan-early-done-for-you",children:["\u2713 ",T(P.early)]}),(0,y.jsx)(o.Muted,{children:"From venue 51, usual prices:"}),(0,y.jsxs)(i.default,{testID:"plan-usual-lite",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[k," \xb7 ",C," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:S}),O.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e)),(0,y.jsx)(o.T,{size:13,testID:"plan-lite-not-included",children:"Not included: the owner's dashboard and admin, or the voice Assistant."})]}),(0,y.jsxs)(i.default,{testID:"plan-usual-pro",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[_," \xb7 ",L," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:v}),R.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e))]}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>w(!0),style:{marginTop:6}})]}),(0,y.jsx)(o.Card,{children:(0,y.jsxs)(i.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,y.jsx)(o.T,{weight:"bold",colour:h.colours.gold,children:"free"}),"."]}),(0,y.jsx)(o.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,y.jsx)(o.Muted,{children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, and subscribers get free lifetime 24/7 customer support. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{children:"Free trial"}),(0,y.jsxs)(o.T,{weight:"bold",colour:h.colours.gold,children:[j.daysLeft," day",1===j.daysLeft?'':'s'," left"]})]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(100*(1-j.daysLeft/j.total))}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),(0,y.jsxs)(o.Muted,{children:["Then \xa3",c.PLAN.monthlyPence/100," a month + VAT if applicable. The trial start date is not set up yet."]})]}),(0,y.jsx)(f.AssistantPlanCard,{}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{weight:"semibold",children:"Free lifetime customer support"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"Included"})]}),(0,y.jsx)(o.Muted,{children:"Free for as long as you subscribe, day or night. Setup is all done digitally. Support contact details: not set up yet."})]})]}):(0,y.jsx)(o.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),i=(e=n)&&e.__esModule?e:{default:e},o=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]);const b=!0,j='Founding offer, free trial, set-up guide',x='. The owner\'s dashboard and admin come with Full Restaurant Pro App (\xa399 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',w='Voice Assistant (hold to talk) for seating guests, marking tables as cleared, temperature logs and finding something in the app: fair usage 1,000 voice tasks a month per venue',A='Supplier links: open your suppliers\' ordering sites and keep order lists',P={lite:1,pro:3,early:3},T=e=>`${e} done-for-you ${1===e?'change':'changes'} a month`,k='Customer & Takeaway App',_='Full Restaurant Pro App',C='\xa349',L='\xa399',S='A lite version of CoverCharge: 3 core customer and takeaway functions tailored to you, set up digitally with the in-app guided setup and step-by-step guides, free lifetime 24/7 customer support while subscribed, and unlimited self-edits of your basic info. The owner\'s dashboard and admin, and the voice Assistant, are not included.',v='Every feature, every app, including the owner\'s dashboard and admin and the voice Assistant. Set up digitally with the in-app guided setup and step-by-step guides, the Assistant (fair use 300 tasks a month), free lifetime 24/7 customer support while subscribed, and unlimited self-edits.',O=['Customer app: menu, allergens, bookings and loyalty','Takeaway ordering','Set up digitally: in-app guided setup and step-by-step guides','Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits of your basic info',T(P.lite)],R=['Every feature, every app','The owner\'s dashboard and admin',A,'Set up digitally: in-app guided setup and step-by-step guides','The Assistant, fair use 300 tasks a month',w,'Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits',T(P.pro)],I=[['Choose your 3 core functions','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function M({onBack:e}){const[t,n]=(0,s.useState)([]);return(0,y.jsxs)(i.default,{style:{gap:10},testID:"setup-guide",children:[(0,y.jsx)(o.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,y.jsx)(o.H2,{children:"Set-up guide"}),(0,y.jsxs)(o.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",t.length," of ",I.length," done."]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(t.length/I.length*100)}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),I.map(([e,s],l)=>{const u=t.includes(l);return(0,y.jsx)(o.Card,{children:(0,y.jsxs)(o.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,y.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:u?h.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(o.T,{size:14,weight:"bold",colour:u?'#1a1610':h.colours.gold,children:u?'\u2713':String(l+1)})}),(0,y.jsxs)(i.default,{style:{flex:1,gap:4},children:[(0,y.jsx)(o.T,{weight:"semibold",children:e}),(0,y.jsx)(o.Muted,{children:s}),(0,y.jsx)(o.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>n(u?t.filter(e=>e!==l):[...t,l])})]})]})},e)}),(0,y.jsx)(o.Muted,{children:"Stuck? Free lifetime customer support is included while you subscribe. Ticks on this guide are not saved."})]})}},1485,[1486,34,102,794,850,891,1488,821,1087,1489,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1486,[34,102,794,821,1487,25]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1487,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1488,[]); -__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,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return v}}),_e.AssistantFab=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)(e=>e.enabled);return R(e)&&t?(0,A.jsxs)(c.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>v.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:k.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,A.jsx)(M,{size:22}),(0,A.jsx)(b.T,{weight:"bold",colour:I,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=v(e=>e.open),o=()=>v.getState().setOpen(!1),{rid:a,role:p,me:C}=(0,w.useCtx)(3e4),S=(0,j.useAssistant)(),I=B(),[E,L]=(0,r.useState)([]),[W,z]=(0,r.useState)(''),[$,_]=(0,r.useState)(!1),N=(0,r.useRef)(null),F=(0,r.useRef)(null);if((0,r.useEffect)(()=>{setTimeout(()=>N.current?.scrollToEnd?.({animated:!0}),50)},[E.length]),!e||!R(p))return null;const H=(e,t,s)=>j.useAssistant.getState().record({at:(new Date).toISOString(),by:C,role:p,asked:e,action:t,outcome:s}),U=(e,t="result")=>L(s=>[...s,{id:D(),from:'assistant',text:e,kind:t}]),V=async e=>{const t=e.trim();if(!t)return;let s;z(''),L(e=>[...e,{id:D(),from:'you',text:t}]);try{s=await(0,y.getProvider)('xai').interpret(t,I)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&H(t,'\u2014','not understood'),L(e=>[...e,{id:D(),from:'assistant',proposal:s,state:'open',asked:t}])},G=(e,t)=>L(s=>s.map(s=>s.id===e?{...s,state:t}:s)),q=async(e,t,n)=>{if(G(e.id,'confirmed'),'external'===t.kind)return H(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void U(T,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await m.repo.bookings.seatWalkIn(a,Number(o.party),s,'Added by Assistant'),s&&(0,f.resetTableLive)(a,s),U(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),H(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),U(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),H(e.asked,t.title,'done');break;case'price':await m.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),U(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),H(e.asked,t.title,'done');break;case'offer':x.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),U(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),H(e.asked,t.title,'done');break;case'rota':case'bookings':U(String(o.result)),H(e.asked,t.title,'looked up')}},Y=e=>{G(e.id,'cancelled'),H(e.asked,e.proposal?.title??'\u2014','cancelled'),U('Cancelled. Nothing was changed.','note')},K='lite'===S.tier,J=(0,j.tasksUsed)(S);return(0,A.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,A.jsx)(h.default,{style:[b.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,A.jsxs)(h.default,{testID:"assistant-sheet",style:{backgroundColor:k.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:k.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.Row,{gap:8,style:{flex:1},children:[(0,A.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:18})}),(0,A.jsx)(b.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,A.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,A.jsx)(h.default,{testID:"assistant-demo-badge",children:(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),K?(0,A.jsxs)(h.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,A.jsx)(b.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,A.jsx)(b.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(u.default,{ref:N,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===E.length?(0,A.jsxs)(h.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,A.jsxs)(b.T,{children:["Hi ",C.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,A.jsx)(b.Muted,{children:"Try:"}),y.SUGGESTED_PROMPTS.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:k.colours.surface2},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]}):null,E.map(e=>'you'===e.from?(0,A.jsx)(h.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,A.jsx)(b.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,A.jsx)(P,{m:e,onConfirm:(t,s)=>q(e,t,s),onCancel:()=>Y(e)},e.id):'choose'===e.proposal.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),(0,A.jsx)(b.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>V(e.prompt)},e.label))})]},e.id):(0,A.jsxs)(h.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:8},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]},e.id):(0,A.jsx)(h.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?k.colours.amberBg:k.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:k.colours.amber},children:(0,A.jsx)(b.T,{children:e.text})},e.id))]}),(0,A.jsxs)(b.Row,{gap:8,children:[(0,A.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:W,onChangeText:z,onSubmitEditing:()=>V(W),returnKeyType:"send",style:[b.styles.input,{flex:1,minWidth:0,width:40}]}),S.voice?(0,A.jsx)(c.default,{testID:"assistant-mic",accessibilityRole:"button",accessibilityLabel:$?'Stop listening':'Speak',onPress:()=>{const e=O();if(e)if($)F.current?.stop?.();else try{const t=new e;F.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&z(t)},t.onend=()=>_(!1),t.onerror=()=>{_(!1),U("Sorry, I didn't catch that. You can type instead.",'note')},_(!0),t.start()}catch{_(!1),U("Voice input isn't available here. Please type instead.",'note')}else U("Voice input isn't available in this browser (for example Huawei Browser). Please type your request instead.",'note')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:$?k.colours.gold:'transparent'},children:(0,A.jsx)(b.T,{size:20,children:"\ud83c\udfa4"})}):null,(0,A.jsx)(b.Button,{label:"Send",accessibilityLabel:"Send",disabled:!W.trim(),onPress:()=>V(W)})]}),(0,A.jsxs)(b.Muted,{center:!0,children:["Demo on this device \xb7 ",J," of ",j.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,w.useCtx)(6e4),s=(0,j.useAssistant)();return R(t)?(0,A.jsxs)(h.default,{style:{gap:12},children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{gap:10,children:[(0,A.jsx)(h.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:22})}),(0,A.jsxs)(h.default,{style:{flex:1},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,A.jsx)(b.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,A.jsx)(b.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>v.getState().setOpen(!0)}),(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,A.jsxs)(h.default,{testID:"assistant-log",style:{gap:6},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>j.useAssistant.getState().clearLog()}):null]}),(0,A.jsx)(b.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,A.jsx)(b.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,A.jsxs)(h.default,{style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.T,{size:12,colour:k.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,A.jsx)(b.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,A.jsxs)(b.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,A.jsxs)(b.T,{size:13,colour:k.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,A.jsx)(b.Muted,{children:"The activity log is visible to the owner."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)();return R(e)?(0,A.jsxs)(h.default,{style:{gap:12},testID:"assistant-settings",children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,A.jsx)(b.Muted,{children:"Shows the gold Assistant button on every Managers screen."}),(0,A.jsx)(b.Toggle,{label:"Voice input (microphone)",value:t.voice,onChange:e=>t.set({voice:e})}),(0,A.jsx)(b.Muted,{children:"What you say is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. If this device can\u2019t record, just type."})]}),(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Connected services"}),E.map(e=>(0,A.jsxs)(h.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:k.colours.border,paddingTop:8},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{children:e.name}),(0,A.jsx)(b.Badge,{kind:"neutral",label:"Not connected"})]}),(0,A.jsxs)(b.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,A.jsx)(b.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,A.jsx)(b.Muted,{children:"The Assistant comes with Full Restaurant Pro App and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,A.jsx)(b.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to the voice assistant to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,j.useAssistant)(),t=(0,j.tasksUsed)(e),s=Math.min(1,t/j.FAIR_USE);return(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,A.jsx)(b.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,A.jsx)(h.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${j.FAIR_USE} tasks used`,style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,A.jsx)(h.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:k.colours.gold,borderRadius:4}})}),(0,A.jsxs)(b.Muted,{children:[t," of ",j.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]),a=_r(d[4]),r=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var c=e(_r(d[8])),u=e(_r(d[9])),h=e(_r(d[10])),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),m=_r(d[14]),x=_r(d[15]),y=_r(d[16]),j=_r(d[17]),k=_r(d[18]),w=_r(d[19]),C=_r(d[20]),A=_r(d[21]);const S=!0,T='Nothing was sent or changed: this connection is not set up yet.',I='#1A1408',v=(0,p.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=e=>'owner'===e||'manager'===e,D=()=>Math.random().toString(36).slice(2,9);function M({size:e=24,colour:t=I}){return(0,A.jsx)(b.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function B(){const{rid:e,r:t,now:s,today:n}=(0,w.useCtx)(3e4),a=(0,m.useAllMenu)(e),l=(0,f.useTableNames)(e),c=(0,m.useBookings)(e),u=(0,x.useOwner)(e=>e.staff),h=(0,x.useOwner)(e=>e.shifts),p=(0,x.useOwner)(e=>e.offers),b=(0,x.useOwner)(e=>e.suppliers);return(0,r.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:a.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:l,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,C.workingShifts)(h,x.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,x.addDays)(n,-(0,x.weekdayOf)(n))&&e.date<=(0,x.addDays)(n,6-(0,x.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${b[0]?.contact??'Alex Sample'}, ${b[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),a,l,c,u,h,p,b])}function P({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[a,l]=(0,r.useState)(!1),[c,u]=(0,r.useState)('external'===o.kind?o.text:''),p='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,A.jsxs)(h.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:p?k.colours.gold:k.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:k.colours.surface2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,A.jsx)(b.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[o.detail?(0,A.jsx)(b.Muted,{children:o.detail}):null,(0,A.jsx)(b.T,{size:14,colour:k.colours.muted,children:o.label}),a&&p?(0,A.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:u,style:[b.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,A.jsx)(h.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:k.colours.gold,paddingLeft:10},children:(0,A.jsxs)(b.T,{children:["\u201c",c,"\u201d"]})}),(0,A.jsxs)(b.Muted,{children:["Sends to: ",o.service.map(e=>y.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,A.jsxs)(h.default,{style:{gap:4},children:[(0,A.jsx)(b.Muted,{children:o.detail}),o.warning?(0,A.jsxs)(b.T,{size:13,colour:k.colours.amber,children:["\u26a0 ",o.warning]}):null]}),p?(0,A.jsxs)(b.Row,{wrap:!0,gap:8,children:[(0,A.jsx)(b.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:a?'Done editing':'Edit',testID:"edit-action",onPress:()=>l(!a)}):null,(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,A.jsx)(b.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),p?(0,A.jsxs)(b.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}function O(){return'undefined'==typeof window?null:(0,a.speechRecognizer)()}const E=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1489,[827,979,796,884,931,34,395,236,402,295,102,846,794,1125,874,891,1490,1494,821,1087,1097,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);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]}})})},1490,[1491,1493,1492]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1491,[860,1492]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1492,[]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Voice assistant (server, with on-device fallback)',interpret:s}},1493,[1491,932]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1494,[884,839,846,849]); -__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.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1495,[5,1062,979,1415,828,827,837,1270,1440,34,402,410,102,879,794,874,891,861,867,858,821,1200,1087,1179,1444,1229,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1496,[860,34,102,1180,794,874,861,869,858,821,1200,1087,25]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1497,[1075,34,102,1498,829,873,794,891,821,1087,25]); -__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.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1498,[827,34,236,402,102,797,829,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1499,[34,1175,863,1087,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1500,[34,1061,1087,987,999,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1501,[34,1391,1087,25]); -__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.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:s}=(0,c.useCtx)(6e4),a=(0,r.useBookings)(e),n=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,t.useState)('day'),k=(0,d.hasAnyTakings)(n,e),w=(0,d.dayRows)(n,a,e,s,14),f=(0,d.weekRows)(n,a,e,s,8),v=(0,d.averageSph)(w),$=(e,t,s,a,n)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${t}: ${'No takings entered'===a?'no takings entered':`spend per head ${a}`}, ${s}${n?`, ${n}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:t}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:s}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===a?h.colours.muted:h.colours.goldLight,size:'No takings entered'===a?13:16,children:a}),n?(0,u.jsx)(i.Muted,{center:!0,children:n}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:k?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:w.map(e=>({label:x(e.date),value:e.sph}))}),[...w].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),a=_r(_d[2]),n=e(a),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,t.useState)(320),[x,y]=(0,t.useState)(e.length);(0,t.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),k=Math.max(0,j-b),w=e.slice(k,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),T=e=>38+e*(f-76)/Math.max(1,w.length-1),S=e=>140-e/$*106,L=[];let D=[];w.forEach((e,t)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:t,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(n.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(a.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(n.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(a.Line,{x1:0,x2:f,y1:S($*e/4),y2:S($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,t)=>(0,u.jsx)(a.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},t)),w.map((e,t)=>(0,u.jsx)(s.default.Fragment,{children:null==e.value?(0,u.jsx)(a.Circle,{cx:T(t),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.Circle,{cx:T(t),cy:S(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(a.Text,{x:T(t),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},k+t))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:w.map((e,t)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},k+t))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===k,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1502,[34,102,797,794,874,1038,1503,821,1087,25]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1503,[13]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1504,[34,102,1351,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1505,[34,793,1087,25]); -__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.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1506,[5,1415,827,837,860,1507,1439,1477,1235,14,1270,987,1508,1510,1440,34,1125,1485,30,402,102,879,1290,794,874,891,867,881,1130,1259,858,821,1200,1087,1159,884,1456,869,1055,1175,863,861,25]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1507,[860,34,102,794,861,867,1174,874,869,821,25]); -__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1508,[987,34,281,236,102,1290,794,1267,1270,821,1509,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1509,[34,236,102,794,1267,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1510,[5,1415,34,102,794,867,1267,1268,1269,987,1270,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1511,[34,1224,1177,1225,1232,1087,1191,863,872,1024,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1512,[34,102,794,987,858,821,25]); -__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.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["Every booking and takeaway order gets a text (a phone number is needed to book) and an email if they gave one. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1513,[828,827,837,34,236,402,102,794,1237,874,1494,864,1239,1047,821,1056,1087,25]); -__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.OrderSheetSettings=function(){const e=(0,i.useOwner)(e=>e.site),u=(0,o.useSheets)(e),[c,m]=(0,l.useState)(null);return c?(0,p.jsxs)(s.Card,{children:[(0,p.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===c.id)?`Edit ${c.name}`:'New supplier'}),(0,p.jsx)(x,{rid:e,s:c,onDone:()=>m(null)})]}):(0,p.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,p.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,p.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,p.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,p.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,p.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,p.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,p.jsx)(s.Row,{wrap:!0,gap:8,children:(0,p.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var l=r(_d[0]),t=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),i=r(_d[4]),o=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]);const c=['online','phone','text','whatsapp','tbc'];function m({label:e,value:l,onChange:t}){return(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,p.jsx)(s.Chip,{label:e,selected:l.includes(n),onPress:()=>t(l.includes(n)?l.filter(e=>e!==n):[...l,n].sort())},e))})]})}function x({rid:e,s:t,onDone:i}){const d=(0,o.useOrderSheets)(e=>e.upsert),x=(0,o.useOrderSheets)(e=>e.remove),[b,f]=(0,l.useState)(t),[j,y]=(0,l.useState)(t.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[C,v]=(0,l.useState)(t.priceCapPerKg?(t.priceCapPerKg/100).toFixed(2):''),[w,T]=(0,l.useState)(!1),D=e=>f(l=>({...l,...e}));return(0,p.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,p.jsx)(s.Field,{label:"Supplier name",value:b.name,onChangeText:e=>D({name:e})}),(0,p.jsx)(s.Field,{label:"What they supply",value:b.goods,onChangeText:e=>D({goods:e})}),(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:c.map(e=>(0,p.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:b.method===e,onPress:()=>D({method:e})},e))})]}),'text'===b.method||'whatsapp'===b.method||'phone'===b.method?(0,p.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:b.number,keyboardType:"phone-pad",onChangeText:e=>D({number:e})}):null,'online'===b.method?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:b.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>D({url:e.trim()})}),(0,p.jsx)(s.Field,{label:"Button label",value:b.urlLabel??'',placeholder:"Open website",onChangeText:e=>D({urlLabel:e})})]}):null,(0,p.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:b.contact??'',onChangeText:e=>D({contact:e})}),(0,p.jsx)(m,{label:"Delivery days",value:b.deliveryDays,onChange:e=>D({deliveryDays:e})}),(0,p.jsx)(m,{label:"Order days (a reminder shows in the Head Chef app)",value:b.orderDays,onChange:e=>D({orderDays:e})}),(0,p.jsxs)(s.Row,{gap:10,children:[(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:b.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>D({cutoff:e})})}),(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Price cap \xa3/kg (optional)",value:C,keyboardType:"decimal-pad",onChangeText:v})})]}),(0,p.jsx)(s.Field,{label:"Reminder text (optional)",value:b.reminder,onChangeText:e=>D({reminder:e})}),(0,p.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:b.frequency,onChangeText:e=>D({frequency:e})}),b.priceCapPerKg||C?(0,p.jsx)(s.Field,{label:"Seller",value:b.seller,onChangeText:e=>D({seller:e})}):null,(0,p.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:y}),(0,p.jsx)(s.Field,{label:"Notes for the chef",value:b.notes,multiline:!0,onChangeText:e=>D({notes:e})}),(0,p.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,p.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const l=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,l)=>{const[n,s]=e.split('|').map(e=>e.trim()),i=t.items.find(e=>e.name===n);return{id:i?.id??`${b.id}-i${l}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*parseFloat(C.replace(/[\xa3,]/g,'')));d(e,{...b,items:l,priceCapPerKg:n>0?n:0,placeholder:b.placeholder&&'tbc'===b.method}),i()},disabled:!b.name.trim()}),(0,p.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:i}),w?(0,p.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{x(e,t.id),i()}}):(0,p.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>T(!0)})]})]})}},1514,[34,402,102,794,891,1030,867,1031,821,25]); -__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.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1515,[34,236,402,102,426,794,821,1373,873,1375,858,987,1376,1087,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1516,[835,984,1454,34,236,102,794,831,891,983,1030,985,987,1517,821,2,1181,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1517,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1518,[34,102,794,821,1435,1507,1087,25]); -__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.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1519,[827,1062,796,34,402,102,794,891,1470,1520,1521,1522,821,1087,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1520,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1521,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1522,[1523,1127,860,1524,1525,891,874,1028,1470,1520,1521,1527,1526,1529,1530,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1523,[1092,1091,1052]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1524,[984,1127,835,860,874,831,1028,983,985,1039,891,1094,882,863,861]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1525,[835,874,831,1028,891,1033,1043,1044,1009,1008,1038,13,1063,1064,1065,1034,1094,882,1104,1025,870,1526,1524]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1526,[835,979,1127,860,1160,1270,874,831,1028,1033,994,862,861,1104,1105,1025,1034,867,1527,1528]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1527,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1528,[839,846,849]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1529,[831,891,994,867,1526,1046,1097]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1530,[]); -__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.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"Staff hold the gold button, say what they need and let go. It sits at the top right in Managers, Head Chef, the Staff app (the full voice assistant, without team financial or HR information) and on the Display (no money, tips or HR either), never in the customer app. Tap it to type or open the Assistant. Replies and change confirmations are shown in text, never spoken. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts for you."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,r.useDrafts)(e=>e.drafts),u=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[j,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:r.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The voice helper and the Assistant save bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting. Try holding the voice button and saying \u201cadd blue roll to the Booker list\u201d."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!j,onClose:()=>y(null),title:'approved'===j?.status?'Approve this draft?':'Dismiss this draft?',children:j?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:j.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===j.status?`This marks it approved${v[j.d.kind]?` and opens ${v[j.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===j.status?'success':'danger',label:'approved'===j.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(j.d.id,j.status,o.replace(' (example)',''));const e=v[j.d.kind];y(null),'approved'===j.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const v={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1531,[34,379,102,794,821,1466,1527,1477,1528,1157,931,1486,1087,25]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1532,[34,796,102,794,861,1267,1533,1534,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1533,[861]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1534,[987,1533,1270]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_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]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1535,[34,102,794,874,1038,1536,979,13,1537,1049,821,1087,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1536,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(o){const{rid:u,date:c,bookings:f,cashUps:p,fields:v,soldOut:h}=o,b=f.filter(t=>t.restaurantId===u&&t.date===c),k=p.find(t=>t.rid===u&&t.date===c&&t.confirmedAt),y=p.find(n=>n.rid===u&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),N=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,O=(0,n.coversOn)(f,u,c),S=null==N||O<=0?null:Math.round(N/O*100)/100,_=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&_.set(n,(_.get(n)??0)+(t.partySize||0))}let w=null;for(const[t,n]of _)(!w||n>w.n)&&(w={hour:t,n:n});return{date:c,spendPerHead:s(S),covers:O,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(N),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(y?(0,t.grossOf)(y.vals)??(0,t.takings)(y.vals):null),busiestHour:w?`${String(w.hour).padStart(2,'0')}:00 \xb7 ${w.n} Covers`:'Not entered',soldOut:h.filter(Boolean),cashUp:v.map(t=>({label:t.label,value:k?l(k.vals[t.key],t.kind):'Not entered'}))}};var t=r(d[0]),n=r(d[1]);const s=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?s(t):String(t)},1537,[13,1503]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1538,[827,34,102,794,1539,1050,821,1540,1087,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1539,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1540,[1049,1050,976,933,987]); -__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.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1541,[34,281,236,102,794,827,821,987,1430,1204,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1542,[236]); -__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,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','voice','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1544,[]); -__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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1545,[34,283,364,236,402,295,102,426,36,797,827,796,794,1237,1385,1114,1470,1113,1111,1239,1252,979,891,1061,1477,2,987,821,1343,1546,1087,1489,1414,1179,1472,1474,1464,1456,1475,1542,1544,1552,1553,1554,1557,1560,25]); -__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.micAvailable=O,_e.NoShows=z,_e.CarApp=function(){(0,H.useCarViewport)();const{width:e,height:n}=(0,c.default)(),o=Math.max(320,A(e)),{role:d,today:u,now:h}=(0,w.useCtx)(3e4),[p,f]=(0,t.useState)(n),x=o,[y,I]=(0,t.useState)(null),[D,W]=(0,t.useState)(!1),[M,z]=(0,t.useState)(null),[V,F]=(0,t.useState)(!1),[G,Y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{O().then(z)},[]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==d&&T.useOwner.getState().setPreviewRole('owner')},[d]);const X=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,X);const q=(0,t.useCallback)(()=>W(!1),[]);(0,j.useBackLayer)(D,q);const J=e=>{W(!1),I({btn:e,page:e.pages[0].id})},K=(0,t.useCallback)((e,t)=>{const n=e=>R.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:n('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:n('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??R.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=n(t);return I(n=>({btn:e??n?.btn??R.CAR_BUTTONS[0],page:t}))}I(null)},[]),Q=x,Z=y?y.btn.label:'';return(0,L.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-p)>1&&f(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:o,maxWidth:'100%',overflow:'hidden'},children:[(0,L.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,L.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,L.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,L.jsx)(B.ParkedOnly,{small:o<1400}),(0,L.jsx)(N,{open:D,onPress:()=>W(!0)})]}),subHeader:(0,L.jsx)($,{onRota:()=>J(R.CAR_BUTTONS[0]),onAccount:()=>F(!0)})}),y?(0,L.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:Q,zIndex:40,backgroundColor:S.colours.bg},children:[(0,L.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${Z}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||X()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,L.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,L.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,L.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,L.jsx)(N,{testID:"car-menu-button-page",open:D,onPress:()=>W(!0)})})]}),y.btn.pages.length>1?(0,L.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,L.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?P:'transparent',alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,L.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:'assistant'===y.page&&!1===M?(0,L.jsx)(U,{}):(0,L.jsx)(_,{id:y.page,go:K},y.page)})]}):null]}),(0,L.jsx)(E,{visible:D,onClose:q,onPick:J,current:y?.btn.id,W:o,H:p}),V?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>F(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,L.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,L.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,L.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{F(!1),Y(!0)},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>F(!1),style:{minHeight:56}})]}):null,G?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>Y(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,L.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,L.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{Y(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>Y(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),c=e(r(_d[7])),d=r(_d[8]),u=e(d),h=r(_d[9]),b=r(_d[10]),p=r(_d[11]);r(_d[12]);var f=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),R=r(_d[26]),W=r(_d[27]),B=r(_d[28]),M=r(_d[29]),H=r(_d[30]),L=r(_d[31]);const P='rgba(201,162,74,0.14)';async function O(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}}function $({onRota:e,onAccount:n}){const o=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[c,d]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>d(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=o.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,L.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,L.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,L.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:n,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,L.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,L.jsx)(M.CarGameButton,{})]})}function z({go:e}){const{rid:t,now:n}=(0,w.useCtx)(3e4),o=(0,I.useBookings)(t),s=(0,D.ymd)(n),a=(0,D.ymd)(new Date(n.getTime()-24192e5)),c=o.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),d=o.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,L.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,L.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:c.length?`${c.length} no-show${1===c.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),d.length?(0,L.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),d.map(e=>(0,L.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,L.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,c.map(e=>(0,L.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,L.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,L.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function N({onPress:e,open:t,testID:n="car-menu-button"}){return(0,L.jsx)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:R.MENU_BUTTON,height:R.MENU_BUTTON,borderRadius:R.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,L.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,L.jsx)(d.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function E({visible:e,onClose:a,onPick:c,current:d,W:u,H:b}){const[p,f]=(0,t.useState)(0),m=(0,R.menuSizes)(u,b),x=p?Math.floor((p-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new n.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),n.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,L.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,L.jsx)(n.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,L.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,L.jsxs)(n.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,L.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,L.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,L.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,L.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>f(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:R.CAR_BUTTONS.map(e=>{const t=d===e.id;return(0,L.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>c(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,L.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:P,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(W.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,L.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U(){return(0,L.jsxs)(l.default,{testID:"car-no-mic",accessibilityLiveRegion:"polite",style:{gap:10,alignItems:'center',paddingVertical:24},children:[(0,L.jsx)(C.T,{center:!0,size:20,weight:"semibold",colour:S.colours.goldLight,children:"The Assistant needs the car\u2019s microphone"}),(0,L.jsx)(C.Muted,{center:!0,style:{maxWidth:520},children:"Sorry, this car\u2019s browser isn\u2019t letting the page use a microphone. For now, please use the Assistant in Managers on your phone."})]})}function _({id:e,go:t}){if('@bookings'===e)return(0,L.jsx)(f.Bookings,{go:t});if('@chat'===e)return(0,L.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,L.jsx)(z,{go:t});if('@orders'===e)return(0,L.jsx)(x.Orders,{});if('@forecast'===e)return(0,L.jsx)(y.Forecasts,{go:t});const n=(0,p.pageFor)(e);if(!n)return(0,L.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const o=n.C;return(0,L.jsx)(o,{go:t})}function A(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,n=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,n))}},1546,[34,283,364,236,402,295,102,426,797,796,1343,1456,1475,1414,1179,1474,1472,1087,1055,794,874,891,858,987,2,821,1547,1548,1549,1550,1551,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1547,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1548,[34,797,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1549,[34,102,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1550,[34,402,1181,1182,831,5,794,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1551,[34,236]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1552,[1547]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1553,[]); -__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.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1554,[34,402,102,426,827,794,1098,1061,1196,1142,1118,874,1038,891,1100,13,930,987,821,1414,1087,1456,1555,1544,1553,1556,25]); -__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,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1555,[34,402,295,102,794,821,25]); -__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.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1556,[34,102,797,794,821,1555,1553,25]); -__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.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1557,[34,281,402,102,797,794,874,891,1558,999,1226,1463,821,1548,1087,1555,1559,1553,1556,1554,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1558,[846,849,839]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1559,[999]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1560,[34,102,794,821,1561,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1561,[]); -__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.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:$,meId:V,me:Q}=(0,z.useCtx)(3e4);(0,m.useTipsPosted)(e,_);const Y=(0,z.useSignedIn)();(0,x.useSoldOutLink)(!0,(Y?.name??Q).replace(' (example)',''));const[ee,te]=(0,a.useState)({kind:'tab',tab:'home'}),[se,ae]=(0,a.useState)(''),oe=(0,a.useRef)(null);(0,a.useEffect)(()=>{(0,z.ensureAttendance)(_,$),(0,M.ensureChat)($)},[_]),globalThis.__ccNow=$.getTime();const ne=(0,a.useCallback)((e,t=null)=>{if('more'===e&&t){const e=q[t];return void te(e?{kind:'edit',id:e}:{kind:'page',id:t})}te('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,a.useEffect)(()=>(S.useVoiceNav.setState({go:ne}),()=>S.useVoiceNav.setState({go:null})),[ne]),(0,a.useEffect)(()=>{D.PITCH&&(globalThis.__pitchGo=ne,globalThis.__deskGo=e=>te(e))},[ne]),(0,E.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:Y?.id??'',name:Q,onOpen:e=>'bookings'===e?ne('bookings'):'chat'===e?ne('chat'):ne('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!Y}),(0,a.useEffect)(()=>((0,T.warmDesktopStt)(),(0,C.installVoiceKeys)()),[]);const re=(0,a.useMemo)(()=>[...G,...U].map(e=>e.s),[]);(0,a.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void oe.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=re[Number(e.key)-1];return void(t&&(e.preventDefault(),te(t)))}if('z'===t&&!Z(e.target)){const t=(0,W.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!Z(e.target)){const t=(0,W.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[re]);const ie=O.PAGES.filter(e=>(!e.can||e.can(f))&&!q[e.id]),le=(0,a.useMemo)(()=>{const e=se.trim().toLowerCase(),t={};return ie.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ie,se]),de=G.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ue=p.CAN.forecasts(f)?U:U.filter(e=>'rota'===e.s.id),ce='page'===ee.kind?(0,O.pageFor)(ee.id):void 0,be='tab'===ee.kind?G.find(e=>X(e.s,ee))?.label:'edit'===ee.kind?U.find(e=>X(e.s,ee))?.label:ce?.title,he='tab'===ee.kind?G.find(e=>X(e.s,ee))?.tip:'page'===ee.kind?`${ce?.sub??''}. Press ${(0,N.CMD)()}K to jump to any page, or hold Space and ask.`:'',ge=({label:e,s:t,n:s})=>{const a=X(t,ee);return(0,K.jsxs)(o.default,{accessibilityRole:"button",accessibilityState:{selected:a},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>te(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:a?A.colours.goldTint:e?A.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:a?A.colours.gold:'transparent'}),children:[(0,K.jsx)(g.T,{size:14,weight:a?'semibold':'regular',colour:a?A.colours.gold:A.colours.text,style:{flex:1},numberOfLines:1,children:e}),s?(0,K.jsxs)(g.T,{size:11,colour:A.colours.muted,children:[(0,N.CMD)(),s]}):null]})},fe=({t:e})=>(0,K.jsx)(g.T,{size:11,weight:"semibold",colour:A.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),pe='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,K.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:A.colours.bg},testID:"desktop-shell",children:[(0,K.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,K.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(g.Row,{gap:10,children:[(0,K.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(u.VenueName,{name:c.name}),(0,K.jsx)(g.Row,{gap:6,children:(0,K.jsx)(l.AppBadge,{label:pe})})]})]}),(0,K.jsx)(u.PoweredBy,{}),(0,K.jsx)(s.TextInput,{ref:oe,testID:"side-filter",value:se,onChangeText:ae,placeholder:`Find a page (${(0,N.CMD)()}K)`,placeholderTextColor:A.colours.muted,style:[g.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,K.jsxs)(n.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[se?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fe,{t:"Run the day"}),de.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:t+1},e.label)),(0,K.jsx)(fe,{t:"Drag-and-drop editors"}),ue.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:de.length+t+1},e.label))]}),Object.entries(le).map(([e,t])=>(0,K.jsxs)(r.default,{children:[(0,K.jsx)(fe,{t:e}),t.map(e=>(0,K.jsx)(ge,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{flex:1},children:[(0,K.jsx)(r.default,{testID:"desk-title",children:(0,K.jsx)(g.T,{size:24,weight:"bold",children:be??''})}),(0,K.jsxs)(g.Muted,{size:12,children:[Y?`Signed in as ${Y.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]}),(0,K.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(g.T,{size:15,weight:"bold",colour:A.colours.gold,children:"Talk to CoverCharge"}),(0,K.jsxs)(g.Muted,{size:12,children:["Hold Space, or ",(0,N.CMD)(),"\u21e7G"]})]}),(0,K.jsx)(v.VoiceSlot,{size:76})]}),(0,K.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[he?(0,K.jsx)(F.Tip,{children:he}):null,'edit'===ee.kind?(0,K.jsx)(J,{id:ee.id,rid:e,me:Q,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,K.jsxs)(n.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===ee.kind&&'home'===ee.tab?(0,K.jsx)(H.Dashboard,{go:ne}):null,'tab'===ee.kind&&'orders'===ee.tab?(0,K.jsx)(I.Orders,{}):null,'tab'===ee.kind&&'bookings'===ee.tab?(0,K.jsx)(R.Bookings,{}):null,'tab'===ee.kind&&'forecast'===ee.tab?(0,K.jsx)(P.Forecasts,{go:ne}):null,'tab'===ee.kind&&'chat'===ee.tab?(0,K.jsx)(M.Chat,{go:ne}):null,ce?(0,K.jsx)(ce.C,{go:ne}):'page'===ee.kind?(0,K.jsx)(g.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,K.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,K.jsx)(h.PrintHost,{rid:e}):null,'staff'!==f?(0,K.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Q,onOpen:e=>ne('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,K.jsx)(L.AssistantSheet,{}),(0,K.jsx)(B.OnboardingHost,{go:ne}),(0,K.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),s=_r(d[1]),a=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]),g=_r(d[12]),f=_r(d[13]),p=_r(d[14]),x=_r(d[15]),m=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),S=_r(d[22]),v=_r(d[23]),T=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),z=_r(d[31]),H=_r(d[32]),P=_r(d[33]),B=_r(d[34]),I=_r(d[35]),O=_r(d[36]);_r(d[37]);var _=_r(d[38]),N=_r(d[39]),W=_r(d[40]),$=_r(d[41]),V=_r(d[42]),F=_r(d[43]),K=_r(d[44]);const G=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Hold Space and say \u201chow many Covers tonight?\u201d for a quick answer without leaving this screen.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first. Say \u201cshow new orders\u201d to jump back any time.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber. Hold Space and say \u201caccept the 7 o\u2019clock\u201d.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],U=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],q={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},X=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),Z=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function J({id:e,rid:t,me:s,role:o,today:n,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,a.useState)(0),[h,p]=(0,a.useState)('');return'menu'===e?(0,K.jsx)($.MenuEditor,{rid:t,me:s,role:o}):'rota'===e?(0,K.jsx)(V.RotaEditor,{today:n}):'brand'===e?(0,K.jsx)(_.BrandEditor,{rid:t}):(0,K.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,K.jsxs)(F.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,N.CMD)(),"Z undoes, then Save."]}),h?(0,K.jsx)(g.T,{size:13,colour:A.colours.goldLight,children:h}):null,(0,K.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:A.colours.border,borderRadius:12,overflow:'hidden'},children:(0,K.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1562,[828,827,34,402,295,102,36,1358,873,1361,1237,1385,794,1028,891,979,1061,1470,1114,1113,1111,1563,1477,1156,931,1239,2,821,1489,1414,1179,1087,1432,1472,1464,1474,1456,1475,1564,1542,1566,1568,1570,1567,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1563,[846]); -__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.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1564,[34,295,102,1498,873,794,891,829,1457,821,1565,1566,1567,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1565,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1566,[34]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1567,[34,102,794,821,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1568,[827,34,102,794,876,831,979,981,982,861,882,1173,821,1565,1566,1567,1569,25]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1569,[891]); -__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.RotaEditor=function({today:e}){const y=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[$,j]=(0,t.useState)((0,i.mondayOfDate)(e)),[v,k]=(0,t.useState)(null),[w,D]=(0,t.useState)(''),B=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),O=b.map((e,t)=>(0,i.addDays)($,t)),P=(e,t,o)=>{e.preventDefault(),k(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=y.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=$&&e.date<=O[6]),I=T.filter(e=>!e.published||e.changed).length;return(0,p.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,p.jsx)(h.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,p.jsxs)(s.Row,{gap:8,children:[(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>j((0,i.addDays)($,-7))}),(0,p.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date($+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>j((0,i.addDays)($,7))}),(0,p.jsx)(d.default,{style:{flex:1}}),w?(0,p.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:w}):null,(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!B.canUndo,onPress:B.undo,testID:"rota-undo"}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!B.canRedo,onPress:B.redo,testID:"rota-redo"}),(0,p.jsx)(s.Button,{small:!0,label:I?`Publish (${I})`:'Published',disabled:!I,onPress:()=>{B.record('published the week');const e=i.useOwner.getState().publishWeek($);D(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,p.jsx)("div",{style:(0,h.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,p.jsxs)("div",{style:(0,h.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,p.jsx)("div",{style:(0,h.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),O.map((t,o)=>(0,p.jsxs)("div",{style:(0,h.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[b[o]," ",Number(t.slice(8))]},t)),y.map(e=>(0,p.jsxs)(o.default.Fragment,{children:[(0,p.jsxs)("div",{style:(0,h.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,p.jsx)("div",{style:(0,h.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,p.jsx)("div",{style:(0,h.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),O.map(t=>{const o=`${e.id}|${t}`,d=T.filter(o=>o.staffId===e.id&&o.date===t);return(0,p.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',k(o)},onDragLeave:()=>k(null),onDrop:o=>P(o,e.id,t),style:(0,h.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,p.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,h.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,p.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]),f=r(_d[9]),p=r(_d[10]);const b=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],x=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1570,[34,102,794,891,1090,821,1565,1566,1567,1569,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1571,[30,34,872,1572,25]); -__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1572,[1457,1573,828,996,1098,1507,1223,1054,1055,1508,1532,1510,1173,979,1015,1574,1012,2,1060,1061,1483,998,1038,999,34,1175,1248,1252,1219,373,402,295,102,426,36,794,873,1156,891,821,1179,1414,1093,1111,1113,1107,1056,1039,1087,1501,1496,1516,1575,1423,1003,236,1254,1198,1204,1455,1218,1217,1471,1201,15,1224,1225,925,793,987,25]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1573,[34,102,794,1087,987,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1574,[236,1013]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1575,[860,34,102,794,891,1028,858,1090,1088,987,1089,5,1000,821,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1576,[30,34,872,25]); -__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1577,[1451,987,795,1408,1578,1025,30,1605,496,34,385,336,236,41,102,5,873,872,1607,36,874,1028,891,821,1423,1003,1023,1608,1609,1057,1610,1129,2,1038,998,1612,1376,25,1614,1615,1616,1617]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1578,[1579,1602,1604]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1579,[215,1580,1583,1597,1598,1599,1600,1601]); -__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1580,[215,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1581,[1582]); -__d(function(g,r,i,a,m,e,d){},1582,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1583,[1584,215,1580,1597,1598]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1584,[1585,1586,1596]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1585,[1586,1590,1595]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1586,[215,372,1587,1591,1592,1593,1594,1590,1595]); -__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1587,[215,1588,339,280,1589,1590]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1588,[504]); -__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1589,[215,339]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1590,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1591,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1592,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1593,[1591]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1594,[]); -__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1595,[372,1589]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1596,[34,1586]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1597,[1584,215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1598,[1584,1597]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1599,[1580]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1600,[215,1580,1583,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1601,[]); -__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1602,[215,54,1603]); -__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1603,[215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1604,[34,1579]); -__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]}})})},1605,[1606]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1606,[]); -__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1607,[34,41,102,426,794,873,1003,987,2,5,821,1547,1549,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1608,[989,883,882,987]); -__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1609,[828,796,827,34,1011,1458,1029,402,102,872,987,1013,1028,5,821,794,1354,976,2,25]); -__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1610,[5,796,827,34,385,283,364,380,236,402,295,426,102,1489,1156,2,797,1087,15,891,794,821,1522,932,1611,1520,1521,1477,1157,1487,931,1563,1530,25,277]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1611,[891,831,1028]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1612,[874,831,891,1038,15,1003,872,2,1613]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1613,[874,1038]); -__d(function(e,o,s,p,t,n,a){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1614,[]); -__d(function(o,e,s,p,t,c,d){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1615,[]); -__d(function(o,e,s,p,t,d,f){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1616,[]); -__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1617,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1618,[30,34,872,25]); -__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1619,[1620]); -__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1620,[25,1621,591]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1621,[34,172]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1622,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1623,[25,499,34,270,651]); +__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return Q.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return Q.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return Q.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return Q.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return Q.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ot}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ie.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ie.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ie.useOwner.getState().chatSeen(t,e)),$t(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ie.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...ht(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(fe.PITCH)return ge.unlockCashUp(e,t,a);const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?de.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):de.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(fe.PITCH)return ge.cashAudit(e);const t=Ae.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(_a.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=pa,i.readAccessLog=async function(){const e=Ae.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ae.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return ga}}),i.uploadOrderLogo=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(ga).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ma.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(ga).createSignedUrl(e,3600);if(t?.signedUrl)return ma.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(ga).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return _a}}),i.claimInvite=Ua,i.makeChromeHandover=async function(){const e=Ae.getState();if(fe.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ee});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(fe.PITCH||!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ee});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),Me&&qa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Ne();const t=await q.kv.get(Ia,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Ne(),await q.kv.get(Oa,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_WILDINGS||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Ne(),await q.kv.remove(Ia),await q.kv.remove(Oa),Ce({mode:'signin',perms:[]});try{await xa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ae.getState().venueId;if(fe.PITCH||!s||'staff'!==Ae.getState().kind)return{ok:!0};if(!(0,re.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Pa('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ua(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(fe.PITCH)return ge.reissueInvite(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Pa('staff_app_link_history',{p_venue:Ae.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Pa('revoke_staff_app_link',{p_venue:Ae.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(fe.PITCH)return ge.linkPhones();const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return{};try{const t=await Pa('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(fe.PITCH)return ge.resetPhone(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Number(await Pa('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(fe.PITCH)return ge.inviteStatus();const e=Ae.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:t,error:a}=await Re().rpc(d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_pairing_code':d.IS_GREENSIDE?'claim_greenside_pairing_code':d.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':d.IS_KIRKTON?'claim_kirkton_pairing_code':d.IS_WILDINGS?'claim_wildings_pairing_code':d.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':d.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await q.kv.set(ka,n),qa(),{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}`}}},i.carPairStart=async function(){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await q.kv.set(Ea,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ta(e)}}},i.carPairPoll=async function(e){try{Ne();const t=e??await q.kv.get(Ea,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,J.carPairApproved)(n)){const e=(0,J.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await q.kv.get(ka,null);await q.kv.set(ka,e),await q.kv.remove(Ia),A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||qa()}return'revoked'!==i&&'unknown'!==i||await Na(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Ne(),await Re().rpc('car_sign_out')}catch{}await Na(),await xa();try{await Re().auth.signOut({scope:'local'})}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Pa('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ta(e)}}},i.carList=async function(){const e=Ae.getState().venueId;if(!e)return[];return(await Pa('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Pa('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ta(e)}}},i.unpairDisplay=async function(){await q.kv.remove(ka),await xa();try{await Re().auth.signOut()}catch{}Ce({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await q.kv.remove(Ia),await q.kv.remove(Oa),await xa();try{await Re().auth.signOut()}catch{}Ce({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.'})},i.wipeThisDevice=async function(e={}){try{await xa()}catch{}try{(0,N.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${d.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!d.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Ka,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Pa}}),i.mendSession=La,i.startAppSync=async function(e=d.VENUE_RID){if(d.IS_ISOLATED_VENUE&&e!==d.VENUE_RID)return;if(Me)return;Me=!0,Ba=e,'customer'===Ee&&'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Ne(),'customer'!==Ee){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ee&&(0,y.isAnchorage)(e)?[V.useStore,ie.useOwner,se.useKitchen,ne.useSafety,X.useCardStore,_.useGpCalc,ee.useOrderSheets,h.useSpecials,C.useHr]:[V.useStore,ie.useOwner,se.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ee&&(0,y.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ce({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Os(e)}catch{if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e))return void Ce({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,N.isSupabaseConfigured)())return void Ce({mode:'off'});F.mutationQueue.subscribe(()=>{const e=F.mutationQueue.waiting,t=e[0];Ce({pending:F.mutationQueue.pending.length,failed:F.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,B.describeWrite)(t)}: ${(0,B.plainReason)({...t.lastErr},'retry')}`:void 0})}),F.mutationQueue.onFailed(e=>Ce({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:F.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,B.describeWrite)(e),why:'conflict'===e.reason?(0,B.plainReason)({code:'conflict'},'refused'):(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Pe.push((0,K.onConnectivity)(e=>Ce({mode:e?Ae.getState().venueId?'live':Ae.getState().mode:Ae.getState().venueId?'offline':Ae.getState().mode}))),await ja()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Qa}}),i.serverOrder=Za,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return Ya}}),i.nudgeGuestSync=function(){Xa?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return es}}),i.stockSaveBlocker=ts,i.stockEventStatus=function(e){if(Ze(e))return{state:'saved'};const t=F.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,B.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=as,i.saveStockEventsNow=ss,i.bookingSaveBlocker=is,i.resendUnsavedBookings=ds,i.saveBookingsNow=us,i.waitForBookingSave=function(e,t=12e3){if(!Ue())return Promise.resolve({state:'local'});const a=is();if(a)return Promise.resolve({state:'refused',why:a});const s=rs()[0]?.venueId??'',n=()=>ns.some(t=>F.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=$.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,K.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(F.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(F.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||rs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||rs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=gs,i.tempLogState=function(){const e=ms()[0]?.venueId??'',t=ms().find(e=>'temp_readings'===e.spec.table),a=F.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!F.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(W.useTempSaves.getState().notSaved),i=ne.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=_s,i.waitForTempSave=function(e,t,a=1e4){if(!Ue()||!ms().length)return Promise.resolve({state:'local'});const s=gs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ms()[0]?.venueId??'',i=ms().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>W.useTempSaves.getState().notSaved[(0,W.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>F.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=ws,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ms}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Ps.get(a);if('customer'!==Ee||!(0,N.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Ps.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Pa('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:Le(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:Le(a.from_time),to:Le(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Ps.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ms.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Ps.get(a);e&&!e.ok&&Ps.delete(a)}));const n=Ps.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ae.getState().venueId;if(!n||'staff'!==Ae.getState().kind)throw new Error('Connect to your venue first.');const i=await Pa('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});V.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return null;return(await Pa('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');await Pa('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),O=t(r[18]),R=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(pe),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]),Oe=t(r[71]);const Re=()=>(0,T.getSupabase)();F.mutationQueue.setExecutor(L.executeMutation),(0,M.setClockServer)(()=>'staff'===Ae.getState().kind);const Ae=(0,E.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ce=e=>Ae.setState(e),De=e=>{const t=Ae.getState().perms;return t.includes('*')||t.includes(e)},Ue=()=>{const e=Ae.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ae.subscribe(()=>(0,be.setLiveData)(Ue()));let Ee=G.IS_CAR?'car':G.APP_VARIANT,Te=!1;const Ne=()=>{Te||((0,q.setSyncNamespace)(Ee),Te=!0)};let Ke=[],Pe=[],Me=!1;const xe=()=>(new Date).toISOString().slice(0,10),qe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),Le=e=>e?e.slice(0,5):'',Be=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))):[],je=e=>JSON.parse(JSON.stringify(e));function Fe(e,t){const a=qe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>V.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=je(e);if(t)return{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:Be(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,re.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:Be(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function $e(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>V.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.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,re.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:je(e.lines??[]),allergies:Be(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:je(e.allergyChain??{}),readiness:je(e.readiness??{}),allergy_ticks:je(e.allergyTicks??{}),handover_check:e.handoverCheck?je(e.handoverCheck):null,accepted:e.accepted?je(e.accepted):null,doc:je(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)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function We(e){const t=qe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...z.useBlocks.getState().blocks,...z.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Ae.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:je(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,z.blockClock)(t.from_time)??a?.from,n=(0,z.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>z.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>z.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Qe=null,He='Main plan';function Ve(e){const t=e=>je({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(Z.useFloor.getState().plans[e]??(0,Z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>De('floor.manage')||De('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Qe??(0,ke.uuidFrom)(`plan:${a}`),venue_id:a,name:He||'Main plan',is_active:!0,...t(e),updated_by:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>(Qe=String(e.id),He=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,Ie.withSeedBest)(e,t[0]):void 0;a&&Z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>Z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ge(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Y.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>De('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,re.isUuid)(e.supplierId)?e.supplierId:(0,ke.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),dt.get(t)??t)}:{}};var t},apply:(t,a)=>Y.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Je=new Set,ze=new Set;F.mutationQueue.onDone(e=>{'stock_events'===e.table&&ze.add(e.rowKey)});const Ze=e=>ze.has(e)||Je.has(e),Ye=()=>De('*')||De('staff.manage')||De('recipes.edit')||De('recipes.signoff'),Xe=()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write'));function et(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Y.useShellStore.getState().events.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,re.isUuid)(t.id)&&!!(Y.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('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,re.isUuid)(e.undoes)&&(Ze(e.undoes)||F.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Je.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)=>Y.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function tt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Y.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={...Y.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Y.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Je]}}}))},afterRead:()=>{Y.useShellStore.getState().server[e]||Y.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Je]}}}))},subscribe:()=>()=>{}}}const at=new Set;function st(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=V.useStore.getState().menu;return X.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:t=>(0,re.isUuid)(t.card.id)&&!((0,y.isAnchorage)(e)&&(0,y.isDemoCard)(t.card))&&!(0,y.isPlaceholderCard)(t.card),writable:()=>De('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,y.isAnchorage)(e)&&(s={...s,signOff:(0,y.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,y.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,y.isAnchorage)(e)&&(0,y.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,ke.photoPath)(a,s),t=nt(s.photo);t&&((0,X.cachePhotoAs)(e,t),it(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,ke.cardToRow)(s,a);return{...i,...r,doc:je({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,y.isPlaceholderCard)(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,signOff:(0,y.isAnchorage)(e)&&(0,y.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!De('recipes.edit')&&t.length){const e=new Set(t);X.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);X.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&V.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&V.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=X.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=V.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const nt=e=>(0,X.readLocalPhoto)(e);async function it(e,t){if(!at.has(e)){at.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(ke.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){at.delete(e),Ce({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const rt=new Map,ot=(0,E.create)(()=>({n:0}));(0,X.setStoragePhotoResolver)(e=>{const t=rt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,N.isSupabaseConfigured)()&&'off'!==Ae.getState().mode?(t||(rt.set(e,{url:'',at:Date.now()}),Re().storage.from(ke.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(rt.set(e,{url:t.signedUrl,at:Date.now()}),ot.setState(e=>({n:e.n+1})),X.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const dt=new Map;const ut=(e,t)=>{const a=(0,re.isUuid)(t)?t:(0,ke.uuidFrom)(`sup:${e}:${t}`);return dt.set(a,t),a};function ct(e){return{name:'order_sheets',table:'suppliers',list:()=>ee.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,y.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>De('suppliers.manage'),toRow:(e,t)=>({id:ut(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:je(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(dt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ee.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ee.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,re.isUuid)(e)?e:(0,ke.uuidFrom)(`sup:${Ae.getState().venueId}:${e}`)})}}let lt=!1,ft=!1;const pt=new Map,gt=new Map,mt=new Map,_t=new Map,St=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ht=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'},yt=(e,t)=>({...e,managerAccess:t}),wt=()=>({nickname:lt,display:ft}),vt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=yt({role:e.role,level:e.level??ht(St(e)).level},!0===e.managerAccess);return(0,j.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},wt())};const bt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},kt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},It=e=>{const t=ie.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ot=2e3;function Rt(e,t){return t||!e.length||e.length>=Ot?null:e=>(0,re.isUuid)(e.id)}function At(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,De('rota.manage')):null,keepOnEmpty:()=>e&&!De('rota.manage'),list:()=>ie.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&pt.has(e.staffId)&&(De('rota.manage')||It(e.staffId)),writable:()=>De('rota.manage')||De('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(bt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:kt(e.start),end_time:kt(e.end),published:!!e.published,doc:je(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Ct(){const e=qe(62),t=e=>De('rota.manage')||e.staffId===Ae.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ie.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ae.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=qe(2)&&e.staffId===Ae.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:je(e.breaks??[]),break_mins:e.breakMins??0,doc:je((0,w.privateAttendance)(d.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,w.privateAttendance)(d.VENUE_RID,{...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Dt(){const e=qe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.staffId===Ae.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ae.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:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,re.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:je({...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Ut(e){ie.leaveRemote.decide=t=>!(!De('rota.manage')||!(0,re.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(F.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Pe.push(()=>{ie.leaveRemote.decide=null})}function Et(e){ie.timesheetRemote.send=(t,a)=>{if(!De('rota.manage')||!(0,re.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return F.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:je(s)}}),!0}const s=a;if('attendance_void'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return F.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:je(s.breaks??[]),p_reason:n,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0},Pe.push(()=>{ie.timesheetRemote.send=null})}function Tt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>V.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ae.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,re.isUuid)(a)?a:(0,ke.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,re.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:je(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>V.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=>V.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Nt=e=>V.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Kt(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}));V.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Pt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=V.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[je({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:Z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Nt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>De('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...xt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...xt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...xt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Mt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Mt=t.feature_flags??{},xt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),je({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}:{}})},apply:t=>{const a=t[0];a&&(V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&Z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Kt(e,a.events))},subscribe:e=>{const t=V.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=Z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Mt=null,xt=null;const qt=()=>new Date(Date.now()-2592e6).toISOString(),Lt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Bt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>gt.get(e));return 2===t.length&&t[0]&&t[1]?(0,he.dmId)(t[0],t[1]):null},jt=()=>Ae.getState().perms.includes('*');function Ft(){const e=()=>Ae.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ie.useOwner.getState().chat.filter(e=>(0,re.isUuid)(e.id)).map(e=>je({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=>!!Lt(t.ch)&&(t.from===e()||jt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('created_at',qt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=qt(),toRow:(e,t)=>{const a=Lt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:pt.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=Bt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?gt.get(String(e.from_staff)):'system';return s?je({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ie.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?gt.get(String(t.from_staff)):'system',i=Bt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ie.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,he.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,ye.soundAllowed)())try{(0,ye.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,k.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function $t(e,t,a){const s=Ae.getState();if(!Se.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=pt.get(e),i='*'===t?'*':Lt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Wt(e){const t=Ae.getState().staffRef,a=t?pt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Bt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ie.useOwner.getState().chatMarkRead(t,i)}catch{}}function Qt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=D.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:je(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>D.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,U.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Ht(e){const t=qe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>D.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.reminderId)&&e.staffRef===Ae.getState().staffRef,writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>D.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Vt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Gt=e=>null==e||''===e?null:Number(e),Jt=e=>e.filter(e=>!e.startsWith('data:')),zt=()=>De('takings.view');function Zt(e){const t=!zt();return{name:'cash_ups',table:'cash_ups',list:()=>de.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',qe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:je(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({cashUps:Vt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Yt(e){return{name:'sales_reports',table:'sales_reports',list:()=>de.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:je(e.vals),categories:e.categories,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({sales:Vt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Xt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=de.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,de.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:je({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,de.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>de.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ea(e){return{name:'day_tips',table:'day_tips',list:()=>de.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',qe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>de.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ta(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>de.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Gt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>de.useCashUp.setState(s=>({pot:Vt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function aa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=de.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>De('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>de.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function sa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>oe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:je(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>oe.useNotifs.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>oe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function na(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ue.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:je(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ue.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ce.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Vt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ia(e){const t=()=>De('venue.settings')||De('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ue.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,re.isUuid)(a.id)&&(0,re.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ue.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ae.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ae.getState().staffRef)||null,doc:je(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ra(e){const t=qe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ue.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:je(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({history:Vt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function oa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=le.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:je(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>De('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&le.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,w.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>le.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function da(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=me.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,me.libraryRowId)(e),kind:'library',doc:je({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,me.personRowId)(e,i),kind:'person',staffRef:i,doc:je({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ie.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,_e.canEditTasks)(t,a)},writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>me.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,me.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ua(e){const t=qe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>me.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ae.getState();return e.byRef===t.staffRef||De('staff.manage')},writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>me.useDailyTasks.setState(s=>({ticks:Vt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ca(e,t=!1){const a=qe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>we.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind||De('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,ke.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>we.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>we.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{ve.autoSync.soldOutRead.add(e)}}}function la(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>ve.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:(0,ke.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>ve.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>ve.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{ve.autoSync.linksRead.add(e)}}}async function fa(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&q.kv.get(a,!1):(q.kv.set(a,!0),!0)}catch{return q.kv.get(a,!1)}}async function pa(){const e=Ae.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();_a.setState({live:!!t?.push_live,known:!0})}catch{}}const ga='order-list-logos';const ma=new Map;const _a=(0,E.create)(()=>({live:!1,known:!1}));async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('reminders:ok',!1):(q.kv.set('reminders:ok',!0),!0)}catch{return q.kv.get('reminders:ok',!1)}}async function ha(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('chat:ok',!1):(q.kv.set('chat:ok',!0),!0)}catch{return q.kv.get('chat:ok',!1)}}const ya=(e,t)=>je({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),wa='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function va(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>C.useHr.getState().questions.filter(t=>t.venue===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ya(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);C.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>C.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function ba(e,t){const a=(t,a,s)=>{F.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(C.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(wa).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||C.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ya(e,t)))}catch{}}}),Pe.push(()=>{Object.assign(C.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ka='pair:v1',Ia='staff:v1',Oa='staff:rejoin:v1';async function Ra(e){const t=d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_invite':d.IS_GREENSIDE?'claim_greenside_invite':d.IS_ABBOTSFORD?'claim_abbotsford_invite':d.IS_KIRKTON?'claim_kirkton_invite':d.IS_WILDINGS?'claim_wildings_invite':d.IS_KIRKMICHAEL?'claim_kirkmichael_invite':d.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ee,p_device:(0,A.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,A.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Aa(){if('display'===Ee||'customer'===Ee||fe.PITCH)return'none';const e=await q.kv.get(Oa,null);if(!e)return'none';try{await Da();const{data:t,error:a}=await Ra(e);if(a)return(0,O.inviteRefusal)(a.message)?(await q.kv.remove(Oa),await q.kv.remove(Ia),'refused'):'offline';const s=t?.[0];return s?(await q.kv.set(Ia,{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,displayName:s.display_name}),'ok'):(await q.kv.remove(Oa),'refused')}catch{return'offline'}}const Ca=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Da(){Ne();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ce({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 Ua(e){if(fe.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Ra(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,d.venueKey)(`cc-pending-invite:${Ee}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),await q.kv.set(Oa,e),Me&&qa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ce({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ea='car:request:v1',Ta=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Na(){await q.kv.remove(ka),await q.kv.remove(Ia),await q.kv.remove(Ea),A.useSession.getState().meId&&A.useSession.getState().signOut()}async function Ka(){if(!(0,N.isSupabaseConfigured)())return!1;try{return await Da(),!0}catch{return!1}}const Pa=async(e,t={})=>{if(fe.PITCH)return(0,pe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Ma=null;async function xa(){for(const e of Pe)try{e()}catch{}Pe=[],Ke.forEach(e=>e.stop()),Ke=[],Ma&&(clearInterval(Ma),Ma=null)}async function qa(){await xa(),await ja()}async function La(){if(!(0,N.isSupabaseConfigured)()||'customer'===Ee||fe.PITCH)return!1;try{Ne();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ee)return!1;if(!await q.kv.get(Oa,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Aa()&&(qa(),!0)}catch{return!1}}(0,c.setSessionMender)(La);let Ba=d.VENUE_RID;async function ja(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Ba;try{if(Ce({mode:'connecting'}),await F.mutationQueue.load(),'customer'===Ee)return void await Va(e);let t=await q.kv.get(ka,null),a=await q.kv.get(Ia,null);if(G.IS_CAR&&!t&&a){const e=(0,J.migrateCarStaffIdentity)(a);e&&(t=e,await q.kv.set(ka,t)),await q.kv.remove(Ia),a=null,A.useSession.getState().meId&&A.useSession.getState().signOut()}if(d.IS_ISOLATED_VENUE&&(t&&!(0,d.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,d.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ce({mode:'display'===Ee?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ee&&!G.IS_CAR&&a&&!s.session){const t=await Aa();if('offline'===t)return Ce({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Ba===e&&qa()},6e4);'refused'===t&&a.staffRef&&A.useSession.getState().meId===a.staffRef&&A.useSession.getState().signOut(),a=await q.kv.get(Ia,null),({data:s}=await Re().auth.getSession())}const n='display'===Ee||G.IS_CAR?t:a;if(!s.session||!n)return void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Pa('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ee||G.IS_CAR?await q.kv.remove(ka):(await q.kv.remove(Ia),await q.kv.remove(Oa)),'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId===n.staffRef&&A.useSession.getState().signOut(),void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ee?'This display was unpaired by a manager.':G.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,K.isOnline)()||/fetch|network/i.test(String(t?.message)))Ce({mode:'offline'});else if(Ca(t)&&'display'!==Ee){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Aa()&&setTimeout(()=>{Ba===e&&qa()},500)}i=Ae.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ce({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!G.IS_CAR&&'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId!==n.staffRef&&(A.useSession.getState().signIn(n.staffRef),ie.useOwner.setState({staffAs:n.staffRef})),G.IS_CAR&&(A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({previewRole:'owner'})),await $a(n.venueId,e,n.kind)}catch(e){Ce({mode:'local',lastError:String(e?.message??e)})}}const Fa=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','venue_reminders','reminder_done']);async function $a(e,a,s){if(!(0,d.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||G.IS_CAR&&'device'===s;await ws(a),Pe.push(Ks(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])mt.set(e.key,e.id),_t.set(e.id,e.key)}catch{}const i=[Pt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ie.useOwner.getState().staff.map(vt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>De('staff.manage'),deletes:!1,revision:e=>(0,j.staffRevision)(e,wt()),toRow:(e,t)=>(0,j.staffRow)(e,t,wt(),e.managerAccess||e.ownerAccess?null:mt.get(St(e))),fromRow:e=>{if(!e.external_ref)return null;pt.set(String(e.external_ref),String(e.id)),gt.set(String(e.id),String(e.external_ref)),Us.set(String(e.external_ref),e.avatar_path??null);const t=yt(ht(_t.get(String(e.role_id))),!0===e.manager_access);return(0,j.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},wt())},apply:e=>ie.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=>ie.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ns()},onRemote:()=>{Ns()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ie.useOwner.getState(),t=ae.useSetup.getState().sites[Ba]?.staffGrade??{};return e.staff.filter(e=>pt.has(e.id)).map(a=>je({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=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:pt.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=gt.get(String(e.staff_id));return t?je({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=>ie.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=ae.useSetup.getState().sites[Ba],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&&ae.useSetup.getState().patch(Ba,{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=ie.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=ae.useSetup.subscribe((t,a)=>{t.sites[Ba]?.staffGrade!==a.sites[Ba]?.staffGrade&&e()});return()=>{t(),a()}}},Fe(a,!1),Fe(a,!0),We(a),Ve(a),$e(a),Ge(a),et(a),tt(a),ct(a),{name:'supplier_directory',table:'suppliers',list:()=>ie.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('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:je(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ie.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId),writable:()=>De('suppliers.order')||De('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||xe(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:je(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},st(a),As(a)];De('wages.view')&&i.push(Cs(a)),n&&(i.push(At(!0),Ct(),Dt(),Tt(a)),Et(e)),n&&await fa('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ae.getState().staffRef&&'pending'===e.status||De('rota.manage')),writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:je(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Fa.add('staff_leave'),Ut(e));const o=n&&await ha();if(Se.useChatSync.setState({synced:o,checked:!0}),Pe.push(()=>Se.useChatSync.setState({synced:!1})),o&&i.push(Ft(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(he.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:pt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:pt.get(e.id),include:e.include}),fromRow:e=>{const t=gt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>he.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=>he.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await fa('hr_questions')&&(i.push(va(a)),Fa.add('hr_questions'),ba(e,a)),'guest'!==s&&'customer'!==Ee&&await fa('temp_readings')&&(i.push((0,Q.tempUnitsSpec)(ne.useSafety,Ye),(0,Q.tempReadingsSpec)(ne.useSafety,Xe)),Fa.add('temp_units'),Fa.add('temp_readings')),'guest'!==s&&await fa('sold_out_items')?(i.push(ca(a,await fa('sold_out_items','auto'))),Fa.add('sold_out_items')):ve.autoSync.soldOutRead.add(a),'guest'!==s&&await fa('sold_out_links')?(i.push(la(a)),Fa.add('sold_out_links')):ve.autoSync.linksRead.add(a),D.useReminders.getState().ensure(a),'guest'!==s&&await Sa()&&(i.push(Qt(a)),n&&i.push(Ht(a))),oe.useNotifs.getState().ensure(a),ue.useOrderLists.getState().ensure(a),n){lt=await fa('staff','nickname'),ft=await fa('staff','display_clock');const[e,t,s,n]=await Promise.all([fa('scheduled_notifications'),fa('order_lists'),fa('venue_clock_area'),fa('daily_tasks')]);me.useDailyTasks.getState().ensure(a),n&&(i.push(da(a),ua(a)),Fa.add('daily_tasks'),Fa.add('daily_task_ticks')),e&&(i.push(sa(a)),pa()),t&&i.push(na(a),ia(a),ra(a)),s&&i.push(oa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Fa.add(n)}if('guest'!==s&&await fa('day_tips')){i.push(ea(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Fa.add(e);await fa('tips_pot_events')&&i.push(ta(a),aa(a)),n&&(zt()||(0,de.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(Zt(a),Xt(a)),Fa.add('cash_ups'),zt()&&(i.push(Yt(a)),Fa.add('sales_reports')),t(r[73])(r[72],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(At(),Ct()),await fa('scheduled_notifications')&&i.push(sa(a)));let u=!1;const c=()=>{if(G.IS_CAR&&n&&De('recipes.edit'))return!0;const e=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);return!!e&&e.active&&De('recipes.edit')&&(0,S.costsAllowedFor)(e)};n&&c()&&await fa('ingredient_prices')&&(i.push((0,_.gpSyncSpec)('ing',c)),Fa.add('ingredient_prices'),await fa('card_costs')&&(i.push((0,_.gpSyncSpec)('card',c)),Fa.add('card_costs')),await fa('kitchen_deliveries')&&(i.push((0,_.gpSyncSpec)('del',c)),Fa.add('kitchen_deliveries')),await fa('kitchen_stock_counts')&&(i.push((0,_.gpSyncSpec)('count',c)),Fa.add('kitchen_stock_counts'))),(0,Oe.specialsSyncOn)()&&'guest'!==s&&await fa('specials_boards')&&(i.push((0,Oe.specialsBoardSpec)(a,()=>De('recipes.edit')||De('floor.manage')||De('*'))),Fa.add('specials_boards'));const l={onActivity:()=>Ce({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ce({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ce({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Pa('whoami')??[]).some(t=>t.venue_id===e))return void(Ba===a&&qa());for(const a of Ke){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||$.useBookingSaves.getState().mark({id:t,table:e,why:is()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||W.useTempSaves.getState().mark({id:t,table:e,why:gs(e)??'this screen could not send it'})}};Ke=i.map(t=>new H.EntityBridge(t,e,l)),await Promise.all(Ke.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,K.isOnline)())try{const t=await Pa('whoami');if(!t?.some(t=>t.venue_id===e))return void(Ba===a&&qa())}catch(e){if(Ca(e)){if(G.IS_CAR)return void(Ba===a&&qa());const e=await Aa();return void('ok'!==e&&'refused'!==e||Ba===a&&qa())}}let t=0;for(const[a,s]of Ke.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(Se.useChatSync.getState().error&&Se.useChatSync.setState({error:void 0}),await Wt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&Se.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({mode:'live',lastSyncAt:e,lastServerAt:e}),F.mutationQueue.flush()}else Ce({mode:'offline'});if(!De('wages.view')){const e=Ae.getState().staffRef;ie.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const m=new Map;for(const e of Ke)m.set(e.spec.table,[...m.get(e.spec.table)??[],e]);const h=[...m.keys()].filter(e=>Fa.has(e)).map(e=>({table:e,venueColumn:m.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,H.venueChannel)(e,h,(e,t,a)=>{for(const s of m.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ce({lastSyncAt:s,lastServerAt:s})},e=>{Ce({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Pe.push(()=>{Re().removeChannel(w)}),Pe.push((0,K.onConnectivity)(e=>{e&&p()}));const v=Ke.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,P.superviseSync)({fastMs:Qa(Ee),readFast:async()=>{for(const e of v)await e.read()},readAll:p,flush:()=>{F.mutationQueue.flush()},wake:()=>{F.mutationQueue.retryNow()},restart:()=>{Ba===a&&qa()},realtime:()=>Ae.getState().realtime,lastServerAt:()=>{const e=Ae.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Ca,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>Wa(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Pe.push(k.stop)}async function Wa(e){const t=Ae.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Pa('sync_heartbeat',{p_venue:e,p_device:(0,A.deviceId)()??'unknown',p_app:Ee,p_version:x.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Qa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ae.getState(),queue:F.mutationQueue.pending.map(e=>e.table),failedTables:F.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),fe.PITCH&&(window.__ccSyncPreview=e=>Ce(e)));const Ha='guest:sent:v1';async function Va(e){Ce({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Pa('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!d.IS_ISOLATED_VENUE||t.id===d.VENUE_UUID)){Ce({venueId:t.id,venueName:t.name}),await ws(e);const a=t.app?.restaurant;a&&V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withWildingsAddress)({...a,id:e}):t)})),Kt(e,t.app?.events)}await Ga(e),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ce({mode:(0,K.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Ga(e).catch(()=>{})},6e4);Pe.push(()=>clearInterval(t)),d.IS_ISOLATED_VENUE||await Ja(e)}async function Ga(e){const t=await Pa('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));X.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&V.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))]}});try{const t=await Pa('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function Ja(e){let t=await q.kv.get(Ha,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=V.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Ka())return;for(const a of n)try{const s=(await Pa('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(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&&V.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'},Ce({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Pa('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(a.allergies)}}))?.[0];t={...t,[a.id]:'order'},s&&V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?Za(e,s):e)}))}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ce({lastError:`Order: ${s}`}),V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:Ya(s)}}:e)})))}await q.kv.set(Ha,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Pa('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await q.kv.set(Ha,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Pa('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));V.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=Za(e,a);return za(s)===za(e)?e:s})})),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ce({mode:(0,K.isOnline)()?Ae.getState().mode:'offline'})}finally{a=!1}}};Pe.push(V.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Ma=setInterval(()=>{n()},15e3),Xa=()=>{n()},n()}const za=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function Za(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const Ya=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let Xa=null;const es={bridges:()=>Ke,restart:qa};function ts(){const e=Ae.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!De('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function as(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(!e||ts())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(F.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function ss(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}as();try{await F.mutationQueue.retryNow()}catch{}}Ae.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{ss()},3e3)});const ns=['bookings','walk_ins'];function is(){const e=Ae.getState();return Ue()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const rs=()=>Ke.filter(e=>ns.includes(e.spec.table)),os=e=>F.mutationQueue.failed.some(t=>ns.includes(t.table)&&t.rowKey===e);function ds(e=!1){return is()?0:rs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&os(t)&&!!$.useBookingSaves.getState().notSaved[t]),0)}async function us(e=!1){const t=is();if(t)return t;for(const e of rs())try{await e.read()}catch{}ds(e);try{await F.mutationQueue.retryNow()}catch{}return e&&cs(),null}function cs(){const e=rs()[0]?.venueId??'',t=$.useBookingSaves.getState(),a=new Set(rs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||os(s)||ns.some(t=>F.mutationQueue.hasPending(t,e,s))||t.clear(s)}F.mutationQueue.onFailed(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().clear(e.rowKey)});let ls=null;const fs=(e=2500)=>{ls&&clearTimeout(ls),ls=setTimeout(()=>{ls=null,us(!1)},e)};(0,K.onConnectivity)(e=>{e&&fs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&fs(3e3)});const ps=['temp_readings','temp_units'];function gs(e="temp_readings"){const t=Ae.getState();return Ue()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ye()?'device'!==t.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ms=()=>Ke.filter(e=>ps.includes(e.spec.table));async function _s(e=!1){const t=gs();if(t)return t;for(const e of ms())try{await e.read()}catch{}const a=ms()[0]?.venueId??'';for(const t of ms())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,F.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await F.mutationQueue.retryNow()}catch{}if(e){const e=W.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ms().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||F.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,W.tempKey)(t.table,t.id))}}return null}F.mutationQueue.onFailed(e=>{ps.includes(e.table)&&W.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ps.includes(e.table)&&W.useTempSaves.getState().clear((0,W.tempKey)(e.table,e.rowKey))});let Ss=null;const hs=(e=3e3)=>{Ss&&clearTimeout(Ss),Ss=setTimeout(()=>{Ss=null,_s(!1)},e)};(0,K.onConnectivity)(e=>{e&&hs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3500)});const ys='golive:v1:';async function ws(e){'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)?await Os(e):(await q.kv.get(ys+e,!1)||await Os(e),await q.kv.get(ks+e,!1)||(Is(e),await q.kv.set(ks+e,!0)),await q.kv.get(vs+e,!1)||(bs(),await q.kv.set(vs+e,!0)))}const vs='golive:v3:';function bs(){const e=e=>JSON.stringify(e).includes('(example)');try{se.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ks='golive:v2:';function Is(e){const t=e=>JSON.stringify(e).includes('(example)');V.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)))})),ie.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 Os(e){if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)){const t=(0,g.stripCoreLiveSamples)(V.useStore.getState()),a=(0,se.stripKitchenExamples)(se.useKitchen.getState()),s=ie.useOwner.getState(),n=(0,g.stripOwnerLiveSamples)(s),i={accidents:ne.useSafety.getState().accidents.filter(e=>!(0,ne.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(V.useStore.getState(),t)&&(await(0,m.archiveChefCache)('core',V.useStore.getState()),V.useStore.setState(t)),r(se.useKitchen.getState(),a)&&(await(0,m.archiveChefCache)('kitchen',se.useKitchen.getState()),se.useKitchen.setState(a)),r(s,n)&&(await(0,m.archiveChefCache)('owner',s),ie.useOwner.setState(n)),r(ne.useSafety.getState(),i)&&(await(0,m.archiveChefCache)('safety',ne.useSafety.getState()),ne.useSafety.setState(i));const o=(0,C.stripHrSamples)(C.useHr.getState());r(C.useHr.getState(),o)&&(await(0,m.archiveChefCache)('hr',C.useHr.getState()),C.useHr.setState(o));const d=(0,_.stripGpSamples)(_.useGpCalc.getState());r(_.useGpCalc.getState(),d)&&(await(0,m.archiveChefCache)('gp',_.useGpCalc.getState()),_.useGpCalc.setState(d));const u=ee.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,m.archiveChefCache)('order-sheets',u),ee.useOrderSheets.setState(c));const l=X.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,p.isLiveVenue)(e.restaurantId)||!(0,y.isDemoCard)(e)),log:l.log.filter(e=>!(0,y.demoActor)(e.by))};return r(l,f)&&(await(0,m.archiveChefCache)('recipe-cards',l),X.useCardStore.setState(f)),void await q.kv.set(ys+e,!0)}const t=t=>t.restaurantId===e&&!(0,re.isUuid)(t.id);V.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)))})),z.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,re.isUuid)(t.id))})),Z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ie.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,re.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,re.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,re.isUuid)(e.id)),leave:e.leave.filter(e=>(0,re.isUuid)(e.id)),swaps:[]}));try{se.useKitchen.setState(e=>(0,se.stripKitchenExamples)(e))}catch{}ie.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,re.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId))}));try{ne.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await q.kv.set(ys+e,!0)}const Rs=(e,t)=>je({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function As(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(Z.useFloor.getState().live[e]??{}).map(([e,t])=>Rs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ae.getState().kind||De('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:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>Rs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>Z.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=>Z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Cs(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(ae.useSetup.getState().sites[e]?.grades??ae.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:()=>De('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=ae.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));ae.useSetup.getState().patch(e,{grades:i})},subscribe:t=>ae.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ds='staff-avatars',Us=new Map;let Es=!1;const Ts=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ns(){if(!Es){Es=!0;try{for(const[e,t]of Us){const a=te.useAvatars.getState().photos[e];if(!t){a?.path&&te.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ae.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Ds).download(t);if(n||!s)continue;const i=await Ts(s);i.startsWith('data:image/')&&te.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{Es=!1}}}function Ks(e){const t=async()=>{const t=Ae.getState().staffRef,a=t?pt.get(t)??Ae.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ae.getState().kind)return;const s=te.useAvatars.getState().photos[t];try{const n=Us.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Ds).remove([t]).catch(()=>{})};if(!s){const e=!!te.useAvatars.getState().clears?.[t];return e&&n&&(await Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}),Us.set(t,null),i(n)),void(e&&te.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ce({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Ds).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Pa('set_staff_avatar',{p_staff_ref:t,p_path:d}),Us.set(t,d),n!==d&&i(n),te.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ce({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:te.useAvatars.getState().photos},s=te.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),De('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ae.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Us.set(t,null),te.useAvatars.getState().doneClear(t),Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Ds).remove([e])).catch(()=>{})}});return t(),s}const Ps=new Map,Ms=(0,E.create)(()=>({n:0}))},987,[988,5,989,932,6,832,837,833,838,990,994,995,835,997,999,1000,1001,1002,1003,13,1004,1006,1009,1010,846,933,976,1011,1012,1013,1016,977,1017,1015,1020,1014,1021,1022,1023,1024,831,872,1025,1026,1029,983,883,1031,926,927,1033,1034,891,870,1036,1039,1040,1041,1042,2,1043,1044,1045,1046,1047,1048,979,981,884,863,859,1049,1052,1053]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},988,[846]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},990,[837,34,838,5,839,846,849,991,863,870,992,993]); +__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},991,[984]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},992,[991]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},993,[991,992]); +__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},994,[]); +__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},995,[835,837,838,5,839,846,849,996,831,884]); +__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'}}]},996,[]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},997,[6,998]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},999,[846]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},1000,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1001,[846]); +__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1002,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1003,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1004,[839,846,849,5,872,1005,15,1003]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1005,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1006,[838,835,837,5,839,846,849,1007,870]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1008,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1009,[839,846,849,863,1010,870]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1010,[]); +__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)))},1011,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1012,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1013,[34,1014]); +__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1014,[1011,977,1015]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1015,[1011]); +__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.3.12.172'},1016,[]); +__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1017,[1018,1019,933,977,1014]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1019,[977]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1020,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1021,[846,849,839]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1022,[846,849,839]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1023,[1024]); +__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1024,[1018,933,1011,977,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1025,[]); +__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1026,[860,839,870,846,849,858,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1028,[891,1004,1027]); +__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1029,[5,860,839,1030,846,849,859]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1030,[1008]); +__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1031,[837,838,5,839,846,849,1032]); +__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1032,[984]); +__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1033,[837,984,838,835,5,839,846,849]); +__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1034,[837,838,5,839,846,849,1035]); +__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1035,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1036,[839,846,849,863,1037,15,870,1038]); +__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1037,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1038,[]); +__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1039,[34,839,846,849,863,13,870]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1040,[839,846,849,863,1041,870,1038]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1041,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1042,[5,997,839,846,849,998]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1043,[1039]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1044,[839,846,849,863,1045,870]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1045,[]); +__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},1046,[846]); +__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(':')}`},1047,[839,846,849]); +__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{}}},1048,[236,872]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1049,[995,1050,1051,976,933]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1051,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1052,[933,987,999]); +__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1053,[1054]); +__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1054,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1055,[34]); +__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1056,[34,236,402,102,846,821,794,1055,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1057,[34,102,794,1058,821,1059,25]); +__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1058,[827,34,379,236,402,102,821,987,1059,2,872,1016,5,796,797,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1059,[1060,933,987,872,236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1060,[]); +__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1061,[827,796,34,402,102,794,821,1044,1045,1010,1001,870,891,25]); +__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1062,[828,1063,796,827,34,281,283,364,336,402,102,426,794,821,1039,831,13,1064,1065,1001,1075,1080,1081,1084,1085,1086,1093,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1063,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1064,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1065,[34,876,1066,1067,1064]); +__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1066,[839,846,849]); +__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1067,[6,1068,1069,1070,1071,1072,1073,1074,3]); +__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1068,[]); +__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1069,[]); +__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1070,[]); +__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1071,[]); +__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1072,[]); +__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1073,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1074,[1064]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1075,[236,933,987,1076]); +__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})},1076,[499,1077,1079,1078]); +__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1077,[499,1078,1079]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1078,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1079,[1078]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1080,[933,987]); +__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1081,[34,281,236,102,794,1039,13,1082,821,1083,25]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1082,[13]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1083,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1084,[827,2,34,102,794,821,1039,891,13,987,1001,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1085,[13]); +__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1086,[34,1063,281,402,102,794,1087,1088,1092,1093,821,25]); +__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1087,[34,402,102,794,821,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1088,[837,34,874,891,858,872,1025,987,1089,1004,15,1091]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1089,[1090]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1090,[1091]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1091,[858]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1092,[34,872,1093,858,987,933]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1093,[]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1094,[34,1095,891,1009,1010,1001,1047,831,1098]); +__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1095,[997,1042,891,998,1096,1097]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1096,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1097,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1098,[]); +__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1099,[34,986,402,102,1100,794,874,1101,858,1102,821,25]); +__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)'}})]})}},1100,[34,281,283,364,102,1048,821,25]); +__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1101,[861,859]); +__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1102,[34,402,102,794,1101,858,821,25]); +__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1103,[34,102,794,874,877,821,25]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1104,[860,34,102,794,874,1026,1029,1105,1106,877,821,25]); +__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1105,[1029,859,1101]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1106,[860,877]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1107,[860,34,102,794,874,983,891,1101,858,821,25]); +__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1108,[828,827,1056,34,336,379,236,402,102,794,821,1040,1041,1001,1109,1110,987,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1109,[1076,236]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1110,[839,846,849]); +__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1111,[827,997,34,379,402,102,794,821,1036,1037,891,1040,1041,1042,998,1096,987,1059,1001,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1112,[34,1036,891,1040,1113,1009,831,1037,1001,1094]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1113,[846]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1114,[997,34,1042,891,831,998,1010,1096,1001,1095]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1115,[860,34,1001,874,1101,1048]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1116,[860,1117,34,102,794,874,1101,821,1118,1107,1119,1140,1143,1099,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1117,[34,102,14,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1118,[821]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1119,[34,102,1120,821,1121,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1120,[860,1105]); +__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1121,[1122,860,34,1123,987,1125,402,102,874,1029,1120,1124,821,858,794,1126,1026,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1122,[34,859,821,794,25]); +__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1123,[34,402,102,874,1124,1125,987,1021,821,1121,794,25]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1124,[860,1105]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1125,[281,236]); +__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1126,[827,1127,1128,860,867,14,1129,1130,34,859,402,102,872,1088,874,1131,1105,858,821,864,794,1029,1026,1132,1133,1138,1107,1101,1139,1124,1123,25]); +__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1127,[34,402,412,102,1128,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1128,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1129,[34,102,794,25]); +__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1130,[34,236,402,295,102,426,821,794,1001,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1131,[878,858,877]); +__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1132,[34,402,102,878,858,821,794,25]); +__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1133,[860,877,34,102,879,1134,1135,1137,794,874,1029,983,861,867,872,1101,821,25]); +__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1134,[34,402,821,794,25]); +__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1135,[828,860,1136,34,281,236,102,1029,1105,821,794,1107,859,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1137,[34,402,102,874,861,863,821,794,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1138,[1128,1120,1124]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1139,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1140,[1141,34,102,874,1029,1124,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1141,[34,102,874,1029,1120,1142,1124,821,1004,891,872,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1142,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1143,[34,1063,1127,102,874,1029,1026,876,872,1138,861,1004,891,1027,1120,821,858,1132,1117,1129,1144,14,1141,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1144,[34,102,874,872,1138,14,1125,821,794,25]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1145,[34,102,794,1063,1093,1146,1092,1086,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1146,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1147,[34,102,794,827,1034,891,835,1148,821,1149,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1148,[1035]); +__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1149,[34,402,102,1125,987,1150,1022,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1150,[933,976,1011,1019,1014,1017,1151,1152,1153,1154,1155,1156,977]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1151,[1019,933,1017]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1152,[1019,933,976,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1153,[1011,976,1152,1014,1017,1151]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1154,[933,977]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1155,[34,1014]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1156,[933]); +__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1157,[30,34,426,102,846,872,1088,1158,25]); +__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1158,[839,846,849]); +__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()},1159,[1160]); +__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1160,[1161,858,884]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1161,[1162,877,1163,878,858,884,1164]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1162,[858]); +__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'},1163,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1164,[858]); +__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1165,[978,34,835,402,102,874,891,1166,1161,794,821,1088,1159,1033,15,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1166,[34,102,794,874,1039,884,1167,831,13,1164,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1167,[34,884]); +__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1168,[34,402,102,794,867,821,1160,1159,1165,1033,25]); +__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1169,[34,402,102,794,874,1161,858,821,1170,1166,1165,25]); +__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1170,[828,34,283,364,236,102,426,797,794,827,821,1171,25]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1171,[]); +__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1172,[827,984,1173,835,860,1174,1175,34,402,295,102,794,874,882,1176,891,994,861,867,1179,858,821,1180,1113,1088,1160,1159,1181,869,1165,1033,925,1182,1004,987,1185,989,1098,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1173,[1159,984]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1174,[827,34,102,794,874,979,891,980,981,982,831,821,25]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1175,[]); +__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1176,[827,796,34,336,402,102,821,794,874,1177,1056,882,861,863,885,1109,1178,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1177,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1178,[827,796,34,336,236,402,102,794,831,990,861,991,994,891,1004,882,821,930,992,25]); +__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])},1179,[858]); +__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1180,[928,828,827,837,5,34,1056,336,402,102,794,891,858,821,1088,1025,925,1047,1046,987,1113,1098,25]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1181,[828,34,102,794,876,831,869,821,925,25]); +__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1182,[928,828,34,395,236,402,102,925,794,926,891,1183,927,831,5,1184,987,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1183,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1184,[933,976,987,977]); +__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1185,[34,402,102,794,891,989,1098,994,987,1091,858,1125,821,25]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1186,[1173,984,34,379,102,794,891,994,867,821,1088,1165,1033,1187,25]); +__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1187,[827,835,984,34,379,236,402,102,794,1031,983,985,867,1032,821,1165,25]); +__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1188,[984,872,34,986,1189,336,402,102,1190,794,985,983,1031,821,874,1101,858,1125,987,25]); +__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1189,[5,822,823,828,236,826]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1190,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1191,[827,1031,1173,984,34,402,102,794,891,867,821,1165,1033,25]); +__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1192,[827,34,402,102,794,796,990,874,863,991,992,821,930,1193,1197,1178,25]); +__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1194,[1195,933,987,872,2,1196,1075]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1195,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1196,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1197,[34,102,797,794,990,874,993,821,930,1178,1198,25]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1198,[]); +__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1199,[827,1200,34,402,102,426,794,891,867,858,821,1201,1088,1065,25]); +__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1201,[34,402,102,794,821,5,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1202,[860,1102,1099,1117,34,102,846,794,874,1101,878,877,858,821,1107,1203,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1203,[34,794,874,1204,25]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1204,[379]); +__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1205,[827,1063,1200,34,1206,236,402,426,102,1208,1209,1210,794,831,891,867,1064,821,930,1218,1201,1088,1065,1211,872,1212,1216,25]); +__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1206,[34,402,102,1207,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1207,[34,797,25]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1208,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1209,[34,102,794,827,891,867,1208,821,25]); +__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1210,[827,1208,34,402,102,794,925,891,1098,858,821,1201,1088,1211,872,1212,1213,1215,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1211,[1063,1085,1093]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1212,[34,102,794,891,1039,1063,1093,1087,1211,821,872,1210,1086,1088,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1213,[1064,1214]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1214,[1064,1208]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1215,[34,102,794,827,1063,1064,1213,1125,821,1216,25]); +__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1216,[1063,34,402,102,794,827,891,1214,1064,1217,1125,821,1205,1088,1208,1213,1065,25]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1217,[]); +__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1218,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1180,1201,1088,1065,1160,987,1039,1062,13,1085,1064,2,25]); +__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1219,[828,891,1220,1200,1006,1007,34,1013,1014,236,402,295,102,794,874,1098,1210,1182,1221,1090,5,1222,1161,867,858,821,1201,1180,1088,925,1042,997,998,1095,1001,1097,1166,1164,1213,1215,1091,25]); +__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1220,[827,34,402,102,794,821,891,831,876,1006,1007,25]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1221,[34,102,794,891,1090,821,1098,25]); +__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1222,[34,402,102,794,891,858,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1223,[34,102,794,891,821,1088,1091,1221,1098,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1224,[34,102,1088,821,794,25]); +__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1225,[827,1063,34,402,102,794,1034,821,930,25]); +__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1226,[827,796,1227,1149,835,891,34,336,402,102,794,1034,1035,821,925,930,1228,1231,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1227,[34,1034,891,835]); +__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1228,[828,1063,796,827,1227,835,891,34,336,402,102,797,794,925,1034,1035,1229,821,930,1230,25]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1229,[]); +__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1230,[831,891,5]); +__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1231,[34,1063,379,236,102,794,891,1034,1230,1035,1232,821,930,1227,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1232,[1035]); +__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1233,[34,402,102,794,995,861,996,821,930,1234,25]); +__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1234,[828,34,336,395,402,295,102,1235,794,995,861,996,858,821,1049,25,1237]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1235,[34,1236,102,861,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1236,[2,987]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1237,[]); +__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1238,[860,1058,34,236,402,102,797,874,821,794,1239,1130,1240,25]); +__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1239,[860,34,380,236,402,102,36,821,794,796,1130,874,25,277]); +__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1240,[1241,1242,1244,1243,1245,1048,1246]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1241,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1242,[839,5,846,849,872,1048,1243]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1243,[860,236,872,1241]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1244,[34,874,861,869,867,1242,1241]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1245,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1246,[34,1242,987,933]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1247,[34,402,102,426,874,861,821,794,1238,1130,1248,25]); +__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1248,[34,102,426,874,861,1240,1048,821,794,1130,25]); +__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1249,[34,236,402,102,879,794,821,1001,1250,1251,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1250,[872,6,933,976,1001,1240,1251]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1251,[839,1252,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1252,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1253,[34,872,1250]); +__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1254,[827,796,1227,835,984,34,931,1206,395,236,402,295,102,846,794,861,1035,867,882,1034,821,1165,1159,1186,932,25]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1255,[34,402,346,102,426,821,1207,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1256,[30,34,792,872,25]); +__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1257,[860,1127,877,30,34,1258,1002,102,14,1129,1138,794,861,867,1131,858,874,987,821,1204,864,1026,1029,1105,1133,1101,1259,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1258,[827,34,236,102,25]); +__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1259,[34,402,102,878,858,1063,1260,821,794,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1260,[1063]); +__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 b}});var n=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),a=e(_r(_d[3])),l=e(_r(_d[4])),r=_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]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,t.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),x=(0,h.useMenu)(e).find(e=>e.id===b),y=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===x?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,n.useTakeawayMenu)(n=>n.byVenue[e]),S=(0,h.useStore)(n=>n.basket.restaurantId===e&&'table'===n.basket.mode),[C,B]=(0,s.useState)(()=>(x?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,s.useState)(1),[P,T]=(0,s.useState)(''),[L,O]=(0,s.useState)(!1),[D,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[q,_]=(0,s.useState)(!1),N=(0,s.useMemo)(()=>x?(0,c.effectiveAllergens)(x,C):{},[x,C]);if(!j||!x)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(N,y.allergies),Y=(x.price??0)+(x.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,n)=>e+n.priceDelta,0),z=S||j.fictional?'on':(0,n.takeawayAvail)(x,w),F=x.soldOut||!x.signOff||null===x.price||'on'!==z,Q=(e,n)=>{const t=x.optionGroups.find(n=>n.id===e);B(e=>{const s=t.choices.map(e=>e.id);return t.multi?e.includes(n)?e.filter(e=>e!==n):[...e,n]:e.includes(n)&&!t.required?e.filter(e=>e!==n):[...e.filter(e=>!s.includes(e)),n]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:x.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),_(!0)};return(0,f.jsxs)(d.Screen,{title:x.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(a.default,{testID:"dish-photo",source:k,accessibilityLabel:`${x.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===x.price?x.priceNote:(0,u.gbp)(Y)}),x.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:x.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(x.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(n=>(0,f.jsx)(d.Chip,{label:n.label,sub:n.priceDelta?`+${(0,u.gbp)(n.priceDelta)}`:void 0,selected:C.includes(n.id),onPress:()=>Q(e.id,n.id)},n.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:x,map:N,declared:y.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:x.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&x.signOff&&null!==x.price?'This dish isn\u2019t on the takeaway menu. You can have it when you eat in.':x.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(l.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${x.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1261,[988,30,34,336,102,1235,1262,794,861,867,874,882,821,25]); +__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])},1262,[30,34,402,874,821,794,25]); +__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1263,[30,34,794,1264,874,1249,25]); +__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])},1264,[34,402,821,794,25]); +__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1265,[837,30,34,1266,794,867,874,821,1267,1271,25]); +__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:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1266,[34,385,102,874,867,821,794,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1267,[34,102,794,867,1268,1269,1270,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1268,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1269,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1270,[933,987,1269]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1271,[846,933,976,987,2,1268]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),I=_r(_d[23]),O=_r(_d[24]),R=_r(_d[25]),A=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),C=_r(_d[29]),_=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const M=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let $=!1,E=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,k.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,k.useRestaurant)(e),l=(0,k.useMenu)(e),a=(0,k.useCustomer)(),s=(0,k.useBasket)(),n=(0,k.useStore)(e=>e.startBasket),o=(0,k.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[U,V]=(0,u.useState)(!1),[Q,Y]=(0,u.useState)('takeaway'===M?'takeaway':'main');c.default.useEffect(()=>{M&&!$&&($=!0,'book'===M?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,k.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>d.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{C.START_LOYALTY_CODE&&!E&&(E=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,k.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||k.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=l.filter(e=>!('All'!==r&&e.section!==r||'takeaway'===Q&&'off'===ne(e))),re=(0,j.hoursFor)(t,o),ie=e=>()=>d.router.push(`/customer/${t.id}${e}`),de=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>V(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:ie('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:ie('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:ie('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:ie('/refer')},{icon:'gift',label:'Gift cards',on:ie('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:ie('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:ie('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:ie('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:ie('/feedback')},{icon:'hanger',label:'Lost property',on:ie('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:ie('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[re?`Kitchen today ${(0,j.kitchenHoursOn)(t,o)[0]}\u2013${(0,j.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:de.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:de.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=Q===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===Q?(0,v.jsx)(A.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===Q?(0,v.jsx)(m.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==Q?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==Q||oe.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==Q?se.filter(e=>('All'===r||e===r)&&oe.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),oe.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?'Not on the takeaway menu':'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:U,onClose:()=>V(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{V(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1272,[1273,1282,5,1283,1284,1285,1288,860,30,34,236,402,102,1235,1262,794,861,867,878,874,988,821,1289,1249,872,891,1234,995,996,1004,1290,1271,25]); +__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1273,[34,379,794,873,1274,1275,1281,874,5,6,25]); +__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1274,[34,379,102,794,997,998,1096,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1275,[6,34,933,794,1276,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1276,[6,1063,1277,1278,1279,34,102,827,794,821,11,1280,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1278,[4,11]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1279,[11]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1280,[6,933]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1281,[34,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1282,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1283,[34,102,794,1276,25]); +__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1284,[34,379,933,794,873,1274,1276,4,25]); +__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1285,[34,379,794,1274,873,1275,8,1286,25]); +__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1286,[34,102,794,1287,25]); +__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1287,[]); +__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1288,[34,794,873,1274,1275,874,9,25]); +__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1289,[34,402,102,426,794,821,1207,25]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1290,[34,102,1291,794,874,1004,1268,1271,821,25]); +__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1291,[34,102,1292,821,25]); +__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1292,[1293]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1293,[34,797,1294,1323,1324,25]); +__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1294,[1295]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1295,[1296,1297,1320,1322]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1296,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1297,[1298,1299,1300,1301,1302,1303,1304,1305,1306,1309,1313,1310,1314]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1298,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1299,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1300,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1301,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1306,[1307]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1310,[1311,1312]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1311,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1312,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1315,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1316,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1318,[1310,1298]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1319,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1320,[1321]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1322,[1321]); +__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1323,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1324,[34,797,1325,25]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1325,[]); +__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1326,[30,34,794,874,891,25]); +__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1327,[837,30,34,102,1291,794,867,874,821,1290,1271,25]); +__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1328,[837,30,34,102,1266,794,874,891,867,858,821,1267,1271,25]); +__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1329,[837,30,34,794,874,891,858,821,1290,1271,25]); +__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1330,[837,30,34,794,874,891,821,1290,1271,25]); +__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1331,[30,34,794,858,1161,1332,874,821,25]); +__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}},1332,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1333,[30,1101,34,402,102,794,858,874,821,25]); +__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 v}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),o=_r(d[3]),r=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),k=_r(d[15]),p=_r(d[16]),f=_r(d[17]);function v(){const e=(0,b.useBasket)(),v=(0,b.useRestaurant)(e.restaurantId??void 0),w=(0,b.useAllMenu)(e.restaurantId??void 0),C=(0,b.useCustomer)(),S=(0,b.useOrders)(v?.id),T=(0,b.useStore)(e=>e.setLineQty),B=(0,b.useStore)(e=>e.overrideLine),P=(0,b.useStore)(e=>e.startBasket),I=(0,b.useNow)(15e3),[O,$]=(0,a.useState)(null),[N,M]=(0,a.useState)(!1),[F,L]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,r.startForm)()),[A,R]=(0,a.useState)(''),[Y,D]=(0,a.useState)(C.phone??''),[E,_]=(0,a.useState)(C.email??''),[q,H]=(0,a.useState)(C.name&&'Guest'!==C.name?C.name:''),[G,V]=(0,a.useState)(!1),K=(0,b.useOrderAtTable)(e.restaurantId??void 0),Q=(0,p.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{K||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[K,e.mode]);const[U,J]=(0,a.useState)(null),[W,X]=(0,a.useState)(!1),Z=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,w,C.allergies),[e,w,C.allergies]);if(!v||!e.lines.length)return(0,f.jsxs)(i.Screen,{title:"Your basket",children:[(0,f.jsx)(i.Muted,{children:"Your basket is empty."}),(0,f.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ee=K&&'table'===e.mode,le=(0,h.takeawaySlots)(v,S,I),te=Z.reduce((e,l)=>e+l.unitPrice*l.qty,0),ae=Z.some(e=>e.contains.length&&!e.overridden),ne=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ee&&'on'!==(0,p.takeawayAvail)(l,Q)}),oe=!ee&&!O,re=!ee&&v.settings.takeawayPaused,se=(0,x.ukPhone)(Y),ie=q.trim().length>=2&&'guest'!==q.trim().toLowerCase(),de=ee||(0,p.takesCardTakeaway)(v,k.IS_ISOLATED_VENUE),ue=!G&&de&&!ae&&!ne.length&&N&&!oe&&!re&&(ee||ie&&se.ok&&(0,x.emailOk)(E)),ce=async()=>{V(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ee?void 0:O,tip:0,notes:F,phone:ee?void 0:se.pretty,email:ee?void 0:E.trim()||void 0,customerName:ee?void 0:q.trim()});(0,r.rememberGuard)(e.id,(0,r.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{V(!1)}},he=e.lines.find(e=>e.key===U),me=he?Z[e.lines.indexOf(he)]:void 0;return(0,f.jsxs)(i.Screen,{title:"Your basket",subtitle:`${v.name} \xb7 ${ee?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,f.jsx)(i.T,{weight:"bold",size:20,colour:j.colours.gold,children:(0,c.gbp)(te)})]}),de?ae?(0,f.jsx)(i.T,{size:14,colour:j.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):N?oe&&!re?(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Choose a collection time."}):ee||ie?ee||se.ok?null:(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your mobile number."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your name for the order."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Confirm your allergies to continue."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ee?(0,f.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!ue,onPress:()=>ce(),testID:"send-table-order"}):(0,f.jsx)(i.Button,{label:G?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(te)}`,disabled:!ue,onPress:()=>ce(),testID:"checkout"}),ee?null:(0,f.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ee||e.tableNo,null),ee?(0,f.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,v.fictional?null:(0,f.jsx)(i.AllergenNotice,{phone:v.phone}),Z.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,f.jsxs)(i.Card,{highlight:l.contains.length?j.colours.red:l.may.length?j.colours.amber:void 0,children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,f.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,f.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,f.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,f.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,f.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,f.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${C.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,f.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{X(!1),J(a.key)}})]})]}):l.contains.length?(0,f.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,f.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ne.includes(a)?(0,f.jsx)(i.Badge,{kind:"amber",label:!ee&&Q&&w.find(e=>e.id===a.itemId)&&'sold-out'===(0,p.takeawayAvail)(w.find(e=>e.id===a.itemId),Q)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Stepper,{value:a.qty,onChange:e=>T(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${v.id}`)}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(I)]}),re?(0,f.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===le.length?(0,f.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(i.Muted,{children:["15-minute slots, max ",v.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:le.slice(0,16).map(e=>(0,f.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:O===e.time.toISOString(),onPress:()=>$(e.time.toISOString())},e.label))})]})]}),(0,f.jsxs)(i.Card,{highlight:N?void 0:j.colours.amber,children:[(0,f.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:C.allergies.length?C.allergies.map(e=>(0,f.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,f.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,f.jsx)(i.Toggle,{label:C.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:N,onChange:M}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.H2,{children:"Your details"}),(0,f.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:q,onChangeText:H,autoComplete:"name",placeholder:"e.g. Sam Smith"}),q&&!ie?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"Please add your name."}):null,(0,f.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:Y,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!se.ok&&Y?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:se.error}):null,(0,f.jsx)(i.Field,{label:"Email (optional)",value:E,onChangeText:_,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,x.emailOk)(E)?null:(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,f.jsx)(i.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,f.jsx)(i.Field,{label:"Order notes (optional)",value:F,onChangeText:L,placeholder:"e.g. cutlery please"}),ee?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>P(v.id,'takeaway')}):null,(0,f.jsxs)(i.Sheet,{visible:!!he,onClose:()=>J(null),title:"Allergy override",children:[me?(0,f.jsx)(i.Banner,{kind:"danger",title:`${me.name} contains ${me.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,f.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:W,onChange:X}),(0,f.jsx)(i.Button,{kind:"danger",disabled:!W,label:"Confirm override",onPress:()=>{he&&me&&B(he.key,me.contains),J(null)}})]}),(0,f.jsx)(o.Honeypot,{value:A,onChange:R})]})}},1334,[860,30,34,1258,1002,102,794,861,867,1131,858,874,831,821,864,5,988,25]); +__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1335,[30,34,102,1262,794,861,878,874,821,1289,5,25]); +__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 f}});var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1336,[860,30,34,102,1264,794,861,867,858,874,821,1337,25]); +__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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1337,[34,371,379,236,30,794,867,821,988,1338,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1338,[933,987]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1339,[860,1271,30,34,102,794,861,867,858,874,879,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1340,[30,34,872,25]); +__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1341,[837,30,34,794,874,5,1271,25]); +__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1342,[30,34,794,1343,1175,1271,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1343,[827,860,34,102,794,861,867,1175,1344,874,821,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1344,[933,987,1175]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1345,[30,34,872,1346,1410,25]); +__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1346,[1162,796,5,6,1347,828,853,1122,860,1161,1348,1349,1350,1119,1143,1351,1352,1357,1358,1359,872,1360,1174,979,1130,1361,34,1099,1202,1048,1115,1157,1362,395,380,402,295,102,426,36,794,1249,1253,873,861,858,874,821,1118,891,1126,1088,1029,1105,1135,1363,1134,1364,1371,1373,1376,1379,1375,1380,1382,1383,1140,1123,1124,878,1387,1238,1388,1248,1240,1026,1393,1401,1402,1102,1142,1404,1405,1406,1098,1189,1407,1188,1181,869,1408,1409,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1348,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1349,[1027,1088]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1350,[34,102,1105,794,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1351,[860,34,102,794,874,1175,821,25]); +__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1352,[34,395,402,426,102,1291,794,1189,796,1029,1353,1354,1356,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1353,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1354,[34,395,402,295,412,102,426,796,794,821,1355,1356,25]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1355,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1356,[1025,872,1355,933,987]); +__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1357,[846]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1358,[828,34,379,395,402,102,794,1189,821,25]); +__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1359,[34,236,402,102,794,821,891,1004,858,1098,25]); +__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1360,[828,827,34,236,402,295,102,794,1174,874,979,831,981,982,872,980,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1361,[828,34,102,821,794,25]); +__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1362,[34,102,797,821,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1363,[]); +__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1364,[828,796,827,1122,860,1130,34,236,402,295,426,102,859,821,794,1365,1366,1029,891,1134,1368,987,872,25]); +__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1365,[828,860,34,1366,102,859,821,794,1135,1367,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1366,[859]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1367,[1366,859]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1368,[34,385,295,102,859,1369,1370,821,796,827,794,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1369,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[1369,1025,872,933,987]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[34,236,402,102,821,794,1189,1372,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[828,860,1123,34,281,236,295,102,1136,874,1029,1105,14,858,1124,1374,821,794,1375,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1376,[5,828,34,283,336,236,402,102,426,821,873,794,1030,1001,1357,1377,2,1378,1379,874,858,25]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1377,[236]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1379,[34,846,933,987,1378]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1380,[860,14,1029,1381]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1381,[861]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1382,[34,102,797,821,25]); +__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1383,[1384,860,1123,1029,34,102,794,1126,874,1386,1380,1124,858,1121,1140,1141,1142,821,1349,25]); +__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1384,[34,379,402,102,874,1004,891,1027,1385,872,821,794,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1385,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1386,[1029,1105]); +__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1387,[1384,828,1123,827,860,1161,1119,1140,858,34,1107,236,402,295,102,794,1126,1375,874,1029,861,1117,1105,1332,821,1349,25]); +__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1388,[827,34,236,402,102,794,874,1029,1389,821,1390,1392,25]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1389,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1390,[846,874,1029,1389,1391,1392]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1391,[860]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1392,[236,1391]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1393,[860,34,1206,1189,402,102,1026,1029,878,858,821,794,1394,1397,25]); +__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1394,[1395,870,860,34,281,395,402,295,102,874,1026,1029,1396,858,821,1056,794,1397,1398,987,1349,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1395,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1396,[878,858,877]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1397,[5,1029,933,987]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1398,[846,933,987,1399,2,1400]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1399,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1400,[15]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1402,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1403,[1105]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1404,[860,1381]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1405,[34,402,102,794,1404,821,1362,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1406,[34,102,925,794,1189,858,821,25]); +__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1407,[34,1189,402,102,426,794,25]); +__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1408,[828,1063,827,2,1189,34,402,102,426,794,821,891,998,858,1001,1398,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[34,1036,891,1009,831,1037,1001,1398,1094]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[5,828,873,34,236,402,102,426,987,821,794,1357,1411,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1412,[30,34,872,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1413,[30,34,872,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1414,[30,34,1415,872,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1415,[34,872,1416,1550,25]); +__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,"canSignOffHours",{enumerable:!0,get:function(){return he}}),_e.barTabsFor=me,_e.signOffSpeech=be,_e.OwnerApp=function(){return H.IS_OWNER_DESKTOP?(0,ue.jsx)(de.DesktopGate,{phone:(0,ue.jsx)(xe,{})}):(0,le.isDesktop)()?(0,ue.jsx)(ce.DesktopShell,{}):(0,ue.jsx)(xe,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),j=_r(d[14]),w=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=e(_r(d[20])),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),I=_r(d[24]),L=_r(d[25]),O=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]),$=_r(d[32]);_r(d[33]);var D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),z=_r(d[39]),F=_r(d[40]),U=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]),Y=_r(d[45]);_r(d[46]);var J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]),de=_r(d[60]),ce=_r(d[61]),ue=_r(d[62]);const fe=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ge=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],he=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function me(e,t){return ge.filter(t=>!t.can||t.can(e)).map(e=>'orders'===e.id&&t?{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'}:'forecast'===e.id?{id:'rota',label:'Rota',icon:'rota'}:e)}function be(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const pe={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function xe(){const{rid:e,r:le,role:de,today:ce,now:xe,meId:je,me:we}=(0,_.useCtx)(3e4);(0,b.useTipsPosted)(e,ce,'staff'!==de);const Se=(0,_.useSignedIn)();(0,c.useSoldOutLink)(!0,(Se?.name??we).replace(' (example)',''));const ye=(0,I.useOrders)(e),[Ae,ke]=(0,j.useState)('home'),[Re,Ce]=(0,j.useState)(null),[ve,Te]=(0,j.useState)(!1),Ie=(0,n.useLiveVenue)(),[Le,Oe]=(0,j.useState)(!1),Ee=(0,j.useRef)(null);(0,j.useEffect)(()=>{(0,_.ensureAttendance)(ce,xe),(0,Q.ensureChat)(xe)},[ce]),globalThis.__ccNow=xe.getTime();const Be=(0,Q.useChatUnread)().total,Pe=(0,j.useRef)({t:'home',s:null});Pe.current={t:Ae,s:Re};const Ne=(0,j.useRef)([]),$e=(0,l.useScrollMemory)(Ee),De=(0,j.useCallback)((e,t=null)=>{const s=Pe.current;s.t===e&&s.s===t||(Ne.current=[...Ne.current,{...s,y:$e.leave()}].slice(-30),$e.restore(0)),ke(e),Ce(t)},[]),Me=(0,j.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Pe.current;let t=Ne.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Ne.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return $e.leave(),ke(s.t),Ce(s.s),$e.restore(s.y??0),!0},[]);(0,u.useWebBack)(Me);const He=(0,u.useInnerBackShown)();(0,j.useEffect)(()=>(re.useVoiceNav.setState({go:De}),()=>re.useVoiceNav.setState({go:null})),[De]),(0,j.useEffect)(()=>{f.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchOwner=L.useOwner)},[De]),(0,j.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Me);return()=>e.remove()},[Me]),(0,j.useEffect)(()=>{const e=ge.find(e=>e.id===Ae);e?.can&&!e.can(de)&&De('home');const t=(0,K.pageFor)(Re);t?.can&&!t.can(de)&&Ce(null)},[de]);const We='more'===Ae?(0,K.pageFor)(Re):void 0,Ve=ye.filter(e=>(0,B.LIVE)(e)&&'new'===e.status).length,{unread:ze,list:Fe,read:Ue}=(0,J.useNotifications)();(0,se.useAlertWatcher)(e,{nag:'staff'!==de}),(0,oe.useReviewAlerts)(e),(0,ne.useScheduledNotices)({rid:e,staffId:Se?.id??'',name:we,onOpen:e=>'bookings'===e?De('bookings'):'chat'===e?De('chat'):De('more',e)}),(0,ae.useOffRotaAlerts)({enabled:'staff'!==de&&!!Se});const qe=Se?.role??de,Ge='owner'===qe?'OWNER':'manager'===qe?'MANAGER':'STAFF',Ke=(0,se.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,se.isUnread)(t,s)&&!(0,se.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),Ye=(0,se.useAlerts)(t=>t.todoSeen[e]),Je=Math.max(0,ze-Fe.filter(e=>!Ue[e.id]&&(Ye??[]).includes(e.id)).length)+Ke;(0,se.useAlertSeenSync)(e),(0,j.useEffect)(()=>{G.useShellBadges.setState({notifCount:Je})},[Je]);const Qe=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Xe=he(de),Ze=(0,r.useOutstanding)(),et=Ze.days.length+Ze.requests,tt=me(de,Xe),st='more'===Ae&&'signoff'===Re?'signoff':'more'===Ae&&'rota'===Re?'rota':'forecast'===Ae||'orders'===Ae&&Xe?'more':Ae,ot=t.IS_ISOLATED_VENUE?[{id:e,name:le.name,place:le.location||le.address||''}]:fe,rt=ot.find(t=>t.id===e)??ot[0],nt=Se?.ownerAccess&&'owner'!==Se.role?'owner privileges':Se?.managerAccess&&'staff'===Se.role?'manager privileges':'',at=(0,M.ownerHomeLayout)(de,Se);(0,k.default)().width;return(0,ue.jsxs)(C.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,ue.jsxs)(R.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,ue.jsxs)(R.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>De('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,ue.jsx)(y.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:Je?`Notifications, ${Je} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>De('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),Je?(0,ue.jsx)(R.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(v.T,{size:10,weight:"bold",children:Je})}):null]})}),(0,ue.jsx)(Z.VoiceSlot,{size:44})]}),(0,ue.jsx)(R.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ue.jsx)(R.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,ue.jsx)(y.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${we}. Account and role${nt?`, ${nt}`:''}`,disabled:'owner'!==H.APP_VARIANT,onPress:()=>Oe(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ue.jsxs)(v.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ue.jsx)(P.StaffAvatar,{id:je,size:24,ring:!1}),(0,ue.jsxs)(R.default,{style:{flexShrink:1},children:[(0,ue.jsxs)(v.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[Se?`${we} \xb7 ${Se.level??L.ROLE_LABEL[Se.role]}`:`${we} \xb7 ${L.ROLE_LABEL[de]}`,'owner'===H.APP_VARIANT?' \u25be':'']}),nt?(0,ue.jsx)(v.Muted,{center:!1,size:10,numberOfLines:1,children:nt}):null]})]})})})}),(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>Te(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,ue.jsx)(T.VenueHeaderBlock,{rid:e,name:le.name,badge:Ge,place:`${'staff'===de?'Staff preview \xb7 ':'Managers \xb7 '}${rt.place}`})}),de!==(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner')&&'owner'===H.APP_VARIANT?(0,ue.jsx)(y.default,{onPress:()=>L.useOwner.getState().setPreviewRole(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,ue.jsx)(v.T,{size:12,colour:O.colours.gold,children:'staff'===de?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[de].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`})}):null]}),(0,ue.jsxs)(A.default,{ref:Ee,...$e.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ue.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Re||He),onBack:Me,title:We?We.title:'bookings'===Ae&&'waitlist'===Re?'Waitlist':'staff'===de&&'home'===Ae?'Staff app preview':pe[Ae]}),'home'===Ae&&Se&&'staff'===Se.role&&'owner'===H.APP_VARIANT?(0,ue.jsxs)(R.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,ue.jsx)(v.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,ue.jsx)(v.Button,{label:"Clock in and my shifts",onPress:()=>De('more','clock')})]}):null,'home'!==Ae||at?null:(0,ue.jsx)(a.WhoBar,{}),'home'===Ae&&!at&&Se?(0,ue.jsx)(ie.MyShiftCard,{go:De}):null,'home'===Ae&&!at&&Se?(0,ue.jsx)(h.MyTasksToday,{rid:e,staffId:Se.id,name:Se.name,onShift:(0,p.shiftNow)(Se.id,Date.now()).on}):null,'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TodaysTipsCard,{rid:e,today:ce}),'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TipsPotCard,{rid:e,today:ce}),'home'===Ae?'staff'===de?(0,ue.jsx)(z.StaffHome,{go:De}):(0,ue.jsx)(D.Dashboard,{go:De,ownerHome:at}):null,'orders'===Ae?(0,ue.jsx)(Y.Orders,{}):null,'bookings'===Ae?(0,ue.jsx)(E.Bookings,{go:De,only:'waitlist'===Re?'waitlist':void 0}):null,'forecast'===Ae?(0,ue.jsx)(F.Forecasts,{go:De}):null,'chat'===Ae?(0,ue.jsx)(Q.Chat,{go:De}):null,'more'===Ae?We?(0,ue.jsx)(We.C,{go:De}):(0,ue.jsx)(K.MoreMenu,{go:De}):null]}),(0,ue.jsx)(x.SeatAllergenReminder,{rid:e}),'staff'!==de?(0,ue.jsx)(te.PrintHost,{rid:e}):null,'staff'!==de?(0,ue.jsx)(ee.AlertHost,{variant:"managers",rid:e,me:we,onOpen:e=>De('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,ue.jsx)(X.AssistantSheet,{}),(0,ue.jsx)(q.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:st,onPress:e=>'signoff'===e?De('more','signoff'):'rota'===e?De('more','rota'):De(e),tabs:tt.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?be(Ze.days.length,Ze.requests):'more'===e.id&&Xe&&Ve?`More, ${Ve} new order${Ve>1?'s':''} in Orders`:void 0,badge:'chat'===e.id&&Be?{text:String(Be),bg:O.colours.red}:'bookings'===e.id&&Qe?{text:String(Qe),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&Ve?{text:String(Ve),bg:O.colours.red}:'signoff'===e.id&&et?{text:String(et),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Xe&&Ve?{text:String(Ve),bg:O.colours.red,testID:'more-orders-badge'}:null}))}),(0,ue.jsx)(S.default,{visible:ve,transparent:!0,animationType:"fade",onRequestClose:()=>Te(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Te(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Your venues"}),ot.filter(e=>!Ie||'saltmarsh'!==e.id).map(t=>(0,ue.jsx)(y.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),Te(!1),De('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,ue.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(v.T,{weight:"medium",children:t.name}),(0,ue.jsx)(v.Muted,{children:t.place})]}),t.id===e?(0,ue.jsx)(v.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,ue.jsx)(v.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${le.name}.`:Ie?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,ue.jsx)(S.default,{visible:Le,transparent:!0,animationType:"fade",onRequestClose:()=>Oe(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Oe(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[Se?(0,ue.jsxs)(v.Row,{gap:10,children:[(0,ue.jsx)(P.StaffAvatar,{id:Se.id,size:44}),(0,ue.jsxs)(R.default,{style:{flex:1},children:[(0,ue.jsxs)(v.T,{weight:"semibold",children:["Signed in as ",Se.name]}),(0,ue.jsx)(v.Muted,{children:(0,$.levelJob)(Se.level??L.ROLE_LABEL[Se.role],Se.job)})]})]}):(0,ue.jsxs)(R.default,{style:{gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,ue.jsx)(v.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,ue.jsx)(N.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!Se?null:(0,ue.jsx)(v.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,$.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,ue.jsx)(v.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!Se||(0,_.clampRole)(e,Se.ownerAccess?'owner':Se.managerAccess?'manager':Se.role)===e).map(e=>(0,ue.jsx)(v.Button,{kind:e===de?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),Oe(!1)}},e))]})})}),(0,ue.jsx)(W.OnboardingHost,{go:De}),(0,ue.jsx)(V.CoachHost,{})]})}},1416,[5,828,987,1210,1236,1224,1055,979,1056,2,1061,1062,1094,1115,34,373,395,402,295,426,102,36,794,873,874,891,821,1417,1201,1088,925,1426,1004,236,1435,13,872,1467,1473,1474,1475,1207,1255,1476,1459,1477,1479,1457,1180,1493,1157,1238,1388,1240,1253,1481,1112,1114,1223,1546,1547,1566,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1417,[5,1418,1123,11,1419,827,837,1140,1141,1119,1143,1420,1138,1142,1404,1405,1088,1349,1027,1117,14,1144,1422,1249,1423,1393,1107,1101,1118,34,102,794,1362,874,861,867,858,1332,821,1201,1126,1029,1424,1087,1181,1425,1240,987,1203,1401,878,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1418,[34,794,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1419,[6,34,102,794,987,1280,25]); +__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[34,402,102,1421,987,933,821,794,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[827,5,34,379,236,102,794,876,14,867,1032,933,821,1204,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[34,402,1189,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1424,[34,102,874,1029,794,821,25]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1425,[34,102,879,874,864,821,794,25]); +__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1426,[5,1427,1428,1429,1430,1431,34,236,41,102,872,1432,1004,821,1434,794,987,2,1097,1003,891,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1427,[34,102,873,794,5,6,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1428,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1429,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1430,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1431,[34,102,873,794,25]); +__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1432,[34,295,102,794,873,821,1433,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1433,[]); +__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1434,[929,828,34,1097,336,236,402,295,41,102,872,926,891,831,987,1004,15,793,821,925,794,25]); +__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.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:b,now:F,role:oe,me:ae,today:ne}=(0,A.useCtx)(5e3),ie=(0,p.useOrders)(n),re=(0,p.useBookings)(n),de=(0,p.useWaitlist)(n),ue=(0,p.useEvents)(n),ge=(0,p.useRatings)(n),xe=(0,k.useOwner)(e=>e.staff),ye=(0,k.useOwner)(e=>(0,k.liveAttendance)(e.attendance)),be=(0,k.useOwner)(e=>e.shifts),fe=(0,L.useRealHistory)(n,F),me=(0,o.useMemo)(()=>(0,t.forecastToday)(b,re,ie,ue,F,fe??void 0),[b,re,ie,ue,fe,F.getTime()/6e4|0]),je=(0,N.useExamples)(),pe=(0,P.useCashUp)(e=>e.cashUps),ke=re.filter(e=>e.date===ne),we=ie.filter(D.LIVE),$e=de.filter(e=>'waiting'===e.status||'notified'===e.status),ve=ke.filter(e=>['seated','finished'].includes((0,I.shownStatus)(e))).reduce((e,s)=>e+s.partySize,0),Ce=(0,te.coversSplit)(ke,ne),Ie=Ce.walkIns,Te=Ce.bookings,Be=we.filter(e=>(0,q.chainNeedsAction)(e,re)),De=ke.filter(e=>['confirmed','seated'].includes(e.status)&&(0,q.bookingNeedsAction)(e,we)),Ae=we.flatMap(e=>(0,v.readinessFor)(e,b,F).map(s=>({...s,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Se=me.nextHour,Le=(0,D.busyLevel)(Se?.coversHigh??0,me.busy.busy),Ne=(0,D.restOfDayLevel)(me,b),Pe=ie.filter(e=>e.paid>0&&!!e.createdAt&&(0,C.ymd)(new Date(e.createdAt))===ne).reduce((e,s)=>e+s.paid,0),Me=(0,H.tradingDay)(F),Fe=je?(0,S.revenueHistory)(b,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Oe=je?{today:186e3+Pe,last:Fe?{date:(0,C.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,W.takingsToday)(pe,n,Me,Pe),Re=k.CAN.takings(oe)&&(!(0,R.isLive)()||(0,R.can)('takings.view')),He=(0,o.useMemo)(()=>(0,S.insights)(b,re,ie,ue,ge,F,ve),[b.id,re.length,ge.length,ve]),We=((0,A.weekday)(F),ye.filter(e=>e.date===ne&&e.in&&!e.out)),Ee=(0,J.useFrontDoor)(ne),ze=(0,h.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,r.useTravelDay)('owner',ne),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,M.canSeeMonthTakings)(oe,qe,{inStaffApp:Ye,live:(0,R.isLive)()}),Qe=(0,O.homeSetupNagsHidden)(n),Ve=(0,k.useOwner)(e=>e.socialPosts.reduce((e,s)=>e+('awaiting approval'===s.status?1:0),0)),[Xe,Ze]=(0,o.useState)(!1),Je=ae.replace(' (example)',''),es=k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(r.DayView,{rid:n,day:Ue,today:ne,app:"owner"})]}):a?(0,le.jsxs)(m.default,{style:{gap:12},testID:"owner-home",children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Re&&Oe.show?(0,le.jsx)(j.Row,{wrap:!0,gap:10,children:(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})})}):null,(0,le.jsx)(X.TodaysTipsCard,{rid:n,today:ne}),(0,le.jsx)(X.TipsPotCard,{rid:n,today:ne}),k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),qe&&'owner'!==qe.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,le.jsx)(V.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,Z.shiftNow)(qe.id,Date.now()).on}):null,k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]}):(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,Re&&Oe.show?(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=de,_e.MonthTakingsCard=ce,_e.WalkInSplitCard=he;var s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),o=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),y=_r(_d[12]),b=e(_r(_d[13])),f=e(_r(_d[14])),m=e(_r(_d[15])),j=_r(_d[16]),p=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),I=_r(_d[23]),T=_r(_d[24]),B=_r(_d[25]),D=_r(_d[26]),A=_r(_d[27]),S=_r(_d[28]),L=_r(_d[29]),N=_r(_d[30]),P=_r(_d[31]),M=_r(_d[32]),F=_r(_d[33]),O=_r(_d[34]),R=_r(_d[35]),H=_r(_d[36]),W=_r(_d[37]),E=_r(_d[38]),z=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),q=_r(_d[42]),Y=_r(_d[43]),_=_r(_d[44]),K=_r(_d[45]),Q=_r(_d[46]),V=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),se=_r(_d[52]),te=_r(_d[53]),le=_r(_d[54]);const oe=18,ae=18,ne=150,ie=34;function re(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const s=e.length,t=[],l=[];for(let l=0;l9){const n=3/Math.sqrt(a);l[e]=n*s*t[e],l[e+1]=n*o*t[e]}}let o=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let t=0;toe+(s-1)/Math.max(1,e-1)*t,o=[1,5,10,15,20,25].filter(s=>s=36)&&a.push(e);for(;a.length&&l(e)-l(a[a.length-1])<36;)a.pop();return[...a,e]}function ce({rid:e,today:s}){const t=(0,P.useCashUp)(e=>e.cashUps),[l,i]=(0,o.useState)(s.slice(0,7)),[r,d]=(0,o.useState)(0),[c,u]=(0,o.useState)(null),h=(0,o.useMemo)(()=>(0,M.monthTakings)(t,e,l,s),[t,e,l,s]),x=(0,o.useMemo)(()=>(0,M.firstTakingsMonth)(t,e),[t,e]),y=!!x&&xoe+(e-1)/Math.max(1,k-1)*w,I=e=>$-e/v*128,T=[];h.days.forEach((e,s)=>{if('recorded'!==e.state)return;const t={x:C(e.day),y:I(e.value)};s&&'recorded'===h.days[s-1].state?T[T.length-1].push(t):T.push([t])});const D=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),S=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===s):void 0)??A??D[D.length-1],L=e=>{const s=D.findIndex(e=>e.date===S?.date),t=D[Math.max(0,Math.min(D.length-1,s+e))];t&&(u(t.date),b.default.announceForAccessibility?.(N(t)))},N=e=>`${(0,M.longDay)(e.date)}, ${'recorded'===e.state?(0,M.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,O=h.current?`so far in ${h.month}`:`in ${h.month} ${l.slice(0,4)}`,R=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,M.monthName)((0,M.addMonths)(l,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,H=h.recorded?`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. ${(0,M.poundsWhole)(h.total)} ${O}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,M.longDay)(h.best.date)}, ${(0,M.poundsWhole)(h.best.value)}.${R?` ${R.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,W=r?de(k,r):[],E=(e,s,t,o,a)=>(0,le.jsx)(f.default,{testID:a,accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{disabled:!t},disabled:!t,onPress:()=>{i((0,M.addMonths)(l,o)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:t?e?.6:1:.25}),children:(0,le.jsx)(j.T,{size:24,colour:B.colours.gold,center:!0,children:e})});return(0,le.jsx)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(m.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),y||p?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[E('\u2039',`Previous month, ${(0,M.monthName)((0,M.addMonths)(l,-1))}`,y,-1,'mt-prev'),(0,le.jsxs)(j.T,{center:!0,colour:B.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",l.slice(0,4)]}),E('\u203a',`Next month, ${(0,M.monthName)((0,M.addMonths)(l,1))}`,p,1,'mt-next')]}):null,(0,le.jsx)(m.default,{accessible:!0,accessibilityLabel:H,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(j.T,{size:38,weight:"bold",colour:B.colours.gold,center:!0,testID:"mt-total",children:(0,M.poundsWhole)(h.total)}),(0,le.jsx)(j.T,{center:!0,colour:B.colours.goldLight,children:O}),(0,le.jsxs)(j.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,M.shortDay)(h.best.date)," \xb7 ",(0,M.poundsWhole)(h.best.value)]}),R?(0,le.jsx)(j.Muted,{center:!0,testID:"mt-vs",children:R}):null]}):(0,le.jsx)(j.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(m.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(m.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ne,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ne,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:oe,y1:$,x2:r-ae,y2:$,stroke:B.colours.hairline,strokeWidth:1}),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:`${re(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${s}`)),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:re(e),stroke:B.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${s}`)),T.filter(e=>1===e.length).map((e,s)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:B.colours.gold},`s${s}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:C(e.day),cy:$,r:2,fill:"none",stroke:B.colours.muted,strokeWidth:1},e.date)),S&&'recorded'===S.state?(0,le.jsx)(a.Line,{x1:C(S.day),y1:10,x2:C(S.day),y2:$,stroke:B.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===s);return(0,le.jsx)(a.Circle,{cx:C(e.day),cy:'recorded'===e.state?I(e.value):$,r:4.5,fill:B.colours.gold,stroke:B.colours.surface,strokeWidth:1.5})})():null,S&&'recorded'===S.state&&S.date!==s?(0,le.jsx)(a.Circle,{cx:C(S.day),cy:I(S.value),r:5,fill:B.colours.surface,stroke:B.colours.gold,strokeWidth:2}):null]}):null,r?D.map(e=>(0,le.jsx)(f.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:N(e),accessibilityState:{selected:S?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ne,left:C(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(m.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:W.map(e=>(0,le.jsx)(j.T,{size:F.AXIS_FONT,colour:B.colours.muted,style:{position:'absolute',left:C(e)-17,width:ie,top:0,textAlign:'center'},children:String(e)},e))})]}),S&&D.length?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(f.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:D[0]?.date===S.date,onPress:()=>L(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[0]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(m.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:N(S),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(j.Muted,{center:!0,children:S.date===s?`Today \xb7 ${(0,M.shortDay)(S.date)}`:(0,M.shortDay)(S.date)}),(0,le.jsx)(j.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===S.state?B.colours.goldLight:B.colours.muted,children:'recorded'===S.state?(0,M.poundsWhole)(S.value):'pending'===S.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(f.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:D[D.length-1]?.date===S.date,onPress:()=>L(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[D.length-1]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(j.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ue='#3A2F1E';function he({split:e}){return(0,le.jsx)(j.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(m.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(j.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(m.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",colour:B.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(m.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ue,borderWidth:1,borderColor:B.colours.gold},children:[(0,le.jsx)(m.default,{style:{width:`${e.walkInPct}%`,backgroundColor:B.colours.gold}}),(0,le.jsx)(m.default,{style:{flex:1,backgroundColor:ue}})]})]})]})})}},1435,[860,1161,1436,34,797,1099,1202,1103,1104,1423,1349,877,1107,281,402,102,794,874,891,1210,861,1179,858,1101,881,821,1201,1088,1160,1166,1167,1039,13,1171,927,987,1000,1445,1446,1170,1447,1181,869,1450,1205,1224,1223,1061,1062,1094,1126,1393,1174,1348,25]); +__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.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:z}=(0,R.useCtx)(6e4),V=z.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsxs)(j.Muted,{size:12,children:["Uses: ",e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')," from the counted stock. Held from the Display count and shown as \u201cReserved\u201d."]})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),De=J.hourOverrides??[],Re=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:D.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),Re?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:Re}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!Re,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),De.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:De.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...De.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),ze=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,$e]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{$e(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From a party of"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from party size"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:D.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)($.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:ze,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:D.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:D.colours.accentBorder,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:D.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:D.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,R.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:D.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:D.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:D.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),D=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),z=_r(_d[31]),I=_r(_d[32]),$=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:D.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?D.colours.red:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:D.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:D.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:D.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:D.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,z.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:D.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1436,[1162,1063,5,1418,827,1437,1438,1440,1441,1442,1220,1061,1062,1039,1044,34,402,102,794,14,1443,831,878,1101,877,821,1088,874,1204,1009,1010,891,1444,1388,1029,1111,1036,1164,980,25]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1437,[827,34,102,794,1161,877,821,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1438,[860,34,236,102,794,874,1029,1175,1271,987,1344,1439,25]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1439,[860,1295]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1440,[34,102,794,1029,1353,821,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1441,[34,102,794,1029,858,1396,5,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1442,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1443,[34,1063,102,821,794,1268,1271,25]); +__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1444,[34,102,794,1029,1366,821,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1445,[]); +__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},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])},1446,[34,402,102,794,821,1170,1445,25]); +__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1447,[927,796,831,828,837,878,1076,1448,34,994,336,379,236,402,102,794,874,891,858,821,1201,1088,1230,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1448,[499,1449]); +__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 t={}},1449,[]); +__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.ProgressBar=D,_e.useSetupDone=O,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,C.useCtx)(6e4),n=O(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=f.SETUP_STEPS.findIndex(e=>e.id===a),s=f.SETUP_STEPS[e+1]?.id??null;return(0,E.jsx)(L,{id:a,wizard:!0,onBack:()=>l(e>0?f.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=f.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,E.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{gap:12,children:[(0,E.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(m.T,{size:20,weight:"bold",colour:S.colours.gold,children:["Set up ",t.name]}),(0,E.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,E.jsx)(D,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,E.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,E.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:S.colours.border,backgroundColor:S.colours.surface,overflow:'hidden'},children:f.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,E.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:S.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,E.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?S.colours.gold:'transparent',borderWidth:1.5,borderColor:t?S.colours.gold:S.colours.border},children:(0,E.jsx)(m.T,{weight:"bold",colour:t?S.colours.onGold:S.colours.muted,children:t?'\u2713':s+1})}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"medium",children:e.title}),(0,E.jsx)(m.Muted,{children:e.sub}),o.length?(0,E.jsxs)(m.T,{size:13,colour:S.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,E.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=L,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return W}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,C.useCtx)(6e4),t=O(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,E.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:"Finish setting up"}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]}),(0,E.jsx)(D,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,E.jsxs)(m.Muted,{size:13,children:["Next: ",f.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]);const M=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],R=[1,2,3,4,5,6,0],I=/^([01]\d|2[0-3]):[0-5]\d$/,$=e=>{const s=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(s)&&s>0?Math.round(100*s):null},B=e=>f.SETUP_STEPS.findIndex(s=>s.id===e)+1;function D({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,E.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,E.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:S.colours.gold,borderRadius:5}})}),(0,E.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function O(e){const s=(0,f.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=f.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:f.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function L({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,C.useCtx)(6e4),l=O(a),r=l.prog,d=(0,i.useLiveVenue)(),u=f.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=_[e];return(0,E.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(m.T,{size:12,weight:"semibold",colour:S.colours.gold,children:["STEP ",B(e)," OF ",f.SETUP_STEPS.length]}),s&&o?(0,E.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,E.jsx)(m.T,{size:13,colour:S.colours.muted,children:"All steps"})}):null]}),(0,E.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,E.jsx)(D,{done:r.done,total:r.total})]}),(0,E.jsx)(b,{rid:a,done:(t="Saved.")=>{f.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,E.jsx)(m.Banner,{kind:"success",title:p}):null,(0,E.jsx)(N,{rid:a,id:e,title:u.title,onDone:x}),s?(0,E.jsxs)(m.Row,{gap:10,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,E.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const A=({wizard:e,onPress:s,disabled:t,label:n})=>(0,E.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const F=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function U({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,C.useHourly)(),d=(0,f.useSiteSetup)(e),u=(0,f.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,w.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,f.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),T(null)},z=!!p?.id&&(M=p.id,k.ROSTER.some(e=>e.id===M));var M;const R=p?$(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=R||z&&!p.wage);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,E.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,E.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?S.colours.gold:S.colours.border,backgroundColor:s?'#1d1a14':S.colours.surface}),children:[(0,E.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"semibold",children:e.name}),(0,E.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,f.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,E.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,f.accessOf)(e.level,e.role)})]},e.id))}),y?(0,E.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:S.colours.gold},children:(0,E.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,E.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,E.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,E.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,E.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,E.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Access level"}),(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:f.ACCESS_LEVELS.map(e=>(0,E.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,E.jsxs)(m.Muted,{size:13,children:["Uses the ",f.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Pay"}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,E.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,E.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,E.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,E.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,w.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,E.jsx)(m.Field,{label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=R&&R<1271?(0,E.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,E.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,E.jsxs)(m.Row,{gap:8,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,E.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),f.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:f.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=R&&s.setRate(t,R);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),f.useSetup.getState().patch(e,{staffGrade:o}),f.useSetup.getState().setLook(t,p.look),T(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,E.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,E.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(F(d.grades[0]?.id??'')),T(null)}}),(0,E.jsx)(A,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const _={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,f.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,E.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,E.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,E.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,E.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':'anchorage'===e?'The Anchorage logo in black and gold.':'greenside'===e?'The Greenside Restaurant logo.':'abbotsford'===e?'The Abbotsford Hotel logo.':'kirkton'===e?'The Kirkton Inn logo.':'wildings'===e?'The Wildings Hotel & Restaurant logo.':'kirkmichael'===e?'The Kirkmichael Arms logo.':'souters'===e?'The Souter\u2019s Inn logo.':'Placeholder initials.'," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,E.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,E.jsx)(P.OrderAtTableCard,{rid:e,compact:!0}),u?(0,E.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,E.jsx)(A,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,C.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=R.filter(e=>{const s=n[e];return s&&(!I.test(s[0])||!I.test(s[1]))});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),M.map((e,s)=>{const t=R[s],l=n[t];return(0,E.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:S.colours.border,paddingTop:s?6:0},children:[(0,E.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,E.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"to"}),(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,E.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,E.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries(R.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,E.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,E.jsx)(A,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,y.usePlan)(e),o=(0,y.planCounts)(n);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.TablePlan,{startStep:"areas"}),(0,E.jsx)(A,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,E.jsx)(U,{...e,payList:!0})]})},staff:U,permissions:function({done:e,wizard:s}){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(z.PermissionsScreen,{}),(0,E.jsx)(A,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,f.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,E.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,E.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,E.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,E.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,E.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,E.jsx)(A,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),a=(0,f.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,T.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,E.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,E.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:S.colours.border,padding:10},children:(0,E.jsx)(m.T,{size:14,colour:S.colours.goldLight,children:i})}),(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,T.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,E.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,E.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,E.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,E.jsx)(A,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),f.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,C.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,E.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,E.jsx)(A,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},W=e=>function(){return(0,E.jsx)(L,{id:e})};function N({rid:e,id:s,title:t,onDone:n}){const o=O(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,E.jsxs)(g.default,{style:{gap:4},children:[(0,E.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),f.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,E.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,E.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1450,[929,928,828,827,1076,1451,1452,1453,1454,1456,34,402,102,873,925,794,874,891,1029,927,15,867,821,1088,1457,1460,1464,1465,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1451,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1452,[34,987]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1453,[34,846,987]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1454,[2,827,34,236,383,102,794,1455,987,821,1205,1004,891,994,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1455,[]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1456,[34,402,794,987,821,1454,25]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1457,[827,979,1161,987,797,1238,1240,34,281,379,236,402,102,426,879,794,874,1249,891,867,858,821,1201,1088,869,1447,1180,1458,1459,1160,1167,1166,1039,13,1164,1170,1230,25]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1458,[827,34,1236,1056,870,379,402,102,794,891,867,858,821,1201,1088,1230,25]); +__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1459,[1016,34,402,102,794,891,821,1088,987,25]); +__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1460,[827,34,1048,395,102,1134,1135,1364,1393,794,1026,1029,858,821,1088,1030,1461,1462,1050,25]); +__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1461,[827,34,402,102,794,821,1029,5,1030,872,987,25]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1462,[34,102,794,1029,1463,859,821,1075,933,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1463,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1464,[5,1418,34,102,794,874,891,25]); +__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.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1465,[34,281,402,102,794,821,1000,1466,25]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1466,[933,987,891,872,1000]); +__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.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=M,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=M(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',O[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:O[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withWildingsQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function M(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const O={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from Bidfood or Booker? Add them here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1467,[832,1207,34,281,283,364,395,236,295,102,36,794,873,876,891,1029,1066,1067,5,859,1064,1074,821,872,1088,1468,1471,25]); +__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.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1468,[827,34,379,402,295,102,794,1469,1470,821,1467,1088,891,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1469,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1470,[839,846,849]); +__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.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1471,[34,402,102,794,876,1470,1029,859,1472,1074,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1472,[]); +__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1473,[828,34,283,364,236,402,102,846,794,821,25]); +__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1474,[1202,1099,1140,1117,34,402,102,794,891,858,821,1118,1188,1088,1199,1447,1181,876,1203,869,1201,925,1424,1029,860,1126,1218,1222,1098,25]); +__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.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1475,[34,1101,102,426,794,874,1163,1161,877,858,821,891,1201,1088,1170,1166,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1476,[846]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,x]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),B=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),v=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=v.filter(e=>'due'===e.state||'overdue'===e.state),$=v.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,y.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,y.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,y.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),B.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,B.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&x(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),x=_r(d[13]),y=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),B=_r(d[22]),v=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),y=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,v]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,F]=(0,r.useState)(''),[_,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,x.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(y.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,B.ukPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,B.emailOk)(_),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(y.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:v,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:F,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:_,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),y.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:_.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),x=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,v.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,v.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,y.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,y.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,y.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:x,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1477,[5,1418,860,1388,34,102,794,874,876,881,861,867,1179,1131,858,821,1201,1088,1180,1181,869,1425,864,988,1478,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1478,[34,102,794,874,867,987,821,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return pe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),b=_r(d[9]),h=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),E=_r(d[18]),N=_r(d[19]),P=_r(d[20]),W=_r(d[21]),A=_r(d[22]),R=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),G=_r(d[27]),B=(e=G)&&e.__esModule?e:{default:e},x=_r(d[28]),D=_r(d[29]),I=_r(d[30]),L=_r(d[31]),H=_r(d[32]),_=_r(d[33]),F=_r(d[34]),V=_r(d[35]),Q=_r(d[36]),q=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),K=_r(d[41]),z=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),ae=_r(d[49]),se=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),de=_r(d[55]),ue=_r(d[56]),le=_r(d[57]),ge=_r(d[58]),ce=_r(d[59]);const pe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},be=e=>n.CAN.manage(e);(0,y.register)([{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>be(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:be,C:R.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:w.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:be,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>be(e)&&!r.IS_CAR,badge:'NEW',C:P.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:be,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:be,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',badge:'NEW',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:be,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:be,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:be,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:be,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:b.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:be,badge:'NEW',C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:h.PLAN_SUB,group:'Account',can:n.CAN.billing,C:h.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',badge:'NEW',C:T.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',badge:'NEW',C:W.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:W.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',badge:'NEW',can:be,C:A.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:W.Timesheets}]),(0,y.register)([{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:M.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:M.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',badge:'NEW',can:be,C:E.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',badge:'NEW',can:be,C:N.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'Photo of the cash up sheet, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',badge:'NEW',can:be,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:M.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:M.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:M.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:be,C:M.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:be,C:M.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:be,C:M.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:be,C:M.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:be,C:M.ReviewEmailSettings},{id:'compliance',title:'Daily checks & allergen log',sub:'Fridge temps, opening checks, audit log',group:'Compliance',C:M.Compliance},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:M.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:be,badge:'NEW',C:M.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:M.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:O.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>pe(),C:O.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:be,C:O.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:be,C:O.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:O.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:be,C:O.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:be,C:O.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:be,C:O.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:be,C:O.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:O.TabletPreview}]);const he=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',badge:'NEW',C:()=>B.default.createElement(D.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:x.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',badge:'NEW',can:he,C:x.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',badge:'NEW',can:he,C:D.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',badge:'NEW',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:I.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',badge:'NEW',C:L.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:be,C:L.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:be,badge:'NEW',C:L.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:be,badge:'NEW',C:H.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:be,badge:'NEW',C:H.DisplaySettingsPage}]);const fe=e=>'owner'===e||'manager'===e;_.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:fe,badge:'NEW',C:_.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off, voice, connected services',group:'Account',can:fe,C:_.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',badge:'NEW',can:e=>'owner'===e&&!r.IS_CAR,C:V.CarScreen}]);const ye=e=>'owner'===e||'manager'===e,me=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Ce=e=>ye(e)&&me();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ye,badge:'NEW',C:F.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Prices},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning, allergen checks; filters; CSV and print for the EHO',group:'Compliance',can:ye,badge:'NEW',C:F.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ye,badge:'NEW',C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',badge:'NEW',C:F.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:be,badge:'NEW',C:Q.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:be,badge:'NEW',C:Q.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:be,badge:'NEW',C:Q.Outbox}]);const Se=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Se,badge:'NEW',C:U.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Se,badge:'NEW',C:q.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Se,badge:'NEW',C:Y.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Se,badge:'NEW',C:j.OrderSheetSettings},...K.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Se,C:(0,q.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Se,badge:'NEW',C:z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Se,badge:'NEW',C:$.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:be,badge:'NEW',C:$.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Se,badge:'NEW',C:$.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Se,badge:'NEW',C:J.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:be,badge:'NEW',C:X.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:be,badge:'NEW',C:X.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:be,badge:'NEW',C:X.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:be,badge:'NEW',C:Z.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:be,badge:'NEW',C:ee.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:be,badge:'NEW',C:ae.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, Booker and Bidfood lists, offers, events and specials the voice helper prepared; nothing is sent',group:'Run the day',can:be,badge:'NEW',C:se.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift, left by voice or typing',group:'Run the day',badge:'NEW',C:se.ShiftNotesPage},{id:'voice',title:'Voice helper',sub:'Hold-to-talk input, text-only replies, who gets it and microphone privacy',group:'Settings',can:be,badge:'NEW',C:se.VoiceSettingsPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ie.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update',group:'Compliance',can:ye,badge:'NEW',C:function(){return B.default.createElement(re.FoodSafetyCard,null)}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ne.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ye,badge:'NEW',C:function(){const{rid:e,today:t}=(0,oe.useCtx)(6e4);return B.default.createElement(ne.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',badge:'NEW',C:function(){const{rid:e,me:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:be,badge:'NEW',C:te.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',badge:'NEW',C:function(){const{me:e,role:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(ue.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:be,C:le.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:be,C:ge.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,badge:'NEW',C:ce.UseOnComputerPage}])},1479,[837,1086,872,1480,891,1004,994,831,881,1482,1489,1499,1459,1500,1501,1503,1504,1475,1505,1506,1508,1219,1210,1477,1509,1457,1510,34,1218,1199,1458,1447,1460,1493,1515,1516,1517,1450,1436,1464,1518,927,1519,1520,1522,1205,1467,1523,1388,1468,1535,1108,1111,1088,1220,1174,1536,1539,1542,1545]); +__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,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return k}}),_e.DashCorners=I,_e.ServiceBoard=function(){const{role:e}=(0,j.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,D.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,D.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,D.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,D.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,D.jsx)(I,{onLeave:y}),(0,D.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,D.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,D.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,D.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,D.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,D.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?w((0,D.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]),D=r(d[16]);const k=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function C({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,D.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,D.jsxs)(s.default,{children:[(0,D.jsx)(p.Icon,{name:t,colour:h.colours.gold}),u?(0,D.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,D.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function I({onLeave:e}){const t=(0,x.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>y.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,D.jsx)(C,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,D.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,D.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:k.filter(e=>'left'===e.side).map(n)}),(0,D.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[k.filter(e=>'right'===e.side).map(n),(0,D.jsx)(C,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')}),(0,D.jsx)(f.VoiceSlot,{size:44,layer:1})]})]})}function w(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[17]);return t(e,document.body)}},1480,[34,395,236,402,102,36,794,1056,1346,891,821,1157,1481,1207,1476,1088,25,277]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1481,[846]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, take a picture of the taking sheet and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1482,[827,1456,34,867,102,794,891,821,1088,925,926,1483,987,1001,1061,1454,1484,1485,1487,1027,1488,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1483,[]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1484,[827,34,102,794,821,891,1398,1408,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1485,[34,102,794,1486,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1486,[846,933,987,2]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1487,[34,102,794,821,999,1052,987,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1488,[933,987]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_VOICE_LINE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_SUPPLIER_LINE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DONE_FOR_YOU",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"doneForYouLine",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return v}}),_e.PlanBilling=function(){const{now:e,role:n,rid:b}=(0,p.useCtx)(6e4),j=(0,c.trialStatus)((0,l.defaultSimStart)(),e),[x,w]=(0,s.useState)(!1);return u.CAN.billing(n)?x?(0,y.jsx)(M,{onBack:()=>w(!1)}):(0,y.jsxs)(i.default,{style:{gap:10},children:[(0,y.jsx)(o.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,y.jsx)(t.VoiceUsageCard,{rid:b,now:e}),(0,y.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,y.jsxs)(i.default,{testID:"plan-founding",children:[(0,y.jsx)(o.T,{size:12,weight:"semibold",colour:h.colours.goldMuted,children:"FOUNDING OFFER \xb7 FIRST 50 VENUES"}),(0,y.jsxs)(o.T,{size:30,weight:"bold",children:["\xa349",(0,y.jsx)(o.T,{size:14,colour:h.colours.muted,children:" a month + VAT if applicable, per venue"})]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,y.jsx)(o.Badge,{kind:"gold",label:"Every Full Restaurant Pro feature"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"One month free"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"\xa349 net locked in"})]}),(0,y.jsx)(o.Muted,{children:"Early adopter price for the first 50 venues: every Full Restaurant Pro App feature, including the owner's dashboard and admin and the voice Assistant. \xa349 net stays locked in while your subscription stays active."}),(0,y.jsxs)(o.T,{size:13,testID:"plan-early-done-for-you",children:["\u2713 ",T(P.early)]}),(0,y.jsx)(o.Muted,{children:"From venue 51, usual prices:"}),(0,y.jsxs)(i.default,{testID:"plan-usual-lite",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[k," \xb7 ",C," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:S}),O.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e)),(0,y.jsx)(o.T,{size:13,testID:"plan-lite-not-included",children:"Not included: the owner's dashboard and admin, or the voice Assistant."})]}),(0,y.jsxs)(i.default,{testID:"plan-usual-pro",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[_," \xb7 ",L," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:v}),R.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e))]}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>w(!0),style:{marginTop:6}})]}),(0,y.jsx)(o.Card,{children:(0,y.jsxs)(i.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,y.jsx)(o.T,{weight:"bold",colour:h.colours.gold,children:"free"}),"."]}),(0,y.jsx)(o.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,y.jsx)(o.Muted,{children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, and subscribers get free lifetime 24/7 customer support. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{children:"Free trial"}),(0,y.jsxs)(o.T,{weight:"bold",colour:h.colours.gold,children:[j.daysLeft," day",1===j.daysLeft?'':'s'," left"]})]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(100*(1-j.daysLeft/j.total))}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),(0,y.jsxs)(o.Muted,{children:["Then \xa3",c.PLAN.monthlyPence/100," a month + VAT if applicable. The trial start date is not set up yet."]})]}),(0,y.jsx)(f.AssistantPlanCard,{}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{weight:"semibold",children:"Free lifetime customer support"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"Included"})]}),(0,y.jsx)(o.Muted,{children:"Free for as long as you subscribe, day or night. Setup is all done digitally. Support contact details: not set up yet."})]})]}):(0,y.jsx)(o.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),i=(e=n)&&e.__esModule?e:{default:e},o=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]);const b=!0,j='Founding offer, free trial, set-up guide',x='. The owner\'s dashboard and admin come with Full Restaurant Pro App (\xa399 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',w='Voice Assistant (hold to talk) for seating guests, marking tables as cleared, temperature logs and finding something in the app: fair usage 1,000 voice tasks a month per venue',A='Supplier links: open your suppliers\' ordering sites and keep order lists',P={lite:1,pro:3,early:3},T=e=>`${e} done-for-you ${1===e?'change':'changes'} a month`,k='Customer & Takeaway App',_='Full Restaurant Pro App',C='\xa349',L='\xa399',S='A lite version of CoverCharge: 3 core customer and takeaway functions tailored to you, set up digitally with the in-app guided setup and step-by-step guides, free lifetime 24/7 customer support while subscribed, and unlimited self-edits of your basic info. The owner\'s dashboard and admin, and the voice Assistant, are not included.',v='Every feature, every app, including the owner\'s dashboard and admin and the voice Assistant. Set up digitally with the in-app guided setup and step-by-step guides, the Assistant (fair use 300 tasks a month), free lifetime 24/7 customer support while subscribed, and unlimited self-edits.',O=['Customer app: menu, allergens, bookings and loyalty','Takeaway ordering','Set up digitally: in-app guided setup and step-by-step guides','Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits of your basic info',T(P.lite)],R=['Every feature, every app','The owner\'s dashboard and admin',A,'Set up digitally: in-app guided setup and step-by-step guides','The Assistant, fair use 300 tasks a month',w,'Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits',T(P.pro)],I=[['Choose your 3 core functions','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function M({onBack:e}){const[t,n]=(0,s.useState)([]);return(0,y.jsxs)(i.default,{style:{gap:10},testID:"setup-guide",children:[(0,y.jsx)(o.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,y.jsx)(o.H2,{children:"Set-up guide"}),(0,y.jsxs)(o.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",t.length," of ",I.length," done."]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(t.length/I.length*100)}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),I.map(([e,s],l)=>{const u=t.includes(l);return(0,y.jsx)(o.Card,{children:(0,y.jsxs)(o.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,y.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:u?h.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(o.T,{size:14,weight:"bold",colour:u?'#1a1610':h.colours.gold,children:u?'\u2713':String(l+1)})}),(0,y.jsxs)(i.default,{style:{flex:1,gap:4},children:[(0,y.jsx)(o.T,{weight:"semibold",children:e}),(0,y.jsx)(o.Muted,{children:s}),(0,y.jsx)(o.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>n(u?t.filter(e=>e!==l):[...t,l])})]})]})},e)}),(0,y.jsx)(o.Muted,{children:"Stuck? Free lifetime customer support is included while you subscribe. Ticks on this guide are not saved."})]})}},1489,[1490,34,102,794,850,891,1492,821,1088,1493,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1490,[34,102,794,821,1491,25]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1491,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1492,[]); +__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,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return v}}),_e.AssistantFab=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)(e=>e.enabled);return R(e)&&t?(0,A.jsxs)(c.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>v.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:k.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,A.jsx)(M,{size:22}),(0,A.jsx)(b.T,{weight:"bold",colour:I,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=v(e=>e.open),o=()=>v.getState().setOpen(!1),{rid:a,role:p,me:C}=(0,w.useCtx)(3e4),S=(0,j.useAssistant)(),I=B(),[E,L]=(0,r.useState)([]),[W,z]=(0,r.useState)(''),[$,_]=(0,r.useState)(!1),N=(0,r.useRef)(null),F=(0,r.useRef)(null);if((0,r.useEffect)(()=>{setTimeout(()=>N.current?.scrollToEnd?.({animated:!0}),50)},[E.length]),!e||!R(p))return null;const H=(e,t,s)=>j.useAssistant.getState().record({at:(new Date).toISOString(),by:C,role:p,asked:e,action:t,outcome:s}),U=(e,t="result")=>L(s=>[...s,{id:D(),from:'assistant',text:e,kind:t}]),V=async e=>{const t=e.trim();if(!t)return;let s;z(''),L(e=>[...e,{id:D(),from:'you',text:t}]);try{s=await(0,y.getProvider)('xai').interpret(t,I)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&H(t,'\u2014','not understood'),L(e=>[...e,{id:D(),from:'assistant',proposal:s,state:'open',asked:t}])},G=(e,t)=>L(s=>s.map(s=>s.id===e?{...s,state:t}:s)),q=async(e,t,n)=>{if(G(e.id,'confirmed'),'external'===t.kind)return H(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void U(T,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await m.repo.bookings.seatWalkIn(a,Number(o.party),s,'Added by Assistant'),s&&(0,f.resetTableLive)(a,s),U(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),H(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),U(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),H(e.asked,t.title,'done');break;case'price':await m.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),U(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),H(e.asked,t.title,'done');break;case'offer':x.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),U(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),H(e.asked,t.title,'done');break;case'rota':case'bookings':U(String(o.result)),H(e.asked,t.title,'looked up')}},Y=e=>{G(e.id,'cancelled'),H(e.asked,e.proposal?.title??'\u2014','cancelled'),U('Cancelled. Nothing was changed.','note')},K='lite'===S.tier,J=(0,j.tasksUsed)(S);return(0,A.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,A.jsx)(h.default,{style:[b.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,A.jsxs)(h.default,{testID:"assistant-sheet",style:{backgroundColor:k.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:k.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.Row,{gap:8,style:{flex:1},children:[(0,A.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:18})}),(0,A.jsx)(b.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,A.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,A.jsx)(h.default,{testID:"assistant-demo-badge",children:(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),K?(0,A.jsxs)(h.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,A.jsx)(b.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,A.jsx)(b.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(u.default,{ref:N,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===E.length?(0,A.jsxs)(h.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,A.jsxs)(b.T,{children:["Hi ",C.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,A.jsx)(b.Muted,{children:"Try:"}),y.SUGGESTED_PROMPTS.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:k.colours.surface2},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]}):null,E.map(e=>'you'===e.from?(0,A.jsx)(h.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,A.jsx)(b.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,A.jsx)(P,{m:e,onConfirm:(t,s)=>q(e,t,s),onCancel:()=>Y(e)},e.id):'choose'===e.proposal.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),(0,A.jsx)(b.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>V(e.prompt)},e.label))})]},e.id):(0,A.jsxs)(h.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:8},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]},e.id):(0,A.jsx)(h.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?k.colours.amberBg:k.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:k.colours.amber},children:(0,A.jsx)(b.T,{children:e.text})},e.id))]}),(0,A.jsxs)(b.Row,{gap:8,children:[(0,A.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:W,onChangeText:z,onSubmitEditing:()=>V(W),returnKeyType:"send",style:[b.styles.input,{flex:1,minWidth:0,width:40}]}),S.voice?(0,A.jsx)(c.default,{testID:"assistant-mic",accessibilityRole:"button",accessibilityLabel:$?'Stop listening':'Speak',onPress:()=>{const e=O();if(e)if($)F.current?.stop?.();else try{const t=new e;F.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&z(t)},t.onend=()=>_(!1),t.onerror=()=>{_(!1),U("Sorry, I didn't catch that. You can type instead.",'note')},_(!0),t.start()}catch{_(!1),U("Voice input isn't available here. Please type instead.",'note')}else U("Voice input isn't available in this browser (for example Huawei Browser). Please type your request instead.",'note')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:$?k.colours.gold:'transparent'},children:(0,A.jsx)(b.T,{size:20,children:"\ud83c\udfa4"})}):null,(0,A.jsx)(b.Button,{label:"Send",accessibilityLabel:"Send",disabled:!W.trim(),onPress:()=>V(W)})]}),(0,A.jsxs)(b.Muted,{center:!0,children:["Demo on this device \xb7 ",J," of ",j.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,w.useCtx)(6e4),s=(0,j.useAssistant)();return R(t)?(0,A.jsxs)(h.default,{style:{gap:12},children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{gap:10,children:[(0,A.jsx)(h.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:22})}),(0,A.jsxs)(h.default,{style:{flex:1},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,A.jsx)(b.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,A.jsx)(b.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>v.getState().setOpen(!0)}),(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,A.jsxs)(h.default,{testID:"assistant-log",style:{gap:6},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>j.useAssistant.getState().clearLog()}):null]}),(0,A.jsx)(b.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,A.jsx)(b.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,A.jsxs)(h.default,{style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.T,{size:12,colour:k.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,A.jsx)(b.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,A.jsxs)(b.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,A.jsxs)(b.T,{size:13,colour:k.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,A.jsx)(b.Muted,{children:"The activity log is visible to the owner."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)();return R(e)?(0,A.jsxs)(h.default,{style:{gap:12},testID:"assistant-settings",children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,A.jsx)(b.Muted,{children:"Shows the gold Assistant button on every Managers screen."}),(0,A.jsx)(b.Toggle,{label:"Voice input (microphone)",value:t.voice,onChange:e=>t.set({voice:e})}),(0,A.jsx)(b.Muted,{children:"What you say is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. If this device can\u2019t record, just type."})]}),(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Connected services"}),E.map(e=>(0,A.jsxs)(h.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:k.colours.border,paddingTop:8},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{children:e.name}),(0,A.jsx)(b.Badge,{kind:"neutral",label:"Not connected"})]}),(0,A.jsxs)(b.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,A.jsx)(b.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,A.jsx)(b.Muted,{children:"The Assistant comes with Full Restaurant Pro App and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,A.jsx)(b.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to the voice assistant to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,j.useAssistant)(),t=(0,j.tasksUsed)(e),s=Math.min(1,t/j.FAIR_USE);return(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,A.jsx)(b.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,A.jsx)(h.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${j.FAIR_USE} tasks used`,style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,A.jsx)(h.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:k.colours.gold,borderRadius:4}})}),(0,A.jsxs)(b.Muted,{children:[t," of ",j.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]),a=_r(d[4]),r=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var c=e(_r(d[8])),u=e(_r(d[9])),h=e(_r(d[10])),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),m=_r(d[14]),x=_r(d[15]),y=_r(d[16]),j=_r(d[17]),k=_r(d[18]),w=_r(d[19]),C=_r(d[20]),A=_r(d[21]);const S=!0,T='Nothing was sent or changed: this connection is not set up yet.',I='#1A1408',v=(0,p.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=e=>'owner'===e||'manager'===e,D=()=>Math.random().toString(36).slice(2,9);function M({size:e=24,colour:t=I}){return(0,A.jsx)(b.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function B(){const{rid:e,r:t,now:s,today:n}=(0,w.useCtx)(3e4),a=(0,m.useAllMenu)(e),l=(0,f.useTableNames)(e),c=(0,m.useBookings)(e),u=(0,x.useOwner)(e=>e.staff),h=(0,x.useOwner)(e=>e.shifts),p=(0,x.useOwner)(e=>e.offers),b=(0,x.useOwner)(e=>e.suppliers);return(0,r.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:a.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:l,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,C.workingShifts)(h,x.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,x.addDays)(n,-(0,x.weekdayOf)(n))&&e.date<=(0,x.addDays)(n,6-(0,x.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${b[0]?.contact??'Alex Sample'}, ${b[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),a,l,c,u,h,p,b])}function P({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[a,l]=(0,r.useState)(!1),[c,u]=(0,r.useState)('external'===o.kind?o.text:''),p='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,A.jsxs)(h.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:p?k.colours.gold:k.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:k.colours.surface2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,A.jsx)(b.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[o.detail?(0,A.jsx)(b.Muted,{children:o.detail}):null,(0,A.jsx)(b.T,{size:14,colour:k.colours.muted,children:o.label}),a&&p?(0,A.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:u,style:[b.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,A.jsx)(h.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:k.colours.gold,paddingLeft:10},children:(0,A.jsxs)(b.T,{children:["\u201c",c,"\u201d"]})}),(0,A.jsxs)(b.Muted,{children:["Sends to: ",o.service.map(e=>y.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,A.jsxs)(h.default,{style:{gap:4},children:[(0,A.jsx)(b.Muted,{children:o.detail}),o.warning?(0,A.jsxs)(b.T,{size:13,colour:k.colours.amber,children:["\u26a0 ",o.warning]}):null]}),p?(0,A.jsxs)(b.Row,{wrap:!0,gap:8,children:[(0,A.jsx)(b.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:a?'Done editing':'Edit',testID:"edit-action",onPress:()=>l(!a)}):null,(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,A.jsx)(b.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),p?(0,A.jsxs)(b.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}function O(){return'undefined'==typeof window?null:(0,a.speechRecognizer)()}const E=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1493,[827,979,796,884,931,34,395,236,402,295,102,846,794,1126,874,891,1494,1498,821,1088,1098,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);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]}})})},1494,[1495,1497,1496]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1495,[860,1496]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1496,[]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Voice assistant (server, with on-device fallback)',interpret:s}},1497,[1495,932]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1498,[884,839,846,849]); +__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.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1499,[5,1063,979,1418,828,827,837,1271,1443,34,402,410,102,879,794,874,891,861,867,858,821,1201,1088,1180,1447,1230,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1500,[860,34,102,1181,794,874,861,869,858,821,1201,1088,25]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1501,[1076,34,102,1502,829,873,794,891,821,1088,25]); +__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.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1502,[827,34,236,402,102,797,829,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1503,[34,1176,863,1088,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1504,[34,1062,1088,987,1000,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1505,[34,1394,1088,25]); +__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.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:s}=(0,c.useCtx)(6e4),a=(0,r.useBookings)(e),n=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,t.useState)('day'),k=(0,d.hasAnyTakings)(n,e),w=(0,d.dayRows)(n,a,e,s,14),f=(0,d.weekRows)(n,a,e,s,8),v=(0,d.averageSph)(w),$=(e,t,s,a,n)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${t}: ${'No takings entered'===a?'no takings entered':`spend per head ${a}`}, ${s}${n?`, ${n}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:t}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:s}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===a?h.colours.muted:h.colours.goldLight,size:'No takings entered'===a?13:16,children:a}),n?(0,u.jsx)(i.Muted,{center:!0,children:n}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:k?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:w.map(e=>({label:x(e.date),value:e.sph}))}),[...w].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),a=_r(_d[2]),n=e(a),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,t.useState)(320),[x,y]=(0,t.useState)(e.length);(0,t.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),k=Math.max(0,j-b),w=e.slice(k,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),T=e=>38+e*(f-76)/Math.max(1,w.length-1),S=e=>140-e/$*106,L=[];let D=[];w.forEach((e,t)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:t,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(n.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(a.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(n.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(a.Line,{x1:0,x2:f,y1:S($*e/4),y2:S($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,t)=>(0,u.jsx)(a.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},t)),w.map((e,t)=>(0,u.jsx)(s.default.Fragment,{children:null==e.value?(0,u.jsx)(a.Circle,{cx:T(t),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.Circle,{cx:T(t),cy:S(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(a.Text,{x:T(t),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},k+t))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:w.map((e,t)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},k+t))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===k,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1506,[34,102,797,794,874,1039,1507,821,1088,25]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1507,[13]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1508,[34,102,1354,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1509,[34,793,1088,25]); +__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.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1510,[5,1418,827,837,860,1511,1442,1481,1236,14,1271,987,1512,1514,1443,34,1126,1489,30,402,102,879,1291,794,874,891,867,881,1131,1260,858,821,1201,1088,1160,884,1459,869,1056,1176,863,861,25]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1511,[860,34,102,794,861,867,1175,874,869,821,25]); +__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1512,[987,34,281,236,102,1291,794,1268,1271,821,1513,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1513,[34,236,102,794,1268,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1514,[5,1418,34,102,794,867,1268,1269,1270,987,1271,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1515,[34,1225,1178,1226,1233,1088,1192,863,872,1025,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1516,[34,102,794,987,858,821,25]); +__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.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["Every booking and takeaway order gets a text (a phone number is needed to book) and an email if they gave one. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1517,[828,827,837,34,236,402,102,794,1238,874,1498,864,1240,1048,821,1057,1088,25]); +__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.OrderSheetSettings=function(){const e=(0,i.useOwner)(e=>e.site),u=(0,o.useSheets)(e),[c,m]=(0,l.useState)(null);return c?(0,p.jsxs)(s.Card,{children:[(0,p.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===c.id)?`Edit ${c.name}`:'New supplier'}),(0,p.jsx)(x,{rid:e,s:c,onDone:()=>m(null)})]}):(0,p.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,p.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,p.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,p.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,p.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,p.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,p.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,p.jsx)(s.Row,{wrap:!0,gap:8,children:(0,p.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var l=r(_d[0]),t=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),i=r(_d[4]),o=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]);const c=['online','phone','text','whatsapp','tbc'];function m({label:e,value:l,onChange:t}){return(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,p.jsx)(s.Chip,{label:e,selected:l.includes(n),onPress:()=>t(l.includes(n)?l.filter(e=>e!==n):[...l,n].sort())},e))})]})}function x({rid:e,s:t,onDone:i}){const d=(0,o.useOrderSheets)(e=>e.upsert),x=(0,o.useOrderSheets)(e=>e.remove),[b,f]=(0,l.useState)(t),[j,y]=(0,l.useState)(t.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[C,v]=(0,l.useState)(t.priceCapPerKg?(t.priceCapPerKg/100).toFixed(2):''),[w,T]=(0,l.useState)(!1),D=e=>f(l=>({...l,...e}));return(0,p.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,p.jsx)(s.Field,{label:"Supplier name",value:b.name,onChangeText:e=>D({name:e})}),(0,p.jsx)(s.Field,{label:"What they supply",value:b.goods,onChangeText:e=>D({goods:e})}),(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:c.map(e=>(0,p.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:b.method===e,onPress:()=>D({method:e})},e))})]}),'text'===b.method||'whatsapp'===b.method||'phone'===b.method?(0,p.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:b.number,keyboardType:"phone-pad",onChangeText:e=>D({number:e})}):null,'online'===b.method?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:b.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>D({url:e.trim()})}),(0,p.jsx)(s.Field,{label:"Button label",value:b.urlLabel??'',placeholder:"Open website",onChangeText:e=>D({urlLabel:e})})]}):null,(0,p.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:b.contact??'',onChangeText:e=>D({contact:e})}),(0,p.jsx)(m,{label:"Delivery days",value:b.deliveryDays,onChange:e=>D({deliveryDays:e})}),(0,p.jsx)(m,{label:"Order days (a reminder shows in the Head Chef app)",value:b.orderDays,onChange:e=>D({orderDays:e})}),(0,p.jsxs)(s.Row,{gap:10,children:[(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:b.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>D({cutoff:e})})}),(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Price cap \xa3/kg (optional)",value:C,keyboardType:"decimal-pad",onChangeText:v})})]}),(0,p.jsx)(s.Field,{label:"Reminder text (optional)",value:b.reminder,onChangeText:e=>D({reminder:e})}),(0,p.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:b.frequency,onChangeText:e=>D({frequency:e})}),b.priceCapPerKg||C?(0,p.jsx)(s.Field,{label:"Seller",value:b.seller,onChangeText:e=>D({seller:e})}):null,(0,p.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:y}),(0,p.jsx)(s.Field,{label:"Notes for the chef",value:b.notes,multiline:!0,onChangeText:e=>D({notes:e})}),(0,p.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,p.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const l=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,l)=>{const[n,s]=e.split('|').map(e=>e.trim()),i=t.items.find(e=>e.name===n);return{id:i?.id??`${b.id}-i${l}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*parseFloat(C.replace(/[\xa3,]/g,'')));d(e,{...b,items:l,priceCapPerKg:n>0?n:0,placeholder:b.placeholder&&'tbc'===b.method}),i()},disabled:!b.name.trim()}),(0,p.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:i}),w?(0,p.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{x(e,t.id),i()}}):(0,p.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>T(!0)})]})]})}},1518,[34,402,102,794,891,1031,867,1032,821,25]); +__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.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1519,[34,236,402,102,426,794,821,1376,873,1378,858,987,1379,1088,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1520,[835,984,1457,34,236,102,794,831,891,983,1031,985,987,1521,821,2,1182,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1521,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1522,[34,102,794,821,1438,1511,1088,25]); +__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.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1523,[827,1063,796,34,402,102,794,891,1473,1524,1525,1526,821,1088,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1524,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1525,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1526,[1527,1128,860,1528,1529,891,874,1029,1473,1524,1525,1531,1530,1533,1534,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1527,[1093,1092,1053]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1528,[984,1128,835,860,874,831,1029,983,985,1040,891,1095,882,863,861]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1529,[835,874,831,1029,891,1034,1044,1045,1010,1009,1039,13,1064,1065,1066,1035,1095,882,1105,1026,870,1530,1528]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1530,[835,979,1128,860,1161,1271,874,831,1029,1034,995,862,861,1105,1106,1026,1035,867,1531,1532]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1531,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1532,[839,846,849]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1533,[831,891,995,867,1530,1047,1098]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1534,[]); +__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.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"Staff hold the gold button, say what they need and let go. It sits at the top right in Managers, Head Chef, the Staff app (the full voice assistant, without team financial or HR information) and on the Display (no money, tips or HR either), never in the customer app. Tap it to type or open the Assistant. Replies and change confirmations are shown in text, never spoken. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts for you."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,r.useDrafts)(e=>e.drafts),u=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[j,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:r.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The voice helper and the Assistant save bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting. Try holding the voice button and saying \u201cadd blue roll to the Booker list\u201d."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!j,onClose:()=>y(null),title:'approved'===j?.status?'Approve this draft?':'Dismiss this draft?',children:j?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:j.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===j.status?`This marks it approved${v[j.d.kind]?` and opens ${v[j.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===j.status?'success':'danger',label:'approved'===j.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(j.d.id,j.status,o.replace(' (example)',''));const e=v[j.d.kind];y(null),'approved'===j.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const v={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1535,[34,379,102,794,821,1469,1531,1481,1532,1158,931,1490,1088,25]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1536,[34,796,102,794,861,1268,1537,1538,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1537,[861]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1538,[987,1537,1271]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_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]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1539,[34,102,794,874,1039,1540,979,13,1541,1050,821,1088,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1540,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(o){const{rid:u,date:c,bookings:f,cashUps:p,fields:v,soldOut:h}=o,b=f.filter(t=>t.restaurantId===u&&t.date===c),k=p.find(t=>t.rid===u&&t.date===c&&t.confirmedAt),y=p.find(n=>n.rid===u&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),N=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,O=(0,n.coversOn)(f,u,c),S=null==N||O<=0?null:Math.round(N/O*100)/100,_=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&_.set(n,(_.get(n)??0)+(t.partySize||0))}let w=null;for(const[t,n]of _)(!w||n>w.n)&&(w={hour:t,n:n});return{date:c,spendPerHead:s(S),covers:O,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(N),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(y?(0,t.grossOf)(y.vals)??(0,t.takings)(y.vals):null),busiestHour:w?`${String(w.hour).padStart(2,'0')}:00 \xb7 ${w.n} Covers`:'Not entered',soldOut:h.filter(Boolean),cashUp:v.map(t=>({label:t.label,value:k?l(k.vals[t.key],t.kind):'Not entered'}))}};var t=r(d[0]),n=r(d[1]);const s=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?s(t):String(t)},1541,[13,1507]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1542,[827,34,102,794,1543,1051,821,1544,1088,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1543,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1544,[1050,1051,976,933,987]); +__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.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1545,[34,281,236,102,794,827,821,987,1433,1205,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1546,[236]); +__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,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','voice','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1548,[]); +__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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1549,[34,283,364,236,402,295,102,426,36,797,827,796,794,1238,1388,1115,1473,1114,1112,1240,1253,979,891,1062,1481,2,987,821,1346,1550,1088,1493,1417,1180,1475,1477,1467,1459,1479,1546,1548,1556,1557,1558,1561,1564,25]); +__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.micAvailable=O,_e.NoShows=z,_e.CarApp=function(){(0,H.useCarViewport)();const{width:e,height:n}=(0,c.default)(),o=Math.max(320,A(e)),{role:d,today:u,now:h}=(0,w.useCtx)(3e4),[p,f]=(0,t.useState)(n),x=o,[y,I]=(0,t.useState)(null),[D,W]=(0,t.useState)(!1),[M,z]=(0,t.useState)(null),[V,F]=(0,t.useState)(!1),[G,Y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{O().then(z)},[]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==d&&T.useOwner.getState().setPreviewRole('owner')},[d]);const X=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,X);const q=(0,t.useCallback)(()=>W(!1),[]);(0,j.useBackLayer)(D,q);const J=e=>{W(!1),I({btn:e,page:e.pages[0].id})},K=(0,t.useCallback)((e,t)=>{const n=e=>R.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:n('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:n('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??R.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=n(t);return I(n=>({btn:e??n?.btn??R.CAR_BUTTONS[0],page:t}))}I(null)},[]),Q=x,Z=y?y.btn.label:'';return(0,L.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-p)>1&&f(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:o,maxWidth:'100%',overflow:'hidden'},children:[(0,L.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,L.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,L.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,L.jsx)(B.ParkedOnly,{small:o<1400}),(0,L.jsx)(N,{open:D,onPress:()=>W(!0)})]}),subHeader:(0,L.jsx)($,{onRota:()=>J(R.CAR_BUTTONS[0]),onAccount:()=>F(!0)})}),y?(0,L.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:Q,zIndex:40,backgroundColor:S.colours.bg},children:[(0,L.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${Z}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||X()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,L.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,L.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,L.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,L.jsx)(N,{testID:"car-menu-button-page",open:D,onPress:()=>W(!0)})})]}),y.btn.pages.length>1?(0,L.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,L.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?P:'transparent',alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,L.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:'assistant'===y.page&&!1===M?(0,L.jsx)(U,{}):(0,L.jsx)(_,{id:y.page,go:K},y.page)})]}):null]}),(0,L.jsx)(E,{visible:D,onClose:q,onPick:J,current:y?.btn.id,W:o,H:p}),V?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>F(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,L.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,L.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,L.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{F(!1),Y(!0)},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>F(!1),style:{minHeight:56}})]}):null,G?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>Y(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,L.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,L.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{Y(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>Y(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),c=e(r(_d[7])),d=r(_d[8]),u=e(d),h=r(_d[9]),b=r(_d[10]),p=r(_d[11]);r(_d[12]);var f=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),R=r(_d[26]),W=r(_d[27]),B=r(_d[28]),M=r(_d[29]),H=r(_d[30]),L=r(_d[31]);const P='rgba(201,162,74,0.14)';async function O(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}}function $({onRota:e,onAccount:n}){const o=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[c,d]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>d(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=o.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,L.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,L.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,L.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:n,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,L.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,L.jsx)(M.CarGameButton,{})]})}function z({go:e}){const{rid:t,now:n}=(0,w.useCtx)(3e4),o=(0,I.useBookings)(t),s=(0,D.ymd)(n),a=(0,D.ymd)(new Date(n.getTime()-24192e5)),c=o.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),d=o.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,L.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,L.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:c.length?`${c.length} no-show${1===c.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),d.length?(0,L.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),d.map(e=>(0,L.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,L.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,c.map(e=>(0,L.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,L.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,L.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function N({onPress:e,open:t,testID:n="car-menu-button"}){return(0,L.jsx)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:R.MENU_BUTTON,height:R.MENU_BUTTON,borderRadius:R.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,L.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,L.jsx)(d.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function E({visible:e,onClose:a,onPick:c,current:d,W:u,H:b}){const[p,f]=(0,t.useState)(0),m=(0,R.menuSizes)(u,b),x=p?Math.floor((p-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new n.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),n.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,L.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,L.jsx)(n.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,L.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,L.jsxs)(n.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,L.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,L.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,L.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,L.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>f(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:R.CAR_BUTTONS.map(e=>{const t=d===e.id;return(0,L.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>c(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,L.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:P,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(W.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,L.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U(){return(0,L.jsxs)(l.default,{testID:"car-no-mic",accessibilityLiveRegion:"polite",style:{gap:10,alignItems:'center',paddingVertical:24},children:[(0,L.jsx)(C.T,{center:!0,size:20,weight:"semibold",colour:S.colours.goldLight,children:"The Assistant needs the car\u2019s microphone"}),(0,L.jsx)(C.Muted,{center:!0,style:{maxWidth:520},children:"Sorry, this car\u2019s browser isn\u2019t letting the page use a microphone. For now, please use the Assistant in Managers on your phone."})]})}function _({id:e,go:t}){if('@bookings'===e)return(0,L.jsx)(f.Bookings,{go:t});if('@chat'===e)return(0,L.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,L.jsx)(z,{go:t});if('@orders'===e)return(0,L.jsx)(x.Orders,{});if('@forecast'===e)return(0,L.jsx)(y.Forecasts,{go:t});const n=(0,p.pageFor)(e);if(!n)return(0,L.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const o=n.C;return(0,L.jsx)(o,{go:t})}function A(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,n=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,n))}},1550,[34,283,364,236,402,295,102,426,797,796,1346,1459,1479,1417,1180,1477,1475,1088,1056,794,874,891,858,987,2,821,1551,1552,1553,1554,1555,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1551,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1552,[34,797,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1553,[34,102,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1554,[34,402,1182,1183,831,5,794,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1555,[34,236]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1556,[1551]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1557,[]); +__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.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1558,[34,402,102,426,827,794,1099,1062,1197,1143,1119,874,1039,891,1101,13,930,987,821,1417,1088,1459,1559,1548,1557,1560,25]); +__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,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1559,[34,402,295,102,794,821,25]); +__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.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1560,[34,102,797,794,821,1559,1557,25]); +__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.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1561,[34,281,402,102,797,794,874,891,1562,1000,1227,1466,821,1552,1088,1559,1563,1557,1560,1558,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1562,[846,849,839]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1563,[1000]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1564,[34,102,794,821,1565,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1565,[]); +__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.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:$,meId:V,me:Q}=(0,z.useCtx)(3e4);(0,m.useTipsPosted)(e,_);const Y=(0,z.useSignedIn)();(0,x.useSoldOutLink)(!0,(Y?.name??Q).replace(' (example)',''));const[ee,te]=(0,a.useState)({kind:'tab',tab:'home'}),[se,ae]=(0,a.useState)(''),oe=(0,a.useRef)(null);(0,a.useEffect)(()=>{(0,z.ensureAttendance)(_,$),(0,M.ensureChat)($)},[_]),globalThis.__ccNow=$.getTime();const ne=(0,a.useCallback)((e,t=null)=>{if('more'===e&&t){const e=q[t];return void te(e?{kind:'edit',id:e}:{kind:'page',id:t})}te('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,a.useEffect)(()=>(S.useVoiceNav.setState({go:ne}),()=>S.useVoiceNav.setState({go:null})),[ne]),(0,a.useEffect)(()=>{D.PITCH&&(globalThis.__pitchGo=ne,globalThis.__deskGo=e=>te(e))},[ne]),(0,E.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:Y?.id??'',name:Q,onOpen:e=>'bookings'===e?ne('bookings'):'chat'===e?ne('chat'):ne('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!Y}),(0,a.useEffect)(()=>((0,T.warmDesktopStt)(),(0,C.installVoiceKeys)()),[]);const re=(0,a.useMemo)(()=>[...G,...U].map(e=>e.s),[]);(0,a.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void oe.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=re[Number(e.key)-1];return void(t&&(e.preventDefault(),te(t)))}if('z'===t&&!Z(e.target)){const t=(0,W.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!Z(e.target)){const t=(0,W.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[re]);const ie=O.PAGES.filter(e=>(!e.can||e.can(f))&&!q[e.id]),le=(0,a.useMemo)(()=>{const e=se.trim().toLowerCase(),t={};return ie.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ie,se]),de=G.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ue=p.CAN.forecasts(f)?U:U.filter(e=>'rota'===e.s.id),ce='page'===ee.kind?(0,O.pageFor)(ee.id):void 0,be='tab'===ee.kind?G.find(e=>X(e.s,ee))?.label:'edit'===ee.kind?U.find(e=>X(e.s,ee))?.label:ce?.title,he='tab'===ee.kind?G.find(e=>X(e.s,ee))?.tip:'page'===ee.kind?`${ce?.sub??''}. Press ${(0,N.CMD)()}K to jump to any page, or hold Space and ask.`:'',ge=({label:e,s:t,n:s})=>{const a=X(t,ee);return(0,K.jsxs)(o.default,{accessibilityRole:"button",accessibilityState:{selected:a},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>te(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:a?A.colours.goldTint:e?A.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:a?A.colours.gold:'transparent'}),children:[(0,K.jsx)(g.T,{size:14,weight:a?'semibold':'regular',colour:a?A.colours.gold:A.colours.text,style:{flex:1},numberOfLines:1,children:e}),s?(0,K.jsxs)(g.T,{size:11,colour:A.colours.muted,children:[(0,N.CMD)(),s]}):null]})},fe=({t:e})=>(0,K.jsx)(g.T,{size:11,weight:"semibold",colour:A.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),pe='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,K.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:A.colours.bg},testID:"desktop-shell",children:[(0,K.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,K.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(g.Row,{gap:10,children:[(0,K.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(u.VenueName,{name:c.name}),(0,K.jsx)(g.Row,{gap:6,children:(0,K.jsx)(l.AppBadge,{label:pe})})]})]}),(0,K.jsx)(u.PoweredBy,{}),(0,K.jsx)(s.TextInput,{ref:oe,testID:"side-filter",value:se,onChangeText:ae,placeholder:`Find a page (${(0,N.CMD)()}K)`,placeholderTextColor:A.colours.muted,style:[g.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,K.jsxs)(n.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[se?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fe,{t:"Run the day"}),de.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:t+1},e.label)),(0,K.jsx)(fe,{t:"Drag-and-drop editors"}),ue.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:de.length+t+1},e.label))]}),Object.entries(le).map(([e,t])=>(0,K.jsxs)(r.default,{children:[(0,K.jsx)(fe,{t:e}),t.map(e=>(0,K.jsx)(ge,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{flex:1},children:[(0,K.jsx)(r.default,{testID:"desk-title",children:(0,K.jsx)(g.T,{size:24,weight:"bold",children:be??''})}),(0,K.jsxs)(g.Muted,{size:12,children:[Y?`Signed in as ${Y.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]}),(0,K.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(g.T,{size:15,weight:"bold",colour:A.colours.gold,children:"Talk to CoverCharge"}),(0,K.jsxs)(g.Muted,{size:12,children:["Hold Space, or ",(0,N.CMD)(),"\u21e7G"]})]}),(0,K.jsx)(v.VoiceSlot,{size:76})]}),(0,K.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[he?(0,K.jsx)(F.Tip,{children:he}):null,'edit'===ee.kind?(0,K.jsx)(J,{id:ee.id,rid:e,me:Q,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,K.jsxs)(n.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===ee.kind&&'home'===ee.tab?(0,K.jsx)(H.Dashboard,{go:ne}):null,'tab'===ee.kind&&'orders'===ee.tab?(0,K.jsx)(I.Orders,{}):null,'tab'===ee.kind&&'bookings'===ee.tab?(0,K.jsx)(R.Bookings,{}):null,'tab'===ee.kind&&'forecast'===ee.tab?(0,K.jsx)(P.Forecasts,{go:ne}):null,'tab'===ee.kind&&'chat'===ee.tab?(0,K.jsx)(M.Chat,{go:ne}):null,ce?(0,K.jsx)(ce.C,{go:ne}):'page'===ee.kind?(0,K.jsx)(g.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,K.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,K.jsx)(h.PrintHost,{rid:e}):null,'staff'!==f?(0,K.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Q,onOpen:e=>ne('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,K.jsx)(L.AssistantSheet,{}),(0,K.jsx)(B.OnboardingHost,{go:ne}),(0,K.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),s=_r(d[1]),a=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]),g=_r(d[12]),f=_r(d[13]),p=_r(d[14]),x=_r(d[15]),m=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),S=_r(d[22]),v=_r(d[23]),T=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),z=_r(d[31]),H=_r(d[32]),P=_r(d[33]),B=_r(d[34]),I=_r(d[35]),O=_r(d[36]);_r(d[37]);var _=_r(d[38]),N=_r(d[39]),W=_r(d[40]),$=_r(d[41]),V=_r(d[42]),F=_r(d[43]),K=_r(d[44]);const G=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Hold Space and say \u201chow many Covers tonight?\u201d for a quick answer without leaving this screen.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first. Say \u201cshow new orders\u201d to jump back any time.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber. Hold Space and say \u201caccept the 7 o\u2019clock\u201d.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],U=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],q={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},X=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),Z=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function J({id:e,rid:t,me:s,role:o,today:n,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,a.useState)(0),[h,p]=(0,a.useState)('');return'menu'===e?(0,K.jsx)($.MenuEditor,{rid:t,me:s,role:o}):'rota'===e?(0,K.jsx)(V.RotaEditor,{today:n}):'brand'===e?(0,K.jsx)(_.BrandEditor,{rid:t}):(0,K.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,K.jsxs)(F.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,N.CMD)(),"Z undoes, then Save."]}),h?(0,K.jsx)(g.T,{size:13,colour:A.colours.goldLight,children:h}):null,(0,K.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:A.colours.border,borderRadius:12,overflow:'hidden'},children:(0,K.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1566,[828,827,34,402,295,102,36,1361,873,1364,1238,1388,794,1029,891,979,1062,1473,1115,1114,1112,1567,1481,1157,931,1240,2,821,1493,1417,1180,1088,1435,1475,1467,1477,1459,1479,1568,1546,1570,1572,1574,1571,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1567,[846]); +__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.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1568,[34,295,102,1502,873,794,891,829,1460,821,1569,1570,1571,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1569,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1570,[34]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1571,[34,102,794,821,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1572,[827,34,102,794,876,831,979,981,982,861,882,1174,821,1569,1570,1571,1573,25]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1573,[891]); +__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.RotaEditor=function({today:e}){const y=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[$,j]=(0,t.useState)((0,i.mondayOfDate)(e)),[v,k]=(0,t.useState)(null),[w,D]=(0,t.useState)(''),B=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),O=b.map((e,t)=>(0,i.addDays)($,t)),P=(e,t,o)=>{e.preventDefault(),k(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=y.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=$&&e.date<=O[6]),I=T.filter(e=>!e.published||e.changed).length;return(0,p.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,p.jsx)(h.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,p.jsxs)(s.Row,{gap:8,children:[(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>j((0,i.addDays)($,-7))}),(0,p.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date($+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>j((0,i.addDays)($,7))}),(0,p.jsx)(d.default,{style:{flex:1}}),w?(0,p.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:w}):null,(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!B.canUndo,onPress:B.undo,testID:"rota-undo"}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!B.canRedo,onPress:B.redo,testID:"rota-redo"}),(0,p.jsx)(s.Button,{small:!0,label:I?`Publish (${I})`:'Published',disabled:!I,onPress:()=>{B.record('published the week');const e=i.useOwner.getState().publishWeek($);D(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,p.jsx)("div",{style:(0,h.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,p.jsxs)("div",{style:(0,h.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,p.jsx)("div",{style:(0,h.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),O.map((t,o)=>(0,p.jsxs)("div",{style:(0,h.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[b[o]," ",Number(t.slice(8))]},t)),y.map(e=>(0,p.jsxs)(o.default.Fragment,{children:[(0,p.jsxs)("div",{style:(0,h.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,p.jsx)("div",{style:(0,h.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,p.jsx)("div",{style:(0,h.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),O.map(t=>{const o=`${e.id}|${t}`,d=T.filter(o=>o.staffId===e.id&&o.date===t);return(0,p.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',k(o)},onDragLeave:()=>k(null),onDrop:o=>P(o,e.id,t),style:(0,h.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,p.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,h.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,p.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]),f=r(_d[9]),p=r(_d[10]);const b=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],x=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1574,[34,102,794,891,1091,821,1569,1570,1571,1573,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1575,[30,34,872,1576,25]); +__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1576,[1460,1577,828,997,1099,1511,1224,1055,1056,1512,1536,1514,1174,979,1016,1578,1013,2,1061,1062,1487,999,1039,1000,34,1176,1249,1253,1220,373,402,295,102,426,36,794,873,1157,891,821,1180,1417,1094,1112,1114,1108,1057,1040,1088,1505,1500,1520,1579,1426,1004,236,1255,1199,1205,1458,1219,1218,1474,1202,15,1225,1226,925,793,987,25]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1577,[34,102,794,1088,987,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1578,[236,1014]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1579,[860,34,102,794,891,1029,858,1091,1089,987,1090,5,1001,821,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1580,[30,34,872,25]); +__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1581,[1454,987,795,1411,1582,1026,30,1609,496,34,385,336,236,41,102,5,873,872,1611,36,874,1029,891,821,1426,1004,1024,1612,1613,1058,1614,1130,2,1039,999,1616,1379,25,1618,1619,1620,1621]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1582,[1583,1606,1608]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1583,[215,1584,1587,1601,1602,1603,1604,1605]); +__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1584,[215,1585]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1585,[1586]); +__d(function(g,r,i,a,m,e,d){},1586,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1587,[1588,215,1584,1601,1602]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1588,[1589,1590,1600]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1589,[1590,1594,1599]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1590,[215,372,1591,1595,1596,1597,1598,1594,1599]); +__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1591,[215,1592,339,280,1593,1594]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1592,[504]); +__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1593,[215,339]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1594,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1595,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1596,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1597,[1595]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1598,[]); +__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1599,[372,1593]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1600,[34,1590]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1601,[1588,215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1602,[1588,1601]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1603,[1584]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1604,[215,1584,1587,1585]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1605,[]); +__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1606,[215,54,1607]); +__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1607,[215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1608,[34,1583]); +__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]}})})},1609,[1610]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1610,[]); +__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1611,[34,41,102,426,794,873,1004,987,2,5,821,1551,1553,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1612,[990,883,882,987]); +__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1613,[828,796,827,34,1012,1461,1030,402,102,872,987,1014,1029,5,821,794,1357,976,2,25]); +__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1614,[5,796,827,34,385,283,364,380,236,402,295,426,102,1493,1157,2,797,1088,15,891,794,821,1526,932,1615,1524,1525,1481,1158,1491,931,1567,1534,25,277]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1615,[891,831,1029]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1616,[874,831,891,1039,15,1004,872,2,1617]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1617,[874,1039]); +__d(function(e,o,s,p,t,n,a){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1618,[]); +__d(function(o,e,s,p,t,c,d){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1619,[]); +__d(function(o,e,s,p,t,d,f){"use strict";t.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1620,[]); +__d(function(o,s,e,p,d,t,n){"use strict";d.exports="/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1621,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1622,[30,34,872,25]); +__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1623,[1624]); +__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1624,[25,1625,591]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1625,[34,172]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1626,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1627,[25,499,34,270,651]); __r(501); __r(21); __r(0); \ No newline at end of file diff --git a/owner-app/admin.html b/owner-app/admin.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/admin.html +++ b/owner-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer.html b/owner-app/customer.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer.html +++ b/owner-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage.html b/owner-app/customer/anchorage.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage.html +++ b/owner-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/book.html b/owner-app/customer/anchorage/book.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/book.html +++ b/owner-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/feedback.html b/owner-app/customer/anchorage/feedback.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/feedback.html +++ b/owner-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/gift.html b/owner-app/customer/anchorage/gift.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/gift.html +++ b/owner-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/lost.html b/owner-app/customer/anchorage/lost.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/lost.html +++ b/owner-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/loyalty.html b/owner-app/customer/anchorage/loyalty.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/loyalty.html +++ b/owner-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/merch.html b/owner-app/customer/anchorage/merch.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/merch.html +++ b/owner-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/offers.html b/owner-app/customer/anchorage/offers.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/offers.html +++ b/owner-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/refer.html b/owner-app/customer/anchorage/refer.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/refer.html +++ b/owner-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/waitlist.html b/owner-app/customer/anchorage/waitlist.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/waitlist.html +++ b/owner-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/anchorage/whatson.html b/owner-app/customer/anchorage/whatson.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/anchorage/whatson.html +++ b/owner-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/basket.html b/owner-app/customer/basket.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/basket.html +++ b/owner-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/customer/profile.html b/owner-app/customer/profile.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/customer/profile.html +++ b/owner-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/demo.html b/owner-app/demo.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/demo.html +++ b/owner-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/display.html b/owner-app/display.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/display.html +++ b/owner-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/index.html b/owner-app/index.html index c4816449b5703edc218dad21f1b4e4a2ebf7d37b..0ca27566638f419bc15901fa151cec4052176c22 100644 --- a/owner-app/index.html +++ b/owner-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/kitchen.html b/owner-app/kitchen.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/kitchen.html +++ b/owner-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/owner.html b/owner-app/owner.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/owner.html +++ b/owner-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/staff.html b/owner-app/staff.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/staff.html +++ b/owner-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-app/sw.js b/owner-app/sw.js index e7a28bfe037f8d690a92b747442d9b4fbdf06a77..c663eb0a2a53b0c3aef986d675bb5f171e8931a0 100644 --- a/owner-app/sw.js +++ b/owner-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Manager service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-owner-83575c66a7"; +const V = "cc-owner-5b44843def"; const BASE = "/owner-app/"; -const PRECACHE = ["/owner-app/apple-touch-icon.png", "/owner-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/owner-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/owner-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/owner-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/owner-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/owner-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/owner-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/owner-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/owner-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/owner-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/owner-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/owner-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/owner-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/owner-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/owner-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/owner-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/owner-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/owner-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/owner-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/owner-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/owner-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/owner-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/owner-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/owner-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/owner-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/owner-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/owner-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/owner-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/owner-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/owner-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/owner-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/owner-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-app/brand-logo.png", "/owner-app/favicon.ico", "/owner-app/icon-192.png", "/owner-app/icon-512.png", "/owner-app/icon-maskable-192.png", "/owner-app/icon-maskable-512.png", "/owner-app/manifest.webmanifest", "/owner-app/index.html", "/owner-app/_expo/static/js/web/bundle.js?v=83575c66a7955850bee79524cba048ed6f0b538986bc1252a636d7e33678ffb7"]; +const PRECACHE = ["/owner-app/apple-touch-icon.png", "/owner-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/owner-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/owner-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/owner-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/owner-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/owner-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/owner-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/owner-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/owner-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/owner-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/owner-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/owner-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/owner-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/owner-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/owner-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/owner-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/owner-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/owner-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/owner-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/owner-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/owner-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/owner-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/owner-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/owner-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/owner-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/owner-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/owner-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/owner-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/owner-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/owner-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/owner-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/owner-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-app/brand-logo.png", "/owner-app/favicon.ico", "/owner-app/icon-192.png", "/owner-app/icon-512.png", "/owner-app/icon-maskable-192.png", "/owner-app/icon-maskable-512.png", "/owner-app/manifest.webmanifest", "/owner-app/index.html", "/owner-app/_expo/static/js/web/bundle.js?v=5b44843defd88e2bb6ad8d25ed59e1c66f2689dc5fbb65ac4bf38432d8e7745e"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/owner-app/team.html b/owner-app/team.html index c43ed7768e3aee593ff6186b187563c812de7c13..8d7a7971d155decc64a5cf2ada004008b2ab7e41 100644 --- a/owner-app/team.html +++ b/owner-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-desktop/_expo/static/js/web/bundle.js b/owner-desktop/_expo/static/js/web/bundle.js index 268e4ff69aa023d3e90a342e654376702a3a4656..df34bad1d9034cd3e7f04b38e2d8b61cde2e4e6c 100644 --- a/owner-desktop/_expo/static/js/web/bundle.js +++ b/owner-desktop/_expo/static/js/web/bundle.js @@ -23,11 +23,11 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_VENUE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PITCH_TEAM",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PITCH_TEXT",{enumerable:!0,get:function(){return o}}),e.pitchText=function(a,n=!1){let l=a;for(const[a,s]of o){if(n&&t.test(a.source.replace(/\\/g,'')))continue;a.test(l)?(a.lastIndex=0,l=l.replace(a,s)):a.lastIndex=0}return l};const a={name:'The Harbour Kitchen',tagline:'Harbourside seafood & seasonal plates',location:'12 Quay Street, Portmorran',phone:'01632 960 123',website:'harbourkitchen.example'},n={'st-tracy':{name:'Morgan',job:'Owner',hourlyPence:null,salaried:!0},'st-gordon':{name:'Alex',job:'General Manager',dept:'Management',hourlyPence:null,salaried:!0},'st-bisto':{name:'Ravi',job:'Head Chef',hourlyPence:null,salaried:!0},'st-agate':{name:'Priya',job:'Front of house supervisor',hourlyPence:1450},'st-lenny':{name:'Tom',job:'Commis Chef',hourlyPence:1325},'st-finn':{name:'Lewis',job:'Bar staff',hourlyPence:1290},'st-eilidh':{name:'Chloe',job:'Front of house',hourlyPence:1271},'st-emily':{name:'Ellie',job:'Front of house',hourlyPence:1271},'st-lillie':{name:'Jordan',job:'Kitchen porter (KP)',hourlyPence:1271},'st-jack':{name:'Sam',job:'Kitchen porter (KP)',hourlyPence:1271}},o=[['Harbour View, Dunure, South Ayrshire',a.location],['Harbour View, Dunure',a.location],['Harbour View mug','Harbour Kitchen mug'],['Harbour View','Quay Street'],['anchoragedunure.com',a.website],['01292 502826',a.phone],['Mini Anchors','Little Crew'],['The Anchorage',a.name],['Anchorage','Harbour Kitchen'],['ANCHORAGE','HARBOUR KITCHEN'],['South Ayrshire','the Firth coast'],['Ayrshire','the Firth coast'],['Dunure','Portmorran'],['Kittyfisher boat (Big Sean)','Coastal Fish Co'],['Kittyfisher','Coastal Fish Co'],['Big Sean','Coastal Fish Co'],['Example Fish Co.','Coastal Fish Co'],['Sample Dairy Ltd','Hillside Dairy'],['Sample Fruit & Veg','Fieldfare Veg'],['Mills milk','Hillside Dairy milk'],['Mills','Hillside Dairy'],['J. Pieroni & Sons','Fieldfare Veg'],["Pieroni's",'Fieldfare Veg'],['Pieroni','Fieldfare Veg'],['Alsons (drinks)','Drinks wholesaler'],['Alsons','the drinks wholesaler'],['Spes Bona','the deli wholesaler'],['Tarelgin','the butcher'],['Reids','the bakery'],['Reeds','the bakery'],['Example Butchers Ltd','Quayside Butchers'],['Example Dry Goods Wholesale','Dry goods wholesaler'],['Sample Brewing Co.','Harbourside Brewing'],['Example Cleaning Supplies','Cleaning supplies'],['Sample Packaging Ltd','Packaging supplier'],['Example Kitchen Repairs','Kitchen repairs'],['Preston','Ravi'],['Bisto','Ravi'],['Tracy','Morgan'],['James','Morgan'],['Gordon','Alex'],['Agate','Priya'],['Lenny','Tom'],['Finn','Lewis'],['Eilidh','Chloe'],['Emily','Ellie'],['Gabrielle','Ellie'],['Cameron Mc','Sam'],['Cameron','Sam'],['Lillie','Jordan'],['Lily','Jordan'],['Mia','Jordan'],['Jack','Sam'],['Harvey','Jordan'],['Anna','the supplier'],['(preview)',''],[' (example)','']].map(([a,n])=>[new RegExp(`${/^[A-Za-z]/.test(a)?'(?g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},23,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1619,1622]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1623,1626]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},25,[26]); __d(function(g,r,i,a,m,e,d){ /** @@ -41,8 +41,8 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},26,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},27,[28]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1052,1255,1256,1260,1262,1264,1271,1325,1326,1327,1328,1329,1330,1332,1333,1334,1335,1336,1337,1338,1339,1342,1409,1410,1411,1571,1576,1577,1618]); -__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,993,25]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1053,1256,1257,1261,1263,1265,1272,1326,1327,1328,1329,1330,1331,1333,1334,1335,1336,1339,1340,1341,1342,1345,1412,1413,1414,1575,1580,1581,1622]); +__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,994,25]); __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)},30,[31,32,782,783,785]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},31,[]); __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}},32,[33,692,487,708,557,709,770,761,764,774,647,645,650,562,560,591,465,467,204,205,775,472,473,462,460,569,556,639,659,776,658,162,151,547,433,777,780]); @@ -872,9 +872,9 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},789,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},790,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},791,[]); -__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1054,1055,1015,2,1056,1060,1061,1093,858,1098,1102,1103,1106,1107,1110,1111,1113,1114,1115,1144,1146,1091,34,373,236,402,295,426,102,36,873,1156,794,867,821,1087,1158,1164,1167,1168,1171,1185,1184,1186,1187,1190,1191,1198,1201,1204,1217,1218,1222,1223,925,1003,1224,1177,1225,1232,1237,1246,1239,1175,1248,1252,1219,874,1253,1173,987,1254,25]); +__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1055,1056,1016,2,1057,1061,1062,1094,858,1099,1103,1104,1107,1108,1111,1112,1114,1115,1116,1145,1147,1092,34,373,236,402,295,426,102,36,873,1157,794,867,821,1088,1159,1165,1168,1169,1172,1186,1185,1187,1188,1191,1192,1199,1202,1205,1218,1219,1223,1224,925,1004,1225,1178,1226,1233,1238,1247,1240,1176,1249,1253,1220,874,1254,1174,987,1255,25]); __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=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.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."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.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 CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};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]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(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 v(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 b(e){const{img:t,url:a}=await f(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),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.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()})}},793,[34,336,236,402,102,794,925,929,926,821,930,25]); -__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=D,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(H,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(x.default,{style:{flex:1},children:u}),s?(0,B.jsx)(x.default,{style:N.footer,children:(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=v,_e.Card=F,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(x.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:L?'center':'flex-start'}],children:(0,B.jsx)(D,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(x.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(D,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(D,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(x.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(D,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,p.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(D,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(D,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(x.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(D,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),x=e(_r(d[14])),p=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),L='display'!==S.APP_VARIANT;function D({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),x=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,p=f.default.flatten(t)||{},j=1===p.flex||1===p.flexGrow||'number'==typeof p.width||'left'===p.textAlign,k=c??(L&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,x,(0,W.webLine)(t,r),k&&'left'!==p.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(D,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(D,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(D,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??L});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(x.default,{style:N.brandBar,children:[(0,B.jsxs)(x.default,{style:N.row,children:[(0,B.jsx)(x.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(D,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(x.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(x.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function H(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(D,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function v({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],x={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:x,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(D,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(D,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function F({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(x.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(x.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(D,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(D,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,v.centreRow=!0;const V=()=>(0,B.jsx)(E,{kind:"example",title:"Allergens awaiting kitchen verification",children:"This allergen information has not been verified by the kitchen. Head chef sign-off is required. Always speak to staff about allergies."}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Card payments: not set up yet",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===F?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(L&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(x.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=L&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(x.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(x.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); +__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(v,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(p.default,{style:{flex:1},children:u}),s?(0,B.jsx)(p.default,{style:N.footer,children:(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=F,_e.Card=H,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:D?'center':'flex-start'}],children:(0,B.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,x.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),D='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(D&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??D});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(p.default,{style:N.brandBar,children:[(0,B.jsxs)(p.default,{style:N.row,children:[(0,B.jsx)(p.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function v(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function F({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function H({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,F.centreRow=!0;const V=({phone:e})=>(0,B.jsx)(E,{kind:"warn",title:"Allergies",children:"All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===H?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(D&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=D&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},795,[]); __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.GoldX=h,_e.GoldClose=j,Object.defineProperty(_e,"TEXT_ONLY_CLOSE",{enumerable:!0,get:function(){return x}}),_e.ToastClose=function({onPress:e,label:o="Close",testID:s,size:l="md",style:c,colour:h}){return x?(0,b.jsx)(t.default,{testID:s,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:[{minWidth:64,minHeight:48,alignItems:'center',justifyContent:'center',paddingHorizontal:8},c],children:(0,b.jsx)(u.Text,{style:{fontSize:16,color:h??n.colours.text},children:"Close"})}):(0,b.jsx)(j,{onPress:e,label:o,testID:s,size:l,style:c})},r(d[0]);var t=e(r(d[1])),o=e(r(d[2])),s=r(d[3]),l=e(s),n=r(d[4]),c=r(d[5]),u=r(d[6]),b=r(d[7]);function h({size:e=16,colour:t=n.colours.gold,stroke:o}){const c=o??(e>=20?2.4:2.2);return(0,b.jsx)(l.default,{width:e,height:e,viewBox:"0 0 24 24",accessible:!1,focusable:!1,pointerEvents:"none",children:(0,b.jsx)(s.Path,{d:"M6 6 L18 18 M18 6 L6 18",stroke:t,strokeWidth:Math.min(4,c*(24/e)),strokeLinecap:"round",fill:"none"})})}const f={sm:32,md:38,lg:46},y={sm:13,md:15,lg:18};function j({onPress:e,label:s="Close",testID:l,size:c="md",style:u,disabled:j,hint:x}){const C=f[c],I=Math.max(44,C+8);return(0,b.jsx)(t.default,{testID:l,accessibilityRole:"button",accessibilityLabel:s,accessibilityHint:x,disabled:j,onPress:e,dataSet:{goldClose:'1'},style:[{width:I,height:I,alignItems:'center',justifyContent:'center',flexShrink:0,opacity:j?.4:1},u],children:({pressed:e,hovered:t})=>(0,b.jsx)(o.default,{style:{width:C,height:C,borderRadius:C/2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:e||t?n.colours.gold:n.colours.accentBorder,backgroundColor:e?n.colours.goldTint:t?n.colours.accentBg:'rgba(0,0,0,0.18)'},children:(0,b.jsx)(h,{size:y[c],colour:e?n.colours.goldLight:n.colours.gold})})})}const x=['kirkton','abbotsford'].includes(c.VENUE_RID)},796,[34,402,102,797,821,5,827,25]); __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}},797,[798]); @@ -911,7 +911,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule? __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOUTERS_BG",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SOUTERS_SURFACE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SOUTERS_TYPE_SCALE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"soutersFont",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"soutersSurface",{enumerable:!0,get:function(){return f}}),e.soutersInk=function(o){if(!t.IS_SOUTERS)return o;const c=(0,n.normaliseHex)(o);return c?'#A4622E'===c?'#D9AD8A':(0,n.contrast)(c,u)<4.5?'#FFFFFF':o:o};var t=r(d[0]),n=r(d[1]);const u='#56152A',o='#43122F',c=.88,S=n=>t.IS_SOUTERS?Math.round(n*c*100)/100:n,f=n=>t.IS_SOUTERS?o:n},828,[5,829]); __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normaliseHex=n,e.hexToRgb=r,e.rgbToHex=o,e.hsvToRgb=s,Object.defineProperty(e,"hsvToHex",{enumerable:!0,get:function(){return a}}),e.hexToHsv=function(t){const{r:n,g:o,b:s}=r(t),a=n/255,c=o/255,u=s/255,i=Math.max(a,c,u),h=Math.min(a,c,u),l=i-h;let p=0;l&&(p=i===a?(c-u)/l%6:i===c?(u-a)/l+2:(a-c)/l+4);return{h:(60*p+360)%360,s:i?l/i:0,v:i}},e.luminance=c,e.contrast=u,e.shade=i,e.checkAccent=function(t,r,o,s){const a=n(t)??'#CFA45F',c=u(a,o),h=u(a,s),l=c>=h?o:s,p=[];Math.max(c,h)<4.5?p.push('Button text may be hard to read on this colour. We picked the clearer text colour for you, but a lighter or darker shade will read better.'):l===s&&p.push('This is a dark colour, so buttons use light text.');let b=a,d=0;for(;u(b,r)<4.5&&d<20;)b=i(a,.05*(d+1)),d++;b!==a&&p.push('This colour is hard to read on the dark background, so header text uses a lighter shade of it.');return{onAccent:l,accentText:b,tips:p}},e.pushRecent=function(t,r,o=8){const s=n(r);return s?[s,...(t??[]).filter(t=>t!==s)].slice(0,o):t??[]};const t=(t,n=0,r=1)=>Math.min(r,Math.max(n,t));function n(t){const n=t.trim().replace(/^#/,'');return/^[0-9a-fA-F]{3}$/.test(n)?'#'+n.split('').map(t=>t+t).join('').toUpperCase():/^[0-9a-fA-F]{6}$/.test(n)?'#'+n.toUpperCase():null}function r(t){const r=(n(t)??'#000000').slice(1);return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function o({r:n,g:r,b:o}){return'#'+[n,r,o].map(n=>Math.round(t(n,0,255)).toString(16).padStart(2,'0')).join('').toUpperCase()}function s({h:t,s:n,v:r}){const o=(t%360+360)%360/60,s=r*n,a=s*(1-Math.abs(o%2-1)),c=r-s,[u,i,h]=o<1?[s,a,0]:o<2?[a,s,0]:o<3?[0,s,a]:o<4?[0,a,s]:o<5?[a,0,s]:[s,0,a];return{r:255*(u+c),g:255*(i+c),b:255*(h+c)}}const a=t=>o(s(t));function c(t){const n=t=>{const n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)},{r:o,g:s,b:a}=r(t);return.2126*n(o)+.7152*n(s)+.0722*n(a)}function u(t,n){const r=c(t),o=c(n);return(Math.max(r,o)+.05)/(Math.min(r,o)+.05)}function i(t,n){const{r:s,g:a,b:c}=r(t),u=n>0?255:0,i=Math.abs(n);return o({r:s+(u-s)*i,g:a+(u-a)*i,b:c+(u-c)*i})}},829,[]); __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,"isEditable",{enumerable:!0,get:function(){return u}}),_e.hideKeyboard=s,_e.installKeyboardHide=f,_e.useTyping=function(){const[e,n]=t.default.useState(c);return t.default.useEffect(()=>{if(!o)return;f();const e=()=>setTimeout(()=>n(c()),0);return document.addEventListener('focusin',e,!0),document.addEventListener('focusout',e,!0),()=>{document.removeEventListener('focusin',e,!0),document.removeEventListener('focusout',e,!0)}},[]),e},_e.useVisibleArea=function(){const e=o?window.visualViewport:null,n=()=>e?{height:Math.round(e.height),top:Math.round(e.offsetTop)}:null,[u,c]=t.default.useState(n);return t.default.useEffect(()=>{if(!e)return;const t=()=>c(e=>{const t=n();return e&&t&&e.height===t.height&&e.top===t.top?e:t});return e.addEventListener('resize',t),e.addEventListener('scroll',t),()=>{e.removeEventListener('resize',t),e.removeEventListener('scroll',t)}},[]),u};var t=e(r(d[0])),n=e(r(d[1]));r(d[2]);const o='undefined'!=typeof document,u=e=>!!e&&'function'==typeof e.matches&&e.matches("input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]"),c=()=>!!o&&u(document.activeElement);function s(){try{n.default.dismiss()}catch{}o&&u(document.activeElement)&&document.activeElement.blur()}function a(){if(!o)return;const e=document.activeElement;if(u(e))try{e.scrollIntoView({block:'nearest',inline:'nearest'})}catch{}}let l=!1;function f(){o&&!l&&(l=!0,document.addEventListener('click',e=>{if(!c())return;const t=document.activeElement;if('function'!=typeof t.closest||!t.closest('[aria-modal="true"], [role="dialog"]'))return;const n=e.target;n&&!u(n)&&('function'==typeof n.closest&&n.closest('label, [data-keep-keyboard]')||s())},!0),document.addEventListener('focusin',e=>{u(e.target)&&setTimeout(a,300)},!0),window.visualViewport?.addEventListener('resize',()=>setTimeout(a,50)))}},830,[34,376,236]); -__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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 O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:u,phone:g,email:m})=>{const p=t(),b=p.basket,f=b.restaurantId,k=w(b,p.menu,p.customer.allergies),I=k.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,h=$(p.orders.filter(e=>e.restaurantId===f).map(e=>e.ref),S?'Q-':'T-',S?p.counters.table:p.counters.order),O=u?n(o,f,I+i):0,C=I+i,v={id:(0,y.uuid)(),ref:`${S?'Q':'T'}-${h}`,restaurantId:f,customerId:p.customer.id,customerName:p.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:k,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:u?C:0,status:'new',createdAt:a().toISOString(),allergies:p.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:g??p.customer.phone,email:m??p.customer.email}:{}};e(e=>({orders:[v,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:h}:{...e.counters,order:h}}));const A=k.filter(e=>e.overridden);return r(f,'order',`Order ${v.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${A.length?` \u2014 ALLERGY OVERRIDE on ${A.map(e=>e.name).join(', ')}`:''}`),v.allergies.length&&r(f,'allergy',`Allergies declared and confirmed by customer on ${v.ref}: ${v.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),c(v),v},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); +__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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,choiceIds:s.map(e=>e.id)}]})}const O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:n,tip:s,notes:i,phone:o,email:l,customerName:u})=>{const g=t(),m=g.basket,p=m.restaurantId,b=w(m,g.menu,g.customer.allergies),f=b.reduce((e,t)=>e+t.unitPrice*t.qty,0),k='table'===m.mode,I=$(g.orders.filter(e=>e.restaurantId===p).map(e=>e.ref),k?'Q-':'T-',k?g.counters.table:g.counters.order),S=!k,h=f+(S?0:s),O=(u??'').trim()||g.customer.name,C={id:(0,y.uuid)(),ref:`${k?'Q':'T'}-${I}`,restaurantId:p,customerId:g.customer.id,customerName:O,type:m.mode,tableNo:m.tableNo,slotTime:n,lines:b,subtotal:f,tip:S?0:s,giftCardApplied:0,giftCardCode:void 0,total:h,paid:0,status:S?'awaiting_payment':'new',createdAt:a().toISOString(),allergies:g.customer.allergies,readiness:{},notes:i,channel:'app',...'takeaway'===m.mode?{phone:o??g.customer.phone,email:l??g.customer.email}:{}};e(e=>({orders:[C,...e.orders],basket:{...e.basket,lines:[]},counters:k?{...e.counters,table:I}:{...e.counters,order:I}}));const v=b.filter(e=>e.overridden);return r(p,'order',`Order ${C.ref} placed (${k?`Table ${m.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),C.allergies.length&&r(p,'allergy',`Allergies declared and confirmed by customer on ${C.ref}: ${C.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),'awaiting_payment'!==C.status&&c(C),C},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WILDINGS_LOCATION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WILDINGS_ADDRESS",{enumerable:!0,get:function(){return t}}),e.withWildingsAddress=function(r){return'wildings'===r.id?{...r,location:n,address:t}:r},e.withWildingsQuestionnaireAddress=function(n,r){return'wildings'===n&&r?{...r,venue:{...r.venue,address:t}}:r};const n='Maidens, KA26 9NR',t='Maidens Road, Maidens, KA26 9NR'},832,[]); __d(function(g,r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sampleFingerprint=i,e.stripOwnerLiveSamples=function(n){const a={};for(const[s,o]of Object.entries(t.OWNER_SAMPLE_HASHES)){const t=n[s]||[];a[s]=t.filter(t=>!o.includes(i(t)))}a.chat=(n.chat||[]).filter(t=>!(0,s.isSeedChefChat)(t));const o=(n.changeRequests||[]).length-a.changeRequests.length;o&&(a.changesUsed=Math.max(0,(n.changesUsed||0)-o));return a},e.stripCoreLiveSamples=function(a){const c={...(0,n.stripCoreChefSamples)(a)};c.giftCards=(a.giftCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.giftCards.includes(i(s))),c.stampCards=(a.stampCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.stampCards.includes(i(s))),c.ratings=(a.ratings||[]).filter(t=>!(/^rt-[123]$/.test(t.id)&&(0,s.demoActor)(t.customerName))),i(a.customer)===t.LEGACY_CUSTOMER_HASH&&(c.customer={...a.customer,id:'',name:'',email:'',phone:'',allergies:[],allergyConsent:!1,referralCode:'',marketingOptIn:{}});return c.restaurants=(a.restaurants||[]).filter(t=>!('saltmarsh'===t.id&&['The Venue','Saltmarsh Bistro'].includes(t.name))),c.menu=(c.menu||a.menu||[]).filter(t=>'saltmarsh'!==t.restaurantId).map(t=>t.signOff?t:o(t)),c};var t=r(d[0]),s=r(d[1]),n=r(d[2]);const a=t=>Array.isArray(t)?t.map(a):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&'function'!=typeof t).sort(([t],[s])=>ts?1:0).map(([t,s])=>[t,a(s)])):t;function i(t){const s=JSON.stringify(a(t))??"null";let n=2166136261;for(let t=0;t>>0).toString(16)}const o=t=>Array.isArray(t)?t.map(o):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).map(([t,s])=>[t,'allergenNotes'===t&&'string'==typeof s&&/\(example\)/i.test(s)?'':o(s)])):t},833,[834,835,836]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"OWNER_SAMPLE_HASHES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CORE_SAMPLE_HASHES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"LEGACY_CUSTOMER_HASH",{enumerable:!0,get:function(){return b}});const c={referrals:["43f09bc0","c438fbad","96bf8c62","3399d421"],coats:["f51097ad","2f7efa3a"],merch:["ef6e14e","dbbc0999","dc233c1d"],merchOrders:["13b15512","bc27f242"],offers:["ad0fcde0","59e6c0cf"],photos:["53a60fd9","ab778a74","95de43cd"],changeRequests:["81c5be12","6819542c"],lost:["5bbf0d77","7d3aa9ed","850c049e"],campaigns:["9cdf8346","82150e7"],suppliers:["41df06e7","466e32ac","fa3d8eea","dfafa674","1e26fbd0","c195b120","5fc49e74","6aa8b0af","602fc2e4"],supplierOrders:["22636226","464d6a6a"]},f={giftCards:["b1bba36d","f029bc0e"],stampCards:["e7bedf6f","a3c8404d"]},b="4b1e9971"},834,[]); @@ -1067,643 +1067,647 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},984,[835]); __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 t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(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 u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{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}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},985,[984]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},986,[872,34,102,987,2,821,794,25]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return W.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return W.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return W.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return W.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return W.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return I.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return I.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return It}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ne.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ne.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ne.useOwner.getState().chatSeen(t,e)),Ft(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ne.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...St(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(le.PITCH)return pe.unlockCashUp(e,t,a);const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?oe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):oe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(le.PITCH)return pe.cashAudit(e);const t=Oe.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(ma.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=fa,i.readAccessLog=async function(){const e=Oe.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Oe.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return pa}}),i.uploadOrderLogo=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(pa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ga.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(pa).createSignedUrl(e,3600);if(t?.signedUrl)return ga.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(pa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return ma}}),i.claimInvite=Da,i.makeChromeHandover=async function(){const e=Oe.getState();if(le.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ue});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(le.PITCH||!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ue});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),Pe&&xa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Te();const t=await x.kv.get(ka,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Te(),await x.kv.get(Ia,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_WILDINGS||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Te(),await x.kv.remove(ka),await x.kv.remove(Ia),Ae({mode:'signin',perms:[]});try{await Ma()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Oe.getState().venueId;if(le.PITCH||!s||'staff'!==Oe.getState().kind)return{ok:!0};if(!(0,ie.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ka('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Da(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(le.PITCH)return pe.reissueInvite(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ka('staff_app_link_history',{p_venue:Oe.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ka('revoke_staff_app_link',{p_venue:Oe.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(le.PITCH)return pe.linkPhones();const e=Oe.getState().venueId;if(!e||'staff'!==Oe.getState().kind)return{};try{const t=await Ka('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(le.PITCH)return pe.resetPhone(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ka('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(le.PITCH)return pe.inviteStatus();const e=Oe.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:t,error:a}=await Re().rpc(o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_pairing_code':o.IS_GREENSIDE?'claim_greenside_pairing_code':o.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':o.IS_KIRKTON?'claim_kirkton_pairing_code':o.IS_WILDINGS?'claim_wildings_pairing_code':o.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':o.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await x.kv.set(ba,n),xa(),{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}`}}},i.carPairStart=async function(){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await x.kv.set(Ua,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ea(e)}}},i.carPairPoll=async function(e){try{Te();const t=e??await x.kv.get(Ua,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,G.carPairApproved)(n)){const e=(0,G.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await x.kv.get(ba,null);await x.kv.set(ba,e),await x.kv.remove(ka),O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||xa()}return'revoked'!==i&&'unknown'!==i||await Ta(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Te(),await Re().rpc('car_sign_out')}catch{}await Ta(),await Ma();try{await Re().auth.signOut({scope:'local'})}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ka('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ea(e)}}},i.carList=async function(){const e=Oe.getState().venueId;if(!e)return[];return(await Ka('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ka('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ea(e)}}},i.unpairDisplay=async function(){await x.kv.remove(ba),await Ma();try{await Re().auth.signOut()}catch{}Ae({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await x.kv.remove(ka),await x.kv.remove(Ia),await Ma();try{await Re().auth.signOut()}catch{}Ae({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.'})},i.wipeThisDevice=async function(e={}){try{await Ma()}catch{}try{(0,T.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${o.VENUE_RID}:`)):(0,I.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!o.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Na,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ka}}),i.mendSession=qa,i.startAppSync=async function(e=o.VENUE_RID){if(o.IS_ISOLATED_VENUE&&e!==o.VENUE_RID)return;if(Pe)return;Pe=!0,La=e,'customer'===Ue&&'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Te(),'customer'!==Ue){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ue&&(0,h.isAnchorage)(e)?[H.useStore,ne.useOwner,ae.useKitchen,se.useSafety,Y.useCardStore,m.useGpCalc,X.useOrderSheets,S.useSpecials,A.useHr]:[H.useStore,ne.useOwner,ae.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ue&&(0,h.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ae({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await vs(e)}catch{if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e))return void Ae({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,T.isSupabaseConfigured)())return void Ae({mode:'off'});j.mutationQueue.subscribe(()=>{const e=j.mutationQueue.waiting,t=e[0];Ae({pending:j.mutationQueue.pending.length,failed:j.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,L.describeWrite)(t)}: ${(0,L.plainReason)({...t.lastErr},'retry')}`:void 0})}),j.mutationQueue.onFailed(e=>Ae({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:j.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,L.describeWrite)(e),why:'conflict'===e.reason?(0,L.plainReason)({code:'conflict'},'refused'):(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Ke.push((0,N.onConnectivity)(e=>Ae({mode:e?Oe.getState().venueId?'live':Oe.getState().mode:Oe.getState().venueId?'offline':Oe.getState().mode}))),await Ba()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return za}}),i.stockSaveBlocker=Za,i.stockEventStatus=function(e){if(ze(e))return{state:'saved'};const t=j.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,L.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=Ya,i.saveStockEventsNow=Xa,i.bookingSaveBlocker=ts,i.resendUnsavedBookings=ns,i.saveBookingsNow=is,i.waitForBookingSave=function(e,t=12e3){if(!De())return Promise.resolve({state:'local'});const a=ts();if(a)return Promise.resolve({state:'refused',why:a});const s=as()[0]?.venueId??'',n=()=>es.some(t=>j.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=F.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,N.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(j.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(j.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||as().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||as().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=cs,i.tempLogState=function(){const e=ls()[0]?.venueId??'',t=ls().find(e=>'temp_readings'===e.spec.table),a=j.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!j.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values($.useTempSaves.getState().notSaved),i=se.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=fs,i.waitForTempSave=function(e,t,a=1e4){if(!De()||!ls().length)return Promise.resolve({state:'local'});const s=cs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ls()[0]?.venueId??'',i=ls().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>$.useTempSaves.getState().notSaved[(0,$.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>j.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=_s,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ts}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Es.get(a);if('customer'!==Ue||!(0,T.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Es.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ka('public_day',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:qe(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:qe(a.from_time),to:qe(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Es.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ts.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Es.get(a);e&&!e.ok&&Es.delete(a)}));const n=Es.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Oe.getState().venueId;if(!n||'staff'!==Oe.getState().kind)throw new Error('Connect to your venue first.');const i=await Ka('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});H.useStore.getState().updateRestaurant(e,{...i,id:e})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(fe),ge=t(r[60]),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]);const Re=()=>(0,E.getSupabase)();j.mutationQueue.setExecutor(q.executeMutation),(0,P.setClockServer)(()=>'staff'===Oe.getState().kind);const Oe=(0,U.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ae=e=>Oe.setState(e),Ce=e=>{const t=Oe.getState().perms;return t.includes('*')||t.includes(e)},De=()=>{const e=Oe.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Oe.subscribe(()=>(0,ve.setLiveData)(De()));let Ue=V.IS_CAR?'car':V.APP_VARIANT,Ee=!1;const Te=()=>{Ee||((0,x.setSyncNamespace)(Ue),Ee=!0)};let Ne=[],Ke=[],Pe=!1;const Me=()=>(new Date).toISOString().slice(0,10),xe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),qe=e=>e?e.slice(0,5):'',Le=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))):[],Be=e=>JSON.parse(JSON.stringify(e));function je(e,t){const a=xe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>H.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Be(e);if(t)return{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:Le(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,ie.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:Le(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Fe(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>H.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.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,ie.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Be(e.lines??[]),allergies:Le(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:Be(e.allergyChain??{}),readiness:Be(e.readiness??{}),allergy_ticks:Be(e.allergyTicks??{}),handover_check:e.handoverCheck?Be(e.handoverCheck):null,accepted:e.accepted?Be(e.accepted):null,doc:Be(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)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function $e(e){const t=xe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...J.useBlocks.getState().blocks,...J.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Oe.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:Be(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,J.blockClock)(t.from_time)??a?.from,n=(0,J.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>J.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>J.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let We=null,Qe='Main plan';function He(e){const t=e=>Be({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(z.useFloor.getState().plans[e]??(0,z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Ce('floor.manage')||Ce('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:We??(0,be.uuidFrom)(`plan:${a}`),venue_id:a,name:Qe||'Main plan',is_active:!0,...t(e),updated_by:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>(We=String(e.id),Qe=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,ke.withSeedBest)(e,t[0]):void 0;a&&z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ve(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Z.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Ce('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,ie.isUuid)(e.supplierId)?e.supplierId:(0,be.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),ot.get(t)??t)}:{}};var t},apply:(t,a)=>Z.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Ge=new Set,Je=new Set;j.mutationQueue.onDone(e=>{'stock_events'===e.table&&Je.add(e.rowKey)});const ze=e=>Je.has(e)||Ge.has(e),Ze=()=>Ce('*')||Ce('staff.manage')||Ce('recipes.edit')||Ce('recipes.signoff'),Ye=()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write'));function Xe(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Z.useShellStore.getState().events.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,ie.isUuid)(t.id)&&!!(Z.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('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,ie.isUuid)(e.undoes)&&(ze(e.undoes)||j.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Ge.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)=>Z.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function et(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Z.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={...Z.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Z.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Ge]}}}))},afterRead:()=>{Z.useShellStore.getState().server[e]||Z.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Ge]}}}))},subscribe:()=>()=>{}}}const tt=new Set;function at(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=H.useStore.getState().menu;return Y.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:t=>(0,ie.isUuid)(t.card.id)&&!((0,h.isAnchorage)(e)&&(0,h.isDemoCard)(t.card))&&!(0,h.isPlaceholderCard)(t.card),writable:()=>Ce('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,h.isAnchorage)(e)&&(s={...s,signOff:(0,h.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,h.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,h.isAnchorage)(e)&&(0,h.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,be.photoPath)(a,s),t=st(s.photo);t&&((0,Y.cachePhotoAs)(e,t),nt(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,be.cardToRow)(s,a);return{...i,...r,doc:Be({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,h.isPlaceholderCard)(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,signOff:(0,h.isAnchorage)(e)&&(0,h.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Ce('recipes.edit')&&t.length){const e=new Set(t);Y.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);Y.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&H.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&H.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=Y.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=H.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const st=e=>(0,Y.readLocalPhoto)(e);async function nt(e,t){if(!tt.has(e)){tt.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(be.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){tt.delete(e),Ae({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const it=new Map,rt=(0,U.create)(()=>({n:0}));(0,Y.setStoragePhotoResolver)(e=>{const t=it.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,T.isSupabaseConfigured)()&&'off'!==Oe.getState().mode?(t||(it.set(e,{url:'',at:Date.now()}),Re().storage.from(be.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(it.set(e,{url:t.signedUrl,at:Date.now()}),rt.setState(e=>({n:e.n+1})),Y.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const ot=new Map;const dt=(e,t)=>{const a=(0,ie.isUuid)(t)?t:(0,be.uuidFrom)(`sup:${e}:${t}`);return ot.set(a,t),a};function ut(e){return{name:'order_sheets',table:'suppliers',list:()=>X.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,h.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Ce('suppliers.manage'),toRow:(e,t)=>({id:dt(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:Be(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(ot.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>X.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>X.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,ie.isUuid)(e)?e:(0,be.uuidFrom)(`sup:${Oe.getState().venueId}:${e}`)})}}let ct=!1,lt=!1;const ft=new Map,pt=new Map,gt=new Map,mt=new Map,_t=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',St=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'},ht=(e,t)=>({...e,managerAccess:t}),yt=()=>({nickname:ct,display:lt}),wt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=ht({role:e.role,level:e.level??St(_t(e)).level},!0===e.managerAccess);return(0,B.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},yt())};const vt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},bt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},kt=e=>{const t=ne.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,d.isKitchenTeam)(t)},It=2e3;function Rt(e,t){return t||!e.length||e.length>=It?null:e=>(0,ie.isUuid)(e.id)}function Ot(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,Ce('rota.manage')):null,keepOnEmpty:()=>e&&!Ce('rota.manage'),list:()=>ne.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&ft.has(e.staffId)&&(Ce('rota.manage')||kt(e.staffId)),writable:()=>Ce('rota.manage')||Ce('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(vt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:bt(e.start),end_time:bt(e.end),published:!!e.published,doc:Be(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function At(){const e=xe(62),t=e=>Ce('rota.manage')||e.staffId===Oe.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ne.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&t(e),writable:()=>'staff'===Oe.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=xe(2)&&e.staffId===Oe.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Be(e.breaks??[]),break_mins:e.breakMins??0,doc:Be((0,y.privateAttendance)(o.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,y.privateAttendance)(o.VENUE_RID,{...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Ct(){const e=xe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.staffId===Oe.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Oe.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:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,ie.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:Be({...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Dt(e){ne.leaveRemote.decide=t=>!(!Ce('rota.manage')||!(0,ie.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(j.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Ke.push(()=>{ne.leaveRemote.decide=null})}function Ut(e){ne.timesheetRemote.send=(t,a)=>{if(!Ce('rota.manage')||!(0,ie.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return j.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:Be(s)}}),!0}const s=a;if('attendance_void'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return j.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:Be(s.breaks??[]),p_reason:n,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0},Ke.push(()=>{ne.timesheetRemote.send=null})}function Et(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>H.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Oe.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,ie.isUuid)(a)?a:(0,be.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,ie.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Be(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>H.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=>H.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Tt=e=>H.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Nt(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}));H.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Kt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=H.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Be({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Tt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Ce('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Mt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...Mt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Mt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Pt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Pt=t.feature_flags??{},Mt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Be({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}:{}})},apply:t=>{const a=t[0];a&&(H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,l.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Nt(e,a.events))},subscribe:e=>{const t=H.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Pt=null,Mt=null;const xt=()=>new Date(Date.now()-2592e6).toISOString(),qt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ft.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Lt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?(0,Se.dmId)(t[0],t[1]):null},Bt=()=>Oe.getState().perms.includes('*');function jt(){const e=()=>Oe.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ne.useOwner.getState().chat.filter(e=>(0,ie.isUuid)(e.id)).map(e=>Be({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=>!!qt(t.ch)&&(t.from===e()||Bt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('created_at',xt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=xt(),toRow:(e,t)=>{const a=qt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ft.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=Lt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?pt.get(String(e.from_staff)):'system';return s?Be({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ne.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?pt.get(String(t.from_staff)):'system',i=Lt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ne.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,Se.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,he.soundAllowed)())try{(0,he.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,b.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Ft(e,t,a){const s=Oe.getState();if(!_e.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ft.get(e),i='*'===t?'*':qt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function $t(e){const t=Oe.getState().staffRef,a=t?ft.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Lt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ne.useOwner.getState().chatMarkRead(t,i)}catch{}}function Wt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=C.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Be(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>C.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,D.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Qt(e){const t=xe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>C.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.reminderId)&&e.staffRef===Oe.getState().staffRef,writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>C.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Ht(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Vt=e=>null==e||''===e?null:Number(e),Gt=e=>e.filter(e=>!e.startsWith('data:')),Jt=()=>Ce('takings.view');function zt(e){const t=!Jt();return{name:'cash_ups',table:'cash_ups',list:()=>oe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,v.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,v.tradingDay)()&&!e.onServer),writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,v.tradingDay)()):e.gte('for_date',xe(400)),...t?{inWindow:e=>e.date===(0,v.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:Be(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({cashUps:Ht(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Zt(e){return{name:'sales_reports',table:'sales_reports',list:()=>oe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Be(e.vals),categories:e.categories,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({sales:Ht(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Yt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=oe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,oe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Be({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,oe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>oe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function Xt(e){return{name:'day_tips',table:'day_tips',list:()=>oe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',xe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>oe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ea(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>oe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Vt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>oe.useCashUp.setState(s=>({pot:Ht(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function ta(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=oe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Ce('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>oe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function aa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>re.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Be(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>re.useNotifs.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>re.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function sa(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=de.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Be(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>de.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ue.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Ht(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function na(e){const t=()=>Ce('venue.settings')||Ce('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>de.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,ie.isUuid)(a.id)&&(0,ie.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,de.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Oe.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Oe.getState().staffRef)||null,doc:Be(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ia(e){const t=xe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>de.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Be(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({history:Ht(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function ra(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=ce.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Be(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&ce.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,y.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>ce.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function oa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=ge.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,ge.libraryRowId)(e),kind:'library',doc:Be({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,ge.personRowId)(e,i),kind:'person',staffRef:i,doc:Be({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ne.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,me.canEditTasks)(t,a)},writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>ge.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,ge.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function da(e){const t=xe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>ge.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Oe.getState();return e.byRef===t.staffRef||Ce('staff.manage')},writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>ge.useDailyTasks.setState(s=>({ticks:Ht(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ua(e,t=!1){const a=xe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>ye.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind||Ce('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,be.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>ye.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>ye.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{we.autoSync.soldOutRead.add(e)}}}function ca(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>we.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:(0,be.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>we.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>we.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{we.autoSync.linksRead.add(e)}}}async function la(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&x.kv.get(a,!1):(x.kv.set(a,!0),!0)}catch{return x.kv.get(a,!1)}}async function fa(){const e=Oe.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();ma.setState({live:!!t?.push_live,known:!0})}catch{}}const pa='order-list-logos';const ga=new Map;const ma=(0,U.create)(()=>({live:!1,known:!1}));async function _a(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('reminders:ok',!1):(x.kv.set('reminders:ok',!0),!0)}catch{return x.kv.get('reminders:ok',!1)}}async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('chat:ok',!1):(x.kv.set('chat:ok',!0),!0)}catch{return x.kv.get('chat:ok',!1)}}const ha=(e,t)=>Be({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),ya='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function wa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>A.useHr.getState().questions.filter(t=>t.venue===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ha(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);A.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>A.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function va(e,t){const a=(t,a,s)=>{j.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(A.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(ya).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||A.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ha(e,t)))}catch{}}}),Ke.push(()=>{Object.assign(A.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ba='pair:v1',ka='staff:v1',Ia='staff:rejoin:v1';async function Ra(e){const t=o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_invite':o.IS_GREENSIDE?'claim_greenside_invite':o.IS_ABBOTSFORD?'claim_abbotsford_invite':o.IS_KIRKTON?'claim_kirkton_invite':o.IS_WILDINGS?'claim_wildings_invite':o.IS_KIRKMICHAEL?'claim_kirkmichael_invite':o.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ue,p_device:(0,O.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,O.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Oa(){if('display'===Ue||'customer'===Ue||le.PITCH)return'none';const e=await x.kv.get(Ia,null);if(!e)return'none';try{await Ca();const{data:t,error:a}=await Ra(e);if(a)return(0,I.inviteRefusal)(a.message)?(await x.kv.remove(Ia),await x.kv.remove(ka),'refused'):'offline';const s=t?.[0];return s?(await x.kv.set(ka,{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,displayName:s.display_name}),'ok'):(await x.kv.remove(Ia),'refused')}catch{return'offline'}}const Aa=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Ca(){Te();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ae({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 Da(e){if(le.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,I.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Ra(e);if(a){const e=(0,I.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,o.venueKey)(`cc-pending-invite:${Ue}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),await x.kv.set(Ia,e),Pe&&xa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ae({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ua='car:request:v1',Ea=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Ta(){await x.kv.remove(ba),await x.kv.remove(ka),await x.kv.remove(Ua),O.useSession.getState().meId&&O.useSession.getState().signOut()}async function Na(){if(!(0,T.isSupabaseConfigured)())return!1;try{return await Ca(),!0}catch{return!1}}const Ka=async(e,t={})=>{if(le.PITCH)return(0,fe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Pa=null;async function Ma(){for(const e of Ke)try{e()}catch{}Ke=[],Ne.forEach(e=>e.stop()),Ne=[],Pa&&(clearInterval(Pa),Pa=null)}async function xa(){await Ma(),await Ba()}async function qa(){if(!(0,T.isSupabaseConfigured)()||'customer'===Ue||le.PITCH)return!1;try{Te();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ue)return!1;if(!await x.kv.get(Ia,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Oa()&&(xa(),!0)}catch{return!1}}(0,u.setSessionMender)(qa);let La=o.VENUE_RID;async function Ba(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=La;try{if(Ae({mode:'connecting'}),await j.mutationQueue.load(),'customer'===Ue)return void await Ha(e);let t=await x.kv.get(ba,null),a=await x.kv.get(ka,null);if(V.IS_CAR&&!t&&a){const e=(0,G.migrateCarStaffIdentity)(a);e&&(t=e,await x.kv.set(ba,t)),await x.kv.remove(ka),a=null,O.useSession.getState().meId&&O.useSession.getState().signOut()}if(o.IS_ISOLATED_VENUE&&(t&&!(0,o.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,o.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ae({mode:'display'===Ue?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ue&&!V.IS_CAR&&a&&!s.session){const t=await Oa();if('offline'===t)return Ae({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{La===e&&xa()},6e4);'refused'===t&&a.staffRef&&O.useSession.getState().meId===a.staffRef&&O.useSession.getState().signOut(),a=await x.kv.get(ka,null),({data:s}=await Re().auth.getSession())}const n='display'===Ue||V.IS_CAR?t:a;if(!s.session||!n)return void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ka('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ue||V.IS_CAR?await x.kv.remove(ba):(await x.kv.remove(ka),await x.kv.remove(Ia)),'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId===n.staffRef&&O.useSession.getState().signOut(),void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ue?'This display was unpaired by a manager.':V.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,N.isOnline)()||/fetch|network/i.test(String(t?.message)))Ae({mode:'offline'});else if(Aa(t)&&'display'!==Ue){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Oa()&&setTimeout(()=>{La===e&&xa()},500)}i=Oe.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ae({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!V.IS_CAR&&'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId!==n.staffRef&&(O.useSession.getState().signIn(n.staffRef),ne.useOwner.setState({staffAs:n.staffRef})),V.IS_CAR&&(O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({previewRole:'owner'})),await Fa(n.venueId,e,n.kind)}catch(e){Ae({mode:'local',lastError:String(e?.message??e)})}}const ja=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','venue_reminders','reminder_done']);async function Fa(e,a,s){if(!(0,o.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||V.IS_CAR&&'device'===s;await _s(a),Ke.push(Us(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])gt.set(e.key,e.id),mt.set(e.id,e.key)}catch{}const i=[Kt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ne.useOwner.getState().staff.map(wt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Ce('staff.manage'),deletes:!1,revision:e=>(0,B.staffRevision)(e,yt()),toRow:(e,t)=>(0,B.staffRow)(e,t,yt(),e.managerAccess||e.ownerAccess?null:gt.get(_t(e))),fromRow:e=>{if(!e.external_ref)return null;ft.set(String(e.external_ref),String(e.id)),pt.set(String(e.id),String(e.external_ref)),Os.set(String(e.external_ref),e.avatar_path??null);const t=ht(St(mt.get(String(e.role_id))),!0===e.manager_access);return(0,B.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},yt())},apply:e=>ne.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=>ne.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ds()},onRemote:()=>{Ds()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ne.useOwner.getState(),t=te.useSetup.getState().sites[La]?.staffGrade??{};return e.staff.filter(e=>ft.has(e.id)).map(a=>Be({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=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ft.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=pt.get(String(e.staff_id));return t?Be({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=>ne.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=te.useSetup.getState().sites[La],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&&te.useSetup.getState().patch(La,{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=ne.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=te.useSetup.subscribe((t,a)=>{t.sites[La]?.staffGrade!==a.sites[La]?.staffGrade&&e()});return()=>{t(),a()}}},je(a,!1),je(a,!0),$e(a),He(a),Fe(a),Ve(a),Xe(a),et(a),ut(a),{name:'supplier_directory',table:'suppliers',list:()=>ne.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('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:Be(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ne.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId),writable:()=>Ce('suppliers.order')||Ce('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||Me(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Be(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},at(a),ks(a)];Ce('wages.view')&&i.push(Is(a)),n&&(i.push(Ot(!0),At(),Ct(),Et(a)),Ut(e)),n&&await la('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Oe.getState().staffRef&&'pending'===e.status||Ce('rota.manage')),writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Be(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),ja.add('staff_leave'),Dt(e));const d=n&&await Sa();if(_e.useChatSync.setState({synced:d,checked:!0}),Ke.push(()=>_e.useChatSync.setState({synced:!1})),d&&i.push(jt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(Se.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ft.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ft.get(e.id),include:e.include}),fromRow:e=>{const t=pt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>Se.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=>Se.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await la('hr_questions')&&(i.push(wa(a)),ja.add('hr_questions'),va(e,a)),'guest'!==s&&'customer'!==Ue&&await la('temp_readings')&&(i.push((0,W.tempUnitsSpec)(se.useSafety,Ze),(0,W.tempReadingsSpec)(se.useSafety,Ye)),ja.add('temp_units'),ja.add('temp_readings')),'guest'!==s&&await la('sold_out_items')?(i.push(ua(a,await la('sold_out_items','auto'))),ja.add('sold_out_items')):we.autoSync.soldOutRead.add(a),'guest'!==s&&await la('sold_out_links')?(i.push(ca(a)),ja.add('sold_out_links')):we.autoSync.linksRead.add(a),C.useReminders.getState().ensure(a),'guest'!==s&&await _a()&&(i.push(Wt(a)),n&&i.push(Qt(a))),re.useNotifs.getState().ensure(a),de.useOrderLists.getState().ensure(a),n){ct=await la('staff','nickname'),lt=await la('staff','display_clock');const[e,t,s,n]=await Promise.all([la('scheduled_notifications'),la('order_lists'),la('venue_clock_area'),la('daily_tasks')]);ge.useDailyTasks.getState().ensure(a),n&&(i.push(oa(a),da(a)),ja.add('daily_tasks'),ja.add('daily_task_ticks')),e&&(i.push(aa(a)),fa()),t&&i.push(sa(a),na(a),ia(a)),s&&i.push(ra(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&ja.add(n)}if('guest'!==s&&await la('day_tips')){i.push(Xt(a));for(const e of['day_tips','tips_pot_events','tips_settings'])ja.add(e);await la('tips_pot_events')&&i.push(ea(a),ta(a)),n&&(Jt()||(0,oe.forgetPastTakings)(a,(0,v.tradingDay)()),i.push(zt(a),Yt(a)),ja.add('cash_ups'),Jt()&&(i.push(Zt(a)),ja.add('sales_reports')),t(r[72])(r[71],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Ot(),At()),await la('scheduled_notifications')&&i.push(aa(a)));let u=!1;const c=()=>{if(V.IS_CAR&&n&&Ce('recipes.edit'))return!0;const e=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);return!!e&&e.active&&Ce('recipes.edit')&&(0,_.costsAllowedFor)(e)};n&&c()&&await la('ingredient_prices')&&(i.push((0,m.gpSyncSpec)('ing',c)),ja.add('ingredient_prices'),await la('card_costs')&&(i.push((0,m.gpSyncSpec)('card',c)),ja.add('card_costs')),await la('kitchen_deliveries')&&(i.push((0,m.gpSyncSpec)('del',c)),ja.add('kitchen_deliveries')),await la('kitchen_stock_counts')&&(i.push((0,m.gpSyncSpec)('count',c)),ja.add('kitchen_stock_counts'))),(0,Ie.specialsSyncOn)()&&'guest'!==s&&await la('specials_boards')&&(i.push((0,Ie.specialsBoardSpec)(a,()=>Ce('recipes.edit')||Ce('floor.manage')||Ce('*'))),ja.add('specials_boards'));const l={onActivity:()=>Ae({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ae({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ae({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Ka('whoami')??[]).some(t=>t.venue_id===e))return void(La===a&&xa());for(const a of Ne){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||F.useBookingSaves.getState().mark({id:t,table:e,why:ts()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||$.useTempSaves.getState().mark({id:t,table:e,why:cs(e)??'this screen could not send it'})}};Ne=i.map(t=>new Q.EntityBridge(t,e,l)),await Promise.all(Ne.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,N.isOnline)())try{const t=await Ka('whoami');if(!t?.some(t=>t.venue_id===e))return void(La===a&&xa())}catch(e){if(Aa(e)){if(V.IS_CAR)return void(La===a&&xa());const e=await Oa();return void('ok'!==e&&'refused'!==e||La===a&&xa())}}let t=0;for(const[a,s]of Ne.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(_e.useChatSync.getState().error&&_e.useChatSync.setState({error:void 0}),await $t(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&_e.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({mode:'live',lastSyncAt:e,lastServerAt:e}),j.mutationQueue.flush()}else Ae({mode:'offline'});if(!Ce('wages.view')){const e=Oe.getState().staffRef;ne.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const S=new Map;for(const e of Ne)S.set(e.spec.table,[...S.get(e.spec.table)??[],e]);const h=[...S.keys()].filter(e=>ja.has(e)).map(e=>({table:e,venueColumn:S.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,Q.venueChannel)(e,h,(e,t,a)=>{for(const s of S.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ae({lastSyncAt:s,lastServerAt:s})},e=>{Ae({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Ke.push(()=>{Re().removeChannel(w)}),Ke.push((0,N.onConnectivity)(e=>{e&&p()}));const b=Ne.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,K.superviseSync)({fastMs:Wa(Ue),readFast:async()=>{for(const e of b)await e.read()},readAll:p,flush:()=>{j.mutationQueue.flush()},wake:()=>{j.mutationQueue.retryNow()},restart:()=>{La===a&&xa()},realtime:()=>Oe.getState().realtime,lastServerAt:()=>{const e=Oe.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Aa,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>$a(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Ke.push(k.stop)}async function $a(e){const t=Oe.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ka('sync_heartbeat',{p_venue:e,p_device:(0,O.deviceId)()??'unknown',p_app:Ue,p_version:M.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Wa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Oe.getState(),queue:j.mutationQueue.pending.map(e=>e.table),failedTables:j.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),le.PITCH&&(window.__ccSyncPreview=e=>Ae(e)));const Qa='guest:sent:v1';async function Ha(e){Ae({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ka('public_venue',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!o.IS_ISOLATED_VENUE||t.id===o.VENUE_UUID)){Ae({venueId:t.id,venueName:t.name}),await _s(e);const a=t.app?.restaurant;a&&H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,l.withWildingsAddress)({...a,id:e}):t)})),Nt(e,t.app?.events)}await Va(e),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ae({mode:(0,N.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Va(e).catch(()=>{})},6e4);Ke.push(()=>clearInterval(t)),o.IS_ISOLATED_VENUE||await Ga(e)}async function Va(e){const t=await Ka('public_menu',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));Y.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&H.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))]}})}async function Ga(e){let t=await x.kv.get(Qa,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=H.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Na())return;for(const a of n)try{const s=(await Ka('guest_create_booking',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_booking:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(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&&H.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'},Ae({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ka('guest_create_takeaway',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_order:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ae({lastError:`Order: ${e?.message}`}))}await x.kv.set(Qa,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ka('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await x.kv.set(Qa,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ka('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));H.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 Ja(n)===Ja(e)?e:n})})),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ae({mode:(0,N.isOnline)()?Oe.getState().mode:'offline'})}finally{a=!1}}};Ke.push(H.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Pa=setInterval(()=>{n()},15e3),n()}const Ja=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),za={bridges:()=>Ne,restart:xa};function Za(){const e=Oe.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Ce('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function Ya(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(!e||Za())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(j.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function Xa(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}Ya();try{await j.mutationQueue.retryNow()}catch{}}Oe.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{Xa()},3e3)});const es=['bookings','walk_ins'];function ts(){const e=Oe.getState();return De()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const as=()=>Ne.filter(e=>es.includes(e.spec.table)),ss=e=>j.mutationQueue.failed.some(t=>es.includes(t.table)&&t.rowKey===e);function ns(e=!1){return ts()?0:as().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ss(t)&&!!F.useBookingSaves.getState().notSaved[t]),0)}async function is(e=!1){const t=ts();if(t)return t;for(const e of as())try{await e.read()}catch{}ns(e);try{await j.mutationQueue.retryNow()}catch{}return e&&rs(),null}function rs(){const e=as()[0]?.venueId??'',t=F.useBookingSaves.getState(),a=new Set(as().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ss(s)||es.some(t=>j.mutationQueue.hasPending(t,e,s))||t.clear(s)}j.mutationQueue.onFailed(e=>{es.includes(e.table)&&F.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{es.includes(e.table)&&F.useBookingSaves.getState().clear(e.rowKey)});let os=null;const ds=(e=2500)=>{os&&clearTimeout(os),os=setTimeout(()=>{os=null,is(!1)},e)};(0,N.onConnectivity)(e=>{e&&ds()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ds(3e3)});const us=['temp_readings','temp_units'];function cs(e="temp_readings"){const t=Oe.getState();return De()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ze()?'device'!==t.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ls=()=>Ne.filter(e=>us.includes(e.spec.table));async function fs(e=!1){const t=cs();if(t)return t;for(const e of ls())try{await e.read()}catch{}const a=ls()[0]?.venueId??'';for(const t of ls())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,j.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await j.mutationQueue.retryNow()}catch{}if(e){const e=$.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ls().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||j.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,$.tempKey)(t.table,t.id))}}return null}j.mutationQueue.onFailed(e=>{us.includes(e.table)&&$.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{us.includes(e.table)&&$.useTempSaves.getState().clear((0,$.tempKey)(e.table,e.rowKey))});let ps=null;const gs=(e=3e3)=>{ps&&clearTimeout(ps),ps=setTimeout(()=>{ps=null,fs(!1)},e)};(0,N.onConnectivity)(e=>{e&&gs()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&gs(3500)});const ms='golive:v1:';async function _s(e){'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)?await vs(e):(await x.kv.get(ms+e,!1)||await vs(e),await x.kv.get(ys+e,!1)||(ws(e),await x.kv.set(ys+e,!0)),await x.kv.get(Ss+e,!1)||(hs(),await x.kv.set(Ss+e,!0)))}const Ss='golive:v3:';function hs(){const e=e=>JSON.stringify(e).includes('(example)');try{ae.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ys='golive:v2:';function ws(e){const t=e=>JSON.stringify(e).includes('(example)');H.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)))})),ne.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 vs(e){if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)){const t=(0,p.stripCoreLiveSamples)(H.useStore.getState()),a=(0,ae.stripKitchenExamples)(ae.useKitchen.getState()),s=ne.useOwner.getState(),n=(0,p.stripOwnerLiveSamples)(s),i={accidents:se.useSafety.getState().accidents.filter(e=>!(0,se.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(H.useStore.getState(),t)&&(await(0,g.archiveChefCache)('core',H.useStore.getState()),H.useStore.setState(t)),r(ae.useKitchen.getState(),a)&&(await(0,g.archiveChefCache)('kitchen',ae.useKitchen.getState()),ae.useKitchen.setState(a)),r(s,n)&&(await(0,g.archiveChefCache)('owner',s),ne.useOwner.setState(n)),r(se.useSafety.getState(),i)&&(await(0,g.archiveChefCache)('safety',se.useSafety.getState()),se.useSafety.setState(i));const o=(0,A.stripHrSamples)(A.useHr.getState());r(A.useHr.getState(),o)&&(await(0,g.archiveChefCache)('hr',A.useHr.getState()),A.useHr.setState(o));const d=(0,m.stripGpSamples)(m.useGpCalc.getState());r(m.useGpCalc.getState(),d)&&(await(0,g.archiveChefCache)('gp',m.useGpCalc.getState()),m.useGpCalc.setState(d));const u=X.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,g.archiveChefCache)('order-sheets',u),X.useOrderSheets.setState(c));const l=Y.useCardStore.getState(),_={cards:l.cards.filter(e=>!(0,f.isLiveVenue)(e.restaurantId)||!(0,h.isDemoCard)(e)),log:l.log.filter(e=>!(0,h.demoActor)(e.by))};return r(l,_)&&(await(0,g.archiveChefCache)('recipe-cards',l),Y.useCardStore.setState(_)),void await x.kv.set(ms+e,!0)}const t=t=>t.restaurantId===e&&!(0,ie.isUuid)(t.id);H.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)))})),J.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,ie.isUuid)(t.id))})),z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ne.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,ie.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,ie.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,ie.isUuid)(e.id)),leave:e.leave.filter(e=>(0,ie.isUuid)(e.id)),swaps:[]}));try{ae.useKitchen.setState(e=>(0,ae.stripKitchenExamples)(e))}catch{}ne.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,ie.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId))}));try{se.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await x.kv.set(ms+e,!0)}const bs=(e,t)=>Be({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function ks(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(z.useFloor.getState().live[e]??{}).map(([e,t])=>bs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Oe.getState().kind||Ce('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:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>bs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>z.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=>z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Is(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(te.useSetup.getState().sites[e]?.grades??te.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:()=>Ce('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=te.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));te.useSetup.getState().patch(e,{grades:i})},subscribe:t=>te.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Rs='staff-avatars',Os=new Map;let As=!1;const Cs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ds(){if(!As){As=!0;try{for(const[e,t]of Os){const a=ee.useAvatars.getState().photos[e];if(!t){a?.path&&ee.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Oe.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Rs).download(t);if(n||!s)continue;const i=await Cs(s);i.startsWith('data:image/')&&ee.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{As=!1}}}function Us(e){const t=async()=>{const t=Oe.getState().staffRef,a=t?ft.get(t)??Oe.getState().staffUuid:void 0;if(!t||!a||'staff'!==Oe.getState().kind)return;const s=ee.useAvatars.getState().photos[t];try{const n=Os.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Rs).remove([t]).catch(()=>{})};if(!s){const e=!!ee.useAvatars.getState().clears?.[t];return e&&n&&(await Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}),Os.set(t,null),i(n)),void(e&&ee.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ae({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Rs).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ka('set_staff_avatar',{p_staff_ref:t,p_path:d}),Os.set(t,d),n!==d&&i(n),ee.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ae({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ee.useAvatars.getState().photos},s=ee.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Ce('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Oe.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Os.set(t,null),ee.useAvatars.getState().doneClear(t),Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Rs).remove([e])).catch(()=>{})}});return t(),s}const Es=new Map,Ts=(0,U.create)(()=>({n:0}))},987,[5,988,932,6,832,837,833,838,989,993,994,835,996,998,999,1000,1001,1002,13,1003,1005,1008,1009,846,933,976,1010,1011,1012,1015,977,1016,1014,1019,1013,1020,1021,1022,1023,831,872,1024,1025,1028,983,883,1030,926,927,1032,1033,891,870,1035,1038,1039,1040,1041,2,1042,1043,1044,1045,1046,1047,979,981,884,863,859,1048,1051,1052]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},989,[837,34,838,5,839,846,849,990,863,870,991,992]); -__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},990,[984]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},991,[990]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},992,[990,991]); -__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},993,[]); -__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},994,[835,837,838,5,839,846,849,995,831,884]); -__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'}}]},995,[]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},996,[6,997]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},997,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},998,[846]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},999,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1000,[846]); -__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1001,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1002,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1003,[839,846,849,5,872,1004,15,1002]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1004,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1005,[838,835,837,5,839,846,849,1006,870]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1007,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1008,[839,846,849,863,1009,870]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1009,[]); -__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)))},1010,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1011,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1012,[34,1013]); -__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1013,[1010,977,1014]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1014,[1010]); -__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.3.12.171'},1015,[]); -__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1016,[1017,1018,933,977,1013]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1018,[977]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1019,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1020,[846,849,839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1021,[846,849,839]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1022,[1023]); -__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1023,[1017,933,1010,977,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1024,[]); -__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1025,[860,839,870,846,849,858,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1026,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1027,[891,1003,1026]); -__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1028,[5,860,839,1029,846,849,859]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1029,[1007]); -__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1030,[837,838,5,839,846,849,1031]); -__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1031,[984]); -__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1032,[837,984,838,835,5,839,846,849]); -__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1033,[837,838,5,839,846,849,1034]); -__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1034,[]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1035,[839,846,849,863,1036,15,870,1037]); -__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1036,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1037,[]); -__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1038,[34,839,846,849,863,13,870]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1039,[839,846,849,863,1040,870,1037]); -__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1040,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1041,[5,996,839,846,849,997]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1042,[1038]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1043,[839,846,849,863,1044,870]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1044,[]); -__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},1045,[846]); -__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(':')}`},1046,[839,846,849]); -__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{}}},1047,[236,872]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1048,[994,1049,1050,976,933]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1049,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1050,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1051,[933,987,998]); -__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1052,[1053]); -__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1053,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1054,[34]); -__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1055,[34,236,402,102,846,821,794,1054,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1056,[34,102,794,1057,821,1058,25]); -__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1057,[827,34,379,236,402,102,821,987,1058,2,872,1015,5,796,797,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1058,[1059,933,987,872,236]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1059,[]); -__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1060,[827,796,34,402,102,794,821,1043,1044,1009,1000,870,891,25]); -__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1061,[828,1062,796,827,34,281,283,364,336,402,102,426,794,821,1038,831,13,1063,1064,1000,1074,1079,1080,1083,1084,1085,1092,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1062,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1063,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1064,[34,876,1065,1066,1063]); -__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1065,[839,846,849]); -__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1066,[6,1067,1068,1069,1070,1071,1072,1073,3]); -__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1067,[]); -__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1068,[]); -__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1069,[]); -__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1070,[]); -__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1071,[]); -__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1072,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1073,[1063]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1074,[236,933,987,1075]); -__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})},1075,[499,1076,1078,1077]); -__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1076,[499,1077,1078]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1077,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1078,[1077]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1079,[933,987]); -__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1080,[34,281,236,102,794,1038,13,1081,821,1082,25]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1081,[13]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1082,[]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1083,[827,2,34,102,794,821,1038,891,13,987,1000,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1084,[13]); -__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1085,[34,1062,281,402,102,794,1086,1087,1091,1092,821,25]); -__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1086,[34,402,102,794,821,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1087,[837,34,874,891,858,872,1024,987,1088,1003,15,1090]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1088,[1089]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1089,[1090]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1090,[858]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1091,[34,872,1092,858,987,933]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1092,[]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1093,[34,1094,891,1008,1009,1000,1046,831,1097]); -__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1094,[996,1041,891,997,1095,1096]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1095,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1096,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1097,[]); -__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1098,[34,986,402,102,1099,794,874,1100,858,1101,821,25]); -__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)'}})]})}},1099,[34,281,283,364,102,1047,821,25]); -__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1100,[861,859]); -__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1101,[34,402,102,794,1100,858,821,25]); -__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1102,[34,102,794,874,877,821,25]); -__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1103,[860,34,102,794,874,1025,1028,1104,1105,877,821,25]); -__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1104,[1028,859,1100]); -__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1105,[860,877]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1106,[860,34,102,794,874,983,891,1100,858,821,25]); -__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1107,[828,827,1055,34,336,379,236,402,102,794,821,1039,1040,1000,1108,1109,987,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1108,[1075,236]); -__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1109,[839,846,849]); -__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1110,[827,996,34,379,402,102,794,821,1035,1036,891,1039,1040,1041,997,1095,987,1058,1000,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1111,[34,1035,891,1039,1112,1008,831,1036,1000,1093]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1112,[846]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1113,[996,34,1041,891,831,997,1009,1095,1000,1094]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1114,[860,34,1000,874,1100,1047]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1115,[860,1116,34,102,794,874,1100,821,1117,1106,1118,1139,1142,1098,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1116,[34,102,14,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1117,[821]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1118,[34,102,1119,821,1120,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1119,[860,1104]); -__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1120,[1121,860,34,1122,987,1124,402,102,874,1028,1119,1123,821,858,794,1125,1025,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1121,[34,859,821,794,25]); -__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1122,[34,402,102,874,1123,1124,987,1020,821,1120,794,25]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1123,[860,1104]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1124,[281,236]); -__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1125,[827,1126,1127,860,867,14,1128,1129,34,859,402,102,872,1087,874,1130,1104,858,821,864,794,1028,1025,1131,1132,1137,1106,1100,1138,1123,1122,25]); -__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1126,[34,402,412,102,1127,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1127,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1128,[34,102,794,25]); -__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1129,[34,236,402,295,102,426,821,794,1000,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1130,[878,858,877]); -__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1131,[34,402,102,878,858,821,794,25]); -__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1132,[860,877,34,102,879,1133,1134,1136,794,874,1028,983,861,867,872,1100,821,25]); -__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1133,[34,402,821,794,25]); -__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1134,[828,860,1135,34,281,236,102,1028,1104,821,794,1106,859,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1136,[34,402,102,874,861,863,821,794,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1137,[1127,1119,1123]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1138,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1139,[1140,34,102,874,1028,1123,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1140,[34,102,874,1028,1119,1141,1123,821,1003,891,872,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1141,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1142,[34,1062,1126,102,874,1028,1025,876,872,1137,861,1003,891,1026,1119,821,858,1131,1116,1128,1143,14,1140,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1143,[34,102,874,872,1137,14,1124,821,794,25]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1144,[34,102,794,1062,1092,1145,1091,1085,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1145,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1146,[34,102,794,827,1033,891,835,1147,821,1148,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1147,[1034]); -__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1148,[34,402,102,1124,987,1149,1021,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1149,[933,976,1010,1018,1013,1016,1150,1151,1152,1153,1154,1155,977]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1150,[1018,933,1016]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1151,[1018,933,976,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1152,[1010,976,1151,1013,1016,1150]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1153,[933,977]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1154,[34,1013]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1155,[933]); -__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1156,[30,34,426,102,846,872,1087,1157,25]); -__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1157,[839,846,849]); -__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()},1158,[1159]); -__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1159,[1160,858,884]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1160,[1161,877,1162,878,858,884,1163]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1161,[858]); -__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'},1162,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1163,[858]); -__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1164,[978,34,835,402,102,874,891,1165,1160,794,821,1087,1158,1032,15,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1165,[34,102,794,874,1038,884,1166,831,13,1163,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1166,[34,884]); -__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1167,[34,402,102,794,867,821,1159,1158,1164,1032,25]); -__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1168,[34,402,102,794,874,1160,858,821,1169,1165,1164,25]); -__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1169,[828,34,283,364,236,102,426,797,794,827,821,1170,25]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1170,[]); -__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1171,[827,984,1172,835,860,1173,1174,34,402,295,102,794,874,882,1175,891,993,861,867,1178,858,821,1179,1112,1087,1159,1158,1180,869,1164,1032,925,1181,1003,987,1184,988,1097,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1172,[1158,984]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1173,[827,34,102,794,874,979,891,980,981,982,831,821,25]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1174,[]); -__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1175,[827,796,34,336,402,102,821,794,874,1176,1055,882,861,863,885,1108,1177,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1176,[]); -__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1177,[827,796,34,336,236,402,102,794,831,989,861,990,993,891,1003,882,821,930,991,25]); -__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])},1178,[858]); -__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1179,[928,828,827,837,5,34,1055,336,402,102,794,891,858,821,1087,1024,925,1046,1045,987,1112,1097,25]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1180,[828,34,102,794,876,831,869,821,925,25]); -__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1181,[928,828,34,395,236,402,102,925,794,926,891,1182,927,831,5,1183,987,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1182,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1183,[933,976,987,977]); -__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1184,[34,402,102,794,891,988,1097,993,987,1090,858,1124,821,25]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1185,[1172,984,34,379,102,794,891,993,867,821,1087,1164,1032,1186,25]); -__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1186,[827,835,984,34,379,236,402,102,794,1030,983,985,867,1031,821,1164,25]); -__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1187,[984,872,34,986,1188,336,402,102,1189,794,985,983,1030,821,874,1100,858,1124,987,25]); -__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1188,[5,822,823,828,236,826]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1189,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1190,[827,1030,1172,984,34,402,102,794,891,867,821,1164,1032,25]); -__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1191,[827,34,402,102,794,796,989,874,863,990,991,821,930,1192,1196,1177,25]); -__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1193,[1194,933,987,872,2,1195,1074]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1194,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1195,[]); -__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1196,[34,102,797,794,989,874,992,821,930,1177,1197,25]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1197,[]); -__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1198,[827,1199,34,402,102,426,794,891,867,858,821,1200,1087,1064,25]); -__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:d,accent:u,children:a,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:d?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:u??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:u??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,a]});return d?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:d,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const d=e.key===n,u=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.note??String(u)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:d?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(u?2:0,e.a/t*c),backgroundColor:d?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,d=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',u=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,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1200,[34,402,102,794,821,5,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1201,[860,1101,1098,1116,34,102,846,794,874,1100,878,877,858,821,1106,1202,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1202,[34,794,874,1203,25]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1203,[379]); -__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1204,[827,1062,1199,34,1205,236,402,426,102,1207,1208,1209,794,831,891,867,1063,821,930,1217,1200,1087,1064,1210,872,1211,1215,25]); -__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1205,[34,402,102,1206,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1206,[34,797,25]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1207,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1208,[34,102,794,827,891,867,1207,821,25]); -__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1209,[827,1207,34,402,102,794,925,891,1097,858,821,1200,1087,1210,872,1211,1212,1214,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1210,[1062,1084,1092]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1211,[34,102,794,891,1038,1062,1092,1086,1210,821,872,1209,1085,1087,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1212,[1063,1213]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1213,[1063,1207]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1214,[34,102,794,827,1062,1063,1212,1124,821,1215,25]); -__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1215,[1062,34,402,102,794,827,891,1213,1063,1216,1124,821,1204,1087,1207,1212,1064,25]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1216,[]); -__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1217,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1179,1200,1087,1064,1159,987,1038,1061,13,1084,1063,2,25]); -__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1218,[828,891,1219,1199,1005,1006,34,1012,1013,236,402,295,102,794,874,1097,1209,1181,1220,1089,5,1221,1160,867,858,821,1200,1179,1087,925,1041,996,997,1094,1000,1096,1165,1163,1212,1214,1090,25]); -__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1219,[827,34,402,102,794,821,891,831,876,1005,1006,25]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1220,[34,102,794,891,1089,821,1097,25]); -__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1221,[34,402,102,794,891,858,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1222,[34,102,794,891,821,1087,1090,1220,1097,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1223,[34,102,1087,821,794,25]); -__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1224,[827,1062,34,402,102,794,1033,821,930,25]); -__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1225,[827,796,1226,1148,835,891,34,336,402,102,794,1033,1034,821,925,930,1227,1230,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1226,[34,1033,891,835]); -__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1227,[828,1062,796,827,1226,835,891,34,336,402,102,797,794,925,1033,1034,1228,821,930,1229,25]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1228,[]); -__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1229,[831,891,5]); -__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1230,[34,1062,379,236,102,794,891,1033,1229,1034,1231,821,930,1226,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1231,[1034]); -__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1232,[34,402,102,794,994,861,995,821,930,1233,25]); -__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1233,[828,34,336,395,402,295,102,1234,794,994,861,995,858,821,1048,25,1236]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1234,[34,1235,102,861,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1235,[2,987]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1236,[]); -__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1237,[860,1057,34,236,402,102,797,874,821,794,1238,1129,1239,25]); -__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1238,[860,34,380,236,402,102,36,821,794,796,1129,874,25,277]); -__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1239,[1240,1241,1243,1242,1244,1047,1245]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1240,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1241,[839,5,846,849,872,1047,1242]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1242,[860,236,872,1240]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1243,[34,874,861,869,867,1241,1240]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1244,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1245,[34,1241,987,933]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1246,[34,402,102,426,874,861,821,794,1237,1129,1247,25]); -__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1247,[34,102,426,874,861,1239,1047,821,794,1129,25]); -__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1248,[34,236,402,102,879,794,821,1000,1249,1250,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1249,[872,6,933,976,1000,1239,1250]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1250,[839,1251,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1251,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1252,[34,872,1249]); -__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1253,[827,796,1226,835,984,34,931,1205,395,236,402,295,102,846,794,861,1034,867,882,1033,821,1164,1158,1185,932,25]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1254,[34,402,346,102,426,821,1206,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1255,[30,34,792,872,25]); -__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1256,[860,1126,877,30,34,1257,1001,102,14,1128,1137,794,861,867,1130,858,874,987,821,1203,864,1025,1028,1104,1132,1100,1258,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1257,[827,34,236,102,25]); -__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1258,[34,402,102,878,858,1062,1259,821,794,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1259,[1062]); -__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:"ok",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"})]})]})}},1260,[30,34,336,102,1234,1261,794,861,867,874,882,821,25]); -__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])},1261,[30,34,402,874,821,794,25]); -__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1262,[30,34,794,1263,874,1248,25]); -__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])},1263,[34,402,821,794,25]); -__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1264,[837,30,34,1265,794,867,874,821,1266,1270,25]); -__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:x=!0,onPaid:f,title:g="Pay"}){const y=(0,o.useGiftCards)(b).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),_=y.find(e=>e.code===m),v=_?Math.min(_.balance,p):0,R=p-v;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:g,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),x&&y.length>0?(0,h.jsxs)(l.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:!m,onPress:()=>w(void 0)}),y.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,h.jsxs)(l.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)})]}),v?(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.ok,children:["\u2212",(0,n.gbp)(v)]})]}):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)})]})]}),T?(0,h.jsx)(t.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),f({giftCardCode:m,giftApplied:v,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1265,[34,385,102,874,867,821,794,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1266,[34,102,794,867,1267,1268,1269,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1267,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1268,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1269,[933,987,1268]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1270,[846,933,976,987,2,1267]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),r=e(_r(_d[4])),o=e(_r(_d[5])),i=e(_r(_d[6])),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),b=e(c);_r(_d[10]);var h=e(_r(_d[11])),f=e(_r(_d[12])),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),S=_r(_d[20]),T=_r(_d[21]),I=_r(_d[22]),O=_r(_d[23]),R=_r(_d[24]),A=_r(_d[25]),B=_r(_d[26]),P=_r(_d[27]),C=_r(_d[28]),_=_r(_d[29]),v=_r(_d[30]),N=_r(_d[31]);const $=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let E=!1,M=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,u.useLocalSearchParams)(),d=(0,w.useRestaurant)(e),c=s.IS_QUEUED_VENUE?(0,N.jsx)(t.default,{}):s.IS_ABBOTSFORD?(0,N.jsx)(o.default,{}):s.IS_KIRKTON?(0,N.jsx)(i.default,{}):s.IS_GREENSIDE?(0,N.jsx)(r.default,{}):l.IsolatedCustomerHome&&(s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS)?(0,N.jsx)(l.IsolatedCustomerHome,{}):(0,N.jsx)(K,{});return s.IS_ABBOTSFORD||s.IS_KIRKTON||s.IS_WILDINGS||!d?.settings.hotel?.enabled?c:(0,N.jsx)(n.HotelRequestGate,{rid:e,hotel:d.settings.hotel,children:c})}function K(){const{rid:e}=(0,u.useLocalSearchParams)(),t=(0,w.useRestaurant)(e),l=(0,w.useMenu)(e),s=(0,w.useCustomer)(),n=(0,w.useBasket)(),r=(0,w.useStore)(e=>e.startBasket),o=(0,w.useNow)(3e4),[i,H]=(0,c.useState)('All'),[K,W]=(0,c.useState)(null),[G,F]=(0,c.useState)(!1),[U,Q]=(0,c.useState)(!1),[V,Y]=(0,c.useState)('takeaway'===$?'takeaway':'main');b.default.useEffect(()=>{$&&!E&&(E=!0,'book'===$?setTimeout(()=>u.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,w.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,v.guestServer)();b.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>u.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),b.default.useEffect(()=>{C.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>u.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,w.useOrderAtTable)(e);if(b.default.useEffect(()=>{te||n.restaurantId!==e||'table'!==n.mode||w.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,n.mode,n.restaurantId,e]),!t)return(0,N.jsx)(x.Screen,{title:"Not found",children:(0,N.jsx)(x.T,{children:"Restaurant not found."})});const le=te&&n.restaurantId===t.id&&'table'===n.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ae=e=>!(e.soldOut||!e.signOff||null===e.price),ne=l.filter(e=>('All'===i||e.section===i)&&('takeaway'!==V||ae(e))),re=(0,k.hoursFor)(t,o),oe=e=>()=>u.router.push(`/customer/${t.id}${e}`),ie=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),le&&r(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>Q(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:oe('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:oe('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:oe('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:oe('/refer')},{icon:'gift',label:'Gift cards',on:oe('/gift')},{icon:'alert',label:'My allergens',sub:s.allergies.length?`${s.allergies.length} declared`:'None declared',on:()=>u.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:s.marketingOptIn[t.id]?'Opted in':'Opt in',on:oe('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:oe('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:oe('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:oe('/feedback')},{icon:'hanger',label:'Lost property',on:oe('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:oe('/merch')}];return(0,N.jsxs)(x.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,N.jsxs)(x.Row,{children:[(0,N.jsx)(m.BasketButton,{}),(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>u.router.push('/customer/profile')})]}),children:[t.fictional?(0,N.jsx)(x.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,le?(0,N.jsx)(x.Banner,{kind:"success",title:`Ordering at ${(0,d.tableNumbers)(n.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,N.jsx)(x.Card,{children:(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(f.default,{style:{flex:1},children:[(0,N.jsx)(x.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,N.jsxs)(x.Muted,{children:[re?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,N.jsx)(x.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,N.jsx)(x.Row,{wrap:!0,gap:8,children:ie.slice(2,7).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,N.jsx)(f.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ie.map(e=>(0,N.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),le?(0,N.jsx)(x.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,N.jsx)(x.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,N.jsx)(x.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,N.jsx)(x.ExampleAllergenNotice,{}),(0,N.jsxs)(x.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,N.jsx)(f.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,N.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,N.jsx)(x.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,N.jsx)(f.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,N.jsx)(A.SpecialsTab,{rid:t.id,declared:s.allergies,now:o}):null,'takeaway'===V?(0,N.jsx)(x.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==V?(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,N.jsx)(x.Chip,{label:"All",selected:'All'===i,onPress:()=>H('All')}),se.map(e=>(0,N.jsx)(x.Chip,{label:e,selected:i===e,onPress:()=>H(e)},e))]}):null,'specials'!==V?se.filter(e=>('All'===i||e===i)&&ne.some(t=>t.section===e)).map(e=>(0,N.jsxs)(f.default,{style:{gap:10},children:[(0,N.jsx)(x.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),ne.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,s.allergies),o=e.soldOut||!e.signOff||null===e.price;return(0,N.jsxs)(x.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,N.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)},children:[(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,N.jsx)(x.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,N.jsx)(x.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,j.gbp)(e.price)})]}),(0,N.jsx)(x.Muted,{numberOfLines:2,children:e.description})]}),(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,N.jsx)(x.Badge,{kind:"ok",label:e},e)),e.special?(0,N.jsx)(x.Badge,{kind:"gold",label:"Special"}):null,e.soldOut?(0,N.jsx)(x.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,N.jsx)(x.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,N.jsx)(x.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,N.jsx)(x.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,N.jsx)(p.AllergenChips,{map:e.allergens,declared:s.allergies}),K===e.id?(0,N.jsx)(p.AllergenPanel,{item:e,map:e.allergens,declared:s.allergies}):null,(0,N.jsxs)(x.Row,{gap:8,children:[(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,N.jsx)(f.default,{style:{flex:1}}),(0,N.jsx)(x.Button,{small:!0,label:o?e.soldOut?'Sold out':'Not available online':'Choose',disabled:o,onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,N.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,N.jsx)(x.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,N.jsx)(x.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,N.jsx)(T.LauncherLine,{}),te?(0,N.jsxs)(x.Sheet,{visible:U,onClose:()=>Q(!1),title:"Order at your table",children:[(0,N.jsx)(x.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,N.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:`${(0,d.tableNumbers)(e)}`,onPress:()=>{Q(!1),r(t.id,'table',e)}},e))}),(0,N.jsx)(x.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1271,[1272,1281,5,1282,1283,1284,1287,860,30,34,236,402,102,1234,1261,794,861,867,878,874,821,1288,1248,872,891,1233,994,995,1003,1289,1270,25]); -__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1272,[34,379,794,873,1273,1274,1280,874,5,6,25]); -__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1273,[34,379,102,794,996,997,1095,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1274,[6,34,933,794,1275,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1275,[6,1062,1276,1277,1278,34,102,827,794,821,11,1279,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1277,[4,11]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1278,[11]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1279,[6,933]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1280,[34,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1281,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1282,[34,102,794,1275,25]); -__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1283,[34,379,933,794,873,1273,1275,4,25]); -__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1284,[34,379,794,1273,873,1274,8,1285,25]); -__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1285,[34,102,794,1286,25]); -__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1286,[]); -__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1287,[34,794,873,1273,1274,874,9,25]); -__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1288,[34,402,102,426,794,821,1206,25]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1289,[34,102,1290,794,874,1003,1267,1270,821,25]); -__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1290,[34,102,1291,821,25]); -__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1291,[1292]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1292,[34,797,1293,1322,1323,25]); -__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1293,[1294]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1294,[1295,1296,1319,1321]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1295,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1296,[1297,1298,1299,1300,1301,1302,1303,1304,1305,1308,1312,1309,1313]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1297,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1298,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1299,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1300,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1305,[1306]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1309,[1310,1311]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1310,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1311,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1314,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1315,[1309]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1317,[1309,1297]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1318,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1319,[1320]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1321,[1320]); -__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1322,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1323,[34,797,1324,25]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1324,[]); -__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1325,[30,34,794,874,891,25]); -__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1326,[837,30,34,102,1290,794,867,874,821,1289,1270,25]); -__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1327,[837,30,34,102,1265,794,874,891,867,858,821,1266,1270,25]); -__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1328,[837,30,34,794,874,891,858,821,1289,1270,25]); -__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1329,[837,30,34,794,874,891,821,1289,1270,25]); -__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1330,[30,34,794,858,1160,1331,874,821,25]); -__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}},1331,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1332,[30,1100,34,402,102,794,858,874,821,25]); -__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 l=_r(d[0]),t=_r(d[1]),n=_r(d[2]),s=e(n),a=_r(d[3]),o=_r(d[4]),r=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),p=_r(d[15]),k=_r(d[16]);function f(){const e=(0,y.useBasket)(),f=(0,y.useRestaurant)(e.restaurantId??void 0),w=(0,y.useAllMenu)(e.restaurantId??void 0),v=(0,y.useCustomer)(),C=(0,y.useOrders)(f?.id),S=(0,y.useStore)(e=>e.setLineQty),T=(0,y.useStore)(e=>e.overrideLine),B=(0,y.useStore)(e=>e.startBasket),P=(0,y.useNow)(15e3),[$,O]=(0,n.useState)(null),[I,M]=(0,n.useState)(!1),[N,F]=(0,n.useState)(''),[L]=(0,n.useState)(()=>(0,o.startForm)()),[R,z]=(0,n.useState)(''),[A,D]=(0,n.useState)(v.phone??''),[E,Y]=(0,n.useState)(v.email??''),[_,q]=(0,n.useState)(!1),H=(0,y.useOrderAtTable)(e.restaurantId??void 0);s.default.useEffect(()=>{H||'table'!==e.mode||y.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[H,e.mode]);const[G,K]=(0,n.useState)(null),[Q,J]=(0,n.useState)(!1),U=(0,n.useMemo)(()=>(0,j.linesFromBasket)(e,w,v.allergies),[e,w,v.allergies]);if(!f||!e.lines.length)return(0,k.jsxs)(u.Screen,{title:"Your basket",children:[(0,k.jsx)(u.Muted,{children:"Your basket is empty."}),(0,k.jsx)(u.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const V=H&&'table'===e.mode,W=(0,m.takeawaySlots)(f,C,P),X=U.reduce((e,l)=>e+l.unitPrice*l.qty,0),Z=U.some(e=>e.contains.length&&!e.overridden),ee=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff}),le=!V&&!$,te=!V&&f.settings.takeawayPaused,ne=(0,p.ukPhone)(A),se=!Z&&!ee.length&&I&&!le&&!te&&(V||ne.ok&&(0,p.emailOk)(E)),ae=async e=>{const l=await y.repo.orders.placeFromBasket({slotTime:V?void 0:$,tip:0,giftCardCode:e?.giftCardCode,notes:N,paidNow:!V,phone:V?void 0:ne.pretty,email:V?void 0:E.trim()||void 0});(0,o.rememberGuard)(l.id,(0,o.guardFor)({...L,hp:R})),q(!1),t.router.replace(`/customer/order/${l.id}`)},oe=e.lines.find(e=>e.key===G),re=oe?U[e.lines.indexOf(oe)]:void 0;return(0,k.jsxs)(u.Screen,{title:"Your basket",subtitle:`${f.name} \xb7 ${V?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,k.jsxs)(r.default,{style:{gap:8},children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.T,{weight:"semibold",children:"Subtotal"}),(0,k.jsx)(u.T,{weight:"bold",size:20,colour:x.colours.gold,children:(0,h.gbp)(X)})]}),Z?(0,k.jsx)(u.T,{size:14,colour:x.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):I?le&&!te?(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Choose a collection time."}):null:(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Confirm your allergies to continue."}),V?(0,k.jsx)(u.Button,{label:"Send order to the kitchen",disabled:!se,onPress:()=>ae(),testID:"send-table-order"}):(0,k.jsx)(u.Button,{label:`Continue to payment \xb7 ${(0,h.gbp)(X)}`,disabled:!se,onPress:()=>q(!0),testID:"checkout"})]}),children:[(V||e.tableNo,null),V?(0,k.jsx)(u.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,f.fictional?null:(0,k.jsx)(u.ExampleAllergenNotice,{}),U.map((l,t)=>{const n=e.lines[t],s=l.contains.length&&!l.overridden;return(0,k.jsxs)(u.Card,{highlight:l.contains.length?x.colours.red:l.may.length?x.colours.amber:void 0,children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(r.default,{style:{flex:1,paddingRight:8},children:[(0,k.jsx)(u.T,{weight:"semibold",children:l.name}),l.choices.length?(0,k.jsx)(u.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,k.jsxs)(u.Muted,{children:["Note: ",l.notes]}):null]}),(0,k.jsx)(u.T,{weight:"semibold",children:(0,h.gbp)(l.unitPrice*l.qty)})]}),s?(0,k.jsxs)(u.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:[(0,k.jsx)(u.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${v.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} (${(0,c.severityLabel)(e.severity)})`).join(', ')}.`}),(0,k.jsxs)(u.Row,{gap:8,style:{marginTop:6},children:[(0,k.jsx)(u.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{J(!1),K(n.key)}})]})]}):l.contains.length?(0,k.jsx)(u.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,k.jsx)(u.Banner,{kind:"warn",title:`May contain ${l.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ee.includes(n)?(0,k.jsx)(u.Badge,{kind:"amber",label:"No longer available online \u2014 please remove"}):null,(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Stepper,{value:n.qty,onChange:e=>S(n.key,e),min:1,label:l.name})]})]},n.key)}),(0,k.jsx)(u.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${f.id}`)}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsxs)(u.H2,{children:["Collection time \u2014 ",(0,b.niceDate)(P)]}),te?(0,k.jsx)(u.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===W.length?(0,k.jsx)(u.Banner,{kind:"warn",children:"No collection slots left today."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u.Muted,{children:["15-minute slots, max ",f.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:W.slice(0,16).map(e=>(0,k.jsx)(u.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>O(e.time.toISOString())},e.label))})]})]}),(0,k.jsxs)(u.Card,{highlight:I?void 0:x.colours.amber,children:[(0,k.jsx)(u.H2,{children:"Confirm allergies for this order"}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:v.allergies.length?v.allergies.map(e=>(0,k.jsx)(u.Badge,{kind:"red",label:`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`},e.allergen)):(0,k.jsx)(u.Muted,{children:"No allergies declared on your profile."})}),(0,k.jsx)(u.Toggle,{label:v.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:I,onChange:M}),(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsx)(u.H2,{children:"Your details"}),(0,k.jsx)(u.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:A,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!ne.ok&&A?(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:ne.error}):null,(0,k.jsx)(u.Field,{label:"Email (optional)",value:E,onChangeText:Y,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,p.emailOk)(E)?null:(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,k.jsx)(u.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,k.jsx)(u.Field,{label:"Order notes (optional)",value:N,onChangeText:F,placeholder:"e.g. cutlery please"}),V?(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>B(f.id,'takeaway')}):null,(0,k.jsx)(i.MockPay,{visible:_,onClose:()=>q(!1),amount:X,restaurantId:f.id,onPaid:e=>ae({giftCardCode:e.giftCardCode}),title:"Pay for your takeaway"}),(0,k.jsxs)(u.Sheet,{visible:!!oe,onClose:()=>K(null),title:"Allergy override",children:[re?(0,k.jsx)(u.Banner,{kind:"danger",title:`${re.name} contains ${re.contains.map(c.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,k.jsx)(u.Toggle,{label:"I understand and want to add it anyway",value:Q,onChange:J}),(0,k.jsx)(u.Button,{kind:"danger",disabled:!Q,label:"Confirm override",onPress:()=>{oe&&re&&T(oe.key,re.contains),K(null)}})]}),(0,k.jsx)(a.Honeypot,{value:R,onChange:z})]})}},1333,[860,30,34,1257,1001,102,1265,794,861,867,1130,858,874,831,821,864,25]); -__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1334,[30,34,102,1261,794,861,878,874,821,1288,5,25]); -__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 f}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},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]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,s.useLocalSearchParams)(),r=(0,b.useOrder)(e),f=(0,b.useRestaurant)(r?.restaurantId),[C,S]=(0,l.useState)(0),[k,T]=(0,l.useState)(''),[v,P]=(0,l.useState)(!1),[M,$]=(0,l.useState)(!1),[R,A]=(0,l.useState)(1),[I,N]=(0,l.useState)(0),[O,B]=(0,l.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(c.Screen,{title:"Order",children:(0,j.jsx)(c.T,{children:"Order not found."})});const H='takeaway'===r.type?x:w,_=Math.max(0,H.findIndex(([e])=>e===r.status)),D=Math.round(r.subtotal*I/100),F='table'===r.type?r.subtotal+(r.split?r.tip:D):r.total,q=F-r.paid,L=r.split?.ways??O,W=r.split?.paidShares??0,Y=Math.ceil(F/L),E='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(c.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,p.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(c.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Status"}),H.map(([e,t],s)=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=_?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(c.T,{weight:s===_?'semibold':'regular',colour:s<=_?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(c.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,p.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(c.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||E?null:(0,j.jsxs)(c.Row,{gap:8,children:[(0,j.jsx)(c.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>b.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(c.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>b.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(c.T,{children:(0,h.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(c.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(c.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(u.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Subtotal"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Of which gift card"}),(0,j.jsxs)(c.T,{colour:y.colours.ok,children:["\u2212",(0,h.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Tip"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.tip)})]}):null,(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.gold,children:(0,h.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(c.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(F)," \xb7 split ",L," way",L>1?'s':''," \xb7 ",(0,h.gbp)(Y)," each"]}),(0,j.jsxs)(c.T,{children:["Shares paid: ",W," of ",L," \xb7 remaining ",(0,h.gbp)(q)]}),L>1?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{children:"Shares to pay now"}),(0,j.jsx)(c.Stepper,{value:R,onChange:A,min:1,max:L-W,label:"shares"})]}):null,(0,j.jsx)(c.Button,{label:`Pay ${L>1?`${R} share${R>1?'s':''}`:'bill'} \xb7 ${(0,h.gbp)(Math.min(q,Y*R))}`,onPress:()=>$(!0),testID:"pay-bill"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(c.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(c.Chip,{label:e?`${e}%`:'No tip',selected:I===e,onPress:()=>N(e)},e))}),(0,j.jsx)(c.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(c.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(r.subtotal+D),O>1?` \xb7 ${(0,h.gbp)(Math.ceil((r.subtotal+D)/O))} each`:'']}),(0,j.jsx)(c.Button,{label:"Get the bill",onPress:()=>b.repo.orders.setSplit(r.id,O,D),testID:"get-bill"})]})]}):null,!E||r.rated||v?null:(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(c.H2,{children:"How was everything?"}),(0,j.jsxs)(c.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(i.Stars,{value:C,onChange:S}),C?(0,j.jsx)(c.Field,{label:"Anything to add? (optional)",value:k,onChangeText:T}):null,(0,j.jsx)(c.Button,{label:"Send feedback",disabled:!C,onPress:()=>{b.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:C,comment:k,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),P(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(c.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,E?(0,j.jsx)(c.Button,{kind:"secondary",label:"View stamp card",onPress:()=>s.router.push(`/customer/${f.id}/loyalty`)}):null,(0,j.jsx)(o.MockPay,{visible:M,onClose:()=>$(!1),amount:Math.min(q,Y*R),restaurantId:f.id,title:`Pay \u2014 ${(0,t.tableNumbers)(r.tableNo)}`,onPaid:e=>{b.repo.orders.payTable(r.id,{shares:R,giftCardCode:e.giftCardCode}),$(!1),A(1)}})]})}},1335,[860,30,34,102,1265,1263,794,861,867,858,874,821,25]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1336,[860,1270,30,34,102,794,861,867,858,874,879,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1337,[30,34,872,25]); -__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1338,[837,30,34,794,874,5,1270,25]); -__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1339,[30,34,794,1340,1174,1270,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1340,[827,860,34,102,794,861,867,1174,1341,874,821,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1341,[933,987,1174]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1342,[30,34,872,1343,1407,25]); -__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1343,[1161,796,5,6,1344,828,853,1121,860,1160,1345,1346,1347,1118,1142,1348,1349,1354,1355,1356,872,1357,1173,979,1129,1358,34,1098,1201,1047,1114,1156,1359,395,380,402,295,102,426,36,794,1248,1252,873,861,858,874,821,1117,891,1125,1087,1028,1104,1134,1360,1133,1361,1368,1370,1373,1376,1372,1377,1379,1380,1139,1122,1123,878,1384,1237,1385,1247,1239,1025,1390,1398,1399,1101,1141,1401,1402,1403,1097,1188,1404,1187,1180,869,1405,1406,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1345,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1346,[1026,1087]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1347,[34,102,1104,794,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1348,[860,34,102,794,874,1174,821,25]); -__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1349,[34,395,402,426,102,1290,794,1188,796,1028,1350,1351,1353,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1350,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1351,[34,395,402,295,412,102,426,796,794,821,1352,1353,25]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1352,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1353,[1024,872,1352,933,987]); -__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1354,[846]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1355,[828,34,379,395,402,102,794,1188,821,25]); -__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1356,[34,236,402,102,794,821,891,1003,858,1097,25]); -__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1357,[828,827,34,236,402,295,102,794,1173,874,979,831,981,982,872,980,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1358,[828,34,102,821,794,25]); -__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1359,[34,102,797,821,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1360,[]); -__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1361,[828,796,827,1121,860,1129,34,236,402,295,426,102,859,821,794,1362,1363,1028,891,1133,1365,987,872,25]); -__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1362,[828,860,34,1363,102,859,821,794,1134,1364,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1363,[859]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1364,[1363,859]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1365,[34,385,295,102,859,1366,1367,821,796,827,794,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1366,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1367,[1366,1024,872,933,987]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1368,[34,236,402,102,821,794,1188,1369,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1369,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1370,[828,860,1122,34,281,236,295,102,1135,874,1028,1104,14,858,1123,1371,821,794,1372,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1371,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1372,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1373,[5,828,34,283,336,236,402,102,426,821,873,794,1029,1000,1354,1374,2,1375,1376,874,858,25]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1374,[236]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1376,[34,846,933,987,1375]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1377,[860,14,1028,1378]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1378,[861]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1379,[34,102,797,821,25]); -__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1380,[1381,860,1122,1028,34,102,794,1125,874,1383,1377,1123,858,1120,1139,1140,1141,821,1346,25]); -__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1381,[34,379,402,102,874,1003,891,1026,1382,872,821,794,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1382,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1383,[1028,1104]); -__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1384,[1381,828,1122,827,860,1160,1118,1139,858,34,1106,236,402,295,102,794,1125,1372,874,1028,861,1116,1104,1331,821,1346,25]); -__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1385,[827,34,236,402,102,794,874,1028,1386,821,1387,1389,25]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1386,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1387,[846,874,1028,1386,1388,1389]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1388,[860]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1389,[236,1388]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1390,[860,34,1205,1188,402,102,1025,1028,878,858,821,794,1391,1394,25]); -__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1391,[1392,870,860,34,281,395,402,295,102,874,1025,1028,1393,858,821,1055,794,1394,1395,987,1346,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1392,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1393,[878,858,877]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1394,[5,1028,933,987]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1395,[846,933,987,1396,2,1397]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1396,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1397,[15]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1399,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1400,[1104]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1401,[860,1378]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1402,[34,402,102,794,1401,821,1359,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1403,[34,102,925,794,1188,858,821,25]); -__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1404,[34,1188,402,102,426,794,25]); -__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1405,[828,1062,827,2,1188,34,402,102,426,794,821,891,997,858,1000,1395,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1406,[34,1035,891,1008,831,1036,1000,1395,1093]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1407,[5,828,873,34,236,402,102,426,987,821,794,1354,1408,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1408,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1409,[30,34,872,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1410,[30,34,872,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1411,[30,34,1412,872,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1412,[34,872,1413,1546,25]); -__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,"canSignOffHours",{enumerable:!0,get:function(){return he}}),_e.barTabsFor=me,_e.signOffSpeech=be,_e.OwnerApp=function(){return H.IS_OWNER_DESKTOP?(0,ue.jsx)(de.DesktopGate,{phone:(0,ue.jsx)(xe,{})}):(0,le.isDesktop)()?(0,ue.jsx)(ce.DesktopShell,{}):(0,ue.jsx)(xe,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),j=_r(d[14]),w=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=e(_r(d[20])),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),I=_r(d[24]),L=_r(d[25]),O=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]),$=_r(d[32]);_r(d[33]);var D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),z=_r(d[39]),F=_r(d[40]),U=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]),Y=_r(d[45]);_r(d[46]);var J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]),de=_r(d[60]),ce=_r(d[61]),ue=_r(d[62]);const fe=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ge=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],he=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function me(e,t){return ge.filter(t=>!t.can||t.can(e)).map(e=>'orders'===e.id&&t?{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'}:'forecast'===e.id?{id:'rota',label:'Rota',icon:'rota'}:e)}function be(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const pe={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function xe(){const{rid:e,r:le,role:de,today:ce,now:xe,meId:je,me:we}=(0,_.useCtx)(3e4);(0,b.useTipsPosted)(e,ce,'staff'!==de);const Se=(0,_.useSignedIn)();(0,c.useSoldOutLink)(!0,(Se?.name??we).replace(' (example)',''));const ye=(0,I.useOrders)(e),[Ae,ke]=(0,j.useState)('home'),[Re,Ce]=(0,j.useState)(null),[ve,Te]=(0,j.useState)(!1),Ie=(0,n.useLiveVenue)(),[Le,Oe]=(0,j.useState)(!1),Ee=(0,j.useRef)(null);(0,j.useEffect)(()=>{(0,_.ensureAttendance)(ce,xe),(0,Q.ensureChat)(xe)},[ce]),globalThis.__ccNow=xe.getTime();const Be=(0,Q.useChatUnread)().total,Pe=(0,j.useRef)({t:'home',s:null});Pe.current={t:Ae,s:Re};const Ne=(0,j.useRef)([]),$e=(0,l.useScrollMemory)(Ee),De=(0,j.useCallback)((e,t=null)=>{const s=Pe.current;s.t===e&&s.s===t||(Ne.current=[...Ne.current,{...s,y:$e.leave()}].slice(-30),$e.restore(0)),ke(e),Ce(t)},[]),Me=(0,j.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Pe.current;let t=Ne.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Ne.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return $e.leave(),ke(s.t),Ce(s.s),$e.restore(s.y??0),!0},[]);(0,u.useWebBack)(Me);const He=(0,u.useInnerBackShown)();(0,j.useEffect)(()=>(re.useVoiceNav.setState({go:De}),()=>re.useVoiceNav.setState({go:null})),[De]),(0,j.useEffect)(()=>{f.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchOwner=L.useOwner)},[De]),(0,j.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Me);return()=>e.remove()},[Me]),(0,j.useEffect)(()=>{const e=ge.find(e=>e.id===Ae);e?.can&&!e.can(de)&&De('home');const t=(0,K.pageFor)(Re);t?.can&&!t.can(de)&&Ce(null)},[de]);const We='more'===Ae?(0,K.pageFor)(Re):void 0,Ve=ye.filter(e=>(0,B.LIVE)(e)&&'new'===e.status).length,{unread:ze,list:Fe,read:Ue}=(0,J.useNotifications)();(0,se.useAlertWatcher)(e,{nag:'staff'!==de}),(0,oe.useReviewAlerts)(e),(0,ne.useScheduledNotices)({rid:e,staffId:Se?.id??'',name:we,onOpen:e=>'bookings'===e?De('bookings'):'chat'===e?De('chat'):De('more',e)}),(0,ae.useOffRotaAlerts)({enabled:'staff'!==de&&!!Se});const qe=Se?.role??de,Ge='owner'===qe?'OWNER':'manager'===qe?'MANAGER':'STAFF',Ke=(0,se.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,se.isUnread)(t,s)&&!(0,se.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),Ye=(0,se.useAlerts)(t=>t.todoSeen[e]),Je=Math.max(0,ze-Fe.filter(e=>!Ue[e.id]&&(Ye??[]).includes(e.id)).length)+Ke;(0,se.useAlertSeenSync)(e),(0,j.useEffect)(()=>{G.useShellBadges.setState({notifCount:Je})},[Je]);const Qe=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Xe=he(de),Ze=(0,r.useOutstanding)(),et=Ze.days.length+Ze.requests,tt=me(de,Xe),st='more'===Ae&&'signoff'===Re?'signoff':'more'===Ae&&'rota'===Re?'rota':'forecast'===Ae||'orders'===Ae&&Xe?'more':Ae,ot=t.IS_ISOLATED_VENUE?[{id:e,name:le.name,place:le.location||le.address||''}]:fe,rt=ot.find(t=>t.id===e)??ot[0],nt=Se?.ownerAccess&&'owner'!==Se.role?'owner privileges':Se?.managerAccess&&'staff'===Se.role?'manager privileges':'',at=(0,M.ownerHomeLayout)(de,Se);(0,k.default)().width;return(0,ue.jsxs)(C.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,ue.jsxs)(R.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,ue.jsxs)(R.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>De('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,ue.jsx)(y.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:Je?`Notifications, ${Je} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>De('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),Je?(0,ue.jsx)(R.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(v.T,{size:10,weight:"bold",children:Je})}):null]})}),(0,ue.jsx)(Z.VoiceSlot,{size:44})]}),(0,ue.jsx)(R.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ue.jsx)(R.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,ue.jsx)(y.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${we}. Account and role${nt?`, ${nt}`:''}`,disabled:'owner'!==H.APP_VARIANT,onPress:()=>Oe(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ue.jsxs)(v.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ue.jsx)(P.StaffAvatar,{id:je,size:24,ring:!1}),(0,ue.jsxs)(R.default,{style:{flexShrink:1},children:[(0,ue.jsxs)(v.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[Se?`${we} \xb7 ${Se.level??L.ROLE_LABEL[Se.role]}`:`${we} \xb7 ${L.ROLE_LABEL[de]}`,'owner'===H.APP_VARIANT?' \u25be':'']}),nt?(0,ue.jsx)(v.Muted,{center:!1,size:10,numberOfLines:1,children:nt}):null]})]})})})}),(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>Te(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,ue.jsx)(T.VenueHeaderBlock,{rid:e,name:le.name,badge:Ge,place:`${'staff'===de?'Staff preview \xb7 ':'Managers \xb7 '}${rt.place}`})}),de!==(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner')&&'owner'===H.APP_VARIANT?(0,ue.jsx)(y.default,{onPress:()=>L.useOwner.getState().setPreviewRole(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,ue.jsx)(v.T,{size:12,colour:O.colours.gold,children:'staff'===de?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[de].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`})}):null]}),(0,ue.jsxs)(A.default,{ref:Ee,...$e.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ue.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Re||He),onBack:Me,title:We?We.title:'bookings'===Ae&&'waitlist'===Re?'Waitlist':'staff'===de&&'home'===Ae?'Staff app preview':pe[Ae]}),'home'===Ae&&Se&&'staff'===Se.role&&'owner'===H.APP_VARIANT?(0,ue.jsxs)(R.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,ue.jsx)(v.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,ue.jsx)(v.Button,{label:"Clock in and my shifts",onPress:()=>De('more','clock')})]}):null,'home'!==Ae||at?null:(0,ue.jsx)(a.WhoBar,{}),'home'===Ae&&!at&&Se?(0,ue.jsx)(ie.MyShiftCard,{go:De}):null,'home'===Ae&&!at&&Se?(0,ue.jsx)(h.MyTasksToday,{rid:e,staffId:Se.id,name:Se.name,onShift:(0,p.shiftNow)(Se.id,Date.now()).on}):null,'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TodaysTipsCard,{rid:e,today:ce}),'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TipsPotCard,{rid:e,today:ce}),'home'===Ae?'staff'===de?(0,ue.jsx)(z.StaffHome,{go:De}):(0,ue.jsx)(D.Dashboard,{go:De,ownerHome:at}):null,'orders'===Ae?(0,ue.jsx)(Y.Orders,{}):null,'bookings'===Ae?(0,ue.jsx)(E.Bookings,{go:De,only:'waitlist'===Re?'waitlist':void 0}):null,'forecast'===Ae?(0,ue.jsx)(F.Forecasts,{go:De}):null,'chat'===Ae?(0,ue.jsx)(Q.Chat,{go:De}):null,'more'===Ae?We?(0,ue.jsx)(We.C,{go:De}):(0,ue.jsx)(K.MoreMenu,{go:De}):null]}),(0,ue.jsx)(x.SeatAllergenReminder,{rid:e}),'staff'!==de?(0,ue.jsx)(te.PrintHost,{rid:e}):null,'staff'!==de?(0,ue.jsx)(ee.AlertHost,{variant:"managers",rid:e,me:we,onOpen:e=>De('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,ue.jsx)(X.AssistantSheet,{}),(0,ue.jsx)(q.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:st,onPress:e=>'signoff'===e?De('more','signoff'):'rota'===e?De('more','rota'):De(e),tabs:tt.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?be(Ze.days.length,Ze.requests):'more'===e.id&&Xe&&Ve?`More, ${Ve} new order${Ve>1?'s':''} in Orders`:void 0,badge:'chat'===e.id&&Be?{text:String(Be),bg:O.colours.red}:'bookings'===e.id&&Qe?{text:String(Qe),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&Ve?{text:String(Ve),bg:O.colours.red}:'signoff'===e.id&&et?{text:String(et),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Xe&&Ve?{text:String(Ve),bg:O.colours.red,testID:'more-orders-badge'}:null}))}),(0,ue.jsx)(S.default,{visible:ve,transparent:!0,animationType:"fade",onRequestClose:()=>Te(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Te(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Your venues"}),ot.filter(e=>!Ie||'saltmarsh'!==e.id).map(t=>(0,ue.jsx)(y.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),Te(!1),De('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,ue.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(v.T,{weight:"medium",children:t.name}),(0,ue.jsx)(v.Muted,{children:t.place})]}),t.id===e?(0,ue.jsx)(v.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,ue.jsx)(v.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${le.name}.`:Ie?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,ue.jsx)(S.default,{visible:Le,transparent:!0,animationType:"fade",onRequestClose:()=>Oe(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Oe(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[Se?(0,ue.jsxs)(v.Row,{gap:10,children:[(0,ue.jsx)(P.StaffAvatar,{id:Se.id,size:44}),(0,ue.jsxs)(R.default,{style:{flex:1},children:[(0,ue.jsxs)(v.T,{weight:"semibold",children:["Signed in as ",Se.name]}),(0,ue.jsx)(v.Muted,{children:(0,$.levelJob)(Se.level??L.ROLE_LABEL[Se.role],Se.job)})]})]}):(0,ue.jsxs)(R.default,{style:{gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,ue.jsx)(v.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,ue.jsx)(N.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!Se?null:(0,ue.jsx)(v.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,$.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,ue.jsx)(v.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!Se||(0,_.clampRole)(e,Se.ownerAccess?'owner':Se.managerAccess?'manager':Se.role)===e).map(e=>(0,ue.jsx)(v.Button,{kind:e===de?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),Oe(!1)}},e))]})})}),(0,ue.jsx)(W.OnboardingHost,{go:De}),(0,ue.jsx)(V.CoachHost,{})]})}},1413,[5,828,987,1209,1235,1223,1054,979,1055,2,1060,1061,1093,1114,34,373,395,402,295,426,102,36,794,873,874,891,821,1414,1200,1087,925,1423,1003,236,1432,13,872,1464,1470,1471,1472,1206,1254,1473,1456,1474,1475,1454,1179,1489,1156,1237,1385,1239,1252,1477,1111,1113,1222,1542,1543,1562,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1414,[5,1415,1122,11,1416,827,837,1139,1140,1118,1142,1417,1137,1141,1401,1402,1087,1346,1026,1116,14,1143,1419,1248,1420,1390,1106,1100,1117,34,102,794,1359,874,861,867,858,1331,821,1200,1125,1028,1421,1086,1180,1422,1239,987,1202,1398,878,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1415,[34,794,25]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1416,[6,34,102,794,987,1279,25]); -__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1417,[34,402,102,1418,987,933,821,794,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1418,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1419,[827,5,34,379,236,102,794,876,14,867,1031,933,821,1203,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1420,[34,402,1188,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1421,[34,102,874,1028,794,821,25]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1422,[34,102,879,874,864,821,794,25]); -__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1423,[5,1424,1425,1426,1427,1428,34,236,41,102,872,1429,1003,821,1431,794,987,2,1096,1002,891,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1424,[34,102,873,794,5,6,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1425,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1426,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1427,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1428,[34,102,873,794,25]); -__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1429,[34,295,102,794,873,821,1430,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1430,[]); -__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1431,[929,828,34,1096,336,236,402,295,41,102,872,926,891,831,987,1003,15,793,821,925,794,25]); -__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.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:b,now:F,role:oe,me:ae,today:ne}=(0,A.useCtx)(5e3),ie=(0,p.useOrders)(n),re=(0,p.useBookings)(n),de=(0,p.useWaitlist)(n),ue=(0,p.useEvents)(n),ge=(0,p.useRatings)(n),xe=(0,k.useOwner)(e=>e.staff),ye=(0,k.useOwner)(e=>(0,k.liveAttendance)(e.attendance)),be=(0,k.useOwner)(e=>e.shifts),fe=(0,L.useRealHistory)(n,F),me=(0,o.useMemo)(()=>(0,t.forecastToday)(b,re,ie,ue,F,fe??void 0),[b,re,ie,ue,fe,F.getTime()/6e4|0]),je=(0,N.useExamples)(),pe=(0,P.useCashUp)(e=>e.cashUps),ke=re.filter(e=>e.date===ne),we=ie.filter(D.LIVE),$e=de.filter(e=>'waiting'===e.status||'notified'===e.status),ve=ke.filter(e=>['seated','finished'].includes((0,I.shownStatus)(e))).reduce((e,s)=>e+s.partySize,0),Ce=(0,te.coversSplit)(ke,ne),Ie=Ce.walkIns,Te=Ce.bookings,Be=we.filter(e=>(0,q.chainNeedsAction)(e,re)),De=ke.filter(e=>['confirmed','seated'].includes(e.status)&&(0,q.bookingNeedsAction)(e,we)),Ae=we.flatMap(e=>(0,v.readinessFor)(e,b,F).map(s=>({...s,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Se=me.nextHour,Le=(0,D.busyLevel)(Se?.coversHigh??0,me.busy.busy),Ne=(0,D.restOfDayLevel)(me,b),Pe=ie.filter(e=>e.paid>0&&!!e.createdAt&&(0,C.ymd)(new Date(e.createdAt))===ne).reduce((e,s)=>e+s.paid,0),Me=(0,H.tradingDay)(F),Fe=je?(0,S.revenueHistory)(b,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Oe=je?{today:186e3+Pe,last:Fe?{date:(0,C.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,W.takingsToday)(pe,n,Me,Pe),Re=k.CAN.takings(oe)&&(!(0,R.isLive)()||(0,R.can)('takings.view')),He=(0,o.useMemo)(()=>(0,S.insights)(b,re,ie,ue,ge,F,ve),[b.id,re.length,ge.length,ve]),We=((0,A.weekday)(F),ye.filter(e=>e.date===ne&&e.in&&!e.out)),Ee=(0,J.useFrontDoor)(ne),ze=(0,h.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,r.useTravelDay)('owner',ne),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,M.canSeeMonthTakings)(oe,qe,{inStaffApp:Ye,live:(0,R.isLive)()}),Qe=(0,O.homeSetupNagsHidden)(n),Ve=(0,k.useOwner)(e=>e.socialPosts.reduce((e,s)=>e+('awaiting approval'===s.status?1:0),0)),[Xe,Ze]=(0,o.useState)(!1),Je=ae.replace(' (example)',''),es=k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(r.DayView,{rid:n,day:Ue,today:ne,app:"owner"})]}):a?(0,le.jsxs)(m.default,{style:{gap:12},testID:"owner-home",children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Re&&Oe.show?(0,le.jsx)(j.Row,{wrap:!0,gap:10,children:(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})})}):null,(0,le.jsx)(X.TodaysTipsCard,{rid:n,today:ne}),(0,le.jsx)(X.TipsPotCard,{rid:n,today:ne}),k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),qe&&'owner'!==qe.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,le.jsx)(V.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,Z.shiftNow)(qe.id,Date.now()).on}):null,k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]}):(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,Re&&Oe.show?(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=de,_e.MonthTakingsCard=ce,_e.WalkInSplitCard=he;var s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),o=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),y=_r(_d[12]),b=e(_r(_d[13])),f=e(_r(_d[14])),m=e(_r(_d[15])),j=_r(_d[16]),p=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),I=_r(_d[23]),T=_r(_d[24]),B=_r(_d[25]),D=_r(_d[26]),A=_r(_d[27]),S=_r(_d[28]),L=_r(_d[29]),N=_r(_d[30]),P=_r(_d[31]),M=_r(_d[32]),F=_r(_d[33]),O=_r(_d[34]),R=_r(_d[35]),H=_r(_d[36]),W=_r(_d[37]),E=_r(_d[38]),z=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),q=_r(_d[42]),Y=_r(_d[43]),_=_r(_d[44]),K=_r(_d[45]),Q=_r(_d[46]),V=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),se=_r(_d[52]),te=_r(_d[53]),le=_r(_d[54]);const oe=18,ae=18,ne=150,ie=34;function re(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const s=e.length,t=[],l=[];for(let l=0;l9){const n=3/Math.sqrt(a);l[e]=n*s*t[e],l[e+1]=n*o*t[e]}}let o=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let t=0;toe+(s-1)/Math.max(1,e-1)*t,o=[1,5,10,15,20,25].filter(s=>s=36)&&a.push(e);for(;a.length&&l(e)-l(a[a.length-1])<36;)a.pop();return[...a,e]}function ce({rid:e,today:s}){const t=(0,P.useCashUp)(e=>e.cashUps),[l,i]=(0,o.useState)(s.slice(0,7)),[r,d]=(0,o.useState)(0),[c,u]=(0,o.useState)(null),h=(0,o.useMemo)(()=>(0,M.monthTakings)(t,e,l,s),[t,e,l,s]),x=(0,o.useMemo)(()=>(0,M.firstTakingsMonth)(t,e),[t,e]),y=!!x&&xoe+(e-1)/Math.max(1,k-1)*w,I=e=>$-e/v*128,T=[];h.days.forEach((e,s)=>{if('recorded'!==e.state)return;const t={x:C(e.day),y:I(e.value)};s&&'recorded'===h.days[s-1].state?T[T.length-1].push(t):T.push([t])});const D=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),S=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===s):void 0)??A??D[D.length-1],L=e=>{const s=D.findIndex(e=>e.date===S?.date),t=D[Math.max(0,Math.min(D.length-1,s+e))];t&&(u(t.date),b.default.announceForAccessibility?.(N(t)))},N=e=>`${(0,M.longDay)(e.date)}, ${'recorded'===e.state?(0,M.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,O=h.current?`so far in ${h.month}`:`in ${h.month} ${l.slice(0,4)}`,R=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,M.monthName)((0,M.addMonths)(l,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,H=h.recorded?`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. ${(0,M.poundsWhole)(h.total)} ${O}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,M.longDay)(h.best.date)}, ${(0,M.poundsWhole)(h.best.value)}.${R?` ${R.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,W=r?de(k,r):[],E=(e,s,t,o,a)=>(0,le.jsx)(f.default,{testID:a,accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{disabled:!t},disabled:!t,onPress:()=>{i((0,M.addMonths)(l,o)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:t?e?.6:1:.25}),children:(0,le.jsx)(j.T,{size:24,colour:B.colours.gold,center:!0,children:e})});return(0,le.jsx)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(m.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),y||p?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[E('\u2039',`Previous month, ${(0,M.monthName)((0,M.addMonths)(l,-1))}`,y,-1,'mt-prev'),(0,le.jsxs)(j.T,{center:!0,colour:B.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",l.slice(0,4)]}),E('\u203a',`Next month, ${(0,M.monthName)((0,M.addMonths)(l,1))}`,p,1,'mt-next')]}):null,(0,le.jsx)(m.default,{accessible:!0,accessibilityLabel:H,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(j.T,{size:38,weight:"bold",colour:B.colours.gold,center:!0,testID:"mt-total",children:(0,M.poundsWhole)(h.total)}),(0,le.jsx)(j.T,{center:!0,colour:B.colours.goldLight,children:O}),(0,le.jsxs)(j.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,M.shortDay)(h.best.date)," \xb7 ",(0,M.poundsWhole)(h.best.value)]}),R?(0,le.jsx)(j.Muted,{center:!0,testID:"mt-vs",children:R}):null]}):(0,le.jsx)(j.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(m.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(m.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ne,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ne,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:oe,y1:$,x2:r-ae,y2:$,stroke:B.colours.hairline,strokeWidth:1}),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:`${re(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${s}`)),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:re(e),stroke:B.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${s}`)),T.filter(e=>1===e.length).map((e,s)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:B.colours.gold},`s${s}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:C(e.day),cy:$,r:2,fill:"none",stroke:B.colours.muted,strokeWidth:1},e.date)),S&&'recorded'===S.state?(0,le.jsx)(a.Line,{x1:C(S.day),y1:10,x2:C(S.day),y2:$,stroke:B.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===s);return(0,le.jsx)(a.Circle,{cx:C(e.day),cy:'recorded'===e.state?I(e.value):$,r:4.5,fill:B.colours.gold,stroke:B.colours.surface,strokeWidth:1.5})})():null,S&&'recorded'===S.state&&S.date!==s?(0,le.jsx)(a.Circle,{cx:C(S.day),cy:I(S.value),r:5,fill:B.colours.surface,stroke:B.colours.gold,strokeWidth:2}):null]}):null,r?D.map(e=>(0,le.jsx)(f.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:N(e),accessibilityState:{selected:S?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ne,left:C(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(m.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:W.map(e=>(0,le.jsx)(j.T,{size:F.AXIS_FONT,colour:B.colours.muted,style:{position:'absolute',left:C(e)-17,width:ie,top:0,textAlign:'center'},children:String(e)},e))})]}),S&&D.length?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(f.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:D[0]?.date===S.date,onPress:()=>L(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[0]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(m.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:N(S),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(j.Muted,{center:!0,children:S.date===s?`Today \xb7 ${(0,M.shortDay)(S.date)}`:(0,M.shortDay)(S.date)}),(0,le.jsx)(j.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===S.state?B.colours.goldLight:B.colours.muted,children:'recorded'===S.state?(0,M.poundsWhole)(S.value):'pending'===S.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(f.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:D[D.length-1]?.date===S.date,onPress:()=>L(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[D.length-1]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(j.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ue='#3A2F1E';function he({split:e}){return(0,le.jsx)(j.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(m.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(j.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(m.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",colour:B.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(m.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ue,borderWidth:1,borderColor:B.colours.gold},children:[(0,le.jsx)(m.default,{style:{width:`${e.walkInPct}%`,backgroundColor:B.colours.gold}}),(0,le.jsx)(m.default,{style:{flex:1,backgroundColor:ue}})]})]})]})})}},1432,[860,1160,1433,34,797,1098,1201,1102,1103,1420,1346,877,1106,281,402,102,794,874,891,1209,861,1178,858,1100,881,821,1200,1087,1159,1165,1166,1038,13,1170,927,987,999,1442,1443,1169,1444,1180,869,1447,1204,1223,1222,1060,1061,1093,1125,1390,1173,1345,25]); -__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.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:z}=(0,R.useCtx)(6e4),V=z.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsxs)(j.Muted,{size:12,children:["Uses: ",e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')," from the counted stock. Held from the Display count and shown as \u201cReserved\u201d."]})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),De=J.hourOverrides??[],Re=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:D.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),Re?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:Re}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!Re,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),De.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:De.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...De.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),ze=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,$e]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{$e(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From a party of"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from party size"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:D.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)($.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:ze,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:D.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:D.colours.accentBorder,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:D.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:D.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,R.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:D.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:D.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:D.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),D=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),z=_r(_d[31]),I=_r(_d[32]),$=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:D.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?D.colours.red:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:D.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:D.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:D.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:D.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,z.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:D.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1433,[1161,1062,5,1415,827,1434,1435,1437,1438,1439,1219,1060,1061,1038,1043,34,402,102,794,14,1440,831,878,1100,877,821,1087,874,1203,1008,1009,891,1441,1385,1028,1110,1035,1163,980,25]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1434,[827,34,102,794,1160,877,821,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1435,[860,34,236,102,794,874,1028,1174,1270,987,1341,1436,25]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1436,[860,1294]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1437,[34,102,794,1028,1350,821,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1438,[34,102,794,1028,858,1393,5,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1439,[]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1440,[34,1062,102,821,794,1267,1270,25]); -__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1441,[34,102,794,1028,1363,821,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1442,[]); -__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},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])},1443,[34,402,102,794,821,1169,1442,25]); -__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1444,[927,796,831,828,837,878,1075,1445,34,993,336,379,236,402,102,794,874,891,858,821,1200,1087,1229,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1445,[499,1446]); -__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 t={}},1446,[]); -__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.ProgressBar=D,_e.useSetupDone=O,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,C.useCtx)(6e4),n=O(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=f.SETUP_STEPS.findIndex(e=>e.id===a),s=f.SETUP_STEPS[e+1]?.id??null;return(0,E.jsx)(L,{id:a,wizard:!0,onBack:()=>l(e>0?f.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=f.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,E.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{gap:12,children:[(0,E.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(m.T,{size:20,weight:"bold",colour:S.colours.gold,children:["Set up ",t.name]}),(0,E.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,E.jsx)(D,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,E.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,E.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:S.colours.border,backgroundColor:S.colours.surface,overflow:'hidden'},children:f.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,E.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:S.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,E.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?S.colours.gold:'transparent',borderWidth:1.5,borderColor:t?S.colours.gold:S.colours.border},children:(0,E.jsx)(m.T,{weight:"bold",colour:t?S.colours.onGold:S.colours.muted,children:t?'\u2713':s+1})}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"medium",children:e.title}),(0,E.jsx)(m.Muted,{children:e.sub}),o.length?(0,E.jsxs)(m.T,{size:13,colour:S.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,E.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=L,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return W}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,C.useCtx)(6e4),t=O(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,E.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:"Finish setting up"}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]}),(0,E.jsx)(D,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,E.jsxs)(m.Muted,{size:13,children:["Next: ",f.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]);const M=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],R=[1,2,3,4,5,6,0],I=/^([01]\d|2[0-3]):[0-5]\d$/,$=e=>{const s=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(s)&&s>0?Math.round(100*s):null},B=e=>f.SETUP_STEPS.findIndex(s=>s.id===e)+1;function D({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,E.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,E.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:S.colours.gold,borderRadius:5}})}),(0,E.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function O(e){const s=(0,f.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=f.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:f.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function L({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,C.useCtx)(6e4),l=O(a),r=l.prog,d=(0,i.useLiveVenue)(),u=f.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=_[e];return(0,E.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(m.T,{size:12,weight:"semibold",colour:S.colours.gold,children:["STEP ",B(e)," OF ",f.SETUP_STEPS.length]}),s&&o?(0,E.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,E.jsx)(m.T,{size:13,colour:S.colours.muted,children:"All steps"})}):null]}),(0,E.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,E.jsx)(D,{done:r.done,total:r.total})]}),(0,E.jsx)(b,{rid:a,done:(t="Saved.")=>{f.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,E.jsx)(m.Banner,{kind:"success",title:p}):null,(0,E.jsx)(N,{rid:a,id:e,title:u.title,onDone:x}),s?(0,E.jsxs)(m.Row,{gap:10,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,E.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const A=({wizard:e,onPress:s,disabled:t,label:n})=>(0,E.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const F=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function U({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,C.useHourly)(),d=(0,f.useSiteSetup)(e),u=(0,f.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,w.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,f.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),T(null)},z=!!p?.id&&(M=p.id,k.ROSTER.some(e=>e.id===M));var M;const R=p?$(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=R||z&&!p.wage);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,E.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,E.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?S.colours.gold:S.colours.border,backgroundColor:s?'#1d1a14':S.colours.surface}),children:[(0,E.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"semibold",children:e.name}),(0,E.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,f.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,E.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,f.accessOf)(e.level,e.role)})]},e.id))}),y?(0,E.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:S.colours.gold},children:(0,E.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,E.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,E.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,E.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,E.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,E.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Access level"}),(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:f.ACCESS_LEVELS.map(e=>(0,E.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,E.jsxs)(m.Muted,{size:13,children:["Uses the ",f.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Pay"}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,E.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,E.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,E.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,E.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,w.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,E.jsx)(m.Field,{label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=R&&R<1271?(0,E.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,E.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,E.jsxs)(m.Row,{gap:8,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,E.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),f.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:f.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=R&&s.setRate(t,R);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),f.useSetup.getState().patch(e,{staffGrade:o}),f.useSetup.getState().setLook(t,p.look),T(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,E.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,E.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(F(d.grades[0]?.id??'')),T(null)}}),(0,E.jsx)(A,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const _={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,f.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,E.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,E.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,E.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,E.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':'anchorage'===e?'The Anchorage logo in black and gold.':'greenside'===e?'The Greenside Restaurant logo.':'abbotsford'===e?'The Abbotsford Hotel logo.':'kirkton'===e?'The Kirkton Inn logo.':'wildings'===e?'The Wildings Hotel & Restaurant logo.':'kirkmichael'===e?'The Kirkmichael Arms logo.':'souters'===e?'The Souter\u2019s Inn logo.':'Placeholder initials.'," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,E.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,E.jsx)(P.OrderAtTableCard,{rid:e,compact:!0}),u?(0,E.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,E.jsx)(A,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,C.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=R.filter(e=>{const s=n[e];return s&&(!I.test(s[0])||!I.test(s[1]))});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),M.map((e,s)=>{const t=R[s],l=n[t];return(0,E.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:S.colours.border,paddingTop:s?6:0},children:[(0,E.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,E.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"to"}),(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,E.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,E.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries(R.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,E.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,E.jsx)(A,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,y.usePlan)(e),o=(0,y.planCounts)(n);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.TablePlan,{startStep:"areas"}),(0,E.jsx)(A,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,E.jsx)(U,{...e,payList:!0})]})},staff:U,permissions:function({done:e,wizard:s}){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(z.PermissionsScreen,{}),(0,E.jsx)(A,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,f.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,E.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,E.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,E.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,E.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,E.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,E.jsx)(A,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),a=(0,f.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,T.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,E.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,E.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:S.colours.border,padding:10},children:(0,E.jsx)(m.T,{size:14,colour:S.colours.goldLight,children:i})}),(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,T.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,E.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,E.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,E.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,E.jsx)(A,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),f.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,C.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,E.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,E.jsx)(A,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},W=e=>function(){return(0,E.jsx)(L,{id:e})};function N({rid:e,id:s,title:t,onDone:n}){const o=O(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,E.jsxs)(g.default,{style:{gap:4},children:[(0,E.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),f.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,E.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,E.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1447,[929,928,828,827,1075,1448,1449,1450,1451,1453,34,402,102,873,925,794,874,891,1028,927,15,867,821,1087,1454,1457,1461,1462,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1448,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1449,[34,987]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1450,[34,846,987]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1451,[2,827,34,236,383,102,794,1452,987,821,1204,1003,891,993,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1452,[]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1453,[34,402,794,987,821,1451,25]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1454,[827,979,1160,987,797,1237,1239,34,281,379,236,402,102,426,879,794,874,1248,891,867,858,821,1200,1087,869,1444,1179,1455,1456,1159,1166,1165,1038,13,1163,1169,1229,25]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1455,[827,34,1235,1055,870,379,402,102,794,891,867,858,821,1200,1087,1229,25]); -__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1456,[1015,34,402,102,794,891,821,1087,987,25]); -__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1457,[827,34,1047,395,102,1133,1134,1361,1390,794,1025,1028,858,821,1087,1029,1458,1459,1049,25]); -__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1458,[827,34,402,102,794,821,1028,5,1029,872,987,25]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1459,[34,102,794,1028,1460,859,821,1074,933,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1460,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1461,[5,1415,34,102,794,874,891,25]); -__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.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1462,[34,281,402,102,794,821,999,1463,25]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1463,[933,987,891,872,999]); -__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.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=M,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=M(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',O[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:O[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withWildingsQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function M(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const O={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from Bidfood or Booker? Add them here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1464,[832,1206,34,281,283,364,395,236,295,102,36,794,873,876,891,1028,1065,1066,5,859,1063,1073,821,872,1087,1465,1468,25]); -__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.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1465,[827,34,379,402,295,102,794,1466,1467,821,1464,1087,891,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1466,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1467,[839,846,849]); -__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.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1468,[34,402,102,794,876,1467,1028,859,1469,1073,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1469,[]); -__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1470,[828,34,283,364,236,402,102,846,794,821,25]); -__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1471,[1201,1098,1139,1116,34,402,102,794,891,858,821,1117,1187,1087,1198,1444,1180,876,1202,869,1200,925,1421,1028,860,1125,1217,1221,1097,25]); -__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.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1472,[34,1100,102,426,794,874,1162,1160,877,858,821,891,1200,1087,1169,1165,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1473,[846]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=P,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,x]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),v=n.filter(e=>!(0,k.LIVE)(e)).slice(0,8),R=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),A=R.filter(e=>'due'===e.state||'overdue'===e.state),M=R.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,B.jsxs)(o.default,{style:{gap:12},children:[(0,B.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),b?(0,B.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,B.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,B.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,B.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,B.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,B.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===A.length?(0,B.jsx)(i.Muted,{children:"Nothing due right now."}):null,A.map(e=>(0,B.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,y.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,B.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,B.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,B.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),M.map(e=>(0,B.jsxs)(i.Muted,{children:[(0,y.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,y.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,B.jsx)(k.SectionHead,{title:"Live orders",right:(0,B.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,B.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,B.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,B.jsx)(P,{o:e},e.id)),v.length?(0,B.jsx)(k.SectionHead,{title:"Recently completed"}):null,v.map(e=>(0,B.jsx)(i.Card,{style:{opacity:.7},children:(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,B.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,B.jsx)(O,{onClose:e=>{h(!1),e&&x(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),x=_r(d[13]),y=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),v=_r(d[22]),B=_r(d[23]);const R={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function O({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),y=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,R]=(0,r.useState)(''),[O,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[N,$]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,F]=(0,r.useState)(''),[_,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,x.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries(N).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(y.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,v.ukPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,v.emailOk)(_),J=K.length>0&&Y&&(Q?O.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(y.map(e=>e.section)));return(0,B.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,B.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,B.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,B.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,B.jsx)(i.Field,{label:"Table number",value:O,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,B.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:R,placeholder:"e.g. Mrs Reid"}),Q?null:(0,B.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:F,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,B.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,B.jsx)(i.Field,{label:"Email (optional)",value:_,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too"}),'phone'===T?(0,B.jsxs)(o.default,{style:{gap:4},children:[(0,B.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,B.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,B.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,B.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),y.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,B.jsxs)(o.default,{style:{flex:1},children:[(0,B.jsx)(i.T,{size:15,children:e.name}),(0,B.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,B.jsx)(i.Stepper,{value:N[e.id]??0,min:0,max:20,label:e.name,onChange:t=>$({...N,[e.id]:t})})]},e.id)),(0,B.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,B.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,B.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,B.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,B.jsx)(l.GreensideCashOnly,{}):(0,B.jsx)(i.Banner,{kind:"demo",title:"Card payments: not set up yet",children:"Pay on collection or at the table. Nothing is charged in the app."}),(0,B.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?O.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:_.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${O.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function P({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),x=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,B.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,B.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,B.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,B.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,y.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",R[e.channel??(e.type,'app')]," \xb7 ",(0,y.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,B.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,B.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,B.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,B.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,B.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,B.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,y.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,B.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,B.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,B.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,B.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,B.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:x,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,B.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,B.jsx)(i.Button,{small:!0,kind:"ghost",label:"Reject",onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1474,[5,1415,860,1385,34,102,794,874,876,881,861,867,1178,1130,858,821,1200,1087,1179,1180,869,1422,864,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return pe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),b=_r(d[9]),h=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),E=_r(d[18]),N=_r(d[19]),P=_r(d[20]),W=_r(d[21]),A=_r(d[22]),R=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),G=_r(d[27]),B=(e=G)&&e.__esModule?e:{default:e},x=_r(d[28]),D=_r(d[29]),I=_r(d[30]),L=_r(d[31]),H=_r(d[32]),_=_r(d[33]),F=_r(d[34]),V=_r(d[35]),Q=_r(d[36]),q=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),K=_r(d[41]),z=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),ae=_r(d[49]),se=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),de=_r(d[55]),ue=_r(d[56]),le=_r(d[57]),ge=_r(d[58]),ce=_r(d[59]);const pe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},be=e=>n.CAN.manage(e);(0,y.register)([{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>be(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:be,C:R.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:w.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:be,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>be(e)&&!r.IS_CAR,badge:'NEW',C:P.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:be,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:be,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',badge:'NEW',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:be,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:be,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:be,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:be,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:b.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:be,badge:'NEW',C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:h.PLAN_SUB,group:'Account',can:n.CAN.billing,C:h.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',badge:'NEW',C:T.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',badge:'NEW',C:W.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:W.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',badge:'NEW',can:be,C:A.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:W.Timesheets}]),(0,y.register)([{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:M.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:M.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',badge:'NEW',can:be,C:E.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',badge:'NEW',can:be,C:N.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'Photo of the cash up sheet, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',badge:'NEW',can:be,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:M.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:M.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:M.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:be,C:M.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:be,C:M.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:be,C:M.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:be,C:M.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:be,C:M.ReviewEmailSettings},{id:'compliance',title:'Daily checks & allergen log',sub:'Fridge temps, opening checks, audit log',group:'Compliance',C:M.Compliance},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:M.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:be,badge:'NEW',C:M.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:M.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:O.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>pe(),C:O.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:be,C:O.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:be,C:O.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:O.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:be,C:O.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:be,C:O.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:be,C:O.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:be,C:O.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:O.TabletPreview}]);const he=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',badge:'NEW',C:()=>B.default.createElement(D.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:x.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',badge:'NEW',can:he,C:x.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',badge:'NEW',can:he,C:D.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',badge:'NEW',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:I.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',badge:'NEW',C:L.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:be,C:L.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:be,badge:'NEW',C:L.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:be,badge:'NEW',C:H.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:be,badge:'NEW',C:H.DisplaySettingsPage}]);const fe=e=>'owner'===e||'manager'===e;_.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:fe,badge:'NEW',C:_.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off, voice, connected services',group:'Account',can:fe,C:_.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',badge:'NEW',can:e=>'owner'===e&&!r.IS_CAR,C:V.CarScreen}]);const ye=e=>'owner'===e||'manager'===e,me=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Ce=e=>ye(e)&&me();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ye,badge:'NEW',C:F.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Prices},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning, allergen checks; filters; CSV and print for the EHO',group:'Compliance',can:ye,badge:'NEW',C:F.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ye,badge:'NEW',C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',badge:'NEW',C:F.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:be,badge:'NEW',C:Q.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:be,badge:'NEW',C:Q.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:be,badge:'NEW',C:Q.Outbox}]);const Se=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Se,badge:'NEW',C:U.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Se,badge:'NEW',C:q.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Se,badge:'NEW',C:Y.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Se,badge:'NEW',C:j.OrderSheetSettings},...K.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Se,C:(0,q.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Se,badge:'NEW',C:z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Se,badge:'NEW',C:$.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:be,badge:'NEW',C:$.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Se,badge:'NEW',C:$.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Se,badge:'NEW',C:J.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:be,badge:'NEW',C:X.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:be,badge:'NEW',C:X.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:be,badge:'NEW',C:X.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:be,badge:'NEW',C:Z.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:be,badge:'NEW',C:ee.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:be,badge:'NEW',C:ae.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, Booker and Bidfood lists, offers, events and specials the voice helper prepared; nothing is sent',group:'Run the day',can:be,badge:'NEW',C:se.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift, left by voice or typing',group:'Run the day',badge:'NEW',C:se.ShiftNotesPage},{id:'voice',title:'Voice helper',sub:'Hold-to-talk input, text-only replies, who gets it and microphone privacy',group:'Settings',can:be,badge:'NEW',C:se.VoiceSettingsPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ie.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update',group:'Compliance',can:ye,badge:'NEW',C:function(){return B.default.createElement(re.FoodSafetyCard,null)}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ne.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ye,badge:'NEW',C:function(){const{rid:e,today:t}=(0,oe.useCtx)(6e4);return B.default.createElement(ne.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',badge:'NEW',C:function(){const{rid:e,me:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:be,badge:'NEW',C:te.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',badge:'NEW',C:function(){const{me:e,role:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(ue.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:be,C:le.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:be,C:ge.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,badge:'NEW',C:ce.UseOnComputerPage}])},1475,[837,1085,872,1476,891,1003,993,831,881,1478,1485,1495,1456,1496,1497,1499,1500,1472,1501,1502,1504,1218,1209,1474,1505,1454,1506,34,1217,1198,1455,1444,1457,1489,1511,1512,1513,1447,1433,1461,1514,927,1515,1516,1518,1204,1464,1519,1385,1465,1531,1107,1110,1087,1219,1173,1532,1535,1538,1541]); -__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,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return k}}),_e.DashCorners=I,_e.ServiceBoard=function(){const{role:e}=(0,j.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,D.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,D.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,D.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,D.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,D.jsx)(I,{onLeave:y}),(0,D.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,D.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,D.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,D.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,D.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,D.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?w((0,D.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]),D=r(d[16]);const k=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function C({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,D.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,D.jsxs)(s.default,{children:[(0,D.jsx)(p.Icon,{name:t,colour:h.colours.gold}),u?(0,D.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,D.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function I({onLeave:e}){const t=(0,x.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>y.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,D.jsx)(C,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,D.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,D.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:k.filter(e=>'left'===e.side).map(n)}),(0,D.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[k.filter(e=>'right'===e.side).map(n),(0,D.jsx)(C,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')}),(0,D.jsx)(f.VoiceSlot,{size:44,layer:1})]})]})}function w(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[17]);return t(e,document.body)}},1476,[34,395,236,402,102,36,794,1055,1343,891,821,1156,1477,1206,1473,1087,25,277]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1477,[846]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, take a picture of the taking sheet and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1478,[827,1453,34,867,102,794,891,821,1087,925,926,1479,987,1000,1060,1451,1480,1481,1483,1026,1484,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1479,[]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1480,[827,34,102,794,821,891,1395,1405,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1481,[34,102,794,1482,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1482,[846,933,987,2]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1483,[34,102,794,821,998,1051,987,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1484,[933,987]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_VOICE_LINE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_SUPPLIER_LINE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DONE_FOR_YOU",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"doneForYouLine",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return v}}),_e.PlanBilling=function(){const{now:e,role:n,rid:b}=(0,p.useCtx)(6e4),j=(0,c.trialStatus)((0,l.defaultSimStart)(),e),[x,w]=(0,s.useState)(!1);return u.CAN.billing(n)?x?(0,y.jsx)(M,{onBack:()=>w(!1)}):(0,y.jsxs)(i.default,{style:{gap:10},children:[(0,y.jsx)(o.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,y.jsx)(t.VoiceUsageCard,{rid:b,now:e}),(0,y.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,y.jsxs)(i.default,{testID:"plan-founding",children:[(0,y.jsx)(o.T,{size:12,weight:"semibold",colour:h.colours.goldMuted,children:"FOUNDING OFFER \xb7 FIRST 50 VENUES"}),(0,y.jsxs)(o.T,{size:30,weight:"bold",children:["\xa349",(0,y.jsx)(o.T,{size:14,colour:h.colours.muted,children:" a month + VAT if applicable, per venue"})]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,y.jsx)(o.Badge,{kind:"gold",label:"Every Full Restaurant Pro feature"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"One month free"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"\xa349 net locked in"})]}),(0,y.jsx)(o.Muted,{children:"Early adopter price for the first 50 venues: every Full Restaurant Pro App feature, including the owner's dashboard and admin and the voice Assistant. \xa349 net stays locked in while your subscription stays active."}),(0,y.jsxs)(o.T,{size:13,testID:"plan-early-done-for-you",children:["\u2713 ",T(P.early)]}),(0,y.jsx)(o.Muted,{children:"From venue 51, usual prices:"}),(0,y.jsxs)(i.default,{testID:"plan-usual-lite",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[k," \xb7 ",C," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:S}),O.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e)),(0,y.jsx)(o.T,{size:13,testID:"plan-lite-not-included",children:"Not included: the owner's dashboard and admin, or the voice Assistant."})]}),(0,y.jsxs)(i.default,{testID:"plan-usual-pro",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[_," \xb7 ",L," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:v}),R.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e))]}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>w(!0),style:{marginTop:6}})]}),(0,y.jsx)(o.Card,{children:(0,y.jsxs)(i.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,y.jsx)(o.T,{weight:"bold",colour:h.colours.gold,children:"free"}),"."]}),(0,y.jsx)(o.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,y.jsx)(o.Muted,{children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, and subscribers get free lifetime 24/7 customer support. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{children:"Free trial"}),(0,y.jsxs)(o.T,{weight:"bold",colour:h.colours.gold,children:[j.daysLeft," day",1===j.daysLeft?'':'s'," left"]})]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(100*(1-j.daysLeft/j.total))}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),(0,y.jsxs)(o.Muted,{children:["Then \xa3",c.PLAN.monthlyPence/100," a month + VAT if applicable. The trial start date is not set up yet."]})]}),(0,y.jsx)(f.AssistantPlanCard,{}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{weight:"semibold",children:"Free lifetime customer support"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"Included"})]}),(0,y.jsx)(o.Muted,{children:"Free for as long as you subscribe, day or night. Setup is all done digitally. Support contact details: not set up yet."})]})]}):(0,y.jsx)(o.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),i=(e=n)&&e.__esModule?e:{default:e},o=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]);const b=!0,j='Founding offer, free trial, set-up guide',x='. The owner\'s dashboard and admin come with Full Restaurant Pro App (\xa399 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',w='Voice Assistant (hold to talk) for seating guests, marking tables as cleared, temperature logs and finding something in the app: fair usage 1,000 voice tasks a month per venue',A='Supplier links: open your suppliers\' ordering sites and keep order lists',P={lite:1,pro:3,early:3},T=e=>`${e} done-for-you ${1===e?'change':'changes'} a month`,k='Customer & Takeaway App',_='Full Restaurant Pro App',C='\xa349',L='\xa399',S='A lite version of CoverCharge: 3 core customer and takeaway functions tailored to you, set up digitally with the in-app guided setup and step-by-step guides, free lifetime 24/7 customer support while subscribed, and unlimited self-edits of your basic info. The owner\'s dashboard and admin, and the voice Assistant, are not included.',v='Every feature, every app, including the owner\'s dashboard and admin and the voice Assistant. Set up digitally with the in-app guided setup and step-by-step guides, the Assistant (fair use 300 tasks a month), free lifetime 24/7 customer support while subscribed, and unlimited self-edits.',O=['Customer app: menu, allergens, bookings and loyalty','Takeaway ordering','Set up digitally: in-app guided setup and step-by-step guides','Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits of your basic info',T(P.lite)],R=['Every feature, every app','The owner\'s dashboard and admin',A,'Set up digitally: in-app guided setup and step-by-step guides','The Assistant, fair use 300 tasks a month',w,'Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits',T(P.pro)],I=[['Choose your 3 core functions','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function M({onBack:e}){const[t,n]=(0,s.useState)([]);return(0,y.jsxs)(i.default,{style:{gap:10},testID:"setup-guide",children:[(0,y.jsx)(o.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,y.jsx)(o.H2,{children:"Set-up guide"}),(0,y.jsxs)(o.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",t.length," of ",I.length," done."]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(t.length/I.length*100)}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),I.map(([e,s],l)=>{const u=t.includes(l);return(0,y.jsx)(o.Card,{children:(0,y.jsxs)(o.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,y.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:u?h.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(o.T,{size:14,weight:"bold",colour:u?'#1a1610':h.colours.gold,children:u?'\u2713':String(l+1)})}),(0,y.jsxs)(i.default,{style:{flex:1,gap:4},children:[(0,y.jsx)(o.T,{weight:"semibold",children:e}),(0,y.jsx)(o.Muted,{children:s}),(0,y.jsx)(o.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>n(u?t.filter(e=>e!==l):[...t,l])})]})]})},e)}),(0,y.jsx)(o.Muted,{children:"Stuck? Free lifetime customer support is included while you subscribe. Ticks on this guide are not saved."})]})}},1485,[1486,34,102,794,850,891,1488,821,1087,1489,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1486,[34,102,794,821,1487,25]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1487,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1488,[]); -__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,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return v}}),_e.AssistantFab=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)(e=>e.enabled);return R(e)&&t?(0,A.jsxs)(c.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>v.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:k.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,A.jsx)(M,{size:22}),(0,A.jsx)(b.T,{weight:"bold",colour:I,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=v(e=>e.open),o=()=>v.getState().setOpen(!1),{rid:a,role:p,me:C}=(0,w.useCtx)(3e4),S=(0,j.useAssistant)(),I=B(),[E,L]=(0,r.useState)([]),[W,z]=(0,r.useState)(''),[$,_]=(0,r.useState)(!1),N=(0,r.useRef)(null),F=(0,r.useRef)(null);if((0,r.useEffect)(()=>{setTimeout(()=>N.current?.scrollToEnd?.({animated:!0}),50)},[E.length]),!e||!R(p))return null;const H=(e,t,s)=>j.useAssistant.getState().record({at:(new Date).toISOString(),by:C,role:p,asked:e,action:t,outcome:s}),U=(e,t="result")=>L(s=>[...s,{id:D(),from:'assistant',text:e,kind:t}]),V=async e=>{const t=e.trim();if(!t)return;let s;z(''),L(e=>[...e,{id:D(),from:'you',text:t}]);try{s=await(0,y.getProvider)('xai').interpret(t,I)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&H(t,'\u2014','not understood'),L(e=>[...e,{id:D(),from:'assistant',proposal:s,state:'open',asked:t}])},G=(e,t)=>L(s=>s.map(s=>s.id===e?{...s,state:t}:s)),q=async(e,t,n)=>{if(G(e.id,'confirmed'),'external'===t.kind)return H(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void U(T,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await m.repo.bookings.seatWalkIn(a,Number(o.party),s,'Added by Assistant'),s&&(0,f.resetTableLive)(a,s),U(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),H(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),U(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),H(e.asked,t.title,'done');break;case'price':await m.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),U(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),H(e.asked,t.title,'done');break;case'offer':x.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),U(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),H(e.asked,t.title,'done');break;case'rota':case'bookings':U(String(o.result)),H(e.asked,t.title,'looked up')}},Y=e=>{G(e.id,'cancelled'),H(e.asked,e.proposal?.title??'\u2014','cancelled'),U('Cancelled. Nothing was changed.','note')},K='lite'===S.tier,J=(0,j.tasksUsed)(S);return(0,A.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,A.jsx)(h.default,{style:[b.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,A.jsxs)(h.default,{testID:"assistant-sheet",style:{backgroundColor:k.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:k.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.Row,{gap:8,style:{flex:1},children:[(0,A.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:18})}),(0,A.jsx)(b.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,A.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,A.jsx)(h.default,{testID:"assistant-demo-badge",children:(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),K?(0,A.jsxs)(h.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,A.jsx)(b.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,A.jsx)(b.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(u.default,{ref:N,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===E.length?(0,A.jsxs)(h.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,A.jsxs)(b.T,{children:["Hi ",C.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,A.jsx)(b.Muted,{children:"Try:"}),y.SUGGESTED_PROMPTS.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:k.colours.surface2},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]}):null,E.map(e=>'you'===e.from?(0,A.jsx)(h.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,A.jsx)(b.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,A.jsx)(P,{m:e,onConfirm:(t,s)=>q(e,t,s),onCancel:()=>Y(e)},e.id):'choose'===e.proposal.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),(0,A.jsx)(b.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>V(e.prompt)},e.label))})]},e.id):(0,A.jsxs)(h.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:8},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]},e.id):(0,A.jsx)(h.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?k.colours.amberBg:k.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:k.colours.amber},children:(0,A.jsx)(b.T,{children:e.text})},e.id))]}),(0,A.jsxs)(b.Row,{gap:8,children:[(0,A.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:W,onChangeText:z,onSubmitEditing:()=>V(W),returnKeyType:"send",style:[b.styles.input,{flex:1,minWidth:0,width:40}]}),S.voice?(0,A.jsx)(c.default,{testID:"assistant-mic",accessibilityRole:"button",accessibilityLabel:$?'Stop listening':'Speak',onPress:()=>{const e=O();if(e)if($)F.current?.stop?.();else try{const t=new e;F.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&z(t)},t.onend=()=>_(!1),t.onerror=()=>{_(!1),U("Sorry, I didn't catch that. You can type instead.",'note')},_(!0),t.start()}catch{_(!1),U("Voice input isn't available here. Please type instead.",'note')}else U("Voice input isn't available in this browser (for example Huawei Browser). Please type your request instead.",'note')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:$?k.colours.gold:'transparent'},children:(0,A.jsx)(b.T,{size:20,children:"\ud83c\udfa4"})}):null,(0,A.jsx)(b.Button,{label:"Send",accessibilityLabel:"Send",disabled:!W.trim(),onPress:()=>V(W)})]}),(0,A.jsxs)(b.Muted,{center:!0,children:["Demo on this device \xb7 ",J," of ",j.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,w.useCtx)(6e4),s=(0,j.useAssistant)();return R(t)?(0,A.jsxs)(h.default,{style:{gap:12},children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{gap:10,children:[(0,A.jsx)(h.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:22})}),(0,A.jsxs)(h.default,{style:{flex:1},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,A.jsx)(b.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,A.jsx)(b.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>v.getState().setOpen(!0)}),(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,A.jsxs)(h.default,{testID:"assistant-log",style:{gap:6},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>j.useAssistant.getState().clearLog()}):null]}),(0,A.jsx)(b.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,A.jsx)(b.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,A.jsxs)(h.default,{style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.T,{size:12,colour:k.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,A.jsx)(b.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,A.jsxs)(b.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,A.jsxs)(b.T,{size:13,colour:k.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,A.jsx)(b.Muted,{children:"The activity log is visible to the owner."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)();return R(e)?(0,A.jsxs)(h.default,{style:{gap:12},testID:"assistant-settings",children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,A.jsx)(b.Muted,{children:"Shows the gold Assistant button on every Managers screen."}),(0,A.jsx)(b.Toggle,{label:"Voice input (microphone)",value:t.voice,onChange:e=>t.set({voice:e})}),(0,A.jsx)(b.Muted,{children:"What you say is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. If this device can\u2019t record, just type."})]}),(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Connected services"}),E.map(e=>(0,A.jsxs)(h.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:k.colours.border,paddingTop:8},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{children:e.name}),(0,A.jsx)(b.Badge,{kind:"neutral",label:"Not connected"})]}),(0,A.jsxs)(b.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,A.jsx)(b.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,A.jsx)(b.Muted,{children:"The Assistant comes with Full Restaurant Pro App and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,A.jsx)(b.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to the voice assistant to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,j.useAssistant)(),t=(0,j.tasksUsed)(e),s=Math.min(1,t/j.FAIR_USE);return(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,A.jsx)(b.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,A.jsx)(h.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${j.FAIR_USE} tasks used`,style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,A.jsx)(h.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:k.colours.gold,borderRadius:4}})}),(0,A.jsxs)(b.Muted,{children:[t," of ",j.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]),a=_r(d[4]),r=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var c=e(_r(d[8])),u=e(_r(d[9])),h=e(_r(d[10])),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),m=_r(d[14]),x=_r(d[15]),y=_r(d[16]),j=_r(d[17]),k=_r(d[18]),w=_r(d[19]),C=_r(d[20]),A=_r(d[21]);const S=!0,T='Nothing was sent or changed: this connection is not set up yet.',I='#1A1408',v=(0,p.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=e=>'owner'===e||'manager'===e,D=()=>Math.random().toString(36).slice(2,9);function M({size:e=24,colour:t=I}){return(0,A.jsx)(b.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function B(){const{rid:e,r:t,now:s,today:n}=(0,w.useCtx)(3e4),a=(0,m.useAllMenu)(e),l=(0,f.useTableNames)(e),c=(0,m.useBookings)(e),u=(0,x.useOwner)(e=>e.staff),h=(0,x.useOwner)(e=>e.shifts),p=(0,x.useOwner)(e=>e.offers),b=(0,x.useOwner)(e=>e.suppliers);return(0,r.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:a.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:l,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,C.workingShifts)(h,x.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,x.addDays)(n,-(0,x.weekdayOf)(n))&&e.date<=(0,x.addDays)(n,6-(0,x.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${b[0]?.contact??'Alex Sample'}, ${b[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),a,l,c,u,h,p,b])}function P({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[a,l]=(0,r.useState)(!1),[c,u]=(0,r.useState)('external'===o.kind?o.text:''),p='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,A.jsxs)(h.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:p?k.colours.gold:k.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:k.colours.surface2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,A.jsx)(b.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[o.detail?(0,A.jsx)(b.Muted,{children:o.detail}):null,(0,A.jsx)(b.T,{size:14,colour:k.colours.muted,children:o.label}),a&&p?(0,A.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:u,style:[b.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,A.jsx)(h.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:k.colours.gold,paddingLeft:10},children:(0,A.jsxs)(b.T,{children:["\u201c",c,"\u201d"]})}),(0,A.jsxs)(b.Muted,{children:["Sends to: ",o.service.map(e=>y.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,A.jsxs)(h.default,{style:{gap:4},children:[(0,A.jsx)(b.Muted,{children:o.detail}),o.warning?(0,A.jsxs)(b.T,{size:13,colour:k.colours.amber,children:["\u26a0 ",o.warning]}):null]}),p?(0,A.jsxs)(b.Row,{wrap:!0,gap:8,children:[(0,A.jsx)(b.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:a?'Done editing':'Edit',testID:"edit-action",onPress:()=>l(!a)}):null,(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,A.jsx)(b.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),p?(0,A.jsxs)(b.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}function O(){return'undefined'==typeof window?null:(0,a.speechRecognizer)()}const E=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1489,[827,979,796,884,931,34,395,236,402,295,102,846,794,1125,874,891,1490,1494,821,1087,1097,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);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]}})})},1490,[1491,1493,1492]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1491,[860,1492]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1492,[]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Voice assistant (server, with on-device fallback)',interpret:s}},1493,[1491,932]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1494,[884,839,846,849]); -__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.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1495,[5,1062,979,1415,828,827,837,1270,1440,34,402,410,102,879,794,874,891,861,867,858,821,1200,1087,1179,1444,1229,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1496,[860,34,102,1180,794,874,861,869,858,821,1200,1087,25]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1497,[1075,34,102,1498,829,873,794,891,821,1087,25]); -__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.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1498,[827,34,236,402,102,797,829,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1499,[34,1175,863,1087,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1500,[34,1061,1087,987,999,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1501,[34,1391,1087,25]); -__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.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:s}=(0,c.useCtx)(6e4),a=(0,r.useBookings)(e),n=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,t.useState)('day'),k=(0,d.hasAnyTakings)(n,e),w=(0,d.dayRows)(n,a,e,s,14),f=(0,d.weekRows)(n,a,e,s,8),v=(0,d.averageSph)(w),$=(e,t,s,a,n)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${t}: ${'No takings entered'===a?'no takings entered':`spend per head ${a}`}, ${s}${n?`, ${n}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:t}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:s}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===a?h.colours.muted:h.colours.goldLight,size:'No takings entered'===a?13:16,children:a}),n?(0,u.jsx)(i.Muted,{center:!0,children:n}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:k?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:w.map(e=>({label:x(e.date),value:e.sph}))}),[...w].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),a=_r(_d[2]),n=e(a),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,t.useState)(320),[x,y]=(0,t.useState)(e.length);(0,t.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),k=Math.max(0,j-b),w=e.slice(k,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),T=e=>38+e*(f-76)/Math.max(1,w.length-1),S=e=>140-e/$*106,L=[];let D=[];w.forEach((e,t)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:t,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(n.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(a.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(n.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(a.Line,{x1:0,x2:f,y1:S($*e/4),y2:S($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,t)=>(0,u.jsx)(a.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},t)),w.map((e,t)=>(0,u.jsx)(s.default.Fragment,{children:null==e.value?(0,u.jsx)(a.Circle,{cx:T(t),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.Circle,{cx:T(t),cy:S(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(a.Text,{x:T(t),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},k+t))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:w.map((e,t)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},k+t))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===k,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1502,[34,102,797,794,874,1038,1503,821,1087,25]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1503,[13]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1504,[34,102,1351,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1505,[34,793,1087,25]); -__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.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1506,[5,1415,827,837,860,1507,1439,1477,1235,14,1270,987,1508,1510,1440,34,1125,1485,30,402,102,879,1290,794,874,891,867,881,1130,1259,858,821,1200,1087,1159,884,1456,869,1055,1175,863,861,25]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1507,[860,34,102,794,861,867,1174,874,869,821,25]); -__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1508,[987,34,281,236,102,1290,794,1267,1270,821,1509,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1509,[34,236,102,794,1267,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1510,[5,1415,34,102,794,867,1267,1268,1269,987,1270,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1511,[34,1224,1177,1225,1232,1087,1191,863,872,1024,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1512,[34,102,794,987,858,821,25]); -__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.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["Every booking and takeaway order gets a text (a phone number is needed to book) and an email if they gave one. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1513,[828,827,837,34,236,402,102,794,1237,874,1494,864,1239,1047,821,1056,1087,25]); -__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.OrderSheetSettings=function(){const e=(0,i.useOwner)(e=>e.site),u=(0,o.useSheets)(e),[c,m]=(0,l.useState)(null);return c?(0,p.jsxs)(s.Card,{children:[(0,p.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===c.id)?`Edit ${c.name}`:'New supplier'}),(0,p.jsx)(x,{rid:e,s:c,onDone:()=>m(null)})]}):(0,p.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,p.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,p.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,p.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,p.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,p.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,p.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,p.jsx)(s.Row,{wrap:!0,gap:8,children:(0,p.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var l=r(_d[0]),t=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),i=r(_d[4]),o=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]);const c=['online','phone','text','whatsapp','tbc'];function m({label:e,value:l,onChange:t}){return(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,p.jsx)(s.Chip,{label:e,selected:l.includes(n),onPress:()=>t(l.includes(n)?l.filter(e=>e!==n):[...l,n].sort())},e))})]})}function x({rid:e,s:t,onDone:i}){const d=(0,o.useOrderSheets)(e=>e.upsert),x=(0,o.useOrderSheets)(e=>e.remove),[b,f]=(0,l.useState)(t),[j,y]=(0,l.useState)(t.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[C,v]=(0,l.useState)(t.priceCapPerKg?(t.priceCapPerKg/100).toFixed(2):''),[w,T]=(0,l.useState)(!1),D=e=>f(l=>({...l,...e}));return(0,p.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,p.jsx)(s.Field,{label:"Supplier name",value:b.name,onChangeText:e=>D({name:e})}),(0,p.jsx)(s.Field,{label:"What they supply",value:b.goods,onChangeText:e=>D({goods:e})}),(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:c.map(e=>(0,p.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:b.method===e,onPress:()=>D({method:e})},e))})]}),'text'===b.method||'whatsapp'===b.method||'phone'===b.method?(0,p.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:b.number,keyboardType:"phone-pad",onChangeText:e=>D({number:e})}):null,'online'===b.method?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:b.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>D({url:e.trim()})}),(0,p.jsx)(s.Field,{label:"Button label",value:b.urlLabel??'',placeholder:"Open website",onChangeText:e=>D({urlLabel:e})})]}):null,(0,p.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:b.contact??'',onChangeText:e=>D({contact:e})}),(0,p.jsx)(m,{label:"Delivery days",value:b.deliveryDays,onChange:e=>D({deliveryDays:e})}),(0,p.jsx)(m,{label:"Order days (a reminder shows in the Head Chef app)",value:b.orderDays,onChange:e=>D({orderDays:e})}),(0,p.jsxs)(s.Row,{gap:10,children:[(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:b.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>D({cutoff:e})})}),(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Price cap \xa3/kg (optional)",value:C,keyboardType:"decimal-pad",onChangeText:v})})]}),(0,p.jsx)(s.Field,{label:"Reminder text (optional)",value:b.reminder,onChangeText:e=>D({reminder:e})}),(0,p.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:b.frequency,onChangeText:e=>D({frequency:e})}),b.priceCapPerKg||C?(0,p.jsx)(s.Field,{label:"Seller",value:b.seller,onChangeText:e=>D({seller:e})}):null,(0,p.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:y}),(0,p.jsx)(s.Field,{label:"Notes for the chef",value:b.notes,multiline:!0,onChangeText:e=>D({notes:e})}),(0,p.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,p.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const l=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,l)=>{const[n,s]=e.split('|').map(e=>e.trim()),i=t.items.find(e=>e.name===n);return{id:i?.id??`${b.id}-i${l}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*parseFloat(C.replace(/[\xa3,]/g,'')));d(e,{...b,items:l,priceCapPerKg:n>0?n:0,placeholder:b.placeholder&&'tbc'===b.method}),i()},disabled:!b.name.trim()}),(0,p.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:i}),w?(0,p.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{x(e,t.id),i()}}):(0,p.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>T(!0)})]})]})}},1514,[34,402,102,794,891,1030,867,1031,821,25]); -__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.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1515,[34,236,402,102,426,794,821,1373,873,1375,858,987,1376,1087,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1516,[835,984,1454,34,236,102,794,831,891,983,1030,985,987,1517,821,2,1181,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1517,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1518,[34,102,794,821,1435,1507,1087,25]); -__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.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1519,[827,1062,796,34,402,102,794,891,1470,1520,1521,1522,821,1087,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1520,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1521,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1522,[1523,1127,860,1524,1525,891,874,1028,1470,1520,1521,1527,1526,1529,1530,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1523,[1092,1091,1052]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1524,[984,1127,835,860,874,831,1028,983,985,1039,891,1094,882,863,861]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1525,[835,874,831,1028,891,1033,1043,1044,1009,1008,1038,13,1063,1064,1065,1034,1094,882,1104,1025,870,1526,1524]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1526,[835,979,1127,860,1160,1270,874,831,1028,1033,994,862,861,1104,1105,1025,1034,867,1527,1528]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1527,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1528,[839,846,849]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1529,[831,891,994,867,1526,1046,1097]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1530,[]); -__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.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"Staff hold the gold button, say what they need and let go. It sits at the top right in Managers, Head Chef, the Staff app (the full voice assistant, without team financial or HR information) and on the Display (no money, tips or HR either), never in the customer app. Tap it to type or open the Assistant. Replies and change confirmations are shown in text, never spoken. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts for you."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,r.useDrafts)(e=>e.drafts),u=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[j,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:r.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The voice helper and the Assistant save bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting. Try holding the voice button and saying \u201cadd blue roll to the Booker list\u201d."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!j,onClose:()=>y(null),title:'approved'===j?.status?'Approve this draft?':'Dismiss this draft?',children:j?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:j.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===j.status?`This marks it approved${v[j.d.kind]?` and opens ${v[j.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===j.status?'success':'danger',label:'approved'===j.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(j.d.id,j.status,o.replace(' (example)',''));const e=v[j.d.kind];y(null),'approved'===j.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const v={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1531,[34,379,102,794,821,1466,1527,1477,1528,1157,931,1486,1087,25]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1532,[34,796,102,794,861,1267,1533,1534,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1533,[861]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1534,[987,1533,1270]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_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]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1535,[34,102,794,874,1038,1536,979,13,1537,1049,821,1087,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1536,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(o){const{rid:u,date:c,bookings:f,cashUps:p,fields:v,soldOut:h}=o,b=f.filter(t=>t.restaurantId===u&&t.date===c),k=p.find(t=>t.rid===u&&t.date===c&&t.confirmedAt),y=p.find(n=>n.rid===u&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),N=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,O=(0,n.coversOn)(f,u,c),S=null==N||O<=0?null:Math.round(N/O*100)/100,_=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&_.set(n,(_.get(n)??0)+(t.partySize||0))}let w=null;for(const[t,n]of _)(!w||n>w.n)&&(w={hour:t,n:n});return{date:c,spendPerHead:s(S),covers:O,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(N),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(y?(0,t.grossOf)(y.vals)??(0,t.takings)(y.vals):null),busiestHour:w?`${String(w.hour).padStart(2,'0')}:00 \xb7 ${w.n} Covers`:'Not entered',soldOut:h.filter(Boolean),cashUp:v.map(t=>({label:t.label,value:k?l(k.vals[t.key],t.kind):'Not entered'}))}};var t=r(d[0]),n=r(d[1]);const s=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?s(t):String(t)},1537,[13,1503]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1538,[827,34,102,794,1539,1050,821,1540,1087,25]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1539,[839,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1540,[1049,1050,976,933,987]); -__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.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1541,[34,281,236,102,794,827,821,987,1430,1204,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1542,[236]); -__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,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','voice','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1544,[]); -__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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1545,[34,283,364,236,402,295,102,426,36,797,827,796,794,1237,1385,1114,1470,1113,1111,1239,1252,979,891,1061,1477,2,987,821,1343,1546,1087,1489,1414,1179,1472,1474,1464,1456,1475,1542,1544,1552,1553,1554,1557,1560,25]); -__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.micAvailable=O,_e.NoShows=z,_e.CarApp=function(){(0,H.useCarViewport)();const{width:e,height:n}=(0,c.default)(),o=Math.max(320,A(e)),{role:d,today:u,now:h}=(0,w.useCtx)(3e4),[p,f]=(0,t.useState)(n),x=o,[y,I]=(0,t.useState)(null),[D,W]=(0,t.useState)(!1),[M,z]=(0,t.useState)(null),[V,F]=(0,t.useState)(!1),[G,Y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{O().then(z)},[]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==d&&T.useOwner.getState().setPreviewRole('owner')},[d]);const X=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,X);const q=(0,t.useCallback)(()=>W(!1),[]);(0,j.useBackLayer)(D,q);const J=e=>{W(!1),I({btn:e,page:e.pages[0].id})},K=(0,t.useCallback)((e,t)=>{const n=e=>R.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:n('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:n('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??R.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=n(t);return I(n=>({btn:e??n?.btn??R.CAR_BUTTONS[0],page:t}))}I(null)},[]),Q=x,Z=y?y.btn.label:'';return(0,L.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-p)>1&&f(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:o,maxWidth:'100%',overflow:'hidden'},children:[(0,L.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,L.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,L.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,L.jsx)(B.ParkedOnly,{small:o<1400}),(0,L.jsx)(N,{open:D,onPress:()=>W(!0)})]}),subHeader:(0,L.jsx)($,{onRota:()=>J(R.CAR_BUTTONS[0]),onAccount:()=>F(!0)})}),y?(0,L.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:Q,zIndex:40,backgroundColor:S.colours.bg},children:[(0,L.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${Z}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||X()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,L.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,L.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,L.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,L.jsx)(N,{testID:"car-menu-button-page",open:D,onPress:()=>W(!0)})})]}),y.btn.pages.length>1?(0,L.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,L.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?P:'transparent',alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,L.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:'assistant'===y.page&&!1===M?(0,L.jsx)(U,{}):(0,L.jsx)(_,{id:y.page,go:K},y.page)})]}):null]}),(0,L.jsx)(E,{visible:D,onClose:q,onPick:J,current:y?.btn.id,W:o,H:p}),V?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>F(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,L.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,L.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,L.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{F(!1),Y(!0)},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>F(!1),style:{minHeight:56}})]}):null,G?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>Y(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,L.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,L.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{Y(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>Y(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),c=e(r(_d[7])),d=r(_d[8]),u=e(d),h=r(_d[9]),b=r(_d[10]),p=r(_d[11]);r(_d[12]);var f=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),R=r(_d[26]),W=r(_d[27]),B=r(_d[28]),M=r(_d[29]),H=r(_d[30]),L=r(_d[31]);const P='rgba(201,162,74,0.14)';async function O(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}}function $({onRota:e,onAccount:n}){const o=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[c,d]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>d(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=o.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,L.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,L.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,L.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:n,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,L.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,L.jsx)(M.CarGameButton,{})]})}function z({go:e}){const{rid:t,now:n}=(0,w.useCtx)(3e4),o=(0,I.useBookings)(t),s=(0,D.ymd)(n),a=(0,D.ymd)(new Date(n.getTime()-24192e5)),c=o.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),d=o.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,L.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,L.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:c.length?`${c.length} no-show${1===c.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),d.length?(0,L.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),d.map(e=>(0,L.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,L.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,c.map(e=>(0,L.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,L.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,L.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function N({onPress:e,open:t,testID:n="car-menu-button"}){return(0,L.jsx)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:R.MENU_BUTTON,height:R.MENU_BUTTON,borderRadius:R.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,L.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,L.jsx)(d.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function E({visible:e,onClose:a,onPick:c,current:d,W:u,H:b}){const[p,f]=(0,t.useState)(0),m=(0,R.menuSizes)(u,b),x=p?Math.floor((p-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new n.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),n.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,L.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,L.jsx)(n.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,L.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,L.jsxs)(n.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,L.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,L.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,L.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,L.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>f(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:R.CAR_BUTTONS.map(e=>{const t=d===e.id;return(0,L.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>c(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,L.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:P,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(W.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,L.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U(){return(0,L.jsxs)(l.default,{testID:"car-no-mic",accessibilityLiveRegion:"polite",style:{gap:10,alignItems:'center',paddingVertical:24},children:[(0,L.jsx)(C.T,{center:!0,size:20,weight:"semibold",colour:S.colours.goldLight,children:"The Assistant needs the car\u2019s microphone"}),(0,L.jsx)(C.Muted,{center:!0,style:{maxWidth:520},children:"Sorry, this car\u2019s browser isn\u2019t letting the page use a microphone. For now, please use the Assistant in Managers on your phone."})]})}function _({id:e,go:t}){if('@bookings'===e)return(0,L.jsx)(f.Bookings,{go:t});if('@chat'===e)return(0,L.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,L.jsx)(z,{go:t});if('@orders'===e)return(0,L.jsx)(x.Orders,{});if('@forecast'===e)return(0,L.jsx)(y.Forecasts,{go:t});const n=(0,p.pageFor)(e);if(!n)return(0,L.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const o=n.C;return(0,L.jsx)(o,{go:t})}function A(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,n=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,n))}},1546,[34,283,364,236,402,295,102,426,797,796,1343,1456,1475,1414,1179,1474,1472,1087,1055,794,874,891,858,987,2,821,1547,1548,1549,1550,1551,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1547,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1548,[34,797,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1549,[34,102,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1550,[34,402,1181,1182,831,5,794,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1551,[34,236]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1552,[1547]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1553,[]); -__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.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1554,[34,402,102,426,827,794,1098,1061,1196,1142,1118,874,1038,891,1100,13,930,987,821,1414,1087,1456,1555,1544,1553,1556,25]); -__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,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1555,[34,402,295,102,794,821,25]); -__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.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1556,[34,102,797,794,821,1555,1553,25]); -__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.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1557,[34,281,402,102,797,794,874,891,1558,999,1226,1463,821,1548,1087,1555,1559,1553,1556,1554,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1558,[846,849,839]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1559,[999]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1560,[34,102,794,821,1561,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1561,[]); -__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.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:$,meId:V,me:Q}=(0,z.useCtx)(3e4);(0,m.useTipsPosted)(e,_);const Y=(0,z.useSignedIn)();(0,x.useSoldOutLink)(!0,(Y?.name??Q).replace(' (example)',''));const[ee,te]=(0,a.useState)({kind:'tab',tab:'home'}),[se,ae]=(0,a.useState)(''),oe=(0,a.useRef)(null);(0,a.useEffect)(()=>{(0,z.ensureAttendance)(_,$),(0,M.ensureChat)($)},[_]),globalThis.__ccNow=$.getTime();const ne=(0,a.useCallback)((e,t=null)=>{if('more'===e&&t){const e=q[t];return void te(e?{kind:'edit',id:e}:{kind:'page',id:t})}te('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,a.useEffect)(()=>(S.useVoiceNav.setState({go:ne}),()=>S.useVoiceNav.setState({go:null})),[ne]),(0,a.useEffect)(()=>{D.PITCH&&(globalThis.__pitchGo=ne,globalThis.__deskGo=e=>te(e))},[ne]),(0,E.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:Y?.id??'',name:Q,onOpen:e=>'bookings'===e?ne('bookings'):'chat'===e?ne('chat'):ne('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!Y}),(0,a.useEffect)(()=>((0,T.warmDesktopStt)(),(0,C.installVoiceKeys)()),[]);const re=(0,a.useMemo)(()=>[...G,...U].map(e=>e.s),[]);(0,a.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void oe.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=re[Number(e.key)-1];return void(t&&(e.preventDefault(),te(t)))}if('z'===t&&!Z(e.target)){const t=(0,W.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!Z(e.target)){const t=(0,W.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[re]);const ie=O.PAGES.filter(e=>(!e.can||e.can(f))&&!q[e.id]),le=(0,a.useMemo)(()=>{const e=se.trim().toLowerCase(),t={};return ie.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ie,se]),de=G.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ue=p.CAN.forecasts(f)?U:U.filter(e=>'rota'===e.s.id),ce='page'===ee.kind?(0,O.pageFor)(ee.id):void 0,be='tab'===ee.kind?G.find(e=>X(e.s,ee))?.label:'edit'===ee.kind?U.find(e=>X(e.s,ee))?.label:ce?.title,he='tab'===ee.kind?G.find(e=>X(e.s,ee))?.tip:'page'===ee.kind?`${ce?.sub??''}. Press ${(0,N.CMD)()}K to jump to any page, or hold Space and ask.`:'',ge=({label:e,s:t,n:s})=>{const a=X(t,ee);return(0,K.jsxs)(o.default,{accessibilityRole:"button",accessibilityState:{selected:a},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>te(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:a?A.colours.goldTint:e?A.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:a?A.colours.gold:'transparent'}),children:[(0,K.jsx)(g.T,{size:14,weight:a?'semibold':'regular',colour:a?A.colours.gold:A.colours.text,style:{flex:1},numberOfLines:1,children:e}),s?(0,K.jsxs)(g.T,{size:11,colour:A.colours.muted,children:[(0,N.CMD)(),s]}):null]})},fe=({t:e})=>(0,K.jsx)(g.T,{size:11,weight:"semibold",colour:A.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),pe='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,K.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:A.colours.bg},testID:"desktop-shell",children:[(0,K.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,K.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(g.Row,{gap:10,children:[(0,K.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(u.VenueName,{name:c.name}),(0,K.jsx)(g.Row,{gap:6,children:(0,K.jsx)(l.AppBadge,{label:pe})})]})]}),(0,K.jsx)(u.PoweredBy,{}),(0,K.jsx)(s.TextInput,{ref:oe,testID:"side-filter",value:se,onChangeText:ae,placeholder:`Find a page (${(0,N.CMD)()}K)`,placeholderTextColor:A.colours.muted,style:[g.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,K.jsxs)(n.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[se?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fe,{t:"Run the day"}),de.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:t+1},e.label)),(0,K.jsx)(fe,{t:"Drag-and-drop editors"}),ue.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:de.length+t+1},e.label))]}),Object.entries(le).map(([e,t])=>(0,K.jsxs)(r.default,{children:[(0,K.jsx)(fe,{t:e}),t.map(e=>(0,K.jsx)(ge,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{flex:1},children:[(0,K.jsx)(r.default,{testID:"desk-title",children:(0,K.jsx)(g.T,{size:24,weight:"bold",children:be??''})}),(0,K.jsxs)(g.Muted,{size:12,children:[Y?`Signed in as ${Y.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]}),(0,K.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(g.T,{size:15,weight:"bold",colour:A.colours.gold,children:"Talk to CoverCharge"}),(0,K.jsxs)(g.Muted,{size:12,children:["Hold Space, or ",(0,N.CMD)(),"\u21e7G"]})]}),(0,K.jsx)(v.VoiceSlot,{size:76})]}),(0,K.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[he?(0,K.jsx)(F.Tip,{children:he}):null,'edit'===ee.kind?(0,K.jsx)(J,{id:ee.id,rid:e,me:Q,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,K.jsxs)(n.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===ee.kind&&'home'===ee.tab?(0,K.jsx)(H.Dashboard,{go:ne}):null,'tab'===ee.kind&&'orders'===ee.tab?(0,K.jsx)(I.Orders,{}):null,'tab'===ee.kind&&'bookings'===ee.tab?(0,K.jsx)(R.Bookings,{}):null,'tab'===ee.kind&&'forecast'===ee.tab?(0,K.jsx)(P.Forecasts,{go:ne}):null,'tab'===ee.kind&&'chat'===ee.tab?(0,K.jsx)(M.Chat,{go:ne}):null,ce?(0,K.jsx)(ce.C,{go:ne}):'page'===ee.kind?(0,K.jsx)(g.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,K.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,K.jsx)(h.PrintHost,{rid:e}):null,'staff'!==f?(0,K.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Q,onOpen:e=>ne('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,K.jsx)(L.AssistantSheet,{}),(0,K.jsx)(B.OnboardingHost,{go:ne}),(0,K.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),s=_r(d[1]),a=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]),g=_r(d[12]),f=_r(d[13]),p=_r(d[14]),x=_r(d[15]),m=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),S=_r(d[22]),v=_r(d[23]),T=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),z=_r(d[31]),H=_r(d[32]),P=_r(d[33]),B=_r(d[34]),I=_r(d[35]),O=_r(d[36]);_r(d[37]);var _=_r(d[38]),N=_r(d[39]),W=_r(d[40]),$=_r(d[41]),V=_r(d[42]),F=_r(d[43]),K=_r(d[44]);const G=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Hold Space and say \u201chow many Covers tonight?\u201d for a quick answer without leaving this screen.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first. Say \u201cshow new orders\u201d to jump back any time.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber. Hold Space and say \u201caccept the 7 o\u2019clock\u201d.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],U=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],q={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},X=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),Z=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function J({id:e,rid:t,me:s,role:o,today:n,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,a.useState)(0),[h,p]=(0,a.useState)('');return'menu'===e?(0,K.jsx)($.MenuEditor,{rid:t,me:s,role:o}):'rota'===e?(0,K.jsx)(V.RotaEditor,{today:n}):'brand'===e?(0,K.jsx)(_.BrandEditor,{rid:t}):(0,K.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,K.jsxs)(F.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,N.CMD)(),"Z undoes, then Save."]}),h?(0,K.jsx)(g.T,{size:13,colour:A.colours.goldLight,children:h}):null,(0,K.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:A.colours.border,borderRadius:12,overflow:'hidden'},children:(0,K.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1562,[828,827,34,402,295,102,36,1358,873,1361,1237,1385,794,1028,891,979,1061,1470,1114,1113,1111,1563,1477,1156,931,1239,2,821,1489,1414,1179,1087,1432,1472,1464,1474,1456,1475,1564,1542,1566,1568,1570,1567,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1563,[846]); -__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.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1564,[34,295,102,1498,873,794,891,829,1457,821,1565,1566,1567,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1565,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1566,[34]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1567,[34,102,794,821,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1568,[827,34,102,794,876,831,979,981,982,861,882,1173,821,1565,1566,1567,1569,25]); -__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1569,[891]); -__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.RotaEditor=function({today:e}){const y=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[$,j]=(0,t.useState)((0,i.mondayOfDate)(e)),[v,k]=(0,t.useState)(null),[w,D]=(0,t.useState)(''),B=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),O=b.map((e,t)=>(0,i.addDays)($,t)),P=(e,t,o)=>{e.preventDefault(),k(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=y.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=$&&e.date<=O[6]),I=T.filter(e=>!e.published||e.changed).length;return(0,p.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,p.jsx)(h.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,p.jsxs)(s.Row,{gap:8,children:[(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>j((0,i.addDays)($,-7))}),(0,p.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date($+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>j((0,i.addDays)($,7))}),(0,p.jsx)(d.default,{style:{flex:1}}),w?(0,p.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:w}):null,(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!B.canUndo,onPress:B.undo,testID:"rota-undo"}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!B.canRedo,onPress:B.redo,testID:"rota-redo"}),(0,p.jsx)(s.Button,{small:!0,label:I?`Publish (${I})`:'Published',disabled:!I,onPress:()=>{B.record('published the week');const e=i.useOwner.getState().publishWeek($);D(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,p.jsx)("div",{style:(0,h.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,p.jsxs)("div",{style:(0,h.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,p.jsx)("div",{style:(0,h.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),O.map((t,o)=>(0,p.jsxs)("div",{style:(0,h.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[b[o]," ",Number(t.slice(8))]},t)),y.map(e=>(0,p.jsxs)(o.default.Fragment,{children:[(0,p.jsxs)("div",{style:(0,h.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,p.jsx)("div",{style:(0,h.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,p.jsx)("div",{style:(0,h.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),O.map(t=>{const o=`${e.id}|${t}`,d=T.filter(o=>o.staffId===e.id&&o.date===t);return(0,p.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',k(o)},onDragLeave:()=>k(null),onDrop:o=>P(o,e.id,t),style:(0,h.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,p.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,h.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,p.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]),f=r(_d[9]),p=r(_d[10]);const b=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],x=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1570,[34,102,794,891,1090,821,1565,1566,1567,1569,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1571,[30,34,872,1572,25]); -__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1572,[1457,1573,828,996,1098,1507,1223,1054,1055,1508,1532,1510,1173,979,1015,1574,1012,2,1060,1061,1483,998,1038,999,34,1175,1248,1252,1219,373,402,295,102,426,36,794,873,1156,891,821,1179,1414,1093,1111,1113,1107,1056,1039,1087,1501,1496,1516,1575,1423,1003,236,1254,1198,1204,1455,1218,1217,1471,1201,15,1224,1225,925,793,987,25]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1573,[34,102,794,1087,987,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1574,[236,1013]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1575,[860,34,102,794,891,1028,858,1090,1088,987,1089,5,1000,821,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1576,[30,34,872,25]); -__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1577,[1451,987,795,1408,1578,1025,30,1605,496,34,385,336,236,41,102,5,873,872,1607,36,874,1028,891,821,1423,1003,1023,1608,1609,1057,1610,1129,2,1038,998,1612,1376,25,1614,1615,1616,1617]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1578,[1579,1602,1604]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1579,[215,1580,1583,1597,1598,1599,1600,1601]); -__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1580,[215,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1581,[1582]); -__d(function(g,r,i,a,m,e,d){},1582,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1583,[1584,215,1580,1597,1598]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1584,[1585,1586,1596]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1585,[1586,1590,1595]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1586,[215,372,1587,1591,1592,1593,1594,1590,1595]); -__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1587,[215,1588,339,280,1589,1590]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1588,[504]); -__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1589,[215,339]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1590,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1591,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1592,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1593,[1591]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1594,[]); -__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1595,[372,1589]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1596,[34,1586]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1597,[1584,215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1598,[1584,1597]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1599,[1580]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1600,[215,1580,1583,1581]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1601,[]); -__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1602,[215,54,1603]); -__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1603,[215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1604,[34,1579]); -__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]}})})},1605,[1606]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1606,[]); -__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1607,[34,41,102,426,794,873,1003,987,2,5,821,1547,1549,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1608,[989,883,882,987]); -__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1609,[828,796,827,34,1011,1458,1029,402,102,872,987,1013,1028,5,821,794,1354,976,2,25]); -__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1610,[5,796,827,34,385,283,364,380,236,402,295,426,102,1489,1156,2,797,1087,15,891,794,821,1522,932,1611,1520,1521,1477,1157,1487,931,1563,1530,25,277]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1611,[891,831,1028]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1612,[874,831,891,1038,15,1003,872,2,1613]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1613,[874,1038]); -__d(function(e,o,s,t,p,n,a){"use strict";p.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1614,[]); -__d(function(o,e,s,t,d,p,c){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1615,[]); -__d(function(o,e,s,t,d,p,f){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1616,[]); -__d(function(o,s,e,d,t,p,n){"use strict";t.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1617,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1618,[30,34,872,25]); -__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1619,[1620]); -__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1620,[25,1621,591]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1621,[34,172]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1622,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1623,[25,499,34,270,651]); +__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return Q.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return Q.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return Q.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return Q.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return Q.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ot}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ie.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ie.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ie.useOwner.getState().chatSeen(t,e)),$t(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ie.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...ht(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(fe.PITCH)return ge.unlockCashUp(e,t,a);const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?de.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):de.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(fe.PITCH)return ge.cashAudit(e);const t=Ae.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(_a.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=pa,i.readAccessLog=async function(){const e=Ae.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ae.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return ga}}),i.uploadOrderLogo=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(ga).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ma.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(ga).createSignedUrl(e,3600);if(t?.signedUrl)return ma.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(ga).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return _a}}),i.claimInvite=Ua,i.makeChromeHandover=async function(){const e=Ae.getState();if(fe.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ee});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(fe.PITCH||!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ee});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),Me&&qa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Ne();const t=await q.kv.get(Ia,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Ne(),await q.kv.get(Oa,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_WILDINGS||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Ne(),await q.kv.remove(Ia),await q.kv.remove(Oa),Ce({mode:'signin',perms:[]});try{await xa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ae.getState().venueId;if(fe.PITCH||!s||'staff'!==Ae.getState().kind)return{ok:!0};if(!(0,re.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Pa('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ua(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(fe.PITCH)return ge.reissueInvite(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Pa('staff_app_link_history',{p_venue:Ae.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Pa('revoke_staff_app_link',{p_venue:Ae.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(fe.PITCH)return ge.linkPhones();const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return{};try{const t=await Pa('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(fe.PITCH)return ge.resetPhone(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Number(await Pa('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(fe.PITCH)return ge.inviteStatus();const e=Ae.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:t,error:a}=await Re().rpc(d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_pairing_code':d.IS_GREENSIDE?'claim_greenside_pairing_code':d.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':d.IS_KIRKTON?'claim_kirkton_pairing_code':d.IS_WILDINGS?'claim_wildings_pairing_code':d.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':d.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await q.kv.set(ka,n),qa(),{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}`}}},i.carPairStart=async function(){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await q.kv.set(Ea,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ta(e)}}},i.carPairPoll=async function(e){try{Ne();const t=e??await q.kv.get(Ea,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,J.carPairApproved)(n)){const e=(0,J.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await q.kv.get(ka,null);await q.kv.set(ka,e),await q.kv.remove(Ia),A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||qa()}return'revoked'!==i&&'unknown'!==i||await Na(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Ne(),await Re().rpc('car_sign_out')}catch{}await Na(),await xa();try{await Re().auth.signOut({scope:'local'})}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Pa('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ta(e)}}},i.carList=async function(){const e=Ae.getState().venueId;if(!e)return[];return(await Pa('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Pa('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ta(e)}}},i.unpairDisplay=async function(){await q.kv.remove(ka),await xa();try{await Re().auth.signOut()}catch{}Ce({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await q.kv.remove(Ia),await q.kv.remove(Oa),await xa();try{await Re().auth.signOut()}catch{}Ce({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.'})},i.wipeThisDevice=async function(e={}){try{await xa()}catch{}try{(0,N.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${d.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!d.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Ka,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Pa}}),i.mendSession=La,i.startAppSync=async function(e=d.VENUE_RID){if(d.IS_ISOLATED_VENUE&&e!==d.VENUE_RID)return;if(Me)return;Me=!0,Ba=e,'customer'===Ee&&'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Ne(),'customer'!==Ee){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ee&&(0,y.isAnchorage)(e)?[V.useStore,ie.useOwner,se.useKitchen,ne.useSafety,X.useCardStore,_.useGpCalc,ee.useOrderSheets,h.useSpecials,C.useHr]:[V.useStore,ie.useOwner,se.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ee&&(0,y.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ce({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Os(e)}catch{if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e))return void Ce({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,N.isSupabaseConfigured)())return void Ce({mode:'off'});F.mutationQueue.subscribe(()=>{const e=F.mutationQueue.waiting,t=e[0];Ce({pending:F.mutationQueue.pending.length,failed:F.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,B.describeWrite)(t)}: ${(0,B.plainReason)({...t.lastErr},'retry')}`:void 0})}),F.mutationQueue.onFailed(e=>Ce({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:F.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,B.describeWrite)(e),why:'conflict'===e.reason?(0,B.plainReason)({code:'conflict'},'refused'):(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Pe.push((0,K.onConnectivity)(e=>Ce({mode:e?Ae.getState().venueId?'live':Ae.getState().mode:Ae.getState().venueId?'offline':Ae.getState().mode}))),await ja()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Qa}}),i.serverOrder=Za,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return Ya}}),i.nudgeGuestSync=function(){Xa?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return es}}),i.stockSaveBlocker=ts,i.stockEventStatus=function(e){if(Ze(e))return{state:'saved'};const t=F.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,B.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=as,i.saveStockEventsNow=ss,i.bookingSaveBlocker=is,i.resendUnsavedBookings=ds,i.saveBookingsNow=us,i.waitForBookingSave=function(e,t=12e3){if(!Ue())return Promise.resolve({state:'local'});const a=is();if(a)return Promise.resolve({state:'refused',why:a});const s=rs()[0]?.venueId??'',n=()=>ns.some(t=>F.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=$.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,K.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(F.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(F.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||rs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||rs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=gs,i.tempLogState=function(){const e=ms()[0]?.venueId??'',t=ms().find(e=>'temp_readings'===e.spec.table),a=F.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!F.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(W.useTempSaves.getState().notSaved),i=ne.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=_s,i.waitForTempSave=function(e,t,a=1e4){if(!Ue()||!ms().length)return Promise.resolve({state:'local'});const s=gs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ms()[0]?.venueId??'',i=ms().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>W.useTempSaves.getState().notSaved[(0,W.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>F.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=ws,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ms}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Ps.get(a);if('customer'!==Ee||!(0,N.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Ps.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Pa('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:Le(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:Le(a.from_time),to:Le(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Ps.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ms.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Ps.get(a);e&&!e.ok&&Ps.delete(a)}));const n=Ps.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ae.getState().venueId;if(!n||'staff'!==Ae.getState().kind)throw new Error('Connect to your venue first.');const i=await Pa('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});V.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return null;return(await Pa('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');await Pa('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),O=t(r[18]),R=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(pe),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]),Oe=t(r[71]);const Re=()=>(0,T.getSupabase)();F.mutationQueue.setExecutor(L.executeMutation),(0,M.setClockServer)(()=>'staff'===Ae.getState().kind);const Ae=(0,E.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ce=e=>Ae.setState(e),De=e=>{const t=Ae.getState().perms;return t.includes('*')||t.includes(e)},Ue=()=>{const e=Ae.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ae.subscribe(()=>(0,be.setLiveData)(Ue()));let Ee=G.IS_CAR?'car':G.APP_VARIANT,Te=!1;const Ne=()=>{Te||((0,q.setSyncNamespace)(Ee),Te=!0)};let Ke=[],Pe=[],Me=!1;const xe=()=>(new Date).toISOString().slice(0,10),qe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),Le=e=>e?e.slice(0,5):'',Be=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))):[],je=e=>JSON.parse(JSON.stringify(e));function Fe(e,t){const a=qe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>V.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=je(e);if(t)return{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:Be(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,re.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:Be(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function $e(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>V.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.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,re.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:je(e.lines??[]),allergies:Be(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:je(e.allergyChain??{}),readiness:je(e.readiness??{}),allergy_ticks:je(e.allergyTicks??{}),handover_check:e.handoverCheck?je(e.handoverCheck):null,accepted:e.accepted?je(e.accepted):null,doc:je(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)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function We(e){const t=qe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...z.useBlocks.getState().blocks,...z.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Ae.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:je(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,z.blockClock)(t.from_time)??a?.from,n=(0,z.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>z.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>z.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Qe=null,He='Main plan';function Ve(e){const t=e=>je({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(Z.useFloor.getState().plans[e]??(0,Z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>De('floor.manage')||De('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Qe??(0,ke.uuidFrom)(`plan:${a}`),venue_id:a,name:He||'Main plan',is_active:!0,...t(e),updated_by:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>(Qe=String(e.id),He=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,Ie.withSeedBest)(e,t[0]):void 0;a&&Z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>Z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ge(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Y.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>De('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,re.isUuid)(e.supplierId)?e.supplierId:(0,ke.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),dt.get(t)??t)}:{}};var t},apply:(t,a)=>Y.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Je=new Set,ze=new Set;F.mutationQueue.onDone(e=>{'stock_events'===e.table&&ze.add(e.rowKey)});const Ze=e=>ze.has(e)||Je.has(e),Ye=()=>De('*')||De('staff.manage')||De('recipes.edit')||De('recipes.signoff'),Xe=()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write'));function et(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Y.useShellStore.getState().events.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,re.isUuid)(t.id)&&!!(Y.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('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,re.isUuid)(e.undoes)&&(Ze(e.undoes)||F.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Je.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)=>Y.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function tt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Y.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={...Y.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Y.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Je]}}}))},afterRead:()=>{Y.useShellStore.getState().server[e]||Y.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Je]}}}))},subscribe:()=>()=>{}}}const at=new Set;function st(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=V.useStore.getState().menu;return X.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:t=>(0,re.isUuid)(t.card.id)&&!((0,y.isAnchorage)(e)&&(0,y.isDemoCard)(t.card))&&!(0,y.isPlaceholderCard)(t.card),writable:()=>De('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,y.isAnchorage)(e)&&(s={...s,signOff:(0,y.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,y.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,y.isAnchorage)(e)&&(0,y.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,ke.photoPath)(a,s),t=nt(s.photo);t&&((0,X.cachePhotoAs)(e,t),it(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,ke.cardToRow)(s,a);return{...i,...r,doc:je({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,y.isPlaceholderCard)(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,signOff:(0,y.isAnchorage)(e)&&(0,y.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!De('recipes.edit')&&t.length){const e=new Set(t);X.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);X.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&V.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&V.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=X.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=V.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const nt=e=>(0,X.readLocalPhoto)(e);async function it(e,t){if(!at.has(e)){at.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(ke.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){at.delete(e),Ce({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const rt=new Map,ot=(0,E.create)(()=>({n:0}));(0,X.setStoragePhotoResolver)(e=>{const t=rt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,N.isSupabaseConfigured)()&&'off'!==Ae.getState().mode?(t||(rt.set(e,{url:'',at:Date.now()}),Re().storage.from(ke.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(rt.set(e,{url:t.signedUrl,at:Date.now()}),ot.setState(e=>({n:e.n+1})),X.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const dt=new Map;const ut=(e,t)=>{const a=(0,re.isUuid)(t)?t:(0,ke.uuidFrom)(`sup:${e}:${t}`);return dt.set(a,t),a};function ct(e){return{name:'order_sheets',table:'suppliers',list:()=>ee.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,y.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>De('suppliers.manage'),toRow:(e,t)=>({id:ut(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:je(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(dt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ee.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ee.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,re.isUuid)(e)?e:(0,ke.uuidFrom)(`sup:${Ae.getState().venueId}:${e}`)})}}let lt=!1,ft=!1;const pt=new Map,gt=new Map,mt=new Map,_t=new Map,St=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ht=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'},yt=(e,t)=>({...e,managerAccess:t}),wt=()=>({nickname:lt,display:ft}),vt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=yt({role:e.role,level:e.level??ht(St(e)).level},!0===e.managerAccess);return(0,j.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},wt())};const bt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},kt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},It=e=>{const t=ie.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ot=2e3;function Rt(e,t){return t||!e.length||e.length>=Ot?null:e=>(0,re.isUuid)(e.id)}function At(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,De('rota.manage')):null,keepOnEmpty:()=>e&&!De('rota.manage'),list:()=>ie.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&pt.has(e.staffId)&&(De('rota.manage')||It(e.staffId)),writable:()=>De('rota.manage')||De('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(bt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:kt(e.start),end_time:kt(e.end),published:!!e.published,doc:je(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Ct(){const e=qe(62),t=e=>De('rota.manage')||e.staffId===Ae.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ie.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ae.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=qe(2)&&e.staffId===Ae.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:je(e.breaks??[]),break_mins:e.breakMins??0,doc:je((0,w.privateAttendance)(d.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,w.privateAttendance)(d.VENUE_RID,{...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Dt(){const e=qe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.staffId===Ae.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ae.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:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,re.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:je({...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Ut(e){ie.leaveRemote.decide=t=>!(!De('rota.manage')||!(0,re.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(F.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Pe.push(()=>{ie.leaveRemote.decide=null})}function Et(e){ie.timesheetRemote.send=(t,a)=>{if(!De('rota.manage')||!(0,re.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return F.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:je(s)}}),!0}const s=a;if('attendance_void'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return F.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:je(s.breaks??[]),p_reason:n,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0},Pe.push(()=>{ie.timesheetRemote.send=null})}function Tt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>V.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ae.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,re.isUuid)(a)?a:(0,ke.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,re.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:je(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>V.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=>V.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Nt=e=>V.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Kt(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}));V.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Pt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=V.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[je({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:Z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Nt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>De('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...xt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...xt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...xt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Mt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Mt=t.feature_flags??{},xt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),je({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}:{}})},apply:t=>{const a=t[0];a&&(V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&Z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Kt(e,a.events))},subscribe:e=>{const t=V.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=Z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Mt=null,xt=null;const qt=()=>new Date(Date.now()-2592e6).toISOString(),Lt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Bt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>gt.get(e));return 2===t.length&&t[0]&&t[1]?(0,he.dmId)(t[0],t[1]):null},jt=()=>Ae.getState().perms.includes('*');function Ft(){const e=()=>Ae.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ie.useOwner.getState().chat.filter(e=>(0,re.isUuid)(e.id)).map(e=>je({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=>!!Lt(t.ch)&&(t.from===e()||jt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('created_at',qt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=qt(),toRow:(e,t)=>{const a=Lt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:pt.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=Bt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?gt.get(String(e.from_staff)):'system';return s?je({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ie.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?gt.get(String(t.from_staff)):'system',i=Bt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ie.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,he.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,ye.soundAllowed)())try{(0,ye.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,k.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function $t(e,t,a){const s=Ae.getState();if(!Se.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=pt.get(e),i='*'===t?'*':Lt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Wt(e){const t=Ae.getState().staffRef,a=t?pt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Bt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ie.useOwner.getState().chatMarkRead(t,i)}catch{}}function Qt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=D.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:je(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>D.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,U.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Ht(e){const t=qe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>D.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.reminderId)&&e.staffRef===Ae.getState().staffRef,writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>D.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Vt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Gt=e=>null==e||''===e?null:Number(e),Jt=e=>e.filter(e=>!e.startsWith('data:')),zt=()=>De('takings.view');function Zt(e){const t=!zt();return{name:'cash_ups',table:'cash_ups',list:()=>de.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',qe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:je(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({cashUps:Vt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Yt(e){return{name:'sales_reports',table:'sales_reports',list:()=>de.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:je(e.vals),categories:e.categories,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({sales:Vt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Xt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=de.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,de.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:je({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,de.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>de.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ea(e){return{name:'day_tips',table:'day_tips',list:()=>de.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',qe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>de.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ta(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>de.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Gt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>de.useCashUp.setState(s=>({pot:Vt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function aa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=de.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>De('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>de.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function sa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>oe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:je(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>oe.useNotifs.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>oe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function na(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ue.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:je(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ue.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ce.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Vt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ia(e){const t=()=>De('venue.settings')||De('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ue.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,re.isUuid)(a.id)&&(0,re.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ue.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ae.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ae.getState().staffRef)||null,doc:je(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ra(e){const t=qe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ue.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:je(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({history:Vt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function oa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=le.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:je(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>De('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&le.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,w.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>le.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function da(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=me.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,me.libraryRowId)(e),kind:'library',doc:je({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,me.personRowId)(e,i),kind:'person',staffRef:i,doc:je({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ie.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,_e.canEditTasks)(t,a)},writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>me.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,me.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ua(e){const t=qe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>me.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ae.getState();return e.byRef===t.staffRef||De('staff.manage')},writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>me.useDailyTasks.setState(s=>({ticks:Vt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ca(e,t=!1){const a=qe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>we.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind||De('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,ke.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>we.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>we.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{ve.autoSync.soldOutRead.add(e)}}}function la(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>ve.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:(0,ke.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>ve.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>ve.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{ve.autoSync.linksRead.add(e)}}}async function fa(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&q.kv.get(a,!1):(q.kv.set(a,!0),!0)}catch{return q.kv.get(a,!1)}}async function pa(){const e=Ae.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();_a.setState({live:!!t?.push_live,known:!0})}catch{}}const ga='order-list-logos';const ma=new Map;const _a=(0,E.create)(()=>({live:!1,known:!1}));async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('reminders:ok',!1):(q.kv.set('reminders:ok',!0),!0)}catch{return q.kv.get('reminders:ok',!1)}}async function ha(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('chat:ok',!1):(q.kv.set('chat:ok',!0),!0)}catch{return q.kv.get('chat:ok',!1)}}const ya=(e,t)=>je({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),wa='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function va(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>C.useHr.getState().questions.filter(t=>t.venue===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ya(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);C.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>C.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function ba(e,t){const a=(t,a,s)=>{F.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(C.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(wa).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||C.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ya(e,t)))}catch{}}}),Pe.push(()=>{Object.assign(C.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ka='pair:v1',Ia='staff:v1',Oa='staff:rejoin:v1';async function Ra(e){const t=d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_invite':d.IS_GREENSIDE?'claim_greenside_invite':d.IS_ABBOTSFORD?'claim_abbotsford_invite':d.IS_KIRKTON?'claim_kirkton_invite':d.IS_WILDINGS?'claim_wildings_invite':d.IS_KIRKMICHAEL?'claim_kirkmichael_invite':d.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ee,p_device:(0,A.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,A.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Aa(){if('display'===Ee||'customer'===Ee||fe.PITCH)return'none';const e=await q.kv.get(Oa,null);if(!e)return'none';try{await Da();const{data:t,error:a}=await Ra(e);if(a)return(0,O.inviteRefusal)(a.message)?(await q.kv.remove(Oa),await q.kv.remove(Ia),'refused'):'offline';const s=t?.[0];return s?(await q.kv.set(Ia,{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,displayName:s.display_name}),'ok'):(await q.kv.remove(Oa),'refused')}catch{return'offline'}}const Ca=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Da(){Ne();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ce({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 Ua(e){if(fe.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Ra(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,d.venueKey)(`cc-pending-invite:${Ee}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),await q.kv.set(Oa,e),Me&&qa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ce({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ea='car:request:v1',Ta=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Na(){await q.kv.remove(ka),await q.kv.remove(Ia),await q.kv.remove(Ea),A.useSession.getState().meId&&A.useSession.getState().signOut()}async function Ka(){if(!(0,N.isSupabaseConfigured)())return!1;try{return await Da(),!0}catch{return!1}}const Pa=async(e,t={})=>{if(fe.PITCH)return(0,pe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Ma=null;async function xa(){for(const e of Pe)try{e()}catch{}Pe=[],Ke.forEach(e=>e.stop()),Ke=[],Ma&&(clearInterval(Ma),Ma=null)}async function qa(){await xa(),await ja()}async function La(){if(!(0,N.isSupabaseConfigured)()||'customer'===Ee||fe.PITCH)return!1;try{Ne();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ee)return!1;if(!await q.kv.get(Oa,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Aa()&&(qa(),!0)}catch{return!1}}(0,c.setSessionMender)(La);let Ba=d.VENUE_RID;async function ja(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Ba;try{if(Ce({mode:'connecting'}),await F.mutationQueue.load(),'customer'===Ee)return void await Va(e);let t=await q.kv.get(ka,null),a=await q.kv.get(Ia,null);if(G.IS_CAR&&!t&&a){const e=(0,J.migrateCarStaffIdentity)(a);e&&(t=e,await q.kv.set(ka,t)),await q.kv.remove(Ia),a=null,A.useSession.getState().meId&&A.useSession.getState().signOut()}if(d.IS_ISOLATED_VENUE&&(t&&!(0,d.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,d.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ce({mode:'display'===Ee?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ee&&!G.IS_CAR&&a&&!s.session){const t=await Aa();if('offline'===t)return Ce({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Ba===e&&qa()},6e4);'refused'===t&&a.staffRef&&A.useSession.getState().meId===a.staffRef&&A.useSession.getState().signOut(),a=await q.kv.get(Ia,null),({data:s}=await Re().auth.getSession())}const n='display'===Ee||G.IS_CAR?t:a;if(!s.session||!n)return void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Pa('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ee||G.IS_CAR?await q.kv.remove(ka):(await q.kv.remove(Ia),await q.kv.remove(Oa)),'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId===n.staffRef&&A.useSession.getState().signOut(),void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ee?'This display was unpaired by a manager.':G.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,K.isOnline)()||/fetch|network/i.test(String(t?.message)))Ce({mode:'offline'});else if(Ca(t)&&'display'!==Ee){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Aa()&&setTimeout(()=>{Ba===e&&qa()},500)}i=Ae.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ce({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!G.IS_CAR&&'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId!==n.staffRef&&(A.useSession.getState().signIn(n.staffRef),ie.useOwner.setState({staffAs:n.staffRef})),G.IS_CAR&&(A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({previewRole:'owner'})),await $a(n.venueId,e,n.kind)}catch(e){Ce({mode:'local',lastError:String(e?.message??e)})}}const Fa=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','venue_reminders','reminder_done']);async function $a(e,a,s){if(!(0,d.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||G.IS_CAR&&'device'===s;await ws(a),Pe.push(Ks(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])mt.set(e.key,e.id),_t.set(e.id,e.key)}catch{}const i=[Pt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ie.useOwner.getState().staff.map(vt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>De('staff.manage'),deletes:!1,revision:e=>(0,j.staffRevision)(e,wt()),toRow:(e,t)=>(0,j.staffRow)(e,t,wt(),e.managerAccess||e.ownerAccess?null:mt.get(St(e))),fromRow:e=>{if(!e.external_ref)return null;pt.set(String(e.external_ref),String(e.id)),gt.set(String(e.id),String(e.external_ref)),Us.set(String(e.external_ref),e.avatar_path??null);const t=yt(ht(_t.get(String(e.role_id))),!0===e.manager_access);return(0,j.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},wt())},apply:e=>ie.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=>ie.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ns()},onRemote:()=>{Ns()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ie.useOwner.getState(),t=ae.useSetup.getState().sites[Ba]?.staffGrade??{};return e.staff.filter(e=>pt.has(e.id)).map(a=>je({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=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:pt.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=gt.get(String(e.staff_id));return t?je({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=>ie.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=ae.useSetup.getState().sites[Ba],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&&ae.useSetup.getState().patch(Ba,{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=ie.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=ae.useSetup.subscribe((t,a)=>{t.sites[Ba]?.staffGrade!==a.sites[Ba]?.staffGrade&&e()});return()=>{t(),a()}}},Fe(a,!1),Fe(a,!0),We(a),Ve(a),$e(a),Ge(a),et(a),tt(a),ct(a),{name:'supplier_directory',table:'suppliers',list:()=>ie.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('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:je(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ie.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId),writable:()=>De('suppliers.order')||De('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||xe(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:je(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},st(a),As(a)];De('wages.view')&&i.push(Cs(a)),n&&(i.push(At(!0),Ct(),Dt(),Tt(a)),Et(e)),n&&await fa('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ae.getState().staffRef&&'pending'===e.status||De('rota.manage')),writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:je(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Fa.add('staff_leave'),Ut(e));const o=n&&await ha();if(Se.useChatSync.setState({synced:o,checked:!0}),Pe.push(()=>Se.useChatSync.setState({synced:!1})),o&&i.push(Ft(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(he.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:pt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:pt.get(e.id),include:e.include}),fromRow:e=>{const t=gt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>he.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=>he.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await fa('hr_questions')&&(i.push(va(a)),Fa.add('hr_questions'),ba(e,a)),'guest'!==s&&'customer'!==Ee&&await fa('temp_readings')&&(i.push((0,Q.tempUnitsSpec)(ne.useSafety,Ye),(0,Q.tempReadingsSpec)(ne.useSafety,Xe)),Fa.add('temp_units'),Fa.add('temp_readings')),'guest'!==s&&await fa('sold_out_items')?(i.push(ca(a,await fa('sold_out_items','auto'))),Fa.add('sold_out_items')):ve.autoSync.soldOutRead.add(a),'guest'!==s&&await fa('sold_out_links')?(i.push(la(a)),Fa.add('sold_out_links')):ve.autoSync.linksRead.add(a),D.useReminders.getState().ensure(a),'guest'!==s&&await Sa()&&(i.push(Qt(a)),n&&i.push(Ht(a))),oe.useNotifs.getState().ensure(a),ue.useOrderLists.getState().ensure(a),n){lt=await fa('staff','nickname'),ft=await fa('staff','display_clock');const[e,t,s,n]=await Promise.all([fa('scheduled_notifications'),fa('order_lists'),fa('venue_clock_area'),fa('daily_tasks')]);me.useDailyTasks.getState().ensure(a),n&&(i.push(da(a),ua(a)),Fa.add('daily_tasks'),Fa.add('daily_task_ticks')),e&&(i.push(sa(a)),pa()),t&&i.push(na(a),ia(a),ra(a)),s&&i.push(oa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Fa.add(n)}if('guest'!==s&&await fa('day_tips')){i.push(ea(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Fa.add(e);await fa('tips_pot_events')&&i.push(ta(a),aa(a)),n&&(zt()||(0,de.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(Zt(a),Xt(a)),Fa.add('cash_ups'),zt()&&(i.push(Yt(a)),Fa.add('sales_reports')),t(r[73])(r[72],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(At(),Ct()),await fa('scheduled_notifications')&&i.push(sa(a)));let u=!1;const c=()=>{if(G.IS_CAR&&n&&De('recipes.edit'))return!0;const e=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);return!!e&&e.active&&De('recipes.edit')&&(0,S.costsAllowedFor)(e)};n&&c()&&await fa('ingredient_prices')&&(i.push((0,_.gpSyncSpec)('ing',c)),Fa.add('ingredient_prices'),await fa('card_costs')&&(i.push((0,_.gpSyncSpec)('card',c)),Fa.add('card_costs')),await fa('kitchen_deliveries')&&(i.push((0,_.gpSyncSpec)('del',c)),Fa.add('kitchen_deliveries')),await fa('kitchen_stock_counts')&&(i.push((0,_.gpSyncSpec)('count',c)),Fa.add('kitchen_stock_counts'))),(0,Oe.specialsSyncOn)()&&'guest'!==s&&await fa('specials_boards')&&(i.push((0,Oe.specialsBoardSpec)(a,()=>De('recipes.edit')||De('floor.manage')||De('*'))),Fa.add('specials_boards'));const l={onActivity:()=>Ce({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ce({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ce({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Pa('whoami')??[]).some(t=>t.venue_id===e))return void(Ba===a&&qa());for(const a of Ke){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||$.useBookingSaves.getState().mark({id:t,table:e,why:is()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||W.useTempSaves.getState().mark({id:t,table:e,why:gs(e)??'this screen could not send it'})}};Ke=i.map(t=>new H.EntityBridge(t,e,l)),await Promise.all(Ke.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,K.isOnline)())try{const t=await Pa('whoami');if(!t?.some(t=>t.venue_id===e))return void(Ba===a&&qa())}catch(e){if(Ca(e)){if(G.IS_CAR)return void(Ba===a&&qa());const e=await Aa();return void('ok'!==e&&'refused'!==e||Ba===a&&qa())}}let t=0;for(const[a,s]of Ke.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(Se.useChatSync.getState().error&&Se.useChatSync.setState({error:void 0}),await Wt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&Se.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({mode:'live',lastSyncAt:e,lastServerAt:e}),F.mutationQueue.flush()}else Ce({mode:'offline'});if(!De('wages.view')){const e=Ae.getState().staffRef;ie.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const m=new Map;for(const e of Ke)m.set(e.spec.table,[...m.get(e.spec.table)??[],e]);const h=[...m.keys()].filter(e=>Fa.has(e)).map(e=>({table:e,venueColumn:m.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,H.venueChannel)(e,h,(e,t,a)=>{for(const s of m.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ce({lastSyncAt:s,lastServerAt:s})},e=>{Ce({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Pe.push(()=>{Re().removeChannel(w)}),Pe.push((0,K.onConnectivity)(e=>{e&&p()}));const v=Ke.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,P.superviseSync)({fastMs:Qa(Ee),readFast:async()=>{for(const e of v)await e.read()},readAll:p,flush:()=>{F.mutationQueue.flush()},wake:()=>{F.mutationQueue.retryNow()},restart:()=>{Ba===a&&qa()},realtime:()=>Ae.getState().realtime,lastServerAt:()=>{const e=Ae.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Ca,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>Wa(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Pe.push(k.stop)}async function Wa(e){const t=Ae.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Pa('sync_heartbeat',{p_venue:e,p_device:(0,A.deviceId)()??'unknown',p_app:Ee,p_version:x.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Qa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ae.getState(),queue:F.mutationQueue.pending.map(e=>e.table),failedTables:F.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),fe.PITCH&&(window.__ccSyncPreview=e=>Ce(e)));const Ha='guest:sent:v1';async function Va(e){Ce({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Pa('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!d.IS_ISOLATED_VENUE||t.id===d.VENUE_UUID)){Ce({venueId:t.id,venueName:t.name}),await ws(e);const a=t.app?.restaurant;a&&V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withWildingsAddress)({...a,id:e}):t)})),Kt(e,t.app?.events)}await Ga(e),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ce({mode:(0,K.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Ga(e).catch(()=>{})},6e4);Pe.push(()=>clearInterval(t)),d.IS_ISOLATED_VENUE||await Ja(e)}async function Ga(e){const t=await Pa('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));X.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&V.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))]}});try{const t=await Pa('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function Ja(e){let t=await q.kv.get(Ha,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=V.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Ka())return;for(const a of n)try{const s=(await Pa('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(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&&V.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'},Ce({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Pa('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(a.allergies)}}))?.[0];t={...t,[a.id]:'order'},s&&V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?Za(e,s):e)}))}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ce({lastError:`Order: ${s}`}),V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:Ya(s)}}:e)})))}await q.kv.set(Ha,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Pa('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await q.kv.set(Ha,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Pa('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));V.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=Za(e,a);return za(s)===za(e)?e:s})})),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ce({mode:(0,K.isOnline)()?Ae.getState().mode:'offline'})}finally{a=!1}}};Pe.push(V.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Ma=setInterval(()=>{n()},15e3),Xa=()=>{n()},n()}const za=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function Za(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const Ya=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let Xa=null;const es={bridges:()=>Ke,restart:qa};function ts(){const e=Ae.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!De('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function as(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(!e||ts())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(F.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function ss(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}as();try{await F.mutationQueue.retryNow()}catch{}}Ae.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{ss()},3e3)});const ns=['bookings','walk_ins'];function is(){const e=Ae.getState();return Ue()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const rs=()=>Ke.filter(e=>ns.includes(e.spec.table)),os=e=>F.mutationQueue.failed.some(t=>ns.includes(t.table)&&t.rowKey===e);function ds(e=!1){return is()?0:rs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&os(t)&&!!$.useBookingSaves.getState().notSaved[t]),0)}async function us(e=!1){const t=is();if(t)return t;for(const e of rs())try{await e.read()}catch{}ds(e);try{await F.mutationQueue.retryNow()}catch{}return e&&cs(),null}function cs(){const e=rs()[0]?.venueId??'',t=$.useBookingSaves.getState(),a=new Set(rs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||os(s)||ns.some(t=>F.mutationQueue.hasPending(t,e,s))||t.clear(s)}F.mutationQueue.onFailed(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().clear(e.rowKey)});let ls=null;const fs=(e=2500)=>{ls&&clearTimeout(ls),ls=setTimeout(()=>{ls=null,us(!1)},e)};(0,K.onConnectivity)(e=>{e&&fs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&fs(3e3)});const ps=['temp_readings','temp_units'];function gs(e="temp_readings"){const t=Ae.getState();return Ue()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ye()?'device'!==t.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ms=()=>Ke.filter(e=>ps.includes(e.spec.table));async function _s(e=!1){const t=gs();if(t)return t;for(const e of ms())try{await e.read()}catch{}const a=ms()[0]?.venueId??'';for(const t of ms())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,F.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await F.mutationQueue.retryNow()}catch{}if(e){const e=W.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ms().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||F.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,W.tempKey)(t.table,t.id))}}return null}F.mutationQueue.onFailed(e=>{ps.includes(e.table)&&W.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ps.includes(e.table)&&W.useTempSaves.getState().clear((0,W.tempKey)(e.table,e.rowKey))});let Ss=null;const hs=(e=3e3)=>{Ss&&clearTimeout(Ss),Ss=setTimeout(()=>{Ss=null,_s(!1)},e)};(0,K.onConnectivity)(e=>{e&&hs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3500)});const ys='golive:v1:';async function ws(e){'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)?await Os(e):(await q.kv.get(ys+e,!1)||await Os(e),await q.kv.get(ks+e,!1)||(Is(e),await q.kv.set(ks+e,!0)),await q.kv.get(vs+e,!1)||(bs(),await q.kv.set(vs+e,!0)))}const vs='golive:v3:';function bs(){const e=e=>JSON.stringify(e).includes('(example)');try{se.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ks='golive:v2:';function Is(e){const t=e=>JSON.stringify(e).includes('(example)');V.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)))})),ie.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 Os(e){if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)){const t=(0,g.stripCoreLiveSamples)(V.useStore.getState()),a=(0,se.stripKitchenExamples)(se.useKitchen.getState()),s=ie.useOwner.getState(),n=(0,g.stripOwnerLiveSamples)(s),i={accidents:ne.useSafety.getState().accidents.filter(e=>!(0,ne.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(V.useStore.getState(),t)&&(await(0,m.archiveChefCache)('core',V.useStore.getState()),V.useStore.setState(t)),r(se.useKitchen.getState(),a)&&(await(0,m.archiveChefCache)('kitchen',se.useKitchen.getState()),se.useKitchen.setState(a)),r(s,n)&&(await(0,m.archiveChefCache)('owner',s),ie.useOwner.setState(n)),r(ne.useSafety.getState(),i)&&(await(0,m.archiveChefCache)('safety',ne.useSafety.getState()),ne.useSafety.setState(i));const o=(0,C.stripHrSamples)(C.useHr.getState());r(C.useHr.getState(),o)&&(await(0,m.archiveChefCache)('hr',C.useHr.getState()),C.useHr.setState(o));const d=(0,_.stripGpSamples)(_.useGpCalc.getState());r(_.useGpCalc.getState(),d)&&(await(0,m.archiveChefCache)('gp',_.useGpCalc.getState()),_.useGpCalc.setState(d));const u=ee.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,m.archiveChefCache)('order-sheets',u),ee.useOrderSheets.setState(c));const l=X.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,p.isLiveVenue)(e.restaurantId)||!(0,y.isDemoCard)(e)),log:l.log.filter(e=>!(0,y.demoActor)(e.by))};return r(l,f)&&(await(0,m.archiveChefCache)('recipe-cards',l),X.useCardStore.setState(f)),void await q.kv.set(ys+e,!0)}const t=t=>t.restaurantId===e&&!(0,re.isUuid)(t.id);V.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)))})),z.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,re.isUuid)(t.id))})),Z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ie.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,re.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,re.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,re.isUuid)(e.id)),leave:e.leave.filter(e=>(0,re.isUuid)(e.id)),swaps:[]}));try{se.useKitchen.setState(e=>(0,se.stripKitchenExamples)(e))}catch{}ie.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,re.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId))}));try{ne.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await q.kv.set(ys+e,!0)}const Rs=(e,t)=>je({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function As(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(Z.useFloor.getState().live[e]??{}).map(([e,t])=>Rs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ae.getState().kind||De('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:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>Rs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>Z.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=>Z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Cs(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(ae.useSetup.getState().sites[e]?.grades??ae.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:()=>De('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=ae.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));ae.useSetup.getState().patch(e,{grades:i})},subscribe:t=>ae.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ds='staff-avatars',Us=new Map;let Es=!1;const Ts=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ns(){if(!Es){Es=!0;try{for(const[e,t]of Us){const a=te.useAvatars.getState().photos[e];if(!t){a?.path&&te.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ae.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Ds).download(t);if(n||!s)continue;const i=await Ts(s);i.startsWith('data:image/')&&te.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{Es=!1}}}function Ks(e){const t=async()=>{const t=Ae.getState().staffRef,a=t?pt.get(t)??Ae.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ae.getState().kind)return;const s=te.useAvatars.getState().photos[t];try{const n=Us.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Ds).remove([t]).catch(()=>{})};if(!s){const e=!!te.useAvatars.getState().clears?.[t];return e&&n&&(await Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}),Us.set(t,null),i(n)),void(e&&te.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ce({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Ds).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Pa('set_staff_avatar',{p_staff_ref:t,p_path:d}),Us.set(t,d),n!==d&&i(n),te.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ce({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:te.useAvatars.getState().photos},s=te.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),De('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ae.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Us.set(t,null),te.useAvatars.getState().doneClear(t),Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Ds).remove([e])).catch(()=>{})}});return t(),s}const Ps=new Map,Ms=(0,E.create)(()=>({n:0}))},987,[988,5,989,932,6,832,837,833,838,990,994,995,835,997,999,1000,1001,1002,1003,13,1004,1006,1009,1010,846,933,976,1011,1012,1013,1016,977,1017,1015,1020,1014,1021,1022,1023,1024,831,872,1025,1026,1029,983,883,1031,926,927,1033,1034,891,870,1036,1039,1040,1041,1042,2,1043,1044,1045,1046,1047,1048,979,981,884,863,859,1049,1052,1053]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},988,[846]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},990,[837,34,838,5,839,846,849,991,863,870,992,993]); +__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},991,[984]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},992,[991]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},993,[991,992]); +__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},994,[]); +__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},995,[835,837,838,5,839,846,849,996,831,884]); +__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'}}]},996,[]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},997,[6,998]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},999,[846]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},1000,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1001,[846]); +__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1002,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1003,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1004,[839,846,849,5,872,1005,15,1003]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1005,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1006,[838,835,837,5,839,846,849,1007,870]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1008,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1009,[839,846,849,863,1010,870]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1010,[]); +__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)))},1011,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1012,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1013,[34,1014]); +__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1014,[1011,977,1015]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1015,[1011]); +__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.3.12.172'},1016,[]); +__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1017,[1018,1019,933,977,1014]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1019,[977]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1020,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1021,[846,849,839]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1022,[846,849,839]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1023,[1024]); +__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1024,[1018,933,1011,977,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1025,[]); +__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1026,[860,839,870,846,849,858,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1028,[891,1004,1027]); +__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1029,[5,860,839,1030,846,849,859]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1030,[1008]); +__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1031,[837,838,5,839,846,849,1032]); +__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1032,[984]); +__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1033,[837,984,838,835,5,839,846,849]); +__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1034,[837,838,5,839,846,849,1035]); +__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1035,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1036,[839,846,849,863,1037,15,870,1038]); +__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1037,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1038,[]); +__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1039,[34,839,846,849,863,13,870]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1040,[839,846,849,863,1041,870,1038]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1041,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1042,[5,997,839,846,849,998]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1043,[1039]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1044,[839,846,849,863,1045,870]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1045,[]); +__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},1046,[846]); +__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(':')}`},1047,[839,846,849]); +__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{}}},1048,[236,872]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1049,[995,1050,1051,976,933]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1051,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1052,[933,987,999]); +__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1053,[1054]); +__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1054,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1055,[34]); +__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1056,[34,236,402,102,846,821,794,1055,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1057,[34,102,794,1058,821,1059,25]); +__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1058,[827,34,379,236,402,102,821,987,1059,2,872,1016,5,796,797,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1059,[1060,933,987,872,236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1060,[]); +__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1061,[827,796,34,402,102,794,821,1044,1045,1010,1001,870,891,25]); +__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1062,[828,1063,796,827,34,281,283,364,336,402,102,426,794,821,1039,831,13,1064,1065,1001,1075,1080,1081,1084,1085,1086,1093,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1063,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1064,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1065,[34,876,1066,1067,1064]); +__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1066,[839,846,849]); +__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1067,[6,1068,1069,1070,1071,1072,1073,1074,3]); +__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1068,[]); +__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1069,[]); +__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1070,[]); +__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1071,[]); +__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1072,[]); +__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1073,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1074,[1064]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1075,[236,933,987,1076]); +__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})},1076,[499,1077,1079,1078]); +__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1077,[499,1078,1079]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1078,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1079,[1078]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1080,[933,987]); +__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1081,[34,281,236,102,794,1039,13,1082,821,1083,25]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1082,[13]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1083,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1084,[827,2,34,102,794,821,1039,891,13,987,1001,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1085,[13]); +__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1086,[34,1063,281,402,102,794,1087,1088,1092,1093,821,25]); +__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1087,[34,402,102,794,821,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1088,[837,34,874,891,858,872,1025,987,1089,1004,15,1091]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1089,[1090]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1090,[1091]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1091,[858]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1092,[34,872,1093,858,987,933]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1093,[]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1094,[34,1095,891,1009,1010,1001,1047,831,1098]); +__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1095,[997,1042,891,998,1096,1097]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1096,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1097,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1098,[]); +__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1099,[34,986,402,102,1100,794,874,1101,858,1102,821,25]); +__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)'}})]})}},1100,[34,281,283,364,102,1048,821,25]); +__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1101,[861,859]); +__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1102,[34,402,102,794,1101,858,821,25]); +__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1103,[34,102,794,874,877,821,25]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1104,[860,34,102,794,874,1026,1029,1105,1106,877,821,25]); +__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1105,[1029,859,1101]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1106,[860,877]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1107,[860,34,102,794,874,983,891,1101,858,821,25]); +__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1108,[828,827,1056,34,336,379,236,402,102,794,821,1040,1041,1001,1109,1110,987,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1109,[1076,236]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1110,[839,846,849]); +__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1111,[827,997,34,379,402,102,794,821,1036,1037,891,1040,1041,1042,998,1096,987,1059,1001,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1112,[34,1036,891,1040,1113,1009,831,1037,1001,1094]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1113,[846]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1114,[997,34,1042,891,831,998,1010,1096,1001,1095]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1115,[860,34,1001,874,1101,1048]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1116,[860,1117,34,102,794,874,1101,821,1118,1107,1119,1140,1143,1099,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1117,[34,102,14,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1118,[821]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1119,[34,102,1120,821,1121,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1120,[860,1105]); +__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1121,[1122,860,34,1123,987,1125,402,102,874,1029,1120,1124,821,858,794,1126,1026,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1122,[34,859,821,794,25]); +__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1123,[34,402,102,874,1124,1125,987,1021,821,1121,794,25]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1124,[860,1105]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1125,[281,236]); +__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1126,[827,1127,1128,860,867,14,1129,1130,34,859,402,102,872,1088,874,1131,1105,858,821,864,794,1029,1026,1132,1133,1138,1107,1101,1139,1124,1123,25]); +__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1127,[34,402,412,102,1128,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1128,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1129,[34,102,794,25]); +__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1130,[34,236,402,295,102,426,821,794,1001,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1131,[878,858,877]); +__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1132,[34,402,102,878,858,821,794,25]); +__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1133,[860,877,34,102,879,1134,1135,1137,794,874,1029,983,861,867,872,1101,821,25]); +__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1134,[34,402,821,794,25]); +__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1135,[828,860,1136,34,281,236,102,1029,1105,821,794,1107,859,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1137,[34,402,102,874,861,863,821,794,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1138,[1128,1120,1124]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1139,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1140,[1141,34,102,874,1029,1124,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1141,[34,102,874,1029,1120,1142,1124,821,1004,891,872,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1142,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1143,[34,1063,1127,102,874,1029,1026,876,872,1138,861,1004,891,1027,1120,821,858,1132,1117,1129,1144,14,1141,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1144,[34,102,874,872,1138,14,1125,821,794,25]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1145,[34,102,794,1063,1093,1146,1092,1086,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1146,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1147,[34,102,794,827,1034,891,835,1148,821,1149,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1148,[1035]); +__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1149,[34,402,102,1125,987,1150,1022,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1150,[933,976,1011,1019,1014,1017,1151,1152,1153,1154,1155,1156,977]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1151,[1019,933,1017]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1152,[1019,933,976,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1153,[1011,976,1152,1014,1017,1151]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1154,[933,977]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1155,[34,1014]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1156,[933]); +__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1157,[30,34,426,102,846,872,1088,1158,25]); +__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1158,[839,846,849]); +__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()},1159,[1160]); +__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1160,[1161,858,884]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1161,[1162,877,1163,878,858,884,1164]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1162,[858]); +__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'},1163,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1164,[858]); +__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1165,[978,34,835,402,102,874,891,1166,1161,794,821,1088,1159,1033,15,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1166,[34,102,794,874,1039,884,1167,831,13,1164,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1167,[34,884]); +__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1168,[34,402,102,794,867,821,1160,1159,1165,1033,25]); +__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1169,[34,402,102,794,874,1161,858,821,1170,1166,1165,25]); +__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1170,[828,34,283,364,236,102,426,797,794,827,821,1171,25]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1171,[]); +__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1172,[827,984,1173,835,860,1174,1175,34,402,295,102,794,874,882,1176,891,994,861,867,1179,858,821,1180,1113,1088,1160,1159,1181,869,1165,1033,925,1182,1004,987,1185,989,1098,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1173,[1159,984]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1174,[827,34,102,794,874,979,891,980,981,982,831,821,25]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1175,[]); +__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1176,[827,796,34,336,402,102,821,794,874,1177,1056,882,861,863,885,1109,1178,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1177,[]); +__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,"CREATOR_TITLE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"pounds",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"numIn",{enumerable:!0,get:function(){return v}}),_e.useOwnCosting=I,_e.DishCreator=function({rid:e,canPublish:t,initial:n="create"}){const l=I(),o=(0,d.useGpCalcView)(),[c,p]=(0,i.useState)(n),[g,h]=(0,i.useState)(()=>C(o.settings.defaultTarget));return l?(0,j.jsxs)(r.default,{style:{gap:12},testID:"dish-creator",children:[o.alerts.map(e=>(0,j.jsx)(r.default,{testID:"margin-alert",children:(0,j.jsx)(a.Banner,{kind:"danger",title:`Margin dropped: ${e.ingredient} ${e.change}`,children:(0,j.jsxs)(r.default,{style:{gap:4},children:[e.dishes.map(e=>(0,j.jsxs)(a.T,{size:14,colour:"#FFE3DF",children:[e.name,": ",(0,u.pct)(e.before)," \u2192 ",(0,u.pct)(e.after),e.belowTarget?' \xb7 below target':'']},e.id)),(0,j.jsx)(s.ToastClose,{label:"Dismiss alert",testID:`margin-alert-close-${e.id}`,onPress:()=>o.dismissAlert(e.id),size:"sm",style:{alignSelf:'flex-end'}})]})})},e.id)),(0,j.jsx)(y.Tabs,{value:c,onChange:p,options:[{id:'create',label:g.name&&o.dishes.some(e=>e.id===g.id)?'Edit dish':'Create'},{id:'saved',label:'Saved dishes & GP'},{id:'items',label:'Ingredient prices'},{id:'settings',label:'VAT & rounding'}]}),'create'===c?(0,j.jsx)(S,{draft:g,setDraft:h,onNew:()=>h(C(o.settings.defaultTarget)),onSaved:()=>p('saved')},g.id):null,'saved'===c?(0,j.jsx)(B,{rid:e,canPublish:t,onEdit:e=>{h({...e,allergens:[...e.allergens??[]]}),p('create')}}):null,'items'===c?(0,j.jsx)(M,{}):null,'settings'===c?(0,j.jsx)(V,{}):null,(0,j.jsx)(a.Muted,{children:"Costs are visible to Managers and the Head Chef only. Prices you enter, not supplier quotes."})]}):(0,j.jsx)(r.default,{testID:"dish-creator-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,j.jsx)(a.Muted,{center:!0,children:"Ingredient prices and dish costs are for the Head Chef, owners and managers."})})},_e.NewIngredient=k,Object.defineProperty(_e,"TALL",{enumerable:!0,get:function(){return L}}),_e.Pick=A,_e.Items=M,_e.useCardCosting=function(e,t,s="edit"){const{ingredients:n,settings:l,cardCosts:r}=(0,d.useGpCalcView)(),a=I();return(0,i.useMemo)(()=>{if(!e||!a||!(0,p.cardCostsVisible)(t,s))return null;const i=r?.[e.id];if(!i?.lines.length)return null;const o=(0,u.cardCostSummary)(i,n,l,e.price),d={};return o.lines.forEach(e=>{e.line.recipeIngId&&(d[e.line.recipeIngId]={cost:(d[e.line.recipeIngId]?.cost??0)+e.cost,label:e.label})}),{summary:o,byRecipeIng:d}},[e,t,s,a,n,l,r])},_e.CardGpPanel=function({card:e,actor:s,mode:n="edit"}){const{ingredients:l,settings:o,cardCosts:c,saveCardCost:g}=(0,d.useGpCalcView)(),h=I()&&(0,p.cardCostsVisible)(s.role,n),y=h&&'staff'!==s.role,f=c?.[e.id]??{lines:[],portions:1},C=(0,u.cardCostSummary)(f,l,o,e.price),[P,$]=(0,i.useState)(''),[S,D]=(0,i.useState)(),[R,B]=(0,i.useState)(!1),[G,M]=(0,i.useState)(f.menuPrice?(f.menuPrice/100).toFixed(2):''),[z,V]=(0,i.useState)(!1),[O,E]=(0,i.useState)(null),[F,U]=(0,i.useState)(!f.lines.length),[H,q]=(0,i.useState)(!1),[_,Y]=(0,i.useState)(null!=f.target?String(f.target):'');if(!h)return null;const X=t=>g(e.id,{...d.useGpCalc.getState().cardCosts[e.id]??f,...t}),K=(e,t)=>{if(t){const s=(0,b.suggestAmount)(t.qty,t.unit,e);if(s.qty>0)return s}const s=e.servings?'serving':(0,u.unitsFor)(e.packUnit)[0];return{qty:'serving'===s||'each'===s?1:0,unit:s}},J=(t,s=S)=>{const i=e.ingredients.find(e=>e.id===s),n={ingId:t.id,...K(t,i),...s?{recipeIngId:s}:{}},l=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...l.lines,n]}),$(''),D(void 0),B(!1),q(!1)},Q=(e,t)=>X({lines:f.lines.map((s,i)=>i===e?{...s,...t}:s)}),Z=new Set(f.lines.map(e=>e.recipeIngId).filter(Boolean)),ee=e.ingredients.filter(e=>e.name.trim()&&!Z.has(e.id)),te=ee.map(e=>({ri:e,i:(0,b.matchIngredient)(e.name,l)})).filter(e=>!!e.i),se=C.price?C.price/(1+o.vatPct/100):null,ie=l.filter(e=>!P.trim()||P.trim().toLowerCase().split(/\s+/).some(t=>t.length>2&&e.name.toLowerCase().includes(t))||e.name.toLowerCase().includes(P.trim().toLowerCase())).slice(0,12),ne=T(G),le=C.tone?w[C.tone]:x.colours.muted,re=null!=e.price&&C.price===e.price;return(0,j.jsxs)(r.default,{testID:"card-gp",accessibilityLabel:"GP calculator",style:{width:'100%',gap:10,padding:14,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:W},children:[(0,j.jsx)(a.T,{size:20,weight:"bold",center:!0,colour:x.colours.gold,accessibilityRole:"header",children:"GP calculator"}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.goldLight,children:["Costs from the price list (latest delivery prices) \xb7 target ",C.target,"% GP"]}),C.price?(0,j.jsxs)(r.default,{testID:"gp-vat-line",accessible:!0,accessibilityLabel:`Menu price ${(0,u.money)(C.price)} including VAT, ${(0,u.money)(se)} without VAT. GP is worked out on the price without VAT.`,style:{alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,weight:"semibold",children:[(0,u.money)(C.price)," inc VAT \xb7 ",(0,u.money)(se)," ex VAT"]}),(0,j.jsxs)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:[C.priceIsSuggested?'Suggested price':f.menuPrice?'The price you typed':'Menu price on the card'," \xb7 GP is on the ex-VAT price"]})]}):null,f.lines.length?(0,j.jsx)(r.default,{testID:"card-gp-lines",style:{gap:8},children:C.lines.map((e,s)=>{const i=l.find(t=>t.id===e.line.ingId);return(0,j.jsxs)(r.default,{testID:"card-gp-line",style:{gap:6,paddingVertical:8,borderTopWidth:s?1:0,borderColor:x.colours.accentBorder},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.label}, ${i?(0,u.money)(e.cost):'not on the price list'}`,style:{flexDirection:'row',gap:8,alignItems:'center',minHeight:32},children:[(0,j.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,j.jsx)(a.T,{weight:"medium",children:e.name}),(0,j.jsx)(a.T,{size:x.font.small,colour:x.colours.muted,children:e.label})]}),(0,j.jsx)(a.T,{weight:"semibold",colour:i?x.colours.goldLight:x.colours.amber,children:i?(0,u.money)(e.cost):'Removed'})]}),F&&y&&i?(()=>{const n=(0,u.unitsFor)(i.packUnit,i.servings),l=t=>(0,j.jsx)(A,{testID:`gp-unit-${s}-${t}`,label:'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2),accessibilityLabel:`${e.name} by ${'serving'===t?(0,u.servingWord)(i,2):(0,u.unitName)(t,2)}`,selected:e.line.unit===t,onPress:()=>Q(s,{unit:t})},t);return(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:`gp-qty-${s}`,accessibilityLabel:`Amount of ${e.name}`,value:e.line.qty?String(e.line.qty):'',onChangeText:e=>Q(s,{qty:v(e)??0}),placeholder:"amount",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),n.slice(0,-1).map(l),(0,j.jsxs)(r.default,{testID:`gp-unit-end-${s}`,style:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',gap:6},children:[n.slice(-1).map(l),(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})]})]})})():F&&y?(0,j.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:(0,j.jsx)(A,{testID:`gp-remove-${s}`,label:"Remove",accessibilityLabel:`Remove ${e.name} from the costing`,onPress:()=>X({lines:f.lines.filter((e,t)=>t!==s)})})}):null]},s)})}):(0,j.jsx)(r.default,{testID:"card-gp-empty",style:{alignItems:'center',paddingVertical:6},children:(0,j.jsxs)(a.T,{center:!0,colour:x.colours.goldLight,children:["Not costed yet.",y?' Add the ingredients from your price list below.':'']})}),y&&f.lines.length?(0,j.jsx)(a.Button,{small:!0,kind:F?'primary':'secondary',testID:"gp-edit",label:F?'Done':'Change amounts or ingredients',accessibilityLabel:F?'Done changing the costing':`Change the costing for ${e.dish}`,onPress:()=>{U(!F),B(!1)}}):null,y&&F?(0,j.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[te.length?(0,j.jsx)(a.Button,{testID:"gp-link-all",label:`Link ${te.length} matching price${1===te.length?'':'s'}`,accessibilityLabel:`Link ${te.length} of this card's ingredients to matching items on the price list`,onPress:()=>{const t=d.useGpCalc.getState().cardCosts[e.id]??f;X({lines:[...t.lines,...te.map(({ri:e,i:t})=>({ingId:t.id,...K(t,e),recipeIngId:e.id}))]}),E(`Linked ${te.length} ingredient${1===te.length?'':'s'} to the price list. Check the amounts below.`)},style:{minHeight:52}}):null,ee.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Cost this card\u2019s ingredients"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:ee.slice(0,10).map(e=>(0,j.jsx)(A,{testID:`gp-cost-${e.id}`,label:e.name.split(',')[0].slice(0,28),accessibilityLabel:`Cost ${e.name}`,selected:S===e.id,onPress:()=>{D(e.id),$(e.name.split(/[,(]/)[0].trim()),B(!0)}},e.id))})]}):null,R?(0,j.jsxs)(r.default,{style:{width:'100%',gap:6},children:[(0,j.jsx)(t.TextInput,{testID:"gp-search",accessibilityLabel:"Search ingredient prices",value:P,onChangeText:$,placeholder:"Search the price list",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[ie.map(e=>{const t=(0,u.perServing)(e),s=(0,u.perBaseUnit)(e),i=null!=t?`${(0,u.money)(t)} a ${(0,u.servingWord)(e,1)}`:s?`${(0,u.money)(s.pence)} a ${s.per}`:(0,u.money)(e.packPrice);return(0,j.jsx)(A,{testID:`gp-pick-${e.id}`,label:`${e.name} \xb7 ${i}`,accessibilityLabel:`Add ${e.name}, ${i}`,onPress:()=>J(e)},e.id)}),ie.length?null:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:l.length?'Nothing on the price list matches.':'The price list is empty. Add a price here, or record a delivery.'})]}),H?(0,j.jsx)(k,{initial:P.trim(),onDone:e=>{q(!1);const t=e?d.useGpCalc.getState().ingredients.find(t=>t.id===e):void 0;t&&J(t)}}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add-price",label:P.trim()?`Add a price for ${P.trim().slice(0,30)}`:'Add a new price',accessibilityLabel:`Add ${P.trim()||'a new ingredient'} to the price list and cost it on this card`,onPress:()=>q(!0)}),(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{B(!1),D(void 0),$(''),q(!1)}})]}):(0,j.jsx)(a.Button,{small:!0,testID:"gp-add",kind:"secondary",label:"Add from ingredient prices",onPress:()=>{B(!0),D(void 0)}}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Target GP %"}),(0,j.jsx)(t.TextInput,{testID:"gp-target",accessibilityLabel:`Target GP percent for this dish, now ${C.target}`,value:_,onChangeText:e=>{Y(e);const t=v(e);null!=t&&t>0&&t<95?X({target:t}):e.trim()||X({target:void 0})},placeholder:String(o.defaultTarget),placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]}),(0,j.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{testID:"gp-portions",accessibilityLabel:"Portions this recipe makes",value:String(f.portions||1),onChangeText:e=>X({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,L,{width:72,textAlign:'center'}]})]})]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-food-cost",label:"Food cost per portion",value:(0,u.money)(C.perPortion),colour:x.colours.goldLight,sub:(f.portions||1)>1?`Batch ${(0,u.money)(C.batch)} \xf7 ${f.portions}`:C.missing?`${C.missing} line${1===C.missing?'':'s'} not costed`:void 0}),(0,j.jsx)(N,{testID:"gp-suggested",label:`Suggested at ${C.target}% GP`,value:C.suggested?(0,u.money)(C.suggested):'\u2014',colour:x.colours.gold,sub:C.suggested?"inc VAT"+(o.pricePoints?', rounded up':''):'Add amounts first'})]}),y?(0,j.jsxs)(r.default,{style:{gap:6,alignItems:'center'},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"Your menu price (inc VAT)"}),(0,j.jsxs)(a.Row,{gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{size:24,style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{testID:"gp-price",accessibilityLabel:"Your menu price in pounds, including VAT",value:G,onChangeText:e=>{M(e);const t=T(e);null!=t&&t>0?X({menuPrice:t}):e.trim()||X({menuPrice:void 0})},placeholder:C.price?(C.price/100).toFixed(2):'0.00',placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{minHeight:56,width:150,fontSize:24,textAlign:'center'}]})]}),(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:ne?'GP below uses the price you typed.':e.price?`Blank uses the menu price, ${(0,u.money)(e.price)}.`:'Blank uses the suggested price.'}),C.suggested&&!ne?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:"gp-use-suggested",label:`Use suggested ${(0,u.money)(C.suggested)}`,accessibilityLabel:`Use the suggested price, ${(0,u.money)(C.suggested)}`,onPress:()=>{M((C.suggested/100).toFixed(2)),X({menuPrice:C.suggested})}}):null]}):null,(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(N,{testID:"gp-gp",label:`GP on ${C.price?(0,u.money)(C.price):'the price'}`,value:null!=C.gp?(0,u.pct)(C.gp):'\u2014',colour:le,sub:null!=C.gp?'ok'===C.tone?'On target':'amber'===C.tone?'Just under target':'Below target':void 0}),(0,j.jsx)(N,{testID:"gp-cash",label:"Cash GP per portion",value:null!=C.cashGp?(0,u.money)(C.cashGp):'\u2014',colour:le,sub:C.price?`${(0,u.money)(C.price/(1+o.vatPct/100))} ex VAT`:void 0})]}),y&&C.price&&!re?z?(0,j.jsxs)(r.default,{testID:"gp-menu-confirm",style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Put ",(0,u.money)(C.price)," on the menu? The card goes back to Awaiting sign-off until a chef signs it again."]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"gp-menu-yes",label:`Yes, use ${(0,u.money)(C.price)}`,onPress:async()=>{if(C.price)try{await(0,m.recipeCards)().update(e.id,{price:C.price},s),E(`Menu price set to ${(0,u.money)(C.price)}. The card now waits for sign-off again.`),V(!1)}catch(e){E(e?.message??'Could not change the menu price.')}}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Not now",onPress:()=>V(!1)})]})]}):(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:"gp-menu",label:`Use ${(0,u.money)(C.price)} on the menu`,accessibilityLabel:`Use ${(0,u.money)(C.price)} as the menu price for ${e.dish}`,onPress:()=>V(!0)}):null,O?(0,j.jsx)(a.T,{center:!0,size:x.font.small,colour:x.colours.goldLight,children:O}):null,(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:"GP is worked out on the price without VAT. Only the Head Chef and managers see costs."})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),r=e(_r(_d[6])),a=_r(_d[7]),o=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),u=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]);const f='New dish creator',w={ok:x.colours.ok,amber:x.colours.amber,red:x.colours.red},T=e=>{const t=e.replace(/[\xa3\s]/g,'').replace(',','.');return/^\d+(\.\d{1,2})?$/.test(t)?Math.round(100*Number(t)):null},v=e=>{const t=e.trim().replace(',','.');return/^\d*\.?\d+$/.test(t)?Number(t):null},C=e=>({id:(0,d.gid)('gd'),name:'',lines:[],portions:1,target:e,status:'draft',allergens:[],description:''});function I(){const e=(0,h.useSession)(e=>e.meId),t=(0,g.useOwner)(t=>e?t.staff.find(t=>t.id===e):void 0);return!e||!!t&&t.active&&(0,p.costsAllowedFor)(t)}function P({n:e,title:t,children:s,testID:i}){return(0,j.jsxs)(y.Box,{testID:i,children:[(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(r.default,{style:{width:30,height:30,borderRadius:15,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.onGold,children:e})}),(0,j.jsx)(a.T,{size:18,weight:"semibold",style:{flex:1},children:t})]}),s]})}function $({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n}){return(0,j.jsxs)(r.default,{testID:i,style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:14,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border,gap:2},children:[(0,j.jsx)(a.Muted,{children:e}),(0,j.jsx)(a.T,{size:30,weight:"bold",colour:s,children:t}),n?(0,j.jsx)(a.Muted,{children:n}):null]})}function S({draft:e,setDraft:n,onNew:l,onSaved:o}){const{ingredients:p,dishes:g,settings:h,saveDish:m}=(0,d.useGpCalcView)(),[b,f]=(0,i.useState)(''),[C,I]=(0,i.useState)(!1),[S,L]=(0,i.useState)(''),[A,R]=(0,i.useState)(e.menuPrice?'price':'gp'),[B,G]=(0,i.useState)(e.menuPrice?(e.menuPrice/100).toFixed(2):''),[M,z]=(0,i.useState)(String(e.target)),[V,W]=(0,i.useState)(String(e.targetX??4)),N=t=>n({...e,...t}),O=g.filter(t=>t.id!==e.id),E=(0,u.portionCost)(e,p,g),F=h.vatPct,U=v(M)??e.target,H=v(V)??4,q='price'===A?T(B):E>0?'gp'===A?(0,u.suggestPrice)(E,U,F,h.pricePoints):(0,u.suggestForMultiple)(E,H,F,h.multipleBasis,h.pricePoints):null,_=q?(0,u.gpOf)(E,q,F):null,Y=q?(0,u.multipleOf)(E,q,F,h.multipleBasis):0,X=_?(0,u.toneFor)(_.gpPct,U):'ok',K=(0,u.suggestAllergens)(e,p,g),J=t=>{const s=p.find(e=>e.id===t),i=t.startsWith('dish:')?'each':(0,u.unitsFor)(s.packUnit,s.servings)[0],l=[...e.lines,{ingId:t,qty:t.startsWith('dish:')?1:0,unit:i}],r={...e,lines:l},a=(0,u.suggestAllergens)(r,p,g);n({...r,allergens:Array.from(new Set([...e.allergens??[],...a]))})},Q=(t,s)=>N({lines:e.lines.map((e,i)=>i===t?{...e,...s}:e)}),Z=p.filter(e=>!b.trim()||e.name.toLowerCase().includes(b.trim().toLowerCase())),ee=t=>{if(!e.name.trim())return L('Give the dish a name first.');if('ready'===t){if(!e.category)return L('Pick a category to make it menu-ready.');if(!e.lines.length||E<=0)return L('Add ingredients with quantities to make it menu-ready.');if(!q)return L('Set a price to make it menu-ready.')}const s='published'===e.status?'published':t;m({...e,name:e.name.trim(),target:U,targetX:H,menuPrice:q??void 0,status:s}),L('ready'===t?`Saved \u201c${e.name.trim()}\u201d as menu-ready. A manager can publish it to the menu.`:`Saved \u201c${e.name.trim()}\u201d as a draft.`)};return(0,j.jsxs)(r.default,{style:{gap:12},children:[(0,j.jsxs)(P,{n:1,title:"Name and category",testID:"step-name",children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:"Dish name",value:e.name,onChangeText:e=>N({name:e.slice(0,60)}),placeholder:"e.g. Cullen skink",placeholderTextColor:"#7D776C",style:[a.styles.input,{fontSize:20}]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:u.DISH_CATEGORIES.map(t=>(0,j.jsx)(a.Chip,{label:t,selected:e.category===t,onPress:()=>N({category:t})},t))})]}),(0,j.jsxs)(P,{n:2,title:"Add saved items and ingredients",testID:"step-ingredients",children:[O.length?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(a.Muted,{children:"Saved items (tap to add a portion)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:O.map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(`dish:${e.id}`)},e.id))})]}):null,(0,j.jsx)(a.Muted,{children:"Ingredients"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredients",value:b,onChangeText:f,placeholder:"Search ingredients",placeholderTextColor:"#7D776C",style:a.styles.input}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[Z.slice(0,24).map(e=>(0,j.jsx)(a.Chip,{label:`${e.name}`,onPress:()=>J(e.id)},e.id)),(0,j.jsx)(a.Chip,{label:"New ingredient",onPress:()=>I(!0)})]}),C?(0,j.jsx)(k,{initial:b,onDone:e=>{I(!1),f(''),e&&J(e)}}):null,e.lines.length?(0,j.jsx)(r.default,{style:{gap:8},testID:"dish-lines",children:e.lines.map((i,n)=>{const l=i.ingId.startsWith('dish:'),o=p.find(e=>e.id===i.ingId),d=(c=i.ingId).startsWith('dish:')?g.find(e=>e.id===c.slice(5))?.name??'Saved item':p.find(e=>e.id===c)?.name??'?';var c;return(0,j.jsxs)(r.default,{testID:"dish-line",style:{gap:6,padding:10,borderRadius:12,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:x.colours.border},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(a.T,{weight:"medium",style:{flex:1},children:[d,l?' (saved item)':'']}),(0,j.jsx)(a.T,{weight:"semibold",children:(0,u.money)((0,u.lineCost)(i,p,g))}),(0,j.jsx)(s.GoldClose,{size:"sm",label:`Remove ${d}`,onPress:()=>N({lines:e.lines.filter((e,t)=>t!==n)})})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Quantity of ${d}`,value:i.qty?String(i.qty):'',onChangeText:e=>Q(n,{qty:v(e)??0}),placeholder:"qty",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:90}]}),l?(0,j.jsx)(a.Muted,{children:"portion(s)"}):(0,u.unitsFor)(o.packUnit,o.servings).map(e=>(0,j.jsx)(a.Chip,{label:'serving'===e?(0,u.servingWord)(o,2):(0,u.unitName)(e,2),selected:i.unit===e,onPress:()=>Q(n,{unit:e})},e)),l?null:(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${d}`,value:null==i.wastePct?'':String(i.wastePct),onChangeText:e=>Q(n,{wastePct:''===e.trim()?void 0:v(e)??0}),placeholder:`waste ${o.wastePct}%`,placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:110}]})]})]},n)})}):(0,j.jsx)(a.Muted,{children:"Nothing added yet. Tap a saved item or an ingredient above."}),(0,j.jsxs)(a.Row,{gap:10,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Portions this makes"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Portions per batch",value:String(e.portions),onChangeText:e=>N({portions:Math.max(1,Math.round(v(e)??1))}),keyboardType:"number-pad",style:[a.styles.input,{width:80,textAlign:'center'}]})]}),(0,j.jsx)($,{testID:"cost-per-plate",label:"Cost per plate",value:(0,u.money)(E),sub:e.portions>1?`Batch cost ${(0,u.money)(E*e.portions)} \xf7 ${e.portions}`:'Live: updates as you type'})]}),(0,j.jsxs)(P,{n:3,title:"Price it",testID:"step-price",children:[(0,j.jsx)(y.Tabs,{value:A,onChange:R,options:[{id:'gp',label:'Target GP %'},{id:'x',label:'Target multiple'},{id:'price',label:'Type a price'}]}),'gp'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[65,70,75].map(e=>(0,j.jsx)(a.Chip,{label:`${e}%`,selected:U===e,onPress:()=>z(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target GP %",value:M,onChangeText:z,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'x'===A?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[[3,4,5].map(e=>(0,j.jsx)(a.Chip,{label:`${e}x`,selected:H===e,onPress:()=>W(String(e))},e)),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Target multiple",value:V,onChangeText:W,keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}):null,'price'===A?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{size:24,children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Menu price (inc VAT)",value:B,onChangeText:G,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,{width:140,fontSize:24}]}),(0,j.jsx)(a.Muted,{children:"inc VAT"})]}):null,'price'!==A?(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"suggested-price",label:`Suggested menu price (inc ${F}% VAT)`,value:q?(0,u.money)(q):'\u2014',colour:x.colours.gold,sub:q?`${(0,u.money)(q/(1+F/100))} ex VAT${h.pricePoints?' \xb7 rounded up to .50 / .95':''}`:'Add ingredients first'}),q?(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Type my own price",onPress:()=>{G((q/100).toFixed(2)),R('price')}}):null]}):null,(()=>{const t=(0,u.avgMenuPrice)(g,e.category,e.id);return e.category?(0,j.jsx)(r.default,{testID:"avg-menu-price",children:(0,j.jsx)(a.Muted,{children:t?`Average menu price for ${e.category}: ${(0,u.money)(t.avg)} (${t.count} dish${1===t.count?'':'es'})${q?` \xb7 this dish ${q>=t.avg?'+':'\u2212'}${(0,u.money)(Math.abs(q-t.avg))}`:''}`:`No other priced ${e.category.toLowerCase()} yet to compare with.`})}):null})(),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)($,{testID:"big-gp",label:`GP (target ${U}%)`,value:_?(0,u.pct)(_.gpPct):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-x",label:`Multiple (${'inc'===h.multipleBasis?'inc VAT price':'ex VAT price'} \xf7 cost)`,value:_&&E>0?(0,u.fmtX)(Y):'\u2014',colour:x.colours.gold}),(0,j.jsx)($,{testID:"big-profit",label:"Profit per plate (cash GP)",value:_?(0,u.money)(_.cashGp):'\u2014',colour:_?w[X]:x.colours.muted}),(0,j.jsx)($,{testID:"big-foodcost",label:"Food cost",value:_?(0,u.pct)(_.foodCostPct):'\u2014'})]}),(0,j.jsxs)(a.Muted,{children:["GP is worked out on the price without VAT (",F,"% VAT). Gold: at or above target \xb7 amber: up to 5 points under \xb7 red: more than 5 under."]})]}),(0,j.jsxs)(P,{n:4,title:"Photo, allergens and description",testID:"step-details",children:[(0,j.jsx)(D,{value:e.photo,onChange:e=>N({photo:e})}),(0,j.jsx)(a.T,{weight:"medium",children:"Allergens (14 UK allergens)"}),K.length?(0,j.jsx)(r.default,{testID:"allergen-suggest",children:(0,j.jsxs)(a.Muted,{children:["Suggested from the ingredients: ",K.map(e=>c.ALLERGENS.find(t=>t.id===e).short).join(', '),". Check before it goes on the menu."]})}):(0,j.jsx)(a.Muted,{children:"No allergens known from these ingredients yet. Tick any that apply."}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,children:c.ALLERGENS.map(t=>{const s=(e.allergens??[]).includes(t.id);return(0,j.jsx)(a.Chip,{label:`${s?'\u2713 ':''}${t.short}`,sub:K.includes(t.id)?'suggested':void 0,selected:s,onPress:()=>N({allergens:s?e.allergens.filter(e=>e!==t.id):[...e.allergens??[],t.id]})},t.id)})}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Short description",value:e.description??'',onChangeText:e=>N({description:e.slice(0,160)}),multiline:!0,placeholder:"Short description for the menu (up to 160 characters)",placeholderTextColor:"#7D776C",style:[a.styles.input,{minHeight:70,textAlignVertical:'top'}]}),(0,j.jsxs)(a.Muted,{children:[(e.description??'').length,"/160"]})]}),(0,j.jsxs)(P,{n:5,title:"Save",testID:"step-save",children:[(0,j.jsxs)(a.Row,{wrap:!0,gap:8,children:[(0,j.jsx)(a.Button,{label:"Save as draft",kind:"secondary",testID:"save-draft",onPress:()=>ee('draft'),style:{flexGrow:1}}),(0,j.jsx)(a.Button,{label:"Save as menu-ready dish",testID:"save-ready",onPress:()=>ee('ready'),style:{flexGrow:1}})]}),S?(0,j.jsx)(r.default,{testID:"creator-msg",children:(0,j.jsx)(a.T,{size:15,colour:S.startsWith('Saved')?x.colours.ok:x.colours.amber,children:S})}):null,S.startsWith('Saved')?(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.Button,{small:!0,label:"See saved dishes",onPress:o}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Start a new dish",onPress:()=>{l(),L(''),G(''),R('gp')}})]}):null]})]})}function D({value:e,onChange:t}){return(0,j.jsxs)(a.Row,{gap:10,children:[e?(0,j.jsx)(n.default,{testID:"dish-photo",source:{uri:e},style:{width:96,height:72,borderRadius:10}}):(0,j.jsx)(r.default,{style:{width:96,height:72,borderRadius:10,borderWidth:1,borderStyle:'dashed',borderColor:x.colours.border,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(a.Muted,{children:"No photo"})}),(0,j.jsxs)(r.default,{style:{gap:6},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:e?'Change photo':'Add photo (optional)',onPress:()=>{if('undefined'==typeof document)return;const e=document.createElement('input');e.type='file',e.accept='image/*',e.onchange=()=>{const s=e.files?.[0];if(!s)return;const i=new FileReader;i.onload=()=>{const e=new window.Image;e.onload=()=>{const s=Math.min(1,480/Math.max(e.width,e.height)),i=document.createElement('canvas');i.width=Math.round(e.width*s),i.height=Math.round(e.height*s),i.getContext('2d').drawImage(e,0,0,i.width,i.height),t(i.toDataURL('image/jpeg',.8))},e.src=String(i.result)},i.readAsDataURL(s)},e.click()}}),e?(0,j.jsx)(a.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>t(void 0)}):null]})]})}function k({initial:e,onDone:s,edit:n}){const[l,o]=(0,i.useState)(n?.name??e),[p,g]=(0,i.useState)(n?String(n.packSize):''),[h,m]=(0,i.useState)(n?.packUnit??'kg'),[y,b]=(0,i.useState)(n?(n.packPrice/100).toFixed(2):''),[f,w]=(0,i.useState)(n?.wastePct?String(n.wastePct):''),[C,I]=(0,i.useState)(n?.allergens??[]),[P,$]=(0,i.useState)(n?.servings?String(n.servings):''),[S,D]=(0,i.useState)(n?.servingName??''),[k,R]=(0,i.useState)(n?.supplier??''),B=!(!l.trim()||!v(p)||null==T(y)||''!==P.trim()&&!v(P)),G={id:'probe',name:l,packSize:v(p)??0,packUnit:h,packPrice:T(y)??0,wastePct:0,servings:v(P)??void 0,servingName:S.trim()||void 0},M=G.packSize&&G.packPrice?(0,u.perBaseUnit)(G):null,z=G.packPrice?(0,u.perServing)(G):null,V={name:l.trim(),packSize:v(p),packUnit:h,packPrice:T(y),wastePct:Math.min(90,v(f)??0),allergens:C,servings:v(P)??void 0,servingName:S.trim().toLowerCase()||void 0,supplier:k.trim()||void 0};return(0,j.jsxs)(r.default,{testID:n?`edit-ingredient-${n.id}`:'new-ingredient',style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:x.colours.gold,width:'100%'},children:[(0,j.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:n?`Edit ${n.name}`:'New ingredient'}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Ingredient name",value:l,onChangeText:o,placeholder:"e.g. Haddock",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Pack price and what you get for it, e.g. \xa3110 for 1 stone, or \xa340 for 5 kg"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{testID:"ing-pack-price",accessibilityLabel:"Pack price in pounds",value:y,onChangeText:b,placeholder:"\xa3 price",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110,textAlign:'center'}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"for"}),(0,j.jsx)(t.TextInput,{testID:"ing-pack-size",accessibilityLabel:"Pack size",value:p,onChangeText:g,placeholder:"size",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]})]}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.PACK_UNITS.map(e=>(0,j.jsx)(A,{testID:`ing-unit-${e}`,label:(0,u.unitName)(e,2),selected:h===e,onPress:()=>m(e)},e))}),(0,j.jsx)(a.Muted,{center:!0,children:"Optional: roughly how many servings or pieces one pack gives"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"averages"}),(0,j.jsx)(t.TextInput,{testID:"ing-servings",accessibilityLabel:"Averages how many servings or pieces",value:P,onChangeText:$,placeholder:"e.g. 30",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:90,textAlign:'center'}]}),(0,j.jsx)(t.TextInput,{testID:"ing-serving-name",accessibilityLabel:"What one is called, for example serving, breast or piece",value:S,onChangeText:D,placeholder:"serving / breast",placeholderTextColor:"#7D776C",style:[a.styles.input,L,{width:150,textAlign:'center'}]})]}),M||null!=z?(0,j.jsx)(r.default,{testID:"ing-derived",accessible:!0,accessibilityLabel:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(', '),children:(0,j.jsx)(a.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=z?`${(0,u.money)(z)} a ${(0,u.servingWord)(G,1)}`:'',M?`${(0,u.money)(M.pence)} a ${M.per}`:''].filter(Boolean).join(' \xb7 ')})}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Supplier (optional)",value:k,onChangeText:R,placeholder:"Supplier (optional)",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Yield loss or waste percent (optional)",value:f,onChangeText:w,placeholder:"Trim / waste % (optional, for weights)",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L]}),(0,j.jsx)(a.Muted,{center:!0,children:"Allergens in this ingredient (if known)"}),(0,j.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:c.ALLERGENS.map(e=>(0,j.jsx)(a.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>I(C.includes(e.id)?C.filter(t=>t!==e.id):[...C,e.id])},e.id))}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,testID:"ing-save",label:n?'Save ingredient':'Add ingredient',disabled:!B,onPress:()=>{if(n){const e=d.useGpCalc.getState();V.packPrice!==n.packPrice&&e.addPricePaid(n.id,V.packPrice);const t=d.useGpCalc.getState().ingredients.find(e=>e.id===n.id)??n;e.saveIngredient({...t,...V,packPrice:t.packPrice}),s(n.id)}else s(d.useGpCalc.getState().addIngredient(V))}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel",onPress:()=>s()})]})]})}const L={minHeight:48};function A({label:e,selected:t,onPress:s,testID:i,accessibilityLabel:n}){return(0,j.jsx)(l.default,{testID:i,accessibilityRole:"button",accessibilityState:{selected:!!t},accessibilityLabel:`${n??e}${t?', selected':''}`,onPress:s,style:{minHeight:48,minWidth:48,paddingHorizontal:14,justifyContent:'center',alignItems:'center',borderRadius:24,borderWidth:1,borderColor:t?x.colours.gold:x.colours.border,backgroundColor:t?x.colours.gold:x.colours.surface2,maxWidth:'100%'},children:(0,j.jsx)(a.T,{size:x.font.small,weight:"medium",center:!0,colour:t?x.colours.onGold:x.colours.text,children:e})})}const R={draft:{label:'Draft',kind:'neutral'},ready:{label:'Menu-ready',kind:'gold'},published:{label:'On the menu',kind:'ok'}};function B({rid:e,canPublish:t,onEdit:s}){const{dishes:n,ingredients:l,settings:c,saveDish:p}=(0,d.useGpCalcView)(),[g,h]=(0,i.useState)('low'),[m,b]=(0,i.useState)(''),f=(0,i.useMemo)(()=>n.map(e=>{const t=(0,u.portionCost)(e,l,n);return{d:e,cost:t,g:e.menuPrice?(0,u.gpOf)(t,e.menuPrice,c.vatPct):null,x:e.menuPrice?(0,u.multipleOf)(t,e.menuPrice,c.vatPct,c.multipleBasis):0}}).sort((e,t)=>(e.g?e.g.gpPct:999)-(t.g?t.g.gpPct:999)),[n,l,c]),T='low'===g?f:[...f].reverse(),v=f.filter(e=>e.g&&e.g.gpPct{const s={};(t.allergens??[]).forEach(e=>{s[e]='contains'});const i=o.useStore.getState().addMenuItem({restaurantId:e,section:t.category??'Specials',name:t.name,description:t.description??'',price:t.menuPrice??null,dietary:[],allergens:s,prepMins:12,soldOut:!1,signOff:null});p({...t,status:'published',menuItemId:i}),b(`Published \u201c${t.name}\u201d to the menu (${t.category??'Specials'}). It needs allergen sign-off in Menu & allergens.`)};return(0,j.jsxs)(y.Box,{testID:"menu-gp",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"Saved dishes and items \xb7 Menu GP"}),(0,j.jsxs)(a.Muted,{children:[f.length," saved \xb7 ",v," below target \xb7 multiples on the ",'inc'===c.multipleBasis?'inc-VAT menu price':'ex-VAT price']}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Lowest GP first",selected:'low'===g,onPress:()=>h('low')}),(0,j.jsx)(a.Chip,{label:"Highest GP first",selected:'high'===g,onPress:()=>h('high')})]}),T.map(({d:e,cost:i,g:n,x:l})=>{const o=n?(0,u.toneFor)(n.gpPct,e.target):null;return(0,j.jsxs)(r.default,{testID:"gp-row",style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:4},children:[(0,j.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,j.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",children:e.name}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Badge,{kind:R[e.status??'draft'].kind,label:R[e.status??'draft'].label}),e.category?(0,j.jsx)(a.Muted,{children:e.category}):null]}),(0,j.jsxs)(a.Muted,{children:["Cost ",(0,u.money)(i),e.menuPrice?` \xb7 price ${(0,u.money)(e.menuPrice)}`:' \xb7 no price yet']})]}),(0,j.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(a.T,{size:22,weight:"bold",colour:o?w[o]:x.colours.muted,children:n?(0,u.pct)(n.gpPct):'\u2014'}),(0,j.jsx)(a.T,{size:16,weight:"semibold",colour:x.colours.gold,children:n&&i>0?(0,u.fmtX)(l):''})]})]}),n&&n.gpPcts(e)}),t&&'ready'===e.status?(0,j.jsx)(a.Button,{small:!0,label:"Publish to menu",accessibilityLabel:`Publish ${e.name} to menu`,onPress:()=>C(e)}):null,t||'ready'!==e.status?null:(0,j.jsx)(a.Muted,{children:"Waiting for a manager to publish"})]})]},e.id)}),m?(0,j.jsx)(r.default,{testID:"publish-msg",children:(0,j.jsx)(a.T,{size:14,colour:x.colours.ok,children:m})}):null]})}function G(){const{settings:e,setSettings:t}=(0,d.useGpCalcView)(),s=e.priceBasis??'latest',i=e.avgOf??5;return(0,j.jsxs)(r.default,{testID:"price-basis",style:{gap:6},children:[(0,j.jsx)(a.T,{weight:"medium",children:"Cost dishes using"}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Chip,{label:"Latest price paid",selected:'latest'===s,onPress:()=>t({priceBasis:'latest'})}),(0,j.jsx)(a.Chip,{label:`Average price (last ${i})`,selected:'average'===s,onPress:()=>t({priceBasis:'average'})})]}),'average'===s?(0,j.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(a.Muted,{children:"Average of the last"}),[3,5,10].map(e=>(0,j.jsx)(a.Chip,{label:`${e} prices`,selected:i===e,onPress:()=>t({avgOf:e})},e))]}):null,(0,j.jsx)(a.Muted,{children:'average'===s?'Averages smooth out price swings, so GP doesn\u2019t jump every delivery.':'Uses the most recent price you paid.'})]})}function M(){const{ingredients:e,dishes:s,settings:n,cardCosts:l}=(0,d.useGpCalcView)(),[o,c]=(0,i.useState)(''),[u,p]=(0,i.useState)(''),[g,h]=(0,i.useState)(!1),m=e.filter(e=>!u.trim()||`${e.name} ${e.supplier??''}`.toLowerCase().includes(u.trim().toLowerCase())).slice().sort((e,t)=>e.name.localeCompare(t.name));return(0,j.jsxs)(y.Box,{testID:"calc-items",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Ingredient prices"}),(0,j.jsx)(a.Muted,{center:!0,children:"What you pay and what a pack gives you. Recipe cards and dishes cost themselves from this list and update when a price changes."}),(0,j.jsx)(a.Button,{testID:"ing-add-new",label:"Add an ingredient",onPress:()=>{h(!0),c('')}}),g?(0,j.jsx)(k,{initial:u,onDone:e=>{h(!1),e&&c('Added to the price list.')}}):null,(0,j.jsx)(t.TextInput,{accessibilityLabel:"Search ingredient prices",value:u,onChangeText:p,placeholder:"Search ingredients or suppliers",placeholderTextColor:"#7D776C",style:[a.styles.input,L]}),(0,j.jsx)(G,{}),m.map(e=>{return(0,j.jsx)(z,{i:e,n:n.avgOf??5,basis:n.priceBasis??'latest',used:(t=e.id,s.filter(e=>e.lines.some(e=>e.ingId===t)).length+Object.values(l??{}).filter(e=>e.lines.some(e=>e.ingId===t)).length),onSaved:e=>c(e)},e.id);var t}),m.length?null:(0,j.jsx)(r.default,{testID:"ing-empty",style:{alignItems:'center',paddingVertical:12},children:(0,j.jsx)(a.T,{center:!0,colour:x.colours.muted,children:e.length?'No ingredients match.':'No ingredient prices yet. Add the first one above.'})}),o?(0,j.jsx)(r.default,{testID:"items-msg",children:(0,j.jsx)(a.T,{size:14,center:!0,colour:x.colours.ok,children:o})}):null]})}function z({i:e,used:s,n:n,basis:l,onSaved:o}){const[c,p]=(0,i.useState)(String(e.wastePct)),[g,h]=(0,i.useState)(''),[m,y]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),w=(0,u.priceStats)(e,n),C=c!==String(e.wastePct),I=T(g),P=(0,u.perBaseUnit)(e),$=(0,u.perServing)(e),S=`${e.name}, ${(0,u.money)(e.packPrice)} for ${e.packSize} ${(0,u.unitName)(e.packUnit,e.packSize)}${e.servings?`, averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}, ${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:''}${P?`, ${(0,u.money)(P.pence)} a ${P.per}`:''}${e.supplier?`, from ${e.supplier}`:''}`;return m?(0,j.jsx)(k,{initial:"",edit:e,onDone:t=>{y(!1),t&&o(`Saved ${e.name}. Recipe cards and dishes re-costed.`)}}):(0,j.jsxs)(r.default,{testID:`item-${e.id}`,style:{paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border,gap:6},children:[(0,j.jsxs)(r.default,{accessible:!0,accessibilityLabel:S,style:{gap:2},children:[(0,j.jsx)(a.T,{weight:"semibold",size:18,center:!0,children:e.name}),(0,j.jsxs)(a.T,{testID:`pack-${e.id}`,center:!0,colour:x.colours.goldLight,children:[(0,u.money)(e.packPrice)," for ",e.packSize," ",(0,u.unitName)(e.packUnit,e.packSize),e.servings?` \xb7 averages ${e.servings} ${(0,u.servingWord)(e,e.servings)}`:'']}),(0,j.jsx)(a.T,{testID:`derived-${e.id}`,center:!0,weight:"semibold",colour:x.colours.gold,children:[null!=$?`${(0,u.money)($)} a ${(0,u.servingWord)(e,1)}`:'',P?`${(0,u.money)(P.pence)} a ${P.per}`:''].filter(Boolean).join(' \xb7 ')}),(0,j.jsx)(a.Muted,{center:!0,children:[s?`used in ${s}`:'not used yet',e.supplier,e.updatedAt?`updated ${new Date(e.updatedAt).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}`:''].filter(Boolean).join(' \xb7 ')})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsxs)(r.default,{testID:`latest-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'latest'===l?x.colours.gold:x.colours.border},children:[(0,j.jsx)(a.Muted,{children:"Latest"}),(0,j.jsx)(a.T,{weight:"bold",children:(0,u.money)(w.latest)})]}),(0,j.jsxs)(r.default,{testID:`avg-${e.id}`,style:{paddingHorizontal:10,paddingVertical:6,borderRadius:10,backgroundColor:x.colours.surface2,borderWidth:1,borderColor:'average'===l?x.colours.gold:x.colours.border},children:[(0,j.jsxs)(a.Muted,{children:["Average (",w.count,")"]}),(0,j.jsx)(a.T,{weight:"bold",colour:x.colours.gold,children:(0,u.money)(w.avg)})]}),w.count>1?(0,j.jsxs)(r.default,{style:{paddingHorizontal:10,paddingVertical:6},children:[(0,j.jsx)(a.Muted,{children:"Range"}),(0,j.jsxs)(a.T,{size:14,children:[(0,u.money)(w.min),"\u2013",(0,u.money)(w.max)]})]}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"\xa3"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:`Price paid for ${e.name}`,value:g,onChangeText:h,placeholder:"price paid",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[a.styles.input,L,{width:110}]}),(0,j.jsx)(a.Button,{small:!0,label:"Add price paid",testID:`add-price-${e.id}`,disabled:!I,onPress:()=>{d.useGpCalc.getState().addPricePaid(e.id,I),h(''),o(`Recorded ${(0,u.money)(I)} for ${e.name}. Dishes re-costed.`)}})]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,j.jsx)(t.TextInput,{accessibilityLabel:`Waste % for ${e.name}`,value:c,onChangeText:p,keyboardType:"decimal-pad",style:[a.styles.input,L,{width:60}]}),(0,j.jsx)(a.T,{style:{alignSelf:'center'},children:"% waste"}),C?(0,j.jsx)(a.Button,{small:!0,label:"Save",disabled:null==v(c),onPress:()=>{d.useGpCalc.getState().saveIngredient({...e,wastePct:Math.min(90,v(c))}),o(`Saved ${e.name}. Dishes updated.`)}}):null]}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"secondary",testID:`ing-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit ${e.name}`,onPress:()=>y(!0)}),b?null:(0,j.jsx)(a.Button,{small:!0,kind:"ghost",testID:`ing-delete-${e.id}`,label:"Delete",accessibilityLabel:`Delete ${e.name}`,onPress:()=>f(!0)})]}),b?(0,j.jsxs)(r.default,{testID:`ing-delete-confirm-${e.id}`,style:{gap:6,alignItems:'center'},children:[(0,j.jsxs)(a.T,{center:!0,colour:x.colours.amber,children:["Delete ",e.name," from the price list?",s?` ${s} ${1===s?'dish or card uses':'dishes or cards use'} it and will show it as removed.`:'']}),(0,j.jsxs)(a.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(a.Button,{small:!0,kind:"danger",testID:`ing-delete-yes-${e.id}`,label:"Yes, delete",accessibilityLabel:`Yes, delete ${e.name}`,onPress:()=>{d.useGpCalc.getState().removeIngredient(e.id),o(`Deleted ${e.name}.`)}}),(0,j.jsx)(a.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>f(!1)})]})]}):null]})}function V(){const{settings:e,setSettings:s}=(0,d.useGpCalcView)(),[n,l]=(0,i.useState)(String(e.vatPct)),[r,o]=(0,i.useState)(String(e.defaultTarget));return(0,j.jsxs)(y.Box,{testID:"calc-settings",children:[(0,j.jsx)(a.T,{size:18,weight:"semibold",children:"VAT and rounding"}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"VAT rate %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"VAT rate %",value:n,onChangeText:e=>{l(e);const t=v(e);null!=t&&t<=50&&s({vatPct:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(G,{}),(0,j.jsx)(a.Toggle,{label:"Round suggested prices up to .50 / .95",value:e.pricePoints,onChange:e=>s({pricePoints:e})}),(0,j.jsxs)(a.Row,{gap:8,children:[(0,j.jsx)(a.T,{style:{flex:1},children:"Default target GP %"}),(0,j.jsx)(t.TextInput,{accessibilityLabel:"Default target GP %",value:r,onChangeText:e=>{o(e);const t=v(e);null!=t&&t<95&&s({defaultTarget:t})},keyboardType:"decimal-pad",style:[a.styles.input,{width:80}]})]}),(0,j.jsx)(a.T,{weight:"medium",children:"Cost multiple (x) is based on"}),(0,j.jsxs)(a.Row,{gap:6,children:[(0,j.jsx)(a.Chip,{label:"Inc VAT (menu price)",selected:'inc'===e.multipleBasis,onPress:()=>s({multipleBasis:'inc'})}),(0,j.jsx)(a.Chip,{label:"Ex VAT",selected:'ex'===e.multipleBasis,onPress:()=>s({multipleBasis:'ex'})})]}),(0,j.jsx)(a.Muted,{children:"GP % uses the ex-VAT price. The price multiple is the menu price divided by ingredient cost."})]})}const W='#3A2F1E';function N({label:e,value:t,colour:s=x.colours.text,testID:i,sub:n,said:l}){return(0,j.jsxs)(r.default,{testID:i,accessible:!0,accessibilityLabel:l??`${e}, ${t}${n?`, ${n}`:''}`,style:{flexGrow:1,flexBasis:128,minWidth:0,padding:10,borderRadius:14,backgroundColor:x.colours.surface,borderWidth:1,borderColor:x.colours.accentBorder,alignItems:'center',gap:2},children:[(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:e}),(0,j.jsx)(a.T,{size:28,weight:"bold",center:!0,colour:s,children:t}),n?(0,j.jsx)(a.T,{size:x.font.small,center:!0,colour:x.colours.muted,children:n}):null]})}},1178,[827,796,34,336,236,402,102,794,831,990,861,991,994,891,1004,882,821,930,992,25]); +__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])},1179,[858]); +__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1180,[928,828,827,837,5,34,1056,336,402,102,794,891,858,821,1088,1025,925,1047,1046,987,1113,1098,25]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1181,[828,34,102,794,876,831,869,821,925,25]); +__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1182,[928,828,34,395,236,402,102,925,794,926,891,1183,927,831,5,1184,987,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1183,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1184,[933,976,987,977]); +__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1185,[34,402,102,794,891,989,1098,994,987,1091,858,1125,821,25]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1186,[1173,984,34,379,102,794,891,994,867,821,1088,1165,1033,1187,25]); +__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1187,[827,835,984,34,379,236,402,102,794,1031,983,985,867,1032,821,1165,25]); +__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1188,[984,872,34,986,1189,336,402,102,1190,794,985,983,1031,821,874,1101,858,1125,987,25]); +__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1189,[5,822,823,828,236,826]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1190,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1191,[827,1031,1173,984,34,402,102,794,891,867,821,1165,1033,25]); +__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,"dayKey",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"dayName",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"daySaid",{enumerable:!0,get:function(){return w}}),_e.parseDay=T,Object.defineProperty(_e,"whenSaid",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"ukDay",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"qtyText",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"packSaid",{enumerable:!0,get:function(){return S}}),_e.LField=L,_e.RemoveBtn=R,_e.KitchenCosts=function({rid:e,me:t,actor:s,initial:o="deliveries"}){const a=(0,b.useOwnCosting)(),[m,f]=(0,n.useState)(o),j=(0,r.useGpCalcView)(),k=(0,c.useRecipeCards)(e),$=(0,n.useMemo)(()=>Object.values(j.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],[j.counts]),[w]=(0,n.useState)(()=>v(new Date(Date.now()-5184e5))),T=Object.values(j.deliveries??{}).filter(e=>e.date>=w).reduce((e,t)=>e+(0,u.deliveryTotal)(t),0),C=(0,n.useMemo)(()=>k.map(e=>(0,d.cardCostSummary)(j.cardCosts?.[e.id],j.ingredients,j.settings,e.price)).filter(e=>null!=e.gp),[k,j.cardCosts,j.ingredients,j.settings]),D=C.filter(e=>'ok'!==e.tone).length;return a?(0,x.jsxs)(l.default,{style:{gap:12},testID:"kitchen-costs",children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(z,{testID:"kc-stock-value",label:"Stock value (last count)",value:$?(0,d.money)((0,u.countValue)($)):'\u2014',sub:$?`${I($.date)} \xb7 ${$.by}`:'No count yet',onPress:()=>f('count')}),(0,x.jsx)(z,{testID:"kc-spent",label:"Deliveries, last 7 days",value:(0,d.money)(T),sub:"ex VAT",onPress:()=>f('deliveries')}),(0,x.jsx)(z,{testID:"kc-below",label:"Dishes under target GP",value:C.length?String(D):'\u2014',sub:C.length?`of ${C.length} costed`:'None costed yet',colour:D?p.colours.amber:p.colours.ok,onPress:()=>f('dishgp')})]}),(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(h.Tabs,{value:m,onChange:f,options:[{id:'deliveries',label:'Deliveries'},{id:'count',label:'Stock count'},{id:'prices',label:'Prices'},{id:'dishgp',label:'Dish GP'},{id:'gptrend',label:'GP over time'}]})}),'deliveries'===m?(0,x.jsx)(H,{me:t,rid:e}):null,'count'===m?(0,x.jsx)(_,{me:t}):null,'prices'===m?(0,x.jsx)(b.Items,{}):null,'dishgp'===m?(0,x.jsx)(J,{cards:k,actor:s}):null,'gptrend'===m?(0,x.jsx)(y.GpOverTime,{rid:e}):null,(0,x.jsx)(i.Muted,{center:!0,children:"Shared between the Head Chef and Managers apps. Only the Head Chef, owners and managers see prices and costs."})]}):(0,x.jsx)(l.default,{testID:"kitchen-costs-no-access",style:{alignItems:'center',paddingVertical:16},children:(0,x.jsx)(i.Muted,{center:!0,children:"Deliveries, stock counts, prices and GP are for the Head Chef, owners and managers."})})},Object.defineProperty(_e,"blankLine",{enumerable:!0,get:function(){return N}}),Object.defineProperty(_e,"nextLineKey",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"toLine",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"lineOk",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"lineBlank",{enumerable:!0,get:function(){return M}}),_e.DayPicker=E,_e.ExactCount=q,_e.useKitchenSummary=function(e){const t=(0,r.useGpCalcView)(),s=(0,c.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=Object.values(t.counts??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''))[0],n=s.map(e=>(0,d.cardCostSummary)(t.cardCosts?.[e.id],t.ingredients,t.settings,e.price)).filter(e=>null!=e.gp);return{stockValue:e?(0,u.countValue)(e):null,lastCount:e?I(e.date):null,costed:n.length,below:n.filter(e=>'ok'!==e.tone).length,target:t.settings.defaultTarget,avgGp:n.length?n.reduce((e,t)=>e+(t.gp??0),0)/n.length:null,prices:t.ingredients.length}},[t.counts,t.cardCosts,t.ingredients,t.settings,s])};var t=_r(_d[0]),n=_r(_d[1]),s=e(_r(_d[2])),l=e(_r(_d[3])),i=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),a=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),y=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]);const f={ok:p.colours.ok,amber:p.colours.amber,red:p.colours.red};let j=0;const k=e=>(0,a.uuidFrom)(`${e}:${Date.now()}:${Math.random()}:${j++}`),$=e=>String(e).padStart(2,'0'),v=(e=new Date)=>`${e.getFullYear()}-${$(e.getMonth()+1)}-${$(e.getDate())}`,I=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})},w=e=>{const[t,n,s]=e.split('-').map(Number);return new Date(t,n-1,s).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})};function T(e){const t=e.trim().match(/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{2}|\d{4})$/);if(!t)return null;const n=Number(t[1]),s=Number(t[2]),l=2===t[3].length?2e3+Number(t[3]):Number(t[3]),i=new Date(l,s-1,n);return i.getFullYear()!==l||i.getMonth()!==s-1||i.getDate()!==n?null:`${l}-${$(s)}-${$(n)}`}const C=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?'':`${$(t.getDate())}/${$(t.getMonth()+1)}/${t.getFullYear()} at ${$(t.getHours())}:${$(t.getMinutes())}`},D=e=>{const[t,n,s]=e.split('-');return`${s}/${n}/${t}`},P=e=>Number.isInteger(e)?String(e):String(Math.round(1e3*e)/1e3),S=(e,t)=>`${P(e)} ${(0,d.unitName)(t,e)}`;function z({label:e,value:t,sub:n,colour:l=p.colours.gold,testID:o,onPress:r}){return(0,x.jsxs)(s.default,{testID:o,disabled:!r,accessibilityRole:r?'button':void 0,accessibilityLabel:`${e}, ${t}${n?`, ${n}`:''}`,onPress:r,style:({pressed:e})=>({flexGrow:1,flexBasis:150,minWidth:0,padding:12,borderRadius:14,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(i.T,{size:26,weight:"bold",center:!0,colour:l,children:t}),n?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:n}):null]})}function L({label:e,value:n,onChange:s,placeholder:o,testID:r,keyboard:c,width:a,said:d}){return(0,x.jsxs)(l.default,{style:{gap:4,alignItems:'center',width:a??'100%',maxWidth:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:e}),(0,x.jsx)(t.TextInput,{testID:r,accessibilityLabel:d??e,value:n,onChangeText:s,placeholder:o,placeholderTextColor:"#7D776C",keyboardType:c??'default',style:[i.styles.input,b.TALL,{width:'100%',textAlign:'center',fontSize:18}]})]})}function R({onPress:e,said:t,testID:n,label:l="Remove"}){return(0,x.jsxs)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:t,onPress:e,style:({pressed:e})=>({minHeight:48,paddingHorizontal:14,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:e?p.colours.goldTint:'transparent',flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8}),children:[(0,x.jsx)(o.GoldX,{size:14}),(0,x.jsx)(i.T,{size:p.font.small,colour:p.colours.gold,children:l})]})}let G=0;const N=()=>({k:G++,ingId:'',name:'',packs:'1',size:'',unit:'kg',price:'',count:'',countName:''}),A=()=>G++,B=e=>({k:G++,ingId:e.ingId,name:e.name,packs:P(e.packs),size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2),count:e.count?P(e.count):'',countName:e.countName??'',...e.read?{read:e.read}:{}}),V=e=>{const t=(0,b.numIn)(e.count);return{ingId:e.ingId,name:e.name.trim(),packs:(0,b.numIn)(e.packs),packSize:(0,b.numIn)(e.size),packUnit:e.unit,packPrice:(0,b.pounds)(e.price),...t&&t>0?{count:t,countName:e.countName.trim().toLowerCase()||'pieces'}:{},...e.read?{read:e.read}:{}}},O=e=>!!e.name.trim()&&((0,b.numIn)(e.packs)??0)>0&&((0,b.numIn)(e.size)??0)>0&&null!=(0,b.pounds)(e.price),M=e=>!e.name.trim()&&!e.size.trim()&&!e.price.trim();function H({me:e,rid:t}){const[s,o]=(0,n.useState)(!1),{deliveries:c}=(0,r.useGpCalcView)(),[a,d]=(0,n.useState)(null),[u,y]=(0,n.useState)(null),[b,f]=(0,n.useState)(''),j=Object.values(c??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return s?(0,x.jsx)(m.ScanDelivery,{me:e,rid:t,onDone:e=>{o(!1),e&&f(e)}}):a?(0,x.jsx)(W,{me:e,rid:t,edit:'new'===a?void 0:a,onDone:e=>{d(null),e&&f(e)}}):(0,x.jsxs)(h.Box,{testID:"deliveries",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Deliveries in"}),(0,x.jsx)(i.Muted,{center:!0,children:"Scan the delivery note, or type it in. Every line updates that item\u2019s cost, and every recipe card\u2019s GP re-calculates."}),(0,x.jsx)(i.Button,{testID:"delivery-scan",label:"Scan delivery",sub:"Photo of the delivery note",accessibilityLabel:"Scan delivery. Take a photo of the delivery note and check each line before it goes into stock",onPress:()=>{f(''),o(!0)},style:{minHeight:64}}),(0,x.jsx)(i.Button,{testID:"delivery-new",kind:"secondary",label:"Type a delivery",accessibilityLabel:"Type a delivery in by hand",onPress:()=>{f(''),d('new')},style:{minHeight:56}}),b?(0,x.jsx)(l.default,{testID:"delivery-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:b})}):null,j.length?null:(0,x.jsx)(l.default,{testID:"deliveries-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No deliveries recorded yet."})}),j.map(e=>(0,x.jsx)(U,{d:e,open:u===e.id,onToggle:()=>y(u===e.id?null:e.id),onEdit:()=>d(e),onDeleted:e=>{y(null),f(e)}},e.id))]})}function U({d:e,open:t,onToggle:o,onEdit:c,onDeleted:a}){const[h,m]=(0,n.useState)(!1),y=(0,u.deliveryTotal)(e);return(0,x.jsxs)(l.default,{testID:`delivery-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:t},accessibilityLabel:`Delivery ${w(e.date)}, ${e.supplier||'supplier not given'}, ${e.lines.length} line${1===e.lines.length?'':'s'}, ${(0,d.money)(y)}. ${t?'Tap to close':'Tap to see the lines'}`,onPress:o,style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[e.supplier||'Supplier not given',e.ref?` \xb7 ${e.ref}`:'']}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(y)," \xb7 ",e.lines.length," line",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:['scan'===e.source?`Scanned by ${e.by}${e.photos?.length?` \xb7 ${e.photos.length} photo${1===e.photos.length?'':'s'} kept`:''}`:`Entered by ${e.by}`," \xb7 ",C(e.createdAt)]})]}),t?(0,x.jsxs)(l.default,{style:{gap:6},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${P(e.packs)} at ${(0,d.money)(e.packPrice)} for ${S(e.packSize,e.packUnit)}, ${(0,d.money)((0,u.lineTotal)(e))}${e.count?`. Exact count ${P(e.count)} ${e.countName||'pieces'}`:''}`,style:{alignItems:'center',paddingVertical:4},children:[(0,x.jsx)(i.T,{weight:"medium",center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[P(e.packs)," \xd7 ",(0,d.money)(e.packPrice)," (",S(e.packSize,e.packUnit),") = ",(0,d.money)((0,u.lineTotal)(e))]}),e.count?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["Exact count ",P(e.count)," ",e.countName||'pieces'," \xb7 ",(0,d.money)(e.packPrice*e.packs/e.count)," per ",(0,u.pieceName)(e)]}):null]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`delivery-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the delivery of ${w(e.date)}`,onPress:c}),h?null:(0,x.jsx)(R,{testID:`delivery-delete-${e.id}`,label:'scan'===e.source?'Undo goods in':'Remove',said:`${'scan'===e.source?'Undo the goods in':'Delete the delivery'} of ${w(e.date)}`,onPress:()=>m(!0)})]}),h?(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:'scan'===e.source?'Undo this goods in? Its prices and exact counts come off the price list, and recipe GP goes back. The photo is kept.':'Delete this delivery? Its prices come off the price list too.'}),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"danger",testID:`delivery-delete-yes-${e.id}`,label:"Yes, delete",onPress:()=>{r.useGpCalc.getState().removeDelivery(e.id),a(`Deleted the delivery of ${I(e.date)}.`)}}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Keep it",onPress:()=>m(!1)})]})]}):null]}):null]})}function E({value:e,onChange:s,label:o}){const[r,c]=(0,n.useState)(D(e)),[{today:a,yday:d}]=(0,n.useState)(()=>({today:v(),yday:v(new Date(Date.now()-864e5))})),u=!T(r);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center',width:'100%'},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:o}),(0,x.jsxs)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,x.jsx)(b.Pick,{testID:"day-today",label:"Today",selected:e===a,onPress:()=>{s(a),c(D(a))}}),(0,x.jsx)(b.Pick,{testID:"day-yesterday",label:"Yesterday",selected:e===d,onPress:()=>{s(d),c(D(d))}}),(0,x.jsx)(t.TextInput,{testID:"day-text",accessibilityLabel:`${o}, day, month, year`,value:r,onChangeText:e=>{c(e);const t=T(e);t&&s(t)},placeholder:"dd/mm/yyyy",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[i.styles.input,b.TALL,{width:150,textAlign:'center',fontSize:18}]})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:p.colours.goldLight,children:u?'Type the date as day/month/year':w(e)})]})}function W({me:e,edit:t,onDone:s,rid:o}){const{ingredients:a,deliveries:m}=(0,r.useGpCalcView)(),y=(0,c.useRecipeCards)(o),[f,j]=(0,n.useState)(t?.date??v()),[$,w]=(0,n.useState)(t?.supplier??''),[C,P]=(0,n.useState)(t?.ref??''),[S,z]=(0,n.useState)(t?t.lines.map(B):[N()]),[R,G]=(0,n.useState)(''),A=[...new Set(Object.values(m??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6),H=(e,t)=>z(n=>n.map(n=>n.k===e?{...n,...t}:n)),U=S.filter(e=>!M(e)),W=U.filter(O).reduce((e,t)=>e+(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}),0);return(0,x.jsxs)(h.Box,{testID:"delivery-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:t?'Edit delivery':'Record a delivery'}),(0,x.jsx)(E,{label:"Delivery date",value:f,onChange:j}),(0,x.jsx)(L,{testID:"delivery-supplier",label:"Supplier",value:$,onChange:w,placeholder:"Supplier name"}),A.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:A.map(e=>(0,x.jsx)(b.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:$.trim()===e,onPress:()=>w(e)},e))}):null,(0,x.jsx)(L,{testID:"delivery-ref",label:"Invoice or note number (optional)",value:C,onChange:P,placeholder:"e.g. 10452"}),(0,x.jsx)(i.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"Items"}),(0,x.jsx)(i.Muted,{center:!0,children:"Price per pack before VAT, as on the invoice. For example 2 packs of 5 kg at \xa340.00."}),S.map((e,t)=>(0,x.jsx)(F,{n:t+1,l:e,ingredients:a,onChange:t=>H(e.k,t),onRemove:S.length>1?()=>z(t=>t.filter(t=>t.k!==e.k)):void 0},e.k)),(0,x.jsx)(i.Button,{testID:"delivery-add-line",kind:"secondary",label:"Add another item",onPress:()=>z(e=>[...e,N()]),style:{minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(W)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,x.jsx)(i.T,{testID:"delivery-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(W)})]}),R?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:R})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"delivery-save",label:t?'Save changes':'Save delivery',onPress:()=>{if(!T(D(f)))return void G('Check the date.');if(!U.length)return void G('Add at least one item.');const n=U.filter(e=>!O(e));if(n.length)return void G(`${n.length} line${1===n.length?' needs':'s need'} an item, how many, the pack size and the price.`);const l={id:t?.id??k('del'),date:f,supplier:$.trim(),...C.trim()?{ref:C.trim()}:{},by:t?.by??e,createdAt:t?.createdAt??(new Date).toISOString(),...t?.source?{source:t.source}:{},...t?.photos?{photos:t.photos}:{},...t?.reader?{reader:t.reader}:{},lines:U.map(V)},i=new Set(r.useGpCalc.getState().ingredients.map(e=>e.id)),o=r.useGpCalc.getState().saveDelivery(l,y.map(e=>({id:e.id,dish:e.dish,price:e.price}))),c=o.lines.filter(e=>!i.has(e.ingId)).length;s(`Saved the delivery of ${I(f)}: ${o.lines.length} price${1===o.lines.length?'':'s'} updated${c?`, ${c} new item${1===c?'':'s'} added to the price list`:''}. Recipe cards re-costed.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>s(),style:{minHeight:56}})]})]})}function F({n:e,l:t,ingredients:n,onChange:s,onRemove:o}){const r=n.find(e=>e.id===t.ingId),c=t.name.trim().toLowerCase(),a=!r&&c.length>=2?n.filter(e=>e.name.toLowerCase().includes(c)||(0,u.matchIngredient)(t.name,[e])).slice(0,4):[],h=e=>s({ingId:e.id,name:e.name,size:P(e.packSize),unit:e.packUnit,price:(e.packPrice/100).toFixed(2)}),m=O(t),y=m?(0,u.lineTotal)({packs:(0,b.numIn)(t.packs),packPrice:(0,b.pounds)(t.price)}):0;return(0,x.jsxs)(l.default,{testID:`delivery-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:1,borderColor:m?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2},children:[(0,x.jsxs)(i.T,{weight:"semibold",center:!0,colour:p.colours.goldLight,children:["Item ",e]}),(0,x.jsx)(L,{testID:`dl-name-${e}`,label:"Item",said:`Item ${e}, name`,value:t.name,onChange:e=>s({name:e,ingId:r&&e.trim()===r.name?t.ingId:''}),placeholder:"e.g. Haddock fillet"}),r?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:["On the price list: last paid ",(0,d.money)(r.packPrice)," for ",S(r.packSize,r.packUnit)]}):a.length?(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:a.map(t=>(0,x.jsx)(b.Pick,{testID:`dl-pick-${e}-${t.id}`,label:t.name,accessibilityLabel:`Use ${t.name} from the price list, last paid ${(0,d.money)(t.packPrice)} for ${S(t.packSize,t.packUnit)}`,onPress:()=>h(t)},t.id))}):t.name.trim().length>=2?(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"New item: it will be added to the price list."}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-packs-${e}`,label:"How many",said:`Item ${e}, how many packs`,value:t.packs,onChange:e=>s({packs:e}),keyboard:"decimal-pad",width:110}),(0,x.jsx)(L,{testID:`dl-size-${e}`,label:"Pack size",said:`Item ${e}, pack size`,value:t.size,onChange:e=>s({size:e}),keyboard:"decimal-pad",placeholder:"e.g. 5",width:110}),(0,x.jsx)(L,{testID:`dl-price-${e}`,label:"\xa3 per pack",said:`Item ${e}, price per pack in pounds, before VAT`,value:t.price,onChange:e=>s({price:e}),keyboard:"decimal-pad",placeholder:"0.00",width:120})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Pack size is in"}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(n=>(0,x.jsx)(b.Pick,{testID:`dl-unit-${e}-${n}`,label:(0,d.unitName)(n,2),accessibilityLabel:`Item ${e}, pack size in ${(0,d.unitName)(n,2)}`,selected:t.unit===n,onPress:()=>s({unit:n})},n))}),(0,x.jsx)(q,{n:e,l:t,onChange:s}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:m?`Item ${e} total ${(0,d.money)(y)}`:`Item ${e} not complete yet`,style:{alignItems:'center'},children:(0,x.jsx)(i.T,{weight:"bold",center:!0,colour:m?p.colours.gold:p.colours.muted,children:m?`Line total ${(0,d.money)(y)}`:'Fill in item, how many, size and price'})}),o?(0,x.jsx)(l.default,{style:{alignItems:'center'},children:(0,x.jsx)(R,{testID:`dl-remove-${e}`,said:`Remove item ${e}${t.name.trim()?`, ${t.name.trim()}`:''}`,onPress:o})}):null]})}function q({n:e,l:t,onChange:n,word:s="Item"}){const o=(0,b.numIn)(t.count),r=(0,b.numIn)(t.packs)??0,c=(0,b.pounds)(t.price),a=o&&o>0&&null!=c&&r>0?c*r/o:null,u=!(!t.count.trim()||o&&o>0);return(0,x.jsxs)(l.default,{style:{gap:6,alignItems:'center'},children:[(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(L,{testID:`dl-count-${e}`,label:"Exact count (optional)",said:`${s} ${e}, Exact count`,value:t.count,onChange:e=>n({count:e}),keyboard:"number-pad",placeholder:"e.g. 18",width:150}),(0,x.jsx)(L,{testID:`dl-countname-${e}`,label:"Pieces are",said:`${s} ${e}, what each piece is called, for example fillets`,value:t.countName,onChange:e=>n({countName:e}),placeholder:"fillets",width:150})]}),(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:u?p.colours.amber:null!=a?p.colours.goldLight:p.colours.muted,children:u?'Type the count as a whole number':null!=a?`${(0,d.money)(a)} per ${t.countName.trim()?t.countName.trim().toLowerCase().replace(/s$/,''):'piece'}`:'Leave blank if it\u2019s by weight only'})]})}function _({me:e}){const{counts:t}=(0,r.useGpCalcView)(),[o,c]=(0,n.useState)(null),[a,m]=(0,n.useState)(null),[y,b]=(0,n.useState)(''),f=Object.values(t??{}).sort((e,t)=>t.date.localeCompare(e.date)||(t.createdAt??'').localeCompare(e.createdAt??''));return o?(0,x.jsx)(X,{me:e,edit:'new'===o?void 0:o,last:f[0],onDone:e=>{c(null),e&&b(e)}}):(0,x.jsxs)(h.Box,{testID:"counts",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.Muted,{center:!0,children:"Count what is on the shelves. It shows the stock value at what you last paid."}),(0,x.jsx)(i.Button,{testID:"count-new",label:"Start a stock count",onPress:()=>{b(''),c('new')},style:{minHeight:56}}),y?(0,x.jsx)(l.default,{testID:"count-msg",accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:y})}):null,f.length?null:(0,x.jsx)(l.default,{testID:"counts-empty",style:{alignItems:'center',paddingVertical:10},children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No stock counts yet."})}),f.map(e=>{const t=(0,u.countValue)(e),n=a===e.id;return(0,x.jsxs)(l.default,{testID:`count-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:6},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:n},accessibilityLabel:`Stock count ${w(e.date)} by ${e.by}, ${e.lines.length} items, value ${(0,d.money)(t)}`,onPress:()=>m(n?null:e.id),style:({pressed:e})=>({minHeight:56,padding:10,borderRadius:12,backgroundColor:e?p.colours.goldTint:'transparent',alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:18,center:!0,children:I(e.date)}),(0,x.jsxs)(i.T,{center:!0,weight:"bold",colour:p.colours.gold,children:[(0,d.money)(t)," \xb7 ",e.lines.length," item",1===e.lines.length?'':'s']}),(0,x.jsxs)(i.Muted,{center:!0,children:["Counted by ",e.by]})]}),n?(0,x.jsxs)(l.default,{style:{gap:4},children:[e.lines.map((e,t)=>(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${e.name}, ${Y(e)}, ${(0,d.money)((0,u.countLineValue)(e))}`,style:{alignItems:'center',paddingVertical:3},children:[(0,x.jsx)(i.T,{center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[Y(e)," \xb7 ",(0,d.money)((0,u.countLineValue)(e))]})]},t)),(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:`count-edit-${e.id}`,label:"Edit",accessibilityLabel:`Edit the stock count of ${w(e.date)}`,onPress:()=>c(e)}),(0,x.jsx)(R,{testID:`count-delete-${e.id}`,said:`Delete the stock count of ${w(e.date)}`,onPress:()=>{r.useGpCalc.getState().removeCount(e.id),m(null),b(`Deleted the stock count of ${I(e.date)}.`)}})]})]}):null]},e.id)})]})}const K=(e,t,n)=>'pack'===e?`${1===t?'pack':'packs'} of ${S(n.packSize,n.packUnit)}`:'serving'===e?(0,d.servingWord)(n,t):(0,d.unitName)(e,t),Y=e=>`${P(e.qty)} ${K(e.unit,e.qty,e)}`;function X({me:e,edit:s,last:o,onDone:c}){const{ingredients:a}=(0,r.useGpCalcView)(),[m,y]=(0,n.useState)(s?.date??v()),[f,j]=(0,n.useState)(s?.by??e),[$,w]=(0,n.useState)(''),[T,C]=(0,n.useState)(()=>Object.fromEntries((s?.lines??[]).map(e=>[e.ingId,{qty:P(e.qty),unit:e.unit}]))),[D,z]=(0,n.useState)(''),R=a.slice().sort((e,t)=>e.name.localeCompare(t.name)),G=R.filter(e=>!$.trim()||e.name.toLowerCase().includes($.trim().toLowerCase())),N=e=>{const t=T[e.id],n=t?(0,b.numIn)(t.qty):null;return null==n?null:{ingId:e.id,name:e.name,qty:n,unit:t.unit,packPrice:e.packPrice,packSize:e.packSize,packUnit:e.packUnit,...e.servings?{servings:e.servings}:{}}},A=R.map(N).filter(e=>!!e),B=A.reduce((e,t)=>e+(0,u.countLineValue)(t),0);return a.length?(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:s?'Edit stock count':'Stock count'}),(0,x.jsx)(E,{label:"Count date",value:m,onChange:y}),(0,x.jsx)(L,{testID:"count-by",label:"Counted by",value:f,onChange:j}),(0,x.jsx)(L,{testID:"count-search",label:"Find an item",value:$,onChange:w,placeholder:"Search"}),G.map(e=>{const n=T[e.id]??{qty:'',unit:'pack'},r=N(e),c=r?(0,u.countPacks)(r):null,a=o?.lines.find(t=>t.ingId===e.id);return(0,x.jsxs)(l.default,{testID:`count-item-${e.id}`,style:{gap:6,padding:10,borderRadius:14,borderWidth:1,borderColor:r?p.colours.accentBorder:p.colours.border,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.name}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[(0,d.money)(e.packPrice)," for ",S(e.packSize,e.packUnit),a&&!s?` \xb7 last count ${Y(a)}`:'']}),(0,x.jsx)(t.TextInput,{testID:`count-qty-${e.id}`,accessibilityLabel:`${e.name}, how many ${K(n.unit,2,{...e})}`,value:n.qty,onChangeText:t=>C(s=>({...s,[e.id]:{...n,qty:t}})),placeholder:"count",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[i.styles.input,b.TALL,{width:140,textAlign:'center',fontSize:20}]}),(0,x.jsx)(i.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:(0,u.countUnitsFor)(e).map(t=>(0,x.jsx)(b.Pick,{testID:`count-unit-${e.id}-${t}`,label:'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2),accessibilityLabel:`Count ${e.name} in ${'pack'===t?'packs':'serving'===t?(0,d.servingWord)(e,2):(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>C(s=>({...s,[e.id]:{...n,unit:t}}))},t))}),r?(0,x.jsx)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:null==c?p.colours.amber:p.colours.gold,children:null==c?'That unit does not fit this item':`${(0,d.money)((0,u.countLineValue)(r))} at cost`}):null]},e.id)}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Stock value so far ${(0,d.money)(B)}, ${A.length} of ${R.length} items counted`,style:{alignItems:'center',paddingVertical:6},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Stock value so far"}),(0,x.jsx)(i.T,{testID:"count-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(B)}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:[A.length," of ",R.length," items counted"]})]}),D?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.amber,children:D})}):null,(0,x.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(i.Button,{testID:"count-save",label:s?'Save changes':'Save stock count',onPress:()=>{if(!A.length)return void z('Enter at least one count.');if(!f.trim())return void z('Say who counted.');const e={id:s?.id??k('count'),date:m,by:f.trim(),lines:A,createdAt:s?.createdAt??(new Date).toISOString()};r.useGpCalc.getState().saveCount(e),c(`Saved the stock count of ${I(m)}: ${A.length} item${1===A.length?'':'s'}, value ${(0,d.money)(B)}.`)},style:{minHeight:56,flexGrow:1}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>c(),style:{minHeight:56}})]})]}):(0,x.jsxs)(h.Box,{testID:"count-form",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Stock count"}),(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"Nothing on the price list yet. Record a delivery or add prices first, then count them here."}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>c()})]})}function J({cards:e,actor:t}){const{ingredients:o,settings:c,cardCosts:a,setSettings:m}=(0,r.useGpCalcView)(),[y,j]=(0,n.useState)(null),[k,$]=(0,n.useState)(''),v=(0,n.useMemo)(()=>e.map(e=>({c:e,s:(0,d.cardCostSummary)(a?.[e.id],o,c,e.price)})).sort((e,t)=>(null==e.s.gp?1:0)-(null==t.s.gp?1:0)||(e.s.gp??0)-(t.s.gp??0)||e.c.dish.localeCompare(t.c.dish)),[e,a,o,c]),I=v.filter(e=>null!=e.s.gp),w=I.filter(e=>'ok'!==e.s.tone).length;return(0,x.jsxs)(h.Box,{testID:"dish-gp",children:[(0,x.jsx)(i.T,{size:20,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Dish GP"}),(0,x.jsxs)(i.Muted,{center:!0,children:["Food cost from the latest prices, against the menu price. Menu prices include ",c.vatPct,"% VAT; GP is worked out on the price without VAT."]}),(0,x.jsxs)(i.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-down",label:"\u2212",accessibilityLabel:`Lower the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.max(40,c.defaultTarget-1)}),style:{minWidth:52,minHeight:52}}),(0,x.jsxs)(l.default,{accessible:!0,accessibilityLabel:`Target GP ${c.defaultTarget} percent`,style:{alignItems:'center',minWidth:120},children:[(0,x.jsx)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Target GP"}),(0,x.jsxs)(i.T,{testID:"target-gp",size:28,weight:"bold",center:!0,colour:p.colours.gold,children:[c.defaultTarget,"%"]})]}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",testID:"target-up",label:"+",accessibilityLabel:`Raise the target GP, now ${c.defaultTarget} percent`,onPress:()=>m({defaultTarget:Math.min(90,c.defaultTarget+1)}),style:{minWidth:52,minHeight:52}})]}),(0,x.jsxs)(i.T,{center:!0,colour:p.colours.goldLight,children:[I.length," of ",v.length," dishes costed \xb7 ",w," under target"]}),o.length?(0,x.jsx)(i.Button,{testID:"gp-link-every",kind:"secondary",label:"Link matching prices on every card",onPress:()=>{const t=r.useGpCalc.getState();let n=0,s=0;for(const l of e){const e=t.cardCosts[l.id]??{lines:[],portions:1},i=new Set(e.lines.map(e=>e.recipeIngId).filter(Boolean)),o=l.ingredients.filter(e=>e.name.trim()&&!i.has(e.id)).map(e=>{const n=(0,u.matchIngredient)(e.name,t.ingredients);return n?{ingId:n.id,...(0,u.suggestAmount)(e.qty,e.unit,n),recipeIngId:e.id}:null}).filter(e=>!!e);o.length&&(t.saveCardCost(l.id,{...e,lines:[...e.lines,...o]}),n+=o.length,s++)}$(n?`Linked ${n} ingredient${1===n?'':'s'} on ${s} card${1===s?'':'s'}. Open a dish to check its amounts.`:'Nothing new to link. Add more prices, or link by hand on each dish.')},style:{minHeight:52}}):(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"The price list is empty. Record a delivery or add prices first."}),k?(0,x.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,x.jsx)(i.T,{center:!0,colour:p.colours.goldLight,children:k})}):null,v.map(({c:e,s:n})=>{const o=y===e.id,r=n.tone?f[n.tone]:p.colours.muted,a=n.price?n.price/(1+c.vatPct/100):null,u=null!=n.gp?`${e.dish}. GP ${(0,d.pct)(n.gp)}, ${'ok'===n.tone?'on target':'amber'===n.tone?'just under target':'below target'}. Food cost ${(0,d.money)(n.perPortion)}, cash GP ${(0,d.money)(n.cashGp)}, menu price ${(0,d.money)(n.price)} including VAT.`:`${e.dish}. Not costed yet${e.price?`. Menu price ${(0,d.money)(e.price)} including VAT`:''}.`;return(0,x.jsxs)(l.default,{testID:`dish-gp-${e.id}`,style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:8,gap:8},children:[(0,x.jsxs)(s.default,{accessibilityRole:"button",accessibilityState:{expanded:o},accessibilityLabel:`${u} ${o?'Tap to close':'Tap to cost it'}`,onPress:()=>j(o?null:e.id),style:({pressed:e})=>({minHeight:64,padding:10,borderRadius:14,borderWidth:1,borderColor:null!=n.gp?r:p.colours.border,backgroundColor:e?p.colours.goldTint:p.colours.surface,alignItems:'center',gap:2}),children:[(0,x.jsx)(i.T,{weight:"semibold",size:17,center:!0,children:e.dish}),null!=n.gp?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(i.T,{size:26,weight:"bold",center:!0,colour:r,children:[(0,d.pct)(n.gp)," GP"]}),(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost ",(0,d.money)(n.perPortion)," \xb7 GP ",(0,d.money)(n.cashGp)," \xb7 ",(0,d.money)(n.price)," inc VAT (",(0,d.money)(a)," ex)"]}),'ok'!==n.tone?(0,x.jsxs)(i.T,{size:p.font.small,center:!0,weight:"semibold",colour:r,children:["Under the ",n.target,"% target",n.suggested?` \xb7 price for target ${(0,d.money)(n.suggested)}`:'']}):null]}):(0,x.jsxs)(i.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Not costed yet",e.price?` \xb7 ${(0,d.money)(e.price)} inc VAT`:'']})]}),o?(0,x.jsx)(b.CardGpPanel,{card:e,actor:t,mode:"edit"}):null]},e.id)}),v.length?null:(0,x.jsx)(i.T,{center:!0,colour:p.colours.muted,children:"No recipe cards yet."})]})}},1192,[827,34,402,102,794,796,990,874,863,991,992,821,930,1193,1197,1178,25]); +__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.linesFromNote=I,_e.ScanDelivery=function({me:e,rid:v,onDone:w,initial:C}){const S=(0,r.useGpCalcView)(),R=(0,c.useRecipeCards)(v),[z,F]=(0,t.useState)(()=>(0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),[N,B]=(0,t.useState)(''),[M,A]=(0,t.useState)(!1),[G,H]=(0,t.useState)([]),O=(0,t.useRef)([]),V=()=>{O.current.forEach(clearTimeout),O.current=[]};(0,t.useEffect)(()=>((0,$.primeAnnouncer)(),V),[]);const _=e=>{B(e),(0,$.announce)(e)},[W,E]=(0,t.useState)(C?.photos??[]),[U,Y]=(0,t.useState)(C?.paths??[]),[q,K]=(0,t.useState)(C?.note?'review':'photos'),[X,Q]=(0,t.useState)(''),[J,Z]=(0,t.useState)(C?.note?.reader??null),[ee,te]=(0,t.useState)(C?.note?.date??(0,y.dayKey)()),[ne,se]=(0,t.useState)(C?.note?.supplier??''),[ie,oe]=(0,t.useState)(C?.note?.ref??''),[le,ae]=(0,t.useState)(()=>C?.note?I(C.note,C.note.supplier??'',S.deliveries??{},S.ingredients):[]),[re,ce]=(0,t.useState)(''),[de,he]=(0,t.useState)(null),ue=async e=>{ce('');const t=await(0,b.pickPhotos)({source:e});t.length&&E(e=>[...e,...t].slice(0,j.DELIVERY_READ_CONFIG.maxPages))},ge=(e,t)=>{const n=e.supplier??'';Z(e.reader),se(n),oe(e.ref??''),e.date&&te(e.date);const s=I(e,n,S.deliveries??{},S.ingredients);ae(s);const i=s.filter(e=>e.flags.length).length,o=`${t}${s.length} line${1===s.length?'':'s'} read from ${n||'the invoice'}.${i?` ${i} need${1===i?'s':''} checking, marked in amber.`:''} Check each one against the invoice before you add it to stock.`;Q(o),K('review'),(0,$.announce)(o)},pe=async()=>{if(!W.length)return ce('Take a photo of the delivery note first.'),void(0,$.announce)('Take a photo of the invoice first.');K('reading'),ce(''),A(!1),V(),_(1===W.length?'Sending the photo\u2026':`Sending ${W.length} photos\u2026`);const e=[];for(let t=0;t_('Still reading the invoice\u2026'),3e4)),O.current.push(setTimeout(()=>_('Still reading. Nearly there\u2026'),6e4)),O.current.push(setTimeout(()=>_('Still reading. A long or faint invoice can take up to 2 minutes.'),95e3)));const t=await(0,x.readDeliveryNote)(e.length===W.length?e:[]);if(V(),B(''),!t.ok)return A(!0),Q(t.message),ae([{...(0,y.blankLine)(),flags:[],how:'typed'}]),K('review'),void(0,$.announce)(`Couldn\u2019t read the invoice. ${t.message}`);const n=(t.note.notes??[]).slice(1).filter(e=>e.lines?.length),s=t=>({ph:(t??[]).map(e=>W[e-1]).filter(Boolean),pa:(t??[]).map(t=>e[t-1]).filter(Boolean)});let i='';if(n.length){const e=[t.note.supplier,...n.map(e=>e.supplier)].map(e=>e||'an unnamed supplier');i=`These photos are ${n.length+1} different invoices: ${e.slice(0,-1).join(', ')} and ${e[e.length-1]}. Showing ${e[0]} first; the others come next. `;const o=s(t.note.pages);o.ph.length&&E(o.ph),o.pa.length&&Y(o.pa),H(n.map(e=>{const n=s(e.pages);return{note:{...e,reader:t.note.reader},photos:n.ph,paths:n.pa}}))}t.note.failedPages?.length&&(i+=`Photo ${t.note.failedPages.join(' and ')} couldn\u2019t be read; type any lines from it. `),ge(t.note,i)},me=()=>{const[e,...t]=G;e&&(H(t),he(null),F((0,g.uuidFrom)(`goodsin:${Date.now()}:${Math.random()}`)),E(e.photos),Y(e.paths),A(!1),ce(''),ge(e.note,`Next invoice${t.length?` (${t.length} more after this)`:''}. `))},fe=(e,t)=>ae(n=>n.map(n=>{if(n.k!==e)return n;const s={...n,...t};if(void 0!==t.name&&void 0===t.ingId){const e=S.ingredients.find(e=>e.id===n.ingId);e&&e.name===t.name||(s.ingId='')}return s})),be=le.filter(e=>!(0,y.lineBlank)(e)),ye=be.filter(y.lineOk),xe=(0,t.useMemo)(()=>({id:z,date:ee,supplier:ne.trim(),...ie.trim()?{ref:ie.trim()}:{},by:e,createdAt:(new Date).toISOString(),source:'scan',...U.length?{photos:U}:{},...J?{reader:J}:{},lines:ye.map(y.toLine)}),[z,ee,ne,ie,e,U,J,ye]),$e=(0,t.useMemo)(()=>R.map(e=>({id:e.id,dish:e.dish,price:e.price})),[R]),je=(0,t.useMemo)(()=>ye.length?(0,h.gpImpact)(S.ingredients,S.cardCosts??{},$e,S.settings,xe):null,[S.ingredients,S.cardCosts,$e,S.settings,xe,ye.length]),ke=xe.lines.reduce((e,t)=>e+(0,u.lineTotal)(t),0),ve=je?.dishes.filter(e=>e.flagged)??[],we=()=>{de&&r.useGpCalc.getState().removeDelivery(de.id),w(`Undone: the goods in of ${de?(0,y.dayName)(de.date):''} came off stock, and recipe GP went back.`)};if('done'===q&&de){const e=de.gp;return(0,k.jsxs)(m.Box,{testID:"scan-done",children:[(0,k.jsxs)(i.default,{accessibilityLiveRegion:"polite",style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:"Added to stock"}),(0,k.jsxs)(o.T,{center:!0,children:[de.lines.length," line",1===de.lines.length?'':'s'," from ",de.supplier||'the supplier',", ",(0,d.money)(ke)," before VAT."]}),e&&null!=e.before&&null!=e.after?(0,k.jsxs)(o.T,{center:!0,colour:e.after1?`, then ${G.length-1} more`:''}`,onPress:me,style:{minHeight:64}}):null,(0,k.jsx)(o.Button,{testID:"scan-done-ok",kind:G.length?'secondary':'primary',label:G.length?'Done, skip the rest':'Done',onPress:()=>w(`Added the delivery of ${(0,y.dayName)(de.date)} to stock: ${de.lines.length} lines. Recipe GP re-calculated.`),style:{minHeight:56}}),(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:"scan-undo",label:"Undo goods in",said:"Undo this goods in. Takes it off stock and puts the old costs back",onPress:we})})]})}if('photos'===q||'reading'===q)return(0,k.jsxs)(m.Box,{testID:"scan-delivery",children:[(0,k.jsx)(T,{title:"Scan delivery",onClose:()=>w()}),(0,k.jsx)(o.Muted,{center:!0,children:"Lay the delivery note flat in good light. Take one photo per page. Grok reads every line, then you check them before anything goes into stock."}),W.length?(0,k.jsxs)(i.default,{style:{gap:8,alignItems:'center'},children:[(0,k.jsx)(i.default,{accessibilityLiveRegion:"polite",children:(0,k.jsxs)(o.T,{center:!0,weight:"semibold",children:[W.length," page",1===W.length?'':'s'," ready"]})}),(0,k.jsx)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:W.map((e,t)=>(0,k.jsxs)(i.default,{style:{alignItems:'center',gap:6},children:[(0,k.jsx)(n.default,{source:{uri:e},accessibilityLabel:`Page ${t+1} of the delivery note`,style:{width:96,height:128,borderRadius:10,borderWidth:1,borderColor:p.colours.accentBorder,backgroundColor:'#fff'},resizeMode:"cover"}),'photos'===q?(0,k.jsx)(s.default,{testID:`scan-photo-remove-${t+1}`,accessibilityRole:"button",accessibilityLabel:`Remove page ${t+1}`,onPress:()=>E(e=>e.filter((e,n)=>n!==t)),style:({pressed:e})=>({width:48,height:48,borderRadius:24,borderWidth:1,borderColor:p.colours.accentBorder,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:16})}):null]},t))})]}):null,'photos'===q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(o.Button,{testID:"scan-camera",label:W.length?'Take the next page':'Take a photo',accessibilityLabel:W.length?'Take a photo of the next page':'Take a photo of the delivery note',onPress:()=>{ue('camera')},style:{minHeight:64}}),(0,k.jsx)(o.Button,{testID:"scan-gallery",kind:"secondary",label:"Choose photos",accessibilityLabel:"Choose photos of the delivery note from the phone",onPress:()=>{ue('gallery')},style:{minHeight:56}}),W.length?(0,k.jsx)(o.Button,{testID:"scan-read",label:"Read "+(1===W.length?'the note':`all ${W.length} pages`),accessibilityLabel:`Read the delivery note, ${W.length} page${1===W.length?'':'s'}`,onPress:()=>{pe()},style:{minHeight:64}}):null]}):(0,k.jsxs)(i.default,{testID:"scan-reading",accessibilityLiveRegion:"polite",style:{alignItems:'center',paddingVertical:12,gap:4},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,colour:p.colours.goldLight,children:N||'Reading the invoice\u2026'}),(0,k.jsx)(o.Muted,{center:!0,children:"Keep this screen open. You\u2019ll hear what was read, or why not."})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null]});const Ie=[...new Set(Object.values(S.deliveries??{}).map(e=>e.supplier.trim()).filter(Boolean))].slice(0,6);return(0,k.jsxs)(m.Box,{testID:"scan-review",children:[(0,k.jsx)(T,{title:'confirm'===q?'Add to stock?':'Check the delivery',onClose:()=>w()}),X?(0,k.jsx)(i.default,{testID:"scan-note",accessibilityLiveRegion:"polite",children:(0,k.jsx)(o.T,{center:!0,colour:M?p.colours.amber:p.colours.goldLight,children:X})}):null,M&&W.length&&'review'===q?(0,k.jsx)(o.Button,{testID:"scan-retry",label:"Try reading again",accessibilityLabel:`Try reading the invoice again, ${W.length} photo${1===W.length?'':'s'}`,onPress:()=>{Q(''),A(!1),pe()},style:{minHeight:64}}):null,'confirm'===q?(0,k.jsx)(L,{n:ye.length,total:ke,flagged:ve.length,onYes:()=>{const e=r.useGpCalc.getState().saveDelivery({...xe,createdAt:(new Date).toISOString()},$e);he(e),K('done')},onNo:()=>K('review')}):null,(0,k.jsx)(y.DayPicker,{label:"Delivery date",value:ee,onChange:te}),(0,k.jsx)(y.LField,{testID:"scan-supplier",label:"Supplier",value:ne,onChange:se,placeholder:"Supplier name"}),Ie.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:Ie.map(e=>(0,k.jsx)(f.Pick,{label:e,accessibilityLabel:`Supplier ${e}`,selected:ne.trim()===e,onPress:()=>se(e)},e))}):null,(0,k.jsx)(y.LField,{testID:"scan-ref",label:"Invoice or note number",value:ie,onChange:oe,placeholder:"e.g. 10452"}),(0,k.jsxs)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:[le.length," line",1===le.length?'':'s']}),le.map((e,t)=>(0,k.jsx)(D,{n:t+1,of:le.length,l:e,ings:S.ingredients,settings:S.settings,onChange:t=>fe(e.k,t),onRemove:()=>ae(t=>t.filter(t=>t.k!==e.k))},e.k)),(0,k.jsx)(o.Button,{testID:"scan-add-line",kind:"secondary",label:"Add a line",accessibilityLabel:"Add a line the reader missed",onPress:()=>ae(e=>[...e,{...(0,y.blankLine)(),flags:[],how:'typed'}]),style:{minHeight:52}}),je?(0,k.jsx)(P,{impact:je}):null,(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Delivery total ${(0,d.money)(ke)} before VAT`,style:{alignItems:'center',paddingVertical:6},children:[(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:"Delivery total (ex VAT)"}),(0,k.jsx)(o.T,{testID:"scan-total",size:30,weight:"bold",center:!0,colour:p.colours.gold,children:(0,d.money)(ke)})]}),re?(0,k.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,k.jsx)(o.T,{center:!0,colour:p.colours.amber,children:re})}):null,'review'===q?(0,k.jsx)(o.Button,{testID:"scan-add-to-stock",label:"Add to stock",sub:"You confirm on the next step",accessibilityLabel:`Add to stock, ${ye.length} lines, ${(0,d.money)(ke)}. You confirm on the next step`,onPress:()=>{if(!be.length)return void ce('There are no lines to add yet.');const e=be.filter(e=>!(0,y.lineOk)(e));e.length?ce(`${e.length} line${1===e.length?' needs':'s need'} an item, how many, the pack size and the price.`):(ce(''),K('confirm'))},style:{minHeight:64}}):null,(0,k.jsxs)(o.Muted,{center:!0,children:["Nothing changes stock or prices until you confirm.",J?` Read by ${J}.`:'']})]})};var t=_r(_d[0]),n=e(_r(_d[1])),s=e(_r(_d[2])),i=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),g=_r(_d[11]),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),$=_r(_d[18]),j=_r(_d[19]),k=_r(_d[20]);const v={kg:'kg',litre:'litre',item:'item'},w=e=>e?.base?`${(0,d.money)(e.base.pence)} per ${v[e.base.per]}${e.piece?`, ${(0,d.money)(e.piece.pence)} per ${e.piece.name}`:''}`:'no cost yet';function I(e,t,n,s){return e.lines.map(e=>{const i=(e.item??e.read).trim(),o=(0,h.matchLine)(e.read,i,t,n,s),l=(0,h.packUnitOf)(e.packUnit),r=(0,h.lineFlags)(e,o.how);return{k:(0,y.nextLineKey)(),ingId:o.ing?.id??'',name:o.ing?.name??i,packs:null!=e.packs?(0,y.qtyText)(e.packs):'',size:null!=e.packSize?(0,y.qtyText)(e.packSize):'',unit:l??'kg',price:null!=e.unitPrice?e.unitPrice.toFixed(2):'',count:e.count?(0,y.qtyText)(e.count):'',countName:e.countName??'',read:e.read,flags:r,how:o.how}})}function T({title:e,onClose:t}){return(0,k.jsxs)(i.default,{style:{alignItems:'center',justifyContent:'center',minHeight:48},children:[(0,k.jsx)(o.T,{size:22,weight:"bold",center:!0,colour:p.colours.gold,accessibilityRole:"header",children:e}),(0,k.jsx)(s.default,{testID:"scan-close",accessibilityRole:"button",accessibilityLabel:"Close without adding to stock",onPress:t,hitSlop:8,style:({pressed:e})=>({position:'absolute',right:0,top:0,width:48,height:48,borderRadius:24,alignItems:'center',justifyContent:'center',backgroundColor:e?p.colours.goldTint:'transparent'}),children:(0,k.jsx)(l.GoldX,{size:20})})]})}function L({n:e,total:t,flagged:n,onYes:s,onNo:l}){return(0,k.jsxs)(i.default,{testID:"scan-confirm",accessibilityLiveRegion:"assertive",style:{gap:8,padding:12,borderRadius:14,borderWidth:2,borderColor:p.colours.gold,backgroundColor:p.colours.surface2,alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:18,weight:"bold",center:!0,children:["Add ",e," line",1===e?'':'s',", ",(0,d.money)(t),", to stock?"]}),(0,k.jsxs)(o.T,{center:!0,colour:p.colours.muted,children:["This updates each item\u2019s cost and every recipe card\u2019s GP.",n?` ${n} dish${1===n?'':'es'} will drop GP noticeably.`:'']}),(0,k.jsx)(o.Button,{testID:"scan-confirm-yes",label:"Yes, add to stock",onPress:s,style:{minHeight:64,alignSelf:'stretch'}}),(0,k.jsx)(o.Button,{testID:"scan-confirm-no",kind:"secondary",label:"Not yet, keep checking",onPress:l,style:{minHeight:56,alignSelf:'stretch'}})]})}const C={remembered:'Matched as last time from this supplier',exact:'On your price list',close:'Similar name on your price list',new:'New item: it will be added to your price list',typed:''};function D({n:e,of:t,l:n,ings:s,settings:l,onChange:r,onRemove:c}){const g=s.find(e=>e.id===n.ingId)??null,m=(0,y.lineOk)(n),b=m?(0,y.toLine)(n):null,x=b?(0,h.lineCostChange)(g,b,l):null,$=n.flags.filter(e=>!(m&&/not read/.test(e))),j=null!=x?.changePct&&x.changePct>.5,v=(0,f.numIn)(n.packs),I=n.size?'each'===n.unit?`${n.size} items`:(0,y.packSaid)((0,f.numIn)(n.size)??0,n.unit):'size not read',T=x?.after?x.before?w(x.before)===w(x.after)?` Cost unchanged at ${w(x.after)}.`:` Cost was ${w(x.before)}, now ${w(x.after)}.`:` New item, cost ${w(x.after)}.`:'',L=`Line ${e} of ${t}. ${n.name||'No item name'}. ${v?`${(0,y.qtyText)(v)} pack${1===v?'':'s'}`:'Quantity not read'} of ${I}, at ${n.price?`\xa3${n.price}`:'price not read'} a pack${b?`, line total ${(0,d.money)((0,u.lineTotal)(b))}`:''}.${n.count?` Exact count ${n.count} ${n.countName||'pieces'}.`:''}${$.length?` Check: ${$.join('. ')}.`:''}${T}`,D=!g&&n.name.trim().length>=2?s.filter(e=>e.name.toLowerCase().includes(n.name.trim().toLowerCase().split(' ')[0]??'')).slice(0,3):[];return(0,k.jsxs)(i.default,{testID:`scan-line-${e}`,style:{gap:8,padding:12,borderRadius:14,borderWidth:$.length?2:1,borderColor:$.length?p.colours.amber:p.colours.accentBorder,backgroundColor:p.colours.surface2},children:[(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:L,style:{alignItems:'center',gap:2},children:[(0,k.jsxs)(o.T,{weight:"bold",center:!0,colour:p.colours.goldLight,children:["Line ",e," of ",t]}),n.read?(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["On the note: \u201c",n.read,"\u201d"]}):null,$.map(e=>(0,k.jsxs)(o.T,{size:p.font.small,center:!0,weight:"semibold",colour:p.colours.amber,children:["\u26a0 ",e]},e)),C[n.how]&&!$.some(e=>e.startsWith('New item')||e.startsWith('Matched to a similar'))?(0,k.jsx)(o.T,{size:p.font.small,center:!0,colour:p.colours.goldLight,children:g?`${C[n.how]}: ${g.name}`:C[n.how]}):null]}),(0,k.jsx)(y.LField,{testID:`scan-name-${e}`,label:"Item",said:`Line ${e}, item name`,value:n.name,onChange:e=>r({name:e}),placeholder:"e.g. Hake fillet"}),D.length?(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:D.map(t=>(0,k.jsx)(f.Pick,{label:`Use ${t.name}`,accessibilityLabel:`Line ${e}: use ${t.name} from your price list instead of a new item`,onPress:()=>r({ingId:t.id,name:t.name})},t.id))}):null,(0,k.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,k.jsx)(y.LField,{testID:`scan-packs-${e}`,label:"How many",said:`Line ${e}, how many packs`,value:n.packs,onChange:e=>r({packs:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-size-${e}`,label:"Pack size",said:`Line ${e}, pack size, weight or volume`,value:n.size,onChange:e=>r({size:e}),keyboard:"decimal-pad",width:100}),(0,k.jsx)(y.LField,{testID:`scan-price-${e}`,label:"\xa3 per pack",said:`Line ${e}, price per pack in pounds, before VAT`,value:n.price,onChange:e=>r({price:e}),keyboard:"decimal-pad",width:110})]}),(0,k.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:d.PACK_UNITS.map(t=>(0,k.jsx)(f.Pick,{testID:`scan-unit-${e}-${t}`,label:(0,d.unitName)(t,2),accessibilityLabel:`Line ${e}, pack size in ${(0,d.unitName)(t,2)}`,selected:n.unit===t,onPress:()=>r({unit:t})},t))}),(0,k.jsx)(y.ExactCount,{word:"Line",n:e,l:n,onChange:r}),x?.after?(0,k.jsxs)(i.default,{testID:`scan-cost-${e}`,accessible:!0,accessibilityLabel:`Line ${e}.${T}`,style:{alignItems:'center',gap:2,paddingVertical:4},children:[(0,k.jsxs)(o.T,{size:p.font.small,center:!0,colour:p.colours.muted,children:["Cost was ",x.before?w(x.before):'new item']}),(0,k.jsxs)(o.T,{center:!0,weight:"bold",colour:j?p.colours.amber:p.colours.gold,children:["Now ",w(x.after),null!=x.changePct&&Math.abs(x.changePct)>=.5?` (${x.changePct>0?'+':''}${x.changePct.toFixed(0)}%)`:'']})]}):null,b?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.gold,children:["Line total ",(0,d.money)((0,u.lineTotal)(b))]}):null,(0,k.jsx)(i.default,{style:{alignItems:'center'},children:(0,k.jsx)(y.RemoveBtn,{testID:`scan-remove-${e}`,said:`Remove line ${e}${n.name?`, ${n.name}`:''}`,onPress:c})})]})}function P({impact:e}){const{snap:t,dishes:n}=e;if(null==t.before||null==t.after)return(0,k.jsx)(o.Muted,{center:!0,children:"No recipe cards are costed yet, so there is no GP to update."});const s=t.aftere.flagged);return(0,k.jsxs)(i.default,{testID:"scan-gp",style:{gap:6,padding:12,borderRadius:14,borderWidth:1,borderColor:s?p.colours.amber:p.colours.accentBorder,alignItems:'center'},children:[(0,k.jsx)(o.T,{size:18,weight:"semibold",center:!0,accessibilityRole:"header",children:"What this does to GP"}),(0,k.jsxs)(i.default,{accessible:!0,accessibilityLabel:`Menu GP ${t.before.toFixed(1)} percent now, ${t.after.toFixed(1)} percent after this delivery`,style:{alignItems:'center'},children:[(0,k.jsxs)(o.T,{size:26,weight:"bold",center:!0,colour:s?p.colours.amber:p.colours.gold,children:[t.before.toFixed(1),"% \u2192 ",t.after.toFixed(1),"%"]}),(0,k.jsx)(o.Muted,{center:!0,children:"Menu GP, average of costed dishes"})]}),l.length?(0,k.jsxs)(o.T,{center:!0,weight:"semibold",colour:p.colours.amber,children:[l.length," dish",1===l.length?'':'es'," drop noticeably"]}):null,n.slice(0,8).map(e=>(0,k.jsxs)(i.default,{testID:`scan-gp-dish-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, GP ${e.before.toFixed(1)} percent to ${e.after.toFixed(1)} percent${e.flagged?", a noticeable drop"+(e.aftersetTimeout(e,900)),{ok:!0,note:i.PITCH_DELIVERY_NOTE};const s=n.useSync.getState();if(!l())return{ok:!1,why:'offline',message:h.offline};if(!o.length)return{ok:!1,why:'failed',message:h.upload};try{const{data:n,error:r}=await(0,t.getSupabase)().functions.invoke(e.DELIVERY_READ_CONFIG.serverFunction,{body:{venueId:s.venueId,paths:o}}),i=r?.context,l=i?.status;if(r){let e=null;try{e=i&&'function'==typeof i.clone?await i.clone().json():null}catch{e=null}return 503===l?{ok:!1,why:'not-set-up',message:h.notSetUp}:401===l||403===l?{ok:!1,why:'not-allowed',message:h.notAllowed}:504===l||'timeout'===e?.why?{ok:!1,why:'failed',message:h.timeout}:'busy'===e?.why||429===l?{ok:!1,why:'failed',message:h.busy}:'key'===e?.why?{ok:!1,why:'failed',message:h.key}:l?{ok:!1,why:'failed',message:h.failed}:{ok:!1,why:'failed',message:/timeout/i.test(`${i?.message??''} ${r?.message??''}`)?h.timeout:h.network}}if(!n||!Array.isArray(n.lines))return{ok:!1,why:'failed',message:h.failed};const u=Array.isArray(n.notes)?n.notes.filter(e=>Array.isArray(e?.lines)&&e.lines.length):[];if(!n.lines.length&&!u.length)return{ok:!1,why:'nothing-read',message:h.nothing};return{ok:!0,note:!n.lines.length&&u.length?{...u[0],reader:n.reader??null,notes:u,failedPages:n.failedPages}:n}}catch(e){return{ok:!1,why:'failed',message:/timeout/i.test(String(e?.message??''))?h.timeout:h.network}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),i=_r(d[5]),s=_r(d[6]);const l=()=>{const e=n.useSync.getState();return!!e.venueId&&('staff'===e.kind||'device'===e.kind&&o.IS_CAR)};async function u(e){try{if('undefined'==typeof document)return e;const t=await(await fetch(e)).blob();return await(0,s.shrink)(t,1280,.72)}catch{return e}}const h={offline:'Not connected to the shared team, so the photo can\u2019t be read. Type the lines from the note.',upload:'The photos didn\u2019t upload. Check the signal and try again, or type the lines.',notSetUp:'Photo reading isn\u2019t switched on yet. Type the lines from the note. Nothing is filled in for you.',notAllowed:'You don\u2019t have the Stock and deliveries tick, so you can\u2019t scan deliveries. Ask an owner to tick it on the Permissions screen.',timeout:'The reader took too long (over 2 minutes) and gave up. Try again, or type the lines.',busy:'The photo reader is busy right now. Wait a minute and try again, or type the lines.',key:'The photo reader\u2019s account isn\u2019t working. Gordon has been told. Type the lines from the note for now.',network:'Lost the connection while reading. Check the signal and try again, or type the lines.',failed:'The reader couldn\u2019t read the photo this time. Try again, or type the lines.',nothing:'No product lines could be found on the photo. Make sure the whole note is in the picture, flat and in focus, and try again, or type the lines.'}},1194,[1195,933,987,872,2,1196,1075]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELIVERY_READ_CONFIG",{enumerable:!0,get:function(){return t}});const t={model:'grok-4.7',serverFunction:'delivery-read',bucket:'delivery-photos',maxPages:8}},1195,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_DELIVERY_NOTE",{enumerable:!0,get:function(){return t}});const t={supplier:'Doonfoot Fish & Fine Foods Ltd',date:'2026-11-14',ref:'DN 10452',reader:'grok-4.7',lines:[{read:'HKF05 Hake fillet, skin on, pin-boned 5kg (18 fillets)',item:'Hake fillet',packs:1,packSize:5,packUnit:'kg',count:18,countName:'fillets',unitPrice:81,lineTotal:81,sure:!0},{read:'SAL02 Scottish salmon side, trimmed approx 1.6kg',item:'Scottish salmon side',packs:2,packSize:1.6,packUnit:'kg',count:null,countName:null,unitPrice:24.8,lineTotal:49.6,sure:!0},{read:'LNG01 Langoustine, whole, West Coast 3kg',item:'Langoustines, whole',packs:1,packSize:3,packUnit:'kg',count:null,countName:null,unitPrice:66,lineTotal:66,sure:!0},{read:'MUS10 Rope-grown mussels 5kg bag',item:'Mussels',packs:2,packSize:5,packUnit:'kg',count:null,countName:null,unitPrice:13.5,lineTotal:27,sure:!0},{read:'HAD03 Smoked haddock fillet, undyed 1kg',item:'Smoked haddock fillet',packs:3,packSize:1,packUnit:'kg',count:null,countName:null,unitPrice:15.4,lineTotal:46.2,sure:!1},{read:'CRM02 Double cream 2L',item:'Double cream',packs:3,packSize:2,packUnit:'L',count:null,countName:null,unitPrice:6.95,lineTotal:20.85,sure:!0},{read:'BTR01 Unsalted butter 10 x 250g',item:'Unsalted butter',packs:1,packSize:2.5,packUnit:'kg',count:10,countName:'blocks',unitPrice:21.4,lineTotal:21.4,sure:!0},{read:'POT25 Maris Piper potatoes 25kg',item:'Maris Piper potatoes',packs:1,packSize:25,packUnit:'kg',count:null,countName:null,unitPrice:14.75,lineTotal:14.75,sure:!0},{read:'LEM40 Lemons, box of 40',item:'Lemons',packs:1,packSize:40,packUnit:'each',count:null,countName:null,unitPrice:9.6,lineTotal:9.6,sure:!0},{read:'EGG30 Free-range eggs, tray of 30',item:'Free-range eggs',packs:2,packSize:30,packUnit:'each',count:null,countName:null,unitPrice:5.85,lineTotal:11.7,sure:!0}]}},1196,[]); +__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.GpOverTime=function({rid:e,width:b}){const $=(0,n.useGpCalcView)(),P=(0,o.useRecipeCards)(e),[w,k]=(0,s.useState)('3m'),[v,D]=(0,s.useState)(b??0),_=(0,s.useMemo)(()=>P.map(e=>({id:e.id,dish:e.dish,price:e.price})),[P]),M=(0,s.useMemo)(()=>(0,a.menuGp)($.ingredients,$.cardCosts??{},_,$.settings),[$.ingredients,$.cardCosts,_,$.settings]),G=(0,s.useMemo)(()=>(0,a.gpHistory)(Object.values($.deliveries??{}),M,w),[$.deliveries,M,w]),T=(0,s.useMemo)(()=>M.dishes.map(e=>{const s=G.points.find(s=>null!=s.dishes[e.id])?.dishes[e.id];return{...e,ch:null!=s?e.gp-s:0}}).sort((e,s)=>Math.abs(s.ch)-Math.abs(e.ch)),[M.dishes,G.points]),[A,I]=(0,s.useState)(null),C=(A??T.slice(0,3).map(e=>e.id)).filter(e=>T.some(s=>s.id===e)).slice(0,3),L=(0,a.gpSummary)(G.points,w),F=240,S=(0,s.useMemo)(()=>v>0?(0,u.gpChartLayout)(v,F,G.points,C,M.dishes.map(e=>e.target)):null,[v,G.points,C,M.dishes]),z=e=>M.dishes.find(s=>s.id===e)?.name??G.names[e]??'Dish';return(0,p.jsxs)(d.Box,{testID:"gp-over-time",children:[(0,p.jsx)(r.T,{size:20,weight:"bold",center:!0,colour:c.colours.gold,accessibilityRole:"header",children:"GP over time"}),(0,p.jsx)(r.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['4w','3m','12m'].map(e=>(0,p.jsx)(h.Pick,{testID:`gp-range-${e}`,label:a.RANGE_SAID[e],accessibilityLabel:`Show ${a.RANGE_SAID[e]}`,selected:w===e,onPress:()=>k(e)},e))}),(0,p.jsxs)(t.default,{testID:"gp-summary",accessible:!0,accessibilityLabel:L,accessibilityLiveRegion:"polite",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(r.T,{size:30,weight:"bold",center:!0,colour:m,children:null!=M.menu?`${M.menu.toFixed(1)}%`:'\u2014'}),(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:L.replace(/^Menu GP now [\d.]+ percent, ?/,'').replace(/\.$/,'')||'Menu GP'})]}),(0,p.jsx)(t.default,{testID:"gp-chart",onLayout:b?void 0:e=>D(Math.floor(e.nativeEvent.layout.width)),importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{width:'100%',height:F,alignItems:'center'},children:S?(0,p.jsxs)(l.default,{width:S.width,height:F,children:[S.yTicks.map(e=>(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:e.y,y2:e.y,stroke:c.colours.border,strokeWidth:1},`g${e.v}`)),S.yTicks.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:u.GP_LEFT_BAND-6,y:e.y+4,fontSize:12,fill:c.colours.muted,textAnchor:"end",children:`${e.v}%`},`y${e.v}`)),null!=S.target?(0,p.jsx)(i.Line,{x1:u.GP_LEFT_BAND,x2:S.width-8,y1:S.target,y2:S.target,stroke:y,strokeDasharray:"4 4",strokeWidth:1}):null,S.area?(0,p.jsx)(i.Path,{d:S.area,fill:y,fillOpacity:.18}):null,S.dishPaths.map((e,s)=>(0,p.jsx)(i.Path,{d:e.d,stroke:x,strokeWidth:2,strokeDasharray:f[s]||void 0,fill:"none"},e.id)),S.menuPath?(0,p.jsx)(i.Path,{d:S.menuPath,stroke:m,strokeWidth:3,fill:"none"}):null,S.menuDots.map((e,s)=>(0,p.jsx)(i.Circle,{cx:e.x,cy:e.y,r:3,fill:m},s)),G.markers.map((e,s)=>{const t=S.xOfWeek(e.week);if(null==t)return null;const l=F-u.GP_AXIS_BAND-2;return(0,p.jsx)(i.Polygon,{points:`${t-5},${l} ${t+5},${l} ${t},${l-8}`,fill:y},`${e.id}${s}`)}),S.xLabels.map(e=>(0,p.jsx)(i.Text,{fontFamily:"Poppins_500Medium",x:e.x,y:234,fontSize:12,fill:c.colours.muted,textAnchor:"middle",children:e.text},e.text+e.x))]}):null}),(0,p.jsxs)(r.Row,{wrap:!0,gap:12,style:{justifyContent:'center'},children:[(0,p.jsx)(j,{colour:m,label:"Menu GP"}),C.map((e,s)=>(0,p.jsx)(j,{colour:x,dash:f[s],label:z(e)},e)),(0,p.jsx)(j,{colour:y,label:"Delivery changed costs",tri:!0})]}),T.length?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,colour:c.colours.muted,children:"Dishes on the chart (up to 3)"}),(0,p.jsx)(r.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:T.slice(0,12).map(e=>(0,p.jsx)(h.Pick,{testID:`gp-dish-${e.id}`,label:`${e.name} ${e.gp.toFixed(0)}%`,accessibilityLabel:`${e.name}, GP ${e.gp.toFixed(1)} percent${Math.abs(e.ch)>=.05?`, ${e.ch>0?'up':'down'} ${Math.abs(e.ch).toFixed(1)} points over ${a.RANGE_SAID[w]}`:', steady'}. ${C.includes(e.id)?'On the chart':'Tap to add to the chart'}`,selected:C.includes(e.id),onPress:()=>{return s=e.id,I(C.includes(s)?C.filter(e=>e!==s):[...C,s].slice(-3));var s}},e.id))})]}):(0,p.jsx)(r.Muted,{center:!0,children:"Cost your recipe cards to see dish GP here."}),G.markers.length?(0,p.jsxs)(t.default,{testID:"gp-markers",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(r.T,{size:c.font.small,center:!0,weight:"semibold",children:"Deliveries that changed costs"}),G.markers.slice(-5).reverse().map(e=>(0,p.jsxs)(r.T,{size:c.font.small,center:!0,colour:null!=e.change&&e.change<-.05?c.colours.amber:c.colours.muted,children:[e.date.split('-').reverse().join('/')," \xb7 ",e.supplier||'Supplier',null!=e.change?` \xb7 menu GP ${e.change>0?'+':''}${e.change.toFixed(1)} pts`:'']},e.id))]}):null]})};var s=_r(_d[0]),t=e(_r(_d[1])),i=_r(_d[2]),l=e(i),r=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const m=c.colours.gold,x='#C9CCD1',y='#B0773B',f=['','6 4','2 4'];function j({colour:e,label:s,tri:n,dash:o}){return(0,p.jsxs)(t.default,{style:{flexDirection:'row',alignItems:'center',gap:6},accessible:!1,children:[(0,p.jsx)(l.default,{width:18,height:12,children:n?(0,p.jsx)(i.Polygon,{points:"4,11 14,11 9,2",fill:e}):(0,p.jsx)(i.Line,{x1:0,x2:18,y1:6,y2:6,stroke:e,strokeWidth:3,strokeDasharray:o||void 0})}),(0,p.jsx)(r.T,{size:c.font.small,colour:c.colours.muted,children:s})]})}},1197,[34,102,797,794,990,874,993,821,930,1178,1198,25]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GP_AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GP_LEFT_BAND",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelW",{enumerable:!0,get:function(){return u}}),e.gpChartLayout=function(h,i,o,c,s){const d=Math.max(10,h-n-l),M=Math.max(10,i-t-a-12),f=o.flatMap(t=>[t.menu,...c.map(n=>t.dishes[n])]).filter(t=>null!=t),x=s.length?Math.round(s.reduce((t,n)=>t+n,0)/s.length):null;null!=x&&f.push(x);let p=f.length?5*Math.floor(Math.min(...f)/5)-5:50,b=f.length?5*Math.ceil(Math.max(...f)/5)+5:80;p=Math.max(0,p),b=Math.min(100,Math.max(b,p+10));const $=Math.max(1,o.length-1),y=t=>n+t/$*d,P=t=>a+M-(t-p)/(b-p)*M,_=b-p>30?10:5,F=[];for(let t=p;t<=b;t+=_)F.push({v:t,y:P(t)});const L=t=>{let n='',l=!1;return o.forEach((a,u)=>{const h=t(a);null!=h?(n+=`${l?'L':'M'}${y(u).toFixed(1)},${P(h).toFixed(1)}`,l=!0):l=!1}),n||null},w=L(t=>t.menu),O=o.findIndex(t=>null!=t.menu);let j=-1;o.forEach((t,n)=>{null!=t.menu&&(j=n)});const k=O>=0&&o.slice(O,j+1).every(t=>null!=t.menu),v=w&&k&&j>O?`${w}L${y(j).toFixed(1)},${P(p).toFixed(1)}L${y(O).toFixed(1)},${P(p).toFixed(1)}Z`:null,A=o.map((t,n)=>null!=t.menu?{x:y(n),y:P(t.menu)}:null).filter(t=>!!t),D=t=>`${t.slice(8,10)}/${t.slice(5,7)}`,E=u('00/00'),B=Math.max(2,Math.floor(d/(E+12))+1),G=Math.max(1,Math.ceil(o.length/B)),I=[];for(let t=o.length-1;t>=0;t-=G){const n=Math.min(h-E/2-2,Math.max(36+E/2,y(t)));I.some(t=>Math.abs(t.x-n)[t.week,n]));return{width:h,height:i,yTicks:F,menuPath:w,area:v,menuDots:A,xLabels:I,target:null!=x&&x>=p&&x<=b?P(x):null,dishPaths:c.map(t=>({id:t,d:L(n=>n.dishes[t])})).filter(t=>!!t.d),xOfWeek:t=>{const n=N.get(t);return null==n?null:y(n)}}};const t=24,n=40,l=10,a=12,u=(t,n=12)=>Math.ceil(t.length*n*.62)},1198,[]); +__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1199,[827,1200,34,402,102,426,794,891,867,858,821,1201,1088,1065,25]); +__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1201,[34,402,102,794,821,5,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1202,[860,1102,1099,1117,34,102,846,794,874,1101,878,877,858,821,1107,1203,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1203,[34,794,874,1204,25]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1204,[379]); +__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1205,[827,1063,1200,34,1206,236,402,426,102,1208,1209,1210,794,831,891,867,1064,821,930,1218,1201,1088,1065,1211,872,1212,1216,25]); +__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1206,[34,402,102,1207,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1207,[34,797,25]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1208,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1209,[34,102,794,827,891,867,1208,821,25]); +__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1210,[827,1208,34,402,102,794,925,891,1098,858,821,1201,1088,1211,872,1212,1213,1215,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1211,[1063,1085,1093]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1212,[34,102,794,891,1039,1063,1093,1087,1211,821,872,1210,1086,1088,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1213,[1064,1214]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1214,[1064,1208]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1215,[34,102,794,827,1063,1064,1213,1125,821,1216,25]); +__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1216,[1063,34,402,102,794,827,891,1214,1064,1217,1125,821,1205,1088,1208,1213,1065,25]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1217,[]); +__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1218,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1180,1201,1088,1065,1160,987,1039,1062,13,1085,1064,2,25]); +__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1219,[828,891,1220,1200,1006,1007,34,1013,1014,236,402,295,102,794,874,1098,1210,1182,1221,1090,5,1222,1161,867,858,821,1201,1180,1088,925,1042,997,998,1095,1001,1097,1166,1164,1213,1215,1091,25]); +__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1220,[827,34,402,102,794,821,891,831,876,1006,1007,25]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1221,[34,102,794,891,1090,821,1098,25]); +__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1222,[34,402,102,794,891,858,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1223,[34,102,794,891,821,1088,1091,1221,1098,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1224,[34,102,1088,821,794,25]); +__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1225,[827,1063,34,402,102,794,1034,821,930,25]); +__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1226,[827,796,1227,1149,835,891,34,336,402,102,794,1034,1035,821,925,930,1228,1231,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1227,[34,1034,891,835]); +__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1228,[828,1063,796,827,1227,835,891,34,336,402,102,797,794,925,1034,1035,1229,821,930,1230,25]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1229,[]); +__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1230,[831,891,5]); +__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1231,[34,1063,379,236,102,794,891,1034,1230,1035,1232,821,930,1227,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1232,[1035]); +__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.SpecialsEditor=function({rid:e,me:l,app:n,now:p}){const j=(0,a.useSpecials)(s=>s.current[e]??null),y=(0,a.useSpecials)(e=>e.history).filter(s=>s.restaurantId===e),{post:f,clear:w,reuse:k,remove:T}=a.useSpecials.getState(),[C,S]=(0,s.useState)(!1),[P,v]=(0,s.useState)(null),[D,B]=(0,s.useState)([]),[I,R]=(0,s.useState)(!1),[M,$]=(0,s.useState)(''),[A,N]=(0,s.useState)(''),[L,U]=(0,s.useState)(''),[G,_]=(0,s.useState)({}),[z,W]=(0,s.useState)(!1),[E,O]=(0,s.useState)(null),[F,Y]=(0,s.useState)(null),[H,K]=(0,s.useState)(''),[V,Z]=(0,s.useState)(!1),q=async e=>{Z(!0);const s=await(0,c.pickImageDataUrl)(1100,e);Z(!1),s&&(v(s),K(''))},J=(0,i.parsePrice)(L),Q={name:M,price:J,allergens:G,noAllergens:z},X=(0,i.itemProblems)(Q),ee=''!==L.trim()&&(null===J||Number.isNaN(J)),se=(0,i.draftProblems)({photo:P,items:D,allergensChecked:I});return(0,u.jsxs)(t.default,{style:{gap:12},testID:"specials-editor",children:[(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"On the board now"}),j?(0,u.jsx)(o.Badge,{kind:"ok",label:"Live in customer app"}):(0,u.jsx)(o.Badge,{kind:"neutral",label:"Empty"})]}),(0,u.jsx)(t.default,{testID:"specials-last-updated",children:(0,u.jsx)(o.T,{colour:d.colours.goldLight,children:j?(0,i.lastUpdated)(j,p):'Nothing posted. Customers see \u201cToday\u2019s specials are on their way\u201d.'})}),j?(0,u.jsxs)(o.Muted,{children:[(0,i.boardSummary)(j),j.allergenCheck?` \xb7 allergens signed off by ${j.allergenCheck.by}`:'']}):null,(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-update",label:"Update today\u2019s specials",onPress:()=>{return v((e=!0)?j?.photo??null:null),B(e?j?.items.map(e=>({...e}))??[]:[]),R(!1),$(''),N(''),U(''),_({}),W(!1),S(!0),void K('');var e},style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-clear",kind:"secondary",label:"Clear board",disabled:!j,onPress:()=>O({kind:'clear'}),style:{flexGrow:1}})]})]}),H?(0,u.jsx)(o.Banner,{kind:"success",children:H}):null,C?(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",size:17,children:"Update today\u2019s specials"}),(0,u.jsx)(o.Muted,{children:"Take a photo of the chalkboard, type the specials, or both. Typed specials show prices and allergens to customers."}),(0,u.jsx)(o.T,{weight:"semibold",colour:d.colours.gold,children:"1. Photo of the board"}),P?(0,u.jsxs)(t.default,{style:{gap:6},testID:"specials-photo-preview",children:[(0,u.jsx)(h.BoardPhoto,{photo:P,onPress:()=>Y(P),testID:"specials-editor-photo"}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,kind:"secondary",label:"Retake or change photo",onPress:()=>q(!1)}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>v(null)})]})]}):(0,u.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(o.Button,{testID:"specials-take-photo",kind:"secondary",label:"Take a photo",disabled:V,onPress:()=>q(!0),style:{flexGrow:1}}),(0,u.jsx)(o.Button,{testID:"specials-upload-photo",kind:"secondary",label:"Upload a photo",disabled:V,onPress:()=>q(!1),style:{flexGrow:1}})]}),(0,u.jsx)(o.Muted,{children:"The photo is shrunk and kept on this device for now. Nothing is uploaded."}),(0,u.jsxs)(o.T,{weight:"semibold",colour:d.colours.gold,children:["2. Typed specials (",D.length,")"]}),D.map(e=>(0,u.jsxs)(t.default,{style:{gap:4},children:[(0,u.jsx)(h.SpecialRow,{it:e,declared:[]}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${e.name}`,onPress:()=>O({kind:'remove-item',id:e.id,label:e.name}),style:{alignSelf:'flex-end'}})]},e.id)),(0,u.jsxs)(t.default,{style:{gap:8,borderWidth:1,borderColor:d.colours.border,borderRadius:12,padding:10},testID:"special-form",children:[(0,u.jsx)(o.Field,{label:"Dish name",value:M,onChangeText:$,placeholder:"e.g. Grilled hake, salsa verde"}),(0,u.jsx)(o.Field,{label:"Short description",value:A,onChangeText:N,placeholder:"One line for customers"}),(0,u.jsx)(o.Field,{label:"Price (\xa3)",value:L,onChangeText:U,placeholder:"e.g. 18.50 (blank: ask your server)",keyboardType:"decimal-pad"}),ee?(0,u.jsx)(o.T,{size:13,colour:d.colours.red,children:"Type the price like 18.50"}):null,(0,u.jsx)(x,{map:G,none:z,onChange:_,onNone:e=>{W(e),e&&_({})}}),M.trim()&&X.length?(0,u.jsx)(o.Muted,{children:X.join(' \xb7 ')}):null,(0,u.jsx)(o.Button,{testID:"special-add",kind:"secondary",label:"Add this special",disabled:!!X.length||ee,onPress:()=>{X.length||ee||(B([...D,{id:b(),name:M.trim(),description:A.trim(),price:J,allergens:G,noAllergens:z||void 0}]),$(''),N(''),U(''),_({}),W(!1),R(!1))}})]}),D.length?(0,u.jsxs)(t.default,{testID:"specials-allergen-check",style:{borderWidth:1,borderColor:I?d.colours.ok:d.colours.amber,borderRadius:12,padding:10,gap:4},children:[(0,u.jsx)(o.Toggle,{label:"I have checked the allergens for every typed special",value:I,onChange:R}),(0,u.jsxs)(o.Muted,{children:["Signed off as ",l," with the time. This joins the allergen log, alongside the sign-off chain for guest allergies."]})]}):null,se.length?(0,u.jsx)(t.default,{testID:"specials-problems",children:(0,u.jsx)(o.Muted,{children:se[0]})}):null,(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Cancel",onPress:()=>S(!1)}),(0,u.jsx)(o.Button,{testID:"specials-post",label:"Post to customer app",disabled:!!se.length,onPress:()=>{se.length||(f(e,{photo:P,items:D,allergensChecked:I},l,n),S(!1),K('Specials board updated. Customers see it now in the app\u2019s Specials tab.'))},style:{flex:1}})]})]}):j?(0,u.jsxs)(t.default,{style:{gap:8},testID:"specials-current",children:[j.photo?(0,u.jsx)(h.BoardPhoto,{photo:j.photo,onPress:()=>Y(j.photo)}):null,j.items.map(e=>(0,u.jsx)(h.SpecialRow,{it:e,declared:[]},e.id))]}):null,(0,u.jsxs)(o.Card,{children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Past boards"}),(0,u.jsxs)(o.Muted,{children:["The last ",y.length||'few'," boards. Use one again with one tap; it is posted now, signed off as you."]}),y.length?y.map(s=>(0,u.jsxs)(t.default,{testID:"specials-history-row",style:{borderTopWidth:1,borderColor:d.colours.border,paddingTop:8,gap:6},children:[(0,u.jsx)(o.Row,{style:{justifyContent:'space-between'},children:(0,u.jsxs)(t.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"medium",children:(0,i.whenText)(s.postedAt,p).replace(/^./,e=>e.toUpperCase())}),(0,u.jsxs)(o.Muted,{numberOfLines:2,children:[(0,i.boardSummary)(s)," \xb7 ",s.postedBy,s.items.length?` \xb7 ${s.items.map(e=>e.name.replace(' (sample)','')).slice(0,3).join(', ')}`:'']})]})}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{small:!0,label:"Use again",accessibilityLabel:`Use again: board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>{k(e,s.id,l,n),S(!1),K(`Board from ${(0,i.whenText)(s.postedAt,p)} is live again.`)}}),(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Delete",accessibilityLabel:`Delete board from ${(0,i.whenText)(s.postedAt,p)}`,onPress:()=>O({kind:'delete',id:s.id,label:(0,i.whenText)(s.postedAt,p)})})]})]},s.id)):(0,u.jsx)(o.Muted,{children:"No past boards yet."})]}),(0,u.jsxs)(o.Sheet,{visible:!!E,onClose:()=>O(null),title:'clear'===E?.kind?'Clear the specials board?':'delete'===E?.kind?'Delete this past board?':'Remove this special?',testID:"specials-confirm",children:[(0,u.jsx)(o.Muted,{children:'clear'===E?.kind?'Customers will see \u201cToday\u2019s specials are on their way\u201d until you post a new board. The current board is kept in Past boards.':'delete'===E?.kind?`The board from ${E.label} will be removed from Past boards. This can\u2019t be undone.`:E?`\u201c${E.label}\u201d will be taken off this draft.`:''}),(0,u.jsxs)(o.Row,{gap:8,children:[(0,u.jsx)(o.Button,{kind:"ghost",label:"Keep it",onPress:()=>O(null)}),(0,u.jsx)(o.Button,{testID:"specials-confirm-yes",kind:"danger",style:{flex:1},label:'clear'===E?.kind?'Yes, clear the board':'delete'===E?.kind?'Yes, delete it':'Yes, remove it',onPress:()=>{'clear'===E?.kind&&(w(e,l),S(!1),K('Board cleared. Customers see \u201cToday\u2019s specials are on their way\u201d.')),'delete'===E?.kind&&T(E.id),'remove-item'===E?.kind&&B(D.filter(e=>e.id!==E.id)),O(null)}})]})]}),(0,u.jsx)(h.PhotoZoom,{photo:F,onClose:()=>Y(null)})]})};var s=r(_d[0]),l=e(r(_d[1])),t=e(r(_d[2])),o=r(_d[3]),a=r(_d[4]),n=r(_d[5]),i=r(_d[6]),d=r(_d[7]),c=r(_d[8]),h=r(_d[9]),u=r(_d[10]);let p=0;const b=()=>`sp-${Date.now().toString(36)}${(p++).toString(36)}`;function x({map:e,none:s,onChange:a,onNone:c}){return(0,u.jsxs)(t.default,{style:{gap:6},testID:"special-allergens",children:[(0,u.jsx)(o.T,{size:13,weight:"medium",colour:d.colours.muted,children:"Allergens (tap: contains, tap again: may contain)"}),(0,u.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:n.ALLERGENS.map(t=>{const n=e[t.id],c='contains'===n?d.colours.redBg:'may'===n?d.colours.amberBg:d.colours.surface2,h='contains'===n?d.colours.red:'may'===n?d.colours.amber:d.colours.border;return(0,u.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:`${t.short}: ${'contains'===n?'contains':'may'===n?'may contain':'not listed'}`,disabled:s,onPress:()=>a((0,i.cycleAllergen)(e,t.id)),style:{paddingHorizontal:10,paddingVertical:8,minHeight:40,justifyContent:'center',borderRadius:18,borderWidth:1,borderColor:h,backgroundColor:c,opacity:s?.35:1},children:(0,u.jsxs)(o.T,{size:13,weight:"medium",colour:n?d.colours.text:d.colours.muted,children:[t.short,'may'===n?' (may)':'']})},t.id)})}),(0,u.jsx)(o.Toggle,{label:"None of the 14 allergens",value:s,onChange:c})]})}},1233,[34,402,102,794,995,861,996,821,930,1234,25]); +__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1234,[828,34,336,395,402,295,102,1235,794,995,861,996,858,821,1049,25,1237]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1235,[34,1236,102,861,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1236,[2,987]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1237,[]); +__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1238,[860,1058,34,236,402,102,797,874,821,794,1239,1130,1240,25]); +__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1239,[860,34,380,236,402,102,36,821,794,796,1130,874,25,277]); +__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1240,[1241,1242,1244,1243,1245,1048,1246]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1241,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1242,[839,5,846,849,872,1048,1243]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1243,[860,236,872,1241]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1244,[34,874,861,869,867,1242,1241]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1245,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1246,[34,1242,987,933]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1247,[34,402,102,426,874,861,821,794,1238,1130,1248,25]); +__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1248,[34,102,426,874,861,1240,1048,821,794,1130,25]); +__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1249,[34,236,402,102,879,794,821,1001,1250,1251,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1250,[872,6,933,976,1001,1240,1251]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1251,[839,1252,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1252,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1253,[34,872,1250]); +__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1254,[827,796,1227,835,984,34,931,1206,395,236,402,295,102,846,794,861,1035,867,882,1034,821,1165,1159,1186,932,25]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1255,[34,402,346,102,426,821,1207,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1256,[30,34,792,872,25]); +__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1257,[860,1127,877,30,34,1258,1002,102,14,1129,1138,794,861,867,1131,858,874,987,821,1204,864,1026,1029,1105,1133,1101,1259,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1258,[827,34,236,102,25]); +__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1259,[34,402,102,878,858,1063,1260,821,794,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1260,[1063]); +__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 b}});var n=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),a=e(_r(_d[3])),l=e(_r(_d[4])),r=_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]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,t.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),x=(0,h.useMenu)(e).find(e=>e.id===b),y=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===x?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,n.useTakeawayMenu)(n=>n.byVenue[e]),S=(0,h.useStore)(n=>n.basket.restaurantId===e&&'table'===n.basket.mode),[C,B]=(0,s.useState)(()=>(x?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,s.useState)(1),[P,T]=(0,s.useState)(''),[L,O]=(0,s.useState)(!1),[D,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[q,_]=(0,s.useState)(!1),N=(0,s.useMemo)(()=>x?(0,c.effectiveAllergens)(x,C):{},[x,C]);if(!j||!x)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(N,y.allergies),Y=(x.price??0)+(x.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,n)=>e+n.priceDelta,0),z=S||j.fictional?'on':(0,n.takeawayAvail)(x,w),F=x.soldOut||!x.signOff||null===x.price||'on'!==z,Q=(e,n)=>{const t=x.optionGroups.find(n=>n.id===e);B(e=>{const s=t.choices.map(e=>e.id);return t.multi?e.includes(n)?e.filter(e=>e!==n):[...e,n]:e.includes(n)&&!t.required?e.filter(e=>e!==n):[...e.filter(e=>!s.includes(e)),n]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:x.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),_(!0)};return(0,f.jsxs)(d.Screen,{title:x.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(a.default,{testID:"dish-photo",source:k,accessibilityLabel:`${x.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===x.price?x.priceNote:(0,u.gbp)(Y)}),x.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:x.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(x.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(n=>(0,f.jsx)(d.Chip,{label:n.label,sub:n.priceDelta?`+${(0,u.gbp)(n.priceDelta)}`:void 0,selected:C.includes(n.id),onPress:()=>Q(e.id,n.id)},n.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:x,map:N,declared:y.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:x.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&x.signOff&&null!==x.price?'This dish isn\u2019t on the takeaway menu. You can have it when you eat in.':x.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(l.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${x.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1261,[988,30,34,336,102,1235,1262,794,861,867,874,882,821,25]); +__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])},1262,[30,34,402,874,821,794,25]); +__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1263,[30,34,794,1264,874,1249,25]); +__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])},1264,[34,402,821,794,25]); +__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1265,[837,30,34,1266,794,867,874,821,1267,1271,25]); +__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:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1266,[34,385,102,874,867,821,794,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1267,[34,102,794,867,1268,1269,1270,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1268,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1269,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1270,[933,987,1269]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1271,[846,933,976,987,2,1268]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),I=_r(_d[23]),O=_r(_d[24]),R=_r(_d[25]),A=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),C=_r(_d[29]),_=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const M=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let $=!1,E=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,k.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,k.useRestaurant)(e),l=(0,k.useMenu)(e),a=(0,k.useCustomer)(),s=(0,k.useBasket)(),n=(0,k.useStore)(e=>e.startBasket),o=(0,k.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[U,V]=(0,u.useState)(!1),[Q,Y]=(0,u.useState)('takeaway'===M?'takeaway':'main');c.default.useEffect(()=>{M&&!$&&($=!0,'book'===M?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,k.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>d.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{C.START_LOYALTY_CODE&&!E&&(E=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,k.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||k.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=l.filter(e=>!('All'!==r&&e.section!==r||'takeaway'===Q&&'off'===ne(e))),re=(0,j.hoursFor)(t,o),ie=e=>()=>d.router.push(`/customer/${t.id}${e}`),de=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>V(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:ie('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:ie('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:ie('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:ie('/refer')},{icon:'gift',label:'Gift cards',on:ie('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:ie('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:ie('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:ie('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:ie('/feedback')},{icon:'hanger',label:'Lost property',on:ie('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:ie('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[re?`Kitchen today ${(0,j.kitchenHoursOn)(t,o)[0]}\u2013${(0,j.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:de.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:de.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=Q===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===Q?(0,v.jsx)(A.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===Q?(0,v.jsx)(m.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==Q?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==Q||oe.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==Q?se.filter(e=>('All'===r||e===r)&&oe.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),oe.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?'Not on the takeaway menu':'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:U,onClose:()=>V(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{V(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1272,[1273,1282,5,1283,1284,1285,1288,860,30,34,236,402,102,1235,1262,794,861,867,878,874,988,821,1289,1249,872,891,1234,995,996,1004,1290,1271,25]); +__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1273,[34,379,794,873,1274,1275,1281,874,5,6,25]); +__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1274,[34,379,102,794,997,998,1096,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1275,[6,34,933,794,1276,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1276,[6,1063,1277,1278,1279,34,102,827,794,821,11,1280,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1278,[4,11]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1279,[11]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1280,[6,933]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1281,[34,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1282,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1283,[34,102,794,1276,25]); +__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1284,[34,379,933,794,873,1274,1276,4,25]); +__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1285,[34,379,794,1274,873,1275,8,1286,25]); +__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1286,[34,102,794,1287,25]); +__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1287,[]); +__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1288,[34,794,873,1274,1275,874,9,25]); +__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1289,[34,402,102,426,794,821,1207,25]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1290,[34,102,1291,794,874,1004,1268,1271,821,25]); +__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1291,[34,102,1292,821,25]); +__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1292,[1293]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1293,[34,797,1294,1323,1324,25]); +__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1294,[1295]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1295,[1296,1297,1320,1322]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1296,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1297,[1298,1299,1300,1301,1302,1303,1304,1305,1306,1309,1313,1310,1314]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1298,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1299,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1300,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1301,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1306,[1307]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1310,[1311,1312]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1311,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1312,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1315,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1316,[1310]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1318,[1310,1298]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1319,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1320,[1321]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1322,[1321]); +__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1323,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1324,[34,797,1325,25]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1325,[]); +__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1326,[30,34,794,874,891,25]); +__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1327,[837,30,34,102,1291,794,867,874,821,1290,1271,25]); +__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1328,[837,30,34,102,1266,794,874,891,867,858,821,1267,1271,25]); +__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1329,[837,30,34,794,874,891,858,821,1290,1271,25]); +__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1330,[837,30,34,794,874,891,821,1290,1271,25]); +__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1331,[30,34,794,858,1161,1332,874,821,25]); +__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}},1332,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1333,[30,1101,34,402,102,794,858,874,821,25]); +__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 v}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),o=_r(d[3]),r=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),k=_r(d[15]),p=_r(d[16]),f=_r(d[17]);function v(){const e=(0,b.useBasket)(),v=(0,b.useRestaurant)(e.restaurantId??void 0),w=(0,b.useAllMenu)(e.restaurantId??void 0),C=(0,b.useCustomer)(),S=(0,b.useOrders)(v?.id),T=(0,b.useStore)(e=>e.setLineQty),B=(0,b.useStore)(e=>e.overrideLine),P=(0,b.useStore)(e=>e.startBasket),I=(0,b.useNow)(15e3),[O,$]=(0,a.useState)(null),[N,M]=(0,a.useState)(!1),[F,L]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,r.startForm)()),[A,R]=(0,a.useState)(''),[Y,D]=(0,a.useState)(C.phone??''),[E,_]=(0,a.useState)(C.email??''),[q,H]=(0,a.useState)(C.name&&'Guest'!==C.name?C.name:''),[G,V]=(0,a.useState)(!1),K=(0,b.useOrderAtTable)(e.restaurantId??void 0),Q=(0,p.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{K||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[K,e.mode]);const[U,J]=(0,a.useState)(null),[W,X]=(0,a.useState)(!1),Z=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,w,C.allergies),[e,w,C.allergies]);if(!v||!e.lines.length)return(0,f.jsxs)(i.Screen,{title:"Your basket",children:[(0,f.jsx)(i.Muted,{children:"Your basket is empty."}),(0,f.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ee=K&&'table'===e.mode,le=(0,h.takeawaySlots)(v,S,I),te=Z.reduce((e,l)=>e+l.unitPrice*l.qty,0),ae=Z.some(e=>e.contains.length&&!e.overridden),ne=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ee&&'on'!==(0,p.takeawayAvail)(l,Q)}),oe=!ee&&!O,re=!ee&&v.settings.takeawayPaused,se=(0,x.ukPhone)(Y),ie=q.trim().length>=2&&'guest'!==q.trim().toLowerCase(),de=ee||(0,p.takesCardTakeaway)(v,k.IS_ISOLATED_VENUE),ue=!G&&de&&!ae&&!ne.length&&N&&!oe&&!re&&(ee||ie&&se.ok&&(0,x.emailOk)(E)),ce=async()=>{V(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ee?void 0:O,tip:0,notes:F,phone:ee?void 0:se.pretty,email:ee?void 0:E.trim()||void 0,customerName:ee?void 0:q.trim()});(0,r.rememberGuard)(e.id,(0,r.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{V(!1)}},he=e.lines.find(e=>e.key===U),me=he?Z[e.lines.indexOf(he)]:void 0;return(0,f.jsxs)(i.Screen,{title:"Your basket",subtitle:`${v.name} \xb7 ${ee?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,f.jsx)(i.T,{weight:"bold",size:20,colour:j.colours.gold,children:(0,c.gbp)(te)})]}),de?ae?(0,f.jsx)(i.T,{size:14,colour:j.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):N?oe&&!re?(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Choose a collection time."}):ee||ie?ee||se.ok?null:(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your mobile number."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your name for the order."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Confirm your allergies to continue."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ee?(0,f.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!ue,onPress:()=>ce(),testID:"send-table-order"}):(0,f.jsx)(i.Button,{label:G?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(te)}`,disabled:!ue,onPress:()=>ce(),testID:"checkout"}),ee?null:(0,f.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ee||e.tableNo,null),ee?(0,f.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,v.fictional?null:(0,f.jsx)(i.AllergenNotice,{phone:v.phone}),Z.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,f.jsxs)(i.Card,{highlight:l.contains.length?j.colours.red:l.may.length?j.colours.amber:void 0,children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,f.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,f.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,f.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,f.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,f.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,f.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${C.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,f.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{X(!1),J(a.key)}})]})]}):l.contains.length?(0,f.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,f.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ne.includes(a)?(0,f.jsx)(i.Badge,{kind:"amber",label:!ee&&Q&&w.find(e=>e.id===a.itemId)&&'sold-out'===(0,p.takeawayAvail)(w.find(e=>e.id===a.itemId),Q)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Stepper,{value:a.qty,onChange:e=>T(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${v.id}`)}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(I)]}),re?(0,f.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===le.length?(0,f.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(i.Muted,{children:["15-minute slots, max ",v.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:le.slice(0,16).map(e=>(0,f.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:O===e.time.toISOString(),onPress:()=>$(e.time.toISOString())},e.label))})]})]}),(0,f.jsxs)(i.Card,{highlight:N?void 0:j.colours.amber,children:[(0,f.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:C.allergies.length?C.allergies.map(e=>(0,f.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,f.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,f.jsx)(i.Toggle,{label:C.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:N,onChange:M}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.H2,{children:"Your details"}),(0,f.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:q,onChangeText:H,autoComplete:"name",placeholder:"e.g. Sam Smith"}),q&&!ie?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"Please add your name."}):null,(0,f.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:Y,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!se.ok&&Y?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:se.error}):null,(0,f.jsx)(i.Field,{label:"Email (optional)",value:E,onChangeText:_,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,x.emailOk)(E)?null:(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,f.jsx)(i.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,f.jsx)(i.Field,{label:"Order notes (optional)",value:F,onChangeText:L,placeholder:"e.g. cutlery please"}),ee?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>P(v.id,'takeaway')}):null,(0,f.jsxs)(i.Sheet,{visible:!!he,onClose:()=>J(null),title:"Allergy override",children:[me?(0,f.jsx)(i.Banner,{kind:"danger",title:`${me.name} contains ${me.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,f.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:W,onChange:X}),(0,f.jsx)(i.Button,{kind:"danger",disabled:!W,label:"Confirm override",onPress:()=>{he&&me&&B(he.key,me.contains),J(null)}})]}),(0,f.jsx)(o.Honeypot,{value:A,onChange:R})]})}},1334,[860,30,34,1258,1002,102,794,861,867,1131,858,874,831,821,864,5,988,25]); +__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1335,[30,34,102,1262,794,861,878,874,821,1289,5,25]); +__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 f}});var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1336,[860,30,34,102,1264,794,861,867,858,874,821,1337,25]); +__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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1337,[34,371,379,236,30,794,867,821,988,1338,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1338,[933,987]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1339,[860,1271,30,34,102,794,861,867,858,874,879,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1340,[30,34,872,25]); +__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1341,[837,30,34,794,874,5,1271,25]); +__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1342,[30,34,794,1343,1175,1271,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1343,[827,860,34,102,794,861,867,1175,1344,874,821,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1344,[933,987,1175]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1345,[30,34,872,1346,1410,25]); +__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1346,[1162,796,5,6,1347,828,853,1122,860,1161,1348,1349,1350,1119,1143,1351,1352,1357,1358,1359,872,1360,1174,979,1130,1361,34,1099,1202,1048,1115,1157,1362,395,380,402,295,102,426,36,794,1249,1253,873,861,858,874,821,1118,891,1126,1088,1029,1105,1135,1363,1134,1364,1371,1373,1376,1379,1375,1380,1382,1383,1140,1123,1124,878,1387,1238,1388,1248,1240,1026,1393,1401,1402,1102,1142,1404,1405,1406,1098,1189,1407,1188,1181,869,1408,1409,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1348,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1349,[1027,1088]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1350,[34,102,1105,794,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1351,[860,34,102,794,874,1175,821,25]); +__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1352,[34,395,402,426,102,1291,794,1189,796,1029,1353,1354,1356,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1353,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1354,[34,395,402,295,412,102,426,796,794,821,1355,1356,25]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1355,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1356,[1025,872,1355,933,987]); +__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1357,[846]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1358,[828,34,379,395,402,102,794,1189,821,25]); +__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1359,[34,236,402,102,794,821,891,1004,858,1098,25]); +__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1360,[828,827,34,236,402,295,102,794,1174,874,979,831,981,982,872,980,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1361,[828,34,102,821,794,25]); +__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1362,[34,102,797,821,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1363,[]); +__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1364,[828,796,827,1122,860,1130,34,236,402,295,426,102,859,821,794,1365,1366,1029,891,1134,1368,987,872,25]); +__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1365,[828,860,34,1366,102,859,821,794,1135,1367,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1366,[859]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1367,[1366,859]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1368,[34,385,295,102,859,1369,1370,821,796,827,794,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1369,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1370,[1369,1025,872,933,987]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1371,[34,236,402,102,821,794,1189,1372,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1372,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1373,[828,860,1123,34,281,236,295,102,1136,874,1029,1105,14,858,1124,1374,821,794,1375,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1374,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1375,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1376,[5,828,34,283,336,236,402,102,426,821,873,794,1030,1001,1357,1377,2,1378,1379,874,858,25]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1377,[236]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1379,[34,846,933,987,1378]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1380,[860,14,1029,1381]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1381,[861]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1382,[34,102,797,821,25]); +__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1383,[1384,860,1123,1029,34,102,794,1126,874,1386,1380,1124,858,1121,1140,1141,1142,821,1349,25]); +__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1384,[34,379,402,102,874,1004,891,1027,1385,872,821,794,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1385,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1386,[1029,1105]); +__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1387,[1384,828,1123,827,860,1161,1119,1140,858,34,1107,236,402,295,102,794,1126,1375,874,1029,861,1117,1105,1332,821,1349,25]); +__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1388,[827,34,236,402,102,794,874,1029,1389,821,1390,1392,25]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1389,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1390,[846,874,1029,1389,1391,1392]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1391,[860]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1392,[236,1391]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1393,[860,34,1206,1189,402,102,1026,1029,878,858,821,794,1394,1397,25]); +__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1394,[1395,870,860,34,281,395,402,295,102,874,1026,1029,1396,858,821,1056,794,1397,1398,987,1349,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1395,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1396,[878,858,877]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1397,[5,1029,933,987]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1398,[846,933,987,1399,2,1400]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1399,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1400,[15]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1402,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1403,[1105]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1404,[860,1381]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1405,[34,402,102,794,1404,821,1362,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1406,[34,102,925,794,1189,858,821,25]); +__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1407,[34,1189,402,102,426,794,25]); +__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1408,[828,1063,827,2,1189,34,402,102,426,794,821,891,998,858,1001,1398,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1409,[34,1036,891,1009,831,1037,1001,1398,1094]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1410,[5,828,873,34,236,402,102,426,987,821,794,1357,1411,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1411,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1412,[30,34,872,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1413,[30,34,872,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1414,[30,34,1415,872,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return n.IS_CAR?(0,u.jsx)(t.CarApp,{}):(0,u.jsx)(p.OwnerApp,{})},r(d[0]);var n=r(d[1]),p=r(d[2]),t=r(d[3]),u=r(d[4])},1415,[34,872,1416,1550,25]); +__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,"canSignOffHours",{enumerable:!0,get:function(){return he}}),_e.barTabsFor=me,_e.signOffSpeech=be,_e.OwnerApp=function(){return H.IS_OWNER_DESKTOP?(0,ue.jsx)(de.DesktopGate,{phone:(0,ue.jsx)(xe,{})}):(0,le.isDesktop)()?(0,ue.jsx)(ce.DesktopShell,{}):(0,ue.jsx)(xe,{})};var t=_r(d[0]),s=_r(d[1]),o=_r(d[2]),r=_r(d[3]),n=_r(d[4]),a=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]),b=_r(d[11]),p=_r(d[12]),x=_r(d[13]),j=_r(d[14]),w=e(_r(d[15])),S=e(_r(d[16])),y=e(_r(d[17])),A=e(_r(d[18])),k=e(_r(d[19])),R=e(_r(d[20])),C=_r(d[21]),v=_r(d[22]),T=_r(d[23]),I=_r(d[24]),L=_r(d[25]),O=_r(d[26]),E=_r(d[27]),B=_r(d[28]),_=_r(d[29]),P=_r(d[30]),N=_r(d[31]),$=_r(d[32]);_r(d[33]);var D=_r(d[34]),M=_r(d[35]),H=_r(d[36]),W=_r(d[37]),V=_r(d[38]),z=_r(d[39]),F=_r(d[40]),U=_r(d[41]),q=_r(d[42]),G=_r(d[43]),K=_r(d[44]),Y=_r(d[45]);_r(d[46]);var J=_r(d[47]),Q=_r(d[48]),X=_r(d[49]),Z=_r(d[50]),ee=_r(d[51]),te=_r(d[52]),se=_r(d[53]),oe=_r(d[54]),re=_r(d[55]),ne=_r(d[56]),ae=_r(d[57]),ie=_r(d[58]),le=_r(d[59]),de=_r(d[60]),ce=_r(d[61]),ue=_r(d[62]);const fe=[{id:'anchorage',name:'The Anchorage',place:'Harbour View, Dunure'},{id:'saltmarsh',name:'The Venue',place:'Fictional demo venue'}],ge=[{id:'home',label:'Home',icon:'home'},{id:'orders',label:'Orders',icon:'orders'},{id:'bookings',label:'Bookings',icon:'bookings'},{id:'forecast',label:'Forecast',icon:'forecast',can:L.CAN.forecasts},{id:'chat',label:'Chat',icon:'chat'},{id:'more',label:'More',icon:'more'}],he=e=>L.CAN.manage(e)&&(!(0,o.isLive)()||(0,o.can)('rota.manage'));function me(e,t){return ge.filter(t=>!t.can||t.can(e)).map(e=>'orders'===e.id&&t?{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff'}:'forecast'===e.id?{id:'rota',label:'Rota',icon:'rota'}:e)}function be(e,t){const s=[e?`${e} earlier day${e>1?'s':''} to sign off`:'',t?`${t} correction request${t>1?'s':''}`:''].filter(Boolean);return"Sign off hours"+(s.length?`, ${s.join(' and ')}`:', nothing waiting')}const pe={home:'Today',orders:'Orders',bookings:'Bookings',forecast:'Forecasts',chat:'Staff chat',more:'More'};function xe(){const{rid:e,r:le,role:de,today:ce,now:xe,meId:je,me:we}=(0,_.useCtx)(3e4);(0,b.useTipsPosted)(e,ce,'staff'!==de);const Se=(0,_.useSignedIn)();(0,c.useSoldOutLink)(!0,(Se?.name??we).replace(' (example)',''));const ye=(0,I.useOrders)(e),[Ae,ke]=(0,j.useState)('home'),[Re,Ce]=(0,j.useState)(null),[ve,Te]=(0,j.useState)(!1),Ie=(0,n.useLiveVenue)(),[Le,Oe]=(0,j.useState)(!1),Ee=(0,j.useRef)(null);(0,j.useEffect)(()=>{(0,_.ensureAttendance)(ce,xe),(0,Q.ensureChat)(xe)},[ce]),globalThis.__ccNow=xe.getTime();const Be=(0,Q.useChatUnread)().total,Pe=(0,j.useRef)({t:'home',s:null});Pe.current={t:Ae,s:Re};const Ne=(0,j.useRef)([]),$e=(0,l.useScrollMemory)(Ee),De=(0,j.useCallback)((e,t=null)=>{const s=Pe.current;s.t===e&&s.s===t||(Ne.current=[...Ne.current,{...s,y:$e.leave()}].slice(-30),$e.restore(0)),ke(e),Ce(t)},[]),Me=(0,j.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Pe.current;let t=Ne.current.pop();for(;t&&t.t===e.t&&t.s===e.s;)t=Ne.current.pop();if(!t&&'home'===e.t&&!e.s)return!1;const s=t??{t:'home',s:null};return $e.leave(),ke(s.t),Ce(s.s),$e.restore(s.y??0),!0},[]);(0,u.useWebBack)(Me);const He=(0,u.useInnerBackShown)();(0,j.useEffect)(()=>(re.useVoiceNav.setState({go:De}),()=>re.useVoiceNav.setState({go:null})),[De]),(0,j.useEffect)(()=>{f.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchOwner=L.useOwner)},[De]),(0,j.useEffect)(()=>{const e=w.default.addEventListener('hardwareBackPress',Me);return()=>e.remove()},[Me]),(0,j.useEffect)(()=>{const e=ge.find(e=>e.id===Ae);e?.can&&!e.can(de)&&De('home');const t=(0,K.pageFor)(Re);t?.can&&!t.can(de)&&Ce(null)},[de]);const We='more'===Ae?(0,K.pageFor)(Re):void 0,Ve=ye.filter(e=>(0,B.LIVE)(e)&&'new'===e.status).length,{unread:ze,list:Fe,read:Ue}=(0,J.useNotifications)();(0,se.useAlertWatcher)(e,{nag:'staff'!==de}),(0,oe.useReviewAlerts)(e),(0,ne.useScheduledNotices)({rid:e,staffId:Se?.id??'',name:we,onOpen:e=>'bookings'===e?De('bookings'):'chat'===e?De('chat'):De('more',e)}),(0,ae.useOffRotaAlerts)({enabled:'staff'!==de&&!!Se});const qe=Se?.role??de,Ge='owner'===qe?'OWNER':'manager'===qe?'MANAGER':'STAFF',Ke=(0,se.useAlerts)(t=>t.history.filter(s=>s.rid===e&&(0,se.isUnread)(t,s)&&!(0,se.isCleared)(t,s)&&s.at>(t.seenAt[e]??0)).length),Ye=(0,se.useAlerts)(t=>t.todoSeen[e]),Je=Math.max(0,ze-Fe.filter(e=>!Ue[e.id]&&(Ye??[]).includes(e.id)).length)+Ke;(0,se.useAlertSeenSync)(e),(0,j.useEffect)(()=>{G.useShellBadges.setState({notifCount:Je})},[Je]);const Qe=(0,I.useBookings)(e).filter(e=>'pending'===e.status).length,Xe=he(de),Ze=(0,r.useOutstanding)(),et=Ze.days.length+Ze.requests,tt=me(de,Xe),st='more'===Ae&&'signoff'===Re?'signoff':'more'===Ae&&'rota'===Re?'rota':'forecast'===Ae||'orders'===Ae&&Xe?'more':Ae,ot=t.IS_ISOLATED_VENUE?[{id:e,name:le.name,place:le.location||le.address||''}]:fe,rt=ot.find(t=>t.id===e)??ot[0],nt=Se?.ownerAccess&&'owner'!==Se.role?'owner privileges':Se?.managerAccess&&'staff'===Se.role?'manager privileges':'',at=(0,M.ownerHomeLayout)(de,Se);(0,k.default)().width;return(0,ue.jsxs)(C.SafeAreaView,{style:{flex:1,backgroundColor:O.colours.bg},edges:['top','left','right','bottom'],children:[(0,ue.jsxs)(R.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:O.colours.border,gap:6},children:[(0,ue.jsxs)(R.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center',gap:2},children:[(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Search",hitSlop:8,onPress:()=>De('more','search'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(U.Icon,{name:"search",colour:O.colours.text})}),(0,ue.jsx)(y.default,{testID:"bell",accessibilityRole:"button",accessibilityLabel:Je?`Notifications, ${Je} new`:'Notifications, nothing new',hitSlop:8,onPress:()=>De('more','notifications'),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(U.Icon,{name:"bell",colour:O.colours.text}),Je?(0,ue.jsx)(R.default,{style:{position:'absolute',right:-4,top:-4,backgroundColor:O.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,ue.jsx)(v.T,{size:10,weight:"bold",children:Je})}):null]})}),(0,ue.jsx)(Z.VoiceSlot,{size:44})]}),(0,ue.jsx)(R.default,{style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ue.jsx)(R.default,{testID:"header-me-wrap",style:{alignItems:'flex-start'},children:(0,ue.jsx)(y.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`Signed in as ${we}. Account and role${nt?`, ${nt}`:''}`,disabled:'owner'!==H.APP_VARIANT,onPress:()=>Oe(!0),hitSlop:6,style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ue.jsxs)(v.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ue.jsx)(P.StaffAvatar,{id:je,size:24,ring:!1}),(0,ue.jsxs)(R.default,{style:{flexShrink:1},children:[(0,ue.jsxs)(v.T,{size:13,weight:"semibold",colour:O.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[Se?`${we} \xb7 ${Se.level??L.ROLE_LABEL[Se.role]}`:`${we} \xb7 ${L.ROLE_LABEL[de]}`,'owner'===H.APP_VARIANT?' \u25be':'']}),nt?(0,ue.jsx)(v.Muted,{center:!1,size:10,numberOfLines:1,children:nt}):null]})]})})})}),(0,ue.jsx)(y.default,{accessibilityRole:"button",accessibilityLabel:"Switch venue",onPress:()=>Te(!0),style:{alignSelf:'center',maxWidth:420,width:'100%'},children:(0,ue.jsx)(T.VenueHeaderBlock,{rid:e,name:le.name,badge:Ge,place:`${'staff'===de?'Staff preview \xb7 ':'Managers \xb7 '}${rt.place}`})}),de!==(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner')&&'owner'===H.APP_VARIANT?(0,ue.jsx)(y.default,{onPress:()=>L.useOwner.getState().setPreviewRole(Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner'),style:{backgroundColor:'#3a2f12',borderRadius:8,padding:6},children:(0,ue.jsx)(v.T,{size:12,colour:O.colours.gold,children:'staff'===de?`Staff app preview: what staff see in the Staff app. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`:`Previewing the ${L.ROLE_LABEL[de].toLowerCase()} view. Tap to return to ${L.ROLE_LABEL[Se?.ownerAccess?'owner':Se?.managerAccess?'manager':Se?.role??'owner']}.`})}):null]}),(0,ue.jsxs)(A.default,{ref:Ee,...$e.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:900,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ue.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Re||He),onBack:Me,title:We?We.title:'bookings'===Ae&&'waitlist'===Re?'Waitlist':'staff'===de&&'home'===Ae?'Staff app preview':pe[Ae]}),'home'===Ae&&Se&&'staff'===Se.role&&'owner'===H.APP_VARIANT?(0,ue.jsxs)(R.default,{testID:"access-off-banner",style:{borderWidth:1,borderColor:O.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",colour:O.colours.gold,children:"Your manager access is off"}),(0,ue.jsx)(v.Muted,{children:"Your own shifts, clock in, rota, pay and tips are still here."}),(0,ue.jsx)(v.Button,{label:"Clock in and my shifts",onPress:()=>De('more','clock')})]}):null,'home'!==Ae||at?null:(0,ue.jsx)(a.WhoBar,{}),'home'===Ae&&!at&&Se?(0,ue.jsx)(ie.MyShiftCard,{go:De}):null,'home'===Ae&&!at&&Se?(0,ue.jsx)(h.MyTasksToday,{rid:e,staffId:Se.id,name:Se.name,onShift:(0,p.shiftNow)(Se.id,Date.now()).on}):null,'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TodaysTipsCard,{rid:e,today:ce}),'home'!==Ae||at||'staff'===de?null:(0,ue.jsx)(b.TipsPotCard,{rid:e,today:ce}),'home'===Ae?'staff'===de?(0,ue.jsx)(z.StaffHome,{go:De}):(0,ue.jsx)(D.Dashboard,{go:De,ownerHome:at}):null,'orders'===Ae?(0,ue.jsx)(Y.Orders,{}):null,'bookings'===Ae?(0,ue.jsx)(E.Bookings,{go:De,only:'waitlist'===Re?'waitlist':void 0}):null,'forecast'===Ae?(0,ue.jsx)(F.Forecasts,{go:De}):null,'chat'===Ae?(0,ue.jsx)(Q.Chat,{go:De}):null,'more'===Ae?We?(0,ue.jsx)(We.C,{go:De}):(0,ue.jsx)(K.MoreMenu,{go:De}):null]}),(0,ue.jsx)(x.SeatAllergenReminder,{rid:e}),'staff'!==de?(0,ue.jsx)(te.PrintHost,{rid:e}):null,'staff'!==de?(0,ue.jsx)(ee.AlertHost,{variant:"managers",rid:e,me:we,onOpen:e=>De('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,ue.jsx)(X.AssistantSheet,{}),(0,ue.jsx)(q.BottomTabs,{background:(0,s.soutersSurface)('#0d0d0d'),active:st,onPress:e=>'signoff'===e?De('more','signoff'):'rota'===e?De('more','rota'):De(e),tabs:tt.map(e=>({id:e.id,label:e.label,short:e.short,icon:e.icon,a11y:'rota'===e.id?'Rota, the staff rota':'signoff'===e.id?be(Ze.days.length,Ze.requests):'more'===e.id&&Xe&&Ve?`More, ${Ve} new order${Ve>1?'s':''} in Orders`:void 0,badge:'chat'===e.id&&Be?{text:String(Be),bg:O.colours.red}:'bookings'===e.id&&Qe?{text:String(Qe),bg:O.colours.amber,fg:'#0B0B0B',testID:'pending-badge'}:'orders'===e.id&&Ve?{text:String(Ve),bg:O.colours.red}:'signoff'===e.id&&et?{text:String(et),bg:O.colours.amber,fg:'#0B0B0B',testID:'signoff-badge'}:'more'===e.id&&Xe&&Ve?{text:String(Ve),bg:O.colours.red,testID:'more-orders-badge'}:null}))}),(0,ue.jsx)(S.default,{visible:ve,transparent:!0,animationType:"fade",onRequestClose:()=>Te(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Te(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Your venues"}),ot.filter(e=>!Ie||'saltmarsh'!==e.id).map(t=>(0,ue.jsx)(y.default,{accessibilityRole:"button",onPress:()=>{L.useOwner.getState().setSite(t.id),Te(!1),De('home')},style:{padding:12,borderRadius:12,borderWidth:1,borderColor:t.id===e?O.colours.gold:O.colours.border},children:(0,ue.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,ue.jsxs)(R.default,{children:[(0,ue.jsx)(v.T,{weight:"medium",children:t.name}),(0,ue.jsx)(v.Muted,{children:t.place})]}),t.id===e?(0,ue.jsx)(v.Badge,{kind:"gold",label:"Current"}):null]})},t.id)),(0,ue.jsx)(v.Muted,{children:t.IS_ISOLATED_VENUE?`This app belongs only to ${le.name}.`:Ie?'Switch venues without signing out. Other venues appear here once they are set up.':'Switch venues without signing out. The Venue is made up, for trying CoverCharge offline.'})]})})}),(0,ue.jsx)(S.default,{visible:Le,transparent:!0,animationType:"fade",onRequestClose:()=>Oe(!1),children:(0,ue.jsx)(y.default,{style:{flex:1,backgroundColor:'#000a',justifyContent:'flex-end'},onPress:()=>Oe(!1),children:(0,ue.jsxs)(R.default,{style:{backgroundColor:O.colours.surface,padding:16,gap:8,borderTopLeftRadius:16,borderTopRightRadius:16},children:[Se?(0,ue.jsxs)(v.Row,{gap:10,children:[(0,ue.jsx)(P.StaffAvatar,{id:Se.id,size:44}),(0,ue.jsxs)(R.default,{style:{flex:1},children:[(0,ue.jsxs)(v.T,{weight:"semibold",children:["Signed in as ",Se.name]}),(0,ue.jsx)(v.Muted,{children:(0,$.levelJob)(Se.level??L.ROLE_LABEL[Se.role],Se.job)})]})]}):(0,ue.jsxs)(R.default,{style:{gap:6},children:[(0,ue.jsx)(v.T,{weight:"semibold",children:"Not signed in (preview)"}),(0,ue.jsx)(v.Muted,{children:"Open your personal link, or paste it here, to sign in as yourself."}),(0,ue.jsx)(N.SignInWithLink,{})]}),t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON||t.IS_GREENSIDE||!Se?null:(0,ue.jsx)(v.Button,{kind:"secondary",label:"Open CoverCharge for Staff (as you)",onPress:()=>{(async()=>{const e=t.IS_WILDINGS?await(0,o.wildingsStaffAppUrl)():t.IS_KIRKMICHAEL?await(0,o.kirkmichaelStaffAppUrl)():(0,$.appUrl)('staff');e&&window.location.assign(e)})()}}),(0,ue.jsx)(v.Muted,{children:"Preview what each role sees:"}),['owner','manager','staff'].filter(e=>!Se||(0,_.clampRole)(e,Se.ownerAccess?'owner':Se.managerAccess?'manager':Se.role)===e).map(e=>(0,ue.jsx)(v.Button,{kind:e===de?'primary':'secondary',label:'staff'===e?'Staff app preview':`${L.ROLE_LABEL[e]} view`,onPress:()=>{L.useOwner.getState().setPreviewRole(e),Oe(!1)}},e))]})})}),(0,ue.jsx)(W.OnboardingHost,{go:De}),(0,ue.jsx)(V.CoachHost,{})]})}},1416,[5,828,987,1210,1236,1224,1055,979,1056,2,1061,1062,1094,1115,34,373,395,402,295,426,102,36,794,873,874,891,821,1417,1201,1088,925,1426,1004,236,1435,13,872,1467,1473,1474,1475,1207,1255,1476,1459,1477,1479,1457,1180,1493,1157,1238,1388,1240,1253,1481,1112,1114,1223,1546,1547,1566,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1417,[5,1418,1123,11,1419,827,837,1140,1141,1119,1143,1420,1138,1142,1404,1405,1088,1349,1027,1117,14,1144,1422,1249,1423,1393,1107,1101,1118,34,102,794,1362,874,861,867,858,1332,821,1201,1126,1029,1424,1087,1181,1425,1240,987,1203,1401,878,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1418,[34,794,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1419,[6,34,102,794,987,1280,25]); +__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1420,[34,402,102,1421,987,933,821,794,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1421,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1422,[827,5,34,379,236,102,794,876,14,867,1032,933,821,1204,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1423,[34,402,1189,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1424,[34,102,874,1029,794,821,25]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1425,[34,102,879,874,864,821,794,25]); +__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1426,[5,1427,1428,1429,1430,1431,34,236,41,102,872,1432,1004,821,1434,794,987,2,1097,1003,891,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1427,[34,102,873,794,5,6,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1428,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1429,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1430,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1431,[34,102,873,794,25]); +__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1432,[34,295,102,794,873,821,1433,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1433,[]); +__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1434,[929,828,34,1097,336,236,402,295,41,102,872,926,891,831,987,1004,15,793,821,925,794,25]); +__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.Dashboard=function({go:e,ownerHome:a=!1}){const{rid:n,r:b,now:F,role:oe,me:ae,today:ne}=(0,A.useCtx)(5e3),ie=(0,p.useOrders)(n),re=(0,p.useBookings)(n),de=(0,p.useWaitlist)(n),ue=(0,p.useEvents)(n),ge=(0,p.useRatings)(n),xe=(0,k.useOwner)(e=>e.staff),ye=(0,k.useOwner)(e=>(0,k.liveAttendance)(e.attendance)),be=(0,k.useOwner)(e=>e.shifts),fe=(0,L.useRealHistory)(n,F),me=(0,o.useMemo)(()=>(0,t.forecastToday)(b,re,ie,ue,F,fe??void 0),[b,re,ie,ue,fe,F.getTime()/6e4|0]),je=(0,N.useExamples)(),pe=(0,P.useCashUp)(e=>e.cashUps),ke=re.filter(e=>e.date===ne),we=ie.filter(D.LIVE),$e=de.filter(e=>'waiting'===e.status||'notified'===e.status),ve=ke.filter(e=>['seated','finished'].includes((0,I.shownStatus)(e))).reduce((e,s)=>e+s.partySize,0),Ce=(0,te.coversSplit)(ke,ne),Ie=Ce.walkIns,Te=Ce.bookings,Be=we.filter(e=>(0,q.chainNeedsAction)(e,re)),De=ke.filter(e=>['confirmed','seated'].includes(e.status)&&(0,q.bookingNeedsAction)(e,we)),Ae=we.flatMap(e=>(0,v.readinessFor)(e,b,F).map(s=>({...s,order:e}))).filter(e=>'due'===e.state||'overdue'===e.state),Se=me.nextHour,Le=(0,D.busyLevel)(Se?.coversHigh??0,me.busy.busy),Ne=(0,D.restOfDayLevel)(me,b),Pe=ie.filter(e=>e.paid>0&&!!e.createdAt&&(0,C.ymd)(new Date(e.createdAt))===ne).reduce((e,s)=>e+s.paid,0),Me=(0,H.tradingDay)(F),Fe=je?(0,S.revenueHistory)(b,F,7).filter(e=>e.date.getDay()===F.getDay()).pop():void 0,Oe=je?{today:186e3+Pe,last:Fe?{date:(0,C.ymd)(Fe.date),pence:Fe.total}:null,online:0,show:!0}:(0,W.takingsToday)(pe,n,Me,Pe),Re=k.CAN.takings(oe)&&(!(0,R.isLive)()||(0,R.can)('takings.view')),He=(0,o.useMemo)(()=>(0,S.insights)(b,re,ie,ue,ge,F,ve),[b.id,re.length,ge.length,ve]),We=((0,A.weekday)(F),ye.filter(e=>e.date===ne&&e.in&&!e.out)),Ee=(0,J.useFrontDoor)(ne),ze=(0,h.useBookingWrite)(),Ge=(0,w.useOutstanding)(),Ue=(0,r.useTravelDay)('owner',ne),qe=(0,A.useSignedIn)(),Ye=(0,A.useInStaffApp)(),Ke=(0,M.canSeeMonthTakings)(oe,qe,{inStaffApp:Ye,live:(0,R.isLive)()}),Qe=(0,O.homeSetupNagsHidden)(n),Ve=(0,k.useOwner)(e=>e.socialPosts.reduce((e,s)=>e+('awaiting approval'===s.status?1:0),0)),[Xe,Ze]=(0,o.useState)(!1),Je=ae.replace(' (example)',''),es=k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-restaurant-dashboard",label:"Restaurant dashboard",accessibilityLabel:"Restaurant dashboard, everything on the Display: any day, table plan, Timeline, guests, Covers and actions",onPress:()=>e('more','serviceboard'),style:{minHeight:56}}):null;return Ue?(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(r.DayView,{rid:n,day:Ue,today:ne,app:"owner"})]}):a?(0,le.jsxs)(m.default,{style:{gap:12},testID:"owner-home",children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Re&&Oe.show?(0,le.jsx)(j.Row,{wrap:!0,gap:10,children:(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})})}):null,(0,le.jsx)(X.TodaysTipsCard,{rid:n,today:ne}),(0,le.jsx)(X.TipsPotCard,{rid:n,today:ne}),k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(K.WhoBar,{}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),qe&&'owner'!==qe.role?(0,le.jsx)(Q.MyShiftCard,{go:e}):null,qe?(0,le.jsx)(V.MyTasksToday,{rid:n,staffId:qe.id,name:qe.name,onShift:(0,Z.shiftNow)(qe.id,Date.now()).on}):null,k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]}):(0,le.jsxs)(m.default,{style:{gap:12},children:[es,(0,le.jsx)(r.DayBar,{app:"owner",today:ne}),(0,le.jsx)(i.CoversToday,{rid:n,onPress:()=>e('bookings')}),(0,le.jsx)(he,{split:Ce}),(0,le.jsx)(ee.BlocksBanner,{rid:n,now:F,by:ae}),(0,le.jsx)(y.KitchenSignoffs,{rid:n,today:ne,by:ae,app:"owner",canConfirm:k.CAN.manage(oe)}),Ke?(0,le.jsx)(z.FadeIn,{children:(0,le.jsx)(ce,{rid:n,today:ne})}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(Y.SetupCard,{go:e}):null,k.CAN.manage(oe)&&!Qe?(0,le.jsx)(l.SeasonsTodo,{go:e}):null,(0,le.jsx)(d.LastFoodBanner,{rid:n,now:F}),(0,le.jsx)(c.NextTableFreeCard,{rid:n,now:F}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{testID:"home-blocks",label:"Block bookings",accessibilityLabel:"Block bookings: block now, add a block, see future blocks",accessibilityHint:ze.hint,disabled:!ze.ok,onPress:()=>e('more','blocks')}):null,(0,le.jsx)(j.Button,{testID:"home-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>Ze(!0),style:{minHeight:56}}),(0,le.jsxs)(m.default,{testID:"front-door-bar",dataSet:{centre:'buttons'},style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[(0,le.jsx)(u.QuietButton,{label:"New booking",onPress:Ee.openBooking,testID:"home-booking",disabled:!ze.ok,accessibilityHint:ze.hint}),k.CAN.manage(oe)?(0,le.jsx)(ee.CloseGardenButton,{quiet:!0,short:!0,rid:n,r:b,now:F,by:ae}):null]}),Ee.elements,k.CAN.manage(oe)?(0,le.jsx)(_.PaydaysCard,{go:e}):null,(0,le.jsx)(z.FadeIn,{children:(0,le.jsxs)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center'},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Next hour",Se?` \xb7 ${(0,A.fmtH)(Se.hour)}\u2013${(0,A.fmtH)(Se.hour+1)}`:'']}),me.example?(0,le.jsx)(L.ExampleBadge,{}):me.enough?(0,le.jsx)(j.Badge,{kind:"amber",label:"ESTIMATE"}):(0,le.jsx)(j.Badge,{kind:"neutral",label:"BOOKED ONLY"}),(0,le.jsx)(z.Gauge,{pct:Se?Le.pct:0,label:Se?Le.label:me.open?'Kitchen closing':'Closed today',sub:Se&&!me.enough?`${Se.booked} booked${Se.walkIns?` + ${Se.walkIns} walk-ins seated`:''} \xb7 not enough history for a forecast yet`:Se?`Estimated ${(0,t.coversRange)(Se.coversLow,Se.coversHigh)} \xb7 Busy at ${me.busy.busy} Covers an hour \xb7 ${Se.booked} booked + about ${Se.walkIns} walk-ins${(0,x.showTakeaway)(b)?` \xb7 about ${Se.takeaway} takeaway`:''}`:'No forecast for the next hour'}),(0,le.jsxs)(j.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[me.enough?(0,le.jsx)(j.Badge,{kind:"gold",label:`Rest of today: ${Ne.level.label}${Ne.peak?`, peak ${(0,A.fmtH)(Ne.peak.hour)}`:''}`}):null,me.enough?(0,le.jsx)(j.Badge,{kind:"neutral",label:`${(0,t.coversRange)(me.restOfDay.low,me.restOfDay.high)}${(0,x.showTakeaway)(b)?` \xb7 about ${me.restOfDay.takeaway} takeaways`:''}`}):(0,le.jsx)(j.Badge,{kind:"neutral",label:`Booked so far: ${me.restOfDay.booked} Covers`})]}),me.flags.length?(0,le.jsxs)(j.Muted,{center:!0,children:["Calendar: ",me.flags.join(', ')]}):null,k.CAN.forecasts(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Open forecasts \u2192",onPress:()=>e('forecast')}):null]})}),(0,le.jsxs)(j.Row,{wrap:!0,gap:10,children:[k.CAN.manage(oe)?(0,le.jsx)(z.FadeIn,{delay:40,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{testID:"home-specials-board",label:"Specials board",value:"",accessibilityLabel:"Specials board. Opens the specials board.",onPress:()=>e('more','specialsboard'),sub:"Open the specials board"})}):null,(0,le.jsx)(z.FadeIn,{delay:80,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Covers today",value:"",onPress:()=>e('bookings'),sub:`${ve} seated (${Ie} walk-in) \xb7 ${Te} booked`,children:(0,le.jsx)(z.CountUp,{value:ve})})}),(0,le.jsx)(z.FadeIn,{delay:140,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Bookings today",value:"",onPress:()=>e('bookings'),sub:`${ke.filter(e=>['confirmed','pending'].includes((0,I.shownStatus)(e))).length} still to arrive`,children:(0,le.jsx)(z.CountUp,{value:ke.length})})}),(0,x.showTakeaway)(b)||we.length?(0,le.jsx)(z.FadeIn,{delay:200,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Live orders",value:"",accent:we.some(e=>'new'===e.status)?B.colours.red:void 0,onPress:()=>e('orders'),sub:(0,T.orderAtTableOn)(b)?`${we.filter(e=>'takeaway'===e.type).length} takeaway \xb7 ${we.filter(e=>'table'===e.type).length} table`:`${we.filter(e=>'takeaway'===e.type).length} takeaway`,children:(0,le.jsx)(z.CountUp,{value:we.length})})}):null,$e.length>0?(0,le.jsx)(z.FadeIn,{delay:260,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Waitlist",value:"",onPress:()=>e('bookings','waitlist'),sub:`${$e.reduce((e,s)=>e+s.partySize,0)} Covers waiting`,children:(0,le.jsx)(z.CountUp,{value:$e.length})})}):null,Re&&Oe.show?(0,le.jsx)(z.FadeIn,{delay:320,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(E.TakingsTodayCard,{t:Oe,example:je,onPress:()=>e('more','analytics')})}):null,(0,le.jsx)(z.FadeIn,{delay:380,style:{flexGrow:1,flexBasis:150},children:(0,le.jsx)(D.Tile,{label:"Allergy alerts",value:"",accent:Be.length+De.length?B.colours.red:B.colours.ok,sub:"Need a sign-off",children:(0,le.jsx)(z.CountUp,{value:Be.length+De.length,colour:Be.length+De.length?B.colours.red:B.colours.ok})})})]}),Be.length+De.length+Ae.length?(0,le.jsx)(D.SectionHead,{title:"Needs action now"}):null,Be.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 ${e.ref} ${'table'===e.type?`${(0,s.tableNumbers)(e.tableNo)}`:'takeaway'}`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.AllergyChain,{o:e,me:ae,compact:!0})]},e.id)),De.map(e=>(0,le.jsxs)(D.AlertBox,{colour:B.colours.red,title:`ALLERGY \xb7 booking ${e.time} ${e.name} (${e.partySize})`,children:[(0,le.jsx)(j.T,{size:14,children:e.allergies.map(e=>`${(0,$.allergenLabel)(e.allergen)} (${(0,$.severityLabel)(e.severity)})`).join('; ')}),(0,le.jsx)(U.BookingAllergyChain,{b:e,me:ae})]},e.id)),Ae.map(s=>(0,le.jsxs)(D.AlertBox,{colour:'overdue'===s.state?B.colours.red:B.colours.amber,title:`${'cook'===s.stage?'START COOKING':'bag'===s.stage?'BAG IT':'READY'} \xb7 ${s.order.ref} pickup ${(0,C.hm)(new Date(s.order.slotTime))}${'overdue'===s.state?' \xb7 OVERDUE':''}`,children:[(0,le.jsx)(j.T,{size:14,children:s.detail}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Open orders",onPress:()=>e('orders')})]},s.id)),k.CAN.manage(oe)&&(Ge.days.length||Ge.requests)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`HOURS \xb7 ${Ge.days.length?`${Ge.days.length} earlier day${Ge.days.length>1?'s':''} to sign off`:''}${Ge.days.length&&Ge.requests?' \xb7 ':''}${Ge.requests?`${Ge.requests} correction request${Ge.requests>1?'s':''}`:''}`,children:[(0,le.jsx)(j.T,{size:14,children:"Hours only count for pay once a manager confirms them."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Sign off hours",testID:"nudge-signoff",onPress:()=>e('more','signoff')})]}):null,Ve&&k.CAN.publishSocial(oe)?(0,le.jsxs)(D.AlertBox,{colour:B.colours.amber,title:`SOCIAL \xb7 ${Ve} post${Ve>1?'s':''} awaiting approval`,children:[(0,le.jsx)(j.T,{size:14,children:"Drafted by staff. Review and approve before anything goes out. Posting: not set up yet."}),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Review posts",onPress:()=>e('more','social')})]}):null,(0,le.jsx)(D.SectionHead,{title:"Quick actions"}),(0,le.jsxs)(f.default,{accessibilityRole:"button",accessibilityLabel:"Post to social",onPress:()=>e('more','social'),style:({pressed:e})=>({borderRadius:16,borderWidth:1.5,borderColor:B.colours.gold,backgroundColor:e?B.colours.goldTint:B.colours.surface,padding:12,flexDirection:'row',alignItems:'center',gap:10}),children:[(0,le.jsxs)(j.Row,{gap:4,children:[(0,le.jsx)(G.Mark,{p:"facebook"}),(0,le.jsx)(G.Mark,{p:"instagram"}),(0,le.jsx)(G.Mark,{p:"tiktok"}),(0,le.jsx)(G.Mark,{p:"youtube"})]}),(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"bold",children:"Post to social"}),(0,le.jsx)(j.Muted,{children:"Facebook + Instagram, TikTok + YouTube: not set up yet"})]}),(0,le.jsx)(j.T,{colour:B.colours.gold,size:20,children:"\u203a"})]}),(0,le.jsx)(G.QuickLinksSection,{go:e,heading:e=>(0,le.jsx)(D.SectionHead,{title:e})}),(0,le.jsx)(D.SectionHead,{title:"Who\u2019s on now",right:(0,le.jsx)(j.Badge,{kind:"ok",label:`${We.length} clocked in`})}),(0,le.jsxs)(j.Card,{children:[0===We.length?(0,le.jsx)(j.Muted,{children:"Nobody clocked in yet."}):null,We.map(e=>{const s=xe.find(s=>s.id===e.staffId),t=(0,k.shiftOf)(be,e.staffId,ne),l=new Date(e.in),o=!!t&&l.getHours()+l.getMinutes()/60-t.start>.08333333333333333;return(0,le.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,le.jsxs)(m.default,{style:{flex:1},children:[(0,le.jsx)(j.T,{weight:"semibold",children:s?.name??e.staffId}),(0,le.jsxs)(j.Muted,{children:[s?.job," \xb7 in ",(0,C.hm)(l),t?` \xb7 shift ${(0,A.fmtH)(t.start)}\u2013${(0,A.fmtH)(t.end)}`:' \xb7 unscheduled']})]}),o?(0,le.jsx)(j.Badge,{kind:"amber",label:"Late"}):(0,le.jsx)(j.Badge,{kind:"ok",label:"On site"})]},e.id)}),k.CAN.manage(oe)?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:"Rota & timesheets \u2192",onPress:()=>e('more','rota')}):(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"Clock in / out",onPress:()=>e('more','clock')})]}),'staff'!==oe?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(D.SectionHead,{title:"Insights",sub:je?'AI-style suggestions from your bookings, orders, stock and calendar (example figures)':'From your own bookings, reviews and calendar'}),He.slice(0,4).map((s,t)=>(0,le.jsx)(z.FadeIn,{delay:100+90*t,children:(0,le.jsxs)(j.Card,{style:{borderLeftWidth:4,borderLeftColor:{gold:B.colours.gold,red:B.colours.red,amber:B.colours.amber,ok:B.colours.ok,blue:B.colours.blue}[s.tone]},children:[(0,le.jsxs)(j.T,{weight:"semibold",children:[s.icon," ",s.title]}),(0,le.jsx)(j.Muted,{children:s.body}),s.action?(0,le.jsx)(j.Button,{small:!0,kind:"ghost",label:`${s.action.label} \u2192`,onPress:()=>e(s.action.tab,s.action.sub??null),style:{alignSelf:'flex-start'}}):null]})},s.id)),(0,le.jsx)(j.Button,{small:!0,kind:"secondary",label:"All insights",onPress:()=>e('more','insights')})]}):null,(0,le.jsx)(se.SoldOutSheet,{visible:Xe,onClose:()=>Ze(!1),rid:n,by:Je,hideLinks:!0,testID:"home-soldout-sheet"})]})},_e.monthAxisDays=de,_e.MonthTakingsCard=ce,_e.WalkInSplitCard=he;var s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),o=_r(_d[3]),a=_r(_d[4]),n=e(a),i=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),x=_r(_d[11]),y=_r(_d[12]),b=e(_r(_d[13])),f=e(_r(_d[14])),m=e(_r(_d[15])),j=_r(_d[16]),p=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),$=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),I=_r(_d[23]),T=_r(_d[24]),B=_r(_d[25]),D=_r(_d[26]),A=_r(_d[27]),S=_r(_d[28]),L=_r(_d[29]),N=_r(_d[30]),P=_r(_d[31]),M=_r(_d[32]),F=_r(_d[33]),O=_r(_d[34]),R=_r(_d[35]),H=_r(_d[36]),W=_r(_d[37]),E=_r(_d[38]),z=_r(_d[39]),G=_r(_d[40]),U=_r(_d[41]),q=_r(_d[42]),Y=_r(_d[43]),_=_r(_d[44]),K=_r(_d[45]),Q=_r(_d[46]),V=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),J=_r(_d[50]),ee=_r(_d[51]),se=_r(_d[52]),te=_r(_d[53]),le=_r(_d[54]);const oe=18,ae=18,ne=150,ie=34;function re(e){if(!e.length)return'';if(1===e.length)return`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;const s=e.length,t=[],l=[];for(let l=0;l9){const n=3/Math.sqrt(a);l[e]=n*s*t[e],l[e+1]=n*o*t[e]}}let o=`M${e[0].x.toFixed(1)},${e[0].y.toFixed(1)}`;for(let t=0;toe+(s-1)/Math.max(1,e-1)*t,o=[1,5,10,15,20,25].filter(s=>s=36)&&a.push(e);for(;a.length&&l(e)-l(a[a.length-1])<36;)a.pop();return[...a,e]}function ce({rid:e,today:s}){const t=(0,P.useCashUp)(e=>e.cashUps),[l,i]=(0,o.useState)(s.slice(0,7)),[r,d]=(0,o.useState)(0),[c,u]=(0,o.useState)(null),h=(0,o.useMemo)(()=>(0,M.monthTakings)(t,e,l,s),[t,e,l,s]),x=(0,o.useMemo)(()=>(0,M.firstTakingsMonth)(t,e),[t,e]),y=!!x&&xoe+(e-1)/Math.max(1,k-1)*w,I=e=>$-e/v*128,T=[];h.days.forEach((e,s)=>{if('recorded'!==e.state)return;const t={x:C(e.day),y:I(e.value)};s&&'recorded'===h.days[s-1].state?T[T.length-1].push(t):T.push([t])});const D=h.days.filter(e=>'future'!==e.state),A=[...h.days].reverse().find(e=>'recorded'===e.state),S=h.days.find(e=>e.date===c&&'future'!==e.state)??(h.current?h.days.find(e=>e.date===s):void 0)??A??D[D.length-1],L=e=>{const s=D.findIndex(e=>e.date===S?.date),t=D[Math.max(0,Math.min(D.length-1,s+e))];t&&(u(t.date),b.default.announceForAccessibility?.(N(t)))},N=e=>`${(0,M.longDay)(e.date)}, ${'recorded'===e.state?(0,M.poundsWhole)(e.value):'pending'===e.state?'not cashed up yet':'no cash up'}`,O=h.current?`so far in ${h.month}`:`in ${h.month} ${l.slice(0,4)}`,R=null==h.vsPct?null:`vs ${h.current?'same point last month':(0,M.monthName)((0,M.addMonths)(l,-1))} ${h.vsPct>0?'+':''}${h.vsPct}%`,H=h.recorded?`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. ${(0,M.poundsWhole)(h.total)} ${O}, from ${h.recorded} cash up${1===h.recorded?'':'s'}. Best day ${(0,M.longDay)(h.best.date)}, ${(0,M.poundsWhole)(h.best.value)}.${R?` ${R.replace('+','up ').replace(/ -(\d)/,' down $1')}.`:''}`:`Takings ${h.current?'this month':`${h.month} ${l.slice(0,4)}`}. No cash-ups yet${h.current?' this month':''}.`,W=r?de(k,r):[],E=(e,s,t,o,a)=>(0,le.jsx)(f.default,{testID:a,accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{disabled:!t},disabled:!t,onPress:()=>{i((0,M.addMonths)(l,o)),u(null)},style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:24,opacity:t?e?.6:1:.25}),children:(0,le.jsx)(j.T,{size:24,colour:B.colours.gold,center:!0,children:e})});return(0,le.jsx)(j.Card,{highlight:B.colours.gold,style:{alignItems:'center',gap:6},children:(0,le.jsxs)(m.default,{testID:"home-month-takings",style:{width:'100%',alignItems:'center',gap:6,minWidth:0},children:[(0,le.jsxs)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,accessibilityRole:"header",children:["Takings ",h.current?'this month':'by month']}),y||p?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:4,width:'100%'},children:[E('\u2039',`Previous month, ${(0,M.monthName)((0,M.addMonths)(l,-1))}`,y,-1,'mt-prev'),(0,le.jsxs)(j.T,{center:!0,colour:B.colours.goldLight,style:{flexShrink:1},testID:"mt-month",children:[h.month," ",l.slice(0,4)]}),E('\u203a',`Next month, ${(0,M.monthName)((0,M.addMonths)(l,1))}`,p,1,'mt-next')]}):null,(0,le.jsx)(m.default,{accessible:!0,accessibilityLabel:H,testID:"mt-summary",style:{alignItems:'center',width:'100%',gap:2},children:h.recorded?(0,le.jsxs)(le.Fragment,{children:[(0,le.jsx)(j.T,{size:38,weight:"bold",colour:B.colours.gold,center:!0,testID:"mt-total",children:(0,M.poundsWhole)(h.total)}),(0,le.jsx)(j.T,{center:!0,colour:B.colours.goldLight,children:O}),(0,le.jsxs)(j.Muted,{center:!0,testID:"mt-best",children:["Best day: ",(0,M.shortDay)(h.best.date)," \xb7 ",(0,M.poundsWhole)(h.best.value)]}),R?(0,le.jsx)(j.Muted,{center:!0,testID:"mt-vs",children:R}):null]}):(0,le.jsx)(j.Muted,{center:!0,testID:"mt-empty",children:h.current?'No cash-ups yet this month.':`No cash-ups in ${h.month}.`})}),(0,le.jsxs)(m.default,{style:{width:'100%',minWidth:0},children:[(0,le.jsxs)(m.default,{testID:"mt-plot",onLayout:e=>d(e.nativeEvent.layout.width),style:{height:ne,width:'100%',overflow:'visible'},children:[r?(0,le.jsxs)(n.default,{width:r,height:ne,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:[(0,le.jsx)(a.Defs,{children:(0,le.jsxs)(a.LinearGradient,{id:"mtFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,le.jsx)(a.Stop,{offset:"0",stopColor:"#3A2F1E",stopOpacity:1}),(0,le.jsx)(a.Stop,{offset:"1",stopColor:"#3A2F1E",stopOpacity:.35})]})}),(0,le.jsx)(a.Line,{x1:oe,y1:$,x2:r-ae,y2:$,stroke:B.colours.hairline,strokeWidth:1}),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:`${re(e)} L${e[e.length-1].x.toFixed(1)},142 L${e[0].x.toFixed(1)},142 Z`,fill:"url(#mtFill)",stroke:"none"},`a${s}`)),T.filter(e=>e.length>1).map((e,s)=>(0,le.jsx)(a.Path,{d:re(e),stroke:B.colours.gold,strokeWidth:2.5,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},`l${s}`)),T.filter(e=>1===e.length).map((e,s)=>(0,le.jsx)(a.Circle,{cx:e[0].x,cy:e[0].y,r:3,fill:B.colours.gold},`s${s}`)),h.days.filter(e=>'missing'===e.state).map(e=>(0,le.jsx)(a.Circle,{cx:C(e.day),cy:$,r:2,fill:"none",stroke:B.colours.muted,strokeWidth:1},e.date)),S&&'recorded'===S.state?(0,le.jsx)(a.Line,{x1:C(S.day),y1:10,x2:C(S.day),y2:$,stroke:B.colours.goldMuted,strokeWidth:1,strokeDasharray:"3,3"}):null,h.current?(()=>{const e=h.days.find(e=>e.date===s);return(0,le.jsx)(a.Circle,{cx:C(e.day),cy:'recorded'===e.state?I(e.value):$,r:4.5,fill:B.colours.gold,stroke:B.colours.surface,strokeWidth:1.5})})():null,S&&'recorded'===S.state&&S.date!==s?(0,le.jsx)(a.Circle,{cx:C(S.day),cy:I(S.value),r:5,fill:B.colours.surface,stroke:B.colours.gold,strokeWidth:2}):null]}):null,r?D.map(e=>(0,le.jsx)(f.default,{testID:`mt-day-${e.day}`,accessibilityRole:"button",accessibilityLabel:N(e),accessibilityState:{selected:S?.date===e.date},onPress:()=>u(e.date),style:{position:'absolute',top:0,height:ne,left:C(e.day)-w/Math.max(1,k-1)/2,width:w/Math.max(1,k-1)}},e.date)):null]}),(0,le.jsx)(m.default,{testID:"mt-axis",style:{height:F.AXIS_BAND+6,minHeight:F.AXIS_BAND+6,width:'100%',position:'relative',overflow:'visible'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:W.map(e=>(0,le.jsx)(j.T,{size:F.AXIS_FONT,colour:B.colours.muted,style:{position:'absolute',left:C(e)-17,width:ie,top:0,textAlign:'center'},children:String(e)},e))})]}),S&&D.length?(0,le.jsxs)(m.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center',width:'100%',gap:4},children:[(0,le.jsx)(f.default,{testID:"mt-day-prev",accessibilityRole:"button",accessibilityLabel:"Previous day",disabled:D[0]?.date===S.date,onPress:()=>L(-1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[0]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u2039"})}),(0,le.jsxs)(m.default,{testID:"mt-readout",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:N(S),style:{flexShrink:1,minWidth:0,alignItems:'center',paddingVertical:4},children:[(0,le.jsx)(j.Muted,{center:!0,children:S.date===s?`Today \xb7 ${(0,M.shortDay)(S.date)}`:(0,M.shortDay)(S.date)}),(0,le.jsx)(j.T,{center:!0,size:20,weight:"semibold",colour:'recorded'===S.state?B.colours.goldLight:B.colours.muted,children:'recorded'===S.state?(0,M.poundsWhole)(S.value):'pending'===S.state?'Not cashed up yet':'No cash-up'})]}),(0,le.jsx)(f.default,{testID:"mt-day-next",accessibilityRole:"button",accessibilityLabel:"Next day",disabled:D[D.length-1]?.date===S.date,onPress:()=>L(1),style:({pressed:e})=>({minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:D[D.length-1]?.date===S.date?.25:e?.6:1}),children:(0,le.jsx)(j.T,{size:20,colour:B.colours.gold,center:!0,children:"\u203a"})})]}):null,(0,le.jsx)(j.Muted,{center:!0,size:13,children:"From confirmed cash ups: gross takings, or card + cash. \u25cb = no cash up that day."})]})})}const ue='#3A2F1E';function he({split:e}){return(0,le.jsx)(j.Card,{style:{alignItems:'center',gap:8},children:(0,le.jsxs)(m.default,{testID:"home-covers-split",accessible:!0,accessibilityLabel:`Walk-ins and bookings today. ${e.a11y}`,style:{width:'100%',alignItems:'center',gap:8},children:[(0,le.jsx)(j.T,{weight:"semibold",colour:B.colours.gold,center:!0,children:"Walk-ins and bookings today"}),e.empty?(0,le.jsx)(j.Muted,{center:!0,children:"No Covers yet"}):(0,le.jsxs)(le.Fragment,{children:[(0,le.jsxs)(m.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:18,width:'100%'},children:[(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",colour:B.colours.gold,center:!0,testID:"split-walkin-pct",children:`${e.walkInPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.goldLight,center:!0,children:`Walk-ins \xb7 ${e.walkIns} Covers`})]}),(0,le.jsxs)(m.default,{style:{alignItems:'center',minWidth:120},children:[(0,le.jsx)(j.T,{size:26,weight:"bold",center:!0,testID:"split-booked-pct",children:`${e.bookingPct}%`}),(0,le.jsx)(j.T,{size:14,colour:B.colours.muted,center:!0,children:`Booked \xb7 ${e.bookings} Covers`})]})]}),(0,le.jsxs)(m.default,{style:{width:'100%',maxWidth:420,height:10,borderRadius:5,overflow:'hidden',flexDirection:'row',backgroundColor:ue,borderWidth:1,borderColor:B.colours.gold},children:[(0,le.jsx)(m.default,{style:{width:`${e.walkInPct}%`,backgroundColor:B.colours.gold}}),(0,le.jsx)(m.default,{style:{flex:1,backgroundColor:ue}})]})]})]})})}},1435,[860,1161,1436,34,797,1099,1202,1103,1104,1423,1349,877,1107,281,402,102,794,874,891,1210,861,1179,858,1101,881,821,1201,1088,1160,1166,1167,1039,13,1171,927,987,1000,1445,1446,1170,1447,1181,869,1450,1205,1224,1223,1061,1062,1094,1126,1393,1174,1348,25]); +__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.AdvancedSettings=function({go:e}){const{r:x,rid:P,today:O,me:z}=(0,R.useCtx)(6e4),V=z.replace(" (example)",""),J=x.settings,X=e=>v.useStore.getState().updateSettings(P,e),[ee,te]=(0,m.useState)(()=>(0,h.takeAdvancedPrefill)()),[oe,ae]=(0,m.useState)(null),ne=e=>{if(e.onReset)return e.onReset(),void ae(`${e.title}: back to the defaults.`);X(Object.fromEntries(e.reset.map(e=>[e,void 0]))),ae(`${e.title}: back to the defaults.`)},le=(0,M.useBookings)(P),re=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Ask about allergies first (in red)"}),(0,W.jsx)(j.Badge,{kind:"red",label:"ALWAYS ON"})]}),(0,W.jsx)(j.Muted,{size:13,children:"Food safety: every booking answers this before anything else, and staff tick \u201cAllergens seen\u201d."}),(0,W.jsx)(j.Toggle,{label:"Ask if they\u2019re bringing a dog",value:(0,T.dogQuestionOn)(x),onChange:e=>X({dogQuestion:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Most dogs per booking time"}),(0,W.jsx)(K,{label:"dogs per time",step:1,min:0,max:20,value:J.maxDogsPerSlot??0,unit:e=>e?`${e} dog${1===e?'':'s'}`:'No limit',onChange:e=>X({maxDogsPerSlot:e||void 0})})]}),(0,W.jsx)(j.Toggle,{label:"Ask about wheelchair or step-free access",value:(0,T.accessQuestionOn)(x),onChange:e=>X({accessQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Vegan and vegetarian ticks (optional for guests)",value:(0,T.dietQuestionOn)(x),onChange:e=>X({dietQuestion:e})}),(0,W.jsx)(j.Toggle,{label:"Let guests ask for a table (shown as \u2018not guaranteed\u2019)",value:!1!==J.tableRequests,onChange:e=>X({tableRequests:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Dog-friendly and step-free tables are marked on the table plan."}),e?(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Mark tables on the Table plan \u203a",onPress:()=>e('more','tableplan')}):null]}),ie=(0,T.dwellBands)(x),de=(e,s)=>X({dwellBands:ie.map((t,o)=>o===e?{...t,mins:s}:t)}),he=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"How long a table usually stays, by party size. Used for \u201cNext table free\u201d and for spacing bookings on a table."}),ie.map((e,s)=>{const t=(0,T.dwellFor)(x,9999===e.upTo?20:e.upTo,le);return(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{style:{flex:1},children:(0,T.bandLabel)(ie,s)}),(0,W.jsx)(K,{label:`table time for ${(0,T.bandLabel)(ie,s)}`,min:30,max:360,value:e.mins,unit:Q,onChange:e=>de(s,e)})]}),t.learned&&t.mins!==e.mins?(0,W.jsxs)(j.Muted,{size:12,children:["From your last ",t.samples," tables: about ",Q(t.mins)," (used for estimates)"]}):null]},s)}),(0,W.jsx)(j.Toggle,{label:"Fine-tune from how long tables really stay",value:!1!==J.dwellLearn,onChange:e=>X({dwellLearn:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Defaults: 90 min for 1\u20132 Covers, 105 min for 3\u20135, 2 hours for 6\u201319, 3 hours for 20 or more."})]}),ue=J.reservables??(0,S.reservablesOf)(x),ce=J.reservables??('anchorage'===P?ue:[]),pe=(e,s)=>X({reservables:ce.map(t=>t.id===e?{...t,...s}:t)}),ge=(0,W.jsxs)(y.default,{style:{gap:8},children:[ce.length?ce.map(e=>(0,W.jsxs)(y.default,{style:{gap:4},children:[(0,W.jsx)(j.Toggle,{label:`${e.name} can be reserved`,value:e.active,onChange:s=>pe(e.id,{active:s})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.Muted,{children:"Price"}),(0,W.jsx)(K,{label:`${e.name} price`,min:5,max:1e3,value:Math.round(e.price/100),unit:e=>`\xa3${e}`,onChange:s=>pe(e.id,{price:100*s})})]}),(0,W.jsxs)(j.Muted,{size:12,children:["Uses: ",e.uses.map(e=>`${e.qty} ${e.key}`).join(' + ')," from the counted stock. Held from the Display count and shown as \u201cReserved\u201d."]})]},e.id)):(0,W.jsx)(j.Muted,{children:"No reservable dishes yet."}),(0,W.jsx)(j.Toggle,{label:"Guests can reserve a crab or lobster on its own",value:!1!==J.reserveStock,onChange:e=>X({reserveStock:e})}),(0,W.jsx)(j.Muted,{size:13,children:"The kitchen is told about each reservation and the Head Chef taps OK."})]}),be=(0,T.regularEventsOf)(x),[me,xe]=(0,m.useState)(null),fe=e=>X({regularEvents:e}),ye=me?me.name.trim()?me.time&&!H.test(me.time)?'Start time looks wrong (use 20:00).':me.lastFood&&!H.test(me.lastFood)?'Last food orders looks wrong (use 19:00).':'once'!==me.rule.kind||_.test(me.rule.date)?'':'Date looks wrong (use 2026-12-31).':'Give it a name.':'',je=(0,W.jsxs)(y.default,{style:{gap:8},children:[be.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.name}),e.busier?(0,W.jsx)(j.Badge,{kind:"gold",label:"BUSIER"}):null,e.active?null:(0,W.jsx)(j.Badge,{kind:"neutral",label:"OFF"})]}),(0,W.jsxs)(j.Muted,{children:[(0,T.ruleText)(e.rule),e.time?` \xb7 from ${e.time}`:'',e.lastFood?` \xb7 last food orders ${e.lastFood}`:'']}),e.active?(0,W.jsxs)(j.Muted,{size:12,children:["Next: ",(0,T.nextOccurrence)(e,O)??'\u2014']}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:`event-edit-${e.id}`,onPress:()=>xe({...e})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>fe(be.filter(s=>s.id!==e.id))})]})]},e.id)),me?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Name"}),(0,W.jsx)(q,{label:"Event name",width:220,value:me.name,onChange:e=>xe({...me,name:e}),placeholder:"Open Mic Night"})]}),(0,W.jsx)(j.Muted,{children:"Repeats"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:6,children:[(0,W.jsx)(j.Chip,{label:"Last \u2026 of the month",selected:'last'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'last',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"Every week",selected:'weekly'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'weekly',weekday:'weekday'in me.rule?me.rule.weekday:0}})}),(0,W.jsx)(j.Chip,{label:"One-off date",selected:'once'===me.rule.kind,onPress:()=>xe({...me,rule:{kind:'once',date:O}})})]}),'weekday'in me.rule?(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:Y.map(e=>(0,W.jsx)(j.Chip,{label:G[e],selected:me.rule.weekday===e,onPress:()=>xe({...me,rule:{...me.rule,weekday:e}})},e))}):(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Event date",width:130,value:(0,t.slashDay)(me.rule.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(me.rule.date));xe({...me,rule:{kind:'once',date:(0,t.dayFromSlash)(s)??s}})},placeholder:"31/12/2026"})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts (optional)"}),(0,W.jsx)(q,{label:"Start time",value:me.time??'',onChange:e=>xe({...me,time:e||void 0}),placeholder:"20:00",bad:!!me.time&&!H.test(me.time)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Last food orders (optional)"}),(0,W.jsx)(q,{label:"Last food orders",value:me.lastFood??'',onChange:e=>xe({...me,lastFood:e||void 0}),placeholder:"19:00",bad:!!me.lastFood&&!H.test(me.lastFood)})]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Notes"}),(0,W.jsx)(q,{label:"Notes",width:240,value:me.notes??'',onChange:e=>xe({...me,notes:e||void 0}),placeholder:"Live music from 8pm"})]}),(0,W.jsx)(j.Toggle,{label:"Expect busier (raises the forecast)",value:me.busier,onChange:e=>xe({...me,busier:e})}),(0,W.jsx)(j.Toggle,{label:"On",value:me.active,onChange:e=>xe({...me,active:e})}),ye?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:ye}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save event",disabled:!!ye,testID:"event-save",onPress:()=>{const e={...me,name:me.name.trim()};fe(be.some(s=>s.id===e.id)?be.map(s=>s.id===e.id?e:s):[...be,e]),xe(null),ae(`Saved ${e.name}.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>xe(null)})]})]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a regular event",testID:"event-add",onPress:()=>xe({id:`ev-${Date.now().toString(36)}`,name:'',rule:{kind:'last',weekday:0},busier:!0,active:!0})}),(0,W.jsx)(j.Muted,{size:13,children:"Events show in Forecast key dates (with a Promote button), on the Today date bar, and lift the forecast when \u201cExpect busier\u201d is on."})]}),we=(0,C.hourSetsOf)(x),ke=(0,C.seasonOn)(x,new Date),[ve,Ce]=(0,m.useState)(null),[Se,Te]=(0,m.useState)(null),De=J.hourOverrides??[],Re=ve?ve.start&&!U.test(ve.start)?'Start date looks wrong (use day and month as MM-DD, e.g. 04-01 for 1 April).':ve.hours&&Object.values(ve.hours).some(e=>e&&(!H.test(e[0])||!H.test(e[1])||e[0]>=e[1]))?'Check the times: use 12:00 and 19:00, and closing must be after opening.':'':'',Me=Object.values(J.lastFoodByDay??{}).some(e=>e&&!H.test(e)),Le=[];we.some(e=>!e.hours)&&Le.push(`${we.filter(e=>!e.hours).map(e=>e.name).join(' and ')} kitchen hours`);we.filter(e=>e.hours).length>=1&&we.length>1&&we.some(e=>!e.start)&&Le.push('the date each season starts');const Pe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Muted,{size:13,children:"Kitchen (food) hours, not bar hours. The closing time is last food orders. Dining bookings are only offered inside these hours."}),Le.length?(0,W.jsxs)(j.Banner,{kind:"warn",title:"To finish setting up",children:["Please add ",Le.join(' and '),". Until then the app uses ",ke?.name??'your weekly'," hours all year."]}):null,ke?(0,W.jsxs)(j.T,{colour:D.colours.goldLight,children:["In use today: ",ke.name]}):null,we.map(e=>(0,W.jsxs)(j.Card,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",children:e.name}),ke?.id===e.id?(0,W.jsx)(j.Badge,{kind:"gold",label:"IN USE"}):e.hours?null:(0,W.jsx)(j.Badge,{kind:"amber",label:"NOT SET"})]}),(0,W.jsx)(j.Muted,{children:e.start?`Starts every year on ${e.start}`:'Start date: not set yet'}),e.hours?(0,W.jsx)(j.Muted,{size:13,children:Y.map(s=>`${G[s]} ${e.hours[s]?`${e.hours[s][0]}\u2013${e.hours[s][1]}`:'closed'}`).join(' \xb7 ')}):(0,W.jsx)(j.Muted,{size:13,children:"No hours yet."}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.hours?'Edit':`Set ${e.name} hours`,testID:`season-edit-${e.id}`,onPress:()=>Ce({...e,hours:e.hours?{...e.hours}:{...we.find(e=>e.hours)?.hours??x.kitchenHours}})})]},e.id)),ve?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.T,{weight:"semibold",children:[ve.name," hours"]}),(0,W.jsxs)(j.Row,{gap:8,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Muted,{children:"Starts every year on (MM-DD)"}),(0,W.jsx)(q,{label:"Season start date",value:ve.start??'',onChange:e=>Ce({...ve,start:e||void 0}),placeholder:"04-01",bad:!!ve.start&&!U.test(ve.start)})]}),Y.map(e=>{const s=ve.hours?.[e]??null,t=s=>Ce({...ve,hours:{...ve.hours,[e]:s}});return(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.T,{style:{width:44},children:G[e]}),(0,W.jsx)(j.Chip,{label:s?'Open':'Closed',selected:!!s,onPress:()=>t(s?null:['12:00','19:00'])}),s?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:`${T.DAYS[e]} opens`,value:s[0],width:74,onChange:e=>t([e,s[1]]),bad:!H.test(s[0])}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,value:s[1],width:74,onChange:e=>t([s[0],e]),bad:!H.test(s[1])||s[0]>=s[1]})]}):null]},e)}),Re?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:Re}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save hours",disabled:!!Re,testID:"season-save",onPress:()=>{var e;e=we.map(e=>e.id===ve.id?ve:e),X({hourSets:e}),Ce(null),ae(`Saved ${ve.name} hours.`)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Ce(null)})]})]}):null,(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Special days"}),(0,W.jsx)(j.Muted,{size:13,children:"One-off changes, e.g. closed for a private party or open late on Hogmanay."}),De.map(e=>(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsxs)(j.T,{style:{flex:1},children:[e.date,": ",e.hours?`${e.hours[0]}\u2013${e.hours[1]}`:'kitchen closed',e.note?` \xb7 ${e.note}`:'']}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>X({hourOverrides:De.filter(s=>s.date!==e.date)})})]},e.date)),Se?(0,W.jsxs)(j.Card,{highlight:D.colours.gold,children:[(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Date (DD/MM/YYYY)"}),(0,W.jsx)(q,{label:"Special day date",width:130,value:(0,t.slashDay)(Se.date),onChange:e=>{const s=(0,t.slashDate)(e,(0,t.slashDay)(Se.date));Te({...Se,date:(0,t.dayFromSlash)(s)??s})},placeholder:"31/12/2026",bad:!_.test(Se.date)})]}),(0,W.jsxs)(j.Row,{gap:6,style:{flexWrap:'wrap'},children:[(0,W.jsx)(j.Chip,{label:Se.hours?'Open':'Closed',selected:!!Se.hours,onPress:()=>Te({...Se,hours:Se.hours?null:['12:00','19:00']})}),Se.hours?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:"Opens",width:74,value:Se.hours[0],onChange:e=>Te({...Se,hours:[e,Se.hours[1]]})}),(0,W.jsx)(j.Muted,{children:"to"}),(0,W.jsx)(q,{label:"Last food orders",width:74,value:Se.hours[1],onChange:e=>Te({...Se,hours:[Se.hours[0],e]})})]}):null]}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.Muted,{children:"Note"}),(0,W.jsx)(q,{label:"Note",width:220,value:Se.note??'',onChange:e=>Te({...Se,note:e||void 0}),placeholder:"Private party"})]}),(()=>{const e=_.test(Se.date)?Se.hours&&(!H.test(Se.hours[0])||!H.test(Se.hours[1])||Se.hours[0]>=Se.hours[1])?'Check the times.':'':'Date looks wrong (use 2026-12-31).';return(0,W.jsxs)(W.Fragment,{children:[e?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:e}):null,(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Button,{small:!0,label:"Save special day",disabled:!!e,onPress:()=>{X({hourOverrides:[...De.filter(e=>e.date!==Se.date),Se].sort((e,s)=>e.date.localeCompare(s.date))}),Te(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Te(null)})]})]})})()]}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a special day",testID:"override-add",onPress:()=>Te({date:O,hours:null})}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Earlier last food orders (optional)"}),(0,W.jsx)(j.Muted,{size:13,children:"Leave blank to use the kitchen closing time. Regular events can set their own (Open Mic Night: 7pm)."}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:Y.map(e=>(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.Muted,{size:12,children:G[e]}),(0,W.jsx)(q,{label:`${T.DAYS[e]} last food orders`,width:74,value:J.lastFoodByDay?.[e]??'',placeholder:"\u2014",bad:!!J.lastFoodByDay?.[e]&&!H.test(J.lastFoodByDay[e]),onChange:s=>X({lastFoodByDay:{...J.lastFoodByDay??{},[e]:s||void 0}})})]},e))}),Me?(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"Use times like 19:00 (blank = kitchen close)."}):null,(0,W.jsx)(j.Muted,{children:"After last food orders, booking times are\u2026"}),(0,W.jsxs)(j.Row,{gap:6,children:[(0,W.jsx)(j.Chip,{label:"Offered for drinks only",selected:'drinks'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'drinks'})}),(0,W.jsx)(j.Chip,{label:"Not offered",selected:'block'===(0,T.afterLastFood)(x),onPress:()=>X({afterLastFood:'block'})})]})]}),Oe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"COVERS counter on Today (done / to come / total)",value:(0,T.coversCounterOn)(x),onChange:e=>X({coversCounter:e})}),(0,W.jsx)(j.Toggle,{label:"\u2018Next table free\u2019 when you\u2019re full",value:(0,T.nextTableOn)(x),onChange:e=>X({nextTableFree:e})}),(0,W.jsx)(j.Toggle,{label:"Show takeaway on home screens",value:(0,T.showTakeaway)(x),onChange:e=>X({showTakeaway:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Takeaway order alerts always work. With this off, takeaway figures sit in a collapsed Takeaway section."}),(0,W.jsx)(j.Muted,{size:13,children:"The flap click sound is set on each Display (Display settings), off by default."})]}),ze=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{label:"Show full gov.uk names, e.g. \u2018(substitute day)\u2019",value:!!J.holidayFullNames,onChange:e=>X({holidayFullNames:e})}),(0,W.jsx)(j.Muted,{size:13,children:"Off: \u201cChristmas Day\u201d shows on its date without \u201c(substitute day)\u201d."})]}),[Ie,$e]=(0,m.useState)(null),Ae=Ie??J.whatsapp??'',Be=!Ae.trim()||!!(0,L.waNumber)(Ae),Fe=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.T,{children:"The venue\u2019s WhatsApp number"}),(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(q,{label:"Venue WhatsApp number",testID:"adv-whatsapp-number",width:220,value:Ae,placeholder:"e.g. 01292 500123 or +44 7\u2026",bad:!Be,onChange:e=>{$e(e),e.trim()?(0,L.waNumber)(e)&&X({whatsapp:e.trim()}):X({whatsapp:void 0})}}),Ae.trim()&&Be?(0,W.jsx)(j.Badge,{kind:"gold",label:`wa.me/${(0,L.waNumber)(Ae)}`}):null]}),Be?null:(0,W.jsx)(j.T,{size:13,colour:D.colours.red,children:"That doesn\u2019t look like a phone number. Use the full number, e.g. 01292 500123 or +44 7700 900123."}),(0,W.jsx)(j.Muted,{size:13,children:"With a number here, guests see \u201cMessage us on WhatsApp\u201d on their booking confirmation, and staff and managers see \u201cWhatsApp guest\u201d on bookings that have a mobile number. Blank: all WhatsApp buttons stay hidden."}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: nothing is ever sent for you. The button opens WhatsApp with a message typed in, and the person taps Send themselves."})]}),Ee=(0,N.soldOutSettingsOf)(J.soldOut),Ne=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-soldout-auto",label:"Mark dishes sold out from the counts",value:Ee.auto,onChange:e=>X({soldOut:{...Ee,auto:e}}),a11y:"Mark dishes sold out from the live counts"}),(0,W.jsx)(j.Muted,{size:13,children:Ee.auto?'On: when a count (lobster, crab\u2026) runs out or drops below what a dish needs, every dish that uses it is marked sold out, with the reason, e.g. \u201cDeluxe Seafood Platter (no lobster)\u201d. It goes back on when the count is back up. Dishes marked by hand are left alone. Change which dishes use what in any Sold out list.':'Off: dishes are only marked sold out by hand. Dishes marked from the counts go back on.'}),(0,W.jsx)(j.T,{children:"Clear sold out dishes by themselves"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['close','morning','manual'].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-soldout-${e}`,label:N.SOLD_OUT_CLEAR_LABEL[e],selected:Ee.clear===e,onPress:()=>X({soldOut:{...Ee,clear:e}})},e))}),'manual'!==Ee.clear?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(j.T,{children:"Next morning means"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:['04:00','05:00','06:00','08:00'].map(e=>(0,W.jsx)(j.Chip,{label:e,selected:Ee.morningAt===e,onPress:()=>X({soldOut:{...Ee,morningAt:e}})},e))})]}):null,(0,W.jsx)(j.Muted,{size:13,children:'close'===Ee.clear?'Dishes go back on at the kitchen\u2019s closing time that day (from Kitchen hours). Marked after closing: the next morning.':'morning'===Ee.clear?`Dishes go back on at ${Ee.morningAt} the next morning.`:'Dishes stay sold out until someone taps Back on.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: Sold out is a reminder for staff. It shows on the Display\u2019s slim strip and in every staff app\u2019s Sold out list. CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till."})]}),We=(0,s.venueBusy)(x,le,new Date),He=(0,E.clampWeeks)(J.forecastMinWeeks),Ue=(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsxs)(y.default,{testID:"busy-level-setting",style:{alignItems:'center',gap:12},accessible:!0,accessibilityLabel:We.words,children:[(0,W.jsx)(j.T,{center:!0,size:20,weight:"semibold",children:We.words}),(0,W.jsx)(j.Stepper,{testID:"busy-covers-hour",label:"Busy level in Covers an hour",value:J.busyCoversPerHour??30,min:1,max:200,onChange:e=>X({busyCoversPerHour:e,busyLearning:!1})}),(0,W.jsx)(j.Muted,{children:"Learning starts from your chosen level; enabling it starts a fresh history period, so older trading patterns do not immediately replace your choice."}),(0,W.jsx)(j.Toggle,{label:"Learn the busy level from our real history",value:!1!==J.busyLearning,onChange:e=>X({busyLearning:e,busyLearningSince:(new Date).toISOString().slice(0,10)})}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Steady starts at half the busy level. Busy starts at the busy level. Hourly forecasts use the upper end of their range."}),(0,W.jsx)(j.T,{center:!0,size:16,children:"Learning needs at least 4 weeks, 16 trading days and 40 recorded hours. It uses the 85th percentile of recorded hourly arrivals over the last 8 weeks, including walk-ins, excluding cancellations and no-shows. Changing the number keeps your override until learning is switched on again."}),We.enough?null:(0,W.jsx)(j.T,{center:!0,size:16,children:"Not enough real hourly history to learn yet. Using the starting or owner-set level."})]}),(0,W.jsx)(j.T,{children:"History needed before forecasts show"}),(0,W.jsx)(j.Row,{wrap:!0,gap:8,children:[1,2,3,4,6,8].map(e=>(0,W.jsx)(j.Chip,{testID:`adv-forecast-weeks-${e}`,label:1===e?'1 week':`${e} weeks`,selected:He===e,onPress:()=>X({forecastMinWeeks:e})},e))}),(0,W.jsx)(j.Muted,{size:13,children:`Forecasts, expected walk-ins and labour vs sales start once CoverCharge has ${1===He?'1 week':`${He} weeks`} of your bookings (and cash-ups for sales). Until then you see what is booked and your real labour cost, never invented figures.`}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: 2 weeks is a sensible start. More weeks give steadier forecasts but take longer to begin."}),(0,W.jsx)(l.ForecastDaySettings,{r:x,set:X})]}),Ye=(0,w.depositOf)(J),Ge=e=>X({deposit:{...Ye,...e}}),qe=o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsxs)(y.default,{style:{gap:8},children:[(0,W.jsx)(j.Toggle,{testID:"adv-deposit-on",label:"Ask bigger tables for a deposit",value:Ye.on,onChange:e=>Ge({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Amount per adult"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-amount",value:Ye.perPersonPence/100,min:0,max:100,format:e=>`\xa3${e}`,onChange:e=>Ge({perPersonPence:100*e}),label:"deposit per person"})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"From a party of"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-party",value:Ye.fromParty,min:1,max:30,onChange:e=>Ge({fromParty:e}),label:"deposit from party size"})]}),(0,W.jsx)(j.T,{children:"Refundable?"}),(0,W.jsxs)(j.Row,{wrap:!0,gap:8,children:[(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-yes",label:"Yes",selected:!0===Ye.refundable,onPress:()=>Ge({refundable:!0})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-no",label:"No",selected:!1===Ye.refundable,onPress:()=>Ge({refundable:!1,cutoffHours:null})}),(0,W.jsx)(j.Chip,{testID:"adv-deposit-ref-unset",label:"Not set yet",selected:null===Ye.refundable,onPress:()=>Ge({refundable:null,cutoffHours:null})})]}),!0===Ye.refundable?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Refunded if cancelled this many hours before"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-cutoff",value:Ye.cutoffHours??0,min:0,max:168,step:6,format:e=>e?`${e} h`:'Any time',onChange:e=>Ge({cutoffHours:e||null}),label:"refund cut-off hours"})]}):null,(0,W.jsx)(j.T,{children:"Words guests see (optional)"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Deposit policy shown to guests",testID:"adv-deposit-policy",value:Ye.policy,multiline:!0,onChangeText:e=>Ge({policy:e.slice(0,600)}),placeholder:"e.g. The deposit comes off your bill on the night.",placeholderTextColor:D.colours.muted,style:{minHeight:70,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,padding:10,fontSize:15}}),(0,W.jsx)(j.Muted,{size:13,children:Ye.on&&Ye.perPersonPence>0?`Guests booking for ${Ye.fromParty} or more see: \u201c${(0,w.depositWords)(Ye,Ye.fromParty,x.name).join(' ')}\u201d`:'Off: no booking asks for a deposit.'}),(0,W.jsx)(j.Toggle,{testID:"adv-deposit-wixlinks",label:"Send website bookings deposit links for phone and walk-in bookings",a11y:"Send website bookings deposit links for phone and walk-in bookings",value:!!Ye.wixLinksOn,onChange:e=>Ge({wixLinksOn:e})}),Ye.wixLinksOn?(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{children:"Link works for"}),(0,W.jsx)(j.Stepper,{testID:"adv-deposit-linkhours",value:Ye.wixLinkHours??48,min:6,max:168,step:6,format:e=>`${e} hours`,onChange:e=>Ge({wixLinkHours:e}),label:"hours a deposit link works"})]}):null,(0,W.jsx)(j.Muted,{size:13,children:Ye.wixLinksOn?'On here, but website bookings deposit links also need the server switch, which stays off until the first \xa31 test is approved. Until then the button says so and nothing goes to website bookings.':'Off: no deposit links. Bookings work as before.'}),(0,W.jsx)(j.Muted,{size:13,children:"Tip: deposits are paid through website bookings, never in CoverCharge, and no card is saved. Guests who book on your website pay there, and the booking shows Deposit paid on website bookings by itself. For phone and walk-in bookings, tick Deposit paid once the guest has paid you, or send a website bookings deposit link. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. This does not grant access to other financial or HR information."})]}),Ke=(0,W.jsx)(k.LoyaltySettingsPanel,{}),Qe=(0,W.jsx)(se,{rid:P}),Ve=[{id:'bookings',title:'Bookings',words:'allergen allergy dog dogs cap limit access wheelchair step-free vegan vegetarian veg table request',reset:['dogQuestion','maxDogsPerSlot','accessQuestion','dietQuestion','tableRequests'],body:re,help:'adv-bookings'},{id:'times',title:'Table times',words:'dwell table time turn how long minutes party size next table free',reset:['dwellBands','dwellLearn'],body:he,help:'adv-table-times'},{id:'reserve',title:'Reservable items',words:'platter seafood crab lobster reserve price stock',reset:['reservables','reserveStock'],body:ge,help:'adv-reservable'},{id:'events',title:'Regular events',words:'open mic night music night event repeat monthly weekly promote busier forecast last food',reset:['regularEvents'],body:je,help:'adv-events'},{id:'hours',title:'Kitchen hours & last food orders',words:'hours kitchen season winter summer open close closed special day last food orders cutoff drinks',reset:['hourSets','hourOverrides','lastFoodByDay','afterLastFood'],body:Pe,help:'adv-hours'},{id:'home',title:'Display & home',words:'covers counter flip sound takeaway next table free home display',reset:['coversCounter','nextTableFree','showTakeaway'],body:Oe,help:'adv-home'},{id:'deposits',title:'Deposits',words:'deposit deposits per person party size refund refundable cut off policy paid due booking money wix link pay link online',reset:['deposit'],body:qe,help:'adv-deposits'},{id:'loyalty',title:'Loyalty: stamp card, offers & bring a friend',words:'loyalty stamp stamps card reward rewards offer offers referral refer friend bring expiry',reset:[],body:Ke,help:'adv-loyalty',noReset:!0},{id:'tableorder',title:'Order at the table',words:'order at table qr code scan phone guest menu tables areas accept first order last orders kitchen cut off print sheet pdf pay bar till',reset:[],body:o.IS_GREENSIDE?(0,W.jsx)(a.GreensideCashOnly,{}):(0,W.jsx)(r.TableOrderSettings,{rid:P,me:V}),help:'adv-table-order',noReset:!0},{id:'whatsapp',title:'WhatsApp',words:'whatsapp wa.me message chat guest phone mobile number tap',reset:['whatsapp'],body:Fe,help:'adv-whatsapp'},{id:'reminders',title:'Reminders',words:'reminder reminders break breaks chairs tables close closing shift staff nudge 6 hours law snooze later done',reset:[],body:Qe,help:'adv-reminders',onReset:()=>Z(P)},{id:'notifications',title:'Notifications',words:'notification notifications push phone scheduled order milk mills pieroni pieronis fish veg olsen rota upload remind time send',reset:[],body:(0,W.jsx)(B.NotificationsSettings,{rid:P}),help:'adv-notifications',onReset:()=>F.useNotifs.getState().resetSeeds(P)},{id:'orderlists',title:'Order lists',words:'order list lists alsons drinks cash carry trip shopping supplier logo staff add',reset:[],body:(0,W.jsx)(B.OrderListsSettings,{rid:P}),help:'adv-order-lists',onReset:()=>(0,B.resetOrderLists)(P)},{id:'tasks',title:'Tasks',words:'daily tasks library jobs checklist duties to do todo',reset:[],body:(0,W.jsx)(c.TaskLibrarySettings,{rid:P}),help:'adv-tasks',onReset:()=>b.useDailyTasks.getState().resetLibrary(P)},{id:'cashup',title:'Cash up',words:'cash up sheet takings till float card cash tips weekly sales report pos printout figures fields vat covers',reset:[],body:(0,W.jsx)(p.CashUpSettings,{rid:P}),help:'adv-cashup',onReset:()=>g.useCashUp.getState().resetFields(P)},{id:'tips',title:'Tips',words:'tips pot today tips show hide staff apps payout correction',reset:[],body:(0,W.jsx)(p.TipsSettings,{rid:P}),help:'adv-tips',onReset:()=>g.useCashUp.getState().setShow(P,{showToday:!0,showPot:!0})},{id:'clockarea',title:'Clock-in area',words:'clock in out geofence location area radius gps break forgot forgotten rota visiting map',reset:[],body:(0,W.jsx)(B.ClockAreaSettings,{rid:P,me:V}),help:'adv-clock-area',onReset:()=>(0,B.resetClockArea)(P,V)},{id:'checkout',title:'Shift check-out & question board',words:'check out checkout morale mood staffing staff enough overstaffed survey anonymous question board vote shout out shoutout wellbeing hr wording',reset:['hr'],body:(0,W.jsx)(u.HrSettingsCard,{rid:P}),help:'adv-checkout'},{id:'forecast',title:'Forecast history',words:'forecast history weeks estimate walk-ins opening hours minimum covers floor saturday sunday labour sales example figures not enough history',reset:['forecastMinWeeks'],body:Ue,help:'adv-forecast'},{id:'soldout',title:'Sold out reminders',words:'sold out 86 eighty six run out ran out back on clear end of service morning display strip auto automatic counts shellfish lobster crab platter link uses',reset:['soldOut'],body:Ne,help:'adv-soldout'},{id:'tablegrid',title:'Table plan grid',words:'table plan grid snap line up align tidy tables floor layout guides spacing restore',reset:[],body:(0,W.jsx)(I.GridSettings,{rid:P,me:V}),help:'adv-tablegrid',onReset:()=>{const e=A.useFloor.getState().settings[P];A.useFloor.getState().setSettings(P,{...A.DEFAULT_SETTINGS,...e??{},gridSnap:!0,gridSize:25})}},{id:'printers',title:'Printers',words:'print printer printers printing ticket tickets kitchen ticket docket receipt epson star bluetooth wifi reprint takeaway auto front of house copies',reset:[],body:(0,W.jsx)($.PrintersSettings,{rid:P,go:e}),help:'adv-printers',onReset:()=>{const e=A.useFloor.getState().settings[P];e&&A.useFloor.getState().setSettings(P,{...e,printing:void 0})}},{id:'blocks',title:'Block bookings: lunch, dinner and website bookings',words:'block blocks blocked pause close lunch dinner service times wix website online push',reset:[],noReset:!0,body:(0,W.jsx)(d.BlockSettings,{rid:P}),help:'adv-blocks'},{id:'giftqr',title:'Gift cards on the Display',words:'gift card cards voucher qr code display buy sell wix website page link',reset:[],noReset:!0,body:(0,W.jsx)(i.GiftQrSettings,{rid:P}),help:'adv-giftqr'},{id:'holidays',title:'Holiday names',words:'bank holiday substitute day names',reset:['holidayFullNames'],body:ze,help:'adv-holidays'}],Ze=ee.trim().toLowerCase(),Je=(0,m.useMemo)(()=>Ve.filter(e=>!Ze||`${e.title} ${e.words}`.toLowerCase().includes(Ze)),[Ze,Ve]);return(0,W.jsxs)(y.default,{style:{gap:12},testID:"advanced-settings",children:[(0,W.jsx)(j.Muted,{children:"Owners and managers only. Changes are shared with your team\u2019s devices."}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Search settings",testID:"advanced-search",value:ee,onChangeText:te,placeholder:"Search, e.g. dogs, Open Mic Night, hours",placeholderTextColor:D.colours.muted,style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:D.colours.accentBorder,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:12,fontSize:16}}),oe?(0,W.jsx)(j.Banner,{kind:"success",title:oe}):null,Je.length?null:(0,W.jsxs)(j.Muted,{children:["No settings match \u201c",ee,"\u201d."]}),Je.map(s=>(0,W.jsx)(j.Card,{children:(0,W.jsxs)(y.default,{testID:`adv-${s.id}`,style:{gap:10},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{size:17,weight:"semibold",colour:D.colours.gold,children:s.title}),e?(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`Help: ${s.title}`,onPress:()=>e('more','help'),hitSlop:8,style:{minHeight:44,minWidth:44,justifyContent:'center'},children:(0,W.jsx)(j.T,{colour:D.colours.muted,children:"? Help"})}):null]}),s.body,s.noReset?null:(0,W.jsx)(j.Row,{style:{justifyContent:'flex-end'},children:(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Reset to default",testID:`reset-${s.id}`,onPress:()=>ne(s)})})]})},s.id))]})},Object.defineProperty(_e,"ADVANCED_DEFAULTS",{enumerable:!0,get:function(){return V}}),_e.SeasonsTodo=function({go:e}){const{r:s}=(0,R.useCtx)(6e4),t=(0,C.hourSetsOf)(s),o=[],a=t.filter(e=>!e.hours).map(e=>e.name);a.length&&o.push(`${a.join(' and ')} kitchen hours`);t.length>1&&t.some(e=>!e.start)&&o.push('the date each season starts');return o.length?(0,W.jsx)(j.Card,{onPress:()=>e('more','advanced'),highlight:D.colours.gold,children:(0,W.jsxs)(y.default,{testID:"seasons-todo",style:{gap:4},children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},children:[(0,W.jsx)(j.T,{weight:"semibold",colour:D.colours.gold,children:"Setup checklist: kitchen hours"}),(0,W.jsx)(j.T,{colour:D.colours.muted,children:"\u203a"})]}),(0,W.jsxs)(j.Muted,{size:13,children:["Please add ",o.join(' and ')," (Settings \u203a Advanced \u203a Kitchen hours). Until then the app uses the Winter hours all year."]})]})}):null};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),g=_r(_d[13]),b=_r(_d[14]),m=_r(_d[15]),x=e(m),f=e(_r(_d[16])),y=e(_r(_d[17])),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),v=_r(_d[21]),C=_r(_d[22]),S=_r(_d[23]),T=_r(_d[24]),D=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),L=_r(_d[28]),P=_r(_d[29]),O=_r(_d[30]),z=_r(_d[31]),I=_r(_d[32]),$=_r(_d[33]),A=_r(_d[34]),B=_r(_d[35]),F=_r(_d[36]),E=_r(_d[37]),N=_r(_d[38]),W=_r(_d[39]);const H=/^([01]\d|2[0-3]):[0-5]\d$/,U=/^(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,_=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,Y=[1,2,3,4,5,6,0],G=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];function q({value:e,onChange:s,placeholder:t,label:o,width:a=90,bad:l,testID:r}){return(0,W.jsx)(n.TextInput,{accessibilityLabel:o,testID:r,value:e,onChangeText:s,placeholder:t,placeholderTextColor:D.colours.muted,style:{width:a,minHeight:44,borderRadius:10,borderWidth:1,borderColor:l?D.colours.red:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}})}function K({value:e,onChange:s,min:t,max:o,unit:a,label:n,step:l=5}){const r=(a,l)=>(0,W.jsx)(f.default,{accessibilityRole:"button",accessibilityLabel:`${l<0?'Less':'More'}: ${n}`,onPress:()=>s(Math.min(o,Math.max(t,e+l))),style:{width:44,height:44,borderRadius:10,borderWidth:1,borderColor:D.colours.accentBorder,alignItems:'center',justifyContent:'center'},children:(0,W.jsx)(j.T,{size:20,colour:D.colours.gold,children:a})});return(0,W.jsxs)(j.Row,{gap:8,children:[r('\u2212',-l),(0,W.jsx)(j.T,{weight:"semibold",style:{minWidth:76,textAlign:'center'},children:a(e)}),r('+',l)]})}const Q=e=>e%60?`${Math.floor(e/60)}h ${e%60}m`:`${e/60} hour${60===e?'':'s'}`;const V={DEFAULT_DWELL:T.DEFAULT_DWELL,ANCHORAGE_SEASONS:C.ANCHORAGE_SEASONS};function Z(e){const s=P.useReminders.getState();s.ensure(e),s.resetRules(e),s.resetReminder((0,P.chairsId)(e))}const J=[1,2,3,4,5,6,0],X=e=>`${7===e.days.length?'Every day':J.filter(s=>e.days.includes(s)).map(e=>O.DAY_NAMES[e]).join(', ')||'No days'} at ${e.time} (UK time) \xb7 ${O.AUDIENCE_LABEL[e.audience]}`;function ee({init:e,onSave:s,onCancel:t}){const[o,a]=(0,m.useState)(e.text),[l,r]=(0,m.useState)(e.days),[i,d]=(0,m.useState)(e.time),[h,u]=(0,m.useState)(e.audience),c=o.trim().length>1&&l.length>0&&(0,O.validTime)(i);return(0,W.jsxs)(y.default,{testID:"reminder-editor",style:{gap:8,borderWidth:1,borderColor:D.colours.accentBorder,borderRadius:12,padding:10},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"What it says"}),(0,W.jsx)(n.TextInput,{accessibilityLabel:"Reminder wording",testID:"reminder-text",value:o,onChangeText:a,maxLength:120,placeholder:"e.g. Time to put the chairs up on the tables",placeholderTextColor:D.colours.muted,style:{minHeight:44,borderRadius:10,borderWidth:1,borderColor:D.colours.hairline,backgroundColor:D.colours.surface2,color:D.colours.text,paddingHorizontal:10,fontSize:15}}),(0,W.jsx)(j.T,{weight:"semibold",children:"Days"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:J.map(e=>(0,W.jsx)(j.Chip,{label:O.DAY_NAMES[e],selected:l.includes(e),onPress:()=>r(l.includes(e)?l.filter(s=>s!==e):[...l,e])},e))}),(0,W.jsxs)(j.Row,{gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Time (UK)"}),(0,W.jsx)(q,{label:"Reminder time",testID:"reminder-time",value:i,onChange:d,placeholder:"21:00",bad:!(0,O.validTime)(i)})]}),(0,W.jsx)(j.T,{weight:"semibold",children:"Who sees it"}),(0,W.jsx)(j.Row,{wrap:!0,gap:6,children:['all','foh','kitchen'].map(e=>(0,W.jsx)(j.Chip,{label:O.AUDIENCE_LABEL[e],selected:h===e,onPress:()=>u(e)},e))}),c?null:(0,W.jsx)(j.Muted,{size:13,children:"Add the wording, at least one day and a time like 21:00."}),(0,W.jsxs)(j.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:t}),(0,W.jsx)(j.Button,{small:!0,label:"Save reminder",testID:"reminder-save",disabled:!c,onPress:()=>s({text:o.trim(),days:[...l].sort(),time:i,audience:h})})]})]})}function se({rid:e}){x.default.useEffect(()=>{P.useReminders.getState().ensure(e)},[e]);const s=(0,P.useReminders)(e=>e.reminders),t=s.filter(s=>s.rid===e&&!s.removed),o=(0,P.useReminders)(s=>s.rules[e]),a=(0,O.clampRules)(o??O.DEFAULT_BREAK_RULES),n=(0,P.useReminders)(e=>e.done).filter(s=>s.rid===e).slice(0,5),l=(0,z.useOwner)(e=>e.staff),r=P.useReminders.getState(),[i,d]=(0,m.useState)(null),[h,u]=(0,m.useState)(null),c=s=>r.setRules(e,s);return(0,W.jsxs)(y.default,{style:{gap:10},testID:"reminders-settings",children:[(0,W.jsx)(j.Muted,{size:13,children:"Reminders slide up on the phones of staff who are on shift right now (clocked in, or on the rota at that time), in the Staff and Head Chef apps, while the app is open."}),(0,W.jsx)(j.T,{weight:"semibold",children:"Break reminders"}),(0,W.jsx)(j.Toggle,{label:"Remind staff to take their break",value:a.on,onChange:e=>c({on:e})}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{center:!0,style:{width:'100%'},children:"First reminder, if the rota has no break time"}),(0,W.jsx)(K,{label:"first break reminder",step:15,min:30,max:O.LEGAL_LIMIT_MINS,value:a.afterMins,unit:e=>`${Q(e)} in`,onChange:e=>c({afterMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"Remind once more after"}),(0,W.jsx)(K,{label:"second break reminder",step:5,min:5,max:120,value:a.repeatMins,unit:e=>`${e} min`,onChange:e=>c({repeatMins:e})})]}),(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},wrap:!0,children:[(0,W.jsx)(j.T,{style:{flex:1},children:"\u2018Later\u2019 hides it for"}),(0,W.jsx)(K,{label:"snooze",step:5,min:5,max:60,value:a.snoozeMins,unit:e=>`${e} min`,onChange:e=>c({snoozeMins:e})})]}),(0,W.jsxs)(j.Muted,{size:13,children:["How it works: if the shift on the rota has a break time, the reminder comes at that time. If not, it comes ",Q(a.afterMins)," after they clock in (or after the shift starts, if they haven\u2019t clocked in). If they still haven\u2019t started a break, it comes once more ",a.repeatMins," minutes later, and again at 6 hours. Nobody works more than 6 hours without a reminder: UK law says a shift over 6 hours needs a 20-minute break. \u2018Start break\u2019 starts their break, the same as on the clock screen."]}),(0,W.jsx)(j.T,{weight:"semibold",style:{marginTop:6},children:"Venue reminders"}),t.map(e=>(0,W.jsx)(y.default,{testID:`reminder-${e.builtIn??e.id}`,style:{gap:6,borderBottomWidth:1,borderColor:D.colours.hairline,paddingBottom:8},children:i===e.id?(0,W.jsx)(ee,{init:e,onCancel:()=>d(null),onSave:s=>{r.update(e.id,s),d(null)}}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(j.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,W.jsx)(j.T,{weight:"semibold",style:{flex:1},children:e.text}),e.paused?(0,W.jsx)(j.Badge,{kind:"amber",label:"PAUSED"}):null]}),(0,W.jsx)(j.Muted,{size:13,children:X(e)}),h===e.id?(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.T,{size:14,style:{flex:1},children:"Delete this reminder?"}),(0,W.jsx)(j.Button,{small:!0,kind:"danger",label:"Yes, delete it",onPress:()=>{r.remove(e.id),u(null)}}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>u(null)})]}):(0,W.jsxs)(j.Row,{gap:8,wrap:!0,children:[(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"Edit",testID:"reminder-edit",onPress:()=>d(e.id)}),(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:e.paused?'Resume':'Pause',onPress:()=>r.update(e.id,{paused:!e.paused})}),(0,W.jsx)(j.Button,{small:!0,kind:"ghost",label:"Delete",onPress:()=>u(e.id)})]})]})},e.id)),t.length?null:(0,W.jsx)(j.Muted,{children:"No venue reminders. Add one below, or Reset to default to bring back \u201cchairs up\u201d."}),'new'===i?(0,W.jsx)(ee,{init:{text:'',days:[5,6],time:'21:00',audience:'all'},onCancel:()=>d(null),onSave:s=>{r.add(e,s),d(null)}}):(0,W.jsx)(j.Button,{small:!0,kind:"secondary",label:"\uff0b Add a reminder",testID:"reminder-add",onPress:()=>d('new')}),n.length?(0,W.jsxs)(y.default,{style:{gap:2},children:[(0,W.jsx)(j.T,{weight:"semibold",children:"Recently done"}),n.map(e=>(0,W.jsxs)(j.Muted,{size:13,children:[new Date(e.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})," \xb7 ",(l.find(s=>s.id===e.staffRef)?.name??e.staffName).replace(' (example)','')," \xb7 ",s.find(s=>s.id===e.reminderId)?.text??'Reminder']},e.id))]}):null,(0,W.jsxs)(j.Muted,{size:13,children:["Tip: once anyone taps Done, the reminder goes away for everyone that day, and you can see who did it here. \u2018Later\u2019 hides it on that phone for ",a.snoozeMins," minutes. Reset to default puts back the break times and \u201cchairs up\u201d (",(0,O.defaultChairs)('x',e).days.map(e=>O.DAY_NAMES[e]).join(' and '),", 21:00); your own reminders stay."]}),(0,W.jsx)(j.Muted,{size:13,children:"Reminders show while the app is open. Phones with the app closed don\u2019t get them yet."})]})}},1436,[1162,1063,5,1418,827,1437,1438,1440,1441,1442,1220,1061,1062,1039,1044,34,402,102,794,14,1443,831,878,1101,877,821,1088,874,1204,1009,1010,891,1444,1388,1029,1111,1036,1164,980,25]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ForecastDaySettings=function({r:t,set:s}){const c=(0,o.forecastHoursOf)(t),y=(0,o.minCoversOf)(t),v=t.settings.minCoversNote??('anchorage'!==t.id||t.settings.minCoversByDay?void 0:o.MIN_COVERS_NOTE),x=(e,t,n)=>{const i=c[e]??['12:00','22:00'],o=0===t?[n,i[1]]:[i[0],n];h(o[0])&&h(o[1])&&s({forecastHours:{...c,[e]:o}})},f=(e,t)=>{const n=''===t.trim()?null:Math.max(0,Math.min(999,Math.round(Number(t)||0)));s({minCoversByDay:{...y,[e]:n||null},minCoversNote:void 0})};return(0,u.jsxs)(n.default,{style:{gap:8},testID:"forecast-day-settings",children:[(0,u.jsx)(i.T,{children:"Opening hours shown on the forecast"}),(0,u.jsx)(i.Muted,{size:13,children:"The hours your bar or dining room is open, so the forecast covers the whole day, not just kitchen hours. Any hour with a booking always shows."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),c[t]?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(e.TextInput,{testID:`fc-open-${t}`,accessibilityLabel:`${r.DAYS[t]} opens`,defaultValue:c[t][0],onEndEditing:e=>x(t,0,e.nativeEvent.text),onBlur:e=>x(t,0,e?.target?.value??c[t][0]),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.T,{size:15,children:"to"}),(0,u.jsx)(e.TextInput,{testID:`fc-close-${t}`,accessibilityLabel:`${r.DAYS[t]} closes`,defaultValue:c[t][1],onEndEditing:e=>x(t,1,e.nativeEvent.text),onBlur:e=>x(t,1,e?.target?.value??c[t][1]),style:[i.styles.input,{width:90,minHeight:44}]})]}):(0,u.jsx)(i.Muted,{children:"Kitchen hours"})]},`h${t}`)),(0,u.jsx)(i.T,{style:{marginTop:8},children:"Usual minimum Covers"}),(0,u.jsx)(i.Muted,{size:13,children:"The fewest Covers you always do on that day. The forecast never shows less. Leave blank if you have no usual minimum."}),d.map(t=>(0,u.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,u.jsx)(i.T,{center:!0,size:15,style:{width:'100%'},children:r.DAYS[t]}),(0,u.jsx)(e.TextInput,{testID:`fc-min-${t}`,accessibilityLabel:`${r.DAYS[t]} usual minimum Covers`,keyboardType:"number-pad",defaultValue:y[t]?String(y[t]):'',placeholder:"Blank",placeholderTextColor:"#7D776C",onEndEditing:e=>f(t,e.nativeEvent.text),onBlur:e=>f(t,e?.target?.value??''),style:[i.styles.input,{width:90,minHeight:44}]}),(0,u.jsx)(i.Muted,{children:"Covers"})]},`m${t}`)),v?(0,u.jsxs)(i.T,{size:13,colour:l.colours.goldLight,children:["Set from ",v,"."]}):null,(0,u.jsx)(i.Muted,{size:13,children:"Tip: use a number you are sure of, such as the quietest Saturday in the last few months."})]})};var e=_r(_d[0]);_r(_d[1]);var t,s=_r(_d[2]),n=(t=s)&&t.__esModule?t:{default:t},i=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),u=_r(_d[7]);const d=[1,2,3,4,5,6,0],h=e=>/^([01]\d|2[0-3]):[0-5]\d$/.test(e)},1437,[827,34,102,794,1161,877,821,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderSettings=function({rid:s,me:a}){const k=(0,r.useRestaurant)(s),v=(0,o.usePlan)(s),T=(0,h.staffServer)(),R=!T||(0,b.can)('venue.settings'),[C,S]=(0,t.useState)({...c.TABLE_ORDER_DEFAULT}),[N,P]=(0,t.useState)([]),[$,D]=(0,t.useState)(null),[M,Q]=(0,t.useState)(!1),[O,B]=(0,t.useState)(!1),[A,I]=(0,t.useState)(null),[_,L]=(0,t.useState)(null),[F,E]=(0,t.useState)('sticker'),G=(0,t.useCallback)(async()=>{if(T)try{S(await(0,u.loadTableSettings)()),B(!1),(0,b.can)('venue.settings')&&(P(await(0,u.listTableCodes)()),I(await(0,u.tableReadiness)().catch(()=>null)))}catch(e){D({kind:'danger',t:`Couldn't load: ${e.message}`})}},[T]);(0,t.useEffect)(()=>(G(),T?(0,u.watchTableSettings)(()=>{O||G()}):void 0),[G]);const z=e=>{S(t=>({...t,...e})),B(!0),D(null)},W=v.tables.map(e=>e.name).filter(c.isTableNo).sort((e,t)=>Number(e)-Number(t)),H=C.tables??W,U=e=>z({tables:H.includes(e)?H.filter(t=>t!==e):[...H,e].sort((e,t)=>Number(e)-Number(t))}),Y=e=>v.tables.filter(t=>t.areaId===e).map(e=>e.name).filter(c.isTableNo),q=e=>{const t=Y(e);return t.length>0&&t.every(e=>H.includes(e))},J=e=>{const t=Y(e),s=q(e);z({tables:s?H.filter(e=>!t.includes(e)):[...new Set([...H,...t])].sort((e,t)=>Number(e)-Number(t))})},K=async()=>{Q(!0);try{const e=C.tables&&C.tables.length===W.length&&W.every(e=>C.tables.includes(e))?null:C.tables;T&&await(0,u.saveTableSettings)({...C,tables:e},a),r.useStore.getState().updateSettings(s,{orderAtTable:C.on}),B(!1),D({kind:'success',t:C.on?'Saved. Guests can order from the tables you picked.':'Saved. Order at the table is off.'})}catch(e){D({kind:'danger',t:`Not saved: ${e.message}`})}Q(!1)},V=async()=>{Q(!0);try{const e=await(0,u.makeTableCodes)(H);P(await(0,u.listTableCodes)()),D({kind:'success',t:e.made?`Made ${e.made} new QR code${e.made>1?'s':''}.`:'Every table you picked already has a code.'})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},X=async t=>{Q(!0),L(null);try{await(0,u.renewTableCode)(t),P(await(0,u.listTableCodes)()),D({kind:'warn',t:`Table ${(0,e.tableNumbers)(t)} has a new code. The old QR on that table has stopped working, so print this one and swap it.`})}catch(e){D({kind:'danger',t:e.message})}Q(!1)},Z=e=>{const t=N.filter(t=>e?t.table===e:H.includes(t.table)),s=(0,p.printQrSheet)(k?.name??'Our venue',t.map(e=>({table:e.table,link:(0,c.tableLink)(w(),e.token)})),{logo:`${w()}/customer-app/brand-logo.png`,size:F});D(s?{kind:'success',t:'QR sheet opened. Choose "Save as PDF" or your printer.'}:{kind:'warn',t:'Printing works from the web app on a computer or tablet.'})};return T?(0,f.jsxs)(n.default,{style:{gap:10},testID:"table-order-settings",children:[(0,f.jsx)(l.Muted,{center:!0,children:"Tip: start with a few tables and keep \"Staff accept the first order\" on. Guests pay at the bar or with their server, and the kitchen gets the order like any other ticket."}),A&&A.priced>0&&A.signedz({on:e}),disabled:!R,testID:"tos-on"}),(0,f.jsx)(l.Toggle,{label:"Staff accept the first order from each new phone",value:C.staffAccept,onChange:e=>z({staffAccept:e}),disabled:!R}),(0,f.jsx)(l.Muted,{children:"On is safer: someone sat at the table can't be told apart from someone who photographed the QR. After staff accept one order, that phone's next orders go straight to the kitchen for 12 hours."}),(0,f.jsx)(l.T,{weight:"semibold",children:"Which areas and tables"}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:v.areas.filter(e=>Y(e.id).length).map(e=>(0,f.jsx)(l.Chip,{label:e.name,selected:q(e.id),onPress:R?()=>J(e.id):void 0},e.id))}),(0,f.jsx)(l.Row,{wrap:!0,gap:6,children:W.map(t=>(0,f.jsx)(l.Chip,{label:`${(0,e.tableNumbers)(t)}`,selected:H.includes(t),onPress:R?()=>U(t):void 0},t))}),(0,f.jsxs)(l.Muted,{children:[C.tables?`${H.length} of ${W.length} tables`:'All tables',"."]}),(0,f.jsx)(l.T,{weight:"semibold",children:"Hours"}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Opens at"}),(0,f.jsx)(l.Stepper,{label:"Opens at",value:j(C.openFrom),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({openFrom:x(e)})})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Last orders (kitchen cut-off)"}),(0,f.jsx)(l.Stepper,{label:"Last orders",value:j(C.lastOrders),min:-15,max:1425,step:15,format:y,onChange:e=>R&&z({lastOrders:x(e)})})]}),(0,f.jsx)(l.Muted,{children:(0,c.hoursWords)(C)}),(0,f.jsx)(l.Field,{label:"Note guests see above the menu (optional)",value:C.guestTip,onChangeText:e=>z({guestTip:e.slice(0,160)}),editable:R,placeholder:"e.g. Drinks are ordered at the bar."}),R?(0,f.jsx)(l.Button,{label:M?'Saving\u2026':'Save order at the table',disabled:M||!O,onPress:()=>{K()},testID:"tos-save"}):null,$?(0,f.jsx)(l.Banner,{kind:$.kind,children:$.t}):null,R?(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:"QR codes"}),(0,f.jsx)(l.Badge,{kind:"gold",label:`${N.length} made`})]}),(0,f.jsx)(l.Muted,{children:"Each table gets its own code. A guest can only order with the code that's on the table."}),(0,f.jsx)(l.T,{center:!0,size:13,weight:"semibold",children:"Card size"}),(0,f.jsx)(n.default,{testID:"tos-card-size",children:(0,f.jsx)(l.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:Object.keys(p.QR_CARD).map(e=>(0,f.jsx)(l.Chip,{label:p.QR_CARD[e].label,selected:F===e,onPress:()=>E(e)},e))})}),(0,f.jsxs)(l.Muted,{center:!0,children:['sticker'===F?'For stickers and small QR table stands: 20 to a page, QR 30 mm.':'For table stand cards (about 2 \xd7 3 in): 16 to a page, QR 34 mm, with the short link.'," Print at 100% (actual size), then cut along the dashed lines."]}),(0,f.jsxs)(l.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,f.jsx)(l.Button,{small:!0,label:"Make codes for the tables picked",disabled:M,onPress:()=>{V()}}),(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Print all QR cards",disabled:!N.length,onPress:()=>Z(),testID:"tos-print"})]}),N.map(t=>(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(l.T,{children:["Table ",(0,e.tableNumbers)(t.table),H.includes(t.table)?'':' (not taking orders)']}),(0,f.jsxs)(l.Row,{gap:6,children:[(0,f.jsx)(l.Button,{small:!0,kind:"secondary",label:"Reprint",accessibilityLabel:`Reprint the QR for table ${t.table}`,disabled:M,onPress:()=>Z(t.table),testID:`tos-reprint-${t.table}`}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"New code",accessibilityLabel:`New code for table ${t.table}`,disabled:M,onPress:()=>L(t.table),testID:`tos-renew-${t.table}`})]})]},t.table)),(0,f.jsx)(l.Muted,{children:"Lost or copied QR? Make a new code for that table; the old one stops working."})]}):null,(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.T,{center:!0,weight:"semibold",children:"Paying"}),(0,f.jsx)(l.Muted,{center:!0,children:"Guests pay at the bar or with their server. Paying by card from the phone is coming later; no card details are asked for."})]}),_?(0,f.jsxs)(l.Sheet,{visible:!0,onClose:()=>L(null),title:`New code for table ${(0,e.tableNumbers)(_)}?`,maxWidth:520,testID:"tos-renew-confirm",children:[(0,f.jsxs)(l.T,{center:!0,children:["The QR code on table ",(0,e.tableNumbers)(_)," stops working straight away. Guests who scan the old one are told to ask a member of staff."]}),(0,f.jsx)(l.Muted,{center:!0,children:"Print the new one and swap it on the table."}),(0,f.jsx)(l.Button,{label:"Yes, make a new code",onPress:()=>{X(_)},testID:"tos-renew-yes"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Cancel",onPress:()=>L(null)})]}):null]}):(0,f.jsx)(l.Banner,{kind:"demo",title:"Needs the venue connection",children:"Order at the table runs on the server, so it works once this app is connected to your venue. Nothing here is sent anywhere."})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var s,a=_r(d[3]),n=(s=a)&&s.__esModule?s:{default:s},l=_r(d[4]),r=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),b=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]);const w=()=>'undefined'!=typeof window&&/^https:/.test(window.location.origin)?window.location.origin:"https://covercharge-apps.static.hf.space",j=e=>e?60*Number(e.slice(0,2))+Number(e.slice(3,5)):-15,x=e=>e<0?null:(0,c.hm)(e),y=e=>e<0?'Not set':(0,c.hm)(e)},1438,[860,34,236,102,794,874,1029,1175,1271,987,1344,1439,25]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.qrSvg=n,Object.defineProperty(e,"QR_CARD",{enumerable:!0,get:function(){return r}}),e.qrSheetHtml=s,e.printQrSheet=function(t,o,i={}){if('undefined'==typeof window||!window.open)return!1;const n=window.open('','_blank');return!!n&&(n.document.write(s(t,o,i)),n.document.close(),n.focus(),setTimeout(()=>{try{n.print()}catch{}},800),!0)};var t=_r(_d[0]);const o=_r(_d[1]),i=t=>t.replace(/[&<>"']/g,t=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[t]));function n(t,i=220){const n=o.create(t,{errorCorrectionLevel:'M'}).modules,r=n.size,s=r+8;let l='';for(let t=0;t`}const r={sticker:{w:50,h:50,qr:30,cols:4,rows:5,label:'Stickers 50 \xd7 50 mm'},stand:{w:50,h:70,qr:34,cols:4,rows:4,label:'Stand cards 50 \xd7 70 mm'}};function s(o,s,l={}){const d=l.size??'sticker',c=r[d],m='stand'===d,h=l.logo?``:'',f=o=>`
${h}
${i((0,t.tableNumbersA11y)(o.table))}
${n(o.link,240)}
Scan to order
${m?`
Pay at the bar or with your server
${i(o.link.replace(/^https?:\/\//,''))}
`:''}
`,p=c.cols*c.rows,u=[];for(let t=0;t${s.slice(t,t+p).map(f).join('')}`);return`${i(o)} table QR codes \xb7 ${c.label}

${i(o)} \xb7 ${c.label} \xb7 cut along the dashed lines \xb7 print at 100% (actual size, not "fit to page")

${u.join('')}`}},1439,[860,1295]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftQrSettings=function({rid:e}){const s=(0,n.useFloor)(t=>t.settings[e]),h={...n.DEFAULT_SETTINGS,...s??{}},[p,y]=(0,t.useState)(h.giftQrUrl??''),[Q,b]=(0,t.useState)(''),S=t=>n.useFloor.getState().setSettings(e,{...h,...t}),x=(0,u.giftQrUrlOk)(p);return(0,c.jsxs)(l.default,{style:{gap:8},testID:"adv-giftqr-panel",children:[(0,c.jsx)(o.Toggle,{testID:"giftqr-on",label:"Show \u201cBuy a gift card\u201d on the Display",value:!!h.giftQrOn,disabled:!h.giftQrOn&&!(0,u.giftQrUrlOk)(h.giftQrUrl),onChange:e=>{S({giftQrOn:e}),b(e?'On: the Display shows Buy a gift card.':'Off: the Display hides Buy a gift card.')}}),(0,c.jsx)(o.Field,{testID:"giftqr-url",label:"Your gift card page (https://\u2026)",value:p,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>{y(e.slice(0,u.GIFT_QR_MAX)),b('')},placeholder:"https://www.example.com/gift-card"}),p&&!x?(0,c.jsx)(o.T,{size:13,colour:f.colours.amber,children:"Use the full address starting https://"}):null,(0,c.jsx)(o.Button,{small:!0,label:"Save the page address",testID:"giftqr-save",disabled:!x||p.trim()===(h.giftQrUrl??''),onPress:()=>{S({giftQrUrl:p.trim()}),b('Saved. The Display QR opens this page.')}}),Q?(0,c.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(o.Muted,{children:Q})}):null,(0,c.jsx)(o.Muted,{size:13,children:"Gift cards are sold through your website. The Display shows only a QR code and \u201cScan to buy a gift card on your phone\u201d: no prices or balances."})]})};var e,t=r(d[0]),s=r(d[1]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),u=r(d[4]),f=r(d[5]),c=r(d[6])},1440,[34,102,794,1029,1353,821,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"websiteBlocksSynced",{enumerable:!0,get:function(){return m}}),_e.BlockSettings=function({rid:e}){const n=(0,s.useFloor)(n=>n.settings[e]),h={...s.DEFAULT_SETTINGS,...n??{}},b=h.serviceWindows??{},w=b.lunch??['12:00','17:00'],f=b.dinner??['17:00','21:00'],k=(n,t)=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:{...b,[n]:t}}),y=(e,n,t,s)=>(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{style:{flex:1},children:e}),(0,u.jsx)(o.Stepper,{testID:s,label:e,value:(0,l.toMins)(n),min:360,max:1425,step:15,format:e=>(0,c.fmt12)((0,l.fromMins)(e)),onChange:t})]});return(0,u.jsxs)(t.default,{style:{gap:8},testID:"adv-blocks-panel",children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Lunch and dinner"}),(0,u.jsx)(o.Muted,{children:"Used by Block now (the Lunch and Dinner buttons) and Spend per head. Always kept inside the kitchen hours for the day."}),b.lunch||b.dinner?null:(0,u.jsx)(o.Muted,{testID:"sw-usual",children:"Usual times now: lunch from opening to 5:00pm, dinner from 5:00pm to close. Change a time below to set your own."}),y('Lunch starts',w[0],e=>k('lunch',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(w[1])-15)),w[1]]),'sw-lunch-from'),y('Lunch ends',w[1],e=>k('lunch',[w[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(w[0])+15))]),'sw-lunch-to'),y('Dinner starts',f[0],e=>k('dinner',[(0,l.fromMins)(Math.min(e,(0,l.toMins)(f[1])-15)),f[1]]),'sw-dinner-from'),y('Dinner ends',f[1],e=>k('dinner',[f[0],(0,l.fromMins)(Math.max(e,(0,l.toMins)(f[0])+15))]),'sw-dinner-to'),b.lunch||b.dinner?(0,u.jsx)(o.Button,{small:!0,kind:"ghost",label:"Use the usual times",onPress:()=>s.useFloor.getState().setSettings(e,{...h,serviceWindows:void 0})}):null,(0,u.jsx)(o.T,{weight:"semibold",style:{marginTop:8},children:"Block on website bookings too"}),m(e)?(0,u.jsx)(o.Muted,{testID:"wix-block-sync-on",children:"On. A whole-day or time block made in CoverCharge also closes those times for online booking on your website, editing or removing it updates the website, and blocks made on the website show here too. Website bookings can only close the whole venue, not one area or some tables."}):(0,u.jsx)(o.Muted,{testID:"wix-block-sync-off",children:"Website bookings aren\u2019t connected for this venue yet. Once they are, a whole-day or time block made in CoverCharge also closes those times for online booking on your website. Until then, the website can still take bookings in a blocked time, so check those."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);const m=e=>!h.IS_ISOLATED_VENUE&&'anchorage'===e},1441,[34,102,794,1029,858,1396,5,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"advancedPrefill",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"takeAdvancedPrefill",{enumerable:!0,get:function(){return n}});const t={q:''},n=()=>{const n=t.q;return t.q='',n}},1442,[]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.LoyaltySettingsPanel=function(){const e=(0,c.staffServer)(),[s,n]=(0,t.useState)(null),[f,y]=(0,t.useState)([]),[p,j]=(0,t.useState)(null),[w,b]=(0,t.useState)(!1),v=(0,t.useCallback)(async()=>{try{const[e,t]=await Promise.all([(0,c.readSettings)(),(0,c.readOffers)()]);n(e),y(t)}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}},[]);if((0,t.useEffect)(()=>{if(e)return v(),(0,c.watchLoyalty)(()=>{v()})},[e,v]),!e)return(0,h.jsx)(o.Banner,{kind:"info",title:"Not connected",children:"Loyalty settings are saved on the server. Not set up yet: sign in to the venue on this device to change them."});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const O=e=>{n({...s,...e}),j(null)},S=(0,u.checkSettings)(s),T=async()=>{if(!S){b(!0);try{await(0,c.saveSettings)(s),j({kind:'success',text:'Saved. Every device shows the new card.'})}catch(e){j({kind:'warn',text:(0,u.plainError)(e)})}b(!1)}},C=e=>e?`${e} days`:'Never';return(0,h.jsxs)(a.default,{style:{gap:10},testID:"adv-loyalty-panel",children:[(0,h.jsx)(o.T,{weight:"semibold",children:"Stamp card"}),(0,h.jsx)(o.Toggle,{testID:"loy-card-on",label:"Stamp card on",value:s.cardOn,onChange:e=>O({cardOn:e})}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps for a reward"}),(0,h.jsx)(o.Stepper,{value:s.stampsNeeded,min:2,max:20,onChange:e=>O({stampsNeeded:e}),label:"stamps for a reward"})]}),(0,h.jsx)(o.Field,{testID:"loy-reward",label:"The reward",value:s.reward,onChangeText:e=>O({reward:e.slice(0,80)}),placeholder:"e.g. Free dessert"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Stamps run out after"}),(0,h.jsx)(o.Stepper,{value:s.stampExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({stampExpiryDays:e}),label:"stamp expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Rewards run out after"}),(0,h.jsx)(o.Stepper,{value:s.rewardExpiryDays,min:0,max:1080,step:30,format:C,onChange:e=>O({rewardExpiryDays:e}),label:"reward expiry days"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Minutes between stamps (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.gapMinutes,min:0,max:1440,step:15,onChange:e=>O({gapMinutes:e}),label:"minutes between stamps"})]}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most stamps a day (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.maxPerDay,min:1,max:10,onChange:e=>O({maxPerDay:e}),label:"most stamps a day"})]}),(0,h.jsx)(o.T,{weight:"semibold",children:"Bring a friend"}),(0,h.jsx)(o.Toggle,{testID:"loy-ref-on",label:"Bring-a-friend on",value:s.referralOn,onChange:e=>O({referralOn:e})}),(0,h.jsx)(o.Field,{label:"Reward for the guest who brings a friend",value:s.referralGiver,onChangeText:e=>O({referralGiver:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsx)(o.Field,{label:"Reward for the friend",value:s.referralFriend,onChangeText:e=>O({referralFriend:e.slice(0,80)}),placeholder:"e.g. Free coffee"}),(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{children:"Most friend rewards a month (one guest)"}),(0,h.jsx)(o.Stepper,{value:s.referralMonthlyCap,min:0,max:50,onChange:e=>O({referralMonthlyCap:e}),label:"friend rewards a month"})]}),S?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:S}):null,p?(0,h.jsx)(o.Banner,{kind:p.kind,title:p.text}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{label:w?'Saving\u2026':'Save loyalty settings',testID:"loy-save",disabled:!!S||w,onPress:()=>{T()}}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Back to the defaults",onPress:()=>n({...u.DEFAULT_LOYALTY})})]}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: a friend reward is given when the friend gets their first stamp, and a guest can\u2019t use their own code. Stamps only come from staff, or from a code or QR staff make."}),(0,h.jsx)(o.T,{weight:"semibold",children:"Offers"}),f.length?f.map(e=>(0,h.jsx)(x,{o:e,onSaved:v},e.id)):(0,h.jsx)(o.Muted,{children:"No offers yet."}),(0,h.jsx)(x,{onSaved:v}),(0,h.jsx)(o.Muted,{size:13,children:"Tip: guests see an offer only while it\u2019s on and between its dates. Leave the dates blank to run it until you turn it off."})]})},_e.LoyaltySummaryCard=function({kind:e="card"}){const[s,n]=(0,t.useState)(null),[l,f]=(0,t.useState)(null),x=(0,t.useCallback)(()=>{(0,c.loyaltySummary)().then(n,e=>f((0,u.plainError)(e)))},[]);if((0,t.useEffect)(()=>{if((0,c.staffServer)())return x(),(0,c.watchLoyalty)(x)},[x]),!(0,c.staffServer)())return null;if(l)return(0,h.jsx)(o.Banner,{kind:"warn",title:"Couldn\u2019t load the summary",children:l});if(!s)return(0,h.jsx)(o.Muted,{children:"Loading\u2026"});const y='card'===e?[['Guests with a card',s.members],['Joined this month',s.joinedMonth],['Stamps this week',s.stampsWeek],['Stamps this month',s.stampsMonth],['Rewards ready to use',s.rewardsReady],['Rewards used this month',s.rewardsUsedMonth],['Offers live now',s.offersLive]]:[['Friends waiting for their first stamp',s.referralsWaiting],['Friend rewards given',s.referralsRewarded]];return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:4},testID:`loyalty-summary-${e}`,children:[(0,h.jsx)(o.T,{weight:"semibold",children:'card'===e?'Stamp card so far':'Bring a friend so far'}),y.map(([e,t])=>(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.Muted,{children:e}),(0,h.jsx)(o.T,{weight:"semibold",children:t})]},e)),(0,h.jsx)(o.Muted,{size:13,children:"Tip: these are your real numbers from the server. Change the card in Settings \u203a Advanced \u203a Loyalty."})]})})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),a=(e=n)&&e.__esModule?e:{default:e},l=r(d[3]),o=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]);const f=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;function x({o:e,onSaved:n}){const[x,y]=(0,t.useState)({title:e?.title??'',details:e?.details??'',startsOn:e?.startsOn??'',endsOn:e?.endsOn??'',isOn:e?.isOn??!0}),[p,j]=(0,t.useState)(!!e),[w,b]=(0,t.useState)(null);if(!e&&!p)return(0,h.jsx)(o.Button,{kind:"secondary",small:!0,label:"Add an offer",testID:"loy-offer-add",onPress:()=>j(!0)});const v=(!x.startsOn||f.test(x.startsOn))&&(!x.endsOn||f.test(x.endsOn))?(0,u.checkOffer)({title:x.title,details:x.details,startsOn:x.startsOn||null,endsOn:x.endsOn||null}):'Dates look like 2026-12-01.',O=async()=>{if(!v)try{await(0,c.saveOffer)({id:e?.id,title:x.title.trim(),details:x.details.trim(),startsOn:x.startsOn||null,endsOn:x.endsOn||null,isOn:x.isOn}),b('Saved.'),e||(y({title:'',details:'',startsOn:'',endsOn:'',isOn:!0}),j(!1)),n()}catch(e){b((0,u.plainError)(e))}};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(a.default,{style:{gap:6},children:[e?(0,h.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(o.T,{weight:"semibold",children:e.title}),(0,h.jsx)(o.Badge,{kind:e.isOn?'gold':'neutral',label:e.isOn?'On':'Off'})]}):(0,h.jsx)(o.T,{weight:"semibold",children:"New offer"}),(0,h.jsx)(o.Field,{label:"Title",value:x.title,onChangeText:e=>y({...x,title:e.slice(0,80)}),placeholder:"e.g. Two courses for \xa320 on Tuesdays"}),(0,h.jsx)(o.Field,{label:"Details",value:x.details,onChangeText:e=>y({...x,details:e.slice(0,500)}),multiline:!0}),(0,h.jsxs)(o.Row,{gap:8,wrap:!0,children:[(0,h.jsx)(o.Field,{label:"Starts (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.startsOn,e=>y({...x,startsOn:e.trim()})),placeholder:"01/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,h.jsx)(o.Field,{label:"Ends (optional, DD/MM/YYYY)",...(0,s.slashBox)(x.endsOn,e=>y({...x,endsOn:e.trim()})),placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10})]}),(0,h.jsx)(o.Toggle,{label:"Offer on",value:x.isOn,onChange:e=>y({...x,isOn:e})}),v&&(x.title||e)?(0,h.jsx)(o.T,{size:13,colour:l.colours.amber,children:v}):null,w?(0,h.jsx)(o.Muted,{size:13,children:w}):null,(0,h.jsxs)(o.Row,{gap:8,children:[(0,h.jsx)(o.Button,{small:!0,label:"Save offer",disabled:!!v,onPress:()=>{O()}}),e?null:(0,h.jsx)(o.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>j(!1)})]})]})})}},1443,[34,1063,102,821,794,1268,1271,25]); +__d(function(_g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.tidyWholePlan=u,_e.restoreTidy=h,_e.GridSettings=function({rid:e,me:s}){const p=(0,r.useFloor)(t=>t.settings[e]),c={...r.DEFAULT_SETTINGS,...p??{}},y=t=>r.useFloor.getState().setSettings(e,{...c,...t}),[b,S]=(0,t.useState)(''),f=(0,o.gridOf)(c.gridSize),v=c.tidyBackup,T=v?new Date(v.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'';return(0,g.jsxs)(n.default,{style:{gap:8},children:[(0,g.jsx)(a.Toggle,{testID:"adv-grid-snap",label:"Snap tables to the grid when dragging",value:!1!==c.gridSnap,onChange:e=>y({gridSnap:e}),a11y:"Snap tables to the grid when dragging"}),(0,g.jsx)(a.Muted,{size:13,children:!1!==c.gridSnap?'On: tables jump to the nearest grid line and line up with other tables (gold guides show when edges or centres match). Hold Alt (Option on a Mac) while dragging to move freely.':'Off: tables go exactly where you let go. Gold guides still help you line them up.'}),(0,g.jsx)(a.T,{children:"Grid size"}),(0,g.jsx)(a.Row,{wrap:!0,gap:8,children:o.GRID_SIZES.map(e=>(0,g.jsx)(a.Chip,{testID:`adv-grid-${e}`,label:10===e?'Fine (10)':25===e?'Normal (25)':'Coarse (50)',selected:f===e,onPress:()=>y({gridSize:e})},e))}),(0,g.jsx)(a.Button,{testID:"adv-grid-tidy",label:"Tidy up the whole plan",onPress:()=>{const t=u(e,s,(new Date).toISOString());S(t.moved?`Tidied: ${t.moved} tables lined up on the grid. The old positions are kept below.`:'Already tidy. Nothing moved.')}}),(0,g.jsx)(a.Muted,{size:13,children:"Tidy up snaps every table to the grid and evens out the rows, area by area. Only positions change: table numbers, areas, Covers, sizes and best tables stay as they are."}),v?(0,g.jsxs)(n.default,{testID:"adv-grid-backup",style:{borderWidth:1,borderColor:l.colours.gold,borderRadius:10,padding:10,gap:6},children:[(0,g.jsxs)(a.T,{size:14,children:["Positions from before the tidy on ",T,v.by?` (${v.by})`:''," are kept."]}),(0,g.jsx)(a.Button,{testID:"adv-grid-restore",kind:"secondary",label:"Put the tables back where they were",onPress:()=>{h(e)&&S('Done: every table is back where it was before the tidy.')}})]}):null,b?(0,g.jsx)(a.Banner,{kind:"success",title:b}):null,(0,g.jsx)(a.Muted,{size:13,children:"Tip: in the table plan editor, Tidy up does one area at a time and you can undo it with \u2318Z (Ctrl+Z)."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},a=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),g=_r(d[6]);function u(e,t,s){const n=r.useFloor.getState(),a=n.plans[e]??(0,r.planOf)(e),l={...r.DEFAULT_SETTINGS,...n.settings[e]??{}};let g=a;for(const e of a.areas)g=(0,o.tidyArea)(g,e.id,(0,o.gridOf)(l.gridSize));const u=(0,o.movedCount)(a,g);return u?(n.setSettings(e,{...l,tidyBackup:(0,o.backupOf)(a,s,t,'Before Tidy up')}),n.setPlan(e,g),{moved:u}):{moved:u}}function h(e){const t=r.useFloor.getState(),s={...r.DEFAULT_SETTINGS,...t.settings[e]??{}},n=s.tidyBackup;return!!n&&(t.setPlan(e,(0,o.restoreFrom)(t.plans[e]??(0,r.planOf)(e),n)),t.setSettings(e,{...s,tidyBackup:void 0}),!0)}},1444,[34,102,794,1029,1366,821,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.tillTakings=t,e.takingsToday=function(n,u,l,d){const c=s=>{const l=n.find(n=>n.rid===u&&n.date===s&&!!n.confirmedAt),d=l?t(l.vals):null;return null==d?null:o(d)},y=c(l),p=s(l,-7),h=c(p),f=Math.max(0,Math.round(d||0));return{today:y,last:null==h?null:{date:p,pence:h},online:f,show:null!=y||null!=h||f>0}},Object.defineProperty(e,"money",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return d}}),e.changeWords=c,e.takingsSpeech=function(n){const t=[];t.push(null!=n.today?`Takings today, ${u(n.today)}, from tonight's cash up`:'Takings today, not cashed up yet'),n.last&&t.push(`Last ${d(n.last.date)}, ${u(n.last.pence)}`);const s=c(n);s&&t.push(s);n.online>0&&t.push(`Plus ${u(n.online)} paid online`);return t.push('Opens takings and reports'),t.join('. ')+'.'};const n=n=>'number'==typeof n&&Number.isFinite(n)?n:null;function t(t){const s=n(t.card),o=n(t.cash);return null!=s||null!=o?(s??0)+(o??0):n(t.gross)}const s=(n,t)=>{const s=new Date(`${n}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},o=n=>Math.round(100*n);const u=n=>`\xa3${(n/100).toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=n=>l[new Date(`${n}T12:00:00Z`).getUTCDay()];function c(n){if(null==n.today||!n.last)return null;const t=n.today-n.last.pence;return 0===t?'Same as last week':`${t>0?'Up':'Down'} ${u(Math.abs(t))} on last ${d(n.last.date)}`}},1445,[]); +__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.TakingsTodayCard=function({t:e,example:h,onPress:y}){const x=(0,c.changeWords)(e),f=null!=e.today&&null!=e.last&&e.today(0,c.money)(Math.round(e))}):(0,u.jsx)(s.T,{center:!0,size:18,weight:"bold",colour:l.colours.text,testID:"home-takings-not-yet",children:"Not cashed up yet"}),e.last?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-last",children:["Last ",(0,c.dayName)(e.last.date),": ",(0,c.money)(e.last.pence)]}):null,x?(0,u.jsx)(s.T,{center:!0,size:13,weight:"semibold",colour:f?l.colours.amber:l.colours.gold,testID:"home-takings-change",children:x}):null,e.online>0?(0,u.jsxs)(s.T,{center:!0,size:13,colour:l.colours.muted,testID:"home-takings-online",children:["Plus ",(0,c.money)(e.online)," paid online"]}):null,(0,u.jsx)(s.T,{center:!0,size:11,colour:l.colours.muted,children:null!=e.today||e.last?'Card + cash from the cash up':'Paid online today'})]})})},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])},1446,[34,402,102,794,821,1170,1445,25]); +__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1447,[927,796,831,828,837,878,1076,1448,34,994,336,379,236,402,102,794,874,891,858,821,1201,1088,1230,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1448,[499,1449]); +__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 t={}},1449,[]); +__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.ProgressBar=D,_e.useSetupDone=O,_e.SetupGuide=function({start:e}){const{rid:s,r:t}=(0,C.useCtx)(6e4),n=O(s),o=n.prog,[a,l]=(0,c.useState)(e??null);if(a){const e=f.SETUP_STEPS.findIndex(e=>e.id===a),s=f.SETUP_STEPS[e+1]?.id??null;return(0,E.jsx)(L,{id:a,wizard:!0,onBack:()=>l(e>0?f.SETUP_STEPS[e-1].id:null),onClose:()=>l(null),onNext:()=>l(s)})}const r=f.SETUP_STEPS.find(e=>!n.isDone(e.id))?.id??null,i=!r&&!n.loading;return(0,E.jsxs)(g.default,{style:{gap:12},testID:"setup-guide",children:[(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{gap:12,children:[(0,E.jsx)(p.RestaurantLogo,{rid:s,size:56}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(m.T,{size:20,weight:"bold",colour:S.colours.gold,children:["Set up ",t.name]}),(0,E.jsx)(m.Muted,{children:n.loading?'Checking what is already set up\u2026':i?'Everything is set up. Open any step to check or change it.':'Nine short steps. Do them in order or jump to any one; you can come back to each from Settings.'})]})]}),(0,E.jsx)(D,{done:o.done,total:o.total,testID:"setup-progress"}),n.loading?null:(0,E.jsx)(m.Button,{label:r?o.done?'Continue setup':'Start setup':'Review setup',kind:i?'ghost':void 0,testID:"setup-continue",onPress:()=>l(r??'venue')})]}),(0,E.jsx)(g.default,{style:{borderRadius:14,borderWidth:1,borderColor:S.colours.border,backgroundColor:S.colours.surface,overflow:'hidden'},children:f.SETUP_STEPS.map((e,s)=>{const t=n.isDone(e.id),o=t?[]:n.missing(e.id);return(0,E.jsxs)(h.default,{testID:`setup-step-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Step ${s+1}: ${e.title}${t?', done':o.length?`, still needed: ${o.join(', ')}`:''}`,onPress:()=>l(e.id),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',gap:12,padding:12,minHeight:60,borderTopWidth:s?1:0,borderColor:S.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:[(0,E.jsx)(g.default,{style:{width:32,height:32,borderRadius:16,alignItems:'center',justifyContent:'center',backgroundColor:t?S.colours.gold:'transparent',borderWidth:1.5,borderColor:t?S.colours.gold:S.colours.border},children:(0,E.jsx)(m.T,{weight:"bold",colour:t?S.colours.onGold:S.colours.muted,children:t?'\u2713':s+1})}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"medium",children:e.title}),(0,E.jsx)(m.Muted,{children:e.sub}),o.length?(0,E.jsxs)(m.T,{size:13,colour:S.colours.amber,children:["Still needed: ",o.join('; ')]}):null]}),t?(0,E.jsx)(m.Badge,{kind:"ok",label:"Done"}):null,(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]},e.id)})})]})},_e.StepFrame=L,Object.defineProperty(_e,"stepPage",{enumerable:!0,get:function(){return W}}),_e.SetupCard=function({go:e}){const{rid:s}=(0,C.useCtx)(6e4),t=O(s),n=t.prog;return t.loading||n.done>=n.total?null:(0,E.jsxs)(m.Card,{onPress:()=>e('more','setup'),highlight:S.colours.gold,children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:"Finish setting up"}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"\u203a"})]}),(0,E.jsx)(D,{done:n.done,total:n.total,testID:"dash-setup-progress"}),(0,E.jsxs)(m.Muted,{size:13,children:["Next: ",f.SETUP_STEPS.find(e=>!t.isDone(e.id))?.title]})]})};var s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),o=_r(_d[3]),a=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(_r(_d[4])),l=_r(_d[5]),r=_r(_d[6]),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=e(_r(_d[11])),g=e(_r(_d[12])),p=_r(_d[13]),x=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),k=_r(_d[20]),w=_r(_d[21]),S=_r(_d[22]),C=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),P=_r(_d[26]),z=_r(_d[27]),E=_r(_d[28]);const M=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],R=[1,2,3,4,5,6,0],I=/^([01]\d|2[0-3]):[0-5]\d$/,$=e=>{const s=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(s)&&s>0?Math.round(100*s):null},B=e=>f.SETUP_STEPS.findIndex(s=>s.id===e)+1;function D({done:e,total:s,testID:t}){const o=s?e/s:0;return(0,E.jsxs)(g.default,{testID:t,accessibilityRole:"progressbar",accessibilityValue:{min:0,max:s,now:e},accessibilityLabel:`${e} of ${s} steps done`,style:{gap:4},children:[(0,E.jsx)(g.default,{style:{height:10,borderRadius:5,backgroundColor:(0,n.soutersSurface)('#1F1C17'),overflow:'hidden',borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(g.default,{style:{width:`${Math.round(100*o)}%`,height:'100%',backgroundColor:S.colours.gold,borderRadius:5}})}),(0,E.jsxs)(m.Muted,{size:12,children:[e," of ",s," steps done"]})]})}function O(e){const s=(0,f.useSiteSetup)(e),t=(0,p.useBrand)(e),{status:n,live:o}=(0,r.useSetupStatus)(),a=(0,c.useMemo)(()=>n?(0,l.evalSetup)(n,{logo:!!t.logo,email:s.email,bookingUrl:s.bookingUrl}):null,[n,t.logo,s.email,s.bookingUrl]),d=(0,i.useSetupMarksLoaded)(),u=e=>a?(0,i.applyMark)(!!a[e]?.done,d[e]):!!s.done[e],h=f.SETUP_STEPS.filter(e=>u(e.id)).length;return{isDone:u,markOf:e=>d[e],missing:e=>a?a[e]?.missing??[]:[],prog:{done:h,total:f.SETUP_STEPS.length},loading:o&&!n,fromVenue:!!a}}function L({id:e,wizard:s,onBack:t,onNext:n,onClose:o}){const{rid:a}=(0,C.useCtx)(6e4),l=O(a),r=l.prog,d=(0,i.useLiveVenue)(),u=f.SETUP_STEPS.find(s=>s.id===e),[p,x]=(0,c.useState)(null),b=_[e];return(0,E.jsxs)(g.default,{style:{gap:12},testID:`setup-${e}`,children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(m.T,{size:12,weight:"semibold",colour:S.colours.gold,children:["STEP ",B(e)," OF ",f.SETUP_STEPS.length]}),s&&o?(0,E.jsx)(h.default,{accessibilityRole:"button",onPress:o,hitSlop:10,children:(0,E.jsx)(m.T,{size:13,colour:S.colours.muted,children:"All steps"})}):null]}),(0,E.jsx)(m.T,{size:22,weight:"bold",children:u.title}),(0,E.jsx)(D,{done:r.done,total:r.total})]}),(0,E.jsx)(b,{rid:a,done:(t="Saved.")=>{f.useSetup.getState().markDone(a,e),d&&!1===l.markOf(e)?.done&&i.useSetupMarks.getState().set(d,e,!0),s&&n?n():x(t)},wizard:!!s}),p?(0,E.jsx)(m.Banner,{kind:"success",title:p}):null,(0,E.jsx)(N,{rid:a,id:e,title:u.title,onDone:x}),s?(0,E.jsxs)(m.Row,{gap:10,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Back",onPress:t,style:{flex:1},testID:"setup-back"}),(0,E.jsx)(m.Button,{kind:"ghost",label:"Skip for now",onPress:n,style:{flex:1},testID:"setup-skip"})]}):null]})}const A=({wizard:e,onPress:s,disabled:t,label:n})=>(0,E.jsx)(m.Button,{label:n??(e?'Save and continue':'Save changes'),testID:"setup-save",disabled:t,onPress:s,style:{minHeight:54}});const F=e=>({name:'',job:'',access:'Staff',pay:'grade',gradeId:e,wage:'',noTax:!1,look:null});function U({rid:e,done:n,wizard:o,payList:a=!1}){const l=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,j.useOwner)(e=>e.hourly),i=(0,C.useHourly)(),d=(0,f.useSiteSetup)(e),u=(0,f.useSetup)(e=>e.looks),[p,b]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),v=e=>{const s=d.grades.find(s=>s.id===d.staffGrade[e.id]);return e.salaried&&null==r[e.id]?'Salaried, no hourly wage':s&&!a?`${s.name} grade`:null==r[e.id]?'Pay not set':null!=i[e.id]?`${(0,w.gbp)(i[e.id])} an hour`:'Hourly rate set'},P=e=>{const s=d.staffGrade[e.id];b({id:e.id,name:e.name,job:e.job,access:(0,f.accessOf)(e.level,e.role),pay:e.salaried&&null==r[e.id]?'salaried':s?'grade':'own',gradeId:s??d.grades[0]?.id??'',wage:null!=i[e.id]?(i[e.id]/100).toFixed(2):'',noTax:!!e.noTax,look:u[e.id]??null}),T(null)},z=!!p?.id&&(M=p.id,k.ROSTER.some(e=>e.id===M));var M;const R=p?$(p.wage):null,I=!!p&&p.name.trim().length>=2&&('grade'!==p.pay||!!p.gradeId)&&('own'!==p.pay||null!=R||z&&!p.wage);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Muted,{children:[l.length," people. Tap someone to change their pay, tax or avatar. People from your roster keep their name, access and personal link."]}),(0,E.jsx)(g.default,{style:{gap:8},children:l.map(e=>(0,E.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>P(e),style:({pressed:s})=>({flexDirection:'row',alignItems:'center',gap:10,padding:10,borderRadius:14,borderWidth:1,borderColor:p?.id===e.id?S.colours.gold:S.colours.border,backgroundColor:s?'#1d1a14':S.colours.surface}),children:[(0,E.jsx)(x.StaffAvatar,{id:e.id,size:42}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(m.T,{weight:"semibold",children:e.name}),(0,E.jsxs)(m.Muted,{size:13,children:[a?`Age not recorded \xb7 ${e.job||(0,f.accessOf)(e.level,e.role)} \xb7 `:`${e.job} \xb7 `,v(e),e.noTax?' \xb7 No tax deducted':'']})]}),(0,E.jsx)(m.Badge,{kind:'owner'===e.role?'gold':'manager'===e.role?'blue':'neutral',label:(0,f.accessOf)(e.level,e.role)})]},e.id))}),y?(0,E.jsx)(m.Banner,{kind:"success",title:y}):null,p?(0,E.jsxs)(m.Card,{highlight:S.colours.gold,children:[(0,E.jsx)(m.T,{weight:"semibold",size:18,children:p.id?`Edit ${p.name}`:'New team member'}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{width:84,height:84,borderRadius:42,overflow:'hidden',borderWidth:2,borderColor:S.colours.gold},children:(0,E.jsx)(x.AvatarLook,{look:p.look,id:p.id,name:p.name||'new',size:80})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsx)(m.Muted,{children:"Choose an original icon or keep a crew look. A personal avatar takes priority. They can change their own in My avatar."}),(0,E.jsx)(s.AvatarOptions,{value:null!=p.look&&p.look>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===p.look)?.dataUrl:void 0,onSelect:e=>b({...p,look:e.look})}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Try another look",testID:"avatar-next",onPress:()=>b({...p,look:((p.look??0)+1)%40})}),null!=p.look?(0,E.jsx)(m.Button,{small:!0,kind:"ghost",label:"Default look",onPress:()=>b({...p,look:null})}):null]})]})]}),z?(0,E.jsxs)(m.Muted,{children:[p.name," is on your roster: name and access stay as they are."]}):(0,E.jsx)(m.Field,{label:"Name",value:p.name,onChangeText:e=>b({...p,name:e}),placeholder:"First and last name"}),(0,E.jsx)(m.Field,{label:"Job title",value:p.job,onChangeText:e=>b({...p,job:e}),placeholder:"e.g. Kitchen porter"}),z?null:(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Access level"}),(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:f.ACCESS_LEVELS.map(e=>(0,E.jsx)(m.Chip,{label:e,selected:p.access===e,onPress:()=>b({...p,access:e})},e))}),(0,E.jsxs)(m.Muted,{size:13,children:["Uses the ",f.ACCESS_APP[p.access]," app. Change what each level can do in Permissions."]})]}),(0,E.jsxs)(g.default,{style:{gap:6},children:[(0,E.jsx)(m.T,{size:14,weight:"medium",colour:S.colours.muted,children:"Pay"}),(0,E.jsxs)(m.Row,{gap:6,wrap:!0,children:[a?null:(0,E.jsx)(m.Chip,{label:"Pay grade",selected:'grade'===p.pay,onPress:()=>b({...p,pay:'grade'})}),(0,E.jsx)(m.Chip,{label:"Own hourly rate",selected:'own'===p.pay,onPress:()=>b({...p,pay:'own'})}),(0,E.jsx)(m.Chip,{label:"Salaried / no hourly wage",selected:'salaried'===p.pay,onPress:()=>b({...p,pay:'salaried'})})]}),'grade'!==p.pay||a?null:(0,E.jsx)(m.Row,{gap:6,wrap:!0,children:d.grades.map(e=>(0,E.jsx)(m.Chip,{label:`${e.name} \xb7 ${(0,w.gbp)(e.pence)}`,selected:p.gradeId===e.id,onPress:()=>b({...p,gradeId:e.id})},e.id))}),'own'===p.pay?(0,E.jsx)(m.Field,{label:"\xa3 per hour",value:p.wage,onChangeText:e=>b({...p,wage:e}),keyboardType:"decimal-pad",placeholder:z?'Leave blank to keep their current rate':'e.g. 12.71'}):null,'own'===p.pay&&null!=R&&R<1271?(0,E.jsx)(m.Muted,{size:13,children:"Below \xa312.71: only right for under-21s or apprentices on the correct rate."}):null]}),(0,E.jsx)(m.Toggle,{label:"No tax deducted",value:p.noTax,onChange:e=>b({...p,noTax:e})}),(0,E.jsxs)(m.Row,{gap:8,children:[(0,E.jsx)(m.Button,{kind:"secondary",label:"Cancel",onPress:()=>b(null),style:{flex:1}}),(0,E.jsx)(m.Button,{label:p.id?'Save':'Add to team',testID:"staff-save",disabled:!I,onPress:()=>{if(!p||!I)return;const s=j.useOwner.getState();let t=p.id;if(!t){const e=new Set(s.staff.map(e=>e.id));if(s.addStaff(p.name.trim(),f.ACCESS_ROLE[p.access],p.job.trim()||'Team member'),t=j.useOwner.getState().staff.find(s=>!e.has(s.id))?.id,!t)return}const n={job:p.job.trim()||'Team member',salaried:'salaried'===p.pay,noTax:p.noTax};z||Object.assign(n,{name:p.name.trim(),level:p.access,role:f.ACCESS_ROLE[p.access],dept:'Head Chef'===p.access?'Kitchen':void 0}),s.updateStaff(t,n);const o={...d.staffGrade};if('grade'===p.pay){const e=d.grades.find(e=>e.id===p.gradeId);e&&(a&&d.staffGrade[t]===p.gradeId||s.setRate(t,e.pence),o[t]=e.id)}else delete o[t],'own'===p.pay&&null!=R&&s.setRate(t,R);'salaried'===p.pay&&j.useOwner.setState(e=>{const s={...e.hourly};return delete s[t],{hourly:s}}),f.useSetup.getState().patch(e,{staffGrade:o}),f.useSetup.getState().setLook(t,p.look),T(`${p.name.trim()} ${p.id?'updated':'added'}.`),b(null)},style:{flex:1}})]}),p.id?null:(0,E.jsx)(m.Muted,{size:12,children:"Nothing is sent to them. Make their invite link in the Staff invite links step."})]}):a?null:(0,E.jsx)(m.Button,{kind:"secondary",label:"Add a team member",testID:"add-staff",onPress:()=>{b(F(d.grades[0]?.id??'')),T(null)}}),(0,E.jsx)(A,{wizard:o,label:o?'Team looks right, continue':'Mark as done',onPress:()=>n('Team step marked as done.')})]})}const _={venue:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),l=(0,p.useBrand)(e),r=(0,f.useSiteSetup)(e),[i,d]=(0,c.useState)({name:o.name,address:o.address??o.location,phone:o.phone??'',email:r.email,tagline:o.tagline}),[u,h]=(0,c.useState)('');return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Venue name",value:i.name,onChangeText:e=>d({...i,name:e})}),(0,E.jsx)(m.Field,{label:"Address",value:i.address,onChangeText:e=>d({...i,address:e}),multiline:!0,placeholder:"Street, town, postcode"}),(0,E.jsx)(m.Field,{label:"Phone",value:i.phone,onChangeText:e=>d({...i,phone:e}),keyboardType:"phone-pad"}),(0,E.jsx)(m.Field,{label:"Email",accessibilityLabel:"Venue email address",keyboardType:"email-address",inputMode:"email",autoCapitalize:"none",autoCorrect:!1,value:i.email,onChangeText:e=>d({...i,email:e})}),(0,E.jsx)(m.Field,{multiline:!0,numberOfLines:3,label:"Tagline",value:i.tagline,onChangeText:e=>d({...i,tagline:e}),placeholder:"e.g. Seafood and real ale by the harbour"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Logo"}),(0,E.jsxs)(m.Row,{gap:14,children:[(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:14,padding:8,borderWidth:1,borderColor:S.colours.border},children:(0,E.jsx)(p.RestaurantLogo,{rid:e,size:72})}),(0,E.jsxs)(g.default,{style:{flex:1,gap:6},children:[(0,E.jsxs)(m.Muted,{children:[l.custom?'Your uploaded logo.':'anchorage'===e?'The Anchorage logo in black and gold.':'greenside'===e?'The Greenside Restaurant logo.':'abbotsford'===e?'The Abbotsford Hotel logo.':'kirkton'===e?'The Kirkton Inn logo.':'wildings'===e?'The Wildings Hotel & Restaurant logo.':'kirkmichael'===e?'The Kirkmichael Arms logo.':'souters'===e?'The Souter\u2019s Inn logo.':'Placeholder initials.'," Square images work best. Shown in all five apps and on the Display screensaver."]}),(0,E.jsxs)(m.Row,{gap:8,wrap:!0,children:[(0,E.jsx)(m.Button,{small:!0,label:"Upload a logo",onPress:async()=>{const s=await a.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(s.canceled||!s.assets?.[0])return;const t=s.assets[0];j.useOwner.getState().setBranding(e,{logoUri:t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri})}}),l.custom?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Use the built-in logo",onPress:()=>j.useOwner.getState().setBranding(e,{logoUri:void 0})}):null]})]})]})]}),(0,E.jsx)(P.OrderAtTableCard,{rid:e,compact:!0}),u?(0,E.jsx)(m.Banner,{kind:"warn",title:u}):null,(0,E.jsx)(A,{wizard:t,onPress:()=>{i.name.trim().length<2?h('Add your venue\u2019s name.'):!i.email.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email.trim())?(b.useStore.getState().updateRestaurant(o.id,{name:i.name.trim(),address:i.address.trim(),phone:i.phone.trim(),contactEmail:i.email.trim(),tagline:i.tagline.trim()}),h(''),s('Venue details saved.')):h('Check the email address.')}})]})},hours:function({done:e,wizard:s}){const{r:t}=(0,C.useCtx)(6e4),[n,a]=(0,c.useState)(t.kitchenHours),l=R.filter(e=>{const s=n[e];return s&&(!I.test(s[0])||!I.test(s[1]))});return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Muted,{children:"Kitchen hours, used for online bookings, takeaway slots and the Display timeline. Use 24-hour times, like 12:00 and 21:00."}),M.map((e,s)=>{const t=R[s],l=n[t];return(0,E.jsxs)(g.default,{style:{width:'100%',minWidth:0,gap:8,minHeight:52,borderTopWidth:s?1:0,borderTopColor:S.colours.border,paddingTop:s?6:0},children:[(0,E.jsx)(m.T,{center:!0,weight:"medium",style:{width:'100%'},children:e}),l?(0,E.jsxs)(m.Row,{wrap:!0,gap:6,style:{width:'100%',justifyContent:'center'},children:[(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} opens`,value:l[0],onChangeText:e=>a({...n,[t]:[e,l[1]]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]}),(0,E.jsx)(m.T,{colour:S.colours.muted,children:"to"}),(0,E.jsx)(o.TextInput,{accessibilityLabel:`${e} closes`,value:l[1],onChangeText:e=>a({...n,[t]:[l[0],e]}),style:[m.styles.input,{flex:1,paddingVertical:8,textAlign:'center'}]})]}):(0,E.jsx)(m.Muted,{style:{flex:1},children:"Closed"}),(0,E.jsx)(m.Toggle,{label:`Open on ${e}`,value:!!l,onChange:e=>a({...n,[t]:e?['12:00','21:00']:null})})]},e)}),n[1]?(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:"Copy Monday\u2019s hours to every open day",onPress:()=>{const e=n[1];e&&a(Object.fromEntries(R.map(s=>[s,n[s]?[e[0],e[1]]:null])))}}):null]}),l.length?(0,E.jsx)(m.Banner,{kind:"warn",title:"Check the times",children:"Use 24-hour times like 12:00 or 21:30."}):null,(0,E.jsx)(A,{wizard:s,disabled:!!l.length,onPress:()=>{b.useStore.getState().updateRestaurant(t.id,{kitchenHours:n}),e('Opening hours saved.')}})]})},plan:function({rid:e,done:s,wizard:t}){const n=(0,y.usePlan)(e),o=(0,y.planCounts)(n);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v.TablePlan,{startStep:"areas"}),(0,E.jsx)(A,{wizard:t,disabled:!o.tables,label:t?`Looks right (${o.tables} tables, ${o.seats} seats), continue`:'Mark as done',onPress:()=>s('Table plan step marked as done.')})]})},paygrades:function(e){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{center:!0,children:"Your team's hourly rates. Tap a person to edit. Existing grades are retained in the background; opening this list never changes pay."}),(0,E.jsx)(U,{...e,payList:!0})]})},staff:U,permissions:function({done:e,wizard:s}){return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(z.PermissionsScreen,{}),(0,E.jsx)(A,{wizard:s,onPress:()=>e('Permissions checked.')})]})},email:function({rid:e,done:s,wizard:t}){const n=(0,f.useSiteSetup)(e),[o,a]=(0,c.useState)(n.email||''),l=!o.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim());return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Work email address",value:o,onChangeText:a,placeholder:"e.g. hello@yourvenue.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),l?null:(0,E.jsx)(m.Muted,{size:13,children:"That doesn\u2019t look like an email address."}),(0,E.jsx)(m.Muted,{children:"Used for the Gmail quick link and shown to guests as your contact email."})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Link your inbox"}),(0,E.jsx)(m.Badge,{kind:"amber",label:"Coming soon"})]}),(0,E.jsx)(m.Muted,{children:"Later you\u2019ll be able to link your inbox so booking emails appear in CoverCharge. Nothing is linked yet: CoverCharge doesn\u2019t read or send email from here."}),(0,E.jsx)(m.Button,{kind:"secondary",label:"Link email (coming soon)",disabled:!0,onPress:()=>{}})]}),(0,E.jsx)(A,{wizard:t,disabled:!l,onPress:()=>{b.useStore.getState().updateRestaurant(e,{contactEmail:o.trim()}),s('Email saved.')}})]})},website:function({rid:e,done:s,wizard:t}){const{r:o}=(0,C.useCtx)(6e4),a=(0,f.useSiteSetup)(e),[l,r]=(0,c.useState)(a.website||o.website||''),i=(0,c.useMemo)(()=>(0,T.appUrl)('/customer-app/index.html'),[]),[d,u]=(0,c.useState)(!1),h=l.trim()&&!/^https?:\/\//i.test(l.trim())?`https://${l.trim()}`:l.trim(),p=!h||/^https?:\/\/[^\s.]+\.[^\s]+$/i.test(h);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.Field,{label:"Your website",value:l,onChangeText:r,placeholder:"e.g. www.yourvenue.co.uk",keyboardType:"url",autoCapitalize:"none",autoCorrect:!1}),p?null:(0,E.jsx)(m.Muted,{size:13,children:"Enter a web address like www.yourvenue.co.uk"})]}),(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{weight:"semibold",children:"Your booking link"}),(0,E.jsx)(m.Muted,{children:"Add a \u201cBook a table\u201d button to your website that opens this link. Guests book straight into CoverCharge."}),(0,E.jsx)(g.default,{style:{backgroundColor:(0,n.soutersSurface)('#000'),borderRadius:10,borderWidth:1,borderColor:S.colours.border,padding:10},children:(0,E.jsx)(m.T,{size:14,colour:S.colours.goldLight,children:i})}),(0,E.jsx)(m.Button,{small:!0,kind:"secondary",label:d?'Copied \u2713':'Copy booking link',onPress:async()=>{const e=await(0,T.copyText)(i);u(e)}})]}),['anchorage','6349aa07-3fec-46e9-8c69-7b1b08494793'].includes(e)?null:(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(m.T,{center:!0,weight:"semibold",children:"Website bookings tables"}),(0,E.jsx)(m.Row,{wrap:!0,style:{justifyContent:'center'},children:(0,E.jsx)(m.Badge,{kind:"gold",label:"Coming soon"})}),(0,E.jsx)(m.Muted,{center:!0,children:"Coming soon: show live table availability and take bookings right inside your website."})]}),(0,E.jsx)(A,{wizard:t,disabled:!p,onPress:()=>{b.useStore.getState().updateRestaurant(o.id,{website:h||void 0}),f.useSetup.getState().patch(e,{website:h,bookingUrl:i}),s('Website saved.')}})]})},invites:function({rid:e,done:s,wizard:t}){const n=(0,j.useOwner)(e=>e.staff).filter(e=>e.active),{role:o}=(0,C.useCtx)(6e4),a='owner'===o||'manager'===o?o:'staff';return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(m.Muted,{children:"Every person has an Android app download and an iPhone app link. Both sign in automatically. Share privately; nothing is sent from here."}),n.map(e=>(0,E.jsxs)(m.Card,{children:[(0,E.jsx)(u.StaffLinkChip,{m:e,actorRole:a}),(0,E.jsx)(d.InviteLinkControls,{m:e,actorRole:a})]},e.id)),(0,E.jsx)(A,{wizard:t,label:t?'Finish setup':'Mark as done',onPress:()=>s('Invite links step marked as done.')})]})}},W=e=>function(){return(0,E.jsx)(L,{id:e})};function N({rid:e,id:s,title:t,onDone:n}){const o=O(e),a=(0,i.useLiveVenue)(),l=o.markOf(s),[r,d]=(0,c.useState)(!1);return o.isDone(s)?(0,E.jsxs)(g.default,{style:{gap:4},children:[(0,E.jsx)(m.Button,{kind:"secondary",label:r?'Saving\u2026':'Mark as not done',disabled:r,testID:`setup-notdone-${s}`,accessibilityLabel:`${t}, mark as not done`,style:{minHeight:44},onPress:async()=>{d(!0),f.useSetup.getState().markDone(e,s,!1);const o=!a||await i.useSetupMarks.getState().set(a,s,!1);d(!1),n(o?`${t} marked as not done.`:'Could not save. Check the connection and try again.')}}),(0,E.jsx)(m.Muted,{size:13,children:"Tip: use this if a step needs another look. It goes back on your to-do list until you mark it done again."})]}):l&&!1===l.done&&l.by?(0,E.jsxs)(m.Muted,{size:13,testID:`setup-notdone-by-${s}`,children:["Marked as not done by ",l.by,l.at?` on ${new Date(l.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})}`:'',"."]}):null}},1450,[929,928,828,827,1076,1451,1452,1453,1454,1456,34,402,102,873,925,794,874,891,1029,927,15,867,821,1088,1457,1460,1464,1465,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.evalSetup=function(s,t){const n=e=>{const s=e.filter(([e])=>!e).map(([,e])=>e);return{done:!s.length,missing:s}};return{venue:n([[s.name,'The venue name'],[s.address,'The address'],[s.phone,'A phone number'],[t.logo,'Your logo']]),hours:n([[s.hoursSet&&s.hoursDays>0,'Kitchen opening hours for at least one day']]),plan:n([[s.planAreas>0,'At least one area'],[s.planTables>0,'Tables on the plan']]),paygrades:n([[s.payGrades>0,'At least one pay grade']]),staff:n([[s.staffActive>0,'At least one person on the team']]),permissions:n([[s.roles>0&&s.rolesWithPerms>0,'What each access level can do']]),email:n([[s.email||/\S+@\S+\.\S+/.test(t.email),'A work email address']]),website:n([[s.website,'Your website address']]),invites:n([[s.staffActive>0&&0===s.staffNoAccess,0===s.staffActive?'Add your team first':`${e(s.staffNoAccess,'person has','people have')} no working invite link yet (${s.staffSignedIn} signed in${s.invitesIssued>s.staffSignedIn?"; older links have run out":''})`]])}},Object.defineProperty(_e,"countDone",{enumerable:!0,get:function(){return s}});const e=(e,s,t=`${s}s`)=>`${e} ${1===e?s:t}`;const s=e=>Object.values(e).filter(e=>e.done).length},1451,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSetupStatus=function(){const n=(0,u.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null),[s,l]=(0,t.useState)(null),[r,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{if(!n)return void l(null);let t=!1;return(0,u.rpc)('setup_status',{p_venue:n}).then(u=>{t||l(u??null)}).catch(()=>{}),()=>{t=!0}},[n,r]),{status:s,live:!!n,reload:()=>c(t=>t+1)}};var t=_r(d[0]),u=_r(d[1])},1452,[34,987]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSetupMarks",{enumerable:!0,get:function(){return u}}),e.useLiveVenue=s,e.useSetupMarksLoaded=function(){const n=s(),r=u(t=>t.marks);return(0,t.useEffect)(()=>{n&&u.getState().load(n)},[n]),n?r:{}},Object.defineProperty(e,"applyMark",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const u=(0,n.create)()((t,n)=>({venue:null,marks:{},load:async n=>{try{const u=await(0,r.rpc)('setup_step_marks',{p_venue:n});t({venue:n,marks:u??{}})}catch{}},set:async(u,s,c)=>{try{const o=await(0,r.rpc)('set_setup_step',{p_venue:u,p_step:s,p_done:c});return t({marks:{...n().marks,[s]:{done:c,by:o?.by,at:o?.at}}}),!0}catch{return!1}}}));function s(){return(0,r.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null)}const c=(t,n)=>(!n||!1!==n.done)&&t},1453,[34,846,987]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1454,[2,827,34,236,383,102,794,1455,987,821,1205,1004,891,994,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1455,[]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"showLinkA11y",{enumerable:!0,get:function(){return m}}),_e.StaffLinkChip=function({m:e,actorRole:s}){const[u,b]=(0,n.useState)(!1),f=(0,l.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage'))||'owner'===s||'manager'===s&&'owner'!==e.role&&!e.ownerAccess;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t.default,{testID:`link-chip-${e.id}`,accessibilityRole:"button",accessibilityLabel:m(e.name),disabled:!f,onPress:()=>b(!0),style:({pressed:e})=>({minHeight:44,minWidth:44,padding:10,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:1,borderColor:e?c.colours.gold:c.colours.border}),children:(0,h.jsxs)(o.T,{size:14,children:[e.name.split(' ')[0]," app links"]})}),u?(0,h.jsx)(p,{m:e,actorRole:s,onClose:()=>b(!1)}):null]})},_e.InviteLinkSheet=p;var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]);const m=e=>`${e.split(' ')[0]}, show Android and iPhone app links`;function p({m:e,actorRole:n="staff",onClose:s}){return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:s,title:`${e.name}'s app links`,testID:"invite-link-sheet",children:[(0,h.jsx)(u.InviteLinkControls,{m:e,actorRole:n}),(0,h.jsx)(o.Button,{kind:"ghost",label:"Close",onPress:s,style:{minHeight:56}})]})}},1456,[34,402,794,987,821,1454,25]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1457,[827,979,1161,987,797,1238,1240,34,281,379,236,402,102,426,879,794,874,1249,891,867,858,821,1201,1088,869,1447,1180,1458,1459,1160,1167,1166,1039,13,1164,1170,1230,25]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1458,[827,34,1236,1056,870,379,402,102,794,891,867,858,821,1201,1088,1230,25]); +__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1459,[1016,34,402,102,794,891,821,1088,987,25]); +__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1460,[827,34,1048,395,102,1134,1135,1364,1393,794,1026,1029,858,821,1088,1030,1461,1462,1050,25]); +__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1461,[827,34,402,102,794,821,1029,5,1030,872,987,25]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1462,[34,102,794,1029,1463,859,821,1075,933,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1463,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderAtTableCard=c,_e.OrderAtTableSettings=function(){const e=(0,h.useOwner)(e=>e.site);return(0,u.jsxs)(n.default,{style:{gap:10},children:[(0,u.jsx)(c,{rid:e}),(0,u.jsx)(o.Banner,{kind:"info",title:"Takeaway is separate",children:"Takeaway ordering, slots and the live takeaway queue work the same whichever way this is set. Each venue sets this for itself."})]})};var e=_r(d[0]),t=_r(d[1]);_r(d[2]);var r,s=_r(d[3]),n=(r=s)&&r.__esModule?r:{default:r},o=_r(d[4]),l=_r(d[5]),h=_r(d[6]),u=_r(d[7]);function c({rid:r,compact:s}){const h=(0,l.useOrderAtTable)(r),c=(0,l.useStore)(e=>e.restaurants.find(e=>e.id===r)?.name??'this venue');return e.IS_GREENSIDE?(0,u.jsx)(t.GreensideCashOnly,{}):(0,u.jsx)(n.default,{testID:"order-at-table-card",children:(0,u.jsxs)(o.Card,{children:[(0,u.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsxs)(n.default,{style:{flex:1},children:[(0,u.jsx)(o.T,{weight:"semibold",children:"Order at table"}),(0,u.jsx)(o.Muted,{children:"Guests scan a QR code on the table and order from their phone, then pay at the bar or till. Tables, hours and QR codes: Settings \u203a Advanced \u203a Order at the table."})]}),(0,u.jsx)(o.Toggle,{label:"Order at table",value:h,onChange:e=>l.useStore.getState().updateSettings(r,{orderAtTable:e})})]}),(0,u.jsx)(o.T,{size:13,colour:h?'#E2C489':'#D8CFBF',children:h?`On for ${c}: table QR codes, table orders and table tickets are shown.`:`Off for ${c}: in-house orders go through your till. Takeaway ordering stays on.`}),s?null:(0,u.jsx)(o.Muted,{children:"When it is off: no Order at table or table QR screen in the customer app, no Tables & QR codes page or Table option in Take an order here, no table orders in Live orders, and no table tickets in the Head Chef app."})]})})}},1464,[5,1418,34,102,794,874,891,25]); +__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.PermissionsScreen=function(){const[e,r]=(0,s.useState)(null),[t,y]=(0,s.useState)(''),[f,b]=(0,s.useState)('role'),[j,k]=(0,s.useState)('manager'),[x,w]=(0,s.useState)(null),[L,v]=(0,s.useState)(!1),[R,T]=(0,s.useState)(''),$=(0,s.useCallback)(async()=>{try{r(await(0,d.loadPermissions)()),y('')}catch(e){y(e.message)}},[]);(0,s.useEffect)(()=>{$()},[$]);const E=(0,s.useMemo)(()=>(e?.roles??[]).filter(e=>c.ROLE_ORDER.includes(e.key)),[e]),C=E.find(e=>e.key===j),P=e?.staff.find(e=>e.ref===x)??null,S=!!e?.canEdit,O=async(e,s)=>{v(!0),T('');const r=await e();v(!1);const t=r.ok?s:r.error??'Could not save.';T(t),u(t),r.ok&&await $()};if(t)return(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,colour:l.colours.amber,testID:"perm-error",children:t}),(0,h.jsx)(o.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{$()}})]});if(!e)return(0,h.jsx)(o.Muted,{center:!0,children:"Loading permissions\u2026"});const _=(e,s,r,t,d,u)=>c.PERM_GROUPS.map(m=>(0,h.jsxs)(n.default,{style:{width:'100%',marginTop:6},children:[(0,h.jsx)(o.T,{weight:"semibold",colour:l.colours.gold,size:14,center:!0,accessibilityRole:"header",children:m}),c.PERM_CATALOG.filter(e=>e.group===m).map(n=>{const o=e(n.key);return(0,h.jsx)(p,{id:`${u}-${n.key}`,label:n.label,on:o,locked:s(n.key),note:t(n.key),spoken:r(n.key,o),onPress:()=>d(n.key,o)},n.key)})]},m));return(0,h.jsxs)(n.default,{testID:"permissions-screen",style:{gap:12,width:'100%',alignItems:'center'},children:[(0,h.jsx)(o.Muted,{center:!0,children:"Tick what each role can do, or change one person. These are saved for the whole team and the server checks them on every phone and screen."}),S?null:(0,h.jsx)(n.default,{testID:"perm-readonly",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:12,padding:10},children:(0,h.jsx)(o.T,{center:!0,size:14,children:"Only owners can change permissions. You can see them here."})}),(0,d.permissionsLive)()?null:(0,h.jsx)(o.Muted,{center:!0,size:12,testID:"perm-sample",children:"Sample team: connect to the shared team to see and change your own."}),(0,h.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Chip,{testID:"perm-view-role",label:"By role",selected:'role'===f,onPress:()=>b('role')}),(0,h.jsx)(o.Chip,{testID:"perm-view-person",label:"By person",selected:'person'===f,onPress:()=>b('person')})]}),R?(0,h.jsx)(n.default,{accessibilityLiveRegion:"polite",testID:"perm-msg",children:(0,h.jsx)(o.T,{center:!0,size:15,colour:l.colours.goldLight,children:R})}):null,'role'===f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:E.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-role-${e.key}`,label:c.ROLE_LABEL[e.key]??e.name,sub:e.owner?'Everything':`${(0,c.ticks)(e.perms).length} of ${c.PERM_KEYS.length}`,selected:j===e.key,onPress:()=>k(e.key)},e.key))}),C?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:c.ROLE_LABEL[C.key]??C.name}),C.owner?(0,h.jsx)(o.Muted,{center:!0,children:"Owners can always do everything. This can\u2019t be changed."}):(0,h.jsx)(o.Muted,{center:!0,size:13,children:"Everyone with this role gets these ticks, unless you change them for one person."}),_(e=>(0,c.has)(C.perms,e),()=>C.owner||!S||L,(e,s)=>`${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}.`,e=>c.PERM_CATALOG.find(s=>s.key===e)?.note,(e,s)=>{O(()=>(0,d.saveRolePerms)(C.key,(0,c.toggle)((0,c.ticks)(C.perms),e,!s)),`${s?'Taken off':'Ticked'} for every ${c.ROLE_LABEL[C.key]??C.name}: ${(0,c.permLabel)(e)}. Saved.`)},'perm')]}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,h.jsx)(o.Chip,{testID:`perm-person-${e.ref}`,label:m(e.name),sub:c.ROLE_LABEL[e.role]??e.role,selected:x===e.ref,accessibilityLabel:`${e.name}, ${g(e)}`,onPress:()=>w(e.ref)},e.ref))}),P?(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,size:18,weight:"bold",colour:l.colours.gold,accessibilityRole:"header",children:P.name}),(0,h.jsx)(o.T,{center:!0,size:14,colour:l.colours.muted,testID:"perm-person-facts",children:g(P)}),(0,h.jsx)(o.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:P.extra.length||P.removed.length?(0,h.jsx)(o.Badge,{kind:"gold",label:"Changed just for them"}):(0,h.jsx)(o.Badge,{label:"Same as their role"})}),(0,c.ownerLevel)(P.base)?(0,h.jsx)(o.Muted,{center:!0,children:'owner'===P.role?'Owners can always do everything.':'Temporary owner access: everything. Only an owner can change this, in Staff & roles.'}):null,_(e=>(0,c.has)(P.effective,e),()=>(0,c.ownerLevel)(P.base)||!S||L||P.ref===e.me,(e,s)=>{const r=(0,c.tickSource)(P,e);return`${m(P.name)}: ${(0,c.permLabel)(e)}. ${s?'Ticked':'Not ticked'}${'off'===r?'':`, ${c.SOURCE_WORDS[r]}`}.`},e=>{const s=(0,c.tickSource)(P,e);return'extra'===s||'removed'===s?c.SOURCE_WORDS[s]:'takings.view'===e&&P.cashUp&&!(0,c.has)(P.effective,e)?'Can use cash up: tonight\u2019s cash up only':void 0},(e,s)=>{O(()=>(0,d.savePersonPerms)(P.ref,(0,c.toggle)((0,c.ticks)(P.effective),e,!s)),`${s?'Taken off':'Ticked'} for ${m(P.name)}: ${(0,c.permLabel)(e)}. Saved.`)},'perm-p'),P.ref===e.me?(0,h.jsx)(o.Muted,{center:!0,size:13,children:"You can\u2019t change your own permissions."}):null,S&&(P.extra.length||P.removed.length)?(0,h.jsx)(o.Button,{small:!0,kind:"secondary",testID:"perm-reset",label:"Back to their role",accessibilityLabel:`Put ${m(P.name)} back to the ${c.ROLE_LABEL[P.role]??P.role} role's ticks`,disabled:L,onPress:()=>{O(()=>(0,d.savePersonPerms)(P.ref,null),`${m(P.name)} is back to the ${c.ROLE_LABEL[P.role]??P.role} ticks. Saved.`)}}):null,(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Temporary manager, Temporary owner and Can use cash up are switched in Staff & roles."})]}):(0,h.jsx)(o.Muted,{center:!0,children:"Pick someone to see exactly what they can do."})]}),(0,h.jsxs)(o.Card,{children:[(0,h.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Changes"}),e.log.length?e.log.slice(0,8).map(e=>(0,h.jsxs)(n.default,{testID:"perm-log-row",accessible:!0,accessibilityLabel:`${(0,c.logWhen)(e.at)}. ${(0,c.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{width:'100%',paddingVertical:6,borderTopWidth:1,borderTopColor:l.colours.border,alignItems:'center'},children:[(0,h.jsx)(o.T,{center:!0,size:14,children:(0,c.logWords)(e)}),(0,h.jsxs)(o.Muted,{center:!0,size:12,children:[(0,c.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,h.jsx)(o.Muted,{center:!0,children:"No changes yet."}),(0,h.jsx)(o.Muted,{center:!0,size:12,children:"Every change keeps who made it, when, and what it was before."})]})]})};var s=_r(_d[0]),r=e(_r(_d[1])),t=e(_r(_d[2])),n=e(_r(_d[3])),o=_r(_d[4]),l=_r(_d[5]),c=_r(_d[6]),d=_r(_d[7]),h=_r(_d[8]);const u=e=>{try{r.default.announceForAccessibility?.(e)}catch{}},m=e=>e.split(' ')[0];function p({id:e,label:s,on:r,locked:c,note:d,spoken:u,onPress:m}){return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"checkbox",accessibilityState:{checked:r,disabled:c},"aria-checked":r,accessibilityLabel:u,disabled:c,onPress:m,style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:52,width:'100%',borderTopWidth:1,borderTopColor:l.colours.border,opacity:c&&!r?.6:1},children:[(0,h.jsx)(n.default,{style:{width:28,height:28,borderRadius:7,borderWidth:2,borderColor:r?l.colours.gold:l.colours.muted,backgroundColor:r?l.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:r?(0,h.jsx)(o.T,{weight:"bold",colour:l.colours.onGold,children:"\u2713"}):null}),(0,h.jsxs)(n.default,{style:{flex:1,paddingVertical:6},children:[(0,h.jsx)(o.T,{size:15,children:s}),d?(0,h.jsx)(o.Muted,{size:12,children:d}):null]})]})}function g(e){const s=[c.ROLE_LABEL[e.role]??e.role];return e.ownerAccess&&s.push('temporary owner access'),e.managerAccess&&s.push('temporary manager access'),e.cashUp&&!(0,c.has)(e.effective,'takings.view')?s.push('cash up: tonight only'):(e.cashUp||(0,c.has)(e.effective,'wages.manage'))&&s.push('cash up'),s.join(' \xb7 ')}},1465,[34,281,402,102,794,821,1000,1466,25]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"permissionsLive",{enumerable:!0,get:function(){return f}}),e.loadPermissions=async function(){if(!f())return JSON.parse(JSON.stringify(u()));const{data:r,error:n}=await o().rpc('permissions_get',{p_venue:a.useSync.getState().venueId});if(n)throw new Error(/Only owners and managers/i.test(n.message)?'Only owners and managers can see permissions.':'Could not load the permissions. Try again.');const s=r;return{catalog:s.catalog??[...t.PERM_KEYS],canEdit:!!s.canEdit,me:s.me??null,roles:s.roles??[],staff:s.staff??[],log:s.log??[]}},e.saveRolePerms=async function(r,n,s){if(!f()){const a=u(),o=a.roles.find(a=>a.key===r);if(!o||o.owner)return{ok:!1,error:'Owners always have full access.'};const f=o.perms;return o.perms=[...n].sort(),a.staff.filter(a=>a.role===r).forEach(r=>{r.base=[...new Set([...o.perms,...r.managerAccess?m:[]])].sort(),r.effective=(0,t.effectivePerms)(r.base,r.extra,r.removed)}),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'role',target_ref:r,target_name:o.name,before:f,after:o.perms,reason:s??'Permissions screen'}),{ok:!0}}const{error:c}=await o().rpc('permissions_set_role',{p_venue:a.useSync.getState().venueId,p_role_key:r,p_perms:n,p_reason:s??null});return c?{ok:!1,error:p(c.message)}:{ok:!0}},e.savePersonPerms=async function(r,n,s){if(!f()){const a=u(),o=a.staff.find(a=>a.ref===r);if(!o)return{ok:!1,error:'Unknown staff member'};if('owner'===o.role)return{ok:!1,error:'Owners always have full access.'};const f={extra:o.extra,removed:o.removed};return null==n?(o.extra=[],o.removed=[]):(o.extra=n.filter(r=>!o.base.includes(r)).sort(),o.removed=o.base.filter(r=>t.PERM_KEYS.includes(r)&&!n.includes(r)).sort()),o.effective=(0,t.effectivePerms)(o.base,o.extra,o.removed),a.log.unshift({id:`d${Date.now()}`,at:(new Date).toISOString(),changed_by_name:'You',target_kind:'staff',target_ref:r,target_name:o.name,before:f,after:{extra:o.extra,removed:o.removed},reason:s??'Permissions screen'}),{ok:!0}}const{error:m}=await o().rpc('permissions_set_staff',{p_venue:a.useSync.getState().venueId,p_staff_ref:r,p_perms:n,p_reason:s??null});return m?{ok:!1,error:p(m.message)}:{ok:!0}};var r=_r(_d[0]),a=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),t=_r(_d[4]);const o=()=>(0,r.getSupabase)(),f=()=>{const r=a.useSync.getState();return'staff'===r.kind&&!!r.venueId&&'off'!==r.mode&&'local'!==r.mode},m=['attendance.view','bookings.manage','floor.manage','rota.swap','shift.manager','stock.manage'],c=['bookings.manage','devices.manage','floor.manage','orders.manage','outbox.view','recipes.edit','recipes.signoff','rota.manage','staff.manage','stock.manage','suppliers.manage','suppliers.order','takings.view','venue.settings','wages.manage','wages.view'];let l=null;const d=(r,a)=>'owner'===r?'owner':'Head Chef'===a?'head_chef':'Supervisor'===a?'supervisor':'manager'===r?'manager':'staff';function u(){if(l)return l;const r=[{key:'owner',name:'Owner',owner:!0,perms:['*']},{key:'manager',name:'Manager',owner:!1,perms:[...c]},{key:'supervisor',name:'Supervisor',owner:!1,perms:[...c]},{key:'head_chef',name:'Head Chef',owner:!1,perms:['orders.manage','recipes.edit','recipes.signoff','stock.manage','suppliers.manage','suppliers.order']},{key:'staff',name:'Staff',owner:!1,perms:[]}],a=n.useOwner.getState().staff.filter(r=>r.active&&!r.temp).map(a=>{const n='st-finn'===a.id||'st-agate'===a.id,s=!!a.managerAccess||n,o=n||s&&'manager'===a.role?'staff':a.role,f=d(o,a.level),l=r.find(r=>r.key===f)?.perms??[],u=[...new Set([...l,...s?m:[],...a.ownerAccess?['*',...c]:[]])].sort(),p=n?['bookings.settings']:[],w=n?['rota.swap']:[];return{ref:a.id,name:a.name.replace(' (example)',''),role:f,app:'head_chef'===f?'chef':'staff'===f?'staff':'owner',managerAccess:s,ownerAccess:!!a.ownerAccess,cashUp:n,extra:p,removed:w,base:u,effective:(0,t.effectivePerms)(u,p,w)}}).sort((r,a)=>r.name.localeCompare(a.name)),o=r=>new Date(Date.now()-36e5*r).toISOString(),f=[{id:'l2',at:o(2),changed_by_name:'Admin',target_kind:'role',target_ref:'manager',target_name:'Manager',before:c.filter(r=>'takings.view'!==r),after:c,reason:'Takings split from wages (same access as before)'},{id:'l1',at:o(2.1),changed_by_name:'Admin',target_kind:'staff',target_ref:'st-finn',target_name:a.find(r=>'st-finn'===r.ref)?.name??'Finn',before:null,after:{extra:['bookings.settings'],removed:['rota.swap']},reason:'Moved from the built-in preset (same access as before)'}];return l={catalog:[...t.PERM_KEYS],canEdit:'owner'===s.APP_VARIANT&&!s.IS_CAR,me:n.useOwner.getState().staffAs??null,roles:r,staff:a,log:f},l}const p=r=>/Only an owner/i.test(r)?'Only an owner can change permissions.':/own permissions/i.test(r)?'You can\u2019t change your own permissions.':/Owners always/i.test(r)?'Owners always have full access.':/owner access/i.test(r)?'Only an owner can change the permissions of someone with owner access.':'Could not save. Try again.'},1466,[933,987,891,872,1000]); +__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.useQuestionnaire=P,_e.useProvenance=R,_e.Tick=B,_e.TickLegend=A,_e.useOnboardingDue=M,_e.OnboardingHost=function({go:e}){const{rid:t,role:s}=(0,v.useCtx)(6e4),n=P(t),r=M(t,n);return'owner'===S.APP_VARIANT&&p.CAN.manage(s)&&r&&n?(0,E.jsx)(F,{rid:t,q:n,go:e}):null},_e.SetupChecklist=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),n=P(t),r=(0,m.useOnboard)(e=>e.setup[t]),a=R(t);if(!n)return null;const o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,l=n.onboardedAt||r?.finished;return(0,E.jsxs)(i.default,{style:{gap:10},testID:"setup-checklist",children:[(0,E.jsxs)(u.Card,{highlight:k.colours.gold,children:[(0,E.jsxs)(u.T,{weight:"semibold",children:[l?'Set up':'Getting set up',n.onboardedAt?` \xb7 since ${(0,f.ukDate)(n.onboardedAt)}`:r?.finished?` \xb7 ${(0,f.ukDate)(r.finished)}`:'']}),(0,E.jsx)(i.default,{style:{height:8,borderRadius:4,backgroundColor:k.colours.surface2,overflow:'hidden'},children:(0,E.jsx)(i.default,{style:{width:100*(l&&!o?1:o/w.STEP_IDS.length)+"%",height:8,backgroundColor:k.colours.ok}})}),(0,E.jsx)(u.Muted,{children:n.onboardedAt&&!o?'This venue was set up before the walkthrough existed. Replay it any time to check everything.':`${o} of ${w.STEP_IDS.length} pages checked on this device.`}),(0,E.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(u.Button,{kind:"success",label:l?'Replay welcome':'Resume setup',testID:"replay-welcome",onPress:()=>m.useOnboard.getState().setReplay(t)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Guided setup (detailed)",onPress:()=>e('more','setup')})]})]}),a.any?(0,E.jsx)(A,{}):null,w.STEP_IDS.map(t=>{const n=r?.steps[t],o=_[t].map(e=>a.mark(...e)),l=o.filter(e=>'q'===e).length,d=o.filter(e=>'edited'===e).length;return(0,E.jsx)(u.Card,{onPress:()=>e('more',O[t].page),children:(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,E.jsx)(s.Icon,{name:q[t],size:20,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:w.STEP_TITLE[t]}),(0,E.jsx)(u.Muted,{size:13,children:O[t].label}),l||d?(0,E.jsxs)(u.Row,{gap:6,style:{marginTop:4},children:[l?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"q"}),(0,E.jsx)(u.Muted,{size:12,children:'team'===t||'suppliers'===t||'accounts'===t||'features'===t?'Pre-filled from your questionnaire':`${l} pre-filled from your questionnaire`})]}):null,d?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsxs)(u.Muted,{size:12,children:[d," changed"]})]}):null]}):null]}),(0,E.jsx)(u.Badge,{kind:'done'===n?'ok':'skipped'===n?'amber':'neutral',label:'done'===n?'Checked':'skipped'===n?'Skipped':'To check'})]})},t)}),(0,E.jsxs)(u.Card,{style:{alignItems:'center',backgroundColor:k.colours.bg},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>e('more','tableplan')}),(0,E.jsx)(C.QuestionnaireAnswers,{rid:t,q:n,onEdit:t=>e('more','cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page)})]}),(0,E.jsxs)(u.Card,{style:{alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z}),(0,E.jsx)(u.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),r=e(_r(_d[3])),a=e(_r(_d[4]));_r(_d[5]);var o=e(_r(_d[6]));_r(_d[7]);var l=e(_r(_d[8])),i=e(_r(_d[9])),d=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),h=_r(_d[13]),p=_r(_d[14]),y=_r(_d[15]),m=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),f=_r(_d[20]),w=_r(_d[21]),k=_r(_d[22]),S=_r(_d[23]),v=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),E=_r(_d[27]);function P(e){const s=(0,h.useRestaurant)(e),r=(0,p.useOwner)(e=>e.staff),a=(0,p.useOwner)(e=>e.suppliers),o=(0,y.usePlan)(e),l=(0,m.useOnboard)(t=>t.answers[e]),i=(0,c.useBrand)(e);return(0,n.useMemo)(()=>{if(!s)return null;const n=e===b.VENUE_RID,d=o.areas?.map(e=>e.name)??[],u=(0,j.planCounts)(o),c=(0,w.questionnaireFromFacts)({id:e,name:s.name,tagline:s.tagline,address:s.address??s.location,phone:s.phone,email:s.contactEmail,website:s.website,hasLogo:!!i.logo,hours:s.kitchenHours,hoursNote:s.hoursNote,tables:u.tables||void 0,covers:u.seats||void 0,areas:d.length?d:void 0,team:n?r.filter(e=>e.active).map(e=>({name:e.name,role:e.role,job:e.job})):[],suppliers:n?a.filter(e=>!e.archived).map(e=>({name:e.name,category:e.category,phone:e.phones[0],email:e.email||void 0})):[],pay:s.settings.pay,orderAtTable:s.settings.orderAtTable,takeaway:!s.settings.takeawayPaused,games:s.settings.games,cashUp:s.settings.cashUpRecord}),h=x.SEEDED_ANSWERS[e],p=h?(0,w.cleanQuestionnaire)({...c,...h,venue:{...c.venue,...h.venue??{}},hours:h.hours??c.hours,tables:{...c.tables,...h.tables??{}},team:h.team??[],suppliers:h.suppliers??[],features:{...c.features,...h.features??{}}},e):null;return(0,t.withWildingsQuestionnaireAddress)(e,(0,w.mergeQuestionnaire)((0,w.mergeQuestionnaire)(c,p),l??null))},[s,r,a,o,l,e,i.logo])}const D=(e,t)=>t.reduce((e,t)=>null==e?void 0:e[t],e),I=e=>null!=e&&''!==e&&!(Array.isArray(e)&&!e.length);function R(e){const t=(0,m.useOnboard)(t=>t.answers[e]);return(0,n.useMemo)(()=>{const s='imported'===t?.source,n=s?t:x.SEEDED_ANSWERS[e],r=s||'signup-form'===x.SEEDED_ANSWERS[e]?.source;return{mark:(...e)=>{const a=D(n,e);if(!r&&'pay'!==e[0])return null;if(!I(a))return null;if(!s&&t){const s=D(t,e);if(void 0!==s&&JSON.stringify(s)!==JSON.stringify(a))return'edited'}return'q'},any:r||I(D(n,['pay']))}},[t,e])}const _={venue:[['venue','name'],['venue','tagline'],['venue','address'],['venue','phone'],['venue','email'],['venue','website']],hours:[0,1,2,3,4,5,6].map(e=>['hours','days',e]),tables:[['tables','template'],['tables','tables'],['tables','covers'],['tables','areas']],team:[['team']],suppliers:[['suppliers']],accounts:[['accounts']],pay:[['pay','tipsFrequency'],['pay','tipsAnchorPayday'],['pay','wagePayDay'],['pay','wageCutoffDay']],features:[['features']]};function B({mark:e,testID:t}){return e?'q'===e?(0,E.jsx)(i.default,{testID:t??'q-tick',accessibilityLabel:"From your questionnaire",style:{width:20,height:20,borderRadius:10,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:12,weight:"bold",colour:k.colours.onGold,children:"\u2713"})}):(0,E.jsx)(i.default,{testID:"q-edited",accessibilityLabel:"Edited by you",style:{paddingHorizontal:6,height:20,borderRadius:10,borderWidth:1,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:11,colour:k.colours.gold,children:"\u270e edited"})}):(0,E.jsx)(i.default,{style:{width:20}})}function A({edited:e=!0}){return(0,E.jsxs)(u.Row,{gap:12,wrap:!0,children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"q",testID:"q-legend"}),(0,E.jsx)(u.Muted,{size:12,children:"From your questionnaire"})]}),e?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(B,{mark:"edited"}),(0,E.jsx)(u.Muted,{size:12,children:"Changed by you"})]}):null]})}function M(e,t){const s=(0,m.useOnboard)(t=>t.setup[e]);return(0,m.useOnboard)(e=>e.replay)===e||!(!t||t.onboardedAt)&&(!s?.welcomed&&!s?.finished)}const O={venue:{page:'setup-venue',label:'Edit venue details'},hours:{page:'setup-hours',label:'Edit opening hours'},tables:{page:'tableplan',label:'Open the table plan editor'},team:{page:'staff',label:'Edit staff & roles'},suppliers:{page:'suppliers',label:'Edit suppliers'},accounts:{page:'connections',label:'Open Connected accounts'},pay:{page:'paysettings',label:'Edit pay & tips'},features:{page:'features',label:'See all features'}},q={venue:'home',hours:'clock',tables:'table',team:'user',suppliers:'box',accounts:'swap',pay:'payroll',features:'sparkle'},L={bookings:'Table bookings',takeaway:'Takeaway orders',orderAtTable:'Order at table (QR)',tips:'Tips sharing',rota:'Rota & clocking in',games:'Break room game',specials:'Specials board'},z='Chat with CoverCharge support from Settings. Messages stay on this phone until they are connected. Nobody replies automatically.';function W({at:e}){return(0,E.jsx)(u.Row,{gap:6,style:{justifyContent:'center'},children:w.STEP_IDS.map((t,s)=>(0,E.jsx)(i.default,{style:{width:s===e?22:8,height:8,borderRadius:4,backgroundColor:st.replay===e),b=(0,m.useOnboard)(t=>t.setup[e]),j=w.STEP_IDS.findIndex(e=>!b?.steps[e]),[f,S]=(0,n.useState)(x||!b?.welcomed?-1:j<0?w.STEP_IDS.length:j),P=(0,n.useRef)(new a.default.Value(1)).current,[D,I]=(0,n.useState)(!0);(0,n.useEffect)(()=>{let e=!0;r.default.isReduceMotionEnabled().then(t=>{e&&I(t)});const t=r.default.addEventListener('reduceMotionChanged',I);return()=>{e=!1,t.remove()}},[]),(0,n.useEffect)(()=>{if(D)return void P.setValue(1);P.setValue(0);const e=a.default.timing(P,{toValue:1,duration:300,useNativeDriver:!1});return e.start(),()=>e.stop()},[f,D]);const R=m.useOnboard.getState(),_=()=>{b?.welcomed||R.welcome(e),R.setReplay(null)},B=(s,n)=>{'accounts'===s&&'done'===n&&(0,T.importQuestionnaireAccounts)(e,t,y),R.markStep(e,s,n),S(f+1)},A=t=>{b?.welcomed||R.welcome(e),R.setReplay(null);const s='cashup'===t?'cashup':'menu'===t?'menu':'branding'===t?'branding':O[t].page;h('more',s)};return(0,E.jsx)(o.default,{visible:!0,animationType:D?"none":"fade",onRequestClose:_,children:(0,E.jsx)(d.SafeAreaView,{style:{flex:1,backgroundColor:k.colours.bg},children:-1===f?(0,E.jsx)(l.default,{testID:"onboard-welcome",style:{flex:1},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:24,gap:24},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,width:'100%',maxWidth:560,alignItems:'center',gap:22},children:[(0,E.jsx)(i.default,{style:{width:144,height:144,borderRadius:72,alignItems:'center',justifyContent:'center',shadowColor:k.colours.gold,shadowOpacity:.25,shadowRadius:28,shadowOffset:{width:0,height:0}},children:p.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:144}):(0,E.jsx)(i.default,{style:{width:136,height:136,borderRadius:68,borderWidth:2,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",colour:k.colours.gold,children:t.venue.name.slice(0,1)})})}),(0,E.jsx)(u.T,{center:!0,size:15,colour:k.colours.gold,weight:"semibold",style:{letterSpacing:3,width:'100%'},children:"WELCOME"}),(0,E.jsxs)(u.T,{center:!0,size:30,weight:"bold",style:{width:'100%',maxWidth:'100%'},children:["Thanks for choosing",'\n',"CoverCharge"]}),(0,E.jsxs)(u.T,{center:!0,size:17,colour:k.colours.muted,style:{lineHeight:26,maxWidth:'32ch',width:'100%'},children:["Let\u2019s get ",t.venue.name," ready. Check your details, opening hours and team, then start your day."]}),(0,E.jsx)(u.Button,{testID:"onboard-get-started",label:"Get started",accessibilityLabel:"Get started with your venue setup",onPress:()=>{R.welcome(e),S(0)},style:{minHeight:56,borderRadius:999,width:'100%',maxWidth:320}}),(0,E.jsxs)(i.default,{style:{alignItems:'center',gap:8,width:'100%',marginTop:6},children:[(0,E.jsx)(c.PoweredBy,{size:12}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Chat with CoverCharge support",accessibilityLabel:"Chat with CoverCharge support",onPress:()=>{b?.welcomed||R.welcome(e),R.setReplay(null),h('more','support')}})]})]})}):f===w.STEP_IDS.length?(0,E.jsxs)(l.default,{testID:"onboard-ready-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.ThingsToHaveReady,{onOpenTablePlan:()=>A('tables')}),(0,E.jsx)(u.Button,{testID:"onboard-ready-next",label:"Continue",accessibilityLabel:"Continue to your questionnaire",onPress:()=>S(w.STEP_IDS.length+1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to the previous step",onPress:()=>S(w.STEP_IDS.length-1)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f===w.STEP_IDS.length+1?(0,E.jsxs)(l.default,{testID:"onboard-questionnaire-slide",style:{flex:1,backgroundColor:k.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',padding:22,paddingBottom:40,gap:16,width:'100%',maxWidth:480,alignSelf:'center'},children:[(0,E.jsx)(C.QuestionnaireAnswers,{rid:e,q:t,onEdit:A}),(0,E.jsx)(u.Button,{testID:"onboard-all-correct",label:"All correct",accessibilityLabel:"All correct. Finish the questionnaire.",onPress:()=>S(w.STEP_IDS.length+2)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Back",accessibilityLabel:"Back to things to have ready",onPress:()=>S(w.STEP_IDS.length)}),(0,E.jsx)(u.Button,{kind:"ghost",label:"Finish later",accessibilityLabel:"Finish later",onPress:_})]}):f>w.STEP_IDS.length+1?(0,E.jsx)(G,{rid:e,q:t,onDone:()=>{R.finish(e)}}):(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(i.default,{style:{padding:14,gap:10,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"\u2039 Back",onPress:()=>S(f-1)}),(0,E.jsxs)(u.T,{size:13,colour:k.colours.muted,children:["Step ",f+1," of ",w.STEP_IDS.length]}),(0,E.jsx)(u.Button,{small:!0,kind:"ghost",label:"Finish later",onPress:_})]}),(0,E.jsx)(W,{at:f})]}),(0,E.jsx)(l.default,{contentContainerStyle:{padding:18,paddingBottom:180,gap:14,maxWidth:640,width:'100%',alignSelf:'center'},children:(0,E.jsxs)(a.default.View,{style:{opacity:P,gap:14},children:[(0,E.jsxs)(u.Row,{gap:10,children:[(0,E.jsx)(s.Icon,{name:q[w.STEP_IDS[f]],size:34,colour:k.colours.gold}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{size:24,weight:"bold",children:w.STEP_TITLE[w.STEP_IDS[f]]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:"gold",label:'signup-form'===t.source?'From your questionnaire':'imported'===t.source?'From your imported answers':'From your current setup'}),b?.steps[w.STEP_IDS[f]]?(0,E.jsx)(u.Badge,{kind:'done'===b.steps[w.STEP_IDS[f]]?'ok':'neutral',label:'done'===b.steps[w.STEP_IDS[f]]?'Checked':'Skipped'}):null]})]})]}),(0,E.jsx)(N,{rid:e,step:w.STEP_IDS[f],q:t})]})}),(0,E.jsxs)(i.default,{testID:"onboard-actions",style:{padding:14,gap:8,borderTopWidth:1,borderColor:k.colours.border,maxWidth:640,width:'100%',alignSelf:'center'},children:[(0,E.jsx)(u.Button,{kind:"success",testID:`looks-right-${w.STEP_IDS[f]}`,label:"Looks right \u2713",onPress:()=>B(w.STEP_IDS[f],'done')}),(0,E.jsxs)(u.Row,{gap:8,children:[(0,E.jsx)(u.Button,{kind:"secondary",label:"Edit",onPress:()=>A(w.STEP_IDS[f]),style:{flex:1}}),(0,E.jsx)(u.Button,{kind:"ghost",label:'suppliers'===w.STEP_IDS[f]||'accounts'===w.STEP_IDS[f]?'Skip (optional)':'Skip for now',onPress:()=>B(w.STEP_IDS[f],'skipped'),style:{flex:1}})]})]})]})})})}function $({k:e,v:t,mark:s}){return(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},gap:10,children:[(0,E.jsx)(u.Muted,{children:e}),(0,E.jsx)(u.T,{weight:"medium",style:{flex:1,textAlign:'right'},children:null==t||''===t?'\u2014':String(t)}),void 0!==s?(0,E.jsx)(B,{mark:s}):null]})}function N({rid:e,step:t,q:s}){const n=(0,c.useBrand)(e),{mark:r}=R(e),a=_[t].some(e=>r(...e))?(0,E.jsx)(A,{edited:_[t].some(e=>'edited'===r(...e))}):null;return(0,E.jsxs)(i.default,{style:{gap:10},children:[a,(0,E.jsx)(V,{rid:e,step:t,q:s,brand:n,mark:r})]})}function V({rid:e,step:t,q:s,brand:r,mark:a}){const o=(0,y.usePlan)(e),l=(0,j.planCounts)(o),[d,h]=(0,n.useState)(s.tables.template),[p,x]=(0,n.useState)(s.features);switch(t){case'venue':return(0,E.jsxs)(u.Card,{children:[(0,E.jsxs)(u.Row,{gap:12,children:[r.logo?(0,E.jsx)(c.RestaurantLogo,{rid:e,size:64}):(0,E.jsx)(i.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1,borderColor:k.colours.border,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.Muted,{children:"No logo"})}),(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.T,{size:20,weight:"bold",children:s.venue.name}),(0,E.jsx)(B,{mark:a('venue','name')})]}),s.venue.tagline?(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Muted,{children:s.venue.tagline}),(0,E.jsx)(B,{mark:a('venue','tagline')})]}):null]})]}),(0,E.jsx)($,{k:"Address",v:s.venue.address,mark:a('venue','address')}),(0,E.jsx)($,{k:"Phone",v:s.venue.phone,mark:a('venue','phone')}),(0,E.jsx)($,{k:"Email",v:s.venue.email,mark:a('venue','email')}),(0,E.jsx)($,{k:"Website",v:s.venue.website,mark:a('venue','website')}),r.logo?null:(0,E.jsx)(u.Muted,{children:"No logo yet. Tap Edit, then Branding, to add one; it shows on your guest pages and staff apps."})]});case'hours':return(0,E.jsxs)(u.Card,{children:[w.WEEK_ORDER.map(e=>(0,E.jsx)($,{k:w.DAY_NAMES[e],v:s.hours.days[e]?`${s.hours.days[e][0]} to ${s.hours.days[e][1]}`:'Closed',mark:a('hours','days',e)},e)),s.hours.note?(0,E.jsx)(u.Muted,{children:s.hours.note}):null,(0,E.jsx)(u.Muted,{children:"Guests see these on your booking and order pages. Bookings outside them are turned away."})]});case'tables':return(0,E.jsxs)(u.Card,{children:[l.tables>0?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(u.T,{center:!0,weight:"semibold",testID:"onboard-saved-plan",children:["Your table plan: ",l.tables," tables, ",l.seats," Covers"]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your layout is already saved. Use Edit to change it, or Looks right to keep it."})]}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",children:"Start from a template or keep your own"}),(0,E.jsx)(u.Muted,{center:!0,children:"Choose a starting layout. You can move every table afterwards."}),(0,E.jsx)(i.default,{style:{gap:8,width:'100%'},children:Object.keys(w.TEMPLATE_LABEL).map(t=>(0,E.jsx)(u.Chip,{label:`${w.TEMPLATE_LABEL[t]}${d===t?' \xb7 Selected':''}`,selected:d===t,onPress:()=>{h(t),m.useOnboard.getState().saveAnswers(e,{...s,tables:{...s.tables,template:t}})}},t))})]}),(0,E.jsx)(u.Muted,{center:!0,children:"Your table plan drives bookings, walk-ins and the floor screen."})]});case'team':{const e=s.team.filter(e=>'owner'!==e.role);return(0,E.jsxs)(u.Card,{children:[s.team.length?s.team.map((e,t)=>(0,E.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:6,borderBottomWidth:1,borderColor:k.colours.border},children:[(0,E.jsxs)(i.default,{style:{flex:1},children:[(0,E.jsx)(u.T,{weight:"medium",children:e.name}),(0,E.jsxs)(u.Muted,{size:13,children:[e.job??'',e.email?` \xb7 ${e.email}`:e.phone?` \xb7 ${e.phone}`:'']})]}),(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(u.Badge,{kind:'staff'===e.role?'neutral':'gold',label:'owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff'}),(0,E.jsx)(B,{mark:a('team',t,'name')})]})]},t)):(0,E.jsx)(u.Muted,{children:"No team listed yet. Add people with Edit."}),(0,E.jsx)(u.Banner,{kind:"info",title:`${e.length} invite link${1===e.length?'':'s'} prepared`,children:(0,E.jsx)(u.Muted,{children:"Each person gets their own sign-in link for the Staff app (managers also get the Managers app). They are ready to share from Staff & roles when you are. Nothing has been sent."})})]})}case'suppliers':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Optional. Suppliers feed your order sheets and the shellfish and stock counts."}),s.suppliers.length?s.suppliers.map((e,t)=>(0,E.jsx)($,{k:e.name,v:[e.category,e.phone??e.email].filter(Boolean).join(' \xb7 '),mark:a('suppliers',t,'name')},t)):null,(0,E.jsx)(u.T,{weight:"bold",style:{marginTop:6},children:"Ordering websites"}),(0,E.jsx)(u.Muted,{size:13,children:"Order from Bidfood or Booker? Add them here."}),(0,E.jsx)(T.SupplierPortals,{rid:e,compact:!0})]});case'accounts':return(0,E.jsx)(T.AccountsStep,{q:s,mark:a});case'pay':{const e=s.pay?(0,f.cleanPay)(s.pay):null,t=(0,f.ymdOf)(new Date);if(!e)return(0,E.jsx)(u.Card,{children:(0,E.jsx)(u.Muted,{children:"You didn\u2019t tell us your pay dates. Tap Edit to set when tips and wages are paid; until then Payroll hours uses calendar months."})});const n=(0,f.nextToPay)(e,'tips',t).period,r=(0,f.nextToPay)(e,'wage',t).period;return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)($,{k:"Tips",v:""+('fortnightly'===e.tipsFrequency?'Every two weeks':'weekly'===e.tipsFrequency?'Every week':'Monthly'),mark:a('pay','tipsFrequency')}),(0,E.jsx)($,{k:"Next tips payday",v:n.payday?`${(0,f.ukDate)(n.payday)} (${(0,f.rangeText)(n.start,n.end)})`:'',mark:a('pay','tipsAnchorPayday')}),(0,E.jsx)($,{k:"Wages paid on",v:`the ${e.wagePayDay}${1===e.wagePayDay||21===e.wagePayDay||31===e.wagePayDay?'st':2===e.wagePayDay||22===e.wagePayDay?'nd':3===e.wagePayDay||23===e.wagePayDay?'rd':'th'} of the month`,mark:a('pay','wagePayDay')}),(0,E.jsx)($,{k:"Next payday",v:r.payday?`${(0,f.ukDate)(r.payday)} (${(0,f.rangeText)(r.start,r.end)})`:'',mark:a('pay','wageCutoffDay')}),(0,E.jsx)(u.Muted,{children:"Payroll hours and Tips day use these dates. Only confirmed (signed-off) hours count."})]})}case'features':return(0,E.jsxs)(u.Card,{children:[(0,E.jsx)(u.Muted,{children:"Switch on what you\u2019ll use. You can change these any time in Settings."}),Object.keys(L).map(t=>(0,E.jsxs)(u.Row,{gap:6,children:[(0,E.jsx)(i.default,{style:{flex:1},children:(0,E.jsx)(u.Toggle,{label:L[t],value:p[t],onChange:n=>{return r={...p,[t]:n},x(r),void m.useOnboard.getState().saveAnswers(e,{...s,features:r});var r}})}),(0,E.jsx)(B,{mark:a('features',t)})]},t)),(0,E.jsx)(u.Muted,{size:12,children:"Saved with your answers on this device. Turning on Order at table or the game also needs a manager to switch it on in its own settings page."})]})}}function G({rid:e,q:t,onDone:s}){const r=(0,m.useOnboard)(t=>t.setup[e]),o=w.STEP_IDS.filter(e=>'done'===r?.steps[e]).length,i=w.STEP_IDS.filter(e=>'skipped'===r?.steps[e]),d=(0,n.useRef)(new a.default.Value(0)).current;return(0,n.useEffect)(()=>{a.default.spring(d,{toValue:1,friction:5,useNativeDriver:!1}).start()},[]),(0,E.jsxs)(l.default,{contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:28,gap:16},children:[(0,E.jsx)(a.default.View,{style:{transform:[{scale:d}],width:104,height:104,borderRadius:52,backgroundColor:k.colours.ok,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(u.T,{size:52,weight:"bold",children:"\u2713"})}),(0,E.jsx)(u.T,{size:30,weight:"bold",style:{textAlign:'center'},children:"You\u2019re all set"}),(0,E.jsxs)(u.T,{size:16,colour:k.colours.muted,style:{textAlign:'center',maxWidth:440},children:[t.venue.name," is ready to go. ",o," of ",w.STEP_IDS.length," checked",i.length?`; ${i.map(e=>w.STEP_TITLE[e].toLowerCase()).join(', ')} left for later in Settings \u203a Setup checklist`:'',"."]}),(0,E.jsxs)(u.Card,{style:{maxWidth:440,alignItems:'center'},children:[(0,E.jsx)(u.T,{center:!0,weight:"semibold",colour:k.colours.gold,children:"Chat with CoverCharge support"}),(0,E.jsx)(u.Muted,{center:!0,children:z})]}),(0,E.jsx)(u.Button,{kind:"success",label:"Open my dashboard",onPress:s,testID:"onboard-finish"})]})}},1467,[832,1207,34,281,283,364,395,236,295,102,36,794,873,876,891,1029,1066,1067,5,859,1064,1074,821,872,1088,1468,1471,25]); +__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.ProviderLogo=w,_e.SupplierPortals=k,_e.importQuestionnaireAccounts=T,_e.AccountsStep=function({q:e,mark:n}){const t=e.accounts??[];return(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.Muted,{children:"The services your venue already uses. Listing them lets the Assistant help with them later. Nothing signs in during setup."}),t.length?t.map((e,t)=>{const s=(0,c.providerById)(e.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6,borderBottomWidth:1,borderColor:h.colours.border},children:[s?(0,y.jsx)(w,{p:s,size:32}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??e.provider}),e.handle?(0,y.jsx)(a.Muted,{size:13,children:e.handle}):null]}),(0,y.jsx)(p.Tick,{mark:n('accounts',t,'provider')})]},t)}):(0,y.jsx)(a.Muted,{children:"None listed. Skip, and add them any time in Settings \u203a Connected accounts."}),(0,y.jsx)(a.Muted,{size:13,children:"Looks right adds these to Settings \u203a Connected accounts. Connecting (signing in) happens there, when you\u2019re ready."})]})},_e.ConnectionsPage=function(){const{rid:e,role:n,me:i}=(0,x.useCtx)(6e4),j='owner'===n,B=(0,u.useAccounts)(n=>n.byVenue[e])??b,S=(0,u.useAccounts)(n=>n.log[e])??[],A=(0,p.useQuestionnaire)(e),{mark:M}=(0,p.useProvenance)(e),[P,z]=(0,t.useState)(null),[$,D]=(0,t.useState)(null),[L,N]=(0,t.useState)(!1),O=(0,t.useMemo)(()=>(A?.accounts??[]).map((e,n)=>({a:e,i:n})).filter(({a:e})=>!B.some(n=>n.provider===e.provider)),[A,B]),W=(A?.accounts??[]).some((e,n)=>M('accounts',n,'provider'));return(0,y.jsxs)(l.default,{testID:"connections-page",style:{gap:14},children:[(0,y.jsx)(a.Muted,{children:"The outside services your venue uses: email, website, socials, bookings, payments, accounting and suppliers. Add, re-connect or remove them any time."}),(0,y.jsx)(a.Banner,{kind:"success",title:"Your sign-ins stay safe",children:(0,y.jsx)(a.Muted,{children:"Connecting happens on each service\u2019s own sign-in page. CoverCharge never keeps passwords on this device, and manual sign-in details will only be stored encrypted on our servers, owner-only."})}),W?(0,y.jsx)(p.TickLegend,{edited:!1}):null,O.length?(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:"From your questionnaire"}),O.map(({a:n,i:t})=>{const s=(0,c.providerById)(n.provider);return(0,y.jsxs)(a.Row,{gap:10,style:{paddingVertical:6},children:[s?(0,y.jsx)(w,{p:s,size:34}):null,(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:s?.name??n.provider}),n.handle?(0,y.jsx)(a.Muted,{size:13,children:n.handle}):null]}),(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}),j?(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Add",onPress:()=>u.useAccounts.getState().add(e,{provider:n.provider,handle:n.handle,status:'listed',from:'questionnaire',addedBy:i})}):null]},n.provider)}),j&&O.length>1?(0,y.jsx)(a.Button,{kind:"success",label:`Add all ${O.length}`,onPress:()=>A&&T(e,A,i)}):null]}):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Your accounts"}),(0,y.jsx)(a.Badge,{kind:"gold",label:`${B.length}`})]}),B.length?B.map(e=>{const n=(0,c.providerById)(e.provider)??v('suppliers'),t=(A?.accounts??[]).findIndex(n=>n.provider===e.provider);return(0,y.jsxs)(l.default,{testID:`conn-row-${e.provider}`,style:{paddingVertical:8,borderBottomWidth:1,borderColor:h.colours.border,gap:6},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:n,size:36}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"medium",children:f(e)}),(0,y.jsx)(a.Muted,{size:13,children:[c.CATEGORY_TITLE[n.category],e.handle,e.accountNo?`Account ${e.accountNo}`:''].filter(Boolean).join(' \xb7 ')})]}),'questionnaire'===e.from&&t>=0?(0,y.jsx)(p.Tick,{mark:M('accounts',t,'provider')}):null,(0,y.jsx)(a.Badge,{kind:I[e.status].kind,label:I[e.status].label})]}),j?(0,y.jsxs)(a.Row,{gap:8,children:[n.links?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",label:"Open ordering",onPress:()=>{s.default.openURL(n.links.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Log in",onPress:()=>{s.default.openURL(n.links.login)}})]}):(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:'connected'===e.status?'Re-connect':'Connect',onPress:()=>z({p:n,existing:e})}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`conn-remove-${e.provider}`,label:"Remove",onPress:()=>D(e)})]}):null]},e.id)}):(0,y.jsx)(a.Muted,{children:"Nothing added yet. Pick a service below."}),j?null:(0,y.jsx)(a.Muted,{size:13,children:"Only the owner can add or remove the venue\u2019s accounts."})]}),j?c.CATEGORY_ORDER.map(n=>(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(a.T,{weight:"bold",children:c.CATEGORY_TITLE[n]}),'suppliers'===n?(0,y.jsx)(k,{rid:e}):null,(0,y.jsx)(a.Row,{gap:10,wrap:!0,children:[...c.PROVIDERS.filter(e=>e.category===n&&!e.links),v(n)].map(e=>{const n=B.some(n=>n.provider===e.id);return(0,y.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Connect ${e.name}`,testID:`conn-tile-${e.id}`,onPress:()=>z({p:e}),style:{width:104,padding:10,borderRadius:12,borderWidth:1,borderColor:n?h.colours.ok:h.colours.border,alignItems:'center',justifyContent:'center',gap:6,backgroundColor:h.colours.surface2},children:[(0,y.jsx)(w,{p:e,size:40}),(0,y.jsx)(a.T,{size:12,style:{textAlign:'center'},children:e.id.startsWith('other-')?'Other / enter manually':e.name}),n?(0,y.jsx)(a.Badge,{kind:"ok",label:"Added"}):null]},e.id)})})]},n)):null,(0,y.jsxs)(a.Card,{children:[(0,y.jsx)(o.default,{accessibilityRole:"button",onPress:()=>N(!L),children:(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(a.T,{weight:"bold",children:"Activity"}),(0,y.jsx)(a.Muted,{children:L?'Hide':`Show (${S.length})`})]})}),L?S.length?S.slice(0,30).map((e,n)=>(0,y.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(a.Muted,{size:13,children:[e.what," \xb7 ",e.by]}),(0,y.jsx)(a.Muted,{size:12,children:new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})})]},n)):(0,y.jsx)(a.Muted,{children:"No changes yet."}):null]}),(0,y.jsx)(R,{rid:e,sheet:P,owner:j,by:i,onClose:()=>z(null)}),$?(0,y.jsx)(C,{rid:e,c:$,by:i,onClose:()=>D(null)}):null]})};var n=r(d[0]),t=r(d[1]),s=e(r(d[2])),o=e(r(d[3])),i=e(r(d[4])),l=e(r(d[5])),a=r(d[6]),c=r(d[7]),u=r(d[8]),h=r(d[9]),p=r(d[10]),x=r(d[11]),j=r(d[12]),y=r(d[13]);const b=[],v=e=>({id:`other-${e}`,name:'Other',category:e,colour:'#2A2722',mark:'+',handleLabel:'Name of the service',oauth:'soon'}),f=e=>e.customName??(0,c.providerById)(e.provider)?.name??e.provider;function w({p:e,size:n=40}){return(0,y.jsx)(l.default,{accessibilityLabel:`${e.name} logo`,style:{width:n,height:n,borderRadius:.24*n,backgroundColor:e.colour,borderWidth:1,borderColor:h.colours.border,alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(a.T,{size:Math.round(n*(e.mark.length>2?.3:.42)),weight:"bold",colour:e.fg??'#fff',children:e.mark})})}function k({rid:e,compact:n}){const{role:o,me:i}=(0,x.useCtx)(6e4),p=j.CAN.manage(o),v=(0,u.useAccounts)(n=>n.byVenue[e])??b,[f,k]=(0,t.useState)({}),[T,B]=(0,t.useState)(null),I=u.useAccounts.getState();return(0,y.jsxs)(l.default,{style:{gap:10,width:'100%',maxWidth:'100%',minWidth:0},testID:"supplier-portals",children:[c.SUPPLIER_PORTALS.map(t=>{const o=v.find(e=>e.provider===t.id),c=t.links,u=f[t.id]??o?.accountNo??'';return(0,y.jsxs)(l.default,{testID:`portal-${t.id}`,style:{width:'100%',maxWidth:'100%',minWidth:0,alignSelf:'stretch',gap:10,padding:10,borderRadius:12,borderWidth:1,borderColor:o?h.colours.ok:h.colours.border,backgroundColor:h.colours.surface2},children:[(0,y.jsxs)(l.default,{style:{alignItems:'center',gap:8,width:'100%'},children:[(0,y.jsx)(w,{p:t,size:n?34:40}),(0,y.jsx)(a.T,{center:!0,weight:"bold",children:t.name}),t.note?(0,y.jsx)(a.Muted,{center:!0,size:13,children:t.note}):null,o?(0,y.jsx)(a.Badge,{kind:"gold",label:"Added"}):null]}),(0,y.jsxs)(l.default,{style:{flexDirection:'row',gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Button,{small:!0,kind:"success",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-order-${t.id}`,label:"Open ordering",onPress:()=>{s.default.openURL(c.order)}}),(0,y.jsx)(a.Button,{small:!0,kind:"secondary",style:{flex:1,minWidth:0,paddingHorizontal:6},testID:`portal-login-${t.id}`,label:"Log in",onPress:()=>{s.default.openURL(c.login)}})]}),p?(0,y.jsxs)(l.default,{style:{gap:8,width:'100%',alignItems:'stretch'},children:[(0,y.jsx)(a.Field,{label:`${c.accountLabel} (optional)`,value:u,onChangeText:e=>k({...f,[t.id]:e}),placeholder:"e.g. 123456789",autoCapitalize:"characters",testID:`portal-acct-${t.id}`}),(0,y.jsx)(l.default,{style:{gap:8,width:'100%'},children:o?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{small:!0,kind:"secondary",label:"Save number",disabled:u===(o.accountNo??''),onPress:()=>I.update(e,o.id,{accountNo:u},i,`Updated ${t.name} account number`)}),(0,y.jsx)(a.Button,{small:!0,kind:"ghost",testID:`portal-remove-${t.id}`,label:"Remove",onPress:()=>B(o)})]}):(0,y.jsx)(a.Button,{small:!0,kind:"success",testID:`portal-add-${t.id}`,label:`Add ${t.name}`,onPress:()=>I.add(e,{provider:t.id,accountNo:u||void 0,status:'listed',from:'added',addedBy:i})})}),(0,y.jsxs)(a.Muted,{center:!0,size:12,children:["Sign in on ",t.name,"\u2019s website. Your password is not stored here."]})]}):o?.accountNo?(0,y.jsxs)(a.Muted,{size:13,children:["Account ",o.accountNo]}):null]},t.id)}),T?(0,y.jsx)(C,{rid:e,c:T,by:i,onClose:()=>B(null)}):null]})}function C({rid:e,c:n,by:t,onClose:s}){return(0,y.jsx)(a.Sheet,{visible:!0,onClose:s,title:`Remove ${f(n)}?`,testID:"conn-remove-sheet",children:(0,y.jsxs)(l.default,{style:{gap:12},children:[(0,y.jsx)(a.Banner,{kind:"danger",title:"This removes it from CoverCharge for this venue",children:(0,y.jsxs)(a.Muted,{children:["The Assistant will stop using ",f(n),". Nothing is deleted in your ",f(n)," account itself, and you can add it again later."]})}),(0,y.jsx)(a.Button,{kind:"danger",testID:"conn-remove-confirm",label:`Yes, remove ${f(n)}`,onPress:()=>{u.useAccounts.getState().remove(e,n.id,t),s()}}),(0,y.jsx)(a.Button,{kind:"ghost",label:"Keep it",onPress:s})]})})}function T(e,n,t){const s=u.useAccounts.getState(),o=s.byVenue[e]??[];for(const i of n.accounts??[])o.some(e=>e.provider===i.provider)||s.add(e,{provider:i.provider,handle:i.handle,status:'listed',from:'questionnaire',addedBy:t})}function B({rid:e,p:s,existing:p,owner:x,by:j,onClose:b}){const[v,k]=(0,t.useState)(p?.handle??''),[C,T]=(0,t.useState)(p?.customName??''),[B,I]=(0,t.useState)(!1),[R,S]=(0,t.useState)(!1);if(!s)return null;const A=s.id.startsWith('other-');return(0,y.jsx)(a.Sheet,{visible:!0,onClose:b,title:p?`Re-connect ${f(p)}`:`Connect ${A?'another service':s.name}`,testID:"connect-sheet",children:(0,y.jsxs)(i.default,{contentContainerStyle:{gap:12},children:[(0,y.jsxs)(a.Row,{gap:10,children:[(0,y.jsx)(w,{p:s,size:44}),(0,y.jsxs)(l.default,{style:{flex:1},children:[(0,y.jsx)(a.T,{weight:"bold",children:A?c.CATEGORY_TITLE[s.category]:s.name}),s.note?(0,y.jsx)(a.Muted,{size:13,children:s.note}):null]})]}),A?(0,y.jsx)(a.Field,{label:"Service name",value:C,onChangeText:T,placeholder:"e.g. our local fish supplier\u2019s portal",testID:"conn-custom-name"}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a.Button,{kind:"success",testID:"connect-oauth",label:`Connect with ${s.name}`,onPress:()=>I(!0)}),(0,y.jsxs)(a.Row,{gap:6,children:[(0,y.jsx)(a.Badge,{kind:"amber",label:"Coming soon"}),(0,y.jsxs)(a.Muted,{size:13,style:{flex:1},children:["You\u2019ll sign in on ",s.name,"\u2019s own page; CoverCharge never sees your password."]})]}),B?(0,y.jsx)(a.Banner,{kind:"info",title:`Connect with ${s.name} is coming soon`,children:(0,y.jsx)(a.Muted,{children:"It isn\u2019t switched on yet. For now, save it to your list below so the Assistant knows you use it, and we\u2019ll tell you when it\u2019s ready."})}):null]}),(0,y.jsx)(a.Field,{label:`${s.handleLabel} (public name only, optional)`,value:v,onChangeText:k,placeholder:s.handleLabel,autoCapitalize:"none",testID:"conn-handle"}),(0,y.jsx)(a.Button,{kind:A?'success':'secondary',testID:"conn-save-list",label:p?'Save changes':'Save to my list',onPress:()=>{const n=u.useAccounts.getState();p?n.update(e,p.id,{handle:v.trim()||void 0,customName:A&&C.trim()||void 0},j,`Updated ${f(p)}`):n.add(e,{provider:s.id,customName:A?C.trim()||'Other':void 0,handle:v.trim()||void 0,status:'listed',from:'added',addedBy:j}),b()},disabled:A&&!C.trim()}),(0,y.jsx)(o.default,{accessibilityRole:"button",testID:"conn-manual-toggle",onPress:()=>S(!R),children:(0,y.jsxs)(a.T,{colour:h.colours.goldLight,children:[R?'\u25be':'\u25b8'," Other / enter sign-in details manually"]})}),R?x?(0,y.jsxs)(l.default,{style:{gap:8},testID:"conn-manual",children:[(0,y.jsx)(a.Banner,{kind:"warn",title:"Secure storage coming next",children:(0,y.jsx)(a.Muted,{children:"Manual sign-in details will only ever be saved encrypted on our servers: visible to the owner only, shown masked (like \u2022\u2022\u2022\u2022\u2022\u202242), and every view is logged. That storage isn\u2019t switched on yet, so nothing can be entered here today. Nothing is ever saved on this device."})}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Username or email"}),(0,y.jsx)(n.TextInput,{editable:!1,style:a.styles.input,placeholder:"Available when secure storage is ready",placeholderTextColor:h.colours.muted})]}),(0,y.jsxs)(l.default,{style:{gap:4,opacity:.5},children:[(0,y.jsx)(a.Muted,{size:13,children:"Password"}),(0,y.jsx)(n.TextInput,{editable:!1,secureTextEntry:!0,style:a.styles.input,placeholder:"\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",placeholderTextColor:h.colours.muted})]}),(0,y.jsx)(a.Button,{kind:"success",testID:"manual-save",label:"Secure storage coming next",disabled:!0})]}):(0,y.jsx)(a.Banner,{kind:"info",title:"Owner only",children:(0,y.jsx)(a.Muted,{children:"Only the owner can add sign-in details for the venue\u2019s accounts."})}):null,(0,y.jsx)(a.Button,{kind:"ghost",label:"Close",onPress:b})]})})}const I={connected:{kind:'ok',label:'Connected'},listed:{kind:'neutral',label:'Listed \xb7 not signed in'},'needs-reconnect':{kind:'amber',label:'Needs re-connecting'}};function R({rid:e,sheet:n,owner:t,by:s,onClose:o}){return n?(0,y.jsx)(B,{rid:e,p:n.p,existing:n.existing,owner:t,by:s,onClose:o},n.existing?.id??n.p.id):null}},1468,[827,34,379,402,295,102,794,1469,1470,821,1467,1088,891,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CATEGORY_TITLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"CATEGORY_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PROVIDERS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"providerById",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SUPPLIER_PORTALS",{enumerable:!0,get:function(){return c}});const o={email:'Email',website:'Website',social:'Work social media',bookings:'Bookings & reviews',payments:'Payments & till',accounting:'Accounting',suppliers:'Suppliers'},s=['email','website','social','bookings','payments','accounting','suppliers'],n=(o,s,n,t,l,c,u,b)=>({id:o,name:s,category:n,colour:t,mark:l,handleLabel:c,oauth:'soon',fg:u,note:b}),t=[n('gmail','Gmail','email','#EA4335','G','Email address'),n('outlook','Outlook','email','#2A2722','O','Email address'),n('icloud','iCloud Mail','email','#2A2722','\u2601','Email address'),n('yahoo','Yahoo Mail','email','#2A2722','Y!','Email address'),n('wix','Website bookings','website','#FFFFFF','WB','Website address','#000000'),n('shopify','Shopify','website','#B08D57','S','Shop address'),n('squarespace','Squarespace','website','#111111','\u25a3','Website address'),n('wordpress','WordPress','website','#2A2722','W','Website address'),n('godaddy','GoDaddy','website','#E2C489','GD','Website address','#1F1A12'),n('facebook','Facebook Page','social','#2A2722','f','Page name',void 0,'Your venue\u2019s Page, not a personal profile.'),n('instagram','Instagram (business)','social','#C13584','IG','@handle',void 0,'A business or creator account.'),n('tiktok','TikTok','social','#000000','\u266a','@handle'),n('google-business','Google Business Profile','social','#2A2722','G','Business name'),n('wix-tables','Website bookings table reservations','bookings','#FFFFFF','WT','Site','#000000'),n('tripadvisor','Tripadvisor','bookings','#E2C489','TA','Listing','#000000'),n('sumup','SumUp','payments','#1A1A1A','SU','Merchant'),n('stripe','Stripe','payments','#2A2722','S','Account'),n('zettle','Zettle by PayPal','payments','#2A2722','Z','Account'),n('quickbooks','QuickBooks','accounting','#8A6A3B','qb','Company'),n('xero','Xero','accounting','#2A2722','x','Organisation'),n('cc-books','CoverCharge Books','accounting','#CFA45F','CC','Books','#1A1408','Our own simple bookkeeping (coming soon).'),{...n('bidfood','Bidfood','suppliers','#E30613','BF','Account name'),note:'Wholesale food, drink and catering supplies.',links:{order:'https://www.bidfood.co.uk/login/',login:'https://www.bidfood.co.uk/login/',accountLabel:'Bidfood account number'}},{...n('booker','Booker','suppliers','#0055A5','B','Account name'),note:'Wholesale and cash & carry.',links:{order:'https://www.booker.co.uk',login:'https://www.booker.co.uk',accountLabel:'Booker customer number'}},n('coldweb','Coldweb','suppliers','#2A2722','CW','Customer account'),n('supplier-custom','Other supplier portal','suppliers','#2A2722','+','Supplier and account')],l=o=>t.find(s=>s.id===o),c=t.filter(o=>o.links)},1469,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.looksSecret=l,Object.defineProperty(_e,"useAccounts",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),s=r(d[2]);const c=/^\s*(password|passwd|pwd|passcode|pin|otp|secret|token|api[ _-]?key)\s*[:=]/i,u=/\b(sk|pk|rk)_(live|test)_|\bghp_|\bxox[abp]-|\bAKIA[0-9A-Z]{12}|\beyJ[A-Za-z0-9_-]{10,}\./;function l(e){return!(!c.test(e)&&!u.test(e))||e.split(/\s+/).some(e=>e.length>=24&&/[A-Za-z]/.test(e)&&/\d/.test(e)&&!/^[\w.+-]+@[\w-]+\.[\w.]+$/.test(e)&&!/^(https?:\/\/|www\.)/i.test(e))}const b=e=>e&&!l(e)&&e.trim().slice(0,120)||void 0,p=e=>{const t=e?.trim();return t&&/^[A-Za-z0-9 -]{1,20}$/.test(t)?t:void 0},y=(0,n.create)()((0,s.persist)(e=>({byVenue:{},log:{},add:(t,o)=>e(e=>{const n={...o,handle:b(o.handle),customName:b(o.customName),accountNo:p(o.accountNo),id:`c-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,addedAt:(new Date).toISOString()};return{byVenue:{...e.byVenue,[t]:[...e.byVenue[t]??[],n]},log:{...e.log,[t]:[{at:n.addedAt,by:o.addedBy,what:`Added ${o.customName??o.provider}`},...e.log[t]??[]].slice(0,200)}}}),update:(t,o,n,s,c)=>e(e=>({byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).map(e=>e.id===o?{...e,...n,handle:void 0!==n.handle?b(n.handle):e.handle,accountNo:void 0!==n.accountNo?p(n.accountNo):e.accountNo}:e)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:s,what:c},...e.log[t]??[]].slice(0,200)}})),remove:(t,o,n)=>e(e=>{const s=(e.byVenue[t]??[]).find(e=>e.id===o);return{byVenue:{...e.byVenue,[t]:(e.byVenue[t]??[]).filter(e=>e.id!==o)},log:{...e.log,[t]:[{at:(new Date).toISOString(),by:n,what:`Removed ${s?.customName??s?.provider??'an account'}`},...e.log[t]??[]].slice(0,200)}}})}),{name:'covercharge-accounts-v1',version:1,storage:(0,s.createJSONStorage)(()=>o.default)}))},1470,[839,846,849]); +__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.ThingsToHaveReady=function({onOpenTablePlan:e}){return(0,h.jsxs)(s.default,{testID:"onboard-ready",style:{width:'100%',alignItems:'center',gap:14},children:[b('Things to have ready'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Gather these before you check the questionnaire. Nothing here is sent."}),d.READY_ITEMS.map((t,a)=>(0,h.jsxs)(s.default,{testID:`ready-item-${a+1}`,accessible:!0,accessibilityLabel:t,style:{width:'100%',alignItems:'center',gap:6,minHeight:48},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:"\u2713"}),(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:t}),0===a&&e?(0,h.jsx)(n.Button,{kind:"ghost",label:"Open the table plan",accessibilityLabel:"Open the table plan to add a drawing or picture",onPress:e}):null]},t))]})},_e.QuestionnaireAnswers=function({q:e,rid:t,onEdit:y}){const E=(0,i.usePlan)(t),j=(0,a.useMenu)(t),f=(0,l.useAccounts)(e=>e.byVenue[t])??p,x=(E.areas??[]).map(e=>{const t=(0,o.planCounts)(E,e.id);return t.tables?`${e.name}: ${t.tables} ${1===t.tables?'table':'tables'}, ${t.seats} Covers`:e.name}),$=x.length?x:(e.tables.areas??[]).map(e=>e);(e.tables.tables||e.tables.covers)&&$.unshift([e.tables.tables?`${e.tables.tables} tables`:'',e.tables.covers?`${e.tables.covers} Covers`:''].filter(Boolean).join(', '));const w=c.WEEK_ORDER.map(t=>`${c.DAY_NAMES[t]}: ${e.hours.days[t]?`${e.hours.days[t][0]} to ${e.hours.days[t][1]}`:'Closed'}`),D=e.team.map(e=>{const t='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Staff',s=e.job&&e.job.trim().toLowerCase()!==t.toLowerCase()?e.job.trim():'';return[e.name,s,t].filter(Boolean).join(', ')}),v=e.suppliers.map(e=>[e.name,e.category,e.phone,e.email].filter(Boolean).join(', ')),I=f.filter(e=>e.accountNo).map(e=>`${e.customName||e.provider}: ${e.accountNo}`),L=e.pay?["Tips "+('fortnightly'===e.pay.tipsFrequency?'every two weeks':'weekly'===e.pay.tipsFrequency?'every week':'monthly'),e.pay.tipsAnchorPayday?`Next tips payday anchor ${e.pay.tipsAnchorPayday}`:'',e.pay.wagePayDay?`Wages on day ${e.pay.wagePayDay}`:''].filter(Boolean):[],T=j.filter(e=>Object.keys(e.allergens??{}).length).length,q=j.length?[`${j.length} ${1===j.length?'dish':'dishes'} on the menu`]:[],N=j.length?[T?`Recorded on ${T} ${1===T?'dish':'dishes'}`:d.NOT_ANSWERED]:[],_=[e.venue.name,e.venue.tagline,e.venue.address,e.venue.phone,e.venue.email,e.venue.website].filter(e=>!!e&&''!==e.trim());return(0,h.jsxs)(s.default,{testID:"onboard-questionnaire",style:{width:'100%',alignItems:'center',gap:4},children:[b('Your questionnaire'),(0,h.jsx)(n.T,{center:!0,colour:u.colours.muted,children:"Tap a section to edit it. Blank answers stay blank."}),(0,h.jsx)(m,{testID:"q-venue",title:"Venue",lines:_,onEdit:()=>y('venue'),editLabel:"Edit venue"}),(0,h.jsx)(m,{testID:"q-hours",title:"Opening hours",lines:w,onEdit:()=>y('hours'),editLabel:"Edit opening hours"}),(0,h.jsx)(m,{testID:"q-tables",title:"Table plan",lines:$,onEdit:()=>y('tables'),editLabel:"Edit table plan"}),(0,h.jsx)(m,{testID:"q-team",title:"Staff and roles",lines:D,onEdit:()=>y('team'),editLabel:"Edit staff and roles"}),(0,h.jsx)(m,{testID:"q-pay",title:"Pay and tips dates",lines:L,onEdit:()=>y('pay'),editLabel:"Edit pay and tips"}),(0,h.jsx)(m,{testID:"q-suppliers",title:"Suppliers",lines:v,onEdit:()=>y('suppliers'),editLabel:"Edit suppliers"}),(0,h.jsx)(m,{testID:"q-accounts",title:"Supplier account numbers",lines:I,onEdit:()=>y('accounts'),editLabel:"Edit account numbers"}),(0,h.jsx)(m,{testID:"q-logo",title:"Logo",lines:e.venue.hasLogo?['Logo added']:[],onEdit:()=>y('branding'),editLabel:"Edit logo"}),(0,h.jsx)(m,{testID:"q-menu",title:"Menu",lines:q,onEdit:()=>y('menu'),editLabel:"Edit menu"}),(0,h.jsx)(m,{testID:"q-allergens",title:"Allergens",lines:N,onEdit:()=>y('menu'),editLabel:"Edit allergens"}),(0,h.jsx)(m,{testID:"q-cashup",title:"What to record at nightly cash up",lines:e.cashUp??[],onEdit:()=>y('cashup'),editLabel:"Edit cash up"})]})},r(_d[0]);var t=e(r(_d[1])),s=e(r(_d[2])),n=r(_d[3]),a=r(_d[4]),l=r(_d[5]),i=r(_d[6]),o=r(_d[7]),d=r(_d[8]),c=r(_d[9]),u=r(_d[10]),h=r(_d[11]);const p=[],b=e=>(0,h.jsx)(n.T,{accessibilityRole:"header",center:!0,size:22,weight:"bold",colour:u.colours.gold,style:{width:'100%'},children:e});const y=e=>e.replace(/([@.])/g,'$1\u200b');function m({testID:e,title:s,lines:a,onEdit:l,editLabel:i}){const o=a.length?a.join('. '):d.NOT_ANSWERED;return(0,h.jsxs)(t.default,{testID:e,accessibilityRole:"button",accessibilityLabel:`${s}. ${o}. ${i}.`,onPress:l,style:{width:'100%',minHeight:48,alignItems:'center',gap:4,paddingVertical:10,paddingHorizontal:8,borderTopWidth:1,borderColor:u.colours.border},children:[(0,h.jsx)(n.T,{center:!0,weight:"bold",colour:u.colours.gold,children:s}),(a.length?a:[d.NOT_ANSWERED]).map((e,t)=>(0,h.jsx)(n.T,{center:!0,style:{width:'100%'},children:y(e)},`${s}-${t}`)),(0,h.jsx)(n.T,{center:!0,size:14,colour:u.colours.gold,children:i})]})}},1471,[34,402,102,794,876,1470,1029,859,1472,1074,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"READY_ITEMS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_ANSWERED",{enumerable:!0,get:function(){return t}});const n=['A drawing or other picture of the table plan with area names labelled and how many people each seats','Opening hours','Staff and roles','Pay and tips dates','Supplier account numbers','Logo','Menu','Allergens'],t='Not answered yet'},1472,[]); +__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1473,[828,34,283,364,236,402,102,846,794,821,25]); +__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1474,[1202,1099,1140,1117,34,402,102,794,891,858,821,1118,1188,1088,1199,1447,1181,876,1203,869,1201,925,1424,1029,860,1126,1218,1222,1098,25]); +__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.Forecasts=function({go:e}){const{rid:v,r:$,now:S,today:T}=(0,x.useCtx)(3e4),{width:B}=(0,a.default)(),C=(0,r.useBookings)(v),D=(0,r.useOrders)(v),M=(0,r.useEvents)(v),[P,A]=(0,s.useState)(7),F=(0,k.useRealHistory)(v,S),E=(0,s.useMemo)(()=>(0,l.forecastToday)($,C,D,M,S,F??void 0),[$,C,D,M,F,S.getTime()/6e4|0]),I=(0,s.useMemo)(()=>Array.from({length:P},(e,s)=>{const t=(0,c.addMins)((0,c.parseYmd)(T),1440*s);return{d:t,f:(0,l.forecastToday)($,C,D,M,t,F??void 0)}}),[$,C,D,M,T,P,F]),R=E.hours.reduce((e,s)=>e+s.booked,0),H=(0,i.showTakeaway)($),[L,N]=(0,s.useState)(H),O=M.filter(e=>e.date>=T).sort((e,s)=>e.date.localeCompare(s.date)).slice(0,14),_=Math.min(B,900)-60,Y=e=>I.map(s=>{const t='booked'===e?s.f.hours.reduce((e,s)=>e+s.booked,0):s.f.restOfDay.covers;return{key:(0,c.ymd)(s.d),label:(0,c.dayShort)(s.d),spoken:(0,c.dayLong)(s.d),value:s.f.open?t:0,open:!!s.f.open}}),G=(0,j.jsx)(d.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,j.jsx)(d.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:P===e,onPress:()=>A(e),testID:`forecast-range-${e}`},e))});return E.enough?(0,j.jsxs)(o.default,{style:{gap:12},children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(o.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:[7===P?'This week':`Next ${P} days`," \xb7 forecast covers"]}),E.example?(0,j.jsx)(k.ExampleBadge,{}):(0,j.jsx)(d.Badge,{kind:"amber",label:"ESTIMATE"})]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('forecast'),titleSpoken:`Forecast covers for the next ${P} days`}),I.filter(e=>e.f.flags.length).map(e=>(0,j.jsxs)(d.Muted,{center:!0,children:[(0,c.niceDate)(e.d),": ",e.f.flags.join(', ')," (\xd7",e.f.multiplier.toFixed(2),")"]},(0,c.ymd)(e.d)))]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",colour:u.colours.gold,children:"Suggested actions"}),E.suggestions.map((e,s)=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},s)),(0,j.jsx)(d.Muted,{children:E.example?`${n.EXAMPLE_ACCURACY}. Example figures: confirmed bookings + example weekday/hour averages + expected walk-ins, adjusted for calendar events.`:'Baseline: confirmed bookings + your own weekday/hour averages from past bookings, walk-ins and takeaway, adjusted for calendar events. An estimate, never a promise.'})]}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:H?u.colours.gold:u.colours.muted,children:"Takeaway"}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:L?'Hide':'Show',testID:"forecast-takeaway-toggle",onPress:()=>N(!L)})]}),L?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(d.Muted,{children:"Takeaway orders by hour (forecast vs placed)"}),(0,j.jsx)(f.LineChart,{width:_,series:[E.hours.map(e=>e.takeaway),E.hours.map(e=>e.takeawayPlaced)],labels:E.hours.map(e=>String(e.hour))}),(0,j.jsxs)(d.Row,{gap:12,children:[(0,j.jsx)(d.Muted,{children:"Gold: forecast"}),(0,j.jsx)(d.Muted,{children:"Blue: placed so far"})]})]}):null]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.map(s=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(s.title)}),(0,j.jsx)(d.Badge,{kind:w[s.kind][1],label:w[s.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(s.date))," ",s.date.slice(0,4),s.description?` \xb7 ${s.description}`:'']}),'regular'===s.source?(0,j.jsx)(d.Muted,{children:[s.time?`From ${(0,i.fmt12)(s.time)}`:'',s.lastFood?`last food orders ${(0,i.fmt12)(s.lastFood)}`:'',s.busier?'expect busier':''].filter(Boolean).join(' \xb7 ')}):null,'regular'===s.source?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",testID:`promote-${s.id}`,label:`Promote: ${s.title} ${p(s.date,T)}`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:`${s.title} ${p(s.date,T)}`,body:`${s.title} at ${$.name} ${p(s.date,T)}${s.time?` from ${(0,i.fmt12)(s.time)}`:''}.${s.lastFood?` Food until ${(0,i.fmt12)(s.lastFood)}.`:''} Book a table in the app.`}}),e('more','marketing')}}):'school-holiday'!==s.kind?(0,j.jsx)(d.Button,{small:!0,kind:"secondary",label:`Promote: "${b(s.title)}"`,onPress:()=>{h.useOwner.getState().setOwner({marketingDraft:{title:b(s.title),body:`${b(s.title)} at ${$.name}. Book in the app.`}}),e('more','marketing')}}):null]},s.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]}):(0,j.jsxs)(o.default,{style:{gap:12},testID:"forecast-not-enough",children:[(0,j.jsx)(d.T,{center:!0,size:18,testID:"forecast-busy-level",children:E.busy.words}),(0,j.jsx)(k.NotEnoughHistory,{weeks:E.minWeeks,booked:R}),(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{center:!0,weight:"semibold",colour:u.colours.gold,children:["Booked, next ",P," days"]}),G,(0,j.jsx)(f.DaysLineGraph,{days:Y('booked'),titleSpoken:`Booked covers for the next ${P} days`}),(0,j.jsx)(d.Muted,{children:"Confirmed bookings only. No estimate is added until there is enough history."})]}),(0,j.jsx)(y.SectionHead,{title:"Holidays & local events",sub:"Scottish bank holidays (gov.uk), South Ayrshire school holidays, key dining dates and your events"}),O.slice(0,6).map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",style:{flex:1},children:(0,t.holidayName)(e.title)}),(0,j.jsx)(d.Badge,{kind:w[e.kind][1],label:w[e.kind][0]})]}),(0,j.jsxs)(d.Muted,{children:[(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.date.slice(0,4)]})]},e.id)),(0,j.jsx)(d.Button,{kind:"secondary",label:"Add an event",onPress:()=>e('more','events')})]})};var s=_r(_d[0]),t=_r(_d[1]),o=e(_r(_d[2])),a=e(_r(_d[3])),d=_r(_d[4]),r=_r(_d[5]),n=_r(_d[6]),l=_r(_d[7]),i=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),x=_r(_d[13]),f=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]);const p=(e,s)=>{const t=(0,c.parseYmd)(e),o=Math.round((t.getTime()-(0,c.parseYmd)(s).getTime())/864e5),a=t.toLocaleDateString('en-GB',{weekday:'long'});return o<=0?'tonight':1===o?'tomorrow':o<=6?`this ${a}`:`on ${(0,c.niceDate)(t)}`},b=e=>`${(0,t.holidayName)(e).replace(/ \(example\)| Supper/g,'')} booking now open`,w={'bank-holiday':['Bank holiday','red'],'school-holiday':['School holiday','blue'],occasion:['Key date','gold'],event:['Event','amber']}},1475,[34,1101,102,426,794,874,1163,1161,877,858,821,891,1201,1088,1170,1166,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useShellBadges",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({notifCount:0}))},1476,[846]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.OrderCard=M,_e.Orders=function(){const{rid:e,r:t,now:l,me:s}=(0,w.useCtx)(5e3),n=(0,u.useOrders)(e),[c,h]=(0,r.useState)(!1),[b,x]=(0,r.useState)(null),[f,T]=(0,r.useState)('all'),C=n.filter(k.LIVE).filter(e=>'all'===f||e.type===f).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),B=n.filter(e=>!(0,k.LIVE)(e)&&'awaiting_payment'!==e.status).slice(0,8),v=n.filter(k.LIVE).flatMap(e=>(0,m.readinessFor)(e,t,l).map(t=>({...t,order:e}))),P=v.filter(e=>'due'===e.state||'overdue'===e.state),$=v.filter(e=>'upcoming'===e.state).sort((e,t)=>e.due.getTime()-t.due.getTime()).slice(0,5),N={cook:'START COOKING',bag:'BAG IT',ready:'READY'};return(0,O.jsxs)(o.default,{style:{gap:12},children:[(0,O.jsx)(i.Button,{testID:"take-order",label:"Take an order",sub:(0,p.orderAtTableOn)(t)?'(phone, walk-in or table)':'(phone or walk-in takeaway)',accessibilityLabel:(0,p.orderAtTableOn)(t)?'Take an order, phone, walk-in or table':'Take an order, phone or walk-in takeaway',style:{minHeight:64},onPress:()=>h(!0)}),(0,O.jsx)(R.TakeawayPause,{r:t}),b?(0,O.jsx)(i.Banner,{kind:"success",title:`Order ${b} sent to the kitchen`,children:"It is on the live board below."}):null,(0,O.jsx)(i.Row,{gap:8,children:[['new','acknowledged'],['preparing'],['ready']].map((e,t)=>(0,O.jsxs)(o.default,{style:{flex:1,backgroundColor:j.colours.surface,borderRadius:12,padding:10,borderWidth:1,borderColor:j.colours.border},children:[(0,O.jsx)(i.T,{size:12,colour:j.colours.muted,children:['New','Preparing','Ready'][t]}),(0,O.jsx)(i.T,{size:22,weight:"bold",colour:[j.colours.red,j.colours.amber,j.colours.ok][t],children:n.filter(t=>e.includes(t.status)).length})]},t))}),(0,O.jsx)(k.SectionHead,{title:"Collection readiness",sub:`Takeaway timings: slot \u2212 prep \u2212 ${t.settings.bufferMins} min buffer`}),0===P.length?(0,O.jsx)(i.Muted,{children:"Nothing due right now."}):null,P.map(e=>(0,O.jsxs)(k.AlertBox,{colour:'overdue'===e.state?j.colours.red:j.colours.amber,title:`${N[e.stage]} \xb7 ${e.order.ref} \xb7 pickup ${(0,y.hm)(new Date(e.order.slotTime))}${'overdue'===e.state?' \xb7 OVERDUE':''}`,children:[(0,O.jsx)(i.T,{size:14,children:e.detail}),'ready'===e.stage?(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Mark ready (notify customer)",onPress:()=>u.repo.orders.setStatus(e.orderId,'ready',s)}):(0,O.jsx)(i.Button,{small:!0,label:'cook'===e.stage?'Started cooking':'Bagged & checked',disabled:!!(0,S.statusBlock)(e.order,'preparing',(0,S.linkedBooking)(e.order,u.useStore.getState().bookings)),onPress:()=>u.repo.orders.acknowledgeReadiness(e.orderId,e.stage,s)})]},e.id)),$.map(e=>(0,O.jsxs)(i.Muted,{children:[(0,y.hm)(e.due)," \xb7 ",N[e.stage]," \xb7 ",e.order.ref," (pickup ",(0,y.hm)(new Date(e.order.slotTime)),")"]},e.id)),(0,O.jsx)(k.SectionHead,{title:"Live orders",right:(0,O.jsx)(i.Row,{gap:4,children:((0,p.orderAtTableOn)(t)?['all','takeaway','table']:['all','takeaway']).map(e=>(0,O.jsx)(i.Chip,{label:'all'===e?'All':'takeaway'===e?'Takeaway':'Table',selected:f===e,onPress:()=>T(e)},e))})}),0===C.length?(0,O.jsx)(i.Muted,{children:"No live orders."}):null,C.map(e=>(0,O.jsx)(M,{o:e},e.id)),(0,O.jsx)(R.TakeawayMenuList,{me:s}),B.length?(0,O.jsx)(k.SectionHead,{title:"Recently completed"}):null,B.map(e=>(0,O.jsx)(i.Card,{style:{opacity:.7},children:(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]})},e.id)),c?(0,O.jsx)(A,{onClose:e=>{h(!1),e&&x(e)}}):null]})};var e,t=_r(d[0]),l=_r(d[1]),a=_r(d[2]),s=_r(d[3]),r=_r(d[4]),n=_r(d[5]),o=(e=n)&&e.__esModule?e:{default:e},i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),p=_r(d[9]),h=_r(d[10]),b=_r(d[11]),m=_r(d[12]),x=_r(d[13]),y=_r(d[14]),j=_r(d[15]),k=_r(d[16]),w=_r(d[17]),f=_r(d[18]),T=_r(d[19]),S=_r(d[20]),C=_r(d[21]),B=_r(d[22]),v=_r(d[23]),R=_r(d[24]),O=_r(d[25]);const P={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff (table)','table-qr':'Table QR'};function A({onClose:e}){const{rid:a,r:s,now:n,me:m}=(0,w.useCtx)(3e4),y=(0,c.useAllMenu)(a).filter(e=>!e.hidden&&null!=e.price),k=(0,u.useOrders)(a),[T,S]=(0,r.useState)('phone'),[C,v]=(0,r.useState)(''),[R,P]=(0,r.useState)(''),[A,M]=(0,r.useState)(null),[$,N]=(0,r.useState)({}),[I,L]=(0,r.useState)([]),[D,E]=(0,r.useState)(''),[z,F]=(0,r.useState)(''),[_,G]=(0,r.useState)(''),[H,V]=(0,r.useState)(s.sections[0]??'All'),q=(0,x.takeawaySlots)(s,k,n).filter(e=>!e.full).slice(0,8),K=Object.entries($).filter(([,e])=>e>0),W=K.reduce((e,[t,l])=>e+(y.find(e=>e.id===t)?.price??0)*l,0),Q='staff-table'===T,U=(0,B.ukPhone)(z),Y=Q||('phone'===T?U.ok:!z.trim()||U.ok)&&(0,B.emailOk)(_),J=K.length>0&&Y&&(Q?R.trim().length>0:C.trim().length>1&&('walk-in'===T||A)),X=s.sections.length?s.sections:Array.from(new Set(y.map(e=>e.section)));return(0,O.jsxs)(i.Sheet,{visible:!0,onClose:()=>e(),title:"Take an order",children:[(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,O.jsx)(i.Chip,{label:"Phone takeaway",selected:'phone'===T,onPress:()=>S('phone')}),(0,O.jsx)(i.Chip,{label:"Walk-in takeaway",selected:'walk-in'===T,onPress:()=>S('walk-in')}),(0,p.orderAtTableOn)(s)?(0,O.jsx)(i.Chip,{label:"Table",selected:Q,onPress:()=>S('staff-table')}):null]}),Q?(0,O.jsx)(i.Field,{label:"Table number",value:R,onChangeText:P,keyboardType:"number-pad",placeholder:"e.g. 6"}):(0,O.jsx)(i.Field,{label:"Customer name",value:C,onChangeText:v,placeholder:"e.g. Mrs Reid"}),Q?null:(0,O.jsx)(i.Field,{label:'phone'===T?'Mobile or phone number (needed)':'Mobile number (optional, for a text when it\u2019s ready)',value:z,onChangeText:F,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123"}),Q||!z||U.ok?null:(0,O.jsx)(i.T,{size:13,colour:j.colours.amber,children:U.error}),Q?null:(0,O.jsx)(i.Field,{label:"Email (optional)",value:_,onChangeText:G,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too"}),'phone'===T?(0,O.jsxs)(o.default,{style:{gap:4},children:[(0,O.jsxs)(i.Muted,{children:["Collection slot (cap ",s.settings.slotCap," per ",s.settings.slotMinutes," min)"]}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:q.map(e=>(0,O.jsx)(i.Chip,{label:e.label,sub:e.cap-e.taken+" left",selected:A===e.time.toISOString(),onPress:()=>M(e.time.toISOString())},e.label))}),q.length?null:(0,O.jsx)(i.Muted,{children:"No slots left today."})]}):null,(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:X.map(e=>(0,O.jsx)(i.Chip,{label:e,selected:H===e,onPress:()=>V(e)},e))}),y.filter(e=>e.section===H||!X.includes(e.section)).map(e=>(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between',opacity:e.soldOut?.4:1},children:[(0,O.jsxs)(o.default,{style:{flex:1},children:[(0,O.jsx)(i.T,{size:15,children:e.name}),(0,O.jsxs)(i.Muted,{children:[(0,b.gbp)(e.price??0),e.soldOut?' \xb7 sold out':'']})]}),e.soldOut?null:(0,O.jsx)(i.Stepper,{value:$[e.id]??0,min:0,max:20,label:e.name,onChange:t=>N({...$,[e.id]:t})})]},e.id)),(0,O.jsx)(i.Muted,{children:"Allergies (ask every customer)"}),(0,O.jsx)(i.Row,{wrap:!0,gap:6,children:h.ALLERGENS.map(e=>{const t=I.some(t=>t.allergen===e.id);return(0,O.jsx)(i.Chip,{label:e.short,selected:t,onPress:()=>L(t?I.filter(t=>t.allergen!==e.id):[...I,{allergen:e.id,severity:'allergy'}])},e.id)})}),(0,O.jsx)(i.Field,{label:"Notes",value:D,onChangeText:E,placeholder:"e.g. extra salt, call on arrival"}),t.IS_GREENSIDE?(0,O.jsx)(l.GreensideCashOnly,{}):(0,O.jsx)(i.Banner,{kind:"demo",title:"Phone and walk-in orders: pay at the bar",children:"Take payment on the till. Online guest orders are paid by card on the website before they reach you."}),(0,O.jsx)(i.Button,{label:`Place order \xb7 ${(0,b.gbp)(W)}`,disabled:!J,onPress:()=>{const t=u.useStore.getState().placeManualOrder({restaurantId:a,type:Q?'table':'takeaway',channel:T,customerName:C.trim(),tableNo:Q?R.trim():void 0,slotTime:'phone'===T?A:'walk-in'===T?new Date(n.getTime()+9e5).toISOString():void 0,lines:K.map(([e,t])=>({itemId:e,qty:t})),allergies:I,notes:D.trim()||void 0,by:m,phone:!Q&&U.ok?U.pretty:void 0,email:Q?void 0:_.trim()||void 0});I.length&&(0,f.autoPost)('kitchen',`Allergy alert ${Q?`table ${R.trim()}`:t.ref}: ${I.map(e=>(0,h.allergenLabel)(e.allergen).toLowerCase()).join(', ')}`),e(t.ref)}})]})}function M({o:e}){const{r:t,now:l,me:r}=(0,w.useCtx)(1e4),n=(0,k.nextStatus)(e),c=(0,u.useStore)(e=>e.bookings),p=(0,S.linkedBooking)(e,c),m=e.allergies.length>0&&!!(0,S.nextStep)(e,p)&&!('table'===(0,S.nextStep)(e,p)&&!['ready','served'].includes(e.status)),x=!!n&&!!(0,S.statusBlock)(e,n.to,p);return(0,O.jsxs)(o.default,{style:[i.styles.card,{borderColor:m?j.colours.red:'new'===e.status?j.colours.amber:j.colours.border}],children:[(0,O.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(i.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,a.tableNumbers)(e.tableNo)}`:e.customerName]}),(0,O.jsx)(i.Badge,{kind:(0,k.statusKind)(e.status),label:(0,k.statusLabel)(e)})]}),(0,v.paidBadge)(e)?(0,O.jsx)(i.Badge,{kind:"ok",label:(0,v.paidBadge)(e)}):null,(0,O.jsxs)(i.Muted,{children:['takeaway'===e.type?"Takeaway"+(e.slotTime?` \xb7 pickup ${(0,y.hm)(new Date(e.slotTime))}`:''):'Dine-in'," \xb7 ",P[e.channel??(e.type,'app')]," \xb7 ",(0,y.minsBetween)(new Date(e.createdAt),l)," min ago \xb7 ",(0,b.gbp)(e.total),e.paid>=e.total?' paid':' unpaid']}),e.lines.map((e,t)=>(0,O.jsxs)(i.T,{size:14,children:[e.qty,"\xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 ${e.notes}`:'']},t)),e.notes?(0,O.jsxs)(i.Muted,{children:["Note: ",e.notes]}):null,e.allergies.length?(0,O.jsx)(i.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,O.jsx)(i.Badge,{kind:"red",label:`${(0,h.allergenLabel)(e.allergen)} \xb7 ${(0,h.severityLabel)(e.severity)}`},e.allergen))}):null,e.allergies.length?(0,O.jsx)(T.AllergyChain,{o:e,me:r}):null,e.accepted?(0,O.jsxs)(i.T,{size:13,colour:j.colours.ok,children:["Accepted by ",e.accepted.by,e.readyBy?` \xb7 ready by ${(0,y.hm)(new Date(e.readyBy))}`:'']}):null,'takeaway'===e.type?(0,O.jsx)(C.ConfirmTimeline,{refId:e.id}):null,'takeaway'===e.type?(0,O.jsx)(s.ReprintButton,{rid:t.id,o:e}):null,e.customerSignal?(0,O.jsx)(i.Badge,{kind:"blue",label:'here'===e.customerSignal?'Customer is here':'Customer on the way'}):null,(0,O.jsxs)(i.Row,{wrap:!0,gap:6,children:[n?(0,O.jsx)(i.Button,{small:!0,kind:'ready'===n.to?'success':'primary',label:n.label,testID:`next-${e.ref}`,disabled:x,onPress:()=>u.repo.orders.setStatus(e.id,n.to,r)}):null,'takeaway'!==e.type||'new'!==e.status||e.accepted?null:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(i.Button,{small:!0,kind:"success",label:"Accept",onPress:()=>u.repo.orders.accept(e.id,r)}),[15,20,30].map(t=>(0,O.jsx)(i.Button,{small:!0,kind:"secondary",label:`Ready in ${t}`,onPress:()=>u.repo.orders.accept(e.id,r,t)},t))]}),'new'===e.status?(0,O.jsx)(i.Button,{small:!0,kind:"ghost",label:'paid'===e.payment?.state?'Reject (then refund it in the website\u2019s Orders)':'Reject',onPress:()=>u.repo.orders.setStatus(e.id,'cancelled',r)}):null]})]})}},1477,[5,1418,860,1388,34,102,794,874,876,881,861,867,1179,1131,858,821,1201,1088,1180,1181,869,1425,864,988,1478,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TakeawayPause=function({r:e}){const s=!!e.settings.takeawayPaused;return(0,c.jsx)(l.Card,{highlight:s?r.colours.red:void 0,children:(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(l.T,{weight:"semibold",children:s?'Takeaway is PAUSED':'Taking online takeaway orders'}),(0,c.jsx)(l.Muted,{children:s?'Guests can\u2019t place new orders. Orders already paid still need cooking.':'Paid orders arrive here and on the Head Chef\u2019s, GM\u2019s and the kitchen team\u2019s phones.'})]}),(0,c.jsx)(l.Toggle,{testID:"takeaway-pause",label:s?'Resume':'Pause',value:!s,onChange:s=>d.useStore.getState().updateSettings(e.id,{takeawayPaused:!s})})]})})},_e.TakeawayMenuList=function({me:e}){const[t,d]=(0,s.useState)(!1),[r,h]=(0,s.useState)(null),[y,f]=(0,s.useState)(''),[w,j]=(0,s.useState)(null),x=(0,s.useCallback)(async()=>{f('');try{const e=await(0,u.staffTakeawayMenu)();null===e?f('Connect to the venue to see the takeaway menu.'):h(e)}catch(e){f(String(e?.message??'Couldn\u2019t load the takeaway menu.'))}},[]);(0,s.useEffect)(()=>{t&&x()},[t,x]);const k=async(s,t)=>{j(s.itemId),f('');try{await(0,u.setStaffTakeawayDish)(s.itemId,t,e),h(e=>e?.map(e=>e.itemId===s.itemId?{...e,onMenu:t}:e)??e)}catch(e){f(String(e?.message??'Couldn\u2019t save. Try again.'))}finally{j(null)}},p=r?.filter(e=>e.onMenu).length??0;return(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.T,{weight:"semibold",children:["Takeaway menu",r?` \xb7 ${p} dishes on`:'']}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",label:t?'Hide':'Choose dishes',onPress:()=>d(!t),testID:"takeaway-menu"})]}),t?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(l.Muted,{children:"Guests can order these for collection, at menu prices. Sold out dishes show as Sold out. A dish needs Head Chef allergen sign-off and a price."}),y?(0,c.jsx)(l.Banner,{kind:"warn",children:y}):null,r||y?null:(0,c.jsx)(l.Muted,{children:"Loading\u2026"}),(r??[]).map(e=>(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsxs)(l.T,{size:14,children:[e.dish,e.pricePence?` \xb7 ${(0,o.gbp)(e.pricePence)}`:'']}),(0,c.jsxs)(l.Row,{gap:4,children:[e.soldOut?(0,c.jsx)(l.Badge,{kind:"neutral",label:"Sold out"}):null,e.signedOff?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"Not signed off"}),e.pricePence?null:(0,c.jsx)(l.Badge,{kind:"amber",label:"No price"})]})]}),(0,c.jsx)(l.Toggle,{label:"On takeaway",value:e.onMenu,disabled:w===e.itemId,onChange:s=>{k(e,s)}})]},e.itemId))]}):null]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=_r(_d[2]),d=_r(_d[3]),o=_r(_d[4]),u=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7])},1478,[34,102,794,874,867,987,821,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"tableOnHere",{enumerable:!0,get:function(){return pe}});var e,t=_r(d[0]),s=_r(d[1]),r=_r(d[2]),o=_r(d[3]),n=_r(d[4]),u=_r(d[5]),l=_r(d[6]),c=_r(d[7]),p=_r(d[8]),b=_r(d[9]),h=_r(d[10]),f=_r(d[11]),y=_r(d[12]),C=_r(d[13]),S=_r(d[14]),k=_r(d[15]),v=_r(d[16]),w=_r(d[17]),E=_r(d[18]),N=_r(d[19]),P=_r(d[20]),W=_r(d[21]),A=_r(d[22]),R=_r(d[23]),T=_r(d[24]),M=_r(d[25]),O=_r(d[26]),G=_r(d[27]),B=(e=G)&&e.__esModule?e:{default:e},x=_r(d[28]),D=_r(d[29]),I=_r(d[30]),L=_r(d[31]),H=_r(d[32]),_=_r(d[33]),F=_r(d[34]),V=_r(d[35]),Q=_r(d[36]),q=_r(d[37]),U=_r(d[38]),Y=_r(d[39]),j=_r(d[40]),K=_r(d[41]),z=_r(d[42]),$=_r(d[43]),J=_r(d[44]),X=_r(d[45]),Z=_r(d[46]),ee=_r(d[47]),te=_r(d[48]),ae=_r(d[49]),se=_r(d[50]),ie=_r(d[51]),re=_r(d[52]),oe=_r(d[53]),ne=_r(d[54]),de=_r(d[55]),ue=_r(d[56]),le=_r(d[57]),ge=_r(d[58]),ce=_r(d[59]);const pe=()=>{const e=n.useOwner.getState().site;return(0,p.orderAtTableOn)(c.useStore.getState().restaurants.find(t=>t.id===e))},be=e=>n.CAN.manage(e);(0,y.register)([{id:'lookback',title:'Look back',sub:'Bookings on one exact past date: times, party sizes, recorded tables and Booked covers',group:'Run the day',can:e=>be(e)&&'owner'===r.APP_VARIANT,C:s.LookBack},{id:'orders',title:'Orders',sub:'Live takeaway and table orders, allergy sign-offs',group:'Run the day',can:be,C:R.Orders},{id:'forecasts',title:'Forecasts',sub:'Covers for the days ahead, busy levels and prep from the forecast',group:'Run the day',can:n.CAN.forecasts,C:w.Forecasts},{id:'serviceboard',title:'Restaurant dashboard',sub:'The Display in Managers: any day, plan, Timeline, guests, Covers and all service actions',group:'Run the day',can:be,C:o.ServiceBoard},{id:'vouchers',title:'Gift vouchers',sub:'Website vouchers: search, use by dates, mark as used (one time, nothing left)',group:'Run the day',can:e=>be(e)&&!r.IS_CAR,badge:'NEW',C:P.WebsiteVouchersPage},{id:'info',title:'Info & hours',sub:'Tagline, phone, about, kitchen hours',group:'Manage app',can:be,C:f.InfoHours},{id:'photos',title:'Photos',sub:'Gallery shown in the customer app',group:'Manage app',can:be,C:f.Photos},{id:'recipecards',title:'Recipe cards',sub:'Photo, ingredients, method, allergens, section and price; head chef signs off',group:'Manage app',badge:'NEW',C:k.RecipeCardsPage},{id:'menu',title:'Menu & allergens',sub:'Add, hide, mark sold out, descriptions and options; allergens come from the recipe cards',group:'Manage app',can:be,C:f.MenuManager},{id:'offers',title:'Specials & offers',sub:'Live specials; notifications are not connected',group:'Manage app',can:be,C:f.Offers},{id:'events',title:'Events',sub:"What's on, feeds the forecast",group:'Manage app',can:be,C:f.EventsPage},{id:'feedback',title:'Feedback inbox',sub:'Private ratings after each visit',group:'Manage app',can:be,C:f.Feedback},{id:'staff',title:'Staff & roles',sub:'Team, roles and role preview',group:'Team',C:b.StaffRoles},{id:'branding',title:'Branding',sub:'Your logo and accent colour in all five apps',group:'Account',can:be,badge:'NEW',C:S.BrandingSettings},{id:'plan',title:'Plan & billing',sub:h.PLAN_SUB,group:'Account',can:n.CAN.billing,C:h.PlanBilling}]),(0,y.register)([{id:'avatar',title:'My avatar',sub:'Original icons, Bar & kitchen, animals, sea, sport, patterns or your own photo',group:'Team',badge:'NEW',C:T.MyAvatar},{id:'clock',title:'Clock in / out',sub:'Geofenced, break prompt, privacy-first',group:'Team',badge:'NEW',C:W.ClockInOut},{id:'rota',title:'Rota',sub:'Shift builder, swaps, leave, availability, labour vs forecast',group:'Team',C:W.Rota},{id:'signoff',title:'Sign off hours',sub:'Rostered vs actual, flags, fix times, confirm hours for pay',group:'Team',badge:'NEW',can:be,C:A.SignOff},{id:'timesheets',title:'Timesheets',sub:'Scheduled vs actual, breaks, paid hours, payroll export',group:'Team',C:W.Timesheets}]),(0,y.register)([{id:'insights',title:'Insights',sub:'Smart suggestions from your data',group:'Run the day',can:n.CAN.forecasts,badge:'AI',C:M.Insights},{id:'prep',title:'Prep & stock list',sub:'What to prep from tonight\u2019s forecast',group:'Run the day',C:M.PrepList},{id:'blocks',title:'Block bookings',sub:'Block now, add a block for a future date, time, area or tables, and see every future block',group:'Run the day',badge:'NEW',can:be,C:E.BlocksPage},{id:'spendhead',title:'Spend per head',sub:'Takings \xf7 covers by day, week and service, from your cash ups',group:'Run the day',badge:'NEW',can:be,C:N.SpendPerHeadPage},{id:'cashup',title:'Cash up & sales',sub:'Photo of the cash up sheet, weekly sales report, graphs, Today\u2019s tips and the Tips pot',group:'Run the day',badge:'NEW',can:be,C:v.CashUpPage},{id:'notifications',title:'Notifications',sub:'Orders, allergies, requests, reviews',group:'Run the day',C:M.Notifications},{id:'search',title:'Search',sub:'Dishes, orders, bookings, customers, staff',group:'Run the day',C:M.Search},{id:'analytics',title:'Sales & analytics',sub:'Revenue by channel, top dishes, commission saved',group:'Grow',can:n.CAN.takings,C:M.Analytics},{id:'engineering',title:'Menu engineering',sub:'Margin vs popularity, sold out toggle',group:'Grow',can:be,C:M.MenuEngineering},{id:'crm',title:'Customers (CRM)',sub:'Profiles, visits, allergies, tags, segments',group:'Grow',can:be,C:M.Crm},{id:'marketing',title:'Marketing',sub:'Saved campaign drafts; delivery is not connected',group:'Grow',can:be,C:M.Marketing},{id:'reviews',title:'Reviews',sub:'Look through reviews, publish or remove with a recorded reason',group:'Grow',can:be,C:M.Reviews},{id:'reviewemail',title:'Review emails',sub:'Ask guests for a review after their visit',group:'Settings',can:be,C:M.ReviewEmailSettings},{id:'compliance',title:'Daily checks & allergen log',sub:'Fridge temps, opening checks, audit log',group:'Compliance',C:M.Compliance},{id:'lost',title:'Lost property & coat check',sub:'Found items and coat-check tickets',group:'Compliance',C:M.LostProperty},{id:'apps',title:'Your apps',sub:'Links to all five apps (customer, Staff, Display, Head Chef, Managers)',group:'Account',can:be,badge:'NEW',C:M.YourApps},{id:'demo',title:'Example data',sub:'Example service time, reset',group:'Account',can:()=>!t.LIVE_VENUE_BUILD,C:M.DemoTools}]),(0,y.register)([{id:'features',title:'All features',sub:'Every CoverCharge feature, one tap away',group:'Start here',badge:'19',C:O.AllFeatures},{id:'tables',title:'Tables & QR codes',sub:'QR order & pay at table, live table orders',group:'Run the day',can:()=>pe(),C:O.TablesQr},{id:'takeaway',title:'Takeaway settings',sub:'Slots, capacity, pause, live queue',group:'Run the day',can:be,C:O.TakeawaySettings},{id:'bookingsettings',title:'Booking settings',sub:'Deposits, reminders',group:'Run the day',can:be,C:O.BookingSettings},{id:'allergy',title:'Allergy hub',sub:'14 allergens, alerts, verification, audit log',group:'Compliance',C:O.AllergyHub},{id:'loyalty',title:'Stamp card',sub:'Settings, members, add/redeem stamps, stats',group:'Grow',can:be,C:O.Loyalty},{id:'referrals',title:'Bring a friend',sub:'Referral rewards, list and stats',group:'Grow',can:be,C:O.Referrals},{id:'giftcards',title:'Gift cards & vouchers',sub:'Sell, balance, redeem, honour website bookings cards',group:'Grow',can:be,C:O.GiftVouchers},{id:'merch',title:'Merch shop',sub:'Optional: products, stock, orders',group:'Grow',can:be,C:O.Merch},{id:'tablet',title:'Staff tablet preview',sub:'Tablet app coming later',group:'Account',C:O.TabletPreview}]);const he=e=>'staff'!==e;(0,y.register)([{id:'mypay',title:'My hours & pay',sub:'Hours worked and gross pay, before tax (estimate)',group:'Team',badge:'NEW',C:()=>B.default.createElement(D.MyHoursPay)},{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips',group:'Team',C:x.MyTips},{id:'tips',title:'Tips',sub:'Split tips fairly, approve, compliance checklist',group:'Team',badge:'NEW',can:he,C:x.Tips},{id:'payroll',title:'Payroll & pay rates',sub:'Hourly rates, team gross pay for the period',group:'Team',badge:'NEW',can:he,C:D.Payroll},{id:'suppliers',title:'Suppliers',sub:'Contacts, cut-offs, call, email, order log',group:'Run the day',badge:'NEW',can:e=>'staff'!==e||n.useOwner.getState().staffCanViewSuppliers,C:I.Suppliers}]),(0,y.register)([{id:'social',title:'Post to social',sub:'Publishing is not connected',group:'Grow',badge:'NEW',C:L.SocialPage},{id:'socialaccounts',title:'Social posting accounts',sub:'No social publishing accounts are connected',group:'Grow',can:be,C:L.SocialAccounts},{id:'quicklinks',title:'Quick links',sub:'Work email (Gmail), website bookings and your own shortcuts',group:'Account',can:be,badge:'NEW',C:L.QuickLinksSettings}]),(0,y.register)([{id:'tableplan',title:'Table plan',sub:'Areas, tables, seats, joins; used by the Display floor view',group:'Run the day',can:be,badge:'NEW',C:H.TablePlan},{id:'displaysettings',title:'Display settings',sub:'Privacy mode, screensaver, PIN on wake',group:'Run the day',can:be,badge:'NEW',C:H.DisplaySettingsPage}]);const fe=e=>'owner'===e||'manager'===e;_.ASSISTANT_AVAILABLE&&(0,y.register)([{id:'assistant',title:'Assistant',sub:'Ask in plain English; you confirm every action. Activity log',group:'Start here',can:fe,badge:'NEW',C:_.AssistantPage},{id:'assistantsettings',title:'Assistant settings',sub:'On/off, voice, connected services',group:'Account',can:fe,C:_.AssistantSettings}]),(0,y.register)([{id:'carscreen',title:'Car screen',sub:'Sign the car in with its 6-digit code, or sign a car out. Parked only',group:'Run the day',badge:'NEW',can:e=>'owner'===e&&!r.IS_CAR,C:V.CarScreen}]);const ye=e=>'owner'===e||'manager'===e,me=()=>{const e=u.useSession.getState().meId;if(!e)return!0;const t=n.useOwner.getState().staff.find(t=>t.id===e);return!!t&&t.active&&(0,l.costsAllowedFor)(t)},Ce=e=>ye(e)&&me();(0,y.register)([{id:'specialsboard',title:'Specials board',sub:'Photo of the chalkboard or typed specials with allergens; shown in the customer app',group:'Run the day',can:ye,badge:'NEW',C:F.SafetyPages.Specials},{id:'dishcreator',title:'New dish creator',sub:'Cost a dish, set GP % or multiple, price it, publish to the menu',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Creator},{id:'kitchencosts',title:'Deliveries, stock & GP',sub:'Scan or type deliveries, count stock, see every dish\u2019s GP and GP over time',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Kitchen},{id:'ingredientprices',title:'Ingredient prices',sub:'What you pay per pack and what it averages; recipe cards work out their GP from it',group:'Manage app',can:Ce,badge:'NEW',C:F.SafetyPages.Prices},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning, allergen checks; filters; CSV and print for the EHO',group:'Compliance',can:ye,badge:'NEW',C:F.SafetyPages.Haccp},{id:'allergen-signoffs',title:'Allergen sign-off log',sub:'Five-step sign-off chain for every guest allergy, with names and times',group:'Compliance',can:ye,badge:'NEW',C:C.AllergenSignOffLog},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; RIDDOR prompt for serious ones',group:'Compliance',badge:'NEW',C:F.SafetyPages.Accidents}]),(0,y.register)([{id:'alerts',title:'Alerts & sounds',sub:'Live alerts, chime, which alerts, test alert, phone notifications',group:'Run the day',can:be,badge:'NEW',C:Q.AlertSettings},{id:'guestmsgs',title:'Guest texts & emails',sub:'Booking and order confirmations, with live preview',group:'Manage app',can:be,badge:'NEW',C:Q.GuestTemplates},{id:'outbox',title:'Outbox',sub:'Every guest text and email (preview mode)',group:'Run the day',can:be,badge:'NEW',C:Q.Outbox}]);const Se=e=>'owner'===e||'manager'===e;(0,y.register)([{id:'advanced',title:'Advanced',sub:'Bookings questions, table times, platters, regular events, kitchen hours and seasons, home screens',group:'Settings',can:Se,badge:'NEW',C:U.AdvancedSettings},{id:'setup',title:'Guided setup',sub:'Nine steps with a progress bar: venue, hours, table plan, pay, staff, permissions, links',group:'Settings',can:Se,badge:'NEW',C:q.SetupGuide},{id:'orderattable',title:'Order at table',sub:'On or off for this venue: QR order & pay at table. Takeaway is separate',group:'Settings',can:Se,badge:'NEW',C:Y.OrderAtTableSettings},{id:'ordersheets',title:'Supplier order sheets',sub:'Suppliers, delivery days, cut-offs and how to order; used by the Head Chef app',group:'Settings',can:Se,badge:'NEW',C:j.OrderSheetSettings},...K.SETUP_STEPS.flatMap(e=>[{id:`setup-${e.id}`,title:e.title,sub:e.sub,group:'Settings',can:Se,C:(0,q.stepPage)(e.id)},...'venue'===e.id?[{id:'screensaver',title:'Display screensaver',sub:'What the Display shows when it\'s idle',group:'Settings',can:Se,badge:'NEW',C:z.DisplaySaverSettings}]:[]])]),(0,y.register)([{id:'displays',title:'Displays',sub:'Pair a tablet with a one-time code, or switch one off',group:'Settings',can:Se,badge:'NEW',C:$.DisplaysPage},{id:'trackedstock',title:'Tracked stock',sub:'Live counters (lobster, crab or anything else): units, low warning, supplier',group:'Settings',can:be,badge:'NEW',C:$.TrackedStockPage},{id:'breakroom',title:'Break room game',sub:'On or off for the team',group:'Settings',can:Se,badge:'NEW',C:$.BreakRoomSettings}]),(0,y.register)([{id:'tableqr',title:'Table QR codes',sub:'Scan to order: on or off, hours, print and renew each table\'s QR',group:'Run the day',can:Se,badge:'NEW',C:J.TableQrPage}]),(0,y.register)([{id:'hours',title:'Payroll hours',sub:'Confirmed hours per person for a pay or tips period; copy into your spreadsheet, CSV or print',group:'Team',can:be,badge:'NEW',C:X.PayrollHours},{id:'tipsday',title:'Tips day',sub:'Enter the total; it\u2019s shared by confirmed hours to the penny',group:'Team',can:be,badge:'NEW',C:X.TipsDay},{id:'paysettings',title:'Pay & tips',sub:'Tips payday and frequency, wage pay day and cut-off',group:'Settings',can:be,badge:'NEW',C:X.PayTipsSettings}]),(0,y.register)([{id:'setupchecklist',title:'Setup checklist',sub:'Your setup progress, replay the welcome, questionnaire answers',group:'Settings',can:be,badge:'NEW',C:Z.SetupChecklist}]),(0,y.register)([{id:'help',title:'Help & tutorials',sub:'Search how-tos, Show me where, or ask the Assistant',group:'Start here',can:be,badge:'NEW',C:ee.HelpPage}]),(0,y.register)([{id:'connections',title:'Connected accounts',sub:'Email, website, work socials, bookings, payments, accounting and supplier links',group:'Settings',can:be,badge:'NEW',C:ae.ConnectionsPage}]),(0,y.register)([{id:'drafts',title:'Drafts for approval',sub:'Bookings, Booker and Bidfood lists, offers, events and specials the voice helper prepared; nothing is sent',group:'Run the day',can:be,badge:'NEW',C:se.DraftsPage},{id:'shiftnotes',title:'Shift notes',sub:'Notes for the next shift, left by voice or typing',group:'Run the day',badge:'NEW',C:se.ShiftNotesPage},{id:'voice',title:'Voice helper',sub:'Hold-to-talk input, text-only replies, who gets it and microphone privacy',group:'Settings',can:be,badge:'NEW',C:se.VoiceSettingsPage}]),(0,y.register)([{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, history',group:'Run the day',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ie.OrderListsScreen,{rid:e,today:r,editor:'staff'!==t,who:{id:o?.id??'manager',name:(o?.name??s).replace(' (example)','')}})}},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update',group:'Compliance',can:ye,badge:'NEW',C:function(){return B.default.createElement(re.FoodSafetyCard,null)}}]),(0,y.register)([{id:'board',title:'Question board',sub:'Anonymous questions from the team: vote, reply, hide (logged)',group:'Team',badge:'NEW',C:function(){const{rid:e,role:t,me:s,today:r}=(0,oe.useCtx)(6e4),o=(0,oe.useSignedIn)();return B.default.createElement(ne.QuestionBoard,{rid:e,today:r,manager:'owner'===t||'manager'===t,by:(o?.name??s).replace(' (example)','')})}},{id:'morale',title:'Team morale',sub:'Morale over time, staffing vs Covers each night, shout-outs. Anonymous',group:'Team',can:ye,badge:'NEW',C:function(){const{rid:e,today:t}=(0,oe.useCtx)(6e4);return B.default.createElement(ne.MoraleTrend,{rid:e,today:t})}}]),(0,y.register)([{id:'soldout',title:'Sold out',sub:'Mark dishes sold out or back on. A reminder for staff, shown on the Display',group:'Run the day',badge:'NEW',C:function(){const{rid:e,me:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(de.SoldOutList,{rid:e,by:(s?.name??t).replace(' (example)','')})}}]),(0,y.register)([{id:'printerhelp',title:'Connect a ticket printer',sub:'Wi-Fi, network and Bluetooth printers for kitchen tickets, in plain words',group:'Start here',can:be,badge:'NEW',C:te.PrinterHelpPage}]),(0,y.register)([{id:'guests',title:'Guest profiles',sub:'Visits and Covers from bookings, allergies checked with the guest, preferences, GDPR export and erase requests',group:'Grow',badge:'NEW',C:function(){const{me:e,role:t}=(0,oe.useCtx)(6e4),s=(0,oe.useSignedIn)();return B.default.createElement(ue.GuestProfiles,{me:(s?.name??e).replace(' (example)',''),manager:'owner'===t||'manager'===t})}}]),(0,y.register)([{id:'nightly',title:'Nightly report',sub:'Spend per head, Covers, takings, tips and no-shows from the cash-up',group:'Run the day',can:be,C:le.NightlyReportPage},{id:'support',title:'Chat with CoverCharge support',sub:'A message to the CoverCharge team',group:'Start here',can:be,C:ge.SupportChatPage}]),(0,y.register)([{id:'computer',title:'Use on a computer',sub:'Owners: sign in on a Mac or PC with a one-use link from this phone',group:'Account',can:e=>'owner'===e&&!r.IS_CAR&&!r.IS_OWNER_DESKTOP,badge:'NEW',C:ce.UseOnComputerPage}])},1479,[837,1086,872,1480,891,1004,994,831,881,1482,1489,1499,1459,1500,1501,1503,1504,1475,1505,1506,1508,1219,1210,1477,1509,1457,1510,34,1218,1199,1458,1447,1460,1493,1515,1516,1517,1450,1436,1464,1518,927,1519,1520,1522,1205,1467,1523,1388,1468,1535,1108,1111,1088,1220,1174,1536,1539,1542,1545]); +__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,"DASH_SHORTCUTS",{enumerable:!0,get:function(){return k}}),_e.DashCorners=I,_e.ServiceBoard=function(){const{role:e}=(0,j.useCtx)(3e4),[o,f]=(0,t.useState)(!0),y=()=>f(!1);if((0,c.useBackLayer)(o&&b.CAN.manage(e),y),!b.CAN.manage(e))return(0,D.jsx)(l.Muted,{children:"The Restaurant dashboard is for managers and owners."});const p=(0,D.jsxs)(n.SafeAreaView,{style:{flex:1,backgroundColor:h.colours.bg},edges:['top','bottom','left','right'],children:[(0,D.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderBottomWidth:1,borderColor:h.colours.gold},children:(0,D.jsx)(l.Button,{kind:"secondary",testID:"restaurant-dashboard-close",label:"Back to Managers",accessibilityLabel:"Close Restaurant dashboard, back to Managers",onPress:y,style:{minHeight:48}})}),(0,D.jsx)(I,{onLeave:y}),(0,D.jsx)(s.default,{style:{flex:1,minHeight:0},children:(0,D.jsx)(u.DisplayBoard,{embedded:!0})})]});return(0,D.jsxs)(s.default,{testID:"manager-restaurant-dashboard",style:{gap:10},children:[(0,D.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.goldLight,children:"The same live board as the Display"}),(0,D.jsx)(l.Muted,{children:"Pick any day. Table plan, Timeline, guests, deposits, dogs, joined tables, Covers, chart and block bookings. Today you can seat, finish, mark no-show or cancel a walk-in too."}),(0,D.jsx)(l.Button,{testID:"restaurant-dashboard-open",label:"Open Restaurant dashboard",accessibilityLabel:"Open Restaurant dashboard, the same table plan, Timeline, guests and Covers as the Display",onPress:()=>f(!0),style:{minHeight:56}}),o?w((0,D.jsx)(s.default,{testID:"restaurant-dashboard-layer",style:{position:'fixed',left:0,top:0,right:0,bottom:0,zIndex:50,backgroundColor:h.colours.bg},children:p})):null]})};var t=r(d[0]);r(d[1]),r(d[2]);var o=e(r(d[3])),s=e(r(d[4])),n=r(d[5]),l=r(d[6]),c=r(d[7]),u=r(d[8]),b=r(d[9]),h=r(d[10]),f=r(d[11]),y=r(d[12]),p=r(d[13]),x=r(d[14]),j=r(d[15]),D=r(d[16]);const k=[{id:'home',tab:'home',icon:'home',label:'Home: today in Managers',side:'left'},{id:'bookings',tab:'bookings',icon:'bookings',label:'Bookings',side:'left'},{id:'rota',tab:'more',sub:'rota',icon:'clock',label:'Rota: shifts, swaps and leave',side:'right'},{id:'more',tab:'more',icon:'more',label:'More: every manager function',side:'right'}];function C({testID:e,icon:t,label:n,onPress:c,badge:u}){return(0,D.jsx)(o.default,{testID:e,accessibilityRole:"button",accessibilityLabel:n,onPress:c,style:({pressed:e})=>({width:44,height:44,borderRadius:12,backgroundColor:e?'rgba(201,162,74,0.30)':'rgba(201,162,74,0.16)',alignItems:'center',justifyContent:'center'}),children:(0,D.jsxs)(s.default,{children:[(0,D.jsx)(p.Icon,{name:t,colour:h.colours.gold}),u?(0,D.jsx)(s.default,{style:{position:'absolute',right:-7,top:-6,backgroundColor:h.colours.red,borderRadius:8,minWidth:16,height:16,alignItems:'center',justifyContent:'center'},children:(0,D.jsx)(l.T,{size:10,weight:"bold",children:u})}):null]})})}function I({onLeave:e}){const t=(0,x.useShellBadges)(e=>e.notifCount),o=(t,o)=>{e(),requestAnimationFrame(()=>y.useVoiceNav.getState().go?.(t,o??null))},n=e=>(0,D.jsx)(C,{testID:`dash-go-${e.id}`,icon:e.icon,label:e.label,onPress:()=>o(e.tab,e.sub)},e.id);return(0,D.jsxs)(s.default,{testID:"dash-corners",style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between',paddingHorizontal:12,paddingTop:6,paddingBottom:6,gap:4,borderBottomWidth:1,borderColor:h.colours.hairline},children:[(0,D.jsx)(s.default,{testID:"dash-corner-left",style:{flexDirection:'row',gap:4},children:k.filter(e=>'left'===e.side).map(n)}),(0,D.jsxs)(s.default,{testID:"dash-corner-right",style:{flexDirection:'row',gap:4,alignItems:'center'},children:[k.filter(e=>'right'===e.side).map(n),(0,D.jsx)(C,{testID:"dash-bell",icon:"bell",label:t?`Notifications, ${t} new`:'Notifications, nothing new',badge:t,onPress:()=>o('more','notifications')}),(0,D.jsx)(f.VoiceSlot,{size:44,layer:1})]})]})}function w(e){if('undefined'==typeof document)return e;const{createPortal:t}=r(d[17]);return t(e,document.body)}},1480,[34,395,236,402,102,36,794,1056,1346,891,821,1157,1481,1207,1476,1088,25,277]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1481,[846]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffRoles=function(){const e=(0,u.useHourly)(),l=!!(0,u.useSignedIn)(),{role:f,meId:w,rid:x}=(0,u.useCtx)(6e4),j=(0,u.useSignedIn)(),$=(0,c.useOwner)(e=>e.staff),C=(0,c.useOwner)(e=>e.previewRole),[P,z]=(0,t.useState)(''),[_,H]=(0,t.useState)(''),[E,N]=(0,t.useState)('staff'),[Y,F]=(0,t.useState)({}),G=c.CAN.staffAdmin(f),[U,W]=(0,t.useState)(null),[J,K]=(0,t.useState)(''),[V,Z]=(0,t.useState)({});return(0,T.jsxs)(r.default,{style:{gap:10},children:[!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: switch on Manager access to give someone the Managers app (rota, bookings, staff, settings). Switch it off and they use the Front of House app; the Head Chef goes back to the Head Chef app. Job titles don\u2019t change."})}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(r.default,{testID:"cashup-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cCan use cash up\u201d lets a team member open the cash up, take a picture of the taking sheet and upload a spreadsheet. It\u2019s off for staff until you switch it on; owners and managers always have it. People with it show a Cash up tag."})}),j&&'owner'===j.role?(0,T.jsx)(r.default,{testID:"temp-access-tip",children:(0,T.jsx)(i.Muted,{children:"Tip: \u201cTemporary manager access\u201d gives someone the Managers app while their role stays the same. Switch it off later and nothing else changes. Their cash up switch is separate, so set that on its own."})}):null,(0,T.jsx)(O,{ask:U,onClose:()=>W(null)}),(0,T.jsx)(B,{}),(0,T.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Preview as another role"}),(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:['owner','manager','staff'].filter(e=>!j||(0,u.clampRole)(e,j.role)===e).map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:C===e,onPress:()=>c.useOwner.getState().setPreviewRole(e)},e))}),(0,T.jsx)(i.Muted,{children:A[C]})]}),'owner'===f||'manager'===f?(0,T.jsx)(v.AddTempStaffButton,{}):null,(0,T.jsx)(s.TextInput,{testID:"staff-search",accessibilityLabel:"Search the team",value:J,onChangeText:K,placeholder:"Search by name, nickname or job",placeholderTextColor:h.colours.muted,style:{minHeight:42,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15}}),$.filter(e=>(0,c.staffMatches)(e,J)).map(t=>(0,T.jsxs)(i.Card,{style:{opacity:t.active?1:.5},children:[(0,T.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(i.Row,{gap:10,style:{flex:1},children:[!j||'owner'!==f&&'manager'!==f?(0,T.jsx)(p.StaffAvatar,{id:t.id,size:44}):(0,T.jsx)(n.StaffLinkChip,{m:t,actorRole:j.role,size:36}),(0,T.jsx)(i.T,{weight:"semibold",style:{flex:1},children:(0,c.staffLabel)(t)})]}),(0,T.jsx)(i.Badge,{kind:'owner'===t.role?'gold':'manager'===t.role?'blue':'neutral',label:t.level??c.ROLE_LABEL[t.role]})]}),(0,T.jsx)(I,{id:t.id}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(i.Row,{gap:6,children:(0,T.jsx)(S.CashUpAccessBadge,{m:t})}),(0,T.jsxs)(i.Muted,{children:[t.job,t.dept?` \xb7 ${t.dept}`:'',t.active?'':' \xb7 deactivated']}),'staff'!==f&&l?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:`pay-toggle-${t.id}`,label:Y[t.id]?'Hide pay \u25b4':'Pay details \u25be',onPress:()=>F(e=>({...e,[t.id]:!e[t.id]}))}),Y[t.id]?(0,T.jsxs)(i.Muted,{children:[(0,c.wageLabel)(t,e[t.id],o.gbp),t.noTax?' \xb7 No tax deducted':'']}):null]}):null,!j||'owner'!==f&&'manager'!==f||t.managerAccess||t.ownerAccess?null:(0,T.jsx)(R,{person:t,actor:j,onAsk:W}),!j||'owner'!==j.role||j.ownerAccess||'owner'===t.role&&!t.ownerAccess?null:(0,T.jsx)(L,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f||'owner'===t.role||!t.managerAccess&&'staff'!==t.role?null:(0,T.jsx)(D,{person:t,actor:j}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(b.InviteLinkControls,{m:t,actorRole:j.role}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsxs)(i.Row,{gap:6,children:[(0,T.jsx)(i.Muted,{size:12,children:"Nickname"}),(0,T.jsx)(s.TextInput,{testID:`nickname-${t.id}`,accessibilityLabel:`Nickname for ${t.name}`,value:V[t.id]??t.nickname??'',placeholder:"Optional",placeholderTextColor:h.colours.muted,onChangeText:e=>Z(s=>({...s,[t.id]:e})),onBlur:()=>{const e=(V[t.id]??t.nickname??'').trim().slice(0,40);e!==(t.nickname??'')&&c.useOwner.getState().updateStaff(t.id,{nickname:e||void 0})},style:{flex:1,minHeight:34,borderRadius:8,borderWidth:1,borderColor:h.colours.hairline,color:h.colours.text,paddingHorizontal:8}})]}),!j||'owner'!==f&&'manager'!==f?null:(0,T.jsx)(M,{person:t}),!j||'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(S.CashUpAccessToggle,{m:t}),'owner'!==f&&'manager'!==f||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(v.StaffDisplayControls,{m:t}),!j||'owner'!==j.role&&'manager'!==j.role||!t.active||t.name.includes('(example)')?null:(0,T.jsx)(k.AutoClockToggle,{m:t}),j&&('owner'===f||'manager'===f)&&t.active?(0,T.jsx)(y.DailyTasksEditor,{rid:x,person:t,actor:j}):null,G&&t.id!==w&&'owner'!==t.role?(0,T.jsx)(i.Row,{wrap:!0,gap:6,children:(0,T.jsx)(i.Chip,{label:t.active?'Deactivate':'Reactivate',onPress:()=>c.useOwner.getState().updateStaff(t.id,{active:!t.active})})}):null]},t.id)),G?(0,T.jsxs)(i.Card,{children:[(0,T.jsx)(i.T,{weight:"semibold",children:"Add a team member"}),(0,T.jsx)(i.Field,{label:"Name",value:P,onChangeText:z}),(0,T.jsx)(i.Field,{label:"Job title",value:_,onChangeText:H,placeholder:"e.g. Kitchen porter"}),(0,T.jsx)(i.Row,{gap:6,children:['manager','staff'].map(e=>(0,T.jsx)(i.Chip,{label:c.ROLE_LABEL[e],selected:E===e,onPress:()=>N(e)},e))}),(0,T.jsx)(i.Button,{label:"Add (no invite is sent)",disabled:P.trim().length<2,onPress:()=>{c.useOwner.getState().addStaff(P.trim(),E,_.trim()||'Team member'),z(''),H('')}})]}):(0,T.jsx)(i.Banner,{kind:"info",title:"Owner only",children:"Only the owner can add staff or change roles."})]})};var e,s=_r(d[0]),n=_r(d[1]),t=_r(d[2]),o=_r(d[3]),l=_r(d[4]),r=(e=l)&&e.__esModule?e:{default:e},i=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),p=_r(d[9]),f=_r(d[10]),w=_r(d[11]),x=_r(d[12]),j=_r(d[13]),y=_r(d[14]),b=_r(d[15]),v=_r(d[16]),k=_r(d[17]),S=_r(d[18]),$=_r(d[19]),C=_r(d[20]),T=_r(d[21]);const A={owner:'Everything, including staff & roles and plan & billing.',manager:'Run service, edit the app, rotas and timesheets. No billing or role changes.',staff:'Orders, bookings, waitlist, allergy alerts, own shifts and clock in/out. No takings, forecasts or settings.'};function I({id:e}){const{role:s,meId:n,me:t}=(0,u.useCtx)(6e4),o=(0,f.useAvatars)(s=>s.photos[e]);return o&&'staff'!==s?(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsxs)(i.Muted,{style:{flex:1},children:["Avatar made from their photo on ",new Date(o.at).toLocaleDateString('en-GB'),"."]}),(0,T.jsx)(i.Button,{small:!0,kind:"secondary",label:"Reset avatar",testID:`reset-avatar-${e}`,onPress:()=>f.useAvatars.getState().reset(e,{id:n,role:s,name:t.replace(' (example)','')})})]}):null}function M({person:e}){const s=(0,$.canChangeBookings)(e),n='owner'===e.role||'manager'===e.role||!!e.ownerAccess||!!e.managerAccess,o=e.name.replace(' (example)','').split(' ')[0],[l,u]=(0,t.useState)(null);return(0,T.jsxs)(r.default,{testID:`privileges-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.T,{size:13,weight:"semibold",colour:h.colours.gold,children:"Privileges"}),(0,T.jsx)(i.Toggle,{testID:`booking-write-${e.id}`,label:"Can add and change bookings",a11y:`Can add and change bookings for ${o}: ${s?'on':'off'}`,value:s,disabled:n,onChange:s=>{c.useOwner.getState().updateStaff(e.id,{bookingWrite:s}),(0,C.setCanChangeBookings)(e.id,s).then(e=>u(e.ok?s?`${o} can add and change bookings.`:`${o} can only view bookings.`:e.error??'Saved on this device. It will reach the server when you are connected.'))}}),(0,T.jsx)(i.Muted,{size:12,children:n?'Always on for owners and managers.':s?(0,$.isKitchenPorter)(e)?'Switched on for this kitchen porter.':'Can add walk-ins and change bookings.':'View only. They can see bookings, the plan and the Timeline.'}),l?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`booking-write-msg-${e.id}`,children:l})}):null]})}function R({person:e,actor:s,onAsk:n}){const t=(0,w.canToggleAccess)(s,e),o=(0,w.hasManagerAccess)(e);return(0,T.jsxs)(r.default,{testID:`access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`access-toggle-${e.id}`,label:"Manager access",value:o,disabled:!t.ok,onChange:s=>n({id:e.id,on:s})}),(0,T.jsxs)(i.Muted,{size:12,children:['owner'===e.role?'Owner: always full access':o?'Uses the Manager app':'Head Chef'===e.level?'Uses the Head Chef app':'Uses the Front of House app',t.ok||'owner'===e.role?'':` \xb7 ${t.why}`]})]})}function D({person:e,actor:s}){const n=(0,w.canToggleTempAccess)(s,e),o=!!e.managerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary manager access'),[p,f]=(0,t.useState)(!1),[j,y]=(0,t.useState)(null),b=e.name.replace(' (example)','').split(' ')[0],v=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempManagerAccess)(e.id,l,h);f(!1),c(null),y(s.ok?l?`${b} now has temporary manager access. Logged with your name, the time and the reason.`:`${b}\u2019s temporary manager access is off. Their role and cash up are unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-access-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-access-toggle-${e.id}`,label:"Temporary manager access",a11y:`Temporary manager access for ${b}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Uses the Managers app. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),j?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-access-msg-${e.id}`,children:j})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${b} temporary manager access?`:`Switch off ${b}\u2019s temporary manager access?`,testID:"temp-access-confirm",children:[(0,T.jsx)(i.T,{children:l?`${b} gets the Managers app. Their role stays ${e.level??'Staff'}.`:`${b} goes back to their own app. Role, cash up, pay and links don\u2019t change.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-access-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{v()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function L({person:e,actor:s}){const n='owner'!==s.role||s.ownerAccess?{ok:!1,why:'Only an owner can change this.'}:{ok:!0},o=!!e.ownerAccess,[l,c]=(0,t.useState)(null),[h,u]=(0,t.useState)('temporary owner access'),[p,f]=(0,t.useState)(!1),[w,j]=(0,t.useState)(null),y=e.name.replace(' (example)','').split(' ')[0],b=async()=>{if(null===l)return;f(!0);const s=await(0,x.setTempOwnerAccess)(e.id,l,h);f(!1),c(null),j(s.ok?l?`${y} now has temporary owner access. Logged with your name, the time and the reason.`:`${y}\u2019s temporary owner access is off. Their own role is unchanged.`:s.message)};return(0,T.jsxs)(r.default,{testID:`temp-owner-row-${e.id}`,style:{gap:2},children:[(0,T.jsx)(i.Toggle,{testID:`temp-owner-toggle-${e.id}`,label:"Temporary owner access",a11y:`Temporary owner access for ${y}: ${o?'on':'off'}`,value:o,disabled:!n.ok||p,onChange:e=>c(e)}),(0,T.jsxs)(i.Muted,{size:12,children:[o?`Owner access. Role stays ${e.level??'Staff'}.`:'Off.',n.ok?'':` \xb7 ${n.why}`]}),w?(0,T.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,T.jsx)(i.Muted,{size:12,testID:`temp-owner-msg-${e.id}`,children:w})}):null,null!==l?(0,T.jsxs)(i.Sheet,{visible:!0,onClose:()=>c(null),title:l?`Give ${y} temporary owner access?`:`Switch off ${y}\u2019s temporary owner access?`,testID:"temp-owner-confirm",children:[(0,T.jsx)(i.T,{children:l?`${y} gets owner access in the Managers app. Their role stays ${e.level??'Staff'}.`:`${y} keeps their own role and app. Only the extra owner access is removed.`}),(0,T.jsx)(i.Field,{label:"Reason (kept in the log)",value:h,onChangeText:u}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"temp-owner-yes",label:p?'Saving\u2026':l?'Yes, give access':'Yes, switch off',disabled:p,onPress:()=>{b()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:()=>c(null)})]})]}):null]})}function O({ask:e,onClose:s}){const n=(0,c.useOwner)(e=>e.staff),[o,l]=(0,t.useState)(!1),r=e?n.find(s=>s.id===e.id):void 0;if(!e||!r)return null;const h=(0,w.accessResult)(r,e.on),u=r.name.replace(' (example)','').split(' ')[0],p=async()=>{l(!0);if('staff'===x.useSync.getState().kind&&!!x.useSync.getState().venueId){const n=await(0,x.setManagerAccess)(r.id,e.on);if(l(!1),!n.ok)return(0,j.notify)({id:'access-change',tone:'warn',title:'Not changed',body:n.message,timeoutMs:9e3}),void s()}else c.useOwner.getState().updateStaff(r.id,{role:h.role,level:h.level}),l(!1);(0,j.notify)({id:'access-change',icon:'\ud83d\udd11',kicker:'MANAGER ACCESS',title:e.on?`${u} now has manager access`:`${u}\u2019s manager access is off`,body:`${u} now uses the ${h.app}. Their personal link opens it next time. Logged with your name and the time.`,timeoutMs:8e3}),s()};return(0,T.jsxs)(i.Sheet,{visible:!0,onClose:s,title:e.on?`Give ${u} manager access?`:`Switch off ${u}\u2019s manager access?`,testID:"access-confirm",children:[(0,T.jsx)(i.T,{children:e.on?`${u} will get the Manager app: rota, bookings, staff, hours and settings, plus their own clock in, rota and pay.`:`${u} will use the ${h.app}. They keep their job title (${r.job||'none'}).`}),(0,T.jsx)(i.Muted,{children:"This is logged with your name and the time. You can change it back at any time."}),(0,T.jsxs)(i.Row,{gap:8,children:[(0,T.jsx)(i.Button,{testID:"access-confirm-yes",label:o?'Saving\u2026':e.on?'Yes, give access':'Yes, switch off',disabled:o,onPress:()=>{p()}}),(0,T.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:s})]})]})}function B(){const[e,s]=(0,t.useState)(null);return(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId)?(0,T.jsxs)(r.default,{style:{gap:4},children:[(0,T.jsx)(i.Button,{small:!0,kind:"secondary",testID:"access-log-open",label:e?'Hide access changes \u25b4':'Access changes \u25be',onPress:()=>{e?s(null):(0,x.readAccessLog)().then(s)}}),e?e.length?e.map((e,s)=>(0,T.jsxs)(i.Muted,{size:12,children:[new Date(String(e.changed_at)).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",String(e.changed_by_name??'')," switched ",e.access_on?'on':'off'," ",'manager_access_flag'===e.kind?'temporary ':'',"manager access for ",String(e.staff_name??''),e.reason?` (${String(e.reason)})`:'']},s)):(0,T.jsx)(i.Muted,{size:12,children:"No changes yet."}):null]}):null}},1482,[827,1456,34,867,102,794,891,821,1088,925,926,1483,987,1001,1061,1454,1484,1485,1487,1027,1488,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.canToggleAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'staff'===n.role?{ok:!1,why:'Only owners and managers can change this.'}:'manager'===n.role&&n.id===o.id?{ok:!1,why:'You can\u2019t change your own access. Ask an owner.'}:{ok:!0}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"hasManagerAccess",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isHeadChef",{enumerable:!0,get:function(){return o}}),e.accessResult=function(n,t,c){return t?{role:'manager',level:'Manager',app:'Manager app'}:o(n,c)?{role:'staff',level:'Head Chef',app:'Head Chef app'}:{role:'staff',level:'Staff',app:'Front of House app'}},e.canToggleTempAccess=function(n,o){return n?'owner'===o.role?{ok:!1,why:'Owners always have full access.'}:'owner'!==n.role?{ok:!1,why:'Only an owner can change this.'}:'manager'!==o.role||o.managerAccess?{ok:!0}:{ok:!1,why:'Already a manager.'}:{ok:!1,why:'Sign in from your link first.'}},Object.defineProperty(e,"effectiveRole",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"roleWithoutTempAccess",{enumerable:!0,get:function(){return c}});const n=n=>'manager'===n.role||'owner'===n.role,o=(n,o)=>'head_chef'===o||'Head Chef'===(n.level??'')||/^head chef/i.test(n.job??'');const t=(n,o)=>'owner'===n?'owner':o?'manager':n,c=n=>n.managerAccess?'staff':n.role},1483,[]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffDisplayControls=function({m:e}){const s=(0,p.usePinStatus)(t=>t[e.id]),[c,m]=(0,l.useState)(''),[h,y]=(0,l.useState)(null),[x,S]=(0,l.useState)(!1),b='owner'===e.role||'manager'===e.role?6:4,j=async()=>{S(!0);const t=await(0,p.setStaffPin)(e.id,c,b);S(!1),m(''),y(t.ok?`PIN ${s?.hasPin?'reset':'set'}. Tell ${e.name} in person; it isn\u2019t shown again.`:t.error??'Could not set the PIN.'),t.ok&&(0,p.refreshPinStatus)()};return(0,f.jsxs)(n.default,{testID:`display-controls-${e.id}`,style:{gap:6,paddingTop:4},children:[(0,f.jsx)(o.Toggle,{testID:`display-clock-${e.id}`,label:"Can clock in at the Display",value:!!e.displayClock,onChange:t=>u.useOwner.getState().updateStaff(e.id,{displayClock:t})}),e.displayClock?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Muted,{size:12,children:s?.locked?'PIN locked (5 wrong tries)':s?.hasPin?e.temp?'Code set':'PIN set':'No PIN yet'}),(0,f.jsx)(t.TextInput,{testID:`pin-input-${e.id}`,accessibilityLabel:`New PIN for ${e.name}`,value:c,onChangeText:e=>m(e.replace(/\D/g,'').slice(0,8)),placeholder:`${b}\u20138 digits`,placeholderTextColor:r.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",maxLength:8,style:{width:110,minHeight:34,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,f.jsx)(o.Button,{small:!0,kind:"secondary",testID:`set-pin-${e.id}`,label:s?.hasPin?'Reset PIN':'Set PIN',disabled:x||c.length{j()}})]}):null,h?(0,f.jsx)(o.Muted,{children:h}):null,e.temp?(0,f.jsxs)(o.Row,{gap:6,wrap:!0,children:[(0,f.jsx)(o.Badge,{kind:"gold",label:"Temp"}),(0,f.jsxs)(o.Muted,{size:12,children:[e.tempUntil?`Until ${e.tempUntil}`:'No end date'," \xb7 Display only, no phone app"]}),(0,f.jsx)(o.Button,{small:!0,kind:"ghost",testID:`make-full-${e.id}`,label:"Make full staff",onPress:()=>u.useOwner.getState().updateStaff(e.id,{temp:!1,tempUntil:void 0,job:'Temp'===e.job?'':e.job})})]}):null]})},_e.AddTempStaffButton=function({initialOpen:e}){const[t,s]=(0,l.useState)(!!e),[n,r]=(0,l.useState)(!1),[m,h]=(0,l.useState)(null),[y,x]=(0,l.useState)(null);(0,l.useEffect)(()=>{(0,p.refreshPinStatus)()},[]);const S=()=>{s(!1),x(null),h(null)},b=async e=>{r(!0);const t=await(0,p.addTempStaff)(e);r(!1),t.ok&&t.ref&&t.code?(u.useOwner.setState(l=>({staff:[...l.staff.filter(e=>e.id!==t.ref),{id:t.ref,name:t.name??e.name,role:'staff',job:'Temp',active:!0,level:'Staff',dept:e.dept??'',displayClock:!0,temp:!0,tempUntil:e.until??void 0}],hourly:null!=e.rate?{...l.hourly,[t.ref]:Math.round(100*e.rate)}:l.hourly})),x({name:t.name??e.name,code:t.code})):h(t.error??'Could not add them.')};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Button,{testID:"add-temp-btn",kind:"secondary",label:"Add temp staff",onPress:()=>s(!0)}),t?(0,f.jsx)(o.Sheet,{visible:!0,onClose:S,title:y?'Temp added':'Add temp staff',maxWidth:560,testID:"add-temp",children:y?(0,f.jsx)(c.TempCode,{name:y.name,code:y.code,onClose:S}):(0,f.jsx)(c.AddTempForm,{busy:n,error:m,onSubmit:e=>{b(e)}})}):null]})};var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),n=(e=s)&&e.__esModule?e:{default:e},o=_r(d[3]),r=_r(d[4]),u=_r(d[5]),p=_r(d[6]),c=_r(d[7]),f=_r(d[8])},1484,[827,34,102,794,821,891,1398,1408,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AutoClockToggle=function({m:e}){const o=(0,s.useAutoClock)(t=>!!t.on[e.id]),[r,h]=(0,t.useState)(null);(0,t.useEffect)(()=>{(0,s.refreshAutoClock)()},[]);const f=e.name.replace(' (example)','');return(0,c.jsxs)(l.default,{testID:`auto-clock-${e.id}`,style:{gap:2,paddingTop:4},children:[(0,c.jsx)(n.Toggle,{testID:`auto-clock-toggle-${e.id}`,label:"Auto clock from rota",a11y:`Auto clock ${f} in and out at their rota times`,value:o,onChange:t=>{h(null),(0,s.setAutoClock)(e.id,t).then(e=>{e.ok||h(e.error??'Couldn\u2019t save.')})}}),(0,c.jsx)(n.Muted,{size:12,children:o?`${f} is clocked in at the start and out at the end of each rota shift, so they show in On now. Marked \u201cAuto from rota\u201d in Hours: you can still change the times and sign them off.`:`For someone who can\u2019t use the app: clocks ${f} in and out at their rota times.`}),r?(0,c.jsx)(n.T,{size:12,colour:u.colours.amber,children:r}):null]})};var e,t=_r(d[0]),o=_r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},n=_r(d[2]),s=_r(d[3]),u=_r(d[4]),c=_r(d[5])},1485,[34,102,794,1486,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useAutoClock",{enumerable:!0,get:function(){return r}}),_e.refreshAutoClock=async function(){if(o.PITCH)return;const e=c();if(!e)return;try{const{data:n,error:o}=await(0,t.getSupabase)().from('staff_auto_clock').select('staff_ref, enabled').eq('venue_id',e);if(o||!n)return;const c={};for(const e of n)c[e.staff_ref]=!!e.enabled;r.setState({on:c,loaded:!0})}catch{}},_e.setAutoClock=async function(e,n){const s=r.getState().on[e]??!1;if(r.setState(t=>({on:{...t.on,[e]:n}})),o.PITCH)return{ok:!0};const u=c();if(!u)return r.setState(t=>({on:{...t.on,[e]:s}})),{ok:!1,error:'Not connected to the venue, so this can\u2019t be changed right now.'};try{const{error:o}=await(0,t.getSupabase)().rpc('set_staff_auto_clock',{p_venue:u,p_staff_ref:e,p_on:n});if(o)throw o;return{ok:!0}}catch(t){r.setState(t=>({on:{...t.on,[e]:s}}));const n=String(t?.message??'');return{ok:!1,error:/managers and owners/i.test(n)?'Only managers and owners can change auto clock.':'Couldn\u2019t save. Check the signal and try again.'}}};var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]);const r=(0,e.create)(()=>({on:o.PITCH?{'st-jack':!0}:{},loaded:o.PITCH})),c=()=>n.useSync.getState().venueId},1486,[846,933,987,2]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1487,[34,102,794,821,999,1052,987,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setCanChangeBookings=async function(o,s){const c=n.useSync.getState().venueId;if(!c||'staff'!==n.useSync.getState().kind)return{ok:!1,error:'Saved on this device. Connect to the shared team to store it for everyone.'};const h=(0,t.getSupabase)();try{const{error:t}=await h.rpc('set_can_change_bookings',{p_venue:c,p_staff_ref:o,p_on:s});return t?{ok:!1,error:/owner or manager/i.test(t.message)?'Only an owner or manager can change this.':'Saved on this device. The server did not take the change.'}:{ok:!0}}catch{return{ok:!1,error:'Saved on this device. The server did not take the change.'}}};var t=r(d[0]),n=r(d[1])},1488,[933,987]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"PRICING_AVAILABLE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"PLAN_SUB",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"PLAN_FEATURE_NOTE",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"PLAN_VOICE_LINE",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"PLAN_SUPPLIER_LINE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DONE_FOR_YOU",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"doneForYouLine",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_NAME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_NAME",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_PRICE",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_PRICE",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"PLAN_USUAL_LITE_BLURB",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"PLAN_USUAL_PRO_BLURB",{enumerable:!0,get:function(){return v}}),_e.PlanBilling=function(){const{now:e,role:n,rid:b}=(0,p.useCtx)(6e4),j=(0,c.trialStatus)((0,l.defaultSimStart)(),e),[x,w]=(0,s.useState)(!1);return u.CAN.billing(n)?x?(0,y.jsx)(M,{onBack:()=>w(!1)}):(0,y.jsxs)(i.default,{style:{gap:10},children:[(0,y.jsx)(o.Banner,{kind:"demo",title:"Billing: not set up yet",children:"No card is taken and nothing is charged."}),(0,y.jsx)(t.VoiceUsageCard,{rid:b,now:e}),(0,y.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,y.jsxs)(i.default,{testID:"plan-founding",children:[(0,y.jsx)(o.T,{size:12,weight:"semibold",colour:h.colours.goldMuted,children:"FOUNDING OFFER \xb7 FIRST 50 VENUES"}),(0,y.jsxs)(o.T,{size:30,weight:"bold",children:["\xa349",(0,y.jsx)(o.T,{size:14,colour:h.colours.muted,children:" a month + VAT if applicable, per venue"})]})]}),(0,y.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,y.jsx)(o.Badge,{kind:"gold",label:"Every Full Restaurant Pro feature"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"One month free"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"\xa349 net locked in"})]}),(0,y.jsx)(o.Muted,{children:"Early adopter price for the first 50 venues: every Full Restaurant Pro App feature, including the owner's dashboard and admin and the voice Assistant. \xa349 net stays locked in while your subscription stays active."}),(0,y.jsxs)(o.T,{size:13,testID:"plan-early-done-for-you",children:["\u2713 ",T(P.early)]}),(0,y.jsx)(o.Muted,{children:"From venue 51, usual prices:"}),(0,y.jsxs)(i.default,{testID:"plan-usual-lite",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[k," \xb7 ",C," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:S}),O.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e)),(0,y.jsx)(o.T,{size:13,testID:"plan-lite-not-included",children:"Not included: the owner's dashboard and admin, or the voice Assistant."})]}),(0,y.jsxs)(i.default,{testID:"plan-usual-pro",style:{gap:2,marginTop:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:[_," \xb7 ",L," a month + VAT if applicable, per venue"]}),(0,y.jsx)(o.Muted,{children:v}),R.map(e=>(0,y.jsxs)(o.T,{size:13,children:["\u2713 ",e]},e))]}),(0,y.jsx)(o.Button,{small:!0,kind:"secondary",label:"Set-up guide",testID:"setup-guide-open",onPress:()=>w(!0),style:{marginTop:6}})]}),(0,y.jsx)(o.Card,{children:(0,y.jsxs)(i.default,{testID:"plan-store-listing",style:{gap:4},children:[(0,y.jsxs)(o.T,{weight:"semibold",children:["Your venue in the CoverCharge app on the Apple App Store and Google Play: ",(0,y.jsx)(o.T,{weight:"bold",colour:h.colours.gold,children:"free"}),"."]}),(0,y.jsx)(o.Muted,{children:"Your own app would cost about \xa398 in store fees in the first year alone (Apple \xa378.99 a year in the UK, Google US$25 one-off), then \xa378.99 a year."})]})}),(0,y.jsx)(o.Muted,{children:"Setup is all done digitally with the in-app guided setup and step-by-step guides, and subscribers get free lifetime 24/7 customer support. Edit your basic info yourself anytime (prices, sold-out, hours, specials)."}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{children:"Free trial"}),(0,y.jsxs)(o.T,{weight:"bold",colour:h.colours.gold,children:[j.daysLeft," day",1===j.daysLeft?'':'s'," left"]})]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(100*(1-j.daysLeft/j.total))}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),(0,y.jsxs)(o.Muted,{children:["Then \xa3",c.PLAN.monthlyPence/100," a month + VAT if applicable. The trial start date is not set up yet."]})]}),(0,y.jsx)(f.AssistantPlanCard,{}),(0,y.jsxs)(o.Card,{children:[(0,y.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsx)(o.T,{weight:"semibold",children:"Free lifetime customer support"}),(0,y.jsx)(o.Badge,{kind:"gold",label:"Included"})]}),(0,y.jsx)(o.Muted,{children:"Free for as long as you subscribe, day or night. Setup is all done digitally. Support contact details: not set up yet."})]})]}):(0,y.jsx)(o.Banner,{kind:"info",title:"Owner only",children:"Plan & billing is visible to the owner only."})};var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),i=(e=n)&&e.__esModule?e:{default:e},o=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),h=r(d[7]),p=r(d[8]),f=r(d[9]),y=r(d[10]);const b=!0,j='Founding offer, free trial, set-up guide',x='. The owner\'s dashboard and admin come with Full Restaurant Pro App (\xa399 a month) and the early adopter offer (\xa349 a month), + VAT if applicable, per venue. They are not included with Customer & Takeaway App',w='Voice Assistant (hold to talk) for seating guests, marking tables as cleared, temperature logs and finding something in the app: fair usage 1,000 voice tasks a month per venue',A='Supplier links: open your suppliers\' ordering sites and keep order lists',P={lite:1,pro:3,early:3},T=e=>`${e} done-for-you ${1===e?'change':'changes'} a month`,k='Customer & Takeaway App',_='Full Restaurant Pro App',C='\xa349',L='\xa399',S='A lite version of CoverCharge: 3 core customer and takeaway functions tailored to you, set up digitally with the in-app guided setup and step-by-step guides, free lifetime 24/7 customer support while subscribed, and unlimited self-edits of your basic info. The owner\'s dashboard and admin, and the voice Assistant, are not included.',v='Every feature, every app, including the owner\'s dashboard and admin and the voice Assistant. Set up digitally with the in-app guided setup and step-by-step guides, the Assistant (fair use 300 tasks a month), free lifetime 24/7 customer support while subscribed, and unlimited self-edits.',O=['Customer app: menu, allergens, bookings and loyalty','Takeaway ordering','Set up digitally: in-app guided setup and step-by-step guides','Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits of your basic info',T(P.lite)],R=['Every feature, every app','The owner\'s dashboard and admin',A,'Set up digitally: in-app guided setup and step-by-step guides','The Assistant, fair use 300 tasks a month',w,'Free lifetime 24/7 customer support while you subscribe','Unlimited self-edits',T(P.pro)],I=[['Choose your 3 core functions','Pick what matters most to you, for example menu & allergens, takeaway ordering or the stamp card.'],['Add your logo and colours','More \u203a Branding: upload your logo; the apps use it everywhere.'],['Check your opening hours','More \u203a Opening hours: set your normal week and any closed days.'],['Add your menu and allergens','Menu & allergens: add dishes, prices and the 14 allergens, then sign each dish off.'],['Invite your team','More \u203a Team: add staff so they can use CoverCharge for Staff.'],['Share the customer app','More \u203a Your apps: copy the link or show the QR code at the counter.'],['Try a test order','Place a test order in the customer app and watch it arrive.']];function M({onBack:e}){const[t,n]=(0,s.useState)([]);return(0,y.jsxs)(i.default,{style:{gap:10},testID:"setup-guide",children:[(0,y.jsx)(o.Button,{small:!0,kind:"ghost",label:"\u2039 Plan & billing",onPress:e}),(0,y.jsx)(o.H2,{children:"Set-up guide"}),(0,y.jsxs)(o.Muted,{children:["Setup is all done digitally, one step at a time: this guide plus Managers \u203a Settings \u203a Guided setup. ",t.length," of ",I.length," done."]}),(0,y.jsx)(i.default,{style:{height:8,backgroundColor:h.colours.border,borderRadius:4},children:(0,y.jsx)(i.default,{style:{height:8,width:`${Math.round(t.length/I.length*100)}%`,backgroundColor:h.colours.gold,borderRadius:4}})}),I.map(([e,s],l)=>{const u=t.includes(l);return(0,y.jsx)(o.Card,{children:(0,y.jsxs)(o.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,y.jsx)(i.default,{style:{width:28,height:28,borderRadius:14,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:u?h.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,y.jsx)(o.T,{size:14,weight:"bold",colour:u?'#1a1610':h.colours.gold,children:u?'\u2713':String(l+1)})}),(0,y.jsxs)(i.default,{style:{flex:1,gap:4},children:[(0,y.jsx)(o.T,{weight:"semibold",children:e}),(0,y.jsx)(o.Muted,{children:s}),(0,y.jsx)(o.Button,{small:!0,kind:u?'ghost':'secondary',label:u?'Mark as not done':'Mark as done',accessibilityLabel:`${u?'Undo':'Done'}: ${e}`,onPress:()=>n(u?t.filter(e=>e!==l):[...t,l])})]})]})},e)}),(0,y.jsx)(o.Muted,{children:"Stuck? Free lifetime customer support is included while you subscribe. Ticks on this guide are not saved."})]})}},1489,[1490,34,102,794,850,891,1492,821,1088,1493,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VoiceUsageCard=function({rid:e,now:o}){const h=(0,l.useVoiceUsage)(e,o);return(0,c.jsx)(s.Card,{children:(0,c.jsxs)(n.default,{testID:"voice-usage",style:{gap:6},children:[(0,c.jsx)(s.T,{weight:"semibold",children:h.line}),(0,c.jsx)(n.default,{style:{height:8,borderRadius:4,backgroundColor:t.colours.surface2,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${Math.min(100,Math.round(100*h.pct))}%`,height:8,backgroundColor:h.reached?t.colours.red:h.warn?t.colours.amber:t.colours.ok}})}),(0,c.jsxs)(s.Muted,{children:[l.VOICE_FAIR_USAGE,", shared by all of this venue\u2019s apps and devices. Food safety logging always works."]}),h.reached?(0,c.jsx)(s.Banner,{kind:"info",title:"Allowance reached for this month",children:l.REACHED_TEXT}):h.warn?(0,c.jsx)(s.Banner,{kind:"warn",title:"80% of this month\u2019s allowance used",children:"The voice helper keeps working until 1,000; it starts again on the 1st."}):null,(0,c.jsx)(s.Muted,{children:"For now the count is kept on each device; it will become one venue-wide count."})]})})},r(d[0]);var e,o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),l=r(d[4]),c=r(d[5])},1490,[34,102,794,821,1491,25]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1491,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PLAN",{enumerable:!0,get:function(){return t}}),e.trialStatus=function(n,o){const l=new Date(n.getFullYear(),n.getMonth(),n.getDate()),u=new Date(l.getFullYear(),l.getMonth()+t.trialMonths,l.getDate()),c=Math.max(0,Math.ceil((u.getTime()-o.getTime())/864e5));return{start:l,end:u,daysLeft:c,total:Math.round((u.getTime()-l.getTime())/864e5)}};const t={name:'CoverCharge',monthlyPence:4900,trialMonths:1,vatNote:'+ VAT if applicable'}},1492,[]); +__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,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"useAssistantUi",{enumerable:!0,get:function(){return v}}),_e.AssistantFab=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)(e=>e.enabled);return R(e)&&t?(0,A.jsxs)(c.default,{testID:"assistant-fab",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>v.getState().setOpen(!0),style:{position:'absolute',right:16,bottom:78,height:56,minWidth:56,paddingHorizontal:16,borderRadius:28,backgroundColor:k.colours.gold,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,zIndex:50,boxShadow:'0 4px 14px rgba(0,0,0,0.5)'},children:[(0,A.jsx)(M,{size:22}),(0,A.jsx)(b.T,{weight:"bold",colour:I,children:"Assistant"})]}):null},_e.AssistantSheet=function(){const e=v(e=>e.open),o=()=>v.getState().setOpen(!1),{rid:a,role:p,me:C}=(0,w.useCtx)(3e4),S=(0,j.useAssistant)(),I=B(),[E,L]=(0,r.useState)([]),[W,z]=(0,r.useState)(''),[$,_]=(0,r.useState)(!1),N=(0,r.useRef)(null),F=(0,r.useRef)(null);if((0,r.useEffect)(()=>{setTimeout(()=>N.current?.scrollToEnd?.({animated:!0}),50)},[E.length]),!e||!R(p))return null;const H=(e,t,s)=>j.useAssistant.getState().record({at:(new Date).toISOString(),by:C,role:p,asked:e,action:t,outcome:s}),U=(e,t="result")=>L(s=>[...s,{id:D(),from:'assistant',text:e,kind:t}]),V=async e=>{const t=e.trim();if(!t)return;let s;z(''),L(e=>[...e,{id:D(),from:'you',text:t}]);try{s=await(0,y.getProvider)('xai').interpret(t,I)}catch(e){s={kind:'unknown',message:String(e.message),suggestions:[]}}'unknown'===s.kind&&H(t,'\u2014','not understood'),L(e=>[...e,{id:D(),from:'assistant',proposal:s,state:'open',asked:t}])},G=(e,t)=>L(s=>s.map(s=>s.id===e?{...s,state:t}:s)),q=async(e,t,n)=>{if(G(e.id,'confirmed'),'external'===t.kind)return H(e.asked,`${t.title}: \u201c${(n??t.text).slice(0,120)}\u201d`,'demo (nothing sent)'),void U(T,'demo');if('inapp'!==t.kind)return;const o=t.params;switch(t.intent){case'walkin':{const s=String(o.table||'')||void 0;await m.repo.bookings.seatWalkIn(a,Number(o.party),s,'Added by Assistant'),s&&(0,f.resetTableLive)(a,s),U(`Done: Walk-in \xb7 ${o.party} seated${s?` at table ${s}`:' (table to assign)'}. It's in Bookings now.`),H(e.asked,t.title,'done');break}case'eightysix':(0,s.setSoldOut)(String(o.itemId),Boolean(o.soldOut)),U(o.soldOut?`Done: ${o.name} is marked sold out. Staff see it on the Display.`:`Done: ${o.name} is back on.`),H(e.asked,t.title,'done');break;case'price':await m.repo.menu.updateItem(String(o.itemId),{price:Number(o.pence)}),U(`Done: ${o.name} is now \xa3${(Number(o.pence)/100).toFixed(2)}.`),H(e.asked,t.title,'done');break;case'offer':x.useOwner.getState().addOffer({title:String(o.title),body:String(o.body),kind:'offer',live:!1}),U(`Done: draft offer \u201c${o.title}\u201d saved in Offers & specials (not live).`),H(e.asked,t.title,'done');break;case'rota':case'bookings':U(String(o.result)),H(e.asked,t.title,'looked up')}},Y=e=>{G(e.id,'cancelled'),H(e.asked,e.proposal?.title??'\u2014','cancelled'),U('Cancelled. Nothing was changed.','note')},K='lite'===S.tier,J=(0,j.tasksUsed)(S);return(0,A.jsx)(l.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:o,children:(0,A.jsx)(h.default,{style:[b.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,A.jsxs)(h.default,{testID:"assistant-sheet",style:{backgroundColor:k.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:k.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.Row,{gap:8,style:{flex:1},children:[(0,A.jsx)(h.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:18})}),(0,A.jsx)(b.T,{size:20,weight:"semibold",children:"Assistant"})]}),(0,A.jsx)(n.GoldClose,{testID:"assistant-close",onPress:o,style:{marginRight:-6}})]}),(0,A.jsx)(h.default,{testID:"assistant-demo-badge",children:(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo mode \xb7 the secure AI server isn\u2019t connected yet"})}),K?(0,A.jsxs)(h.default,{testID:"assistant-upgrade",style:{gap:10},children:[(0,A.jsx)(b.Banner,{kind:"info",title:"The Assistant is switched off in this preview",children:"Ask for things in plain English \u2014 add a walk-in, mark a dish sold out, check the rota, draft posts and replies \u2014 and confirm each one before anything happens. To use it, turn off the preview switch in More \u203a Account \u203a Assistant settings."}),(0,A.jsx)(b.Button,{kind:"secondary",label:"Close",onPress:o})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(u.default,{ref:N,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===E.length?(0,A.jsxs)(h.default,{style:{gap:8},testID:"suggested-prompts",children:[(0,A.jsxs)(b.T,{children:["Hi ",C.split(' ')[0]," \u2014 what can I do? I\u2019ll always show you what I\u2019m about to do and wait for you to confirm."]}),(0,A.jsx)(b.Muted,{children:"Try:"}),y.SUGGESTED_PROMPTS.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Suggestion: ${e}`,onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:k.colours.surface2},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]}):null,E.map(e=>'you'===e.from?(0,A.jsx)(h.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,A.jsx)(b.T,{children:e.text})},e.id):e.proposal?'inapp'===e.proposal.kind||'external'===e.proposal.kind?(0,A.jsx)(P,{m:e,onConfirm:(t,s)=>q(e,t,s),onCancel:()=>Y(e)},e.id):'choose'===e.proposal.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),(0,A.jsx)(b.Row,{wrap:!0,gap:6,children:e.proposal.options.map(e=>(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:e.label,onPress:()=>V(e.prompt)},e.label))})]},e.id):(0,A.jsxs)(h.default,{testID:"assistant-unknown",style:{gap:6},children:[(0,A.jsx)(b.T,{children:e.proposal.message}),e.proposal.suggestions.map(e=>(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>V(e),style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:8},children:(0,A.jsx)(b.T,{size:14,children:e})},e))]},e.id):(0,A.jsx)(h.default,{testID:'demo'===e.kind?'assistant-demo-note':'assistant-result',style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:'demo'===e.kind?k.colours.amberBg:k.colours.surface2,borderRadius:14,padding:10,borderWidth:'demo'===e.kind?1:0,borderColor:k.colours.amber},children:(0,A.jsx)(b.T,{children:e.text})},e.id))]}),(0,A.jsxs)(b.Row,{gap:8,children:[(0,A.jsx)(t.TextInput,{accessibilityLabel:"Ask the Assistant",placeholder:"Ask in plain English\u2026",placeholderTextColor:"#7D776C",value:W,onChangeText:z,onSubmitEditing:()=>V(W),returnKeyType:"send",style:[b.styles.input,{flex:1,minWidth:0,width:40}]}),S.voice?(0,A.jsx)(c.default,{testID:"assistant-mic",accessibilityRole:"button",accessibilityLabel:$?'Stop listening':'Speak',onPress:()=>{const e=O();if(e)if($)F.current?.stop?.();else try{const t=new e;F.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&z(t)},t.onend=()=>_(!1),t.onerror=()=>{_(!1),U("Sorry, I didn't catch that. You can type instead.",'note')},_(!0),t.start()}catch{_(!1),U("Voice input isn't available here. Please type instead.",'note')}else U("Voice input isn't available in this browser (for example Huawei Browser). Please type your request instead.",'note')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:k.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:$?k.colours.gold:'transparent'},children:(0,A.jsx)(b.T,{size:20,children:"\ud83c\udfa4"})}):null,(0,A.jsx)(b.Button,{label:"Send",accessibilityLabel:"Send",disabled:!W.trim(),onPress:()=>V(W)})]}),(0,A.jsxs)(b.Muted,{center:!0,children:["Demo on this device \xb7 ",J," of ",j.FAIR_USE," tasks this month \xb7 nothing is sent automatically"]})]})]})})})},_e.AssistantPage=function({go:e}){const{role:t}=(0,w.useCtx)(6e4),s=(0,j.useAssistant)();return R(t)?(0,A.jsxs)(h.default,{style:{gap:12},children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{gap:10,children:[(0,A.jsx)(h.default,{style:{width:44,height:44,borderRadius:22,backgroundColor:k.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(M,{size:22})}),(0,A.jsxs)(h.default,{style:{flex:1},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Ask for things in plain English"}),(0,A.jsx)(b.Muted,{children:"Add walk-ins, mark dishes sold out, change prices, check the rota or bookings, draft offers, posts and replies. You confirm every action."})]})]}),(0,A.jsx)(b.Button,{label:s.enabled?'Open Assistant':'Assistant is off',disabled:!s.enabled,testID:"open-assistant",onPress:()=>v.getState().setOpen(!0)}),(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Assistant settings \u203a",onPress:()=>e('more','assistantsettings')})]}),'owner'===t?(0,A.jsxs)(h.default,{testID:"assistant-log",style:{gap:6},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Activity log"}),s.log.length?(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Clear",onPress:()=>j.useAssistant.getState().clearLog()}):null]}),(0,A.jsx)(b.Muted,{children:"What was asked and what was confirmed, on this device. Visible to the owner."}),0===s.log.length?(0,A.jsx)(b.Muted,{children:"Nothing yet."}):s.log.map(e=>(0,A.jsxs)(h.default,{style:{borderWidth:1,borderColor:k.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsxs)(b.T,{size:12,colour:k.colours.muted,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,")"]}),(0,A.jsx)(b.Badge,{kind:'done'===e.outcome||'looked up'===e.outcome?'ok':'demo (nothing sent)'===e.outcome?'amber':'neutral',label:e.outcome})]}),(0,A.jsxs)(b.T,{size:14,children:["Asked: \u201c",e.asked,"\u201d"]}),(0,A.jsxs)(b.T,{size:13,colour:k.colours.muted,children:["Action: ",e.action]})]},e.id))]}):(0,A.jsx)(b.Muted,{children:"The activity log is visible to the owner."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantSettings=function(){const{role:e}=(0,w.useCtx)(6e4),t=(0,j.useAssistant)();return R(e)?(0,A.jsxs)(h.default,{style:{gap:12},testID:"assistant-settings",children:[(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Assistant on",value:t.enabled,onChange:e=>t.set({enabled:e})}),(0,A.jsx)(b.Muted,{children:"Shows the gold Assistant button on every Managers screen."}),(0,A.jsx)(b.Toggle,{label:"Voice input (microphone)",value:t.voice,onChange:e=>t.set({voice:e})}),(0,A.jsx)(b.Muted,{children:"What you say is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. If this device can\u2019t record, just type."})]}),(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Connected services"}),E.map(e=>(0,A.jsxs)(h.default,{testID:`service-${e.id}`,style:{gap:2,borderTopWidth:1,borderColor:k.colours.border,paddingTop:8},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{children:e.name}),(0,A.jsx)(b.Badge,{kind:"neutral",label:"Not connected"})]}),(0,A.jsxs)(b.Muted,{children:["Needed for ",e.does,". Until it\u2019s connected, the Assistant only shows you a preview \u2014 nothing is sent or changed."]})]},e.id)),(0,A.jsx)(b.Muted,{children:"Connecting accounts isn\u2019t available yet."})]}),'owner'===e?(0,A.jsxs)(b.Card,{children:[(0,A.jsx)(b.Toggle,{label:"Preview the app with the Assistant switched off",value:'lite'===t.tier,onChange:e=>t.set({tier:e?'lite':'pro'})}),(0,A.jsx)(b.Muted,{children:"The Assistant comes with Full Restaurant Pro App and the early adopter offer. It isn\u2019t part of Customer & Takeaway App. This switch only shows how the app looks with it switched off."})]}):null,(0,A.jsx)(b.Muted,{children:"Every action needs your confirmation; nothing is ever sent automatically. If the assistant here doesn\u2019t understand, your words go to the voice assistant to work out what you meant. Nothing changes until you tap Confirm."})]}):(0,A.jsx)(b.Banner,{kind:"info",title:"Owners and managers only",children:"The Assistant is for owners and managers."})},_e.AssistantPlanCard=function(){const e=(0,j.useAssistant)(),t=(0,j.tasksUsed)(e),s=Math.min(1,t/j.FAIR_USE);return(0,A.jsxs)(b.Card,{children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",children:"Assistant: fair use 300 tasks/month"}),(0,A.jsx)(b.Badge,{kind:s>.9?'red':'gold',label:'lite'===e.tier?'Switched off':'Included'})]}),(0,A.jsx)(h.default,{testID:"assistant-usage",accessibilityLabel:`${t} of ${j.FAIR_USE} tasks used`,style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,A.jsx)(h.default,{style:{height:8,width:`${Math.round(100*s)}%`,backgroundColor:k.colours.gold,borderRadius:4}})}),(0,A.jsxs)(b.Muted,{children:[t," of ",j.FAIR_USE," tasks used this month (mock). A task is one confirmed action or look-up."]})]})};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),o=_r(d[3]),a=_r(d[4]),r=_r(d[5]),l=e(_r(d[6]));_r(d[7]);var c=e(_r(d[8])),u=e(_r(d[9])),h=e(_r(d[10])),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),m=_r(d[14]),x=_r(d[15]),y=_r(d[16]),j=_r(d[17]),k=_r(d[18]),w=_r(d[19]),C=_r(d[20]),A=_r(d[21]);const S=!0,T='Nothing was sent or changed: this connection is not set up yet.',I='#1A1408',v=(0,p.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=e=>'owner'===e||'manager'===e,D=()=>Math.random().toString(36).slice(2,9);function M({size:e=24,colour:t=I}){return(0,A.jsx)(b.T,{size:e,weight:"bold",colour:t,style:{lineHeight:1.1*e},children:"\u2726"})}function B(){const{rid:e,r:t,now:s,today:n}=(0,w.useCtx)(3e4),a=(0,m.useAllMenu)(e),l=(0,f.useTableNames)(e),c=(0,m.useBookings)(e),u=(0,x.useOwner)(e=>e.staff),h=(0,x.useOwner)(e=>e.shifts),p=(0,x.useOwner)(e=>e.offers),b=(0,x.useOwner)(e=>e.suppliers);return(0,r.useMemo)(()=>({venue:t.name,now:s.toISOString(),menu:a.map(e=>({id:e.id,name:e.name,price:e.price,soldOut:e.soldOut})),tables:l,staff:u.filter(e=>e.active).map(e=>({id:e.id,name:e.name,job:e.job})),shifts:(0,C.workingShifts)(h,x.useOwner.getState().leave).filter(e=>e.published&&e.date>=(0,x.addDays)(n,-(0,x.weekdayOf)(n))&&e.date<=(0,x.addDays)(n,6-(0,x.weekdayOf)(n))),bookingsToday:c.filter(e=>e.date===n).sort((e,t)=>e.time.localeCompare(t.time)).map(e=>({name:e.walkIn?'Walk-in':e.name,party:e.partySize,time:e.time,table:e.table,status:e.status})),specials:p.filter(e=>'special'===e.kind&&e.live).map(e=>({title:e.title,body:e.body})),kitchenHours:t.kitchenHours,latestSupplierEmail:(0,o.examplesAllowed)()?{from:`${b[0]?.contact??'Alex Sample'}, ${b[0]?.name??'Example Fish Co.'}`,subject:'Price update for next week (example)',body:'Langoustine is up about 8% next week because of the weather. Haddock and hake unchanged. Same delivery days.'}:null}),[t,s.getMinutes(),a,l,c,u,h,p,b])}function P({m:e,onConfirm:s,onCancel:n}){const o=e.proposal,[a,l]=(0,r.useState)(!1),[c,u]=(0,r.useState)('external'===o.kind?o.text:''),p='open'===e.state;return'inapp'!==o.kind&&'external'!==o.kind?null:(0,A.jsxs)(h.default,{testID:"confirm-card",style:{borderWidth:1.5,borderColor:p?k.colours.gold:k.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:k.colours.surface2},children:[(0,A.jsxs)(b.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(b.T,{weight:"semibold",style:{flex:1},children:o.title}),'external'===o.kind?(0,A.jsx)(b.Badge,{kind:"amber",label:"Demo \xb7 not connected"}):(0,A.jsx)(b.Badge,{kind:"gold",label:"In CoverCharge"})]}),'external'===o.kind?(0,A.jsxs)(h.default,{style:{gap:6},children:[o.detail?(0,A.jsx)(b.Muted,{children:o.detail}):null,(0,A.jsx)(b.T,{size:14,colour:k.colours.muted,children:o.label}),a&&p?(0,A.jsx)(t.TextInput,{accessibilityLabel:"Edit text",multiline:!0,value:c,onChangeText:u,style:[b.styles.input,{minHeight:90,textAlignVertical:'top'}]}):(0,A.jsx)(h.default,{testID:"preview-text",style:{borderLeftWidth:3,borderColor:k.colours.gold,paddingLeft:10},children:(0,A.jsxs)(b.T,{children:["\u201c",c,"\u201d"]})}),(0,A.jsxs)(b.Muted,{children:["Sends to: ",o.service.map(e=>y.SERVICE_LABEL[e]).join(' & ')," \u2014 not connected, so nothing will be sent."]})]}):(0,A.jsxs)(h.default,{style:{gap:4},children:[(0,A.jsx)(b.Muted,{children:o.detail}),o.warning?(0,A.jsxs)(b.T,{size:13,colour:k.colours.amber,children:["\u26a0 ",o.warning]}):null]}),p?(0,A.jsxs)(b.Row,{wrap:!0,gap:8,children:[(0,A.jsx)(b.Button,{small:!0,label:'inapp'===o.kind?o.confirmLabel:'Confirm',testID:"confirm-action",onPress:()=>s(o,c)}),'external'===o.kind?(0,A.jsx)(b.Button,{small:!0,kind:"secondary",label:a?'Done editing':'Edit',testID:"edit-action",onPress:()=>l(!a)}):null,(0,A.jsx)(b.Button,{small:!0,kind:"ghost",label:"Cancel",testID:"cancel-action",onPress:n})]}):(0,A.jsx)(b.Badge,{kind:'confirmed'===e.state?'ok':'neutral',label:'confirmed'===e.state?'Confirmed':'Cancelled \u2014 nothing done'}),p?(0,A.jsxs)(b.Muted,{children:["Nothing happens until you tap ",'inapp'===o.kind?o.confirmLabel:'Confirm',"."]}):null]})}function O(){return'undefined'==typeof window?null:(0,a.speechRecognizer)()}const E=[{id:'facebook',name:'Facebook (Page & Messenger)',does:'posts and the Messenger auto-reply'},{id:'instagram',name:'Instagram',does:'posts'},{id:'gmail',name:'Gmail',does:'drafting and replying to email'},{id:'wix',name:'Website bookings',does:'website changes such as opening hours'}]},1493,[827,979,796,884,931,34,395,236,402,295,102,846,794,1126,874,891,1494,1498,821,1088,1098,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"interpretDemo",{enumerable:!0,get:function(){return t.interpretDemo}}),e.getProvider=function(o="demo"){return'xai'===o?n.xaiProvider:t.demoProvider};var t=r(d[0]),n=r(d[1]),o=r(d[2]);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]}})})},1494,[1495,1497,1496]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.interpretDemo=u,Object.defineProperty(_e,"demoProvider",{enumerable:!0,get:function(){return m}});var e=r(_d[0]),t=r(_d[1]);const a=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],n=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,o=e=>e.toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').trim(),s=e=>o(e).replace(/\([^)]*\)/g,' ').split(/[^a-z0-9]+/).filter(e=>e.length>2&&!['the','and','with','our'].includes(e)),l={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},d=e=>e?l[e]??Number(e):NaN,c=e=>(e.match(/["\u201c\u201d']([^"\u201c\u201d]{3,})["\u201c\u201d']?\s*$/)||e.match(/\bto[:\s]+(.{3,})$/i)||[])[1]?.replace(/["\u201c\u201d]+$/,'').trim();function p(e,t){const a=s(t),n=e.menu.map(e=>{const n=s(e.name);return{m:e,hits:a.filter(e=>n.includes(e)).length,exact:o(e.name).includes(o(t))}}),l=n.filter(e=>e.exact);if(1===l.length)return[l[0].m];const d=Math.max(0,...n.map(e=>e.hits));if(!d)return[];const c=n.filter(e=>e.hits===d).map(e=>e.m);return d===a.length&&1===c.length?c:c.slice(0,4)}function u(s,l){const u=o(s),m=new Date(l.now);if(/messenger|auto-?reply|away message/.test(u)){return{kind:'external',intent:'messenger-autoreply',service:['messenger'],title:'Facebook Messenger auto-reply',label:'Change Messenger auto-reply to:',text:c(s)||`Thanks for getting in touch with ${l.venue}! We'll reply as soon as we can. To book a table, use our app.`}}if(/\b(post|share|publish)\b/.test(u)&&/facebook|instagram|\bfb\b|\binsta|\big\b|social/.test(u)){const e=/facebook|\bfb\b|social/.test(u),t=/instagram|\binsta|\big\b|social/.test(u),a=/special/.test(u)&&l.specials.length?`Tonight at ${l.venue}: ${l.specials.map(e=>e.title.replace(/\s*\(example\)/i,'')).join(' \xb7 ')}. Book in the app or just walk in!`:c(s)||`Tonight at ${l.venue} \u2014 come and see us!`,n=[...e?['facebook']:[],...t?['instagram']:[]];return{kind:'external',intent:'social-post',service:n,title:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}`,label:`Post to ${n.map(e=>'facebook'===e?'Facebook':'Instagram').join(' & ')}:`,text:a}}if(/(reply|respond|answer|draft).*(e-?mail|gmail|supplier)|(e-?mail|gmail).*(reply|draft)/.test(u)){const e=l.latestSupplierEmail;if(!e)return{kind:'unknown',message:"I can't read your email yet: CoverCharge isn't linked to Gmail. Paste the supplier's message here and I'll draft a reply for you to check and send yourself.",suggestions:[]};const t=`Hi ${e.from.split(' ')[0]},\n\nThanks for letting us know. That's fine for this week \u2014 please keep our usual standing order and let me know if anything changes.\n\nBest wishes,\n${l.venue}`;return{kind:'external',intent:'gmail-reply',service:['gmail'],title:`Gmail reply to ${e.from}`,label:`Reply to "${e.subject}" (${e.from}):`,text:t,detail:`Latest supplier email (example): "${e.body}"`}}if(/\bwix\b|website|web site/.test(u)&&/hour|open|clos/.test(u)){return{kind:'external',intent:'wix-hours',service:['wix'],title:'Website bookings opening hours',label:'Update website bookings opening hours to:',text:[1,2,3,4,5,6,0].map(e=>{const t=l.kitchenHours[e];return`${a[(e+6)%7]}: ${t?`${t[0]}\u2013${t[1]}`:'Closed'}`}).join('\n'),detail:'From the kitchen hours saved in CoverCharge.'}}const h=u.match(/walk-?in\b.*?\b(?:for|of)\s+(\d+|[a-z]+)(?:.*?\btable\s+([a-z]?\d+[a-z]?(?:\+\d+)?))?/)||u.match(/\b(\d+|[a-z]+)\s+walk-?ins?\b(?:.*?\btable\s+([a-z]?\d+))?/);if(h&&!Number.isNaN(d(h[1]))){const t=d(h[1]),a=h[2]?h[2].toUpperCase():'';if(a&&!l.tables.map(e=>e.toUpperCase()).includes(a))return{kind:'unknown',message:`There's no table ${a} on the table plan. Try one of: ${l.tables.slice(0,12).join(', ')}.`,suggestions:[`Add a walk-in for ${t} at table ${l.tables[0]}`]};const n=a?l.bookingsToday.find(e=>e.table?.toUpperCase().split('+').includes(a)&&['seated','confirmed'].includes(e.status)):void 0;return{kind:'inapp',intent:'walkin',title:`Seat a walk-in for ${t}${a?` at table ${a}`:''}`,detail:`Adds \u201cWalk-in \xb7 ${t}\u201d to today's bookings${a?` at table ${a}`:' (table to assign)'} and counts ${t} covers.`,confirmLabel:'Seat walk-in',params:{party:t,table:a},warning:n?`${(0,e.tableNumbers)(a)} also has a ${n.status} booking at ${n.time} (party of ${n.party}).`:void 0}}const b=u.match(/^(?:please )?(?:mark |set |make )?(?:the )?(.+?)\s+(?:as |to )?(?:86'?d?|86ed|sold out)(?=\W|$)/)||u.match(/^86 (?:the )?(.+)$/),f=u.match(/^(?:put |mark |set )?(?:the )?(.+?)\s+(?:back on|as available|available again|un-?86'?d?)/);if((b||f)&&!/walk|book|rota|price/.test(u)){const e=(b||f)[1].replace(/^mark |^set /,''),t=p(l,e),a=!!f&&!b;return 1===t.length?{kind:'inapp',intent:'eightysix',title:a?`Put ${t[0].name} back on`:`Mark ${t[0].name} sold out`,detail:a?'Takes it off the Sold out list and the Display.':'A reminder for staff: it shows on the Display and in the Sold out list until you put it back on. It doesn\'t change your till.',confirmLabel:a?'Back on':'Mark sold out',params:{itemId:t[0].id,name:t[0].name,soldOut:!a}}:t.length>1?{kind:'choose',message:`I couldn't find "${e}" exactly on the menu. Did you mean:`,options:t.map(e=>({label:e.name,prompt:`Mark ${e.name} sold out`}))}:{kind:'unknown',message:`I couldn't find "${e}" on the menu.`,suggestions:['Mark the Fish Supper sold out']}}const k=u.match(/(?:change|set|update|make)\s+(?:the\s+)?(?:price\s+of\s+(?:the\s+)?)?(.+?)\s+(?:price\s+)?to\s+\xa3?\s?(\d+(?:\.\d{1,2})?)/);if(k&&/\xa3|price|\d/.test(u)){const e=p(l,k[1].replace(/\s*price$/,'')),t=Math.round(100*Number(k[2]));if(1===e.length)return{kind:'inapp',intent:'price',title:`Change ${e[0].name} to \xa3${(t/100).toFixed(2)}`,detail:`Now ${null==e[0].price?'board price':`\xa3${(e[0].price/100).toFixed(2)}`}. Updates the menu in the customer app.`,confirmLabel:'Change price',params:{itemId:e[0].id,name:e[0].name,pence:t}};if(e.length>1)return{kind:'choose',message:'Which dish?',options:e.map(e=>({label:e.name,prompt:`Change the price of ${e.name} to \xa3${(t/100).toFixed(2)}`}))}}if(/rota|who'?s on|who is on|working|on shift/.test(u)){let e=(m.getDay()+6)%7,t='today';/tomorrow/.test(u)&&(e=(e+1)%7,t='tomorrow');const o=a.findIndex(e=>u.includes(e.toLowerCase()));o>=0&&(e=o,t=a[o]);const s=l.shifts.filter(t=>t.day===e).sort((e,t)=>e.start-t.start).map(e=>{const t=l.staff.find(t=>t.id===e.staffId);return`${t?.name??'Someone'} (${t?.job??''}) ${n(e.start)}\u2013${n(e.end)}`});return{kind:'inapp',intent:'rota',title:`Show the rota for ${t} (${a[e]})`,detail:'Read-only: looks up the rota saved in CoverCharge. Nothing is changed.',confirmLabel:'Show rota',params:{day:e,label:t,result:s.length?s.join('\n'):'Nobody is on the rota.'}}}if(/booking|covers|reservations?/.test(u)&&!/^(add|make|create)/.test(u)){const t=l.bookingsToday.filter(e=>!['cancelled','noshow'].includes(e.status)),a=t.map(t=>`${t.time} \xb7 ${t.name} \xb7 ${t.party}${t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:''} \xb7 ${t.status}`);return{kind:'inapp',intent:'bookings',title:"Show today's bookings",detail:'Read-only: looks up bookings saved in CoverCharge. Nothing is changed.',confirmLabel:'Show bookings',params:{result:`${t.length} bookings, ${t.reduce((e,t)=>e+t.party,0)} covers\n${a.join('\n')}`}}}if(/(draft|create|write|make|add).*(offer|deal|promo|special)/.test(u)){const e=(s.match(/(?:offer|deal|promo|special)\s+(?:for|on)\s+(.+)$/i)||[])[1]?.trim(),t=e?`${e[0].toUpperCase()}${e.slice(1)}`:'Midweek offer (draft)';return{kind:'inapp',intent:'offer',title:`Draft an offer: ${t}`,detail:'Saved as a draft in Offers & specials (not live, nothing sent). Edit it there before you publish.',confirmLabel:'Save draft',params:{title:t,body:e?`${t} at ${l.venue}. Ask your server for details.`:`A midweek treat at ${l.venue}. Add the details before you publish.`}}}return{kind:'unknown',message:"Sorry \u2014 I can't do that yet. Here are some things I can help with:",suggestions:t.SUGGESTED_PROMPTS.slice(1,6)}}const m={id:'demo',label:'On-device assistant',interpret:async(e,t)=>u(e,t)}},1495,[860,1496]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SUGGESTED_PROMPTS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SERVICE_LABEL",{enumerable:!0,get:function(){return t}});const o=['Change our Facebook Messenger auto-reply to "Thanks for your message \u2014 we reply within the hour. To book, use the app."','Draft a reply to the latest supplier email','Add a walk-in for 4 at table 7',"Post tonight's specials to Facebook & Instagram",'Mark the fish pie sold out',"Who's on the rota tomorrow?",'Update website bookings opening hours'],t={facebook:'Facebook',messenger:'Facebook Messenger',instagram:'Instagram',gmail:'Gmail',wix:'Website bookings'}},1496,[]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_TOOLS",{enumerable:!0,get:function(){return o}}),e.callToText=a,e.interpretWithServer=s,Object.defineProperty(e,"xaiProvider",{enumerable:!0,get:function(){return u}});var t=_r(d[0]),n=_r(d[1]);const r=(t,n,r,o=[])=>({type:'function',function:{name:t,description:n,parameters:{type:'object',properties:r,required:o}}}),o=[r('walk_in','Seat a walk-in party now',{party:{type:'integer',description:'Number of covers'},table:{type:'string',description:'Table name, optional'}},['party']),r('sold_out','Mark a dish sold out, or put it back on',{dish:{type:'string',description:'Dish name'},back_on:{type:'boolean',description:'True to put it back on'}},['dish']),r('set_price','Change the menu price of a dish',{dish:{type:'string',description:'Dish name'},pounds:{type:'number',description:'New price in pounds'}},['dish','pounds']),r('show_rota','Show who is on the rota',{day:{type:'string',description:'today, tomorrow or a weekday'}}),r('show_bookings',"Show today's bookings and covers",{}),r('draft_offer','Draft an offer (saved as a draft, not live)',{what:{type:'string',description:'What the offer is for'}})];function a(t,n){const r=t=>String(n[t]??'').trim();switch(t){case'walk_in':return Number(n.party)>0?`walk-in for ${Number(n.party)}${r('table')?` table ${r('table')}`:''}`:null;case'sold_out':return r('dish')?n.back_on?`put ${r('dish')} back on`:`mark ${r('dish')} sold out`:null;case'set_price':return r('dish')&&Number(n.pounds)>0?`change the price of ${r('dish')} to \xa3${Number(n.pounds)}`:null;case'show_rota':return`who's on the rota ${r('day')||'today'}`;case'show_bookings':return"today's bookings";case'draft_offer':return"draft an offer"+(r('what')?` for ${r('what')}`:'');default:return null}}async function s(r,s,u=n.askServer){const c=(0,t.interpretDemo)(r,s);if('unknown'!==c.kind)return c;const p=await u('owner',r,o);if('call'===p.kind){const n=a(p.name,p.args);if(n){const r=(0,t.interpretDemo)(n,s);if('unknown'!==r.kind)return r}return c}return'text'===p.kind?{kind:'unknown',message:p.text,suggestions:[]}:c}const u={id:'xai',label:'Voice assistant (server, with on-device fallback)',interpret:s}},1497,[1495,932]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FAIR_USE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useAssistant",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tasksUsed",{enumerable:!0,get:function(){return b}});var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]);const c=300,u=(0,s.create)()((0,l.persist)(e=>({enabled:!0,voice:!0,tier:'pro',baseUsed:41,log:[],set:t=>e(t),record:t=>e(e=>({log:[{...t,id:`as-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`},...e.log].slice(0,200)})),clearLog:()=>e({log:[]})}),{name:'covercharge-assistant-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:(e,t)=>t<2?{...e,enabled:!0,voice:!0}:e})),b=e=>((0,t.examplesAllowed)()?e.baseUsed:0)+e.log.filter(e=>['done','demo (nothing sent)','looked up'].includes(e.outcome)).length},1498,[884,839,846,849]); +__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.InfoHours=function(){const{r:e}=(0,C.useCtx)(6e4),[t,s]=(0,c.useState)(e.tagline),[n,l]=(0,c.useState)(e.phone??''),[i,r]=(0,c.useState)(e.about??''),[d,o]=(0,c.useState)(e.kitchenHours),[u,g]=(0,c.useState)(!1);return(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"info",title:"Edit basic info yourself anytime",children:"Prices, sold-out, hours and specials are free to change on any plan, as often as you like."}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.name}),(0,P.jsx)(x.Muted,{children:e.location}),(0,P.jsx)(x.Field,{label:"Tagline",value:t,onChangeText:s}),(0,P.jsx)(x.Field,{label:"Phone",value:n,onChangeText:l,keyboardType:"phone-pad"}),(0,P.jsx)(x.Field,{label:"About",value:i,onChangeText:r,multiline:!0,placeholder:"A short welcome for the app's restaurant page"})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Kitchen hours"}),R.map((e,t)=>{const s=B[t],n=d[s];return(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{style:{width:44},children:e}),n?(0,P.jsxs)(x.Row,{gap:4,style:{flex:1,minWidth:0},children:[(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} opens`,value:n[0],onChangeText:e=>o({...d,[s]:[e,n[1]]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]}),(0,P.jsx)(x.T,{children:"\u2013"}),(0,P.jsx)(a.TextInput,{accessibilityLabel:`${e} closes`,value:n[1],onChangeText:e=>o({...d,[s]:[n[0],e]}),style:[x.styles.input,{flex:1,minWidth:0,paddingVertical:6}]})]}):(0,P.jsx)(x.Muted,{style:{flex:1},children:"Closed"}),(0,P.jsx)(h.default,{accessibilityLabel:`${e} open`,value:!!n,onValueChange:e=>o({...d,[s]:e?['12:00','20:00']:null}),trackColor:{true:w.colours.gold,false:'#444'},thumbColor:n?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:w.colours.gold,style:{marginLeft:8}})]},e)}),e.hoursNote?(0,P.jsx)(x.Muted,{children:e.hoursNote}):null]}),(0,P.jsx)(x.Button,{label:"Save changes",onPress:()=>{M().updateRestaurant(e.id,{tagline:t,phone:n,about:i,kitchenHours:d}),g(!0)}}),u?(0,P.jsx)(x.Banner,{kind:"success",title:"Saved",children:"Shared with your other devices and the customer app. Guests see it next time they open the app."}):null]})},_e.Photos=function(){const e=(0,m.useOwner)(e=>e.photos),[t,s]=(0,c.useState)('');return r.LIVE_VENUE_BUILD?(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Photo uploads are not connected"}),(0,P.jsx)(x.Muted,{children:"No photo uploads are available here. Your existing venue artwork is unchanged."})]}):(0,P.jsxs)(p.default,{style:{gap:12},children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Placeholder photos",children:"Adding photos from the camera or gallery isn\u2019t set up yet. Tiles stand in for uploaded photos."}),(0,P.jsx)(x.Row,{wrap:!0,gap:8,children:e.map(e=>(0,P.jsxs)(p.default,{style:{width:'48%',height:120,backgroundColor:e.tone,borderRadius:12,padding:8,justifyContent:'flex-end'},children:[(0,P.jsx)(x.T,{size:13,children:e.caption}),(0,P.jsx)(u.default,{accessibilityRole:"button",accessibilityLabel:`Remove photo ${e.caption}`,onPress:()=>m.useOwner.getState().removePhoto(e.id),style:{minHeight:44,minWidth:44,justifyContent:'center',alignSelf:'flex-start'},children:(0,P.jsx)(x.T,{size:13,colour:w.colours.gold,children:"Remove"})})]},e.id))}),(0,P.jsx)(x.Field,{label:"Caption",value:t,onChangeText:s,placeholder:"e.g. Langoustines on the terrace"}),(0,P.jsx)(x.Button,{label:"Add photo (placeholder)",disabled:!t.trim(),onPress:()=>{m.useOwner.getState().addPhoto(`${t.trim()} (placeholder)`),s('')}})]})},_e.MenuManager=function({go:e}={}){const{rid:t,r:s,me:l,role:i}=(0,C.useCtx)(6e4),a=(0,f.useAllMenu)(t),[d,o]=(0,c.useState)(null),[h,g]=(0,c.useState)(!1),[m,j]=(0,c.useState)(5),[y,T]=(0,c.useState)([]),[k,R]=(0,c.useState)('all'),B=(0,f.useStore)(e=>e.menu),$=e=>!!B.find(t=>t.id===e)?.hidden,A=a.filter(e=>!e.signOff&&!$(e.id)).length;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Button,{small:!0,label:"Add dish",onPress:()=>o('new')}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:h?'Done':'Bulk price edit',onPress:()=>{g(!h),T([])}}),!e||'owner'!==i&&'manager'!==i?null:(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"New dish creator \u203a",accessibilityLabel:"Open New dish creator",onPress:()=>e('more','dishcreator')})]}),A?(0,P.jsx)(u.default,{accessibilityRole:"button",onPress:()=>e?.('more','recipecards'),children:(0,P.jsx)(x.Banner,{kind:"warn",title:`${A} dish${1===A?'':'es'} awaiting the head chef's sign-off`,children:"Allergens, section and price come from each dish\u2019s recipe card. The head chef signs cards off in the Head Chef app. Tap to open Recipe cards."})}):null,h?(0,P.jsx)(x.Banner,{kind:"warn",title:"Price changes reset sign-off",children:"Each dish\u2019s price is on its recipe card, so a price change sets that card back to \u201cAwaiting sign-off\u201d until the head chef signs it off."}):null,r.LIVE_VENUE_BUILD?(0,P.jsx)(x.Muted,{children:"The saved menu is shown without an automatic lunch or dinner schedule."}):(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Scheduled menus"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:"All day",selected:'all'===k,onPress:()=>R('all')}),(0,P.jsx)(x.Chip,{label:"Lunch 12:00\u201316:30",selected:'lunch'===k,onPress:()=>R('lunch')}),(0,P.jsx)(x.Chip,{label:"Dinner 16:30\u2013close",selected:'dinner'===k,onPress:()=>R('dinner')})]}),(0,P.jsx)(x.Muted,{children:'all'===k?'The full menu shows all day.':`Preview: the ${k} menu switches automatically at the times above (example schedule).`})]}),h?(0,P.jsxs)(x.Card,{highlight:w.colours.gold,children:[(0,P.jsxs)(x.T,{weight:"semibold",children:["Bulk price edit \xb7 ",y.length," selected"]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Change by %"}),(0,P.jsx)(x.Stepper,{value:m,onChange:j,min:-30,max:30,label:"percent"})]}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Select all priced",onPress:()=>T(a.filter(e=>null!=e.price).map(e=>e.id))}),(0,P.jsx)(x.Button,{small:!0,label:`Apply ${m>0?'+':''}${m}%`,disabled:!y.length||0===m,onPress:()=>{y.forEach(e=>{const t=a.find(t=>t.id===e);null!=t?.price&&M().updateMenuItem(e,{price:5*Math.round(t.price*(100+m)/100/5)})}),T([])}})]}),(0,P.jsx)(x.Muted,{children:"Prices round to the nearest 5p."})]}):null,s.sections.map(e=>{const t=a.filter(t=>t.section===e&&('all'===k||'lunch'!==k||!/supper|steak|lobster/i.test(t.name)));return t.length?(0,P.jsxs)(p.default,{style:{gap:6},children:[(0,P.jsx)(S.SectionHead,{title:e}),t.map(e=>(0,P.jsxs)(p.default,{style:[x.styles.card,{opacity:e.hidden?.5:1,padding:10}],children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[h&&null!=e.price?(0,P.jsx)(x.Toggle,{label:`select ${e.name}`,value:y.includes(e.id),onChange:t=>T(t?[...y,e.id]:y.filter(t=>t!==e.id))}):null,(0,P.jsxs)(u.default,{style:{flex:1},onPress:()=>o(e),accessibilityRole:"button",children:[(0,P.jsx)(x.T,{weight:"medium",children:e.name}),(0,P.jsxs)(x.Muted,{children:[null!=e.price?(0,b.gbp)(e.price):e.priceNote??'Board price'," \xb7 ",Object.keys(e.allergens).length," allergens \xb7 ",e.signOff?`signed off by ${e.signOff.by}, ${e.signOff.at}`:'awaiting sign-off']})]})]}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,P.jsx)(x.Chip,{label:e.soldOut?'Sold out (tap: Back on)':'Mark sold out',selected:e.soldOut,onPress:()=>((0,n.setSoldOut)(e.id,!e.soldOut),(0,v.autoPost)(['kitchen','foh'],e.soldOut?`Back on: ${e.name}`:`Sold out: ${e.name}`))}),(0,P.jsx)(x.Chip,{label:$(e.id)?'Hidden':e.hidden?'Off until signed off':'Visible',selected:$(e.id),onPress:()=>M().updateMenuItem(e.id,{hidden:!$(e.id)})})]})]},e.id))]},e):null}),d?(0,P.jsx)(O,{item:'new'===d?null:d,onClose:()=>o(null),go:e}):null]})},_e.EventsPage=function({go:e}){const{rid:t,today:n}=(0,C.useCtx)(6e4),l=(0,f.useEvents)(t).filter(e=>e.restaurantId===t),[i,a]=(0,c.useState)(''),[r,d]=(0,c.useState)(''),[o,u]=(0,c.useState)(''),[h,g]=(0,c.useState)(null),m=(()=>{const e=r.trim(),t=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{4})$/.exec(e);if(t){const e=Number(t[1]),s=Number(t[2]);return e>=1&&e<=31&&s>=1&&s<=12?`${t[3]}-${String(s).padStart(2,'0')}-${String(e).padStart(2,'0')}`:''}return/^\d{4}-\d{2}-\d{2}$/.test(e)?e:''})(),j=i.trim().length>2&&!!m&&!Number.isNaN((0,y.parseYmd)(m).getTime());return(0,P.jsxs)(p.default,{style:{gap:10},children:[l.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:t.date=n?(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t)),style:{alignSelf:'flex-start'}}):null,t.example?null:h===t.id?(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, remove",testID:"event-remove-yes",onPress:()=>{f.useStore.setState(e=>({events:e.events.filter(e=>e.id!==t.id)})),g(null)}}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>g(null)})]}):(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove ${t.title}`,onPress:()=>g(t.id),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Add an event"}),(0,P.jsx)(x.Field,{label:"Title",value:i,onChangeText:a,placeholder:"e.g. Seafood night"}),(0,P.jsx)(x.Field,{label:"Date (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,s.slashDate)(e,r)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10}),(0,P.jsx)(x.Field,{label:"Description",value:o,onChangeText:u,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add event",disabled:!j,onPress:()=>{M().addEvent({restaurantId:t,date:m,title:i.trim(),kind:'event',description:o.trim(),example:!1}),a(''),d(''),u('')}}),(0,P.jsx)(x.Muted,{children:"Events show in the customer app\u2019s What\u2019s on and on its booking dates, and feed the forecast."})]})]})},_e.GiftCardsPage=function(){const{rid:e}=(0,C.useCtx)(6e4),s=(0,f.useStore)((0,g.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[n,i]=(0,c.useState)(25),[a,r]=(0,c.useState)(''),d=s.reduce((e,t)=>e+t.initial,0),o=s.reduce((e,t)=>e+t.balance,0);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{gap:8,children:[(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Sold (all time)"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(d)})]}),(0,P.jsxs)(x.Card,{style:{flex:1},children:[(0,P.jsx)(x.Muted,{children:"Outstanding balance"}),(0,P.jsx)(x.T,{size:20,weight:"bold",children:(0,b.gbp)(o)})]})]}),s.map(e=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.recipientName}),e.legacy?(0,P.jsx)(x.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,P.jsxs)(x.Muted,{children:[e.code," \xb7 ",(0,b.gbp)(e.balance)," of ",(0,b.gbp)(e.initial)," \xb7 ",e.createdAt]})]},e.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Issue a gift card at the till"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,P.jsx)(x.Chip,{label:`\xa3${e}`,selected:n===e,onPress:()=>i(e)},e))}),(0,P.jsx)(x.Field,{label:"Recipient",value:a,onChangeText:r}),t.IS_GREENSIDE?(0,P.jsx)(l.GreensideCashOnly,{}):(0,P.jsx)(x.Banner,{kind:"info",title:"Card payments: not set up yet",children:"Take payment on your till as usual; nothing is charged here."}),(0,P.jsx)(x.Button,{label:`Issue \xa3${n} card`,disabled:a.trim().length<2,onPress:()=>{M().buyGiftCard(e,100*n,a.trim(),'Issued at the till'),r('')}})]})]})},_e.Feedback=function(){const{rid:e}=(0,C.useCtx)(6e4),t=(0,f.useRatings)(e),[s,n]=(0,c.useState)('all'),l=t.filter(e=>'all'===s||e.stars<=3).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),i=t.length?t.reduce((e,t)=>e+t.stars,0)/t.length:0;return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:t.length?`${i.toFixed(1)}\u2605 average \xb7 ${t.length} ratings`:'No ratings recorded yet'}),(0,P.jsxs)(x.Row,{gap:4,children:[(0,P.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),(0,P.jsx)(x.Chip,{label:"3\u2605 or less",selected:'low'===s,onPress:()=>n('low')})]})]}),t.some(e=>e.stars<=2)?(0,P.jsx)(x.Banner,{kind:"danger",title:"Low-rating alert",children:`${t.filter(e=>e.stars<=2).length} rating(s) at 2\u2605 or below. Reply within 24 hours.`}):null,l.map(e=>(0,P.jsxs)(x.Card,{highlight:e.stars<=2?w.colours.red:void 0,children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",children:e.customerName}),(0,P.jsxs)(x.T,{colour:w.colours.gold,children:['\u2605'.repeat(e.stars),'\u2606'.repeat(5-e.stars)]})]}),(0,P.jsx)(x.T,{size:14,children:e.comment||'(no comment)'}),(0,P.jsx)(x.Muted,{children:e.context??''})]},e.id)),(0,P.jsx)(x.Banner,{kind:"info",title:"No review gating",children:"After private feedback, every customer (whatever their rating) is shown the link to leave a public Google review. Low ratings alert you here so you can put it right."}),(0,P.jsx)(x.Muted,{children:"Private feedback from the app after each visit. Reply drafts are under Reviews."})]})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return S.DemoTag}}),_e.StampSettings=function(){return r.LIVE_VENUE_BUILD||(0,d.staffServer)()?(0,P.jsx)(o.LoyaltySettingsPanel,{}):(0,P.jsx)(A,{})},_e.Offers=function({go:e}){return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,d.staffServer)()?(0,P.jsx)(x.Banner,{kind:"info",title:"Stamp card offers are in Settings \u203a Advanced \u203a Loyalty",children:"Offers there are saved on the server and shown on every guest\u2019s stamp card. Specials below stay as they were."}):null,(0,P.jsx)($,{go:e})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),o=_r(_d[8]),c=_r(_d[9]),u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),g=_r(_d[13]),x=_r(_d[14]),f=_r(_d[15]),m=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),y=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),T=_r(_d[24]),k=_r(_d[25]),P=_r(_d[26]);const R=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],B=[1,2,3,4,5,6,0],M=()=>f.useStore.getState();function O({item:e,onClose:t,go:s}){const{rid:n,r:l}=(0,C.useCtx)(6e4),[i,a]=(0,c.useState)(e?.name??''),[r,d]=(0,c.useState)(e?.description??''),[o,u]=(0,c.useState)(null!=e?.price?(e.price/100).toFixed(2):''),[h,p]=(0,c.useState)(e?.section??l.sections[0]??'Mains'),[g,f]=(0,c.useState)(e?.prepMins??0),m=''===o.trim()?null:Math.round(100*Number(o)),b=i.trim().length>1&&(null==m||Number.isFinite(m)&&m>=0),y=e?.allergens??{},w=!!e&&(i.trim()!==e.name||m!==e.price||h!==e.section);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:t,title:e?`Edit ${e.name}`:'Add a dish',children:[(0,P.jsx)(x.Field,{label:"Name",value:i,onChangeText:a}),(0,P.jsx)(x.Field,{label:"Description",value:r,onChangeText:d,multiline:!0}),(0,P.jsx)(x.Field,{label:"Price \xa3 (blank = board price)",value:o,onChangeText:u,keyboardType:"decimal-pad"}),(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:l.sections.map(e=>(0,P.jsx)(x.Chip,{label:e,selected:h===e,onPress:()=>p(e)},e))}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Prep time (min)"}),(0,P.jsx)(x.Stepper,{value:g,onChange:f,min:1,max:60,label:"prep minutes"})]}),(0,P.jsx)(x.T,{weight:"semibold",children:"14 allergens (from the recipe card)"}),(0,P.jsxs)(x.Row,{wrap:!0,gap:6,children:[j.ALLERGENS.filter(e=>y[e.id]).map(e=>(0,P.jsx)(x.Badge,{label:'may'===y[e.id]?`May contain ${e.short.toLowerCase()}`:e.short,kind:'may'===y[e.id]?'amber':'red'},e.id)),e&&!Object.keys(y).length?(0,P.jsx)(x.Muted,{children:e.signOff?'None of the 14 declared.':'Allergens not confirmed.'}):null]}),(0,P.jsx)(x.Muted,{children:e?e.signOff?`Signed off by ${e.signOff.by} on ${e.signOff.at}.`:'Awaiting sign-off by the head chef.':'Saving adds the dish and its recipe card. Add the ingredients and allergens on the card; the dish stays off the menu until the head chef signs it off.'}),s?(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Edit allergens, ingredients and photo on the recipe card \u203a",onPress:()=>{t(),s('more','recipecards')}}):null,w&&e?.signOff?(0,P.jsx)(x.Banner,{kind:"warn",title:"Sign-off resets",children:"Name, price and section live on the recipe card. Changing them sets the card back to \u201cAwaiting sign-off\u201d until the head chef signs it off again."}):null,(0,P.jsx)(x.Button,{label:e?'Save dish':'Add dish',disabled:!b,onPress:()=>{e?M().updateMenuItem(e.id,{name:i.trim(),description:r.trim(),price:m,section:h,prepMins:g}):M().addMenuItem({restaurantId:n,section:h,name:i.trim(),description:r.trim(),price:m,dietary:[],allergens:{},prepMins:g,soldOut:!1,signOff:null}),t()}})]})}function $({go:e}){const{now:t}=(0,C.useCtx)(6e4),s=(0,m.useOwner)(e=>e.offers),[n,l]=(0,c.useState)(''),[a,r]=(0,c.useState)(''),[d,o]=(0,c.useState)('special'),[u,h]=(0,c.useState)(null);return(0,P.jsxs)(p.default,{style:{gap:10},children:[s.map(t=>(0,P.jsxs)(x.Card,{children:[(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{weight:"semibold",style:{flex:1},children:t.title}),(0,P.jsx)(x.Badge,{kind:'special'===t.kind?'gold':'blue',label:'special'===t.kind?'Special':'Offer'})]}),(0,P.jsxs)(x.Muted,{children:[t.body,t.until?` \xb7 until ${(0,y.niceDate)((0,y.parseYmd)(t.until))}`:'']}),t.pushedAt?(0,P.jsx)(x.Badge,{kind:"amber",label:`Previewed ${t.pushedAt} (push is off: nothing is sent)`}):null,(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Toggle,{label:"Live in app",value:t.live,onChange:e=>m.useOwner.getState().updateOffer(t.id,{live:e})}),(0,P.jsx)(x.Muted,{children:t.live?'Live in app':'Hidden'}),(0,P.jsx)(p.default,{style:{flex:1}}),(0,P.jsx)(x.Button,{small:!0,kind:"secondary",label:"Push to customers",onPress:()=>h(t.id)})]}),(0,P.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.specialDraft)(t)),style:{alignSelf:'flex-start'}})]},t.id)),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"New special or offer"}),(0,P.jsxs)(x.Row,{gap:6,children:[(0,P.jsx)(x.Chip,{label:"Special",selected:'special'===d,onPress:()=>o('special')}),(0,P.jsx)(x.Chip,{label:"Offer",selected:'offer'===d,onPress:()=>o('offer')})]}),(0,P.jsx)(x.Field,{label:"Title",value:n,onChangeText:l}),(0,P.jsx)(x.Field,{label:"Details",value:a,onChangeText:r,multiline:!0}),(0,P.jsx)(x.Button,{label:"Add",disabled:n.trim().length<3,onPress:()=>{m.useOwner.getState().addOffer({title:n.trim(),body:a.trim(),kind:d,live:!0}),l(''),r('')}})]}),u?(()=>{const e=s.find(e=>e.id===u);return(0,P.jsxs)(x.Sheet,{visible:!0,onClose:()=>h(null),title:"Push notification composer",children:[(0,P.jsx)(x.Banner,{kind:"demo",title:"Delivery is not connected",children:"This previews the push. No notification goes to anyone."}),(0,P.jsxs)(p.default,{style:{backgroundColor:(0,i.soutersSurface)('#1F1F1F'),borderRadius:14,padding:12,gap:2},children:[(0,P.jsx)(x.Muted,{children:"CoverCharge \xb7 now"}),(0,P.jsx)(x.T,{weight:"semibold",children:e.title}),(0,P.jsx)(x.T,{size:14,children:e.body})]}),(0,P.jsxs)(x.Muted,{children:["Audience: customers who opted in to ",(0,k.venueInfo)().name," offers. No audience count is available."]}),(0,P.jsx)(x.Button,{label:"Preview (push is off: nothing is sent)",onPress:()=>{m.useOwner.getState().updateOffer(e.id,{pushedAt:`${(0,y.niceDate)(t)} ${t.toTimeString().slice(0,5)}`}),h(null)}})]})})():null]})}function A(){const{r:e}=(0,C.useCtx)(6e4),t=e.settings,[s,n]=(0,c.useState)(t.stampReward);return(0,P.jsxs)(p.default,{style:{gap:10},children:[(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.T,{weight:"semibold",children:"Stamp card"}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Stamps for a reward"}),(0,P.jsx)(x.Stepper,{value:t.stampTarget,min:3,max:15,onChange:t=>M().updateSettings(e.id,{stampTarget:t}),label:"stamps"})]}),(0,P.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,P.jsx)(x.T,{children:"Minimum spend"}),(0,P.jsx)(x.Stepper,{value:t.stampMinSpend/100,min:0,max:50,onChange:t=>M().updateSettings(e.id,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,P.jsxs)(x.Muted,{children:[(0,b.gbp)(t.stampMinSpend)," minimum spend per stamp."]}),(0,P.jsx)(x.Field,{label:"Reward",value:s,onChangeText:n}),(0,P.jsx)(x.Button,{small:!0,label:"Save reward",onPress:()=>M().updateSettings(e.id,{stampReward:s.trim()||t.stampReward})})]}),(0,P.jsxs)(x.Card,{children:[(0,P.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:t.stampTarget},(e,t)=>(0,P.jsx)(p.default,{style:{width:28,height:28,borderRadius:14,borderWidth:2,borderColor:w.colours.gold,backgroundColor:t<3?w.colours.gold:'transparent'}},t))}),(0,P.jsxs)(x.Muted,{children:["Preview: 3 of ",t.stampTarget," stamps \xb7 reward: ",t.stampReward]})]})]})}},1499,[5,1063,979,1418,828,827,837,1271,1443,34,402,410,102,879,794,874,891,861,867,858,821,1201,1088,1180,1447,1230,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1500,[860,34,102,1181,794,874,861,869,858,821,1201,1088,25]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BrandingSettings=function(){const{rid:e,r:t}=(0,h.useCtx)(6e4),p=(0,l.useBrand)(e),x=(0,c.useOwner)(e=>e.setBranding),[j,f]=(0,r.useState)(''),y=(0,c.useOwner)(o=>o.branding[e]?.recent)??[],[w,C]=(0,r.useState)(p.accent);(0,r.useEffect)(()=>{C(p.accent)},[p.accent]);const v=(0,r.useMemo)(()=>(0,a.checkAccent)(w,u.colours.bg,u.colours.onGold,u.colours.text),[w]);return(0,b.jsxs)(n.default,{style:{gap:10},children:[(0,b.jsx)(d.Muted,{children:"Your logo, name and accent colour lead every CoverCharge app: Managers, Staff, Display, Head Chef and the customer app. A small \u201cpowered by CoverCharge\u201d stays at the top left."}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Customer header preview"}),(0,b.jsxs)(n.default,{testID:"branding-preview",style:{backgroundColor:u.colours.bg,borderRadius:12,borderWidth:1,borderColor:u.colours.border,padding:12,gap:4},children:[(0,b.jsx)(l.PoweredBy,{}),(0,b.jsxs)(d.Row,{gap:10,children:[(0,b.jsx)(l.RestaurantLogo,{rid:e,size:52}),(0,b.jsxs)(n.default,{style:{flex:1},children:[(0,b.jsx)(d.T,{weight:"semibold",size:18,children:t.name}),(0,b.jsx)(d.T,{size:12,colour:v.accentText,children:t.location})]})]}),(0,b.jsx)(n.default,{testID:"branding-preview-button",style:{marginTop:8,backgroundColor:w,borderRadius:10,paddingVertical:10,alignItems:'center'},children:(0,b.jsx)(d.T,{weight:"semibold",colour:v.onAccent,children:"Book a table"})})]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Logo"}),(0,b.jsxs)(d.Muted,{children:[p.custom?'Your uploaded logo.':'anchorage'===e?'Built in: The Anchorage logo in black and gold.':l.BUILTIN_LOGOS[e]?`Built in: ${t.name} logo.`:'Built in: placeholder initials for this demo venue.'," Square images work best."]}),(0,b.jsxs)(d.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(d.Button,{label:"Upload a logo",onPress:async()=>{const r=await o.launchImageLibraryAsync({mediaTypes:['images'],allowsEditing:!0,aspect:[1,1],quality:.7,base64:!0});if(r.canceled||!r.assets?.[0])return;const t=r.assets[0],n=t.base64?`data:${t.mimeType??'image/png'};base64,${t.base64}`:t.uri;x(e,{logoUri:n}),f('Logo updated in all apps on this device.')},testID:"branding-upload"}),p.custom?(0,b.jsx)(d.Button,{kind:"secondary",label:"Use the built-in logo",onPress:()=>{x(e,{logoUri:void 0}),f('Back to the built-in logo.')}}):null]})]}),(0,b.jsxs)(d.Card,{children:[(0,b.jsx)(d.T,{weight:"semibold",children:"Accent colour"}),(0,b.jsx)(d.Muted,{children:"Any colour you like for your own brand. The preview above changes as you drag."}),(0,b.jsx)(s.ColourPicker,{value:w,onChange:C,onCommit:o=>{o===p.accent&&y[0]===o||(x(e,{accent:o,recent:(0,a.pushRecent)(y,o)}),f(`Accent set to ${o}.`))},quick:l.ACCENTS,recent:y}),v.tips.length?(0,b.jsx)(n.default,{testID:"accent-tip",style:{borderWidth:1,borderColor:u.colours.amber,backgroundColor:u.colours.amberBg,borderRadius:10,padding:10,gap:4},children:v.tips.map(e=>(0,b.jsx)(d.T,{size:13,colour:u.colours.amber,children:e},e))}):null,(0,b.jsx)(d.Muted,{children:"Used for the restaurant line in headers, the logo ring and main buttons. Text on it is picked to stay readable."})]}),j?(0,b.jsx)(d.Banner,{kind:"success",title:"Saved",children:j}):null,(0,b.jsx)(d.Button,{kind:"ghost",label:"Restore default branding",onPress:()=>{x(e,null),f('Default branding restored.')}}),(0,b.jsx)(d.Muted,{children:"Saved the same way as your logo: on this device, shared by all the apps on it. Nothing is uploaded."})]})};var e,o=(function(e){if(e&&e.__esModule)return e;var o={};return e&&Object.keys(e).forEach(function(r){if('default'!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(o,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),o.default=e,o})(_r(_d[0])),r=_r(_d[1]),t=_r(_d[2]),n=(e=t)&&e.__esModule?e:{default:e},s=_r(_d[3]),a=_r(_d[4]),l=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),b=_r(_d[10])},1501,[1076,34,102,1502,829,873,794,891,821,1088,25]); +__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.ColourPicker=function({value:e,onChange:p,onCommit:v,quick:y,recent:w}){const[R,C]=(0,t.useState)(()=>(0,c.hexToHsv)(e)),[H,T]=(0,t.useState)(e),[S,M]=(0,t.useState)(!1),F=(0,t.useRef)(e);(0,t.useEffect)(()=>{(0,c.normaliseHex)(e)!==(0,c.normaliseHex)(F.current)&&(F.current=e,C((0,c.hexToHsv)(e)),T(e))},[e]);const k=e=>{C(e);const o=(0,c.hsvToHex)(e);F.current=o,T(o),M(!1),p(o)},D=(0,t.useMemo)(()=>(0,c.hsvToHex)({h:R.h,s:R.s,v:1}),[R.h,R.s]),E=(0,t.useMemo)(()=>f.map(e=>(0,c.hsvToHex)({h:e,s:1,v:1})),[]),I=e=>{const o=(0,c.normaliseHex)(e);o&&(F.current=o,C((0,c.hexToHsv)(o)),T(o),M(!1),p(o),v(o))},z=(o,t,n)=>(0,x.jsx)(s.default,{testID:`accent-${n}-${t}`,accessibilityRole:"button",accessibilityLabel:`Accent ${o}`,onPress:()=>I(o),hitSlop:4,style:{width:40,height:40,borderRadius:20,backgroundColor:o,borderWidth:3,borderColor:(0,c.normaliseHex)(e)===(0,c.normaliseHex)(o)?u.colours.text:u.colours.border}},n+o+t);return(0,x.jsxs)(n.default,{testID:"colour-picker",style:{gap:10},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Drag across for the colour, up and down for how strong it is"}),(0,x.jsxs)(b,{testID:"picker-area",label:"Colour and strength",height:170,onMove:(e,o)=>k({h:360*e,s:1-o,v:R.v}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 100",children:[(0,x.jsxs)(l.Defs,{children:[(0,x.jsx)(l.LinearGradient,{id:"cpHue",x1:"0",y1:"0",x2:"1",y2:"0",children:E.map((e,o)=>(0,x.jsx)(l.Stop,{offset:o/(E.length-1),stopColor:e},o))}),(0,x.jsxs)(l.LinearGradient,{id:"cpSat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#FFFFFF",stopOpacity:0}),(0,x.jsx)(l.Stop,{offset:1,stopColor:"#FFFFFF",stopOpacity:1})]})]}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpHue)"}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"100",fill:"url(#cpSat)"})]}),(0,x.jsx)(j,{x:R.h/360*100+"%",y:100*(1-R.s)+"%",colour:D})]}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Brightness"}),(0,x.jsxs)(b,{testID:"picker-brightness",label:"Brightness",height:36,onMove:e=>k({...R,v:Math.max(.04,e)}),onEnd:()=>v(F.current),children:[(0,x.jsxs)(i.default,{width:"100%",height:"100%",preserveAspectRatio:"none",viewBox:"0 0 100 10",children:[(0,x.jsx)(l.Defs,{children:(0,x.jsxs)(l.LinearGradient,{id:"cpVal",x1:"0",y1:"0",x2:"1",y2:"0",children:[(0,x.jsx)(l.Stop,{offset:0,stopColor:"#000000"}),(0,x.jsx)(l.Stop,{offset:1,stopColor:D})]})}),(0,x.jsx)(l.Rect,{x:"0",y:"0",width:"100",height:"10",fill:"url(#cpVal)"})]}),(0,x.jsx)(j,{x:100*R.v+"%",y:"0%",colour:(0,c.hsvToHex)(R),round:!1})]}),(0,x.jsxs)(h.Row,{gap:10,style:{alignItems:'center'},children:[(0,x.jsx)(n.default,{testID:"picker-swatch",style:{width:46,height:46,borderRadius:10,backgroundColor:(0,c.normaliseHex)(H)??e,borderWidth:1,borderColor:u.colours.border}}),(0,x.jsxs)(n.default,{style:{flex:1,gap:2},children:[(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Hex code"}),(0,x.jsx)(o.TextInput,{testID:"picker-hex",value:H,autoCapitalize:"characters",autoCorrect:!1,maxLength:7,placeholder:"#CFA45F",placeholderTextColor:u.colours.muted,accessibilityLabel:"Hex code",onChangeText:e=>{T(e);const o=(0,c.normaliseHex)(e);M(!o&&e.replace('#','').length>=6),o&&6===e.replace('#','').length&&(F.current=o,C((0,c.hexToHsv)(o)),p(o))},onBlur:()=>{const e=(0,c.normaliseHex)(H);e?I(e):(T(F.current),M(!1))},onSubmitEditing:()=>{const e=(0,c.normaliseHex)(H);e?I(e):M(!0)},style:{minHeight:46,borderRadius:10,borderWidth:1,borderColor:S?u.colours.amber:u.colours.accentBorder,backgroundColor:u.colours.surface2,color:u.colours.text,paddingHorizontal:12,fontSize:16}})]})]}),S?(0,x.jsx)(h.T,{size:13,colour:u.colours.amber,children:"Use six letters or numbers after #, like #CFA45F."}):null,(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Quick picks"}),(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:y.map((e,o)=>z(e,o,'quick'))}),(0,x.jsx)(h.T,{size:13,colour:u.colours.muted,children:"Recent colours"}),w.length?(0,x.jsx)(h.Row,{wrap:!0,gap:10,children:w.map((e,o)=>z(e,o,'recent'))}):(0,x.jsx)(h.Muted,{children:"Colours you choose show here."})]})};var o=r(d[0]),t=r(d[1]);r(d[2]);var s=e(r(d[3])),n=e(r(d[4])),l=r(d[5]),i=e(l),c=r(d[6]),u=r(d[7]),h=r(d[8]),x=r(d[9]);const p={touchAction:'none',cursor:'crosshair',userSelect:'none'},f=[0,30,60,90,120,150,180,210,240,270,300,330,360];function b({height:e,onMove:o,onEnd:s,children:l,testID:i,label:c}){const h=(0,t.useRef)({w:1,h:e}),f=e=>{const{locationX:t,locationY:s}=e.nativeEvent;o(Math.min(1,Math.max(0,t/h.current.w)),Math.min(1,Math.max(0,s/h.current.h)))};return(0,x.jsx)(n.default,{testID:i,accessibilityLabel:c,onLayout:e=>{h.current={w:Math.max(1,e.nativeEvent.layout.width),h:Math.max(1,e.nativeEvent.layout.height)}},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:f,onResponderMove:f,onResponderRelease:s,onResponderTerminate:s,style:[{height:e,borderRadius:10,overflow:'hidden',borderWidth:1,borderColor:u.colours.border},p],children:(0,x.jsx)(n.default,{pointerEvents:"none",style:{flex:1},children:l})})}const j=({x:e,y:o,colour:t,round:s=!0})=>(0,x.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:e,top:o,width:26,height:s?26:'100%',marginLeft:-13,marginTop:s?-13:0,borderRadius:s?13:6,borderWidth:3,borderColor:u.colours.text,backgroundColor:t,shadowColor:'#000',shadowOpacity:.6,shadowRadius:3}})},1502,[827,34,236,402,102,797,829,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.RecipeCardsPage=function(){const{rid:c,role:u,me:f}=(0,o.useCtx)(),_=(0,o.useSignedIn)(),l='owner'===u?'owner':'manager'===u?'manager':'staff';return(0,s.jsx)(t.RecipeCards,{rid:c,actor:(0,n.cardActorFor)(f,l,_),mode:'staff'===l?'read':'edit'})},r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4])},1503,[34,1176,863,1088,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CashUpPage=function(){const{rid:l,role:u,me:p,meId:f,today:y}=(0,c.useCtx)(6e4),h='owner'===u||'manager'===u,x=(0,s.useSync)(n=>'staff'===n.kind&&!!n.venueId&&'off'!==n.mode&&'local'!==n.mode),v=(0,s.useSync)(n=>n.perms);return x&&!v.includes('*')&&!v.includes('takings.view')?(0,o.jsx)(n.CashUpScreen,{rid:l,today:(0,t.tradingDay)(),canEdit:!0,closer:!0,who:{id:f??'me',name:p.replace(' (example)','')}}):(0,o.jsx)(n.CashUpScreen,{rid:l,today:y,canEdit:h,backdate:h,who:{id:f??'me',name:p.replace(' (example)','')}})},r(d[0]);var n=r(d[1]),c=r(d[2]),s=r(d[3]),t=r(d[4]),o=r(d[5])},1504,[34,1062,1088,987,1000,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1505,[34,1394,1088,25]); +__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.TrendLine=y,_e.SpendPerHeadPage=function(){const{rid:e,today:s}=(0,c.useCtx)(6e4),a=(0,r.useBookings)(e),n=(0,o.useCashUp)(e=>e.cashUps),[b,j]=(0,t.useState)('day'),k=(0,d.hasAnyTakings)(n,e),w=(0,d.dayRows)(n,a,e,s,14),f=(0,d.weekRows)(n,a,e,s,8),v=(0,d.averageSph)(w),$=(e,t,s,a,n)=>(0,u.jsxs)(l.default,{testID:`sph-row-${e}`,style:{alignItems:'center',paddingVertical:8,borderTopWidth:1,borderTopColor:h.colours.hairline,gap:2},accessible:!0,accessibilityLabel:`${t}: ${'No takings entered'===a?'no takings entered':`spend per head ${a}`}, ${s}${n?`, ${n}`:''}`,children:[(0,u.jsx)(i.T,{center:!0,children:t}),(0,u.jsx)(i.T,{center:!0,colour:h.colours.muted,children:s}),(0,u.jsx)(i.T,{center:!0,weight:"semibold",colour:'No takings entered'===a?h.colours.muted:h.colours.goldLight,size:'No takings entered'===a?13:16,children:a}),n?(0,u.jsx)(i.Muted,{center:!0,children:n}):null]},e);return(0,u.jsxs)(l.default,{style:{gap:12},testID:"sph-screen",children:[(0,u.jsx)(i.Muted,{children:"Tip: spend per head is Gross takings \xf7 Covers. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out."}),(0,u.jsxs)(i.Card,{highlight:h.colours.gold,children:[(0,u.jsx)(i.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{letterSpacing:1.5},children:"LAST 14 DAYS"}),null==v?(0,u.jsx)(i.T,{size:22,weight:"semibold",colour:h.colours.muted,testID:"sph-none",children:"No takings entered"}):(0,u.jsxs)(i.T,{size:34,weight:"bold",colour:h.colours.goldLight,testID:"sph-avg",children:[p(v)," ",(0,u.jsx)(i.T,{size:16,colour:h.colours.muted,children:"per head"})]}),(0,u.jsx)(i.Muted,{children:k?'Only days with gross takings entered are counted.':'Nothing has been entered yet. Spend per head appears once a cash up has Gross takings.'})]}),(0,u.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(i.Chip,{testID:"sph-day",label:"By day",selected:'day'===b,onPress:()=>j('day')}),(0,u.jsx)(i.Chip,{testID:"sph-week",label:"By week",selected:'week'===b,onPress:()=>j('week')})]}),'day'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by day"}),(0,u.jsx)(y,{testID:"sph-trend-day",label:"Spend per head trend by day",points:w.map(e=>({label:x(e.date),value:e.sph}))}),[...w].reverse().map(e=>$(e.date,x(e.date),`${e.covers} Covers`,null==e.sph?'No takings entered':p(e.sph),null!=e.foodPh||null!=e.drinkPh?`food ${p(e.foodPh)}, drink ${p(e.drinkPh)} per head`:void 0))]}):null,'week'===b?(0,u.jsxs)(i.Card,{children:[(0,u.jsx)(i.T,{weight:"semibold",children:"Spend per head by week (Mon\u2013Sun)"}),(0,u.jsx)(y,{testID:"sph-trend-week",label:"Spend per head trend by week",points:f.map(e=>({label:`w/c ${x(e.weekStart).split(' ').slice(1).join(' ')}`,value:e.sph}))}),[...f].reverse().map(e=>$(e.weekStart,`w/c ${x(e.weekStart)}`,e.days?`${e.covers} Covers \xb7 ${e.days} day${1===e.days?'':'s'}`:'\u2014',null==e.sph?'No takings entered':p(e.sph)))]}):null,(0,u.jsx)(i.Muted,{children:"Order-at-table totals will be added here when order at table is switched on. Nothing on this page is estimated."})]})};var t=_r(_d[0]),s=e(t),l=e(_r(_d[1])),a=_r(_d[2]),n=e(a),i=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,x=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function y({points:e,testID:r,label:o}){const[d,c]=(0,t.useState)(320),[x,y]=(0,t.useState)(e.length);(0,t.useEffect)(()=>y(e.length),[e.length,r]);const b=d<340?2:3,j=Math.min(e.length,Math.max(b,x)),k=Math.max(0,j-b),w=e.slice(k,j),f=Math.max(140,d-68),v=e.map(e=>e.value).filter(e=>null!=e),$=Math.max(5,5*Math.ceil(Math.max(0,...v)/5)),T=e=>38+e*(f-76)/Math.max(1,w.length-1),S=e=>140-e/$*106,L=[];let D=[];w.forEach((e,t)=>{null==e.value?(D.length&&L.push(D),D=[]):D.push({i:t,v:e.value})}),D.length&&L.push(D);const M=e.filter(e=>null!=e.value).map(e=>`${e.label} ${p(e.value)}`).join(', ');return(0,u.jsxs)(l.default,{testID:r,onLayout:e=>c(e.nativeEvent.layout.width),style:{gap:8},children:[(0,u.jsxs)(l.default,{accessible:!0,accessibilityLabel:`${o}. ${M||'No takings entered'}`,style:{flexDirection:'row',minWidth:0},children:[(0,u.jsx)(n.default,{width:64,height:170,children:[0,1,2,3,4].map(e=>(0,u.jsx)(a.Text,{x:60,y:S($*e/4)+4,textAnchor:"end",fontSize:11,fill:h.colours.muted,children:p($*e/4)},e))}),(0,u.jsxs)(n.default,{width:f,height:170,children:[[0,1,2,3,4].map(e=>(0,u.jsx)(a.Line,{x1:0,x2:f,y1:S($*e/4),y2:S($*e/4),stroke:h.colours.border,strokeWidth:1},e)),L.map((e,t)=>(0,u.jsx)(a.Polyline,{points:e.map(e=>`${T(e.i)},${S(e.v)}`).join(' '),fill:"none",stroke:h.colours.gold,strokeWidth:2.5},t)),w.map((e,t)=>(0,u.jsx)(s.default.Fragment,{children:null==e.value?(0,u.jsx)(a.Circle,{cx:T(t),cy:140,r:2,fill:"#444"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(a.Circle,{cx:T(t),cy:S(e.value),r:4,fill:h.colours.goldLight}),(0,u.jsx)(a.Text,{x:T(t),y:S(e.value)-10,textAnchor:"middle",fontSize:12,fontWeight:"bold",fill:h.colours.goldLight,children:p(e.value)})]})},k+t))]})]}),(0,u.jsx)(l.default,{style:{flexDirection:'row',gap:12},children:w.map((e,t)=>(0,u.jsxs)(l.default,{style:{flex:1,minWidth:0},accessible:!0,accessibilityLabel:`${e.label}: ${null==e.value?'No takings entered':p(e.value)}`,children:[(0,u.jsx)(i.T,{center:!0,size:12,colour:h.colours.muted,children:e.label}),(0,u.jsx)(i.T,{center:!0,size:14,weight:"semibold",colour:null==e.value?h.colours.muted:h.colours.goldLight,children:null==e.value?'No takings entered':p(e.value)})]},k+t))}),(0,u.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Earlier",accessibilityLabel:"Earlier spend per head chart points",disabled:0===k,onPress:()=>y(Math.max(b,j-b))}),(0,u.jsx)(i.Button,{small:!0,kind:"secondary",label:"Later",accessibilityLabel:"Later spend per head chart points",disabled:j>=e.length,onPress:()=>y(Math.min(e.length,j+b))})]})]})}},1506,[34,102,797,794,874,1039,1507,821,1088,25]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COUNTED",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"serviceOfBooking",{enumerable:!0,get:function(){return o}}),e.coversOn=d,e.dayRows=i,e.weekRows=function(n,t,s,o,d){const u=(0,r.weekStartOf)(o);return Array.from({length:d},(l,f)=>{const h=(0,r.addDaysYmd)(u,7*(f-d+1)),m=i(n,t,s,(0,r.addDaysYmd)(h,6),7).filter(r=>r.date<=o&&null!=r.gross),p=m.length?Math.round(100*m.reduce((r,n)=>r+n.gross,0))/100:null,v=m.reduce((r,n)=>r+n.covers,0);return{weekStart:h,gross:p,covers:v,days:m.length,sph:c(p,v)}})},e.serviceRows=function(n,t,s,o,i,l=1020){const f=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r])),h=[];for(let n=0;nnull!=r.gross&&r.covers>0);return n.length?c(n.reduce((r,n)=>r+n.gross,0),n.reduce((r,n)=>r+n.covers,0)):null},Object.defineProperty(e,"hasAnyTakings",{enumerable:!0,get:function(){return l}});var r=_r(_d[0]);const n=['seated','finished'],t=r=>n.includes(r.status),s=r=>{const[n,t]=r.split(':').map(Number);return 60*n+(t||0)},o=(r,n)=>s(r.time)r.restaurantId===n&&r.date===s&&t(r)&&(!d||o(r,u)===d)).reduce((r,n)=>r+(n.partySize||0),0)}const u=r=>'number'==typeof r&&Number.isFinite(r)?r:null,c=(r,n)=>null==r||n<=0?null:Math.round(r/n*100)/100;function i(n,t,s,o,i){const l=new Map(n.filter(r=>r.rid===s&&r.confirmedAt).map(r=>[r.date,r]));return Array.from({length:i},(n,f)=>{const h=(0,r.addDaysYmd)(o,f-i+1),m=l.get(h)?.vals??{},p=(0,r.grossOf)(m),v=d(t,s,h),y=u(m.food),b=u(m.drink);return{date:h,gross:p,covers:v,sph:c(p,v),food:y,drink:b,foodPh:c(y,v),drinkPh:c(b,v)}})}const l=(n,t)=>n.some(n=>n.rid===t&&n.confirmedAt&&null!=(0,r.grossOf)(n.vals))},1507,[13]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WebsiteVouchersPage=function(){return(0,n.jsx)(s.default,{testID:"managers-vouchers",style:{minHeight:640,flex:1},children:(0,n.jsx)(u.VoucherList,{mode:"managers"})})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},u=r(d[2]),n=r(d[3])},1508,[34,102,1354,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.MyAvatar=function(){const{meId:s,me:c}=(0,n.useCtx)(6e4);return(0,u.jsx)(t.AvatarMaker,{meId:s,me:c})},r(d[0]);var t=r(d[1]),n=r(d[2]),u=r(d[3])},1509,[34,793,1088,25]); +__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.GiftVouchers=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(q,{})},_e.Merch=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(W,{}):(0,_.jsx)(Y,{})},_e.TablesQr=function({go:e}={}){const{rid:t,r:s,now:n,me:r}=(0,N.useCtx)(1e4);return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(i.StaffTableOrders,{rid:t,me:r}),(0,_.jsx)(v.Muted,{children:"QR codes, tables and hours: Settings \u203a Advanced \u203a Order at the table."})]}):(0,M.orderAtTableOn)(s)?(0,_.jsx)(K,{rid:t,now:n,me:r}):(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Order at table is off",children:"In-house orders go through your till. Switch it on in Settings \u203a Order at table if this venue takes orders at the table."}),e?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Open Order at table settings",onPress:()=>e('more','orderattable')}):null]})},_e.TakeawaySettings=function({go:e}){const{rid:t,r:s,now:n}=(0,N.useCtx)(3e4),a=(0,S.useOrders)(t),r=s.settings,i=(0,P.takeawaySlots)(s,a,n).slice(0,10),l=e=>V().updateSettings(t,e),o=a.filter(e=>'takeaway'===e.type&&(0,I.LIVE)(e));return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:r.takeawayPaused?A.colours.red:A.colours.ok,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:r.takeawayPaused?'Takeaway paused':'Taking takeaway orders'}),(0,_.jsx)(v.Toggle,{label:"Takeaway on",value:!r.takeawayPaused,onChange:e=>l({takeawayPaused:!e})})]}),(0,_.jsx)(v.Muted,{children:"Direct ordering, no delivery-app commission."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Collection slots & capacity"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Slot length (min)"}),(0,_.jsx)(v.Stepper,{value:r.slotMinutes,min:5,max:30,onChange:e=>l({slotMinutes:e}),label:"slot minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Orders per slot"}),(0,_.jsx)(v.Stepper,{value:r.slotCap,min:1,max:20,onChange:e=>l({slotCap:e}),label:"orders per slot"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Earliest pickup (min ahead)"}),(0,_.jsx)(v.Stepper,{value:r.leadMins,min:5,max:60,onChange:e=>l({leadMins:e}),label:"lead minutes"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Readiness buffer (min)"}),(0,_.jsx)(v.Stepper,{value:r.bufferMins,min:0,max:20,onChange:e=>l({bufferMins:e}),label:"buffer minutes"})]}),(0,_.jsx)(v.Muted,{children:"Readiness alerts (start cooking \u2192 bag it \u2192 ready) are for takeaway only, timed from the pickup slot. Dine-in starts when the table is seated and has ordered."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Next slots"}),i.map(e=>(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{size:14,children:e.label}),(0,_.jsx)(w.default,{style:{flex:1,height:8,marginHorizontal:8,backgroundColor:A.colours.border,borderRadius:4},children:(0,_.jsx)(w.default,{style:{width:e.taken/e.cap*100+"%",height:8,backgroundColor:e.full?A.colours.red:A.colours.gold,borderRadius:4}})}),(0,_.jsxs)(v.Muted,{children:[e.taken,"/",e.cap]})]},e.label))]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:["Live queue: ",o.length]}),(0,_.jsx)(v.Button,{small:!0,label:"Open orders",onPress:()=>e('orders')})]}),o.map(e=>(0,_.jsxs)(v.Muted,{children:[e.slotTime?(0,B.hm)(new Date(e.slotTime)):'\u2013'," \xb7 ",e.ref," ",e.customerName," \xb7 ",(0,I.statusLabel)(e)]},e.id))]})]})},_e.BookingSettings=function({go:e}){const{rid:n,r:a}=(0,N.useCtx)(6e4),r=a.settings,i=(0,T.useOwner)(e=>e.reminders),l=e=>V().updateSettings(n,e),o=e=>T.useOwner.getState().setOwner({reminders:{...i,...e}});return(0,_.jsxs)(w.default,{style:{gap:10},children:[t.IS_GREENSIDE?(0,_.jsx)(s.GreensideCashOnly,{}):(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Deposits"}),(0,_.jsxs)(v.Muted,{children:[(()=>{const e=(0,c.depositOf)(r);return e.on&&e.perPersonPence>0?`On: ${(0,R.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more. Children never pay.`:'Off.'})()," Deposits are paid through website bookings: website bookings show Deposit paid on website bookings by themselves; staff tick phone and walk-in deposits paid."]}),(0,_.jsx)(v.Muted,{children:"Tip: change the amount, party size, refunds and the words guests see in Settings \u203a Advanced \u203a Deposits."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Reminders"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 24 hours before"}),(0,_.jsx)(v.Toggle,{label:"24h reminder",value:i.h24,onChange:e=>o({h24:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Reminder 2 hours before"}),(0,_.jsx)(v.Toggle,{label:"2h reminder",value:i.h2,onChange:e=>o({h2:e})})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Ask guests to confirm or cancel"}),(0,_.jsx)(v.Toggle,{label:"confirm",value:i.confirmText,onChange:e=>o({confirmText:e})})]}),(0,_.jsx)(v.Muted,{children:"Guest reminders are not connected; nothing is sent."})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Capacity & waitlist"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Booking start times (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingSlotMinutesOf)(a),min:15,max:30,step:15,onChange:e=>l({bookingSlotMinutes:e}),label:"booking start times"})]}),null!=(0,P.bookingCoversPerStartOf)(a)||null!=(0,P.bookingPartiesPerStartOf)(a)?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerStart??15,min:1,max:60,onChange:e=>l({bookingCoversPerStart:e}),label:"covers at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Bookings at each start time"}),(0,_.jsx)(v.Stepper,{value:r.bookingPartiesPerStart??4,min:1,max:20,onChange:e=>l({bookingPartiesPerStart:e}),label:"bookings at each start time"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, from"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).min,min:1,max:(0,P.onlinePartyBounds)(a).max,onChange:e=>l({onlinePartyMin:e}),label:"online party from"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Online party size, up to"}),(0,_.jsx)(v.Stepper,{value:(0,P.onlinePartyBounds)(a).max,min:(0,P.onlinePartyBounds)(a).min,max:100,onChange:e=>l({onlinePartyMax:e}),label:"online party up to"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Minimum notice (min)"}),(0,_.jsx)(v.Stepper,{value:(0,P.bookingNoticeMinsOf)(a),min:0,max:180,step:5,onChange:e=>l({bookingNoticeMins:e}),label:"minimum notice"})]}),(0,_.jsx)(v.Muted,{children:"Each start time has its own covers and bookings cap, so 19:00 and 19:15 do not share a limit. Last booking is still the closing time. Staff can still book over the limit from New booking."})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Covers per 30-min slot"}),(0,_.jsx)(v.Stepper,{value:r.bookingCoversPerSlot,min:2,max:60,onChange:e=>l({bookingCoversPerSlot:e}),label:"Covers per slot"})]}),(0,_.jsx)(v.Muted,{children:"Guests can pick a start every 15 or 30 minutes. The covers cap is still for each half hour, so 19:00 and 19:15 share the same limit."})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"No limit on how far ahead guests book"}),(0,_.jsx)(v.Toggle,{label:"no limit on how far ahead guests book",value:(0,O.bookAheadUnlimited)(a),onChange:e=>l({onlineBookDaysAhead:e?void 0:90})})]}),(0,O.bookAheadUnlimited)(a)?null:(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Guests can book up to (days ahead)"}),(0,_.jsx)(v.Stepper,{value:(0,O.bookAheadDays)(a),min:1,max:O.SERVER_MAX_DAYS_AHEAD-1,step:7,onChange:e=>l({onlineBookDaysAhead:e}),label:"days ahead guests can book"})]}),(0,_.jsx)(v.Muted,{children:(0,O.bookAheadUnlimited)(a)?'Guests can pick any date up to a year ahead (the most the booking system holds), like the website.':`Guests can book up to ${(0,O.bookAheadDays)(a)} days ahead. Staff can always book further from New booking.`}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Typical table turn (min)"}),(0,_.jsx)(v.Stepper,{value:r.turnMins,min:30,max:180,onChange:e=>l({turnMins:e}),label:"turn minutes"})]}),(0,_.jsx)(v.Muted,{children:"The online waitlist estimate uses the table turn time."}),(0,_.jsx)(v.Button,{small:!0,label:"Open bookings & waitlist",onPress:()=>e('bookings')})]})]})},_e.AllergyHub=function({go:e}){const{rid:t,today:s,role:n,me:a}=(0,N.useCtx)(1e4),[r,i]=(0,b.useState)(null),l=(0,S.useOrders)(t),o=(0,S.useStore)((0,k.useShallow)(e=>e.bookings.filter(e=>e.restaurantId===t&&e.date===s))),d=(0,S.useAudit)(t).filter(e=>'allergy'===e.kind),c=(0,F.useUnsignedDishes)(t),h=(0,S.useStore)(e=>e.bookings),u=l.filter(e=>(0,I.LIVE)(e)&&(0,L.chainNeedsAction)(e,h)).length+o.filter(e=>'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l.filter(I.LIVE))).length,g=(0,N.useSignedIn)(),p=(0,U.cardActorFor)(a,'owner'===n?'owner':'manager'===n?'manager':'staff',g);if('unsigned'===r)return(0,_.jsx)(F.UnsignedDishList,{rid:t,actor:p,onClose:()=>i(null),onOpenCards:()=>e('more','recipecards')});if('pending'===r)return(0,_.jsx)(X,{go:e,onClose:()=>i(null)});const m={flex:1,minHeight:48};return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"info",title:"Supports staff, doesn't replace them",children:"CoverCharge flags the 14 UK allergens and asks a named person to verify. Staff still check with the guest and the recipe every time."}),(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsx)(y.default,{testID:"tile-awaiting-verification",accessibilityRole:"button",accessibilityLabel:`Awaiting verification, ${u}. Opens the list.`,onPress:()=>i('pending'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:u?A.colours.red:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Awaiting verification"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:u})]})}),(0,_.jsx)(y.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>i('unsigned'),style:({pressed:e})=>[m,{opacity:e?.85:1}],children:(0,_.jsxs)(v.Card,{style:{flex:1,alignItems:'center'},highlight:c.length?A.colours.amber:void 0,children:[(0,_.jsx)(v.Muted,{center:!0,children:"Dishes not signed off"}),(0,_.jsx)(v.T,{center:!0,size:20,weight:"bold",children:c.length})]})})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"1. Allergens per dish (14 UK allergens)"}),(0,_.jsx)(v.Muted,{children:"Each dish\u2019s recipe card lists contains / may contain, suggested from its ingredients. The head chef signs each card off; the menu, takeaway and booking checks all read the cards."}),(0,_.jsx)(v.Button,{small:!0,label:"Recipe cards",onPress:()=>e('more','recipecards')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"2. Kitchen alerts on orders & bookings"}),(0,_.jsx)(v.Muted,{children:"Red allergy cards; cooking is blocked until the Kitchen sign-off."}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,label:"Orders",onPress:()=>e('orders')}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Bookings",onPress:()=>e('bookings')})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"3. Five-step sign-off chain"}),(0,_.jsx)(v.Muted,{children:"Booked, Ordered, Kitchen, Pass and Table: a named person taps Sign off at each step, in order."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"4. Audit log"}),d.slice(0,6).map(e=>(0,_.jsxs)(v.Muted,{children:[(0,B.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)),d.length?null:(0,_.jsx)(v.Muted,{children:"No allergy events yet."}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Full log & daily checks",onPress:()=>e('more','compliance')})]})]})},_e.TabletPreview=function(){return(0,_.jsx)(w.default,{style:{gap:10},children:(0,_.jsxs)(v.Card,{highlight:A.colours.gold,style:{alignItems:'center'},children:[(0,_.jsxs)(w.default,{style:{width:240,height:160,borderRadius:14,borderWidth:3,borderColor:A.colours.border,alignItems:'center',justifyContent:'center'},children:[(0,_.jsx)(v.T,{size:30,children:"\ud83d\udda5\ufe0f"}),(0,_.jsx)(v.T,{weight:"semibold",children:"Kitchen & front-of-house tablet"})]}),(0,_.jsx)(v.T,{size:20,weight:"bold",colour:A.colours.gold,children:"CoverCharge for Display"}),(0,_.jsx)(v.Muted,{center:!0,children:"The in-restaurant tablet and kitchen display is its own app, CoverCharge for Display (landscape). Everything it shows (orders, readiness alerts, allergies, bookings) is also live in this app."})]})})},_e.AllFeatures=function({go:e}){const{role:t,r:s}=(0,N.useCtx)(6e4),n=(0,d.useLiveVenue)(),a=t=>t.startsWith('tab:')?e(t.slice(4)):e('more',t),r=e=>e.startsWith('tab:')?'tab:forecast'!==e||T.CAN.forecasts(t):(()=>{const s=$.PAGES.find(t=>t.id===e);return!!s&&(!s.can||s.can(t))})();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Card,{highlight:A.colours.gold,children:[(0,_.jsx)(v.T,{weight:"semibold",children:"CoverCharge is five apps that share one set of venue data"}),[['CoverCharge for Managers','This app. Run the venue: orders, bookings, forecasts, team, menu, marketing, social posting, billing.','This app'],['CoverCharge for Staff','Clock in/out with break prompt, rota, swaps & leave, chat, my hours & pay, my tips.','Separate app'],['CoverCharge',`For customers: menu, takeaway ordering, table bookings, loyalty, gift cards${(0,M.orderAtTableOn)(s)?', QR table ordering':''}.`,'Separate app'],['CoverCharge for Display','Restaurant tablet / kitchen display: live orders, readiness, allergy alerts.','Separate app'],['CoverCharge for Head Chef','Stock and deliveries, recipe costing and GP, menu engineering, waste, ordering, prep lists, allergens, kitchen compliance, kitchen rota and chat, plus My pay & tips (their own hours, tips, tip goal and paydays only). No other staff pay, customer data or billing.','Separate app']].map(([e,t,s])=>(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"medium",children:e}),(0,_.jsx)(v.Muted,{children:t})]}),(0,_.jsx)(v.Badge,{kind:'This app'===s?'ok':'gold',label:s})]},e)),'owner'===t?(0,_.jsx)(v.Chip,{label:"Open the Staff app preview \u203a",onPress:()=>{T.useOwner.getState().setPreviewRole('staff'),e('home')}}):null,(0,_.jsx)(v.Muted,{children:n?'All five share your venue\u2019s live data. Each is installed separately, and your venue\u2019s own logo leads (Settings \u203a Branding).':'This copy isn\u2019t connected to a venue yet, so it only shows what is saved on this device. Each app is installed separately, and the venue\u2019s own logo leads (Settings \u203a Branding).'})]}),(0,_.jsx)(v.Muted,{children:"Every CoverCharge feature and where to manage it."}),[...J].filter(e=>4!==e.n||(0,M.orderAtTableOn)(s)).sort((e,t)=>e.n-t.n).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{alignItems:'flex-start'},children:[(0,_.jsxs)(v.T,{weight:"bold",colour:A.colours.gold,style:{width:26},children:[e.n,"."]}),(0,_.jsxs)(w.default,{style:{flex:1},children:[(0,_.jsx)(v.T,{weight:"semibold",children:e.title}),(0,_.jsx)(v.Muted,{children:e.note})]})]}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:e.links.filter(([,e])=>r(e)).map(([e,t])=>(0,_.jsx)(v.Chip,{label:`${e} \u203a`,onPress:()=>a(t)},t))})]},e.n))]})},Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return v.Divider}}),_e.Loyalty=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"card"}):(0,_.jsx)(H,{})},_e.Referrals=function(){return a.LIVE_VENUE_BUILD||(0,h.staffServer)()?(0,_.jsx)(te,{kind:"referrals"}):(0,_.jsx)(Q,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),r=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),g=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),x=_r(_d[16]),f=_r(_d[17]),j=_r(_d[18]),y=e(_r(_d[19])),w=e(_r(_d[20])),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),R=_r(_d[26]),M=_r(_d[27]),P=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),A=_r(_d[31]),I=_r(_d[32]),N=_r(_d[33]),D=_r(_d[34]),E=_r(_d[35]),$=_r(_d[36]),L=_r(_d[37]),z=_r(_d[38]),F=_r(_d[39]),U=_r(_d[40]),G=_r(_d[41]),_=_r(_d[42]);const V=()=>S.useStore.getState();function H(){const{rid:e,r:s,me:a}=(0,N.useCtx)(3e4),r=s.settings,i=(0,S.useStore)((0,k.useShallow)(t=>t.stampCards.filter(t=>t.restaurantId===e))),l=(0,S.useStore)(e=>e.customer.name),o=(0,S.useAudit)(e).filter(e=>'stamp'===e.kind),d=(0,b.useMemo)(()=>(0,D.crmCustomers)(),[]),[c,h]=(0,b.useState)(r.stampReward),[u,g]=(0,b.useState)('');(0,b.useEffect)(()=>{(0,E.examplesAllowed)()&&e===t.VENUE_RID&&!i.some(e=>e.customerId.startsWith('cr-'))&&S.useStore.setState(t=>({stampCards:[...t.stampCards,...d.filter(e=>'cust-demo'!==e.id).map((t,s)=>({restaurantId:e,customerId:t.id,stamps:t.stamps%r.stampTarget,rewardsAvailable:s%5==0?1:0,history:[{at:'2026-10-20',source:s%2?'Takeaway':'Dine-in'}]}))]}))},[e]);const p=e=>d.find(t=>t.id===e)?.name??(e===S.useStore.getState().customer.id?l||'Guest':e),m=i.filter(e=>!u||p(e.customerId).toLowerCase().includes(u.toLowerCase())).sort((e,t)=>t.stamps-e.stamps),x=(0,E.examplesAllowed)(),f=o.filter(e=>/redeemed/.test(e.text)).length+(x?31:0);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Active cards"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.length})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Rewards ready"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i.reduce((e,t)=>e+t.rewardsAvailable,0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Redeemed"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:f}),(0,_.jsx)(v.Muted,{children:x?'all time (example)':'all time'})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card settings"}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Stamps for a reward"}),(0,_.jsx)(v.Stepper,{value:r.stampTarget,min:3,max:15,onChange:t=>V().updateSettings(e,{stampTarget:t}),label:"stamps"})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{children:"Min spend \xa3"}),(0,_.jsx)(v.Stepper,{value:r.stampMinSpend/100,min:0,max:50,onChange:t=>V().updateSettings(e,{stampMinSpend:100*t}),label:"minimum spend"})]}),(0,_.jsx)(v.Field,{label:"Reward",value:c,onChangeText:h}),(0,_.jsx)(v.Button,{small:!0,label:"Save reward",onPress:()=>V().updateSettings(e,{stampReward:c.trim()||r.stampReward})}),(0,_.jsx)(v.Muted,{children:"One card per customer account, shared across dine-in, table QR and takeaway."})]}),(0,_.jsx)(I.SectionHead,{title:"Members"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Search members",placeholder:"Search members",placeholderTextColor:"#7D776C",value:u,onChangeText:g,style:v.styles.input}),m.map(t=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:p(t.customerId)}),t.rewardsAvailable?(0,_.jsx)(v.Badge,{kind:"ok",label:`${t.rewardsAvailable} reward ready`}):null]}),(0,_.jsx)(v.Row,{gap:4,children:Array.from({length:r.stampTarget},(e,s)=>(0,_.jsx)(w.default,{style:{flex:1,height:8,borderRadius:4,backgroundColor:se.source))).join(', ')||'\u2013']}),(0,_.jsxs)(v.Row,{gap:6,children:[(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Add stamp",onPress:()=>V().addStamp(e,t.customerId,`Manual (${a})`)}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem reward",disabled:!t.rewardsAvailable,onPress:()=>V().redeemReward(e,t.customerId)})]})]},t.customerId))]})}function Q(){const e=(0,T.useOwner)(e=>e.referral),t=(0,T.useOwner)(e=>e.referrals),[s,n]=(0,b.useState)(e.giverReward),[a,r]=(0,b.useState)(e.friendReward),i=e=>t.filter(t=>t.status===e).length,l=(0,E.examplesAllowed)();return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[l?(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Invites sent"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:"64"}),(0,_.jsx)(v.Muted,{children:"example"})]}):null,(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sign-ups"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:t.length+(l?23:0)})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Ordered"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:i('first order')+i('rewarded')+(l?9:0)})]})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Bring a friend"}),(0,_.jsx)(v.Toggle,{label:"Referrals on",value:e.active,onChange:t=>T.useOwner.getState().setOwner({referral:{...e,active:t}})})]}),(0,_.jsx)(v.Field,{label:"Reward for the customer who invites",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Reward for the friend (first order)",value:a,onChangeText:r}),(0,_.jsx)(v.Button,{small:!0,label:"Save rewards",onPress:()=>T.useOwner.getState().setOwner({referral:{...e,giverReward:s.trim(),friendReward:a.trim()}})}),(0,_.jsx)(v.Muted,{children:"The inviter\u2019s reward is added to their account after the friend\u2019s first order."})]}),(0,_.jsx)(I.SectionHead,{title:"Referrals"}),t.map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[e.referrer," \u2192 ",e.friend]}),(0,_.jsx)(v.Badge,{kind:'rewarded'===e.status?'ok':'first order'===e.status?'gold':'neutral',label:e.status})]}),(0,_.jsx)(v.Muted,{children:e.at})]},e.id))]})}function W(){const{me:e}=(0,N.useCtx)(6e4),t=(0,N.useSignedIn)();return(0,_.jsx)(p.GiftCardsPage,{me:(t?.name??e).replace(' (example)','')})}function q(){const{rid:e,me:t}=(0,N.useCtx)(6e4),s=(0,S.useStore)((0,k.useShallow)(t=>t.giftCards.filter(t=>t.restaurantId===e))),[a,r]=(0,b.useState)(25),[i,l]=(0,b.useState)(''),[o,d]=(0,b.useState)(''),[c,h]=(0,b.useState)(''),[u,g]=(0,b.useState)(''),[p,m]=(0,b.useState)(''),[x,f]=(0,b.useState)(null),j=s.find(e=>e.code.toUpperCase()===o.trim().toUpperCase()),y=s.find(e=>e.legacy&&e.code.toUpperCase()===u.trim().toUpperCase());return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsxs)(v.Row,{gap:8,children:[(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Sold"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.initial,0))})]}),(0,_.jsxs)(v.Card,{style:{flex:1},children:[(0,_.jsx)(v.Muted,{children:"Outstanding"}),(0,_.jsx)(v.T,{size:20,weight:"bold",children:(0,R.gbp)(s.reduce((e,t)=>e+t.balance,0))})]})]}),x?(0,_.jsx)(v.Banner,{kind:"success",title:x}):null,(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Check balance & redeem"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Gift card code",placeholder:"Code, e.g. ANC-G7QX-4M2P-9TRE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:o,onChangeText:d,style:v.styles.input}),o.trim().length>5?j?(0,_.jsxs)(v.Muted,{children:[j.recipientName," \xb7 balance ",(0,R.gbp)(j.balance)," of ",(0,R.gbp)(j.initial),j.legacy?' \xb7 legacy website bookings':'']}):(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"No card with that code."}):null,(0,_.jsx)(v.Field,{label:"Amount to redeem \xa3",value:c,onChangeText:h,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Redeem",disabled:!j||!(Number(c)>0)||100*Number(c)>(j?.balance??0),onPress:()=>{V().redeemGiftCard(o,Math.round(100*Number(c)),t)&&(f(`Redeemed \xa3${Number(c).toFixed(2)} from ${j.code}`),h(''))}})]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,_.jsx)(n.TextInput,{accessibilityLabel:"Website bookings gift card code",placeholder:"Old gift card code, e.g. WEB-OLD-10-EXAMPLE",placeholderTextColor:"#7D776C",autoCapitalize:"characters",value:u,onChangeText:g,style:v.styles.input}),u.trim().length>4?y?(0,_.jsxs)(v.Muted,{children:["Found in imported website bookings cards: balance ",(0,R.gbp)(y.balance),". Redeem it above."]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v.Muted,{children:"Not in the imported list. Check it in your website bookings dashboard, then honour it here:"}),(0,_.jsx)(v.Field,{label:"Balance confirmed in website bookings \xa3",value:p,onChangeText:m,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Honour & add to CoverCharge",disabled:!(Number(p)>0),onPress:()=>{const s=V().honourLegacyCard(e,u,Math.round(100*Number(p)),t);f(`Website bookings card ${s.code} honoured`),d(s.code),g(''),m('')}})]}):null]}),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Create / sell a gift card"}),(0,_.jsx)(v.Row,{wrap:!0,gap:6,children:[10,25,50,100].map(e=>(0,_.jsx)(v.Chip,{label:`\xa3${e}`,selected:a===e,onPress:()=>r(e)},e))}),(0,_.jsx)(v.Field,{label:"Recipient",value:i,onChangeText:l}),(0,_.jsx)(v.Button,{label:`Record a \xa3${a} card paid at the till`,disabled:i.trim().length<2,onPress:()=>{const t=V().buyGiftCard(e,100*a,i.trim(),'Sold at the till');f(`Created ${t.code}`),l('')}}),(0,_.jsx)(v.Muted,{children:"Gift cards are sold through your website. Record one here only when it was paid at the till."})]}),(0,_.jsx)(I.SectionHead,{title:"All cards"}),s.map(e=>(0,_.jsxs)(v.Card,{onPress:()=>d(e.code),children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.recipientName}),e.legacy?(0,_.jsx)(v.Badge,{kind:"neutral",label:"Legacy website bookings"}):null]}),(0,_.jsxs)(v.Muted,{children:[e.code," \xb7 ",(0,R.gbp)(e.balance)," of ",(0,R.gbp)(e.initial)]})]},e.id))]})}function K({rid:e,now:t,me:s}){const n=(0,S.useOrders)(e).filter(e=>'table'===e.type),[a,i]=(0,b.useState)(null),l=(0,x.useTableUse)(e,t),o=(0,x.useTableNames)(e);return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Muted,{children:"Each table has its own QR code. Guests scan, order and pay (or split) from their phone. Dine-in cooking starts once the table is seated and has ordered."}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Preview customer table ordering (5)",onPress:()=>j.router.push('/table/5'),testID:"preview-table-ordering"}),(0,_.jsx)(v.Row,{wrap:!0,gap:8,children:o.map(e=>{const t=n.filter(t=>t.tableNo===e&&(0,I.LIVE)(t)),s=t.reduce((e,t)=>e+t.total-t.paid,0);return(0,_.jsxs)(y.default,{accessibilityRole:"button",accessibilityLabel:`Table ${(0,r.tableNumbers)(e)}`,onPress:()=>i(e),style:{width:'31%',padding:10,borderRadius:12,borderWidth:1,borderColor:t.length?A.colours.gold:A.colours.border,backgroundColor:A.colours.surface,gap:2},children:[(0,_.jsx)(v.T,{weight:"bold",children:(0,r.tableNumbers)(e)}),(0,_.jsx)(v.T,{size:12,colour:l[e]?.busy?'#FFD9D4':'#E2C489',children:l[e]?.busy?l[e].label:'Free'}),(0,_.jsx)(v.Muted,{children:t.length?`${t.length} order${t.length>1?'s':''}`:'No orders'}),s?(0,_.jsxs)(v.T,{size:12,colour:A.colours.amber,children:[(0,R.gbp)(s)," to pay"]}):(0,_.jsx)(v.T,{size:12,colour:A.colours.muted,children:"View QR"})]},e)})}),(0,_.jsx)(I.SectionHead,{title:"Live table orders"}),n.filter(I.LIVE).map(e=>(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",children:[(0,r.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,_.jsx)(v.Badge,{kind:(0,I.statusKind)(e.status),label:(0,I.statusLabel)(e)})]}),(0,_.jsxs)(v.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,B.minsBetween)(new Date(e.createdAt),t)," min ago \xb7 ",(0,R.gbp)(e.paid)," of ",(0,R.gbp)(e.total)," paid",e.split?` \xb7 split ${e.split.paidShares}/${e.split.ways}`:'']})]},e.id)),n.filter(I.LIVE).length?null:(0,_.jsx)(v.Muted,{children:"No live table orders."}),a?(0,_.jsxs)(v.Sheet,{visible:!0,onClose:()=>i(null),title:`${(0,r.tableNumbers)(a)} QR code`,children:[(0,_.jsx)(w.default,{style:{alignItems:'center',backgroundColor:'#fff',padding:16,borderRadius:12},children:(0,_.jsx)(C.QR,{value:`https://covercharge.example/t/${e}/${a}`,size:200})}),(0,_.jsxs)(v.Muted,{center:!0,children:["Example link (table ordering links aren\u2019t live yet): covercharge.example/t/",e,"/",a]}),(0,_.jsx)(v.Banner,{kind:"demo",title:"Print later",children:"Printing table cards from here isn\u2019t set up yet. Nothing is printed or sent."}),(0,_.jsx)(v.Button,{label:`Preview customer table ordering (${(0,r.tableNumbers)(a)})`,onPress:()=>{const e=a;i(null),j.router.push(`/table/${e}`)}}),(0,_.jsx)(v.Button,{kind:"secondary",label:"Show the code again",onPress:()=>i(a)})]}):null]})}function X({go:e,onClose:t}){const{rid:s,today:n,role:a}=(0,N.useCtx)(1e4),r=(0,S.useOrders)(s),i=(0,S.useStore)(e=>e.bookings);(0,z.useBackLayer)(!0,t);const l=r.filter(I.LIVE),o=[...l.filter(e=>(0,L.chainNeedsAction)(e,i)).map(e=>{const t=(0,L.nextStep)(e,(0,L.linkedBooking)(e,i)),s=L.CHAIN_STEPS.find(e=>e.id===t);return{id:`o-${e.id}`,at:e.createdAt,title:`${e.ref} \xb7 ${'table'===e.type?`Table ${e.tableNo??''}`.trim():'Takeaway'}${e.customerName?` \xb7 ${e.customerName}`:''}`,when:`Ordered ${(0,B.hm)(new Date(e.createdAt))}`,allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:s?`Next: ${s.n}. ${s.label} sign-off`:'Sign-off waiting',tab:'orders',open:'Open Orders to sign off'}}),...i.filter(e=>e.restaurantId===s&&e.date===n&&'cancelled'!==e.status&&(0,L.bookingNeedsAction)(e,l)).map(e=>({id:`b-${e.id}`,at:`${e.date}T${e.time}`,title:`${e.name} \xb7 ${e.partySize} at ${e.time}`,when:`Booking ${e.ref??''}`.trim(),allergies:e.allergies.map(e=>(0,G.allergenLabel)(e.allergen)).join(', '),next:'Next: 1. Booked sign-off',tab:'bookings',open:'Open Bookings to sign off'}))].sort((e,t)=>e.at.localeCompare(t.at));return(0,_.jsxs)(w.default,{testID:"pending-list",style:{gap:12,alignItems:'stretch'},children:[(0,_.jsx)(z.BackButton,{onPress:t,testID:"pending-back"}),(0,_.jsx)(v.T,{center:!0,size:22,weight:"bold",colour:A.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Awaiting verification"}),(0,_.jsx)(v.Muted,{center:!0,testID:"pending-status",children:o.length?`${o.length} allergy ${1===o.length?'sign-off':'sign-offs'} waiting, oldest first.`:'Nothing is waiting for an allergy sign-off.'}),o.map(t=>(0,_.jsxs)(v.Card,{highlight:A.colours.red,style:{alignItems:'center',gap:8},children:[(0,_.jsxs)(w.default,{testID:`pending-row-${t.id}`,accessible:!0,accessibilityLabel:`${t.title}, ${t.when}, allergies: ${t.allergies}. ${t.next}.`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,_.jsx)(v.T,{center:!0,weight:"bold",size:18,children:t.title}),(0,_.jsx)(v.T,{center:!0,children:t.when}),(0,_.jsxs)(v.Muted,{center:!0,children:["Allergies: ",t.allergies]}),(0,_.jsx)(v.T,{center:!0,colour:A.colours.gold,children:t.next})]}),(0,_.jsx)(v.Button,{small:!0,label:t.open,onPress:()=>e(t.tab),style:{alignSelf:'stretch'}})]},t.id)),'owner'===a||'manager'===a?(0,_.jsx)(v.Button,{small:!0,kind:"secondary",label:"Allergen sign-off log",onPress:()=>e('more','allergen-signoffs')}):null]})}function Y(){const e=(0,T.useOwner)(e=>e.merch),t=(0,T.useOwner)(e=>e.merchOrders),[s,n]=(0,b.useState)(''),[a,r]=(0,b.useState)(''),i=(t,s)=>T.useOwner.getState().setOwner({merch:e.map(e=>e.id===t?{...e,...s}:e)});return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(v.Banner,{kind:"demo",title:"Optional add-on",children:"Sell branded items in the customer app for collection. Example only on this device; nothing is charged."}),(0,_.jsx)(I.SectionHead,{title:"Products & stock"}),e.map(e=>(0,_.jsxs)(w.default,{style:v.styles.card,children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(v.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,_.jsx)(v.T,{children:(0,R.gbp)(e.price)})]}),(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsx)(w.default,{style:{flex:1,minWidth:0},children:(0,_.jsx)(v.Toggle,{label:e.live?'In shop':'Hidden',a11y:`${e.name} live`,value:e.live,onChange:t=>i(e.id,{live:t})})}),(0,_.jsx)(v.Stepper,{value:e.stock,min:0,max:500,onChange:t=>i(e.id,{stock:t}),label:`${e.name} stock`})]}),0===e.stock?(0,_.jsx)(v.T,{size:13,colour:A.colours.red,children:"Out of stock"}):e.stock<8?(0,_.jsx)(v.T,{size:13,colour:A.colours.amber,children:"Low stock"}):null]},e.id)),(0,_.jsxs)(v.Card,{children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Add a product"}),(0,_.jsx)(v.Field,{label:"Name",value:s,onChangeText:n}),(0,_.jsx)(v.Field,{label:"Price \xa3",value:a,onChangeText:r,keyboardType:"decimal-pad"}),(0,_.jsx)(v.Button,{small:!0,label:"Add product",disabled:s.trim().length<2||!(Number(a)>0),onPress:()=>{T.useOwner.getState().setOwner({merch:[...e,{id:`mc-${Date.now()}`,name:s.trim(),price:Math.round(100*Number(a)),stock:10,live:!0}]}),n(''),r('')}})]}),(0,_.jsx)(I.SectionHead,{title:"Shop orders"}),t.map(s=>{const n=e.find(e=>e.id===s.productId);return(0,_.jsxs)(v.Card,{children:[(0,_.jsxs)(v.Row,{style:{justifyContent:'space-between'},children:[(0,_.jsxs)(v.T,{weight:"semibold",style:{flex:1},children:[s.qty,"\xd7 ",n?.name," \xb7 ",s.customer]}),(0,_.jsx)(v.Badge,{kind:'new'===s.status?'amber':'ready'===s.status?'blue':'ok',label:s.status})]}),(0,_.jsxs)(v.Muted,{children:[s.at," \xb7 ",(0,R.gbp)((n?.price??0)*s.qty)]}),'collected'!==s.status?(0,_.jsx)(v.Button,{small:!0,label:'new'===s.status?'Mark ready':'Mark collected',onPress:()=>T.useOwner.getState().setOwner({merchOrders:t.map(e=>e.id===s.id?{...e,status:'new'===s.status?'ready':'collected'}:e)})}):null]},s.id)})]})}const J=[{n:1,title:'Loyalty stamp card',links:[['Stamp card','loyalty']],note:'Settings, members, add/redeem, stats. One card across dine-in & takeaway.'},{n:2,title:'Bring-a-friend referrals',links:[['Referrals','referrals']],note:'Rewards, referral list and stats.'},{n:3,title:'Gift cards & vouchers',links:[['Gift cards','giftcards']],note:'Sold through your website. Check a balance, take it off the bill, honour website bookings cards.'},{n:4,title:'QR order & pay at table',links:[['Tables & QR codes','tables']],note:'Table list, QR per table, live table orders.'},{n:5,title:'Direct takeaway ordering',links:[['Takeaway settings','takeaway'],['Orders','tab:orders']],note:'Slots, capacity, live queue, readiness alerts (takeaway only).'},{n:6,title:'Table bookings, no-shows & waitlist',links:[['Bookings','tab:bookings'],['Booking settings','bookingsettings']],note:'Deposits (Deposit due / paid, set in Settings \u203a Advanced), no-show marking, reminders, online waitlist.'},{n:7,title:'Allergy verification',links:[['Allergy hub','allergy'],['Menu & allergens','menu']],note:'14 UK allergens per dish, kitchen alerts, named verification, audit log.'},{n:8,title:'Push offers & specials (opt-in)',links:[['Marketing','marketing'],['Specials & offers','offers']],note:'Saved campaign drafts. Delivery is not connected.'},{n:9,title:'Calendar & marketing hooks',links:[['Forecast calendar','tab:forecast'],['Events','events']],note:'Scottish bank holidays, school holidays, local & own events, promo hooks.'},{n:10,title:'Private feedback',links:[['Feedback inbox','feedback'],['Reviews','reviews']],note:'Low-rating alerts. No review gating.'},{n:11,title:'Lost property & coat check',links:[['Lost property','lost']],note:'Found items and coat-check tickets.'},{n:12,title:'Merch shop (optional)',links:[['Merch shop','merch']],note:'Products, stock and orders.'},{n:14,title:'Staff group chat',links:[['Chat','tab:chat']],note:'Channels, DMs, photos, reactions, read receipts, pins, auto-posts, cover requests. Local only.'},{n:16,title:'Suppliers',links:[['Suppliers','suppliers'],['Prep & stock list','prep']],note:'Contacts, categories, favourites, cut-offs and delivery days, tap to call/email/website, orders due today, order log, staff permission.'},{n:17,title:'Hours & pay',links:[['My hours & pay','mypay'],['Payroll & pay rates','payroll'],['Timesheets','timesheets']],note:'Staff see their own hours and gross pay (before tax, estimate) plus tips; owner sets hourly rates and sees the team payroll summary.'},{n:15,title:'Tip splitter',links:[['Tips','tips'],['My tips','mytips']],note:'Pay periods, card + cash pot, 4 split methods, approve & lock, compliance checklist.'},{n:18,title:'Post to social',links:[['Post to social','social'],['Connected accounts','socialaccounts'],['Marketing','marketing']],note:'Social publishing is not connected. No accounts are linked and nothing is posted.'},{n:20,title:'Head Chef app',links:[['Menu & allergens','menu'],['Suppliers','suppliers']],note:'CoverCharge for Head Chef: stock with par levels and alerts, stock take, deliveries checked against the order, recipe cards with dish cost, GP % and cash GP against a target, price-change impact, theoretical vs actual GP, menu engineering, waste log, ordering from par and forecast, prep lists, 14-allergen matrix with sign-off, temperatures, cleaning and daily checks, kitchen rota, chat, live tickets and a Sold out list (a reminder for staff, shown on the Display). Uses this menu and these suppliers.'},{n:21,title:'Branding',links:[['Branding','branding']],note:'Your logo and accent colour lead all five apps, with a small "powered by CoverCharge". Pick any colour with the colour picker or a hex code; text on it stays readable.'},{n:19,title:'Quick links',links:[['Quick links','quicklinks'],['Dashboard','tab:home']],note:'One-tap Work email (Gmail) and Website bookings view/edit for owners and managers, plus up to 6 of your own links. Staff never see the website bookings links; per-link staff visibility for the rest (off by default). Head Chef: no quick links or email at all. Opens the app or site only.'},{n:13,title:'Forecasting, dashboard & running the business',links:[['Forecast','tab:forecast'],['Dashboard','tab:home'],['Tablet preview','tablet'],['Rota','rota'],['Clock in/out','clock'],['Timesheets','timesheets'],['Analytics','analytics'],['CRM','crm'],['Plan & billing','plan']],note:'Headline forecast, rotas, geofenced clock in/out with break prompt, analytics, CRM'+f.PLAN_FEATURE_NOTE+'.'}];const Z=async e=>{try{return'undefined'!=typeof localStorage&&'1'===localStorage.getItem(e)}catch{return!1}},ee=async e=>{try{'undefined'!=typeof localStorage&&localStorage.setItem(e,'1')}catch{}};function te({kind:e}){const{r:t}=(0,N.useCtx)(6e4),s=(0,T.useOwner)(e=>e.offers);(0,b.useEffect)(()=>{(0,h.migrateLocalOnce)({offers:s},Z,ee).catch(()=>{})},[]);const n=(0,u.can)('venue.settings');return(0,_.jsxs)(w.default,{style:{gap:10},children:[(0,_.jsx)(m.LoyaltySummaryCard,{kind:e}),(0,_.jsx)(g.StaffLoyalty,{venue:t.name,canRemove:n,onOpenSettings:n?()=>{l.advancedPrefill.q='loyalty',o.useVoiceNav.getState().go?.('more','advanced')}:void 0}),n?(0,_.jsx)(v.Card,{children:(0,_.jsxs)(w.default,{style:{gap:8},children:[(0,_.jsx)(v.T,{weight:"semibold",children:"Card, offers and bring-a-friend settings"}),(0,_.jsx)(m.LoyaltySettingsPanel,{})]})}):null]})}},1510,[5,1418,827,837,860,1511,1442,1481,1236,14,1271,987,1512,1514,1443,34,1126,1489,30,402,102,879,1291,794,874,891,867,881,1131,1260,858,821,1201,1088,1160,884,1459,869,1056,1176,863,861,25]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1511,[860,34,102,794,861,867,1175,874,869,821,25]); +__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1512,[987,34,281,236,102,1291,794,1268,1271,821,1513,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1513,[34,236,102,794,1268,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1514,[5,1418,34,102,794,867,1268,1269,1270,987,1271,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SafetyPages",{enumerable:!0,get:function(){return w}}),r(d[0]);var n=r(d[1]),t=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5]),u=r(d[6]),l=r(d[7]),x=r(d[8]),p=r(d[9]),C=r(d[10]);const w={Creator:()=>{const{rid:n,role:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(t.DishCreator,{rid:n,canPublish:'owner'===s||'manager'===s})},Prices:()=>(0,C.jsx)(j,{initial:"prices"}),Kitchen:()=>(0,C.jsx)(j,{initial:"deliveries"}),Haccp:()=>{const{me:n,meId:t,now:o}=(0,c.useCtx)(3e4);return(0,C.jsx)(s.HaccpLog,{mode:"managers",me:n,meId:t,now:o})},Specials:()=>{const{rid:n,me:t,now:s}=(0,c.useCtx)(3e4);return(0,C.jsx)(o.SpecialsEditor,{rid:n,me:t,app:"managers",now:s})},Accidents:()=>{const{me:t,meId:s,now:o,role:u}=(0,c.useCtx)(3e4);return(0,C.jsx)(n.AccidentBook,{app:"managers",me:t,meId:s,now:o,seeAll:'owner'===u||'manager'===u})}};function j({initial:n}){const{rid:t,role:s,me:o}=(0,c.useCtx)(3e4),w=(0,c.useSignedIn)(),j=x.IS_CAR?p.CAR_ACTOR:o;return(0,C.jsx)(u.KitchenCosts,{rid:t,me:j,actor:(0,l.cardActorFor)(j,'owner'===s?'owner':'manager'===s?'manager':'staff',w),initial:n})}},1515,[34,1225,1178,1226,1233,1088,1192,863,872,1025,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"CAR_LINK",{enumerable:!0,get:function(){return u}}),_e.CarScreen=function(){const e=(0,o.useSync)(e=>'staff'===e.kind&&!!e.venueId),[n,c]=(0,t.useState)(''),[b,y]=(0,t.useState)(null),[x,j]=(0,t.useState)(!1),[w,v]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),C=async()=>{try{v(await(0,o.carList)())}catch{v([])}};(0,t.useEffect)(()=>{e&&C()},[e]);const D=n.replace(/\D/g,''),I=async()=>{j(!0),y(null);const e=await(0,o.carApprove)(D);j(!1),e.ok?(c(''),y({ok:!0,text:'Done. The car is paired as an owner device. It opens in a few seconds. Nobody is signed in on the car.'}),C()):y({ok:!1,text:e.message})};return(0,h.jsxs)(r.default,{testID:"car-screen-page",style:{gap:12},children:[(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Pair the car"}),(0,h.jsx)(s.T,{center:!0,children:`In the car, while parked, open the browser and type ${u}`}),(0,h.jsx)(s.T,{center:!0,children:"The car shows 6 numbers on its screen. Only an owner can approve this."}),(0,h.jsx)(s.Field,{testID:"car-code-field",label:"Code shown on the car (6 numbers)",accessibilityLabel:"Code shown on the car, 6 numbers",value:n,onChangeText:e=>c(e.replace(/[^\d ]/g,'').slice(0,7)),keyboardType:"number-pad",inputMode:"numeric",autoComplete:"off",autoCorrect:!1,maxLength:7,placeholder:"123 456"}),(0,h.jsx)(s.Button,{testID:"car-approve",label:x?'Approving\u2026':'Approve car',accessibilityHint:"Pairs the car as an owner device",disabled:!e||x||6!==D.length,onPress:()=>{I()},style:{minHeight:56}}),e?null:(0,h.jsx)(s.Muted,{center:!0,children:"Your phone needs to be connected, and you need to be an owner, to approve a car."}),(0,h.jsx)(r.default,{accessibilityLiveRegion:"polite",accessible:!!b,accessibilityLabel:b?.text,children:b?(0,h.jsx)(s.T,{testID:"car-approve-msg",center:!0,weight:"semibold",colour:b.ok?l.colours.goldLight:l.colours.amber,children:b.text}):null}),(0,h.jsx)(s.Muted,{center:!0,children:"Never open your personal app link in the car. It stays on this phone."})]}),(0,h.jsxs)(s.Card,{children:[(0,h.jsx)(s.T,{center:!0,size:18,weight:"semibold",colour:l.colours.goldLight,accessibilityRole:"header",children:"Cars paired"}),null===w?(0,h.jsx)(s.Muted,{center:!0,children:e?'Loading\u2026':'Shown once your phone is connected.'}):w.length?w.map(e=>(0,h.jsxs)(r.default,{testID:`car-row-${e.id}`,style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:l.colours.border},children:[(0,h.jsx)(s.T,{center:!0,weight:"semibold",children:`${e.label} \xb7 paired`}),(0,h.jsx)(s.Muted,{center:!0,children:`Since ${p(e.approvedAt)}. Last seen ${p(e.lastSeenAt)}.`}),(0,h.jsx)(s.Button,{testID:`car-revoke-${e.id}`,kind:"secondary",label:"Unpair this car",accessibilityLabel:`Unpair ${e.label}`,onPress:()=>k(e),style:{minHeight:56}})]},e.id)):(0,h.jsx)(s.Muted,{center:!0,children:"No cars are paired."})]}),f?(0,h.jsxs)(s.Sheet,{visible:!0,onClose:()=>k(null),title:"Unpair this car?",maxWidth:520,testID:"car-revoke-confirm",children:[(0,h.jsx)(s.T,{center:!0,children:`${f.label} stops working straight away. To use it again, make a new code in the car and approve it here as an owner.`}),(0,h.jsx)(s.Button,{testID:"car-revoke-yes",label:"Yes, unpair it",onPress:async()=>{const e=f;k(null);const t=await(0,o.carRevoke)(e.id);y(t.ok?{ok:!0,text:`${e.label} is unpaired.`}:{ok:!1,text:t.message}),C()},style:{minHeight:56}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Cancel",onPress:()=>k(null),style:{minHeight:56}})]}):null]})};var e,t=_r(d[0]),n=_r(d[1]),r=(e=n)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),c=_r(d[4]),l=_r(d[5]),h=_r(d[6]);const u='covercharge-apps.static.hf.space/car',p=e=>e?`${(0,c.niceDate)(new Date(e))} at ${(0,c.hm)(new Date(e))}`:'not yet'},1516,[34,102,794,987,858,821,25]); +__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.EmailFrame=k,_e.SmsBubble=v,_e.AlertSettings=function({go:e}){const{rid:s}=(0,w.useCtx)(6e4),t=(0,j.useAlerts)(e=>e.prefs),[l,o]=(0,n.useState)((0,j.systemSupport)()),r='granted'===l?'Allowed on this device':'denied'===l?'Blocked. Turn it back on in your browser or phone settings for this site.':'default'===l?'Not asked yet':'This browser can\u2019t show notifications. On iPhone, add the Managers app to your Home Screen first.';return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Alert sound"}),(0,T.jsx)(h.Badge,{kind:t.muted?'neutral':'gold',label:t.muted?'Muted':'On'})]}),(0,T.jsx)(h.Toggle,{label:"Play a chime when an alert arrives",value:!t.muted,onChange:e=>j.useAlerts.getState().setPrefs({muted:!e})}),(0,T.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the chime",onPress:()=>(0,p.chime)('bright')}),(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Play the kitchen chime",onPress:()=>(0,p.lowChime)(.6)})]}),(0,T.jsx)(h.Muted,{children:"The Display is silent and shows alerts on screen. The Head Chef app flashes and plays a soft chime until a takeaway is confirmed and its allergies are ticked."})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Which alerts to show"}),(0,T.jsx)(h.Muted,{children:"Switched-off alerts still go into the list behind the bell, quietly."}),j.ALERT_KINDS.filter(e=>'test'!==e).map(e=>(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindChip,{kind:e,size:30}),(0,T.jsx)(c.default,{style:{flex:1},children:(0,T.jsx)(h.Toggle,{label:j.KIND_META[e].label,value:!1!==t.types[e],onChange:s=>j.useAlerts.getState().setType(e,s)})})]},e))]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Send a test alert"}),(0,T.jsx)(h.Muted,{children:"Shows each alert here (and as a phone notification if allowed). Tests are clearly labelled and never touch real bookings."}),(0,T.jsx)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:['booking','pending','takeaway','email'].map(e=>(0,T.jsx)(h.Button,{small:!0,kind:"secondary",testID:`test-alert-${e}`,label:`Test: ${j.KIND_META[e].label.toLowerCase()}`,onPress:()=>(0,j.sendTestAlert)(s,e)},e))})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Phone and desktop notifications"}),(0,T.jsx)(h.Badge,{kind:'granted'===l?'ok':'denied'===l?'red':'neutral',label:'granted'===l?'On':'denied'===l?'Blocked':'default'===l?'Off':'Not available'})]}),(0,T.jsx)(h.Muted,{children:r}),(0,T.jsx)(h.Toggle,{label:"Pop up alerts when the app is in the background",value:t.system,onChange:e=>j.useAlerts.getState().setPrefs({system:e})}),'default'===l?(0,T.jsx)(h.Button,{small:!0,label:"Allow notifications",onPress:async()=>{o(await(0,j.requestSystemPermission)()),j.useAlerts.getState().setAsked()}}):null,'granted'===l?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Show a test notification",onPress:()=>(0,j.showSystemNotification)({id:`test-sys:${Date.now()}`,kind:'test',rid:s,at:Date.now(),name:'Test guest',when:'Today 19:30',covers:4,source:'Phone',test:!0},!0)}):null,(0,T.jsx)(h.Muted,{children:(0,j.isInstalled)()?'Installed on this device.':'Tip: install the Managers app (Add to Home Screen) for the most reliable alerts.'}),(0,T.jsx)(h.T,{weight:"semibold",style:{marginTop:6},children:"Alerts when the phone is locked"}),(0,T.jsx)(f.PhoneAlerts,{what:"booking alerts (new, changed, cancelled, no-show) and your reminders"})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{gap:10,children:[(0,T.jsx)(u.KindIcon,{kind:"email"}),(0,T.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Venue email"}),(0,T.jsx)(h.Badge,{kind:"neutral",label:j.CONNECTED_INBOX?'Connected':'Not connected'})]}),(0,T.jsx)(h.Muted,{children:j.CONNECTED_INBOX?'New emails to your venue inbox pop up as alerts.':`${j.INBOX_EMPTY}. Once connected, we\u2019ll show who it\u2019s from and the subject, never the whole message on the Display.`})]}),(0,T.jsx)(h.Button,{kind:"ghost",label:"Open alert history",onPress:()=>e('more','notifications')})]})},_e.GuestTemplates=function(){const{rid:e,r:s,today:o}=(0,w.useCtx)(6e4),r=(0,m.useStore)(s=>s.msgTemplates[e]),u=(0,n.useMemo)(()=>(0,b.templatesFor)(r),[r]),j=(0,x.useAssistant)(e=>e.enabled),[p,f]=(0,n.useState)('booking'),[P,M]=(0,n.useState)('sms'),A=u[p],B=s=>m.useStore.getState().setTemplate(e,p,s),R=Object.fromEntries(b.PLACEHOLDERS.map(e=>[e.key,`{${e.key}}`])),L=l.LIVE_VENUE_BUILD?{sms:R,email:R}:'order'===p?(0,b.orderVars)({...E,slotTime:`${o}T18:45:00`},s):(0,b.bookingVars)({...C,date:o},s),I=(0,b.toGsm)((0,b.fill)(A.sms,L.sms)),N=(0,b.fill)(A.subject,L.email),_=(0,b.emailHtml)((0,b.fillEmailText)(A.body,L.email),{venue:s.name,preheader:N}),D=!!r?.[p],O=s.settings;return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsx)(h.Banner,{kind:"demo",title:"Preview mode",children:b.PREVIEW_BANNER}),(0,T.jsxs)(h.Muted,{children:["Every booking and takeaway order gets a text (a phone number is needed to book) and an email if they gave one. Edit the wording here. Words in ",'{curly brackets}'," are filled in for each guest."]}),(0,T.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(b.DEFAULT_TEMPLATES).map(e=>(0,T.jsx)(h.Chip,{label:b.TEMPLATE_LABEL[e].title,selected:p===e,onPress:()=>f(e)},e))}),(0,T.jsx)(h.Muted,{children:b.TEMPLATE_LABEL[p].when}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Text message"}),(0,T.jsxs)(h.Muted,{children:[(0,b.smsParts)(I).chars," characters"]})]}),(0,T.jsx)(t.TextInput,{testID:"tpl-sms",accessibilityLabel:"Text message wording",multiline:!0,value:A.sms,onChangeText:e=>B({sms:e}),style:[h.styles.input,{minHeight:96,textAlignVertical:'top'}]}),(0,b.smsParts)(I).chars>300?(0,T.jsx)(h.T,{size:13,colour:y.colours.amber,children:"This is quite long. Under about 300 characters keeps it to two texts."}):null,(0,T.jsx)(h.T,{weight:"semibold",children:"Email subject"}),(0,T.jsx)(t.TextInput,{accessibilityLabel:"Email subject",value:A.subject,onChangeText:e=>B({subject:e}),style:h.styles.input}),(0,T.jsx)(h.T,{weight:"semibold",children:"Email message"}),(0,T.jsx)(t.TextInput,{testID:"tpl-body",accessibilityLabel:"Email wording",multiline:!0,value:A.body,onChangeText:e=>B({body:e}),style:[h.styles.input,{minHeight:220,textAlignVertical:'top'}]}),(0,T.jsxs)(h.Row,{gap:6,style:{flexWrap:'wrap'},children:[j?(0,T.jsx)(h.Button,{small:!0,kind:"secondary",label:"Make it warmer",testID:"tpl-warmer",onPress:()=>B(S(A))}):null,D?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Reset to our wording",onPress:()=>m.useStore.getState().setTemplate(e,p,null)}):null]}),j?(0,T.jsx)(h.Muted,{children:"\u201cMake it warmer\u201d is an on-device wording tool: it rewrites on this device and keeps every detail. Check it reads right before you leave it."}):null,(0,T.jsxs)(h.Muted,{children:["Placeholders: ",b.PLACEHOLDERS.map(e=>`{${e.key}} ${e.what}`).join(' \xb7 ')]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Live preview"}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:"Text",selected:'sms'===P,onPress:()=>M('sms')}),(0,T.jsx)(h.Chip,{label:"Email",selected:'email'===P,onPress:()=>M('email')})]})]}),l.LIVE_VENUE_BUILD?(0,T.jsx)(h.Muted,{children:"Guest fields are filled only from a saved booking or order. This view contains no guest record."}):(0,T.jsxs)(h.Muted,{children:["Sample guest: Alex, ",'order'===p?'3 items, milk intolerance':'4 people tonight, peanut allergy, birthday note',"."]}),'sms'===P?(0,T.jsx)(v,{text:I,to:l.LIVE_VENUE_BUILD?void 0:"07700 900123"}):(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),N]}),(0,T.jsx)(k,{html:_})]})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Bookings that need confirming"}),(0,T.jsx)(h.Muted,{children:"Online bookings above this size wait for you to confirm. The guest gets a \u201cwe\u2019ve got your request\u201d message first, then the confirmation once you accept."}),(0,T.jsx)(h.Stepper,{label:"Auto-accept online bookings up to",value:O.autoAcceptUpTo??7,min:1,max:30,onChange:s=>m.useStore.getState().updateSettings(e,{autoAcceptUpTo:s})}),(0,T.jsx)(h.Toggle,{label:"Also check online bookings with a special request",value:!!O.reviewRequests,onChange:s=>m.useStore.getState().updateSettings(e,{reviewRequests:s})})]}),(0,T.jsxs)(h.Card,{children:[(0,T.jsx)(h.T,{weight:"semibold",children:"Going live"}),(0,T.jsxs)(h.Muted,{children:["Nothing is sent yet. To send real texts and emails: a text service account (for example Twilio) and an email service (for example Postmark), a small CoverCharge server to keep the keys safe, and your sender name (",s.name,") registered. Your venue name, address and phone come from Info & hours."]})]})]})},_e.Outbox=function(){const{rid:e}=(0,w.useCtx)(3e4),t=(0,m.useStore)(e=>e.outbox).filter(s=>s.restaurantId===e),[l,o]=(0,n.useState)('all'),[u,x]=(0,n.useState)(t.find(e=>'email'===e.channel)?.id??null),j=t.filter(e=>'all'===l||e.channel===l);return(0,T.jsxs)(c.default,{style:{gap:10},children:[(0,T.jsxs)(c.default,{testID:"outbox-banner",style:{backgroundColor:(0,s.soutersSurface)('#2a220f'),borderWidth:1,borderColor:y.colours.gold,borderRadius:12,padding:12},children:[(0,T.jsx)(h.T,{weight:"semibold",colour:y.colours.gold,children:(0,b.isLive)()?'Live: messages are sent through your text and email service.':b.PREVIEW_BANNER}),(0,b.isLive)()?null:(0,T.jsx)(h.Muted,{children:"These are exactly the texts and emails your guests would get. Nobody has been sent anything."})]}),(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Chip,{label:`All (${t.length})`,selected:'all'===l,onPress:()=>o('all')}),(0,T.jsx)(h.Chip,{label:`Texts (${t.filter(e=>'sms'===e.channel).length})`,selected:'sms'===l,onPress:()=>o('sms')}),(0,T.jsx)(h.Chip,{label:`Emails (${t.filter(e=>'email'===e.channel).length})`,selected:'email'===l,onPress:()=>o('email')})]}),j.length?null:(0,T.jsx)(h.Muted,{children:"No messages yet. Make a booking or a takeaway order and its confirmation appears here."}),j.map(e=>(0,T.jsxs)(h.Card,{children:[(0,T.jsxs)(r.default,{accessibilityRole:"button",onPress:()=>x(u===e.id?null:e.id),style:{gap:4},children:[(0,T.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,T.jsxs)(h.Row,{gap:6,children:[(0,T.jsx)(h.Badge,{kind:'sms'===e.channel?'blue':'gold',label:'sms'===e.channel?'Text':'Email'}),(0,T.jsxs)(h.T,{weight:"semibold",children:[P[e.kind]," \xb7 ",e.ref]})]}),(0,T.jsx)(h.Muted,{children:e.at.slice(11,16)})]}),(0,T.jsxs)(h.Muted,{children:["To ",e.toName,", ",e.to]}),(0,T.jsx)(h.T,{size:13,colour:'sent'===e.status?y.colours.ok:'failed'===e.status?y.colours.red:y.colours.amber,children:(0,b.statusLabel)(e)})]}),'sms'===e.channel?(0,T.jsx)(v,{text:e.body}):u===e.id?(0,T.jsxs)(c.default,{style:{gap:6},children:[(0,T.jsxs)(h.T,{size:14,children:[(0,T.jsx)(h.T,{size:14,colour:y.colours.muted,children:"Subject: "}),e.subject]}),(0,T.jsx)(k,{html:e.html??'',height:560})]}):(0,T.jsxs)(h.Muted,{numberOfLines:1,children:["Subject: ",e.subject," (tap to preview)"]})]},e.id)),t.length?(0,T.jsx)(h.Button,{small:!0,kind:"ghost",label:"Clear the Outbox",onPress:()=>m.useStore.getState().clearOutbox(e)}):null]})};var s=_r(d[0]),t=_r(d[1]),l=_r(d[2]),n=_r(d[3]),o=e(n);_r(d[4]);var r=e(_r(d[5])),c=e(_r(d[6])),h=_r(d[7]),u=_r(d[8]),m=_r(d[9]),x=_r(d[10]),b=_r(d[11]),j=_r(d[12]),p=_r(d[13]),y=_r(d[14]),f=_r(d[15]),w=_r(d[16]),T=_r(d[17]);function k({html:e,height:s=520}){return o.default.createElement('iframe',{srcDoc:e,title:'Email preview',sandbox:'',style:{width:'100%',height:s,border:'1px solid #2a2a2a',borderRadius:12,background:'#f4efe6'}})}function v({text:e,to:t}){const l=(0,b.smsParts)(e);return(0,T.jsxs)(c.default,{style:{gap:4},children:[t?(0,T.jsxs)(h.Muted,{children:["To ",t]}):null,(0,T.jsx)(c.default,{style:{alignSelf:'flex-start',maxWidth:420,backgroundColor:(0,s.soutersSurface)('#1f1f22'),borderRadius:18,borderBottomLeftRadius:4,padding:12,borderWidth:1,borderColor:'#2c2c30'},children:(0,T.jsx)(h.T,{size:15,children:e})}),(0,T.jsxs)(h.Muted,{children:[l.chars," characters \xb7 ",l.parts," text",1===l.parts?'':'s',l.unicode?' (special characters make texts shorter)':'']})]})}const C={name:'Alex Morgan',partySize:4,date:'',time:'19:30',ref:'B-1042',allergies:[{allergen:'peanuts',severity:'allergy'}],notes:'It\u2019s my mum\u2019s birthday',table:void 0},E={customerName:'Alex Morgan',ref:'T-2093',total:3150,slotTime:void 0,readyBy:void 0,allergies:[{allergen:'milk',severity:'intolerance'}],lines:[{qty:2,name:'Fish and chips',choices:[]},{qty:1,name:'Sticky toffee pudding',choices:[]}]};function S(e){const s=e.sms.replace(/^Hi \{first\},/,'Hi {first}, lovely news!').replace(/See you soon,/,'We can\u2019t wait to see you,');let t=e.body;return/can\u2019t wait/.test(t)||(t=t.replace(/(Hi \{first\},\n\n)/,'$1We\u2019re so glad you chose us. ')),t=t.replace(/Warm wishes,/,'With very warm wishes from all of us,'),{sms:s,subject:e.subject,body:t}}const P={'booking-confirmation':'Booking confirmation','booking-request':'Request received','booking-declined':'Request declined','order-confirmation':'Takeaway order',test:'Test'}},1517,[828,827,837,34,236,402,102,794,1238,874,1498,864,1240,1048,821,1057,1088,25]); +__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.OrderSheetSettings=function(){const e=(0,i.useOwner)(e=>e.site),u=(0,o.useSheets)(e),[c,m]=(0,l.useState)(null);return c?(0,p.jsxs)(s.Card,{children:[(0,p.jsx)(s.T,{weight:"semibold",children:u.some(e=>e.id===c.id)?`Edit ${c.name}`:'New supplier'}),(0,p.jsx)(x,{rid:e,s:c,onDone:()=>m(null)})]}):(0,p.jsxs)(n.default,{style:{gap:10},testID:"order-sheet-settings",children:[(0,p.jsx)(s.Banner,{kind:"info",title:"Used by the Head Chef app",children:"Each supplier gets an order sheet in Head Chef \u203a Ordering. Text, WhatsApp and phone orders open the phone\u2019s own app with the order written out, and the chef presses Send. Nothing is sent automatically."}),u.map(e=>(0,p.jsx)(t.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${e.name}`,onPress:()=>m(e),children:(0,p.jsxs)(s.Card,{children:[(0,p.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(s.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,p.jsx)(s.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':h.METHOD_LABEL[e.method]})]}),(0,p.jsx)(s.Muted,{children:[e.goods,e.deliveryDays.length?`delivers ${(0,h.dayRange)(e.deliveryDays)}`:'',e.orderDays.length?`order ${(0,h.dayRange)(e.orderDays)}`:'',e.frequency,e.priceCapPerKg?`cap ${(0,d.gbp)(e.priceCapPerKg)}/kg`:''].filter(Boolean).join(' \xb7 ')}),'text'!==e.method&&'whatsapp'!==e.method&&'phone'!==e.method||e.number?null:(0,p.jsx)(s.Muted,{children:"Number not added yet"}),'online'!==e.method||e.url?null:(0,p.jsx)(s.Muted,{children:"Link not added yet"})]})},e.id)),(0,p.jsx)(s.Row,{wrap:!0,gap:8,children:(0,p.jsx)(s.Button,{label:"Add supplier",testID:"sheet-add",onPress:()=>m({id:(0,h.sid)(),name:'',goods:'',method:'text',number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:''})})})]})};var l=r(_d[0]),t=e(r(_d[1])),n=e(r(_d[2])),s=r(_d[3]),i=r(_d[4]),o=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),p=r(_d[9]);const c=['online','phone','text','whatsapp','tbc'];function m({label:e,value:l,onChange:t}){return(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:e}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:h.DAY3.map((e,n)=>(0,p.jsx)(s.Chip,{label:e,selected:l.includes(n),onPress:()=>t(l.includes(n)?l.filter(e=>e!==n):[...l,n].sort())},e))})]})}function x({rid:e,s:t,onDone:i}){const d=(0,o.useOrderSheets)(e=>e.upsert),x=(0,o.useOrderSheets)(e=>e.remove),[b,f]=(0,l.useState)(t),[j,y]=(0,l.useState)(t.items.map(e=>`${e.name}${e.unit?` | ${e.unit}`:''}`).join('\n')),[C,v]=(0,l.useState)(t.priceCapPerKg?(t.priceCapPerKg/100).toFixed(2):''),[w,T]=(0,l.useState)(!1),D=e=>f(l=>({...l,...e}));return(0,p.jsxs)(n.default,{testID:"sheet-editor",style:{gap:10,width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,p.jsx)(s.Field,{label:"Supplier name",value:b.name,onChangeText:e=>D({name:e})}),(0,p.jsx)(s.Field,{label:"What they supply",value:b.goods,onChangeText:e=>D({goods:e})}),(0,p.jsxs)(n.default,{style:{gap:4},children:[(0,p.jsx)(s.T,{size:14,weight:"medium",colour:u.colours.muted,children:"How to order"}),(0,p.jsx)(s.Row,{wrap:!0,gap:6,children:c.map(e=>(0,p.jsx)(s.Chip,{label:h.METHOD_LABEL[e],selected:b.method===e,onPress:()=>D({method:e})},e))})]}),'text'===b.method||'whatsapp'===b.method||'phone'===b.method?(0,p.jsx)(s.Field,{label:"Number (can be left blank for the chef to fill in)",value:b.number,keyboardType:"phone-pad",onChangeText:e=>D({number:e})}):null,'online'===b.method?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(s.Field,{label:"Ordering website link (can be left blank)",value:b.url,autoCapitalize:"none",keyboardType:"url",onChangeText:e=>D({url:e.trim()})}),(0,p.jsx)(s.Field,{label:"Button label",value:b.urlLabel??'',placeholder:"Open website",onChangeText:e=>D({urlLabel:e})})]}):null,(0,p.jsx)(s.Field,{label:"Contact first name for the message (optional)",value:b.contact??'',onChangeText:e=>D({contact:e})}),(0,p.jsx)(m,{label:"Delivery days",value:b.deliveryDays,onChange:e=>D({deliveryDays:e})}),(0,p.jsx)(m,{label:"Order days (a reminder shows in the Head Chef app)",value:b.orderDays,onChange:e=>D({orderDays:e})}),(0,p.jsxs)(s.Row,{gap:10,children:[(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Cut-off (HH:MM, optional)",value:b.cutoff,placeholder:"e.g. 14:00",onChangeText:e=>D({cutoff:e})})}),(0,p.jsx)(n.default,{style:{flex:1},children:(0,p.jsx)(s.Field,{label:"Price cap \xa3/kg (optional)",value:C,keyboardType:"decimal-pad",onChangeText:v})})]}),(0,p.jsx)(s.Field,{label:"Reminder text (optional)",value:b.reminder,onChangeText:e=>D({reminder:e})}),(0,p.jsx)(s.Field,{label:"How often (e.g. Weekly or fortnightly)",value:b.frequency,onChangeText:e=>D({frequency:e})}),b.priceCapPerKg||C?(0,p.jsx)(s.Field,{label:"Seller",value:b.seller,onChangeText:e=>D({seller:e})}):null,(0,p.jsx)(s.Field,{label:"Items, one per line (name | unit)",value:j,multiline:!0,style:{minHeight:90},onChangeText:y}),(0,p.jsx)(s.Field,{label:"Notes for the chef",value:b.notes,multiline:!0,onChangeText:e=>D({notes:e})}),(0,p.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,p.jsx)(s.Button,{label:"Save supplier",testID:"sheet-save",onPress:()=>{const l=j.split('\n').map(e=>e.trim()).filter(Boolean).map((e,l)=>{const[n,s]=e.split('|').map(e=>e.trim()),i=t.items.find(e=>e.name===n);return{id:i?.id??`${b.id}-i${l}-${Date.now().toString(36)}`,name:n,unit:s??''}}),n=Math.round(100*parseFloat(C.replace(/[\xa3,]/g,'')));d(e,{...b,items:l,priceCapPerKg:n>0?n:0,placeholder:b.placeholder&&'tbc'===b.method}),i()},disabled:!b.name.trim()}),(0,p.jsx)(s.Button,{kind:"ghost",label:"Cancel",onPress:i}),w?(0,p.jsx)(s.Button,{kind:"danger",label:"Yes, remove",onPress:()=>{x(e,t.id),i()}}):(0,p.jsx)(s.Button,{kind:"ghost",label:"Remove from list",onPress:()=>T(!0)})]})]})}},1518,[34,402,102,794,891,1031,867,1032,821,25]); +__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.DisplaySaverSettings=function(){const{rid:e,me:s}=(0,v.useCtx)(6e4),u=s.replace(' (example)','');(0,f.useSync)(e=>e.venueId);const x=(0,b.saverConnected)(),R=!x||(0,f.can)('venue.settings'),D=(0,b.useSaverSync)(),[k,M]=(0,t.useState)(D??p.SAVER_DEFAULT),[C,T]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[L,E]=(0,t.useState)(null);(0,t.useEffect)(()=>{C||M(D??p.SAVER_DEFAULT)},[D]);const O=e=>{R&&(M(t=>({...t,...e})),T(!0),E(null))},_=async()=>{P(!0);try{await(0,b.saveSaver)(k,u),T(!1),E({kind:'success',t:x?'Saved. The Display changes within a few seconds; no need to pair it again.':'Saved on this device (demo).'})}catch(e){E({kind:'danger',t:`Couldn't save: ${e.message}`})}finally{P(!1)}},{width:$}=(0,l.default)(),U=Math.min($-48,520),A=Math.round(10*U/16);return(0,j.jsxs)(n.default,{style:{gap:14,width:'100%',maxWidth:640,alignSelf:'center'},testID:"saver-settings",children:[(0,j.jsx)(i.T,{center:!0,size:22,weight:"semibold",colour:c.colours.gold,accessibilityRole:"header",children:"Display screensaver"}),(0,j.jsx)(i.Muted,{center:!0,children:"What the Display shows when nobody has touched it for a while. Tap anywhere on the Display to wake it; that tap doesn\u2019t press anything."}),R?null:(0,j.jsx)(i.Banner,{kind:"info",title:"Managers and owners only",children:"You can see the screensaver settings, but only a manager or owner can change them."}),!D&&x?(0,j.jsx)(i.Muted,{center:!0,children:"Not set yet: the Display shows your logo after the idle time set on that Display."}):null,(0,j.jsx)(i.Card,{children:(0,j.jsx)(i.Toggle,{label:"Screensaver on",value:k.on,onChange:e=>O({on:e}),testID:"saver-on",a11y:"Screensaver on or off"})}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Start after"}),(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:p.IDLE_OPTIONS.map(e=>(0,j.jsx)(i.Chip,{label:e.label,selected:k.idleMins===e.mins,disabled:!k.on,onPress:()=>O({idleMins:e.mins}),testID:`saver-idle-${e.mins}`,accessibilityLabel:e.mins?`Start after ${e.mins} minutes with no touches`:'Never start the screensaver'},e.mins))}),(0,j.jsx)(i.Muted,{center:!0,children:k.on?k.idleMins?`Starts after ${k.idleMins} minutes with no touches.`:'Never: the Display stays on the board.':'Off: the Display never goes to the screensaver.'})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Style"}),(0,j.jsx)(n.default,{accessibilityRole:"radiogroup",style:{gap:8},children:p.SAVER_STYLES.map(e=>{const t=k.style===e.id;return(0,j.jsxs)(o.default,{testID:`saver-style-${e.id}`,onPress:()=>O({style:e.id}),disabled:!R,accessibilityRole:"radio",accessibilityState:{checked:t,disabled:!R},accessibilityLabel:`${e.label}. ${e.sub}`,style:{minHeight:64,borderRadius:14,borderWidth:2,borderColor:t?c.colours.gold:c.colours.border,backgroundColor:t?'rgba(201,162,74,0.12)':'transparent',paddingVertical:10,paddingHorizontal:14,alignItems:'center',justifyContent:'center'},children:[(0,j.jsxs)(i.T,{center:!0,weight:"semibold",colour:t?c.colours.gold:c.colours.text,children:[t?'\u25cf ':'\u25cb ',e.label]}),(0,j.jsx)(i.Muted,{center:!0,children:e.sub})]},e.id)})})]}),(0,j.jsx)(S,{rid:e,c:k,set:O,editor:R,connected:x,onMsg:E}),'photos'===k.style?(0,j.jsx)(w,{c:k,set:O,editor:R,connected:x,onMsg:E}):null,(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.Toggle,{label:"Dim at night",value:k.dimOn,onChange:e=>O({dimOn:e}),testID:"saver-dim",a11y:"Dim the screensaver at night"}),k.dimOn?(0,j.jsxs)(n.default,{style:{gap:8,alignItems:'center'},children:[(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"From"}),(0,j.jsx)(i.Stepper,{label:"Dim from",value:(0,y.toMins)(k.dimFrom),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimFrom:(0,y.fromMins)(e)}),testID:"saver-dim-from"})]}),(0,j.jsxs)(i.Row,{gap:10,style:{justifyContent:'center'},children:[(0,j.jsx)(i.T,{children:"Until"}),(0,j.jsx)(i.Stepper,{label:"Dim until",value:(0,y.toMins)(k.dimTo),min:0,max:1410,step:30,format:y.fromMins,onChange:e=>O({dimTo:(0,y.fromMins)(e)}),testID:"saver-dim-to"})]})]}):null,(0,j.jsxs)(i.Muted,{center:!0,children:[(0,p.dimWords)(k),". The screensaver is shown much darker between these times."]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Preview"}),(0,j.jsx)(n.default,{style:{alignItems:'center'},testID:"saver-preview",accessibilityLabel:"Preview of the screensaver",children:(0,j.jsx)(n.default,{style:{width:U,height:A,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:c.colours.border},children:k.on?(0,j.jsx)(h.Saver,{rid:e,cfg:k,box:{width:U,height:A}},`${k.style}-${k.photos.length}-${k.logo??''}`):(0,j.jsx)(n.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,j.jsx)(i.Muted,{center:!0,children:"Screensaver off"})})})})]}),L?(0,j.jsx)(i.Banner,{kind:L.kind,children:L.t}):null,R?(0,j.jsx)(i.Button,{label:I?'Saving\u2026':C?'Save screensaver':'Saved',disabled:I||!C,onPress:()=>{_()},testID:"saver-save"}):null]})};var t=r(d[0]),s=e(t);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),l=e(r(d[4])),i=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),v=r(d[13]),j=r(d[14]);const x='undefined'!=typeof document;function w({c:e,set:o,editor:l,connected:h,onMsg:u}){const y=(0,t.useRef)(null),[f,v]=(0,t.useState)(!1),[w,S]=(0,t.useState)({});(0,t.useEffect)(()=>{let t=!0;return Promise.all(e.photos.map(async e=>[e,await(0,b.saverPhotoUrl)(e)])).then(e=>{t&&S(Object.fromEntries(e.filter(e=>e[1])))}),()=>{t=!1}},[e.photos.join('|')]);const R=async t=>{if(t?.length){v(!0);try{const s=[];for(const o of Array.from(t).slice(0,p.MAX_SAVER_PHOTOS-e.photos.length))s.push(h?await(0,b.uploadSaverPhoto)(o,e.photos.length+s.length):URL.createObjectURL(o));o({photos:[...e.photos,...s]}),u({kind:'success',t:`${s.length} photo${1===s.length?'':'s'} added. Tap Save screensaver to show ${1===s.length?'it':'them'} on the Display.`})}catch(e){u({kind:'danger',t:e.message})}finally{v(!1),y.current&&(y.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Slideshow photos"}),(0,j.jsxs)(i.Muted,{center:!0,children:["Your own photos of the venue, food and team, one every 8 seconds. Up to ",p.MAX_SAVER_PHOTOS,". With no photos the Display shows your logo."]}),e.photos.length?(0,j.jsx)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:e.photos.map((t,h)=>(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:4},children:[w[t]&&x?s.default.createElement('img',{src:w[t],alt:`Slideshow photo ${h+1}`,style:{width:96,height:64,objectFit:'cover',borderRadius:8}}):(0,j.jsx)(n.default,{style:{width:96,height:64,borderRadius:8,backgroundColor:c.colours.border}}),l?(0,j.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove photo ${h+1} from the slideshow`,onPress:()=>o({photos:e.photos.filter(e=>e!==t)})}):null]},t))}):(0,j.jsx)(i.Muted,{center:!0,children:"No photos yet."}),l?(0,j.jsx)(i.Button,{kind:"secondary",label:f?'Uploading\u2026':'Upload photos',disabled:f||e.photos.length>=p.MAX_SAVER_PHOTOS,onPress:()=>{x&&y.current?.click()},testID:"saver-upload",accessibilityLabel:"Upload photos for the slideshow"}):null,x?s.default.createElement('input',{ref:y,type:'file',accept:'image/jpeg,image/png,image/webp',multiple:!0,style:{display:'none'},'aria-hidden':!0,onChange:e=>{R(e.target.files)}}):null,(0,j.jsx)(i.Muted,{center:!0,children:"Removing a photo takes it off the slideshow; the file itself is kept."})]})}function S({rid:e,c:o,set:l,editor:y,connected:f,onMsg:v}){const w=(0,t.useRef)(null),[S,R]=(0,t.useState)(!1),[D,k]=(0,t.useState)(!1),M=(0,u.useBrand)(e).name,C=!!o.logo,T=async e=>{const t=e?.[0];if(t){R(!0);try{let e;if(f)e=await(0,b.uploadSaverLogo)(t);else{const s=(0,p.logoFileProblem)(t.type,t.size);if(s)throw new Error(s);if('image/svg+xml'===t.type&&!(0,p.svgSafe)(await t.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');e=URL.createObjectURL(t)}l({logo:e}),v({kind:'success',t:(C?'New logo ready':'Logo uploaded')+". Tap Save screensaver to show it on the Display."})}catch(e){v({kind:'danger',t:e.message})}finally{R(!1),w.current&&(w.current.value='')}}};return(0,j.jsxs)(i.Card,{children:[(0,j.jsxs)(n.default,{style:{alignItems:'center',gap:10},testID:"saver-logo-card",children:[(0,j.jsx)(i.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Screensaver logo"}),(0,j.jsx)(i.Muted,{center:!0,children:'logo'===o.style?'Shown drifting slowly round the Display.':'Shown with the Logo style, and small on the clock and covers screens.'}),(0,j.jsx)(n.default,{style:{minWidth:132,maxWidth:240,height:132,paddingHorizontal:12,borderRadius:14,backgroundColor:'#000000',borderWidth:1,borderColor:c.colours.border,alignItems:'center',justifyContent:'center'},accessible:!0,accessibilityLabel:C?'Your uploaded logo':`Your standard logo, ${M}`,children:(0,j.jsx)(h.SaverLogoPreview,{rid:e,path:o.logo,size:108})}),(0,j.jsx)(i.Muted,{center:!0,children:C?'Your uploaded logo':'Your standard logo'}),y?(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:C?'secondary':'primary',label:S?'Uploading\u2026':C?'Replace logo':'Upload logo',disabled:S,onPress:()=>{x&&w.current?.click()},testID:"saver-logo-upload",accessibilityLabel:C?'Replace the screensaver logo':'Upload a logo for the screensaver'}),C?(0,j.jsx)(i.Button,{kind:"ghost",label:"Remove",disabled:S,onPress:()=>k(!0),testID:"saver-logo-remove",accessibilityLabel:"Remove the uploaded logo and go back to the standard one"}):null]}):null,(0,j.jsx)(i.Muted,{center:!0,children:"PNG, JPG or SVG, up to 2 MB (an SVG is saved as a picture). A square logo on a transparent or black background looks best."})]}),x?s.default.createElement('input',{ref:w,type:'file',accept:Object.keys(p.LOGO_TYPES).join(','),style:{display:'none'},'aria-hidden':!0,onChange:e=>{T(e.target.files)}}):null,D?(0,j.jsx)(i.Sheet,{visible:!0,onClose:()=>k(!1),title:"Remove the uploaded logo?",maxWidth:520,testID:"saver-logo-remove-confirm",children:(0,j.jsxs)(n.default,{style:{gap:12,alignItems:'center'},children:[(0,j.jsx)(i.Muted,{center:!0,children:"The screensaver goes back to your standard logo once you save. The uploaded file is kept, and the standard logo isn\u2019t changed."}),(0,j.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,j.jsx)(i.Button,{kind:"secondary",label:"Keep it",onPress:()=>k(!1),testID:"saver-logo-remove-no"}),(0,j.jsx)(i.Button,{kind:"danger",label:"Remove logo",onPress:()=>{l({logo:null}),k(!1),v({kind:'success',t:'Logo removed. Tap Save screensaver to go back to the standard logo on the Display.'})},testID:"saver-logo-remove-yes"})]})]})}):null]})}},1519,[34,236,402,102,426,794,821,1376,873,1378,858,987,1379,1088,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1520,[835,984,1457,34,236,102,794,831,891,983,1031,985,987,1521,821,2,1182,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1521,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableQrPage=function(){const{rid:e,me:t}=(0,h.useCtx)(6e4),b=t.replace(' (example)','');return(0,u.jsxs)(s.default,{style:{gap:14,width:'100%',maxWidth:760,alignSelf:'center'},testID:"table-qr-page",children:[(0,u.jsx)(l.T,{center:!0,size:22,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Table QR codes"}),(0,u.jsx)(l.Muted,{center:!0,children:"Guests scan the code on their table, see the menu and send their order to the kitchen. They pay at the bar or with their server."}),(0,u.jsx)(c.TableOrderSettings,{rid:e,me:b}),(0,u.jsx)(l.T,{center:!0,size:20,weight:"semibold",colour:o.colours.gold,accessibilityRole:"header",children:"Orders from the tables"}),(0,u.jsx)(n.StaffTableOrders,{rid:e,me:b})]})},r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),n=r(d[5]),h=r(d[6]),u=r(d[7])},1522,[34,102,794,821,1438,1511,1088,25]); +__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.showMe=j,_e.HelpPage=function({go:e}){const[s,a]=(0,n.useState)(''),[r,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),j=(0,n.useMemo)(()=>s.trim()?(0,u.searchHelp)(c.HELP,s,10).map(e=>e.a):c.HELP.filter(e=>!r||e.topic===r),[s,r]);return(0,f.jsxs)(o.default,{style:{gap:10},testID:"help-page",children:[(0,f.jsxs)(o.default,{style:[i.styles.input,{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:4}],children:[(0,f.jsx)(i.T,{colour:x.colours.muted,children:"\ud83d\udd0d"}),(0,f.jsx)(t.TextInput,{testID:"help-search",value:s,onChangeText:a,placeholder:"Search help",placeholderTextColor:"#7D776C",accessibilityLabel:"Search help",style:{flex:1,minWidth:0,width:0,boxSizing:'border-box',color:x.colours.text,paddingVertical:8,fontSize:16,outlineStyle:'none'}}),s?(0,f.jsx)(l.GoldClose,{testID:"help-search-clear",size:"sm",label:"Clear search",onPress:()=>a('')}):null]}),(0,f.jsx)(b,{go:e}),s?(0,f.jsx)(i.Muted,{children:j.length?`${j.length} result${1===j.length?'':'s'} for \u201c${s.trim()}\u201d`:`Nothing for \u201c${s.trim()}\u201d. Try other words, or ask the Assistant above.`}):(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[null,...c.HELP_TOPICS].map(e=>(0,f.jsx)(i.Chip,{label:e??'All',selected:r===e,onPress:()=>h(e)},e??'all'))}),j.map((t,l)=>(0,f.jsx)(y,{a:t,go:e,open:p===t.id||!!s&&0===l&&null===p,onToggle:()=>m(p===t.id?'':t.id)},t.id)),(0,f.jsxs)(i.Card,{style:{alignItems:'center'},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",colour:x.colours.gold,children:"Chat with CoverCharge support"}),(0,f.jsx)(i.Muted,{center:!0,children:"Send a message to the CoverCharge team. Nobody replies automatically."}),(0,f.jsx)(i.Button,{label:"Open the chat",accessibilityLabel:"Open the chat with CoverCharge support",onPress:()=>e('more','support')})]})]})},_e.AskAssistant=b;var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),n=_r(d[3]),a=e(_r(d[4])),o=e(_r(d[5])),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),p=_r(d[11]),x=_r(d[12]),m=_r(d[13]),f=_r(d[14]);function j(e,t){e.showMe&&(t(e.showMe.tab,e.showMe.page??null),setTimeout(()=>h.useCoach.getState().show(e.showMe.target,e.showMe.hint),300))}function y({a:e,go:t,open:s,onToggle:l}){return(0,f.jsx)(o.default,{testID:`help-${e.id}`,children:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(a.default,{accessibilityRole:"button",onPress:l,children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},gap:8,children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:e.title}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:'guide'===e.kind?'gold':'neutral',label:'guide'===e.kind?'Step by step':'FAQ'}),(0,f.jsx)(i.Muted,{size:12,children:e.topic})]})]}),(0,f.jsx)(i.T,{colour:x.colours.muted,children:s?'\u25be':'\u203a'})]})}),s?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{children:e.body}),e.steps?.map((e,t)=>(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,f.jsx)(o.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{size:12,weight:"bold",colour:"#1A1408",children:t+1})}),(0,f.jsx)(i.T,{style:{flex:1},children:e})]},t))]}):null,e.showMe?(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",testID:`showme-${e.id}`,onPress:()=>j(e,t)})}):null]})})}function b({go:e}){const{rid:t,today:s}=(0,m.useCtx)(6e4),l={rid:t,today:s,go:(t,s)=>e(t,s??null)},[a,r]=(0,n.useState)(''),[h,u]=(0,n.useState)(null),[y,b]=(0,n.useState)(null),k=async()=>{const e=a.trim();if(!e)return;b(null),u(null);const t=(0,p.matchIntent)(e,s);if('action'!==t.kind)'help'!==t.kind?b({text:'Sorry, I didn\u2019t follow that. Try \u201cadd a walk-in for 4 at table 7\u201d, \u201cput Ellie on Friday 5 till 11\u201d, or ask \u201chow do I export hours?\u201d.',kind:'note'}):b({text:'Here\u2019s what I found. Tap Show me and I\u2019ll point to it.',kind:'note',help:t.ids});else{if(!(0,p.needsConfirm)(t.action.risk)){const e=await(0,p.runAction)(t.action.id,t.params,l);return void b({text:'done'===e.status?e.message:e.message??'',kind:'done'})}u({action:t.action,params:{...w(t.action,s),...t.params},asked:e})}};return(0,f.jsx)(o.default,{testID:"ask-assistant",children:(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(o.default,{style:{width:28,height:28,borderRadius:14,backgroundColor:x.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(i.T,{weight:"bold",colour:"#1A1408",children:"\u2726"})}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:"Ask the Assistant"})]}),(0,f.jsxs)(o.default,{testID:"help-assistant-stack",style:{gap:8,width:'100%',minWidth:0},children:[(0,f.jsx)(i.Field,{label:"Ask or tell it what to do",testID:"assistant-input",value:a,onChangeText:r,placeholder:"Ask in plain words",onSubmitEditing:k,returnKeyType:"send",style:{width:'100%',minWidth:0,boxSizing:'border-box'}}),(0,f.jsx)(i.Button,{label:"Ask",testID:"assistant-ask",disabled:!a.trim(),onPress:k,style:{width:'100%',minWidth:0,minHeight:52}})]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:['Add a walk-in for 4 at table 7','Put a shift on Friday 5 till 11','How do I export hours for payroll?','Pay out the tips'].map(e=>(0,f.jsx)(i.Chip,{label:e,onPress:()=>r(e)},e))}),h?(0,f.jsx)(C,{p:h,today:s,onChange:e=>u({...h,params:e}),onConfirm:async()=>{if(!h)return;const e=await(0,p.runAction)(h.action.id,h.params,l,!0);u(null),r(''),b('done'===e.status?{text:e.message,kind:'done'}:'demo_only'===e.status?{text:e.message,kind:'demo'}:{text:e.message??'Couldn\u2019t do that.',kind:'error'})},onCancel:()=>{u(null),b({text:'Cancelled. Nothing was changed.',kind:'note'})}}):null,y?(0,f.jsxs)(o.default,{style:{gap:6},testID:"assistant-reply",children:[(0,f.jsx)(i.Banner,{kind:'done'===y.kind?'success':'error'===y.kind?'warn':'demo'===y.kind?'demo':'info',title:y.text}),y.help?.map(t=>{const s=(0,c.helpById)(t);return(0,f.jsxs)(i.Row,{gap:6,style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{style:{flex:1},children:s.title}),s.showMe?(0,f.jsx)(i.Button,{small:!0,kind:"success",label:"Show me",onPress:()=>j(s,e)}):null]},t)})]}):null,(0,f.jsx)(i.Muted,{size:12,children:"It shows you what it will do and waits for your tap. It never sends, pays or deletes anything."})]})})}function w(e,t){return'add_rota_shift'===e.id?{date:t,start:17,end:23}:'add_walkin'===e.id?{covers:2}:{}}function C({p:e,today:t,onChange:l,onConfirm:n,onCancel:a}){const h=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),c=(0,p.demoOnly)(e.action.risk),u=(t,s)=>l({...e.params,[t]:s}),m=e.action,j=e.params,y=m.params.every(e=>!e.required||void 0!==j[e.name]&&''!==j[e.name]);return(0,f.jsxs)(o.default,{testID:"assistant-confirm",style:{borderWidth:2,borderColor:c?x.colours.red:x.colours.ok,borderRadius:14,padding:12,gap:8,backgroundColor:c?'#2a1010':x.colours.okBg},children:[(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Badge,{kind:c?'red':'ok',label:p.RISK_LABEL[m.risk]}),(0,f.jsx)(i.T,{weight:"semibold",style:{flex:1},children:m.title})]}),m.form&&'add_walkin'===m.id?(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Covers",value:void 0===j.covers?'':String(j.covers),onChangeText:e=>u('covers',e.replace(/\D/g,'')?Number(e.replace(/\D/g,'')):void 0),keyboardType:"number-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Table (optional)",value:void 0===j.table?'':String(j.table),onChangeText:e=>u('table',e.trim()?e.trim().toUpperCase():void 0)})})]}):null,m.form&&'add_rota_shift'===m.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsx)(i.Muted,{size:12,children:"Who"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:h.slice(0,14).map(e=>(0,f.jsx)(i.Chip,{label:e.name.replace(' (example)','').split(' ')[0],selected:j.staffId===e.id,onPress:()=>u('staffId',e.id)},e.id))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(o.default,{style:{flex:1.3},children:(0,f.jsx)(i.Field,{label:"Date (DD/MM/YYYY)",...(0,s.slashBox)(String(j.date??t),e=>u('date',e)),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"Start (24h)",value:String(j.start??''),onChangeText:e=>u('start',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})}),(0,f.jsx)(o.default,{style:{flex:1},children:(0,f.jsx)(i.Field,{label:"End (24h)",value:String(j.end??''),onChangeText:e=>u('end',''===e?void 0:Number(e)),keyboardType:"decimal-pad"})})]})]}):null,(0,f.jsx)(i.T,{children:y?m.preview(j,{rid:'',today:t,go:()=>{}}):'Fill in the missing details above.'}),c?(0,f.jsx)(i.Muted,{children:"This Assistant does not send, pay or delete. Confirm only shows what would happen."}):(0,f.jsx)(i.Muted,{children:"Nothing happens until you tap Confirm."}),(0,f.jsxs)(i.Row,{gap:8,children:[(0,f.jsx)(i.Button,{kind:c?'danger':'success',label:c?'Confirm (nothing is sent)':'Confirm',testID:"assistant-confirm-yes",disabled:!y,onPress:n,style:{flex:1}}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Cancel",onPress:a,style:{flex:1}})]})]})}},1523,[827,1063,796,34,402,102,794,891,1473,1524,1525,1526,821,1088,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1524,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1525,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1526,[1527,1128,860,1528,1529,891,874,1029,1473,1524,1525,1531,1530,1533,1534,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1527,[1093,1092,1053]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1528,[984,1128,835,860,874,831,1029,983,985,1040,891,1095,882,863,861]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1529,[835,874,831,1029,891,1034,1044,1045,1010,1009,1039,13,1064,1065,1066,1035,1095,882,1105,1026,870,1530,1528]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1530,[835,979,1128,860,1161,1271,874,831,1029,1034,995,862,861,1105,1106,1026,1035,867,1531,1532]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1531,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1532,[839,846,849]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1533,[831,891,995,867,1530,1047,1098]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1534,[]); +__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.VoiceSettingsPage=function(){const{rid:e,r:s,now:t}=(0,f.useCtx)(6e4),o=(0,p.useVoiceSettings)();return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Hold to talk",children:"Staff hold the gold button, say what they need and let go. It sits at the top right in Managers, Head Chef, the Staff app (the full voice assistant, without team financial or HR information) and on the Display (no money, tips or HR either), never in the customer app. Tap it to type or open the Assistant. Replies and change confirmations are shown in text, never spoken. Tap Confirm or Cancel, or say \u201cyes\u201d to confirm. Supplier orders, messages and payments are only saved as drafts for you."}),(0,x.jsx)(c.VoiceUsageCard,{rid:e,now:t}),(0,x.jsxs)(i.Card,{children:[(0,x.jsxs)(i.T,{weight:"semibold",children:["Who gets the voice button at ",s.name]}),(0,x.jsx)(n.default,{style:{gap:6,marginTop:8},children:p.VOICE_ROLES.map(s=>(0,x.jsx)(i.Toggle,{label:p.VOICE_ROLE_LABEL[s],value:(0,p.voiceOn)(o.enabled,e,s),onChange:t=>o.setEnabled(e,s,t)},s))}),(0,x.jsx)(i.Muted,{children:"Saved on this device for now; set it on each device."})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{testID:"voice-text-only",weight:"semibold",children:"The helper replies in text only. It never speaks."}),(0,x.jsx)(i.Row,{gap:8,wrap:!0,style:{marginTop:8},children:(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Show the microphone explanation again",onPress:()=>o.setMicExplained(!1)})})]}),(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{weight:"semibold",children:"Privacy"}),(0,x.jsxs)(i.Muted,{children:["What is said while the button is held (up to 30 seconds) is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio. Each device asks once to use the microphone. ",(0,u.canListen)()?'This device can listen.':'This device can\u2019t listen, so the button offers \u201ctype instead\u201d.']})]})]})},_e.DraftsPage=function(){const{rid:e,me:o,role:h}=(0,f.useCtx)(6e4),p=(0,r.useDrafts)(e=>e.drafts),u=(0,r.useDrafts)(e=>e.decide),c=(0,l.useVoiceNav)(e=>e.go),[j,y]=(0,s.useState)(null),[k,w]=(0,s.useState)(!1),T=p.filter(s=>s.rid===e),B=T.filter(e=>'draft'===e.status),S=T.filter(e=>'draft'!==e.status).slice(0,30),C='owner'===h||'manager'===h,D=e=>e.supplier?d.SUPPLIER_PORTALS.find(s=>s.id===e.supplier):void 0,P=e=>(0,x.jsx)(i.Card,{children:(0,x.jsxs)(n.default,{testID:`draft-${e.id}`,style:{gap:6},children:[(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Badge,{label:r.DRAFT_LABEL[e.kind],kind:"gold"}),'draft'!==e.status?(0,x.jsx)(i.Badge,{label:'approved'===e.status?'Approved':'Dismissed',kind:'approved'===e.status?'ok':'neutral'}):null]}),(0,x.jsx)(i.T,{weight:"semibold",children:e.title}),e.lines.map((s,t)=>(0,x.jsxs)(i.T,{size:15,children:['shopping'===e.kind?'\u2022 ':'',s]},t)),(0,x.jsxs)(i.Muted,{children:["From ",e.by," (",e.app,"), ",b(e.at),e.decidedBy?` \xb7 ${e.status} by ${e.decidedBy}, ${b(e.decidedAt)}`:'']}),'draft'===e.status&&C?(0,x.jsxs)(i.Row,{gap:8,wrap:!0,children:[(0,x.jsx)(i.Button,{small:!0,kind:"success",label:"Approve",testID:`draft-approve-${e.id}`,onPress:()=>y({d:e,status:'approved'})}),(0,x.jsx)(i.Button,{small:!0,kind:"secondary",label:"Dismiss",testID:`draft-dismiss-${e.id}`,onPress:()=>y({d:e,status:'dismissed'})}),D(e)?.links?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:`Open ${D(e).name} ordering`,onPress:()=>{t.default.openURL(D(e).links.order)}}):null]}):null]})},e.id);return(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(i.Banner,{kind:"info",title:"Nothing here has been sent, ordered or paid",children:"The voice helper and the Assistant save bookings, supplier shopping lists, offers, events, specials, messages and payments here for you to check. Approving marks it approved and takes you to the right screen; you still do the booking, the order or the post yourself."}),C?null:(0,x.jsx)(i.Banner,{kind:"warn",title:"Owners and managers approve drafts",children:"You can see the drafts but not approve them."}),B.length?B.map(P):(0,x.jsx)(i.Muted,{children:"No drafts waiting. Try holding the voice button and saying \u201cadd blue roll to the Booker list\u201d."}),S.length?(0,x.jsx)(i.Button,{small:!0,kind:"ghost",label:k?'Hide approved and dismissed':`Show approved and dismissed (${S.length})`,onPress:()=>w(!k)}):null,k?S.map(P):null,(0,x.jsx)(i.Sheet,{visible:!!j,onClose:()=>y(null),title:'approved'===j?.status?'Approve this draft?':'Dismiss this draft?',children:j?(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.T,{weight:"semibold",children:j.d.title}),(0,x.jsx)(i.T,{size:15,children:'approved'===j.status?`This marks it approved${v[j.d.kind]?` and opens ${v[j.d.kind].label}`:''}. Nothing is sent, ordered or paid automatically.`:'It moves to the dismissed list. Nothing is sent.'}),(0,x.jsx)(i.Button,{kind:'approved'===j.status?'success':'danger',label:'approved'===j.status?'Approve':'Dismiss',testID:"draft-confirm",onPress:()=>{u(j.d.id,j.status,o.replace(' (example)',''));const e=v[j.d.kind];y(null),'approved'===j.status&&e&&c&&c(e.tab,e.sub)}}),(0,x.jsx)(i.Button,{kind:"secondary",label:"Back",onPress:()=>y(null)})]}):null})]})},_e.ShiftNotesPage=function(){const{rid:e}=(0,f.useCtx)(6e4),s=(0,h.useShiftNotes)(e=>e.notes).filter(s=>s.rid===e),t=(0,h.useShiftNotes)(e=>e.setDone);return(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(i.Muted,{children:"Notes left for the next shift, by voice (\u201ctell the next shift the glass washer is leaking\u201d) or the Assistant. Kept on this device for now."}),s.length?s.slice(0,60).map(e=>(0,x.jsxs)(i.Card,{children:[(0,x.jsx)(i.T,{style:{textDecorationLine:e.done?'line-through':'none'},colour:e.done?o.colours.muted:o.colours.text,children:e.text}),(0,x.jsxs)(i.Row,{style:{justifyContent:'space-between',marginTop:6},children:[(0,x.jsxs)(i.Muted,{children:[e.by," (",e.app,"), ",b(e.at)]}),(0,x.jsx)(i.Button,{small:!0,kind:e.done?'ghost':'success',label:e.done?'Reopen':'Done',onPress:()=>t(e.id,!e.done)})]})]},e.id)):(0,x.jsx)(i.Muted,{children:"No shift notes yet."})]})};var s=_r(_d[0]),t=e(_r(_d[1])),n=e(_r(_d[2])),i=_r(_d[3]),o=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),h=_r(_d[8]),p=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),f=_r(_d[12]),x=_r(_d[13]);const b=e=>new Date(e).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});const v={booking:{tab:'bookings',sub:null,label:'Bookings'},offer:{tab:'more',sub:'offers',label:'Specials & offers'},event:{tab:'more',sub:'events',label:'Events'},special:{tab:'more',sub:'specialsboard',label:'Specials board'},shopping:{tab:'more',sub:'suppliers',label:'Suppliers'}}},1535,[34,379,102,794,821,1469,1531,1481,1532,1158,931,1490,1088,25]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1536,[34,796,102,794,861,1268,1537,1538,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1537,[861]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1538,[987,1537,1271]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.NightlyReportPage=function(){const{rid:e,r:s,today:v}=(0,y.useCtx)(6e4),f=(0,r.useBookings)(e),S=(0,d.useCashUp)(e=>e.cashUps),k=(0,d.useCashSettings)(e),w=(0,o.useNightlyPrefs)(l=>l.email[e]??!1),T=(0,o.useNightlyPrefs)(e=>e.setEmail),C=(0,c.useSoldOut)(e=>e.entries).filter(l=>l.rid===e&&l.on).map(e=>e.name),[N,P]=(0,l.useState)((0,u.addDaysYmd)(v,-1)),U=(0,u.cashFieldsForRecord)(k.cashFields,s.settings.cashUpRecord),_=(0,h.nightlyReport)({rid:e,date:N,bookings:f,cashUps:S,fields:U,soldOut:C}),D='anchorage'!==e&&w,E=[0,1,2].map(e=>(0,u.addDaysYmd)(v,-e));return(0,j.jsxs)(t.default,{testID:"nightly-report",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,j.jsx)(n.Muted,{center:!0,children:"Spend per head, Covers and the cash-up for one night. Blank means it was not entered."}),(0,j.jsx)(t.default,{style:{width:'100%',gap:8},children:E.map(e=>(0,j.jsx)(n.Button,{kind:e===N?'primary':'secondary',label:e===v?'Today':e===(0,u.addDaysYmd)(v,-1)?'Yesterday':e,accessibilityLabel:`Nightly report for ${e}`,onPress:()=>P(e)},e))}),(0,j.jsxs)(n.Card,{style:{alignItems:'center',width:'100%'},children:[(0,j.jsx)(x,{label:"Spend per head",value:_.spendPerHead}),(0,j.jsx)(x,{label:"Covers",value:String(_.covers)}),(0,j.jsx)(x,{label:"No-shows",value:String(_.noShows)}),(0,j.jsx)(x,{label:"Cancellations",value:String(_.cancellations)}),(0,j.jsx)(x,{label:"Takings",value:_.takings}),(0,j.jsx)(x,{label:"Tips",value:_.tips}),(0,j.jsx)(x,{label:"Takings last week",value:_.lastWeekTakings}),(0,j.jsx)(x,{label:"Busiest hour",value:_.busiestHour}),(0,j.jsx)(x,{label:"Sold out",value:_.soldOut.length?_.soldOut.join(', '):'None recorded'}),(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,style:{marginTop:8},children:"Cash up"}),_.cashUp.length?_.cashUp.map(e=>(0,j.jsx)(x,{label:e.label,value:e.value},e.label)):(0,j.jsx)(n.Muted,{center:!0,children:"No cash-up fields for this venue."})]}),p.RELEASE.nightlyEmail&&'anchorage'!==e?(0,j.jsx)(n.Toggle,{testID:"nightly-email",label:"Also email the nightly report",value:D,onChange:l=>T(e,l)}):null]})};var e,l=_r(_d[0]),s=_r(_d[1]),t=(e=s)&&e.__esModule?e:{default:e},n=_r(_d[2]),r=_r(_d[3]),d=_r(_d[4]),o=_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]),j=_r(_d[12]);const x=({label:e,value:l})=>(0,j.jsxs)(t.default,{accessible:!0,accessibilityLabel:`${e}. ${l}`,style:{width:'100%',alignItems:'center',gap:2,paddingVertical:8},children:[(0,j.jsx)(n.T,{center:!0,weight:"bold",colour:b.colours.gold,children:e}),(0,j.jsx)(n.T,{center:!0,children:l})]})},1539,[34,102,794,874,1039,1540,979,13,1541,1050,821,1088,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useNightlyPrefs",{enumerable:!0,get:function(){return s}});var e,t=r(d[0]),l=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);const s=(0,n.create)()((0,o.persist)(e=>({email:{},setEmail:(t,l)=>e(e=>({email:{...e.email,[t]:'anchorage'!==t&&l}}))}),{name:'covercharge-nightly-email-v1',storage:(0,o.createJSONStorage)(()=>l.default),version:1}))},1540,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nightlyReport=function(o){const{rid:u,date:c,bookings:f,cashUps:p,fields:v,soldOut:h}=o,b=f.filter(t=>t.restaurantId===u&&t.date===c),k=p.find(t=>t.rid===u&&t.date===c&&t.confirmedAt),y=p.find(n=>n.rid===u&&n.date===(0,t.addDaysYmd)(c,-7)&&n.confirmedAt),N=k?(0,t.grossOf)(k.vals)??(0,t.takings)(k.vals):null,O=(0,n.coversOn)(f,u,c),S=null==N||O<=0?null:Math.round(N/O*100)/100,_=new Map;for(const t of b){if(!['seated','finished'].includes(t.status))continue;const n=Number(t.time.slice(0,2));Number.isFinite(n)&&_.set(n,(_.get(n)??0)+(t.partySize||0))}let w=null;for(const[t,n]of _)(!w||n>w.n)&&(w={hour:t,n:n});return{date:c,spendPerHead:s(S),covers:O,noShows:b.filter(t=>'noshow'===t.status).length,cancellations:b.filter(t=>'cancelled'===t.status).length,takings:s(N),tips:s(k?(0,t.combinedTips)(k.vals):null),lastWeekTakings:s(y?(0,t.grossOf)(y.vals)??(0,t.takings)(y.vals):null),busiestHour:w?`${String(w.hour).padStart(2,'0')}:00 \xb7 ${w.n} Covers`:'Not entered',soldOut:h.filter(Boolean),cashUp:v.map(t=>({label:t.label,value:k?l(k.vals[t.key],t.kind):'Not entered'}))}};var t=r(d[0]),n=r(d[1]);const s=t=>null==t?'Not entered':`\xa3${t.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,l=(t,n)=>null==t||''===t?'Not entered':'money'===n&&'number'==typeof t?s(t):String(t)},1541,[13,1507]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SupportChatPage=function(){const{rid:e,me:o,meId:S}=(0,m.useCtx)(6e4),j=(0,u.useSupportChat)(e=>e.messages).filter(t=>t.rid===e),C=(0,u.useSupportChat)(e=>e.send),y=(0,u.useSupportChat)(e=>e.markSent),[f,I]=(0,s.useState)(''),[M,w]=(0,s.useState)(''),T=S===b,v=async e=>{const t=await(0,p.writeSupportMessage)(e);if(t.ok)return y(e.id),void w('');w(t.message||c.SUPPORT_NOT_SENT)};return(0,x.jsxs)(n.default,{testID:"support-chat",style:{gap:12,alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.Muted,{center:!0,children:"A message to the CoverCharge team. Nobody replies automatically."}),M?(0,x.jsx)(l.Muted,{center:!0,testID:"support-note",children:M}):null,j.length?j.map(e=>(0,x.jsxs)(l.Card,{style:{alignItems:'center',width:'100%'},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:e.from}),(0,x.jsx)(l.T,{center:!0,children:e.text}),(0,x.jsxs)(l.Muted,{center:!0,children:[e.sent?'Sent':'Not sent'," \xb7 ",new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]}),e.sent?null:(0,x.jsx)(l.Button,{kind:"ghost",label:"Send again",accessibilityLabel:`Send again: ${e.text}`,onPress:()=>{v(e)}})]},e.id)):(0,x.jsx)(l.Muted,{center:!0,children:"No messages yet."}),(0,x.jsx)(t.TextInput,{testID:"support-draft",accessibilityLabel:"Message to CoverCharge support",value:f,onChangeText:I,placeholder:"Write a message",placeholderTextColor:h.colours.muted,multiline:!0,style:{width:'100%',minHeight:88,borderWidth:1,borderColor:h.colours.border,borderRadius:12,padding:12,color:h.colours.text,textAlign:'center'}}),(0,x.jsx)(l.Button,{testID:"support-send",label:"Send",accessibilityLabel:"Send message to CoverCharge support",disabled:!f.trim(),onPress:()=>{const t=C(e,o||'Manager',S||'',f);t&&(I(''),v(t))}}),T?(0,x.jsxs)(n.default,{testID:"support-inbox",style:{width:'100%',alignItems:'center',gap:8},children:[(0,x.jsx)(l.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Support inbox"}),(0,x.jsx)(l.Muted,{center:!0,children:j.length?`${j.length} message${1===j.length?'':'s'} from this venue.`:'No messages in the inbox.'})]}):null]})};var e,t=r(d[0]),s=r(d[1]),o=r(d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),p=r(d[7]),m=r(d[8]),x=r(d[9]);const b='st-gordon'},1542,[827,34,102,794,1543,1051,821,1544,1088,25]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useSupportChat",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},n=r(d[1]),o=r(d[2]);let c=0;const u=(0,n.create)()((0,o.persist)(e=>({messages:[],send:(t,s,n,o)=>{const u=o.trim().slice(0,1e3);if(!u)return null;const l={id:`sm-${Date.now().toString(36)}${(c++).toString(36)}`,rid:t,at:(new Date).toISOString(),from:s.slice(0,80),staffRef:n,text:u,sent:!1};return e(e=>({messages:[...e.messages,l].slice(-200)})),l},markSent:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,sent:!0}:e)}))}),{name:'covercharge-support-chat-v1',storage:(0,o.createJSONStorage)(()=>s.default),version:1}))},1543,[839,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.writeSupportMessage=async function(S){if(!s.RELEASE.supportSync)return{ok:!1,message:t.SUPPORT_NOT_SENT};if(!(0,n.isSupabaseConfigured)())return{ok:!1,message:t.SUPPORT_NOT_SENT};const _=u.useSync.getState().venueId;if(!_)return{ok:!1,message:`${t.SUPPORT_NOT_SENT} Sign in and try again.`};try{const s=(0,o.getSupabase)(),{error:n}=await s.from('support_messages').insert({venue_id:_,body:S.text,from_name:S.from,staff_ref:S.staffRef||null});return n?{ok:!1,message:t.SUPPORT_NOT_SENT}:{ok:!0}}catch{return{ok:!1,message:t.SUPPORT_NOT_SENT}}};var s=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4])},1544,[1050,1051,976,933,987]); +__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.UseOnComputerPage=function(){const[e,n]=(0,o.useState)(null),[f,y]=(0,o.useState)(''),[b,x]=(0,o.useState)(!1);return(0,p.jsxs)(t.default,{style:{gap:12},testID:"use-on-computer",children:[(0,p.jsx)(r.T,{weight:"semibold",center:!1,children:"CoverCharge for desktop, for owners on a Mac or PC"}),(0,p.jsx)(r.Muted,{center:!1,children:"The same account, bookings and permissions as this phone, on a big screen: wide booking and hours tables you can sort, filter and download, and larger takings and GP charts."}),(0,p.jsxs)(t.default,{style:{gap:4},children:[(0,p.jsx)(r.T,{size:14,center:!1,children:"1. On the computer, open Chrome, Edge or Safari and go to the CoverCharge website\u2019s /desktop page."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"2. Here, tap Make a sign-in link, then Share or copy it to yourself."}),(0,p.jsx)(r.T,{size:14,center:!1,children:"3. Open the link on the computer, or type the code into the sign-in box."})]}),(0,p.jsx)(r.Muted,{center:!1,children:"The link works once, for 10 minutes. This phone stays signed in, and your personal link isn\u2019t changed."}),(0,p.jsx)(r.Button,{label:b?'Making a link\u2026':e?'Make a new sign-in link':'Make a sign-in link',disabled:b,onPress:async()=>{x(!0),y('');const e=await(0,l.makeChromeHandover)();if(x(!1),!e.ok)return y(e.message),void k(e.message);const o='undefined'!=typeof window&&(0,u.desktopLinkFor)(window.location.href,e.code)||'';n({link:o,code:e.code}),k('Sign-in link made. It works once, for 10 minutes. Share it or copy it next.')},testID:"uoc-make"}),e?(0,p.jsxs)(t.default,{style:{gap:8,padding:14,borderRadius:12,borderWidth:1,borderColor:c.colours.border,backgroundColor:c.colours.surface},children:[(0,p.jsx)(r.Button,{label:"Share or copy the link",onPress:async()=>{if(!e)return;const o='undefined'!=typeof navigator?navigator:null;if(o?.share&&e.link)try{return void await o.share({title:'CoverCharge for desktop',text:'Sign in to CoverCharge for desktop (works once, for 10 minutes)',url:e.link})}catch{}const n=e.link&&await(0,h.copyText)(e.link)?'Link copied. Paste it into a message to yourself, then open it on the computer.':'Couldn\u2019t copy. Read the code below and type it on the computer instead.';y(n),k(n)},testID:"uoc-share"}),(0,p.jsx)(r.T,{size:13,colour:c.colours.muted,center:!1,children:"Or type this code on the computer:"}),(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-code",accessibilityLabel:`Code: ${(0,u.codeGroups)(e.code).split('').join(' ')}`,style:{fontSize:20,fontWeight:'700',color:c.colours.goldLight,letterSpacing:1},children:(0,u.codeGroups)(e.code)}),e.link?(0,p.jsx)(s.Text,{selectable:!0,testID:"uoc-link",style:{fontSize:12,color:c.colours.muted},children:e.link}):null]}):null,(0,p.jsx)(t.default,{accessibilityLiveRegion:"polite",children:f?(0,p.jsx)(r.T,{size:14,center:!1,colour:/Couldn|Sign in|Too many|connection/i.test(f)?c.colours.red:c.colours.text,children:f}):null})]})};var o=_r(d[0]),n=e(_r(d[1]));_r(d[2]);var t=e(_r(d[3])),r=_r(d[4]),s=_r(d[5]),c=_r(d[6]),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]);const k=e=>{try{n.default.announceForAccessibility(e)}catch{}}},1545,[34,281,236,102,794,827,821,987,1433,1205,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ccDesktop",{enumerable:!0,get:function(){return o}}),e.isDesktop=function(){if(!t())return!1;if(o())return!0;try{const o=new URLSearchParams(t().location?.search??'');return'1'===o.get('desktop')?(t().localStorage?.setItem('cc-desktop','1'),!0):'0'===o.get('desktop')?(t().localStorage?.removeItem('cc-desktop'),!1):'1'===t().localStorage?.getItem('cc-desktop')}catch{return!1}},Object.defineProperty(e,"isMac",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CMD",{enumerable:!0,get:function(){return n}}),r(d[0]);const t=()=>'undefined'!=typeof window?window:void 0,o=()=>t()?.ccDesktop;const c=()=>!!o()?.mac||/Mac/i.test(t()?.navigator?.platform??''),n=()=>c()?'\u2318':'Ctrl+'},1546,[236]); +__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,"DESKTOP_MIN_WIDTH",{enumerable:!0,get:function(){return j}}),_e.DesktopGate=function({phone:e}){const{width:x}=(0,n.default)(),y=(0,c.useSignedIn)(),{rid:w,role:_}=(0,c.useCtx)(6e4),b=y?(0,c.authorityRole)(y):_;return(y||t.PITCH)&&(0,f.desktopAllowed)(b)?xt.who.includes(e)&&(!t.page||s(t.page)))},Object.defineProperty(_e,"DESKTOP_ROLES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"desktopAllowed",{enumerable:!0,get:function(){return n}}),_e.shortcutIndex=function(e){if(!e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return null;const t=/^Digit([0-9])$/.exec(e.code??'');if(!t)return null;const s=Number(t[1]);return 0===s?9:s-1},Object.defineProperty(_e,"shortcutLabel",{enumerable:!0,get:function(){return o}}),_e.commandKey=function(e,t){const s=(e.key??'').toLowerCase();return!e.ctrlKey&&!e.metaKey||e.altKey||'k'!==s?'escape'===s?'escape':t||e.ctrlKey||e.metaKey||e.altKey?null:'?'===e.key?'help':'/'===e.key?'filter':null:'find'},Object.defineProperty(_e,"SHORTCUTS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"SETTINGS_GROUPS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"OWNER_SETTINGS",{enumerable:!0,get:function(){return u}}),_e.deskCopy=function(e){let t=e;for(const[e,s]of c)t=t.replace(e,s);return t};const e=['owner','manager'],t=[{id:'home',label:'Home',sub:'Today at a glance: Covers, bookings to confirm, takings and GP',who:e},{id:'bookings',label:'Bookings',sub:'Every booking in a wide table: sort, filter and export, or the day view',who:e},{id:'orders',label:'Orders',sub:'Takeaway and table orders',who:e},{id:'forecast',label:'Forecast',sub:'Covers forecast for the days ahead',who:e},{id:'takings',label:'Takings & cash-up',sub:'Cash ups, weekly sales, takings and tips charts',page:'cashup',who:e},{id:'hours',label:'Hours & rota',sub:'Clocked hours in a wide table, sign-off, the rota and payroll hours',who:e},{id:'staff',label:'Staff & roles',sub:'The team, roles, sign-in links and access switches',page:'staff',who:e},{id:'permissions',label:'Permissions',sub:'Saved on the server for the whole team. Only owners can change them',page:'setup-permissions',who:e},{id:'stock',label:'Stock, deliveries & GP',sub:'Scan or type deliveries, count stock, dish GP and GP over time',page:'kitchencosts',who:e},{id:'vouchers',label:'Gift vouchers',sub:'Website vouchers: search, use-by dates, mark as used',page:'vouchers',who:e},{id:'reviews',label:'Reviews',sub:'Read reviews, publish or remove with a recorded reason',page:'reviews',who:e},{id:'settings',label:'Settings',sub:'Venue, hours, booking, pay, Display and app settings',who:e},{id:'chat',label:'Chat',sub:'Staff chat',who:e}];const s=['owner'],n=e=>s.includes(e);const o=(e,t)=>e>9?'':`${t?'\u2325':'Alt+'}${9===e?0:e+1}`;const i=e=>[[e?'\u23251 to \u23250':'Alt+1 to Alt+0','Open the first ten Menu buttons (Rota is 1)'],[e?'\u2318K':'Ctrl+K','Find any page by name'],['/','Jump to the filter box on a table'],['?','Show this list'],['Esc','Close a popup or this list'],['Tab, Shift+Tab','Move between buttons, links and boxes'],['Enter or Space','Press the button, or sort a table column']],l=['Settings','Manage app','Run the day','Team','Compliance','Grow','Start here','Account'],u=['menu','info','tableplan','tables','bookingsettings','staff','payroll','paysettings','haccp','kitchencosts','trackedstock','suppliers','branding','notifications','alerts','displays','displaysettings','connections','voice','giftcards','vouchers','reviewemail','assistantsettings','advanced'],c=[[/\bWix\b/g,'the website'],[/\b(Booker|Bidfood|Brakes)\b/g,'supplier'],[/\bAlsons \(drinks\)/g,'Drinks supplier'],[/\bAlsons\b/g,'the drinks supplier'],[/\bSpes Bona\b/g,'the deli supplier'],[/the the /gi,'the ']]},1548,[]); +__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.OwnersDesktop=function(){const{rid:e,role:s,today:o,now:u,me:h}=(0,B.useCtx)(3e4),b=(0,B.useSignedIn)(),{width:se,height:oe}=(0,a.default)(),[ne,re]=(0,t.useState)(null),[ie,le]=(0,t.useState)(!1),[ae,de]=(0,t.useState)(!1),[ce,ue]=(0,t.useState)(''),[ge,he]=(0,t.useState)(!1),[pe,be]=(0,t.useState)(!1),[fe,me]=(0,t.useState)(!1),[xe,ke]=(0,t.useState)(!1),ye=(0,t.useRef)(null),je=(0,t.useRef)(null),we=(0,t.useRef)(null),Ce=(0,t.useRef)(null);(0,t.useEffect)(()=>{if('undefined'==typeof document)return;const e=document.createElement('style');return e.id='cc-owner-desktop-css',e.textContent="\n[data-testid=\"owners-desktop\"] :focus-visible {outline:3px solid #E2C489!important;outline-offset:3px!important;}\n[data-testid=\"owners-desktop\"] ::selection {background:#CFA45F;color:#0B0B0B;}\n[data-testid=\"owners-desktop\"] * {scrollbar-color:#887047 #171511;scrollbar-width:thin;}\n[data-testid=\"desk-skip\"] {position:absolute!important;left:50%;transform:translateX(-50%);top:-100px;z-index:99;background:#CFA45F!important;color:#0B0B0B!important;padding:10px 16px;border-radius:8px;}\n[data-testid=\"desk-skip\"]:focus {top:8px;}\n@media(prefers-reduced-motion:reduce){[data-testid=\"owners-desktop\"] *,[data-testid=\"owners-desktop\"] *:before,[data-testid=\"owners-desktop\"] *:after{animation:none!important;transition:none!important;scroll-behavior:auto!important;}}\n",document.head.appendChild(e),()=>{e.remove()}},[]),(0,S.useTipsPosted)(e,o),(0,D.useSoldOutLink)(!0,(b?.name??h).replace(' (example)','')),(0,t.useEffect)(()=>{(0,B.ensureAttendance)(o,u),(0,E.ensureChat)(u)},[o]),(0,t.useEffect)(()=>{globalThis.__ccNow=u.getTime()},[u]);const ve=(0,G.useTakingsAllowed)(s),De=(0,t.useCallback)(e=>{const t=(0,F.pageFor)(e);return!!t&&(!t.can||t.can(s))},[s]),Ie=(0,t.useMemo)(()=>(0,N.buttonsFor)({takings:ve,pageOk:De}),[ve,De]),Se=ne?(0,N.tabsFor)(ne.btn,{takings:ve,pageOk:De}):[],Te=(0,t.useCallback)((e,t)=>{const s=(0,N.tabsFor)(e,{takings:ve,pageOk:De});s.length&&(le(!1),de(!1),ue(''),re({btn:e,tab:t&&s.some(e=>e.id===t)?t:s[0].id,page:null}))},[ve,De]),Re=Ie.find(e=>'settings'===e.id),Oe=(0,t.useCallback)(e=>{const t=Ie.find(t=>t.pages.some(t=>t.id===e));t?Te(t,e):Re&&De(e)&&(le(!1),de(!1),ue(''),re({btn:Re,tab:'@desk-settings',page:e}))},[Ie,Te,Re,De]),Pe=(0,t.useCallback)((e,t)=>{if('home'!==e)if('more'===e&&t)Oe(t);else{if('bookings'===e){const e=Ie.find(e=>'bookings'===e.id);return void(e&&Te(e,'@bookings'))}if('chat'===e){const e=Ie.find(e=>'chat'===e.id);return void(e&&Te(e))}'orders'!==e&&'forecast'!==e?'more'===e&&Re&&Te(Re):re(t=>({btn:t?.btn??Ie[0],tab:'orders'===e?'@orders':'@forecast',page:null}))}else re(null)},[Ie,Te,Oe,Re]);(0,t.useEffect)(()=>(T.useVoiceNav.setState({go:Pe}),()=>T.useVoiceNav.setState({go:null})),[Pe]),(0,C.useAlertWatcher)(e,{nag:!0}),(0,v.useReviewAlerts)(e),(0,w.useScheduledNotices)({rid:e,staffId:b?.id??'',name:h,onOpen:e=>'bookings'===e?Pe('bookings'):'chat'===e?Pe('chat'):Pe('more',e)}),(0,j.useOffRotaAlerts)({enabled:!!b});const Le=!ne||Ie.some(e=>e.id===ne.btn.id)&&Se.some(e=>e.id===ne.tab)&&(!ne.page||De(ne.page));(0,t.useEffect)(()=>{if(!Le){const e=setTimeout(()=>re(null),0);return()=>clearTimeout(e)}},[Le]);const We=ne?.page?(0,F.pageFor)(ne.page):void 0,Be=ne?(0,V.deskCopy)(We?.title??ne.btn.label):'Floor plan';(0,t.useEffect)(()=>{if('undefined'!=typeof document&&(document.title=`${Be} \xb7 The Anchorage \xb7 CoverCharge for desktop`),Ce.current?.scrollTo?.({y:0,animated:!1}),ne){const e=setTimeout(()=>Z(we.current),80);return()=>clearTimeout(e)}},[Be,ne?.tab,ne?.page]),(0,t.useEffect)(()=>{if(ae){const e=setTimeout(()=>ye.current?.focus?.(),100);return()=>clearTimeout(e)}},[ae]),(0,t.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{if(e.defaultPrevented||e.isComposing)return;const t=Y(e.target),s=(0,V.commandKey)(e,t);if('escape'===s){if(ae||ge||pe||fe)return e.preventDefault(),de(!1),he(!1),be(!1),void me(!1);if(document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;return ie?(e.preventDefault(),void le(!1)):void(ne&&(e.preventDefault(),re(null)))}if(ae||ge||pe||fe||document.querySelector('[role="dialog"]:not([data-testid="desk-menu-panel"])'))return;if('find'===s)return e.preventDefault(),le(!1),void de(!0);if('help'===s)return e.preventDefault(),void he(!0);if('filter'===s&&je.current&&ne)return e.preventDefault(),void je.current?.focus?.();const o=t?null:(0,V.shortcutIndex)(e);null!=o&&Ie[o]&&(e.preventDefault(),Te(Ie[o]))};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[ae,ge,pe,fe,ie,ne,Ie,Te]),(0,t.useEffect)(()=>{if(R.PITCH)return globalThis.__pitchGo=Pe,globalThis.__deskOpen=(e,t)=>{const s=Ie.find(t=>t.id===e);s&&Te(s,t)},globalThis.__deskRole=e=>I.useOwner.getState().setPreviewRole(e),()=>{delete globalThis.__deskOpen,delete globalThis.__deskRole}},[Pe,Ie,Te]);const He=(0,t.useMemo)(()=>{const e=ce.trim().toLowerCase().split(/\s+/).filter(Boolean),t=Ie.flatMap(e=>(0,N.tabsFor)(e,{takings:ve,pageOk:De}).map(t=>({key:`t-${e.id}-${t.id}`,title:t.label===e.label?e.label:`${e.label}: ${t.label}`,sub:e.hint,run:()=>Te(e,t.id)}))),o=new Set(Ie.flatMap(e=>e.pages.map(e=>e.id)));return[...t,...F.PAGES.filter(e=>(!e.can||e.can(s))&&!o.has(e.id)).map(e=>({key:`p-${e.id}`,title:(0,V.deskCopy)(e.title),sub:(0,V.deskCopy)(e.sub??''),run:()=>Oe(e.id)}))].filter(t=>e.every(e=>`${t.title} ${t.sub}`.toLowerCase().includes(e)))},[ce,Ie,s,ve,De,Te,Oe]),Me=(0,K.ddmmyyyy)(o),Ee=u.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),$e=b?(0,B.authorityRole)(b):s,ze=(b?.name??h).replace(' (example)',''),Ae='owner'===$e?b?.ownerAccess&&'owner'!==b.role?'Owner access':'Owner':'Manager',Fe=e=>(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1280,alignSelf:'center'},children:e}),Ve=e=>{const t=(0,F.pageFor)(e);return!t||t.can&&!t.can(s)?(0,q.jsx)(f.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,q.jsx)(l.default,{style:{width:'100%',maxWidth:1100,alignSelf:'center'},children:(0,q.jsx)(t.C,{go:Pe})})};return(0,q.jsxs)(c.SafeAreaView,{testID:"owners-desktop",style:{flex:1,backgroundColor:P.colours.bg},children:[(0,q.jsx)(n.default,{accessibilityRole:"link",testID:"desk-skip",onPress:()=>ne?Z(we.current):le(!0),children:(0,q.jsx)(f.T,{weight:"bold",colour:P.colours.onGold,children:ne?'Skip to main content':'Open the owner tools menu'})}),(0,q.jsxs)(l.default,{testID:"desk-board",role:"main",'aria-label':'Floor plan, live',style:{flex:1,minHeight:0,width:'100%'},children:[(0,q.jsx)(L.DisplayBoard,{embedded:!0,noVoice:!0,boardW:se,headerExtra:(0,q.jsx)(Q,{open:ie,onPress:()=>le(!0)}),subHeader:(0,q.jsx)(ee,{name:ze,access:Ae,day:Me,at:Ee})}),ne&&Le?(0,q.jsxs)(l.default,{testID:"desk-panel",style:{position:'absolute',top:0,bottom:0,left:0,right:0,zIndex:40,backgroundColor:P.colours.bg},children:[(0,q.jsxs)(l.default,{testID:"desk-panel-head",role:"banner",style:{flexDirection:'row',alignItems:'center',gap:10,paddingHorizontal:16,paddingVertical:10,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-start'},children:(0,q.jsx)(n.default,{testID:"desk-panel-close",accessibilityRole:"button",accessibilityLabel:ne.page?'Back to all settings':`Close ${ne.btn.label}, back to the floor plan`,onPress:()=>ne.page?re({...ne,page:null}):re(null),style:({hovered:e,focused:t})=>({minHeight:48,paddingHorizontal:16,borderRadius:14,borderWidth:1,borderColor:e||t?P.colours.gold:P.colours.border,alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:ne.page?'\u2039 All settings':'\u2039 Floor plan'})})}),(0,q.jsxs)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,q.jsx)(l.default,{ref:we,role:"heading",'aria-level':1,tabIndex:-1,nativeID:"desk-page-title",testID:"desk-page-title",style:{outlineStyle:'none'},children:(0,q.jsx)(f.T,{size:24,weight:"bold",colour:P.colours.gold,center:!0,numberOfLines:1,children:Be})}),(0,q.jsx)(f.T,{size:12,colour:P.colours.muted,center:!0,numberOfLines:1,children:(0,V.deskCopy)(We?.sub??ne.btn.hint)})]}),(0,q.jsx)(l.default,{style:{width:210,alignItems:'flex-end'},children:(0,q.jsx)(Q,{testID:"desk-menu-button-page",open:ie,onPress:()=>le(!0)})})]}),Se.length>1&&!ne.page?(0,q.jsx)(l.default,{testID:"desk-panel-tabs",role:"tablist",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:Se.map(e=>{const t=e.id===ne.tab;return(0,q.jsx)(n.default,{testID:`desk-tab-${e.id.replace(/^@(desk-)?/,'')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>re({btn:ne.btn,tab:e.id,page:null}),style:({hovered:e,focused:s})=>({minHeight:44,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t||s?P.colours.gold:P.colours.border,backgroundColor:t?J:e?P.colours.tilePressed:'transparent',alignItems:'center',justifyContent:'center'}),children:(0,q.jsx)(f.T,{weight:"semibold",colour:t?P.colours.goldLight:P.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,q.jsx)(i.default,{ref:Ce,testID:"desk-main",'aria-labelledby':'desk-page-title',style:{flex:1,minHeight:0},contentContainerStyle:{padding:22,gap:16,paddingBottom:48,width:'100%',maxWidth:1400,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:(()=>{if(!ne||!Le)return null;if(ne.page)return Ve(ne.page);switch(ne.tab){case'@desk-bookings':return(0,q.jsx)(G.DesktopBookings,{filterRef:je});case'@desk-hours':return(0,q.jsx)(G.DesktopHours,{go:Pe,filterRef:je});case'@desk-takings':return ve?(0,q.jsx)(G.DesktopTakings,{go:Pe}):(0,q.jsx)(f.Muted,{center:!0,children:"Takings aren\u2019t available for your role."});case'@desk-settings':return(0,q.jsx)(G.DesktopSettings,{open:e=>re(t=>t?{...t,page:e}:t)});case'@desk-permissions':return(0,q.jsx)(U.DeskPermissions,{});case'@desk-leavers':return(0,q.jsx)(U.DeskLeavers,{});case'@desk-temps':return Fe((0,q.jsx)(U.DeskTemps,{}));case'@desk-bookinghistory':return Fe((0,q.jsx)(U.DeskCoversHistory,{}));case'@bookings':return(0,q.jsx)(M.Bookings,{go:Pe});case'@chat':return(0,q.jsx)(E.Chat,{go:Pe});case'@noshows':return Fe((0,q.jsx)(W.NoShows,{go:Pe}));case'@orders':return(0,q.jsx)(z.Orders,{});case'@forecast':return(0,q.jsx)($.Forecasts,{go:Pe});default:return Ve(ne.tab)}})()})]}):null]}),(0,q.jsx)(te,{visible:ie,buttons:Ie,current:ne?.btn.id,W:se,H:oe,onClose:()=>le(!1),onPick:e=>Te(e),onFind:()=>{le(!1),de(!0)},onKeys:()=>{le(!1),he(!0)},onInstall:()=>{le(!1),be(!0)},onSignOut:()=>{le(!1),me(!0)}}),ae?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>de(!1),title:"Find a page",maxWidth:640,testID:"desk-search",children:[(0,q.jsx)(p.TextInput,{ref:ye,value:ce,onChangeText:ue,placeholder:"Name of a page or what you want to do",accessibilityLabel:"Find a page",style:[f.styles.input,{fontSize:15,textAlign:'center'}],placeholderTextColor:P.colours.muted,testID:"desk-search-input"}),(0,q.jsx)(l.default,{'aria-live':'polite',children:(0,q.jsxs)(f.Muted,{center:!0,children:[He.length," pages"]})}),He.slice(0,60).map(e=>(0,q.jsxs)(n.default,{accessibilityRole:"button",onPress:e.run,style:({hovered:e})=>({padding:12,borderWidth:1,borderColor:P.colours.border,borderRadius:9,backgroundColor:e?P.colours.tilePressed:P.colours.surface}),children:[(0,q.jsx)(f.T,{weight:"semibold",center:!0,children:e.title}),(0,q.jsx)(f.Muted,{center:!0,children:e.sub})]},e.key))]}):null,ge?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>he(!1),title:"Keyboard shortcuts",maxWidth:600,testID:"desk-shortcuts",children:[(0,V.SHORTCUTS)((0,_.isMac)()).map(([e,t])=>(0,q.jsxs)(l.default,{style:{alignItems:'center',paddingVertical:4},children:[(0,q.jsx)(f.T,{weight:"semibold",colour:P.colours.goldLight,center:!0,children:e}),(0,q.jsx)(f.T,{center:!0,children:t})]},e)),(0,q.jsx)(f.Muted,{center:!0,children:"Alt 1 to 0 open the first ten Menu buttons (Rota is 1). Option is the Alt key on a Mac. Esc closes the menu, then the open screen. Screen-reader users can use the headings and landmarks, or Tab through."})]}):null,fe?(0,q.jsxs)(f.Sheet,{visible:!0,onClose:()=>me(!1),title:"Sign out of this computer?",maxWidth:560,testID:"desk-signout-sheet",children:[(0,q.jsx)(f.Muted,{center:!0,children:"This signs CoverCharge out in this browser (the desktop and the Managers web app on this computer). Your phone stays signed in. To come back, make a new sign-in link on your phone."}),(0,q.jsxs)(f.Row,{gap:10,style:{justifyContent:'center',marginTop:12},children:[(0,q.jsx)(f.Button,{kind:"secondary",label:"Cancel",onPress:()=>me(!1),testID:"desk-signout-cancel"}),(0,q.jsx)(f.Button,{label:xe?'Signing out\u2026':'Sign out',disabled:xe,onPress:async()=>{ke(!0),await(0,O.wipeThisDevice)({reload:!0})},testID:"desk-signout-go"})]})]}):null,pe?(0,q.jsx)(f.Sheet,{visible:!0,onClose:()=>be(!1),title:"Install CoverCharge for desktop",maxWidth:680,testID:"desk-install-sheet",children:(0,q.jsx)(X.DesktopInstallPage,{})}):null,(0,q.jsx)(k.SeatAllergenReminder,{rid:e}),(0,q.jsx)(x.PrintHost,{rid:e}),(0,q.jsx)(m.AlertHost,{variant:"managers",rid:e,me:h,onOpen:e=>Pe('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}),(0,q.jsx)(H.AssistantSheet,{}),(0,q.jsx)(A.OnboardingHost,{go:Pe}),(0,q.jsx)(y.CoachHost,{})]})};var t=r(d[0]),s=e(r(d[1])),o=e(r(d[2]));r(d[3]);var n=e(r(d[4])),i=e(r(d[5])),l=e(r(d[6])),a=e(r(d[7])),c=r(d[8]),u=r(d[9]),h=e(u),p=r(d[10]),b=r(d[11]),f=r(d[12]),m=r(d[13]),x=r(d[14]),k=r(d[15]),y=r(d[16]),j=r(d[17]),w=r(d[18]),C=r(d[19]),v=r(d[20]),D=r(d[21]),I=r(d[22]),S=r(d[23]),T=r(d[24]),R=r(d[25]),O=r(d[26]),P=r(d[27]),L=r(d[28]),W=r(d[29]),B=r(d[30]),H=r(d[31]),M=r(d[32]),E=r(d[33]),$=r(d[34]),z=r(d[35]),A=r(d[36]),F=r(d[37]);r(d[38]);var _=r(d[39]),V=r(d[40]),N=r(d[41]),K=r(d[42]),G=r(d[43]),U=r(d[44]),X=r(d[45]),q=r(d[46]);const Y=e=>/^(INPUT|TEXTAREA|SELECT)$/.test(e?.tagName??'')||!!e?.isContentEditable,Z=e=>{if(!e)return;const t=e.getScrollableNode?.()??e;t?.focus?.()},J='rgba(201,162,74,0.14)';function Q({onPress:e,open:t,testID:s="desk-menu-button"}){return(0,q.jsxs)(n.default,{testID:s,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner tools: Rota, Bookings, Historical data, Staff leaving, Permissions, Settings and more",accessibilityState:{expanded:t},'aria-haspopup':'dialog',onPress:e,style:({pressed:e,hovered:s})=>({height:52,paddingHorizontal:16,borderRadius:26,borderWidth:1.5,borderColor:P.colours.gold,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t||s?P.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:[(0,q.jsx)(h.default,{width:22,height:22,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,q.jsx)(u.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:P.colours.gold},`${t}-${e}`)))}),(0,q.jsx)(f.T,{size:16,weight:"semibold",colour:P.colours.gold,center:!0,children:"Menu"})]})}function ee({name:e,access:t,day:s,at:o}){const n=(0,I.useOwner)(e=>e.attendance),i=(0,I.useOwner)(e=>e.staff),{now:a}=(0,B.useCtx)(3e4),c=a.getTime(),u=[...new Set(n.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean))];return(0,q.jsxs)(l.default,{testID:"desk-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:14,paddingHorizontal:12,paddingVertical:4,minHeight:40,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.T,{size:14,weight:"semibold",colour:P.colours.goldLight,center:!0,numberOfLines:1,children:u.length?`On now: ${u.join(' \xb7 ')}`:'Nobody clocked in'}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,children:`${s} \xb7 ${o} UK`}),(0,q.jsx)(f.T,{size:13,colour:P.colours.muted,center:!0,testID:"desk-who",children:`Signed in: ${e} \xb7 ${t}`})]})}function te({visible:e,buttons:a,current:c,onClose:u,onPick:h,onFind:p,onKeys:m,onInstall:x,onSignOut:k,W:y,H:j}){const w=(0,N.deskMenuSizes)(y,j),[C,v]=(0,t.useState)(0),D=C?Math.floor((C-2*w.pad)/w.rows):w.per,I=Math.max(44,Math.min(w.circle,D-2*w.lineH-14)),S={...w,per:Math.min(D,I+2*w.lineH+56),circle:I,icon:Math.round(.44*I)},[T]=(0,t.useState)(()=>new s.default.Value(0)),[R,O]=(0,t.useState)(e),L=(0,t.useRef)(null);if((0,t.useEffect)(()=>{const t=e?setTimeout(()=>O(!0),0):void 0;s.default.timing(T,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&O(!1)});const n=e?setTimeout(()=>Z(L.current),120):void 0;return()=>{clearTimeout(t),clearTimeout(n)}},[e,T]),!R)return null;const W=T.interpolate({inputRange:[0,1],outputRange:[.35*S.panelW,0]}),B=(0,_.isMac)();return(0,q.jsxs)(l.default,{testID:"desk-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,q.jsx)(s.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:T,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,q.jsx)(n.default,{testID:"desk-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:u,style:{flex:1}})}),(0,q.jsxs)(s.default.View,{testID:"desk-menu-panel",accessibilityViewIsModal:!0,role:"dialog",'aria-modal':!0,'aria-label':'Owner tools',style:{position:'absolute',top:0,bottom:0,right:0,width:S.panelW,opacity:T,transform:[{translateX:W}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:P.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,q.jsxs)(l.default,{style:{height:S.head,flexDirection:'row',alignItems:'center',paddingHorizontal:14,borderBottomWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(l.default,{style:{width:56}}),(0,q.jsx)(l.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:(0,q.jsx)(f.T,{size:21,weight:"semibold",colour:P.colours.gold,accessibilityRole:"header",center:!0,children:"Owner tools"})}),(0,q.jsx)(b.GoldClose,{testID:"desk-menu-close",label:"Close menu",size:"lg",onPress:u})]}),(0,q.jsx)(i.default,{style:{flex:1},contentContainerStyle:{flexGrow:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:S.pad},testID:"desk-menu-grid",onLayout:e=>v(Math.round(e.nativeEvent.layout.height)),children:a.map((e,t)=>{const s=c===e.id,o=(0,N.deskShortcut)(t,B);return(0,q.jsxs)(n.default,{ref:0===t?L:void 0,testID:`desk-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${e.label}${s?', open':''}. ${e.hint}${o?`. ${B?'Option':'Alt'} ${9===t?0:t+1}`:''}`,'aria-keyshortcuts':t<10?`Alt+${9===t?'0':t+1}`:void 0,onPress:()=>h(e),style:({pressed:e,hovered:t,focused:s})=>({width:S.colW,height:S.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e||t||s?'rgba(207,164,95,0.10)':'transparent'}),children:[(0,q.jsx)(l.default,{style:{width:S.circle,height:S.circle,borderRadius:S.circle/2,borderWidth:1.5,borderColor:e.extra?P.colours.goldLight:P.colours.gold,backgroundColor:s?P.colours.gold:J,alignItems:'center',justifyContent:'center'},children:(0,q.jsx)(U.DeskGlyph,{name:e.icon,size:S.icon,colour:s?'#0B0B0B':P.colours.goldLight})}),(0,q.jsx)(f.T,{size:S.label,weight:s?'semibold':'medium',colour:s?P.colours.goldLight:P.colours.text,center:!0,numberOfLines:2,style:{lineHeight:S.lineH,maxWidth:S.colW-6},children:e.label})]},e.id)})}),(0,q.jsxs)(l.default,{testID:"desk-menu-foot",style:{minHeight:S.foot,flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderTopWidth:1,borderColor:P.colours.hairline},children:[(0,q.jsx)(f.Button,{kind:"secondary",small:!0,label:"Find a page "+(B?'\u2318K':'Ctrl+K'),onPress:p,testID:"desk-find"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Keys ?",accessibilityLabel:"Keyboard shortcuts",onPress:m,testID:"desk-keys"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Install",accessibilityLabel:"Install CoverCharge for desktop",onPress:x,testID:"desk-install"}),(0,q.jsx)(f.Button,{kind:"ghost",small:!0,label:"Sign out",accessibilityLabel:"Sign out of this computer",onPress:k,testID:"desk-signout"})]})]})]})}},1549,[34,283,364,236,402,295,102,426,36,797,827,796,794,1238,1388,1115,1473,1114,1112,1240,1253,979,891,1062,1481,2,987,821,1346,1550,1088,1493,1417,1180,1475,1477,1467,1459,1479,1546,1548,1556,1557,1558,1561,1564,25]); +__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.micAvailable=O,_e.NoShows=z,_e.CarApp=function(){(0,H.useCarViewport)();const{width:e,height:n}=(0,c.default)(),o=Math.max(320,A(e)),{role:d,today:u,now:h}=(0,w.useCtx)(3e4),[p,f]=(0,t.useState)(n),x=o,[y,I]=(0,t.useState)(null),[D,W]=(0,t.useState)(!1),[M,z]=(0,t.useState)(null),[V,F]=(0,t.useState)(!1),[G,Y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{(0,w.ensureAttendance)(u,h),(0,m.ensureChat)(h)},[u]),(0,t.useEffect)(()=>{O().then(z)},[]),(0,t.useEffect)(()=>{if(v.PITCH)return;const e=setInterval(()=>{(0,k.carPairPoll)()},6e4);return()=>clearInterval(e)},[]),(0,t.useEffect)(()=>{'owner'!==d&&T.useOwner.getState().setPreviewRole('owner')},[d]);const X=(0,t.useCallback)(()=>I(null),[]);(0,j.useBackLayer)(!!y,X);const q=(0,t.useCallback)(()=>W(!1),[]);(0,j.useBackLayer)(D,q);const J=e=>{W(!1),I({btn:e,page:e.pages[0].id})},K=(0,t.useCallback)((e,t)=>{const n=e=>R.CAR_BUTTONS.find(t=>t.pages.some(t=>t.id===e));if('home'===e)return I(null);if('bookings'===e)return I({btn:n('@bookings'),page:'@bookings'});if('chat'===e)return I({btn:n('@chat'),page:'@chat'});if('orders'===e||'forecast'===e)return I(t=>({btn:t?.btn??R.CAR_BUTTONS[3],page:'orders'===e?'@orders':'@forecast'}));if('more'===e&&t){const e=n(t);return I(n=>({btn:e??n?.btn??R.CAR_BUTTONS[0],page:t}))}I(null)},[]),Q=x,Z=y?y.btn.label:'';return(0,L.jsxs)(l.default,{testID:"car-app",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.height);t>200&&Math.abs(t-p)>1&&f(t)},style:{flex:1,flexDirection:'row',backgroundColor:S.colours.bg,minHeight:0,width:o,maxWidth:'100%',overflow:'hidden'},children:[(0,L.jsxs)(l.default,{testID:"car-board",style:{width:x,minWidth:0,minHeight:0},children:[(0,L.jsx)(b.DisplayBoard,{embedded:!0,noVoice:!0,boardW:x,headerExtra:(0,L.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:10},children:[(0,L.jsx)(B.ParkedOnly,{small:o<1400}),(0,L.jsx)(N,{open:D,onPress:()=>W(!0)})]}),subHeader:(0,L.jsx)($,{onRota:()=>J(R.CAR_BUTTONS[0]),onAccount:()=>F(!0)})}),y?(0,L.jsxs)(l.default,{testID:"car-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:Q,zIndex:40,backgroundColor:S.colours.bg},children:[(0,L.jsxs)(l.default,{testID:"car-panel-head",style:{flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-panel-close",accessibilityRole:"button",accessibilityLabel:`Close ${Z}, back to the board`,onPress:()=>{(0,j.runBackLayer)()||X()},style:{minHeight:56,minWidth:96,paddingHorizontal:14,borderRadius:14,borderWidth:1,borderColor:S.colours.border,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",center:!0,children:"Close"})}),(0,L.jsx)(l.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,L.jsx)(C.T,{size:20,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,accessibilityRole:"header",children:y.btn.label})}),(0,L.jsx)(l.default,{style:{minWidth:96,alignItems:'flex-end'},children:(0,L.jsx)(N,{testID:"car-menu-button-page",open:D,onPress:()=>W(!0)})})]}),y.btn.pages.length>1?(0,L.jsx)(l.default,{testID:"car-panel-tabs",style:{flexDirection:'row',justifyContent:'center',flexWrap:'wrap',gap:8,paddingHorizontal:12,paddingVertical:8},children:y.btn.pages.map(e=>{const t=e.id===y.page;return(0,L.jsx)(s.default,{testID:`car-tab-${e.id.replace('@','')}`,accessibilityRole:"tab",accessibilityState:{selected:t},accessibilityLabel:e.label,onPress:()=>I({btn:y.btn,page:e.id}),style:{minHeight:48,paddingHorizontal:18,borderRadius:999,borderWidth:1,borderColor:t?S.colours.gold:S.colours.border,backgroundColor:t?P:'transparent',alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(C.T,{weight:"semibold",colour:t?S.colours.goldLight:S.colours.text,center:!0,children:e.label})},e.id)})}):null,(0,L.jsx)(a.default,{testID:"car-panel-scroll",style:{flex:1},contentContainerStyle:{padding:16,paddingBottom:32,gap:12,width:'100%',maxWidth:1200,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:'assistant'===y.page&&!1===M?(0,L.jsx)(U,{}):(0,L.jsx)(_,{id:y.page,go:K},y.page)})]}):null]}),(0,L.jsx)(E,{visible:D,onClose:q,onPick:J,current:y?.btn.id,W:o,H:p}),V?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>F(!1),title:"This car",maxWidth:560,testID:"car-account-sheet",children:[(0,L.jsx)(C.T,{center:!0,children:"This car is paired as an owner device for The Anchorage, with full owner access. Nobody is signed in. Changes are recorded as Car. Use it only when the car is in Park."}),(0,L.jsx)(C.Muted,{center:!0,children:"To unpair from your phone: Managers, More, Car screen. Only an owner can approve or revoke this pairing."}),(0,L.jsx)(C.Button,{testID:"car-sign-out",kind:"secondary",label:"Unpair this car",onPress:()=>{F(!1),Y(!0)},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"ghost",label:"Close",onPress:()=>F(!1),style:{minHeight:56}})]}):null,G?(0,L.jsxs)(C.Sheet,{visible:!0,onClose:()=>Y(!1),title:"Unpair this car?",maxWidth:520,testID:"car-sign-out-confirm",children:[(0,L.jsx)(C.T,{center:!0,children:"You\u2019ll need a new code, approved by an owner on their phone, to use it again."}),(0,L.jsx)(C.Button,{testID:"car-sign-out-yes",label:"Yes, unpair this car",onPress:()=>{Y(!1),(0,k.carSignOut)()},style:{minHeight:56}}),(0,L.jsx)(C.Button,{kind:"secondary",label:"Cancel",onPress:()=>Y(!1),style:{minHeight:56}})]}):null]})};var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2]));r(_d[3]);var s=e(r(_d[4])),a=e(r(_d[5])),l=e(r(_d[6])),c=e(r(_d[7])),d=r(_d[8]),u=e(d),h=r(_d[9]),b=r(_d[10]),p=r(_d[11]);r(_d[12]);var f=r(_d[13]),m=r(_d[14]),x=r(_d[15]),y=r(_d[16]),w=r(_d[17]),j=r(_d[18]),C=r(_d[19]),I=r(_d[20]),T=r(_d[21]),D=r(_d[22]),k=r(_d[23]),v=r(_d[24]),S=r(_d[25]),R=r(_d[26]),W=r(_d[27]),B=r(_d[28]),M=r(_d[29]),H=r(_d[30]),L=r(_d[31]);const P='rgba(201,162,74,0.14)';async function O(){try{const e='undefined'!=typeof navigator?navigator.mediaDevices:null;if(!e?.getUserMedia||!e?.enumerateDevices)return!1;return(await e.enumerateDevices()).some(e=>'audioinput'===e.kind)}catch{return!1}}function $({onRota:e,onAccount:n}){const o=(0,T.useOwner)(e=>e.attendance),a=(0,T.useOwner)(e=>e.staff),[c,d]=(0,t.useState)(()=>Date.now());(0,t.useEffect)(()=>{const e=setInterval(()=>d(Date.now()),3e4);return()=>clearInterval(e)},[]);const u=o.filter(e=>e.in&&!e.out&&c-new Date(e.in).getTime()<72e6&&c>=new Date(e.in).getTime()).map(e=>(a.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')).filter(Boolean),h=[...new Set(u)],b=h.length?`On now: ${h.join(' \xb7 ')}`:'Nobody clocked in';return(0,L.jsxs)(l.default,{testID:"car-strip",style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',justifyContent:'center',gap:10,paddingHorizontal:12,paddingVertical:2,minHeight:44,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(s.default,{testID:"car-whos-on",accessibilityRole:"button",accessibilityLabel:`${b}. Opens the rota.`,onPress:e,style:{flexShrink:1,minHeight:44,justifyContent:'center',paddingHorizontal:8},children:(0,L.jsx)(C.T,{size:14,weight:"semibold",colour:S.colours.goldLight,numberOfLines:1,center:!0,children:b})}),(0,L.jsx)(s.default,{testID:"car-account",accessibilityRole:"button",accessibilityLabel:"This car is paired. Car pairing options.",onPress:n,style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:22,borderWidth:1,borderColor:S.colours.gold,flexShrink:0},children:(0,L.jsx)(C.T,{size:13,weight:"semibold",colour:S.colours.gold,center:!0,numberOfLines:1,children:"Paired"})}),(0,L.jsx)(M.CarGameButton,{})]})}function z({go:e}){const{rid:t,now:n}=(0,w.useCtx)(3e4),o=(0,I.useBookings)(t),s=(0,D.ymd)(n),a=(0,D.ymd)(new Date(n.getTime()-24192e5)),c=o.filter(e=>'noshow'===e.status&&e.date>=a&&e.date<=s).sort((e,t)=>(t.date+t.time).localeCompare(e.date+e.time)),d=o.filter(e=>e.date===s&&'confirmed'===e.status&&!e.walkIn&&new Date(`${e.date}T${e.time}:00`).getTime()e+(t.partySize||0),0);return(0,L.jsxs)(l.default,{testID:"car-noshows",style:{gap:10},children:[(0,L.jsx)(C.T,{center:!0,size:18,weight:"semibold",colour:S.colours.goldLight,children:c.length?`${c.length} no-show${1===c.length?'':'s'} in the last 28 days \xb7 ${u} Covers`:'No no-shows in the last 28 days'}),d.length?(0,L.jsxs)(l.default,{testID:"car-late",style:{gap:6,borderWidth:1,borderColor:S.colours.amber,borderRadius:12,padding:12},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",colour:S.colours.amber,children:"Running more than 15 minutes late"}),d.map(e=>(0,L.jsx)(C.T,{center:!0,children:`${e.time} \xb7 ${e.name} \xb7 ${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}`},e.id)),(0,L.jsx)(C.Muted,{center:!0,children:"Call them first. If they don\u2019t come, mark No-show on their booking."})]}):null,c.map(e=>(0,L.jsxs)(l.default,{style:{borderWidth:1,borderColor:S.colours.border,borderRadius:12,padding:12,gap:2},children:[(0,L.jsx)(C.T,{center:!0,weight:"semibold",children:`${e.date===s?'Today':(0,D.niceDate)((0,D.parseYmd)(e.date))} \xb7 ${e.time} \xb7 ${e.name}`}),(0,L.jsx)(C.Muted,{center:!0,children:`${e.partySize} Covers${e.table?` \xb7 Table ${e.table}`:''}${e.phone?' \xb7 phone on the booking':''}`})]},e.id)),(0,L.jsx)(C.Button,{testID:"car-noshows-bookings",label:"Open Bookings to mark or undo a no-show",onPress:()=>e('bookings'),style:{minHeight:56}})]})}function N({onPress:e,open:t,testID:n="car-menu-button"}){return(0,L.jsx)(s.default,{testID:n,accessibilityRole:"button",accessibilityLabel:"Menu",accessibilityHint:"Opens the owner buttons: Rota, Bookings, Stock and more",accessibilityState:{expanded:t},onPress:e,style:({pressed:e})=>({width:R.MENU_BUTTON,height:R.MENU_BUTTON,borderRadius:R.MENU_BUTTON/2,borderWidth:1.5,borderColor:S.colours.gold,alignItems:'center',justifyContent:'center',flexShrink:0,backgroundColor:e||t?S.colours.goldTint:'rgba(207,164,95,0.10)',boxShadow:'0 4px 14px rgba(0,0,0,0.45)',cursor:'pointer'}),children:(0,L.jsx)(u.default,{width:24,height:24,viewBox:"0 0 24 24",pointerEvents:"none",children:[4,10.5,17].flatMap(e=>[4,10.5,17].map(t=>(0,L.jsx)(d.Rect,{x:t,y:e,width:3.6,height:3.6,rx:1.2,fill:S.colours.gold},`${t}-${e}`)))})})}function E({visible:e,onClose:a,onPick:c,current:d,W:u,H:b}){const[p,f]=(0,t.useState)(0),m=(0,R.menuSizes)(u,b),x=p?Math.floor((p-2*m.pad)/m.rows):m.per,y=Math.max(48,Math.min(76,x-m.lineH-18,m.colW-28)),w={...m,per:Math.min(x,y+m.lineH+60),circle:y},j=Math.round(.44*w.circle),I=(0,t.useRef)(new n.default.Value(0)).current,[T,D]=(0,t.useState)(e);if((0,t.useEffect)(()=>{e&&D(!0),n.default.timing(I,{toValue:e?1:0,duration:e?190:150,easing:o.default.out(o.default.cubic),useNativeDriver:!1}).start(({finished:t})=>{t&&!e&&D(!1)})},[e,I]),!T)return null;const k=I.interpolate({inputRange:[0,1],outputRange:[.35*w.panelW,0]});return(0,L.jsxs)(l.default,{testID:"car-menu",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:60},children:[(0,L.jsx)(n.default.View,{style:{position:'absolute',top:0,left:0,right:0,bottom:0,opacity:I,backgroundColor:'rgba(0,0,0,0.55)'},children:(0,L.jsx)(s.default,{testID:"car-menu-backdrop",accessibilityRole:"button",accessibilityLabel:"Close menu",onPress:a,style:{flex:1}})}),(0,L.jsxs)(n.default.View,{testID:"car-menu-panel",accessibilityViewIsModal:!0,style:{position:'absolute',top:0,bottom:0,right:0,width:w.panelW,opacity:I,transform:[{translateX:k}],backgroundColor:'#0E0D0B',borderLeftWidth:1,borderColor:S.colours.accentBorder,borderTopLeftRadius:22,borderBottomLeftRadius:22,overflow:'hidden',boxShadow:'-24px 0 60px rgba(0,0,0,0.6)'},children:[(0,L.jsxs)(l.default,{style:{height:w.head,flexDirection:'row',alignItems:'center',paddingLeft:w.pad+4,paddingRight:14,borderBottomWidth:1,borderColor:S.colours.hairline},children:[(0,L.jsx)(l.default,{style:{flex:1,minWidth:0},children:(0,L.jsx)(C.T,{size:21,weight:"semibold",colour:S.colours.gold,accessibilityRole:"header",children:"Owner tools"})}),(0,L.jsx)(h.GoldClose,{testID:"car-menu-close",label:"Close menu",size:"lg",onPress:a})]}),(0,L.jsx)(l.default,{testID:"car-menu-grid",onLayout:e=>f(Math.round(e.nativeEvent.layout.height)),style:{flex:1,flexDirection:'row',flexWrap:'wrap',alignContent:'center',justifyContent:'center',padding:w.pad},children:R.CAR_BUTTONS.map(e=>{const t=d===e.id;return(0,L.jsxs)(s.default,{testID:`car-btn-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:t},accessibilityLabel:t?`${e.label}, open`:e.label,onPress:()=>c(e),style:({pressed:e})=>({width:w.colW,height:w.per,alignItems:'center',justifyContent:'center',gap:6,borderRadius:18,overflow:'hidden',backgroundColor:e?'rgba(207,164,95,0.08)':'transparent'}),children:[(0,L.jsx)(l.default,{style:{width:w.circle,height:w.circle,borderRadius:w.circle/2,borderWidth:1.5,borderColor:S.colours.gold,backgroundColor:t?S.colours.gold:P,alignItems:'center',justifyContent:'center'},children:(0,L.jsx)(W.CarGlyph,{name:e.icon,size:j,colour:t?'#0B0B0B':S.colours.goldLight})}),(0,L.jsx)(C.T,{size:w.label,weight:t?'semibold':'medium',colour:t?S.colours.goldLight:S.colours.text,center:!0,numberOfLines:1,style:{lineHeight:w.lineH,maxWidth:w.colW-8},children:w.colW<130?e.short:e.label})]},e.id)})})]})]})}function U(){return(0,L.jsxs)(l.default,{testID:"car-no-mic",accessibilityLiveRegion:"polite",style:{gap:10,alignItems:'center',paddingVertical:24},children:[(0,L.jsx)(C.T,{center:!0,size:20,weight:"semibold",colour:S.colours.goldLight,children:"The Assistant needs the car\u2019s microphone"}),(0,L.jsx)(C.Muted,{center:!0,style:{maxWidth:520},children:"Sorry, this car\u2019s browser isn\u2019t letting the page use a microphone. For now, please use the Assistant in Managers on your phone."})]})}function _({id:e,go:t}){if('@bookings'===e)return(0,L.jsx)(f.Bookings,{go:t});if('@chat'===e)return(0,L.jsx)(m.Chat,{go:t});if('@noshows'===e)return(0,L.jsx)(z,{go:t});if('@orders'===e)return(0,L.jsx)(x.Orders,{});if('@forecast'===e)return(0,L.jsx)(y.Forecasts,{go:t});const n=(0,p.pageFor)(e);if(!n)return(0,L.jsx)(C.Muted,{center:!0,children:"This screen isn\u2019t in the car yet. Open it in Managers on your phone."});const o=n.C;return(0,L.jsx)(o,{go:t})}function A(e){if('undefined'==typeof document)return e;const t=document.documentElement?.clientWidth||e,n=window.visualViewport?.width||e;return Math.floor(Math.min(e,t,n))}},1550,[34,283,364,236,402,295,102,426,797,796,1346,1459,1479,1417,1180,1477,1475,1088,1056,794,874,891,858,987,2,821,1551,1552,1553,1554,1555,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1551,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGlyph=function({name:e,size:x,colour:n}){const c={stroke:n,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'},l={rota:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h3M14 14h3M7 17h3",...c})]}),signoff:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...c}),(0,h.jsx)(s.Path,{d:"M12 7v5l3 2",...c}),(0,h.jsx)(s.Path,{d:"M15.5 18.5l1.8 1.8 3.4-3.6",...c})]}),menu:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M6 3v8a2 2 0 0 0 2 2v8M10 3v8a2 2 0 0 1-2 2M8 3v6",...c}),(0,h.jsx)(s.Path,{d:"M16 21V3c2.5 1.5 3 5 3 8h-3",...c})]}),bookings:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...c}),(0,h.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...c})]}),noshow:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...c}),(0,h.jsx)(s.Path,{d:"M3 21c0-4 3-6 7-6s7 2 7 6M17 9l4 4M21 9l-4 4",...c})]}),chat:(0,h.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...c}),stock:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M3 7l9-4 9 4-9 4z",...c}),(0,h.jsx)(s.Path,{d:"M3 7v10l9 4 9-4V7M12 11v10",...c})]}),loyalty:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"2",...c}),(0,h.jsx)(s.Circle,{cx:"8",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.5",...c}),(0,h.jsx)(s.Circle,{cx:"16",cy:"12",r:"1.5",...c})]}),takings:(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...c})}),safety:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Path,{d:"M10 14V5a2 2 0 0 1 4 0v9a4 4 0 1 1-4 0z",...c}),(0,h.jsx)(s.Path,{d:"M12 9v7",...c})]}),reviews:(0,h.jsx)(s.Path,{d:"M12 3l2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z",...c}),assistant:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",...c}),(0,h.jsx)(s.Path,{d:"M5 11a7 7 0 0 0 14 0M12 18v3M9 21h6",...c})]})};return(0,h.jsx)(t.default,{width:x,height:x,viewBox:"0 0 24 24",children:l[e]})},_e.GameGlyph=function({size:e,colour:x}){const n={stroke:x,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,h.jsxs)(t.default,{width:e,height:e,viewBox:"0 0 24 24",children:[(0,h.jsx)(s.Path,{d:"M7 8h10a4 4 0 0 1 4 4v3a3 3 0 0 1-5.4 1.8L14.5 15h-5l-1.1 1.8A3 3 0 0 1 3 15v-3a4 4 0 0 1 4-4z",...n}),(0,h.jsx)(s.Path,{d:"M7 11v3M5.5 12.5h3",...n}),(0,h.jsx)(s.Circle,{cx:"16",cy:"11.5",r:"0.9",...n}),(0,h.jsx)(s.Circle,{cx:"18",cy:"13.5",r:"0.9",...n})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},h=r(d[2])},1552,[34,797,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1553,[34,102,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CarGameButton=function(){const e=(0,u.useStore)(e=>!1!==e.restaurants.find(e=>e.id===c.VENUE_RID)?.settings?.games),[n,y]=(0,t.useState)(!1),[C]=(0,t.useState)(()=>new Date),_=(0,s.useGameClock)(null,n?new Date:C);return e?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"car-game-open",accessibilityRole:"button",accessibilityLabel:"Game: Lenny's Kitchen Chaos. Parked only.",onPress:()=>y(!0),style:{minHeight:44,justifyContent:'center',paddingHorizontal:14,borderRadius:22,borderWidth:1,borderColor:f.colours.gold,flexShrink:0},children:(0,h.jsx)(b.T,{size:13,weight:"semibold",colour:f.colours.gold,center:!0,numberOfLines:1,children:"Game"})}),n?(0,h.jsx)(s.BreakRoom,{car:!0,staffId:null,name:"Car",playable:(0,o.gamePlayable)(_),clock:_,onClose:()=>y(!1)}):null]}):null};var e,t=r(d[0]),n=r(d[1]),l=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]),f=r(d[7]),h=r(d[8])},1554,[34,402,1182,1183,831,5,794,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useCarViewport=function(){(0,t.useEffect)(()=>{if(!o)return;const t=document.documentElement,n=document.body,s=[t.style.cssText,n.style.cssText];for(const o of[t.style,n.style])o.height='100%',o.margin='0',o.overflow='hidden',o.overscrollBehavior='none',o.touchAction='manipulation';return()=>{t.style.cssText=s[0],n.style.cssText=s[1]}},[])};var t=r(d[0]);r(d[1]);const o='undefined'!=typeof document},1555,[34,236]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_EXTRA",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DESK_BUTTONS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REQUIRED_DESK_BUTTONS",{enumerable:!0,get:function(){return l}}),e.tabsFor=c,e.buttonsFor=function(s){return o.filter(t=>c(t,s).length>0)},e.deskMenuSizes=function(s,t){const i=Math.ceil(o.length/4),n=Math.round(Math.max(320,Math.min(s-24,s>=1600?640:s>=1280?580:520))),l=Math.floor((n-36-2)/4),c=Math.floor(Math.max(88,(t-72-64-36)/i)),h=t>=1e3?15:13,k=Math.round(1.4*h),b=Math.max(48,Math.min(72,c-2*k-14,l-34));return{panelW:n,colW:l,per:c,circle:b,label:h,lineH:k,icon:Math.round(.44*b),cols:4,rows:i,head:72,foot:64,pad:18}},Object.defineProperty(e,"deskShortcut",{enumerable:!0,get:function(){return h}});var s=r(d[0]);const t={signoff:{last:[{id:'@desk-hours',label:'Hours table'}]},bookings:{first:[{id:'@desk-bookings',label:'Bookings table'}],last:[{id:'@bookings',label:'Day view'}]},takings:{first:[{id:'@desk-takings',label:'Takings charts',takings:!0}]}},i={rota:'Make and publish the rota',signoff:'Sign off clocked hours, timesheets and the hours table',menu:'Sold out, menu and allergens, table QR codes',bookings:'Every booking in a wide table, the day view and Look back',noshows:'No-shows in the last 28 days',chat:'Staff chat',stock:'Deliveries, GP, tracked stock, order lists and supplier links',loyalty:'The stamp card',takings:'Takings, cash ups, tips and spend per head',safety:'Food safety log and daily checks',reviews:'Read and answer reviews',assistant:'Ask the Assistant'},n=[{id:'history',label:'Historical data',short:'History',icon:'history',extra:!0,hint:'Look back by date, bookings and covers, takings, hours, fridge temperatures and the forecast',pages:[{id:'lookback',label:'Look back'},{id:'@desk-bookinghistory',label:'Bookings & covers'},{id:'@desk-takings',label:'Takings & tips',takings:!0},{id:'@desk-hours',label:'Hours'},{id:'@desk-temps',label:'Fridges & freezers'},{id:'@forecast',label:'Forecast'}]},{id:'leavers',label:'Staff leaving',short:'Leaving',icon:'leaver',extra:!0,hint:'Switch off a leaver\u2019s app, or switch it back on. Their hours, tips and rota are kept',pages:[{id:'@desk-leavers',label:'Staff leaving'}]},{id:'permissions',label:'Permissions',short:'Access',icon:'permissions',extra:!0,hint:'On and off switches for each level and each person',pages:[{id:'@desk-permissions',label:'Permissions'}]},{id:'settings',label:'Settings',short:'Settings',icon:'settings',extra:!0,hint:'Menu, opening hours, table plan, deposits, staff, wages, fridges, branding and more',pages:[{id:'@desk-settings',label:'All settings'}]}],o=[...s.CAR_BUTTONS.map(s=>{const n=t[s.id]??{},o=[...n.first??[],...s.pages.filter(s=>!(n.last??[]).some(t=>t.id===s.id)),...n.last??[]];return{id:s.id,label:s.label,short:s.short,icon:s.icon,hint:i[s.id]??s.label,pages:o}}),...n],l=['rota','signoff','menu','bookings','noshows','chat','stock','loyalty','takings','safety','reviews','assistant','history','leavers','permissions','settings'];function c(s,t){return s.pages.filter(s=>(!s.takings||t.takings)&&(s.id.startsWith('@')||t.pageOk(s.id)))}const h=(s,t)=>s>9?'':`${t?'\u2325':'Alt+'}${9===s?0:s+1}`},1556,[1551]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ukTime",{enumerable:!0,get:function(){return n}}),e.sortRows=function(t,n,a){if(!n)return t.slice();const l='asc'===a?1:-1;return t.map((t,a)=>({r:t,i:a,v:n.value(t)})).sort((t,n)=>{const a=t.v,i=n.v,r='number'==typeof a&&'number'==typeof i?a-i:String(a).localeCompare(String(i),'en-GB',{numeric:!0,sensitivity:'base'});return r?r*l:t.i-n.i}).map(t=>t.r)},e.filterRows=function(t,n,a){const l=a.toLowerCase().split(/\s+/).filter(Boolean);return l.length?t.filter(t=>{const a=n.map(n=>n.text?n.text(t):String(n.value(t))).join(' ').toLowerCase();return l.every(t=>a.includes(t))}):t.slice()},e.csvCell=a,e.toCsv=function(t,n){return[n.map(t=>a(t.label)).join(','),...t.map(t=>n.map(n=>a(n.text?n.text(t):n.value(t))).join(','))].join('\r\n')},Object.defineProperty(e,"csvName",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"sourceWord",{enumerable:!0,get:function(){return o}}),e.bookingColumns=function(n){const a=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.time}`,text:n=>t(n.date)},{key:'time',label:'Time',width:70,value:t=>t.time},{key:'name',label:'Name',width:190,value:t=>t.walkIn?'Walk-in':t.name},{key:'party',label:'Covers',width:76,value:t=>t.partySize,numeric:!0},{key:'table',label:'Table',width:84,value:t=>t.table??'',text:t=>t.table||'No table'},{key:'status',label:'Status',width:140,value:t=>r[t.status]??t.status},{key:'source',label:'From',width:96,value:t=>o(t)},{key:'allergies',label:'Allergies',width:150,value:t=>t.allergies?.length?t.allergies.map(t=>i[t.allergen]??t.allergen).join(', '):t.allergyNone?'None':''},{key:'deposit',label:'Deposit',width:88,value:t=>t.depositPaid??0,text:t=>s(t.depositPaid)||(t.depositDue?`Due ${s(t.depositDue)}`:''),numeric:!0},{key:'notes',label:'Notes',width:240,value:t=>[t.occasion??'',...t.tags??[],t.notes??''].filter(Boolean).join(' \xb7 ')}];n&&a.splice(4,0,{key:'phone',label:'Phone',width:132,value:t=>t.phone??''});return a},e.bookingsBetween=function(t,n,a,l){return t.filter(t=>t.date>=n&&t.date<=a&&('all'===l||('active'===l?'cancelled'!==t.status&&'noshow'!==t.status:t.status===l))).sort((t,n)=>(t.date+t.time).localeCompare(n.date+n.time))},Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"HOURS_COLUMNS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"totalPaid",{enumerable:!0,get:function(){return c}}),e.perDay=function(t,n){return t.map(t=>({date:t,value:n(t)}))},e.lastDays=function(t,n){const a=[],l=new Date(`${t}T12:00:00Z`);for(let t=n-1;t>=0;t--){const n=new Date(l);n.setUTCDate(l.getUTCDate()-t),a.push(n.toISOString().slice(0,10))}return a};const t=t=>/^\d{4}-\d{2}-\d{2}/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t,n=t=>t?new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'';function a(t){let n=String(t??'');return/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),/[",\r\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}const l=(n,a,l)=>`anchorage-${n}-${t(a).replace(/\//g,'-')}${l&&l!==a?`-to-${t(l).replace(/\//g,'-')}`:''}.csv`,i={gluten:'Gluten',crustaceans:'Crustaceans',molluscs:'Molluscs',eggs:'Eggs',fish:'Fish',peanuts:'Peanuts',treenuts:'Tree nuts',soya:'Soya',milk:'Milk',celery:'Celery',mustard:'Mustard',sesame:'Sesame',sulphites:'Sulphites',lupin:'Lupin'},r={pending:'Needs confirming',confirmed:'Booked',seated:'Seated',finished:'Done',noshow:'No-show',cancelled:'Cancelled'},o=t=>t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source?'Website':'Phone',s=t=>t?`\xa3${(t/100).toFixed(2)}`:'';const u=t=>`${Math.floor(Math.max(0,t)/60)}h ${String(Math.round(Math.max(0,t)%60)).padStart(2,'0')}m`,d=[{key:'date',label:'Date',width:108,value:t=>`${t.date} ${t.inT}`,text:n=>t(n.date)},{key:'name',label:'Name',width:180,value:t=>t.name},{key:'job',label:'Job',width:150,value:t=>t.job},{key:'in',label:'In',width:70,value:t=>t.inT},{key:'out',label:'Out',width:70,value:t=>t.outT,text:t=>t.outT||'On now'},{key:'break',label:'Break',width:80,value:t=>t.breakMins,text:t=>t.breakMins?`${t.breakMins} min`:'None',numeric:!0},{key:'paid',label:'Paid hours',width:100,value:t=>t.paidMins,text:t=>u(t.paidMins),numeric:!0},{key:'status',label:'Status',width:170,value:t=>t.status},{key:'signed',label:'Signed off by',width:140,value:t=>t.signedBy},{key:'note',label:'Note',width:200,value:t=>t.note}],c=t=>t.reduce((t,n)=>t+n.paidMins,0)},1557,[]); +__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.useTakingsAllowed=N,_e.Grid=W,_e.Panel=L,_e.DesktopHome=function({go:e}){const{rid:s,role:a,today:i,now:l}=(0,w.useCtx)(3e4),u=(0,g.useBookings)(s),h=(0,y.useCashUp)(e=>e.cashUps),b=(0,m.useOwner)(e=>e.staff),x=(0,m.useOwner)(e=>e.attendance),j=N(a),C=P('kitchencosts',a),S=u.filter(e=>'pending'===e.status&&e.date>=i).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time)),D=u.filter(e=>e.date===i&&'cancelled'!==e.status&&'noshow'!==e.status).sort((e,t)=>e.time.localeCompare(t.time)),R=`${String(l.getHours()).padStart(2,'0')}:${String(l.getMinutes()).padStart(2,'0')}`,O=D.filter(e=>'confirmed'===e.status&&e.time>=R).slice(0,6),B=(0,m.liveAttendance)(x).filter(e=>e.date===i&&e.in&&!e.out).map(e=>b.find(t=>t.id===e.staffId)?.name.replace(' (example)','')).filter(Boolean),U=(0,t.useMemo)(()=>[...(0,T.lastDays)(i,21),...[1,2,3,4,5,6,7].map(e=>M(i,e))].map(e=>({date:e,value:(0,f.coversFour)(u,e).total||0,future:e>i})),[u,i]),A=h.filter(e=>e.rid===s&&e.confirmedAt),_=(0,t.useMemo)(()=>(0,T.lastDays)(i,28).map(e=>{const t=A.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),[A,i]);return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-home",children:[(0,I.jsxs)(W,{min:330,children:[(0,I.jsx)(L,{title:"Covers today",testID:"desk-home-covers",children:(0,I.jsx)(r.CoversToday,{rid:s,big:!0,onPress:()=>e('bookings'),testID:"desk-covers-today"})}),(0,I.jsx)(L,{title:`Needs confirming (${S.length})`,testID:"desk-home-pending",action:(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Open Bookings",onPress:()=>e('bookings')}),children:S.length?S.slice(0,5).map(e=>(0,I.jsxs)(n.default,{accessible:!0,accessibilityLabel:`${e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}. Needs confirming.`,style:{alignItems:'center',paddingVertical:4,borderTopWidth:1,borderColor:k.colours.hairline},children:[(0,I.jsxs)(o.T,{weight:"semibold",center:!0,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsxs)(o.Muted,{center:!0,children:[(0,T.ddmmyyyy)(e.date)," at ",e.time]})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"Nothing waiting. Every booking is confirmed."})}),(0,I.jsxs)(L,{title:"Next to arrive",testID:"desk-home-next",children:[O.length?O.map(e=>(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(o.T,{size:15,weight:"semibold",colour:k.colours.gold,children:e.time}),(0,I.jsxs)(o.T,{size:15,children:[e.name," \xb7 ",e.partySize]}),(0,I.jsx)(o.Muted,{children:e.table?`Table ${e.table}`:'No table'})]},e.id)):(0,I.jsx)(o.Muted,{center:!0,children:"No more bookings to arrive today."}),(0,I.jsx)(o.Muted,{center:!0,children:B.length?`On now: ${B.join(', ')}`:'Nobody is clocked in right now.'})]})]}),(0,I.jsxs)(W,{min:480,children:[(0,I.jsx)(L,{testID:"desk-home-covers-chart",children:(0,I.jsx)(v.WideChart,{title:"Covers by day",sub:"Last 3 weeks, then the next 7 days booked so far (lighter)",points:U,fmt:e=>String(Math.round(e)),today:i,testID:"chart-covers",valueLabel:"Covers"})}),j?(0,I.jsx)(L,{testID:"desk-home-takings",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 28 days",sub:"Card + cash from signed-off cash ups. A grey stub means no cash up that day.",points:_,fmt:$,today:i,testID:"chart-takings",valueLabel:"Takings"})}):null]}),(0,I.jsxs)(W,{min:480,children:[C?(0,I.jsx)(L,{testID:"desk-home-gp",children:(0,I.jsx)(c.GpOverTime,{rid:s})}):null,j?(0,I.jsxs)(L,{title:"Tips",testID:"desk-home-tips",children:[(0,I.jsx)(d.TodaysTipsCard,{rid:s,today:i}),(0,I.jsx)(d.TipsPotCard,{rid:s,today:i})]}):null]})]})},_e.rangeDates=U,_e.FilterBox=_,_e.DesktopBookings=function({filterRef:e}){const{rid:s,today:a,me:i,role:l}=(0,w.useCtx)(15e3),r=(0,g.useBookings)(s),[d,c]=(0,t.useState)('table'),[y,m]=(0,t.useState)('next7'),[f,p]=(0,t.useState)('active'),[x,C]=(0,t.useState)(''),[D,v]=(0,t.useState)(!1),[$,R]=(0,t.useState)('date'),[M,O]=(0,t.useState)('asc'),[N,P]=(0,t.useState)(null),[W,L]=U(y,a),z=(0,t.useMemo)(()=>(0,T.bookingColumns)(D),[D]),E=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)((0,T.bookingsBetween)(r,W,L,f),z,x),z.find(e=>e.key===$),M),[r,W,L,f,z,x,$,M]),F=E.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status).reduce((e,t)=>e+t.partySize,0),G=N?r.find(e=>e.id===N.id)??N:null;return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-bookings",children:[(0,I.jsxs)(o.Row,{style:{justifyContent:'center'},gap:8,children:[(0,I.jsx)(o.Chip,{label:"Table",selected:'table'===d,onPress:()=>c('table'),testID:"desk-bk-view-table",accessibilityLabel:"Show bookings as a table"}),(0,I.jsx)(o.Chip,{label:"Day view",selected:'day'===d,onPress:()=>c('day'),testID:"desk-bk-view-day",accessibilityLabel:"Show one day, with confirm, seat and edit"})]}),'day'===d?(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:980,alignSelf:'center'},children:(0,I.jsx)(j.Bookings,{})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(n.default,{role:"group",'aria-label':'Which dates',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:B.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:y===e,onPress:()=>m(e),testID:`desk-bk-range-${e}`},e))})}),(0,I.jsx)(n.default,{role:"group",'aria-label':'Which bookings',children:(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:A.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:f===e,onPress:()=>p(e),testID:`desk-bk-status-${e}`},e))})}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:x,onChange:C,label:"Filter by name, table, allergy or note",inputRef:e,testID:"desk-bk-filter"}),(0,I.jsx)(o.Chip,{label:D?'Hide phone numbers':'Show phone numbers',selected:D,onPress:()=>v(e=>!e),testID:"desk-bk-phones"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-bk-csv",accessibilityLabel:`Export these ${E.length} bookings as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('bookings',W,L),(0,T.toCsv)(E,z))})]}),(0,I.jsx)(n.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-bk-count",children:`${E.length} ${1===E.length?'booking':'bookings'} \xb7 ${F} covers \xb7 ${(0,T.ddmmyyyy)(W)}${L!==W?` to ${(0,T.ddmmyyyy)(L)}`:''}`})}),(0,I.jsx)(S.DataTable,{caption:`Bookings ${(0,T.ddmmyyyy)(W)} to ${(0,T.ddmmyyyy)(L)}`,cols:z,rows:E,rowKey:e=>e.id,sortKey:$,dir:M,onSort:e=>{e===$?O(e=>'asc'===e?'desc':'asc'):(R(e),O('asc'))},testID:"desk-bk-table",onRowPress:e=>P(e),rowLabel:e=>`${e.walkIn?'Walk-in':e.name}, ${e.partySize} people, ${(0,T.ddmmyyyy)(e.date)} at ${e.time}, ${e.table?`table ${e.table}`:'no table'}, ${T.STATUS_WORD[e.status]??e.status}`,empty:"No bookings match. Try another date range or clear the filter."})]}),G?(0,I.jsxs)(o.Sheet,{visible:!0,onClose:()=>P(null),title:`${G.walkIn?'Walk-in':G.name} \xb7 ${G.partySize}`,maxWidth:560,testID:"desk-bk-sheet",children:[(0,I.jsxs)(o.T,{center:!0,children:[(0,T.ddmmyyyy)(G.date)," at ",G.time," \xb7 ",G.table?`Table ${G.table}`:'No table'," \xb7 ",T.STATUS_WORD[G.status]??G.status]}),G.phone&&D?(0,I.jsx)(o.T,{center:!0,children:G.phone}):null,G.allergies?.length?(0,I.jsxs)(o.T,{center:!0,colour:k.colours.amber,children:["Allergies: ",G.allergies.map(e=>e.allergen).join(', ')]}):null,G.notes?(0,I.jsx)(o.Muted,{center:!0,children:G.notes}):null,(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:10,children:[(0,I.jsx)(h.BookingTableButton,{rid:s,booking:G,readOnly:G.datee.staff),d=(0,m.useOwner)(e=>e.attendance),[c,u]=(0,t.useState)('table'),[h,g]=(0,t.useState)('thisweek'),[y,f]=(0,t.useState)(''),[p,x]=(0,t.useState)('all'),[j,D]=(0,t.useState)('date'),[v,$]=(0,t.useState)('desc'),[R,M]=E(h,i),O=(0,t.useMemo)(()=>(0,m.liveAttendance)(d).filter(e=>e.in&&e.date>=R&&e.date<=M).map(e=>{const t=r.find(t=>t.id===e.staffId),s=(0,w.paidMins)(e,l);return{id:e.id,date:e.date,name:(t?.name??'Former team member').replace(' (example)',''),job:t?.job??'',inT:(0,T.ukTime)(e.in),outT:(0,T.ukTime)(e.out),breakMins:s.brk,paidMins:s.paid,status:e.out?e.signOff?'Signed off':'Waiting for sign-off':'On now',signedBy:e.signOff?.by?.replace(' (example)','')??'',note:e.adjusted?`Changed: ${e.adjusted.reason}`:e.added?'Added by a manager':e.auto?'From the rota':'display'===e.via?'Clocked on the Display':''}}),[d,r,R,M,l]),N=(0,t.useMemo)(()=>(0,T.sortRows)((0,T.filterRows)(O.filter(e=>'all'===p||e.status===p),T.HOURS_COLUMNS,y),T.HOURS_COLUMNS.find(e=>e.key===j),v),[O,p,y,j,v]),P=t=>{const s=(0,C.pageFor)(t);return!s||s.can&&!s.can(a)?(0,I.jsx)(o.Muted,{center:!0,children:"That page isn\u2019t available for your role."}):(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:(0,I.jsx)(s.C,{go:e})})};return(0,I.jsxs)(n.default,{style:{gap:14},testID:"desk-hours",children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:8,children:[['table','Hours table'],['signoff','Sign off hours'],['rota','Rota'],['payroll','Payroll hours']].map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:c===e,onPress:()=>u(e),testID:`desk-hr-tab-${e}`},e))}),'signoff'===c?P('signoff'):'rota'===c?P('rota'):'payroll'===c?P('hours'):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:z.map(([e,t])=>(0,I.jsx)(o.Chip,{label:t,selected:h===e,onPress:()=>g(e),testID:`desk-hr-range-${e}`},e))}),(0,I.jsx)(o.Row,{wrap:!0,style:{justifyContent:'center'},gap:6,children:['all','Waiting for sign-off','Signed off','On now'].map(e=>(0,I.jsx)(o.Chip,{label:'all'===e?'All shifts':e,selected:p===e,onPress:()=>x(e),testID:`desk-hr-status-${e.split(' ')[0].toLowerCase()}`},e))}),(0,I.jsxs)(o.Row,{wrap:!0,style:{justifyContent:'center',alignItems:'center'},gap:10,children:[(0,I.jsx)(_,{value:y,onChange:f,label:"Filter by name, job or note",inputRef:s,testID:"desk-hr-filter"}),(0,I.jsx)(o.Button,{kind:"secondary",small:!0,label:"Export CSV",testID:"desk-hr-csv",accessibilityLabel:`Export these ${N.length} shifts as a CSV file`,onPress:()=>(0,b.downloadText)((0,T.csvName)('hours',R,M),(0,T.toCsv)(N,T.HOURS_COLUMNS))})]}),(0,I.jsx)(n.default,{'aria-live':'polite',children:(0,I.jsx)(o.T,{size:14,colour:k.colours.muted,center:!0,testID:"desk-hr-count",children:`${N.length} ${1===N.length?'shift':'shifts'} \xb7 ${(0,T.hm)((0,T.totalPaid)(N))} paid \xb7 ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`})}),(0,I.jsx)(S.DataTable,{caption:`Hours ${(0,T.ddmmyyyy)(R)} to ${(0,T.ddmmyyyy)(M)}`,cols:T.HOURS_COLUMNS,rows:N,rowKey:e=>e.id,sortKey:j,dir:v,onSort:e=>{e===j?$(e=>'asc'===e?'desc':'asc'):(D(e),$('asc'))},testID:"desk-hr-table",empty:"No shifts in these dates."}),(0,I.jsx)(o.Muted,{center:!0,children:"To change or sign off a shift, open Sign off hours. Pay rates stay in Payroll, for people with pay and wages access."})]})]})},_e.DesktopTakings=function({go:e}){const{rid:t,role:s,today:a}=(0,w.useCtx)(6e4),i=(0,y.useCashUp)(e=>e.cashUps),l=N(s),r=(0,C.pageFor)('cashup'),d=i.filter(e=>e.rid===t&&e.confirmedAt),c=(0,T.lastDays)(a,42),u=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.takings)(t.vals):null}}),h=c.map(e=>{const t=d.find(t=>t.date===e);return{date:e,value:t?(0,p.combinedTips)(t.vals):null}});return(0,I.jsxs)(n.default,{style:{gap:16},testID:"desk-takings",children:[l?(0,I.jsxs)(W,{min:520,children:[(0,I.jsx)(L,{testID:"desk-tk-chart",children:(0,I.jsx)(v.WideChart,{title:"Takings, last 6 weeks",sub:"Card + cash from signed-off cash ups",points:u,fmt:$,today:a,testID:"chart-takings-6w",valueLabel:"Takings"})}),(0,I.jsx)(L,{testID:"desk-tips-chart",children:(0,I.jsx)(v.WideChart,{title:"Tips, last 6 weeks",sub:"Card + cash tips, team total",points:h,fmt:R,today:a,testID:"chart-tips-6w",valueLabel:"Tips"})})]}):null,(0,I.jsx)(n.default,{style:{width:'100%',maxWidth:1040,alignSelf:'center'},children:!r||r.can&&!r.can(s)?(0,I.jsx)(o.Muted,{center:!0,children:"Cash up isn\u2019t available for your role."}):(0,I.jsx)(r.C,{go:e})})]})},_e.DesktopSettings=function({open:e}){const{role:t}=(0,w.useCtx)(6e4),{width:s}=(0,i.default)(),l=e=>!e.can||e.can(t),r=[{g:'Owners use most',items:D.OWNER_SETTINGS.map(e=>C.PAGES.find(t=>t.id===e)).filter(e=>!!e&&l(e))},...D.SETTINGS_GROUPS.map(e=>({g:e,items:C.PAGES.filter(t=>t.group===e&&l(t)&&!D.OWNER_SETTINGS.includes(t.id))}))].filter(e=>e.items.length);return(0,I.jsx)(n.default,{style:{gap:20},testID:"desk-settings",children:r.map(({g:t,items:i})=>(0,I.jsxs)(n.default,{style:{gap:10},children:[(0,I.jsx)(n.default,{role:"heading",'aria-level':2,children:(0,I.jsx)(o.T,{size:13,weight:"semibold",colour:k.colours.goldMuted,center:!0,style:{letterSpacing:1},children:t.toUpperCase()})}),(0,I.jsx)(W,{min:s>=1400?300:260,gap:12,children:i.map(t=>(0,I.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:(0,D.deskCopy)(`${t.title}. ${t.sub}`),testID:`desk-set-${t.id}`,onPress:()=>e(t.id),style:({hovered:e,focused:t})=>({height:'100%',minHeight:92,padding:14,borderRadius:14,borderWidth:1,borderColor:t?k.colours.gold:k.colours.border,backgroundColor:e?k.colours.tilePressed:k.colours.surface,alignItems:'center',justifyContent:'center',gap:4}),children:[(0,I.jsxs)(o.Row,{gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(o.T,{weight:"semibold",center:!0,children:(0,D.deskCopy)(t.title)}),t.badge?(0,I.jsx)(o.Badge,{kind:"gold",label:t.badge}):null]}),(0,I.jsx)(o.Muted,{center:!0,children:(0,D.deskCopy)(t.sub??'')})]},t.id))})]},t))})};var t=_r(_d[0]),s=e(t),a=e(_r(_d[1])),n=e(_r(_d[2])),i=e(_r(_d[3])),l=_r(_d[4]),o=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),g=_r(_d[11]),y=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),b=_r(_d[16]),x=_r(_d[17]),k=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),D=_r(_d[23]),T=_r(_d[24]),v=_r(_d[25]),I=_r(_d[26]);const $=e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,R=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)},O=e=>{const t=new Date(`${e}T12:00:00Z`);return M(e,-(t.getUTCDay()+6)%7)};function N(e){const t=(0,x.useSync)(e=>'staff'===e.kind&&!!e.venueId&&'off'!==e.mode&&'local'!==e.mode),s=(0,x.useSync)(e=>e.perms);return m.CAN.takings(e)&&(!t||s.includes('*')||s.includes('takings.view'))}const P=(e,t)=>{const s=(0,C.pageFor)(e);return!!s&&(!s.can||s.can(t))};function W({children:e,min:t=320,gap:a=16}){const i=s.default.Children.toArray(e).filter(Boolean);return(0,I.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:a},children:i.map((e,s)=>(0,I.jsx)(n.default,{style:{flexGrow:1,flexShrink:1,flexBasis:t,minWidth:Math.min(t,280)},children:e},s))})}function L({title:e,children:t,testID:s,action:a}){return(0,I.jsxs)(n.default,{testID:s,style:{backgroundColor:k.colours.surface,borderWidth:1,borderColor:k.colours.border,borderRadius:16,padding:18,gap:12,height:'100%'},children:[e?(0,I.jsx)(n.default,{role:"heading",'aria-level':2,style:{alignItems:'center'},children:(0,I.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}):null,t,a?(0,I.jsx)(n.default,{style:{alignItems:'center',marginTop:'auto'},children:a}):null]})}const B=[['today','Today'],['tomorrow','Tomorrow'],['next7','Next 7 days'],['thisweek','This week'],['next30','Next 30 days'],['last30','Last 30 days']];function U(e,t){if('today'===e)return[t,t];if('tomorrow'===e){const e=M(t,1);return[e,e]}if('next7'===e)return[t,M(t,6)];if('thisweek'===e){const e=O(t);return[e,M(e,6)]}return'next30'===e?[t,M(t,29)]:[M(t,-29),t]}const A=[['active','Not cancelled'],['all','All'],['pending','Needs confirming'],['confirmed','Booked'],['seated','Seated'],['finished','Done'],['cancelled','Cancelled'],['noshow','No-show']];function _({value:e,onChange:t,label:s,inputRef:a,testID:n}){return(0,I.jsx)(l.TextInput,{ref:a,testID:n,value:e,onChangeText:t,placeholder:`${s} (press /)`,placeholderTextColor:k.colours.muted,accessibilityLabel:s,style:[o.styles.input,{minWidth:260,flexGrow:1,maxWidth:420,fontSize:14}]})}const z=[['thisweek','This week'],['lastweek','Last week'],['last14','Last 14 days'],['thismonth','This month']];function E(e,t){const s=O(t);return'thisweek'===e?[s,M(s,6)]:'lastweek'===e?[M(s,-7),M(s,-1)]:'last14'===e?[M(t,-13),t]:[`${t.slice(0,8)}01`,t]}},1558,[34,402,102,426,827,794,1099,1062,1197,1143,1119,874,1039,891,1101,13,930,987,821,1417,1088,1459,1559,1548,1557,1560,25]); +__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,"MAX_ROWS",{enumerable:!0,get:function(){return c}}),_e.DataTable=function({caption:e,cols:a,rows:u,rowKey:h,sortKey:f,dir:b,onSort:x,onRowPress:y,rowLabel:w,testID:j,empty:p="Nothing to show."}){const C=Math.round(.8*a.reduce((e,r)=>e+r.width,0)),T=u.slice(0,c),$=(e,r,o,l)=>(0,i.jsx)(t.default,{role:o?'columnheader':'cell',...l??{},style:{flexGrow:e.width,flexShrink:1,flexBasis:0,minWidth:Math.round(.8*e.width),paddingHorizontal:10,paddingVertical:o?0:9,justifyContent:'center',alignItems:e.numeric?'flex-end':'flex-start'},children:r},e.key);return(0,i.jsx)(o.default,{horizontal:!0,contentContainerStyle:{minWidth:'100%'},style:{borderWidth:1,borderColor:s.colours.border,borderRadius:12},testID:j,children:(0,i.jsxs)(t.default,{role:"table",...n({'aria-label':e,'aria-rowcount':T.length+1}),style:{flexGrow:1,minWidth:C},children:[(0,i.jsx)(t.default,{role:"row",style:{flexDirection:'row',backgroundColor:s.colours.surface2,borderBottomWidth:1,borderColor:s.colours.border,borderTopLeftRadius:12,borderTopRightRadius:12},children:a.map(e=>{const o=f===e.key,c=o?'asc'===b?'ascending':'descending':'none';return $(e,x?(0,i.jsxs)(r.default,{accessibilityRole:"button",testID:`${j??'table'}-sort-${e.key}`,accessibilityLabel:`${e.label}. ${o?`Sorted ${c}. Press to sort ${'asc'===b?'descending':'ascending'}`:'Press to sort'}`,onPress:()=>x(e.key),style:({hovered:r,focused:o})=>({minHeight:44,flexDirection:'row',alignItems:'center',gap:4,paddingHorizontal:4,borderRadius:6,backgroundColor:r||o?s.colours.tilePressed:'transparent',alignSelf:e.numeric?'flex-end':'flex-start'}),children:[(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:o?s.colours.gold:s.colours.goldMuted,children:e.label}),(0,i.jsx)(l.T,{size:12,colour:o?s.colours.gold:s.colours.muted,accessibilityLabel:"",children:o?'asc'===b?'\u25b2':'\u25bc':'\u2195'})]}):(0,i.jsx)(t.default,{style:{minHeight:44,justifyContent:'center'},children:(0,i.jsx)(l.T,{size:13,weight:"semibold",colour:s.colours.goldMuted,children:e.label})}),!0,n({'aria-sort':c}))})}),T.length?T.map((e,o)=>{const n=a.map(r=>$(r,(0,i.jsx)(l.T,{size:14,colour:s.colours.text,style:{textAlign:r.numeric?'right':'left'},children:r.text?r.text(e):String(r.value(e))}))),c=({hovered:e,focused:r})=>({flexDirection:'row',borderTopWidth:o?1:0,borderColor:s.colours.hairline,backgroundColor:e||r?s.colours.tilePressed:o%2?'rgba(255,255,255,0.02)':'transparent'});return y?(0,i.jsx)(r.default,{role:"row",testID:`${j??'table'}-row-${o}`,accessibilityLabel:w?.(e),accessibilityHint:"Opens the details",onPress:()=>y(e),style:c,children:n},h(e)):(0,i.jsx)(t.default,{role:"row",style:c({}),children:n},h(e))}):(0,i.jsx)(t.default,{role:"row",style:{padding:18},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{colour:s.colours.muted,center:!0,children:p})})}),u.length>c?(0,i.jsx)(t.default,{role:"row",style:{padding:12},children:(0,i.jsx)(t.default,{role:"cell",style:{flex:1},children:(0,i.jsx)(l.T,{size:13,colour:s.colours.muted,center:!0,children:`Showing the first ${c} of ${u.length}. Export CSV for all of them.`})})}):null]})})},_r(d[0]);var r=e(_r(d[1])),o=e(_r(d[2])),t=e(_r(d[3])),l=_r(d[4]),s=_r(d[5]),i=_r(d[6]);const n=e=>e,c=500},1559,[34,402,295,102,794,821,25]); +__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.axisTop=x,_e.chartSummary=v,_e.WideChart=function({title:e,sub:$,points:b,fmt:M,today:j,height:p=260,testID:w,valueLabel:_="Amount"}){const[S,k]=(0,t.useState)(0),[D,I]=(0,t.useState)(!1),L=x(Math.max(0,...b.map(e=>e.value??0))),T=Math.max(0,S-64-12),z=p-18-34,A=b.length?T/b.length:0,F=Math.max(2,Math.min(34,.68*A)),P=Math.max(1,Math.ceil(b.length/Math.max(1,Math.floor(T/54)))),R=[{key:'date',label:'Date',width:140,value:e=>e.date,text:e=>(0,c.ddmmyyyy)(e.date)},{key:'v',label:_,width:140,value:e=>e.value??-1,text:e=>null==e.value?'No figure':`${M(e.value)}${e.future?' (booked so far)':''}`,numeric:!0}];return(0,f.jsxs)(i.default,{testID:w,style:{gap:8},children:[(0,f.jsxs)(i.default,{style:{alignItems:'center',gap:2},children:[(0,f.jsx)(i.default,{role:"heading",'aria-level':2,children:(0,f.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:e})}),$?(0,f.jsx)(o.T,{size:13,colour:s.colours.muted,center:!0,children:$}):null]}),(0,f.jsx)(i.default,{onLayout:e=>k(Math.floor(e.nativeEvent.layout.width)),role:"img",'aria-label':v(e,b,M),style:{width:'100%',height:p},children:S>0?(0,f.jsxs)(u.default,{width:S,height:p,'aria-hidden':!0,children:[[0,1,2,3,4].map(e=>{const t=18+z-z*e/4;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Line,{x1:64,x2:S-12,y1:t,y2:t,stroke:e?'rgba(255,255,255,0.08)':s.colours.border,strokeWidth:1}),(0,f.jsx)(n.Text,{x:56,y:t+4,fill:s.colours.muted,fontSize:11,textAnchor:"end",fontFamily:"Poppins_400Regular",children:M(L*e/4).replace(/\.00$/,'')})]},e)}),b.map((e,t)=>{const i=64+A*t+(A-F)/2,u=null==e.value?2:Math.max(2,e.value/L*z),o=null==e.value?'#3A3732':e.future?'rgba(207,164,95,0.45)':e.date===j?s.colours.goldLight:s.colours.gold;return(0,f.jsxs)(l.default.Fragment,{children:[(0,f.jsx)(n.Rect,{x:i,y:18+z-u,width:F,height:u,rx:Math.min(4,F/3),fill:o}),t%P===0||e.date===j?(0,f.jsx)(n.Text,{x:i+F/2,y:p-12,fill:e.date===j?s.colours.goldLight:s.colours.muted,fontSize:11,textAnchor:"middle",fontFamily:"Poppins_400Regular",children:y(e.date)}):null]},e.date)})]}):null}),(0,f.jsx)(i.default,{style:{alignItems:'center'},children:(0,f.jsx)(o.Button,{kind:"ghost",small:!0,label:D?'Hide the figures':'Show the figures',accessibilityLabel:`${D?'Hide':'Show'} the figures for ${e} as a table`,onPress:()=>I(e=>!e),testID:w?`${w}-figures`:void 0})}),D?(0,f.jsx)(h.DataTable,{caption:`${e}, figures`,cols:R,rows:b,rowKey:e=>e.date,testID:w?`${w}-table`:void 0}):null]})};var t=r(d[0]),l=e(t),i=e(r(d[1])),n=r(d[2]),u=e(n),o=r(d[3]),s=r(d[4]),h=r(d[5]),c=r(d[6]),f=r(d[7]);const y=e=>`${e.slice(8,10)}/${e.slice(5,7)}`;function x(e){if(e<=0)return 4;const t=e/4,l=Math.pow(10,Math.floor(Math.log10(t))),i=t/l,n=((l>=10?[1,1.5,2,2.5,3,4,5,6,7.5,8,10]:[1,2,3,4,5,6,8,10]).find(e=>e>=i-1e-9)??10)*l;return Math.max(4,4*Math.ceil(n))}function v(e,t,l){const i=t.filter(e=>null!=e.value&&!e.future);if(!i.length)return`${e}: no figures yet.`;const n=i.reduce((e,t)=>e+t.value,0),u=i.reduce((e,t)=>t.value>e.value?t:e,i[0]);return`${e}, ${(0,c.ddmmyyyy)(t[0].date)} to ${(0,c.ddmmyyyy)(t[t.length-1].date)}: total ${l(n)}, average ${l(n/i.length)} on ${i.length} days with figures, best ${l(u.value)} on ${(0,c.ddmmyyyy)(u.date)}.`}},1560,[34,102,797,794,821,1559,1557,25]); +__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.DeskGlyph=function({name:e,size:t,colour:s}){const l={stroke:s,strokeWidth:1.8,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return'history'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Path,{d:"M3 12a9 9 0 1 0 3-6.7L3 8",...l}),(0,v.jsx)(n.Path,{d:"M3 3v5h5M12 7v5l3 3",...l})]}):'leaver'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"9",cy:"8",r:"4",...l}),(0,v.jsx)(n.Path,{d:"M2 21c0-4 3-6 7-6 2 0 3.5.5 4.6 1.3M16 15l5 5M21 15l-5 5",...l})]}):'permissions'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Rect,{x:"3",y:"6",width:"18",height:"12",rx:"6",...l}),(0,v.jsx)(n.Circle,{cx:"15",cy:"12",r:"3",...l})]}):'settings'===e?(0,v.jsxs)(o.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,v.jsx)(n.Circle,{cx:"12",cy:"12",r:"3",...l}),(0,v.jsx)(n.Path,{d:"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1",...l})]}):(0,v.jsx)(f.CarGlyph,{name:e,size:t,colour:s})},_e.OnOff=C,_e.DeskPermissions=function(){const[e,s]=(0,t.useState)(null),[l,n]=(0,t.useState)(''),[o,d]=(0,t.useState)('level'),[c,h]=(0,t.useState)(null),[g,f]=(0,t.useState)(!1),[p,x]=(0,t.useState)(''),w=(0,t.useCallback)(async()=>{try{s(await(0,y.loadPermissions)()),n('')}catch(e){n(e.message)}},[]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{w()},0);return()=>clearTimeout(e)},[w]);const j=async(e,t)=>{f(!0),x('');const s=await e();f(!1);const l=s.ok?t:s.error??'Could not save. Try again.';x(l),I(l),s.ok&&await w()},S=(0,t.useMemo)(()=>b.DESK_LEVELS.map(t=>e?.roles.find(e=>e.key===t)).filter(Boolean),[e]);if(l)return(0,v.jsxs)(r.default,{style:{alignItems:'center',gap:10},children:[(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-error",children:l}),(0,v.jsx)(a.Button,{small:!0,kind:"secondary",label:"Try again",onPress:()=>{w()}})]});if(!e)return(0,v.jsx)(a.Muted,{center:!0,children:"Loading permissions\u2026"});const D=!!e.canEdit,L=e.staff.find(e=>e.ref===c);return(0,v.jsxs)(r.default,{testID:"desk-permissions",style:{gap:14,width:'100%',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"Switch each kind of access on or off for a whole level, or for one person. Every change saves straight away for the whole team, the server checks it on every phone and screen, and it is logged with who and when. Owners always keep full access."}),D?null:(0,v.jsx)(a.T,{center:!0,colour:m.colours.amber,testID:"dperm-readonly",children:"Only owners can change these. You can see them here."}),(0,y.permissionsLive)()?null:(0,v.jsx)(a.Muted,{center:!0,size:12,testID:"dperm-sample",children:"Sample team on this screen: nothing is saved."}),(0,v.jsxs)(a.Row,{gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"dperm-view-level",label:"By level",selected:'level'===o,onPress:()=>d('level')}),(0,v.jsx)(a.Chip,{testID:"dperm-view-person",label:"By person",selected:'person'===o,onPress:()=>d('person')})]}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"dperm-msg",children:p?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:p}):null}),'level'===o?(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:8},children:[(0,v.jsx)(a.Muted,{center:!0,size:13,children:b.LEVEL_NOTE}),(0,v.jsxs)(r.default,{role:"table",'aria-label':'Access by level',testID:"dperm-matrix",style:{borderWidth:1,borderColor:m.colours.border,borderRadius:14,overflow:'hidden'},children:[(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',backgroundColor:m.colours.surface2,borderBottomWidth:1,borderColor:m.colours.border},children:[(0,v.jsx)(r.default,{role:"columnheader",style:{flex:3,padding:10,justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Access"})}),S.map(e=>(0,v.jsx)(r.default,{role:"columnheader",style:{flex:1,padding:10,alignItems:'center',justifyContent:'center'},children:(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,children:(0,b.levelLabel)(e.key)})},e.key))]}),u.PERM_GROUPS.map(e=>(0,v.jsxs)(r.default,{children:[(0,v.jsx)(r.default,{role:"row",style:{paddingVertical:6,backgroundColor:'#14120F',borderTopWidth:1,borderColor:m.colours.border},children:(0,v.jsx)(r.default,{role:"rowheader",style:{alignItems:'center'},children:(0,v.jsx)(a.T,{size:13,weight:"semibold",colour:m.colours.goldMuted,center:!0,style:{letterSpacing:1},children:e.toUpperCase()})})}),u.PERM_CATALOG.filter(t=>t.group===e).map(e=>(0,v.jsxs)(r.default,{role:"row",style:{flexDirection:'row',alignItems:'center',borderTopWidth:1,borderColor:m.colours.border,minHeight:56},children:[(0,v.jsxs)(r.default,{role:"rowheader",style:{flex:3,paddingHorizontal:12,paddingVertical:6},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:e.label}),e.note?(0,v.jsx)(a.Muted,{size:11,center:!0,children:e.note}):null]}),S.map(t=>{const s=(0,b.levelSwitch)(t,e.key,D);return(0,v.jsx)(r.default,{role:"cell",style:{flex:1,alignItems:'center'},children:(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-${t.key}-${e.key}`,onPress:()=>{j(()=>(0,y.saveRolePerms)(t.key,(0,u.toggle)((0,u.ticks)(t.perms),e.key,!s.on)),`${(0,b.levelLabel)(t.key)}: ${e.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})},t.key)})]},e.key))]},e))]})]}):(0,v.jsxs)(r.default,{style:{width:'100%',maxWidth:1180,gap:10,alignItems:'center'},children:[(0,v.jsx)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:e.staff.map(e=>(0,v.jsx)(a.Chip,{testID:`dperm-person-${e.ref}`,label:$(e.name),sub:(0,b.levelLabel)(e.role),selected:c===e.ref,accessibilityLabel:`${e.name}, ${(0,b.levelLabel)(e.role)}${e.ownerAccess?', owner access':''}`,onPress:()=>h(e.ref)},e.ref))}),L?(0,v.jsxs)(r.default,{testID:"dperm-person",style:{width:'100%',gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{size:20,weight:"bold",colour:m.colours.gold,center:!0,accessibilityRole:"header",children:L.name.replace(' (example)','')}),(0,v.jsx)(a.Row,{gap:6,style:{justifyContent:'center'},children:L.extra.length||L.removed.length?(0,v.jsx)(a.Badge,{kind:"gold",label:"Changed just for them"}):(0,v.jsx)(a.Badge,{label:"Same as their level"})}),(0,v.jsx)(k.Grid,{min:340,gap:10,children:u.PERM_CATALOG.map(t=>{const s=(0,b.personSwitch)(L,t.key,e.me,D);return(0,v.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:10,padding:10,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{size:14,center:!0,children:t.label}),(0,v.jsxs)(a.Muted,{size:11,center:!0,children:[t.group,s.why?` \xb7 ${s.why}`:'']})]}),(0,v.jsx)(C,{s:s,busy:g,testID:`dperm-p-${t.key}`,onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,(0,u.toggle)((0,u.ticks)(L.effective),t.key,!s.on)),`${$(L.name)}: ${t.label} switched ${s.on?'off':'on'}. Saved and logged.`)}})]},t.key)})}),D&&(L.extra.length||L.removed.length)?(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:"dperm-reset",label:"Back to their level",onPress:()=>{j(()=>(0,y.savePersonPerms)(L.ref,null),`${$(L.name)} is back to the ${(0,b.levelLabel)(L.role)} level. Saved and logged.`)}}):null,(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Temporary manager, temporary owner and cash up switches are in Settings, Staff & roles."})]}):(0,v.jsx)(a.Muted,{center:!0,children:"Pick someone to see and switch exactly what they can do."})]}),(0,v.jsxs)(r.default,{testID:"dperm-log",style:{width:'100%',maxWidth:1180,borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Changes log"}),e.log.length?e.log.slice(0,10).map(e=>(0,v.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${(0,u.logWhen)(e.at)}. ${(0,u.logWords)(e)}${e.reason?`. ${e.reason}`:''}`,style:{paddingVertical:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{center:!0,size:14,children:(0,u.logWords)(e)}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[(0,u.logWhen)(e.at),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,v.jsx)(a.Muted,{center:!0,children:"No changes yet."})]})]})},_e.DeskLeavers=function(){const{meId:e}=(0,p.useCtx)(6e4),s=(0,p.useSignedIn)(),l=(0,c.useOwner)(e=>e.staff),n=(0,h.useLeavers)(e=>e.notes),[o,d]=(0,t.useState)(null),[g,y]=(0,t.useState)(''),[f,x]=(0,t.useState)(''),[w,j]=(0,t.useState)(''),C=s?.id??e,S=(s?.name??'Owner').replace(' (example)',''),D=l.filter(e=>!e.name.includes('(example)')).sort((e,t)=>e.name.localeCompare(t.name)),L=D.filter(e=>e.active),T=D.filter(e=>!e.active),M=o?l.find(e=>e.id===o.id):void 0,P=()=>{d(null),y(''),x('')},R=(e,t)=>{const s=t?(0,b.leaverBlock)(e,C):null;return(0,v.jsxs)(r.default,{testID:`leaver-row-${e.id}`,style:{flexDirection:'row',alignItems:'center',gap:12,padding:12,borderWidth:1,borderColor:m.colours.border,borderRadius:12,backgroundColor:m.colours.surface},children:[(0,v.jsxs)(r.default,{style:{flex:1},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:e.name}),(0,v.jsxs)(a.Muted,{center:!0,size:12,children:[e.job||(0,b.levelLabel)(e.role),e.temp?' \xb7 temporary':'',t?'':' \xb7 app switched off']})]}),t?s?(0,v.jsx)(r.default,{style:{maxWidth:220},children:(0,v.jsx)(a.Muted,{center:!0,size:12,children:s})}):(0,v.jsx)(a.Button,{small:!0,kind:"secondary",testID:`leaver-off-${e.id}`,label:"Switch off their app",accessibilityLabel:`Switch off ${e.name}\u2019s app`,onPress:()=>d({id:e.id,on:!1})}):(0,v.jsx)(a.Button,{small:!0,testID:`leaver-on-${e.id}`,label:"Switch back on",accessibilityLabel:`Switch ${e.name}\u2019s app back on`,onPress:()=>d({id:e.id,on:!0})})]},e.id)};return(0,v.jsxs)(r.default,{testID:"desk-leavers",style:{gap:14,width:'100%',maxWidth:1180,alignSelf:'center',alignItems:'center'},children:[(0,v.jsx)(a.Muted,{center:!0,style:{maxWidth:820},children:"When someone leaves, switch off their app. They can\u2019t sign in or access new shared data. Information already downloaded may stay on their device until it refreshes. Nothing is deleted: their hours, tips, rota history and pay records stay, and you can switch them back on."}),(0,v.jsx)(r.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',testID:"leaver-msg",children:w?(0,v.jsx)(a.T,{center:!0,colour:m.colours.goldLight,children:w}):null}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`Team with the app on (${L.length})`}),(0,v.jsx)(k.Grid,{min:420,gap:8,children:L.map(e=>R(e,!0))})]}),(0,v.jsxs)(r.default,{style:{width:'100%',gap:8},testID:"leaver-off-list",children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,colour:m.colours.gold,accessibilityRole:"header",children:`App switched off (${T.length})`}),T.length?(0,v.jsx)(k.Grid,{min:420,gap:8,children:T.map(e=>R(e,!1))}):(0,v.jsx)(a.Muted,{center:!0,children:"Nobody is switched off."})]}),(0,v.jsxs)(r.default,{testID:"leaver-log",style:{width:'100%',borderWidth:1,borderColor:m.colours.border,borderRadius:14,padding:14,gap:4,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Leaving log on this computer"}),n.length?n.slice(0,12).map(e=>(0,v.jsx)(a.Muted,{center:!0,size:13,children:`${(0,u.logWhen)(e.at)} \xb7 ${e.by} switched ${$(e.name)}\u2019s app ${e.on?'back on':'off'} \xb7 ${e.reason}`},e.id)):(0,v.jsx)(a.Muted,{center:!0,size:13,children:"No changes yet."})]}),o&&M?(0,v.jsxs)(a.Sheet,{visible:!0,onClose:P,title:o.on?`Switch ${$(M.name)}\u2019s app back on?`:`Switch off ${$(M.name)}\u2019s app?`,maxWidth:620,testID:"leaver-sheet",children:[o.on?(0,v.jsx)(a.T,{center:!0,children:`${$(M.name)} can sign in and use their app again with their own link. Their old hours and tips are all still there.`}):(0,v.jsx)(r.default,{style:{gap:6},children:(0,b.switchOffWords)($(M.name)).map(e=>(0,v.jsx)(a.T,{center:!0,children:e},e))}),o.on?null:(0,v.jsxs)(r.default,{style:{gap:8,alignItems:'center'},children:[(0,v.jsx)(a.T,{weight:"semibold",center:!0,children:"Why are they leaving?"}),(0,v.jsx)(a.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:b.LEAVE_REASONS.map(e=>(0,v.jsx)(a.Chip,{testID:`leaver-reason-${e.split(' ')[0].toLowerCase()}`,label:e,selected:g===e,onPress:()=>y(e)},e))})]}),(0,v.jsx)(a.Field,{label:o.on?'Note (optional)':'Other'===g?'Reason':'Note (optional)',value:f,onChangeText:x,testID:"leaver-note",placeholder:o.on?'e.g. Back for the summer':'e.g. Last shift Saturday'}),(0,v.jsxs)(a.Row,{gap:10,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Button,{kind:"secondary",label:"Cancel",onPress:P,testID:"leaver-cancel"}),(0,v.jsx)(a.Button,{testID:"leaver-yes",label:o.on?`Yes, switch ${$(M.name)} back on`:`Yes, switch off ${$(M.name)}\u2019s app`,disabled:!o.on&&!(0,b.leaverReasonOk)(g,f),onPress:()=>{if(!M||!o)return;if(!1===o.on&&((0,b.leaverBlock)(M,C)||!(0,b.leaverReasonOk)(g,f)))return;c.useOwner.getState().updateStaff(M.id,{active:o.on}),h.useLeavers.getState().add({staffId:M.id,name:M.name,on:o.on,at:(new Date).toISOString(),by:S,reason:o.on?f.trim()||'Back at work':(0,b.leaverReasonText)(g,f)});const e=o.on?`${$(M.name)}\u2019s app is switched back on.`:`${$(M.name)}\u2019s app is switched off. Nothing was deleted.`;j(e),I(e),P()}})]})]}):null]})},_e.DeskCoversHistory=function(){const{rid:e,today:s}=(0,p.useCtx)(6e4),l=(0,d.useBookings)(e),[n,o]=(0,t.useState)(28),[c,h]=(0,t.useState)({k:'date',d:'desc'}),u=(0,w.lastDays)(s,n+1).filter(e=>e{const t=l.filter(t=>t.date===e),s=t.filter(e=>'cancelled'!==e.status&&'noshow'!==e.status);return{date:e,bookings:s.filter(e=>!e.walkIn).length,covers:s.reduce((e,t)=>e+(t.partySize||0),0),walkIns:s.filter(e=>e.walkIn).length,noShows:t.filter(e=>'noshow'===e.status).length,cancelled:t.filter(e=>'cancelled'===e.status).length}}),g=u.map(e=>({date:e.date,value:e.covers})),y=(0,w.sortRows)(u,S.find(e=>e.key===c.k),c.d),f=u.reduce((e,t)=>e+t.covers,0);return(0,v.jsxs)(r.default,{testID:"desk-covers-history",style:{gap:14,width:'100%'},children:[(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,28,42].map(e=>(0,v.jsx)(a.Chip,{testID:`hist-days-${e}`,label:"Last "+(7===e?'7 days':28===e?'4 weeks':'6 weeks'),selected:n===e,onPress:()=>o(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:m.colours.goldLight,children:`${f} covers over ${u.length} days \xb7 ${u.reduce((e,t)=>e+t.noShows,0)} no-shows`}),(0,v.jsx)(k.Panel,{children:(0,v.jsx)(j.WideChart,{title:"Covers per day",sub:"Bookings and walk-ins that came (no-shows and cancellations left out)",points:g,fmt:e=>String(Math.round(e)),today:s,testID:"chart-covers-history",valueLabel:"Covers"})}),(0,v.jsx)(x.DataTable,{caption:"Bookings and covers by day",cols:S,rows:y,rowKey:e=>e.date,sortKey:c.k,dir:c.d,testID:"hist-days-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.date)}: ${e.bookings} bookings, ${e.covers} covers, ${e.walkIns} walk-ins, ${e.noShows} no-shows, ${e.cancelled} cancelled`}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"For one exact date, use the Look back tab."})]})},_e.DeskTemps=function(){const{today:e}=(0,p.useCtx)(6e4),s=(0,g.useSafetyView)('managers'),[l,n]=(0,t.useState)('all'),[o,d]=(0,t.useState)(14),[c,h]=(0,t.useState)({k:'at',d:'desc'}),u=(s.allPoints??s.points).filter(e=>'fridge'===e.kind||'freezer'===e.kind),y=(0,w.lastDays)(e,o)[0],f=s.entries.filter(e=>('fridge'===e.kind||'freezer'===e.kind)&&'number'==typeof(e.correctedValue??e.value)&&e.at.slice(0,10)>=y&&!e.archived&&('all'===l||e.pointId===l)).map(e=>({id:e.id,at:e.at,unit:e.name,value:e.correctedValue??e.value,ok:e.ok,by:(e.by||'').replace(' (example)',''),action:e.corrective??''})),b=(0,w.sortRows)(f,D.find(e=>e.key===c.k),c.d),j=f.filter(e=>!e.ok).length;return(0,v.jsxs)(r.default,{testID:"desk-temps",style:{gap:12,width:'100%'},children:[(0,v.jsxs)(a.Row,{gap:6,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(a.Chip,{testID:"temps-unit-all",label:"All units",selected:'all'===l,onPress:()=>n('all')}),u.map(e=>(0,v.jsx)(a.Chip,{testID:`temps-unit-${e.id}`,label:e.name,sub:e.archived?'no longer used':'freezer'===e.kind?'Freezer':'Fridge',selected:l===e.id,onPress:()=>n(e.id)},e.id))]}),(0,v.jsx)(a.Row,{gap:8,style:{justifyContent:'center'},children:[7,14,28].map(e=>(0,v.jsx)(a.Chip,{testID:`temps-days-${e}`,label:`Last ${e} days`,selected:o===e,onPress:()=>d(e)},e))}),(0,v.jsx)(a.T,{center:!0,weight:"semibold",colour:j?m.colours.amber:m.colours.goldLight,testID:"temps-summary",children:f.length?`${f.length} readings \xb7 ${j?`${j} out of range`:'all in range'}`:'No fridge or freezer readings in these days'}),(0,v.jsx)(x.DataTable,{caption:"Fridge and freezer temperatures",cols:D,rows:b,rowKey:e=>e.id,sortKey:c.k,dir:c.d,testID:"temps-table",onSort:e=>h(t=>({k:e,d:t.k===e&&'desc'===t.d?'asc':'desc'})),rowLabel:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}, ${e.unit}, ${e.value} degrees, ${e.ok?'in range':'out of range'}, by ${e.by}`,empty:"No readings to show."}),(0,v.jsx)(a.Muted,{center:!0,size:12,children:"Limits for each fridge and freezer are in Settings, Food safety log."})]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),r=e(_r(_d[3])),n=_r(_d[4]),o=e(n),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),h=_r(_d[8]),u=_r(_d[9]),g=_r(_d[10]),y=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),v=_r(_d[20]);const I=e=>{try{s.default.announceForAccessibility?.(e)}catch{}},$=e=>e.replace(' (example)','').split(' ')[0];function C({s:e,onPress:t,testID:s,busy:n}){const o=e.locked||n;return(0,v.jsxs)(l.default,{testID:s,accessibilityRole:"switch",accessibilityState:{checked:e.on,disabled:o},'aria-checked':e.on,accessibilityLabel:e.spoken,disabled:o,onPress:t,style:({hovered:t,focused:s})=>({minWidth:64,minHeight:40,alignItems:'center',justifyContent:'center',borderRadius:10,backgroundColor:t||s?m.colours.tilePressed:'transparent',opacity:e.locked?.75:1}),children:[(0,v.jsx)(r.default,{style:{width:46,height:26,borderRadius:13,borderWidth:1.5,borderColor:e.on?m.colours.gold:m.colours.muted,backgroundColor:e.on?m.colours.gold:'#26231E',justifyContent:'center',paddingHorizontal:2,alignItems:e.on?'flex-end':'flex-start'},children:(0,v.jsx)(r.default,{style:{width:19,height:19,borderRadius:10,backgroundColor:e.on?'#0B0B0B':'#BBB4A6'}})}),(0,v.jsx)(a.T,{size:11,colour:e.on?m.colours.goldLight:m.colours.muted,center:!0,children:e.locked&&e.on?'Always on':e.on?'On':'Off'})]})}const S=[{key:'date',label:'Date',width:150,value:e=>e.date,text:e=>(0,w.ddmmyyyy)(e.date)},{key:'bookings',label:'Bookings',width:110,value:e=>e.bookings,numeric:!0},{key:'covers',label:'Covers',width:110,value:e=>e.covers,numeric:!0},{key:'walkIns',label:'Walk-ins',width:110,value:e=>e.walkIns,numeric:!0},{key:'noShows',label:'No-shows',width:110,value:e=>e.noShows,numeric:!0},{key:'cancelled',label:'Cancelled',width:110,value:e=>e.cancelled,numeric:!0}];const D=[{key:'at',label:'Date and time',width:170,value:e=>e.at,text:e=>`${(0,w.ddmmyyyy)(e.at.slice(0,10))} ${(0,w.ukTime)(e.at)}`},{key:'unit',label:'Fridge or freezer',width:220,value:e=>e.unit},{key:'value',label:'Reading \xb0C',width:110,value:e=>e.value,text:e=>`${e.value}\xb0C`,numeric:!0},{key:'ok',label:'In range',width:100,value:e=>e.ok?'Yes':'No'},{key:'by',label:'Checked by',width:140,value:e=>e.by},{key:'action',label:'What was done',width:240,value:e=>e.action}]},1561,[34,281,402,102,797,794,874,891,1562,1000,1227,1466,821,1552,1088,1559,1563,1557,1560,1558,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLeavers",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),s=r(d[1]),n=r(d[2]),o=(e=n)&&e.__esModule?e:{default:e};const c=(0,t.create)()((0,s.persist)(e=>({notes:[],add:t=>e(e=>({notes:[{...t,id:`lv-${Date.now()}-${Math.random().toString(36).slice(2,7)}`},...e.notes].slice(0,200)}))}),{name:'covercharge-desk-leavers-v1',storage:(0,s.createJSONStorage)(()=>o.default)}))},1562,[846,849,839]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESK_LEVELS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"LEVEL_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"levelLabel",{enumerable:!0,get:function(){return s}}),e.levelSwitch=function(t,o,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=s(t.key),h=t.owner||(0,n.has)(t.perms,o),u=t.owner?'Owners always have everything':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},e.personSwitch=function(t,o,s,c){const f=n.PERM_CATALOG.find(n=>n.key===o),l=t.name.split(' ')[0],h=(0,n.has)(t.effective,o),u='owner'===t.role?'Owners always have everything':t.ownerAccess||t.base.includes('*')?'Owner access: everything':t.ref===s?'You can\u2019t change your own access':c?void 0:'Only owners can change this';return{on:h,locked:!!u,why:u,spoken:`${l}: ${f?.label??o}. ${h?'On':'Off'}${u?`. ${u}`:''}.`}},Object.defineProperty(e,"LEAVE_REASONS",{enumerable:!0,get:function(){return c}}),e.leaverBlock=function(n,t){return'owner'===n.role?'Owners can\u2019t be switched off here.':n.ownerAccess?'Has owner access. Take that off in Staff & roles first.':n.id===t?'You can\u2019t switch off your own app.':n.name.includes('(example)')?'Sample person.':null},Object.defineProperty(e,"leaverReasonOk",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"leaverReasonText",{enumerable:!0,get:function(){return l}}),e.switchOffWords=function(n){return[`${n}\u2019s access to the shared app is switched off. They can\u2019t sign in or get new data.`,"Nothing is deleted. Their hours, tips, rota history and pay records are all kept.","Already downloaded information may stay on their device until it refreshes. You can switch access back on at any time."]};var n=r(d[0]);const t=['owner','manager','supervisor','head_chef','staff'],o='Front of house, kitchen porters and other team members are the Staff level. To change one person, use By person.',s=t=>n.ROLE_LABEL[t]??t;const c=['Left the job','End of the season','Temporary work finished','Dismissed','Other'];const f=(n,t)=>!!n&&('Other'!==n||t.trim().length>=3),l=(n,t)=>('Other'===n?t.trim():t.trim()?`${n}: ${t.trim()}`:n).slice(0,200)},1563,[1000]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DesktopInstallPage=function(){const e='undefined'!=typeof navigator?navigator.userAgent:'',s=(0,o.isMacUa)(e,'undefined'!=typeof navigator?navigator.platform:''),u=(0,o.browserOf)(e),[,p]=(0,t.useState)(0),[f,j]=(0,t.useState)('');return(0,t.useEffect)(()=>(0,o.onInstallChange)(()=>p(e=>e+1)),[]),(0,c.jsxs)(n.default,{style:{gap:12},testID:"desk-install-page",children:[(0,o.installedWindow)()?(0,c.jsx)(l.T,{center:!0,colour:i.colours.goldLight,children:"CoverCharge for desktop is installed on this computer."}):(0,o.canPromptInstall)()?(0,c.jsxs)(n.default,{style:{alignItems:'center',gap:6},children:[(0,c.jsx)(l.Button,{label:"Install now",testID:"desk-install-now",onPress:async()=>{const e=await(0,o.promptInstall)();j(e?'Installed. CoverCharge opens in its own window.':'Not installed. You can do it later from here.')}}),f?(0,c.jsx)(n.default,{'aria-live':'polite',children:(0,c.jsx)(l.Muted,{center:!0,children:f})}):null]}):(0,c.jsx)(h,{head:"On this computer",lines:(0,o.installSteps)(u,s)}),(0,c.jsx)(h,{head:"Windows PC: Chrome or Edge",lines:[...(0,o.installSteps)('edge',!1).slice(0,1),(0,o.installSteps)('chrome',!1)[0],'Click Install, then pin CoverCharge to the taskbar.']}),(0,c.jsx)(h,{head:"Mac: Chrome, Edge or Safari",lines:[(0,o.installSteps)('chrome',!0)[0],(0,o.installSteps)('safari',!0)[0],'Safari\u2019s Dock app keeps its own sign-in: sign in once inside it.']}),(0,c.jsx)(l.Muted,{center:!0,children:"It is the same CoverCharge as the phone apps: same sign-in, same data and the same permissions, checked by the server. It updates itself; there is nothing to download or keep up to date."})]})};var e,t=r(d[0]),s=r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),i=r(d[3]),o=r(d[4]),c=r(d[5]);function h({head:e,lines:t}){return(0,c.jsxs)(n.default,{style:{gap:6,padding:14,borderWidth:1,borderColor:i.colours.border,borderRadius:12,backgroundColor:i.colours.surface},children:[(0,c.jsx)(n.default,{role:"heading",'aria-level':3,children:(0,c.jsx)(l.T,{weight:"semibold",center:!0,colour:i.colours.goldLight,children:e})}),(0,c.jsx)(n.default,{role:"list",children:t.map((e,t)=>(0,c.jsx)(n.default,{role:"listitem",style:{paddingVertical:3},children:(0,c.jsx)(l.T,{size:14,center:!0,children:`${t+1}. ${e}`})},t))})]})}},1564,[34,102,794,821,1565,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canPromptInstall",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"onInstallChange",{enumerable:!0,get:function(){return s}}),_e.promptInstall=async function(){if(!e)return!1;const n=e;e=null,await n.prompt();const o=await n.userChoice;return t.forEach(e=>e()),'accepted'===o.outcome},_e.installedWindow=function(){try{return!!n()?.matchMedia?.('(display-mode: standalone)').matches||!!n()?.navigator?.standalone}catch{return!1}},_e.browserOf=function(e){return/Edg\//.test(e)?'edge':/Firefox\//.test(e)?'firefox':/Chrome\//.test(e)||/CriOS/.test(e)?'chrome':/Safari\//.test(e)&&/Version\//.test(e)?'safari':'other'},Object.defineProperty(_e,"isMacUa",{enumerable:!0,get:function(){return l}}),_e.installSteps=function(e,t){return'chrome'===e?["Click the install icon at the right of the address bar (a small screen with an arrow), or the \u22ee menu, then \u201cCast, save and share\u201d \u203a \u201cInstall page as app\u2026\u201d.",'Click Install. CoverCharge opens in its own window and is added to your '+(t?'Applications folder and Launchpad.':'Start menu. Right-click it in the taskbar to pin it.')]:'edge'===e?['Click the \u22ef menu, then \u201cApps\u201d \u203a \u201cInstall this site as an app\u201d.','Click Install. CoverCharge opens in its own window. Pin it to the taskbar or Start when Edge asks.']:'safari'===e?['In the menu bar, choose File \u203a Add to Dock (macOS Sonoma 14 or later).','Click Add. Open CoverCharge from the Dock, then sign in once inside it (the Dock app keeps its own sign-in).']:'firefox'===e?['Firefox can\u2019t install web apps. It works fine in a normal tab: bookmark this page.','To get it in its own window, open this page in Chrome or Edge and install it there.']:['Open this page in Chrome or Edge (Windows or Mac), or Safari 17 or later on a Mac, to install it.']};let e=null;const t=new Set,n=()=>'undefined'!=typeof window?window:void 0;n()?.addEventListener&&(n().addEventListener('beforeinstallprompt',n=>{n.preventDefault(),e=n,t.forEach(e=>e())}),n().addEventListener('appinstalled',()=>{e=null,t.forEach(e=>e())}));const o=()=>!!e,s=e=>(t.add(e),()=>{t.delete(e)});const l=(e,t="")=>/Mac/i.test(t)||/Macintosh|Mac OS X/.test(e)},1565,[]); +__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.DesktopShell=function(){const{rid:e,r:c,role:f,today:_,now:$,meId:V,me:Q}=(0,z.useCtx)(3e4);(0,m.useTipsPosted)(e,_);const Y=(0,z.useSignedIn)();(0,x.useSoldOutLink)(!0,(Y?.name??Q).replace(' (example)',''));const[ee,te]=(0,a.useState)({kind:'tab',tab:'home'}),[se,ae]=(0,a.useState)(''),oe=(0,a.useRef)(null);(0,a.useEffect)(()=>{(0,z.ensureAttendance)(_,$),(0,M.ensureChat)($)},[_]),globalThis.__ccNow=$.getTime();const ne=(0,a.useCallback)((e,t=null)=>{if('more'===e&&t){const e=q[t];return void te(e?{kind:'edit',id:e}:{kind:'page',id:t})}te('more'===e?{kind:'page',id:'help'}:{kind:'tab',tab:e})},[]);(0,a.useEffect)(()=>(S.useVoiceNav.setState({go:ne}),()=>S.useVoiceNav.setState({go:null})),[ne]),(0,a.useEffect)(()=>{D.PITCH&&(globalThis.__pitchGo=ne,globalThis.__deskGo=e=>te(e))},[ne]),(0,E.useAlertWatcher)(e,{nag:'staff'!==f}),(0,w.useScheduledNotices)({rid:e,staffId:Y?.id??'',name:Q,onOpen:e=>'bookings'===e?ne('bookings'):'chat'===e?ne('chat'):ne('more',e)}),(0,y.useOffRotaAlerts)({enabled:'staff'!==f&&!!Y}),(0,a.useEffect)(()=>((0,T.warmDesktopStt)(),(0,C.installVoiceKeys)()),[]);const re=(0,a.useMemo)(()=>[...G,...U].map(e=>e.s),[]);(0,a.useEffect)(()=>{const e=e=>{if(!(e.metaKey||e.ctrlKey))return;const t=e.key.toLowerCase();if('k'===t)return e.preventDefault(),void oe.current?.focus();if(/^[1-9]$/.test(e.key)&&!e.shiftKey){const t=re[Number(e.key)-1];return void(t&&(e.preventDefault(),te(t)))}if('z'===t&&!Z(e.target)){const t=(0,W.activeUndo)();if(!t)return;e.preventDefault(),e.shiftKey?t.redo():t.undo()}if('y'===t&&!Z(e.target)){const t=(0,W.activeUndo)();t&&(e.preventDefault(),t.redo())}};return window.addEventListener('keydown',e),()=>window.removeEventListener('keydown',e)},[re]);const ie=O.PAGES.filter(e=>(!e.can||e.can(f))&&!q[e.id]),le=(0,a.useMemo)(()=>{const e=se.trim().toLowerCase(),t={};return ie.filter(t=>!e||`${t.title} ${t.sub}`.toLowerCase().includes(e)).forEach(e=>{(t[e.group]??=[]).push(e)}),t},[ie,se]),de=G.filter(e=>'tab'!==e.s.kind||'forecast'!==e.s.tab||p.CAN.forecasts(f)),ue=p.CAN.forecasts(f)?U:U.filter(e=>'rota'===e.s.id),ce='page'===ee.kind?(0,O.pageFor)(ee.id):void 0,be='tab'===ee.kind?G.find(e=>X(e.s,ee))?.label:'edit'===ee.kind?U.find(e=>X(e.s,ee))?.label:ce?.title,he='tab'===ee.kind?G.find(e=>X(e.s,ee))?.tip:'page'===ee.kind?`${ce?.sub??''}. Press ${(0,N.CMD)()}K to jump to any page, or hold Space and ask.`:'',ge=({label:e,s:t,n:s})=>{const a=X(t,ee);return(0,K.jsxs)(o.default,{accessibilityRole:"button",accessibilityState:{selected:a},testID:`side-${e.toLowerCase().replace(/[^a-z]+/g,'-')}`,onPress:()=>te(t),style:({hovered:e})=>({flexDirection:'row',alignItems:'center',paddingVertical:7,paddingHorizontal:10,borderRadius:8,backgroundColor:a?A.colours.goldTint:e?A.colours.tilePressed:'transparent',borderLeftWidth:3,borderLeftColor:a?A.colours.gold:'transparent'}),children:[(0,K.jsx)(g.T,{size:14,weight:a?'semibold':'regular',colour:a?A.colours.gold:A.colours.text,style:{flex:1},numberOfLines:1,children:e}),s?(0,K.jsxs)(g.T,{size:11,colour:A.colours.muted,children:[(0,N.CMD)(),s]}):null]})},fe=({t:e})=>(0,K.jsx)(g.T,{size:11,weight:"semibold",colour:A.colours.goldMuted,style:{letterSpacing:1,marginTop:14,marginBottom:4,paddingHorizontal:10},children:e.toUpperCase()}),pe='owner'===f?'OWNER':'manager'===f?'MANAGER':'STAFF';return(0,K.jsxs)(i.SafeAreaView,{style:{flex:1,backgroundColor:A.colours.bg},testID:"desktop-shell",children:[(0,K.jsxs)(r.default,{style:{flex:1,flexDirection:'row'},children:[(0,K.jsxs)(r.default,{style:{width:250,backgroundColor:(0,t.soutersSurface)('#0E0E0E'),borderRightWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{padding:12,gap:6,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(g.Row,{gap:10,children:[(0,K.jsx)(u.RestaurantLogo,{rid:e,size:40}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsx)(u.VenueName,{name:c.name}),(0,K.jsx)(g.Row,{gap:6,children:(0,K.jsx)(l.AppBadge,{label:pe})})]})]}),(0,K.jsx)(u.PoweredBy,{}),(0,K.jsx)(s.TextInput,{ref:oe,testID:"side-filter",value:se,onChangeText:ae,placeholder:`Find a page (${(0,N.CMD)()}K)`,placeholderTextColor:A.colours.muted,style:[g.styles.input,{paddingVertical:6,fontSize:13}]})]}),(0,K.jsxs)(n.default,{contentContainerStyle:{padding:8,paddingBottom:30},children:[se?null:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fe,{t:"Run the day"}),de.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:t+1},e.label)),(0,K.jsx)(fe,{t:"Drag-and-drop editors"}),ue.map((e,t)=>(0,K.jsx)(ge,{label:e.label,s:e.s,n:de.length+t+1},e.label))]}),Object.entries(le).map(([e,t])=>(0,K.jsxs)(r.default,{children:[(0,K.jsx)(fe,{t:e}),t.map(e=>(0,K.jsx)(ge,{label:e.title,s:{kind:'page',id:e.id}},e.id))]},e))]})]}),(0,K.jsxs)(r.default,{style:{flex:1,minWidth:0},children:[(0,K.jsxs)(r.default,{style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:20,paddingVertical:10,borderBottomWidth:1,borderColor:A.colours.border},children:[(0,K.jsxs)(r.default,{style:{flex:1},children:[(0,K.jsx)(r.default,{testID:"desk-title",children:(0,K.jsx)(g.T,{size:24,weight:"bold",children:be??''})}),(0,K.jsxs)(g.Muted,{size:12,children:[Y?`Signed in as ${Y.name} \xb7 ${p.ROLE_LABEL[f]}`:`Preview \xb7 ${p.ROLE_LABEL[f]}`," \xb7 ",c.name]})]}),(0,K.jsxs)(r.default,{style:{alignItems:'flex-end'},children:[(0,K.jsx)(g.T,{size:15,weight:"bold",colour:A.colours.gold,children:"Talk to CoverCharge"}),(0,K.jsxs)(g.Muted,{size:12,children:["Hold Space, or ",(0,N.CMD)(),"\u21e7G"]})]}),(0,K.jsx)(v.VoiceSlot,{size:76})]}),(0,K.jsxs)(r.default,{style:{flex:1,padding:16,gap:10,minHeight:0},children:[he?(0,K.jsx)(F.Tip,{children:he}):null,'edit'===ee.kind?(0,K.jsx)(J,{id:ee.id,rid:e,me:Q,role:'owner'===f?'owner':'manager',today:_,venue:c.name}):(0,K.jsxs)(n.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:60,maxWidth:1100},keyboardShouldPersistTaps:"handled",children:['tab'===ee.kind&&'home'===ee.tab?(0,K.jsx)(H.Dashboard,{go:ne}):null,'tab'===ee.kind&&'orders'===ee.tab?(0,K.jsx)(I.Orders,{}):null,'tab'===ee.kind&&'bookings'===ee.tab?(0,K.jsx)(R.Bookings,{}):null,'tab'===ee.kind&&'forecast'===ee.tab?(0,K.jsx)(P.Forecasts,{go:ne}):null,'tab'===ee.kind&&'chat'===ee.tab?(0,K.jsx)(M.Chat,{go:ne}):null,ce?(0,K.jsx)(ce.C,{go:ne}):'page'===ee.kind?(0,K.jsx)(g.Muted,{children:"That page isn\u2019t available for your role."}):null]})]})]})]}),(0,K.jsx)(j.SeatAllergenReminder,{rid:e}),'staff'!==f?(0,K.jsx)(h.PrintHost,{rid:e}):null,'staff'!==f?(0,K.jsx)(b.AlertHost,{variant:"managers",rid:e,me:Q,onOpen:e=>ne('takeaway'===e.kind?'orders':'email'===e.kind||'test'===e.kind?'more':'bookings','email'===e.kind||'test'===e.kind?'notifications':null)}):null,(0,K.jsx)(L.AssistantSheet,{}),(0,K.jsx)(B.OnboardingHost,{go:ne}),(0,K.jsx)(k.CoachHost,{})]})};var t=_r(d[0]),s=_r(d[1]),a=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),i=_r(d[6]),l=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]),h=_r(d[11]),g=_r(d[12]),f=_r(d[13]),p=_r(d[14]),x=_r(d[15]),m=_r(d[16]),k=_r(d[17]),j=_r(d[18]),y=_r(d[19]),w=_r(d[20]),C=_r(d[21]),S=_r(d[22]),v=_r(d[23]),T=_r(d[24]),E=_r(d[25]),D=_r(d[26]),A=_r(d[27]),L=_r(d[28]),R=_r(d[29]),M=_r(d[30]),z=_r(d[31]),H=_r(d[32]),P=_r(d[33]),B=_r(d[34]),I=_r(d[35]),O=_r(d[36]);_r(d[37]);var _=_r(d[38]),N=_r(d[39]),W=_r(d[40]),$=_r(d[41]),V=_r(d[42]),F=_r(d[43]),K=_r(d[44]);const G=[{label:'Today',s:{kind:'tab',tab:'home'},tip:'Hold Space and say \u201chow many Covers tonight?\u201d for a quick answer without leaving this screen.'},{label:'Orders',s:{kind:'tab',tab:'orders'},tip:'New takeaway and table orders land here first. Say \u201cshow new orders\u201d to jump back any time.'},{label:'Bookings',s:{kind:'tab',tab:'bookings'},tip:'Bookings that need a yes or no are marked in amber. Hold Space and say \u201caccept the 7 o\u2019clock\u201d.'},{label:'Forecasts',s:{kind:'tab',tab:'forecast'},tip:'The forecast learns from your past weeks; the more you trade, the better it gets.'},{label:'Staff chat',s:{kind:'tab',tab:'chat'},tip:'Messages here go to staff in the Staff app only, never by text or WhatsApp.'}],U=[{label:'Table plan',s:{kind:'edit',id:'plan'},tip:''},{label:'Menu',s:{kind:'edit',id:'menu'},tip:''},{label:'Rota',s:{kind:'edit',id:'rota'},tip:''},{label:'Branding & Display',s:{kind:'edit',id:'brand'},tip:''}],q={tableplan:'plan',menu:'menu',rota:'rota',branding:'brand'},X=(e,t)=>e.kind===t.kind&&('tab'===e.kind?e.tab===t.tab:e.id===t.id),Z=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable};function J({id:e,rid:t,me:s,role:o,today:n,venue:i}){const l=(0,f.usePlan)(t),[u,b]=(0,a.useState)(0),[h,p]=(0,a.useState)('');return'menu'===e?(0,K.jsx)($.MenuEditor,{rid:t,me:s,role:o}):'rota'===e?(0,K.jsx)(V.RotaEditor,{today:n}):'brand'===e?(0,K.jsx)(_.BrandEditor,{rid:t}):(0,K.jsxs)(r.default,{style:{flex:1,gap:8,minHeight:0},testID:"desk-plan",children:[(0,K.jsxs)(F.Tip,{children:["Drag tables to move them; they snap to the grid and line up with their neighbours (gold lines). Hold Option (Alt) to move freely. \u201cTidy up\u201d lines up a whole area. ",(0,N.CMD)(),"Z undoes, then Save."]}),h?(0,K.jsx)(g.T,{size:13,colour:A.colours.goldLight,children:h}):null,(0,K.jsx)(r.default,{style:{flex:1,minHeight:0,borderWidth:1,borderColor:A.colours.border,borderRadius:12,overflow:'hidden'},children:(0,K.jsx)(c.PlanDesigner,{initial:l,venue:i,mode:"managers",startStep:"arrange",onSave:e=>{f.useFloor.getState().setPlan(t,e),p('Table plan saved. The Display uses it straight away.'),b(e=>e+1)},onCancel:()=>{p('Changes thrown away.'),b(e=>e+1)}},u)})]})}},1566,[828,827,34,402,295,102,36,1361,873,1364,1238,1388,794,1029,891,979,1062,1473,1115,1114,1112,1567,1481,1157,931,1240,2,821,1493,1417,1180,1088,1435,1475,1467,1477,1459,1479,1568,1546,1570,1572,1574,1571,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1567,[846]); +__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.BrandEditor=function({rid:e}){const w=(0,l.useBrand)(e),k=(0,u.useOwner)(t=>t.branding[e]?.recent)??[],[D,B]=(0,t.useState)(w.accent);(0,t.useEffect)(()=>B(w.accent),[w.accent]);const[S,v]=(0,t.useState)(!1),[O,C]=(0,t.useState)(''),P=(0,j.useHistory)(()=>{const t=u.useOwner.getState().branding[e];return t?{...t}:void 0},t=>{u.useOwner.getState().setBranding(e,null),t&&u.useOwner.getState().setBranding(e,t)},'branding'),R=(0,h.checkAccent)(D,x.colours.bg,x.colours.onGold,x.colours.text),T=async t=>{t.preventDefault(),v(!1);const o=(0,b.filesOf)(t)[0];if(o)try{const t=await(0,b.shrinkImage)(o,512,'image/png'===o.type?'image/png':'image/jpeg');P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:t}),C('Logo updated in all apps.')}catch{C('That picture couldn\u2019t be read.')}else C('Drop a picture file (PNG or JPEG).')};return(0,y.jsxs)(o.default,{style:{flex:1},contentContainerStyle:{gap:12,paddingBottom:30},testID:"desk-brand",children:[(0,y.jsx)(f.Tip,{children:"Drop your logo from Finder onto the box, then pick an accent colour. \u2318Z undoes. Display layout settings are further down."}),(0,y.jsxs)(c.Row,{gap:8,children:[(0,y.jsx)(n.default,{style:{flex:1}}),O?(0,y.jsx)(c.T,{size:13,colour:x.colours.goldLight,children:O}):null,(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!P.canUndo,onPress:P.undo,testID:"brand-undo"}),(0,y.jsx)(c.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!P.canRedo,onPress:P.redo,testID:"brand-redo"})]}),(0,y.jsxs)(n.default,{style:{flexDirection:'row',gap:16,flexWrap:'wrap'},children:[(0,y.jsxs)(n.default,{style:{width:320,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Logo"}),(0,y.jsxs)("div",{"data-testid":"brand-logo-drop",onDragOver:e=>{(0,b.hasFiles)(e)&&(e.preventDefault(),v(!0))},onDragLeave:()=>v(!1),onDrop:e=>{T(e)},style:(0,f.box)({height:200,borderRadius:14,border:`2px dashed ${S?x.colours.gold:x.colours.accentBorder}`,background:S?x.colours.accentBg:x.colours.surface,display:'flex',flexDirection:'column',alignItems:'center',justifyContent:'center',gap:10}),children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:96}),(0,y.jsx)("span",{style:(0,f.box)({fontSize:13,color:x.colours.muted}),children:"Drop a logo here (PNG with a clear background is best)"})]}),w.custom&&u.useOwner.getState().branding[e]?.logoUri?(0,y.jsx)(c.Button,{small:!0,kind:"ghost",label:"Use the standard logo",onPress:()=>{P.record('logo'),u.useOwner.getState().setBranding(e,{logoUri:void 0})}}):null,(0,y.jsx)(c.T,{weight:"semibold",children:"Preview"}),(0,y.jsxs)(n.default,{style:{backgroundColor:x.colours.bg,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12,gap:8},children:[(0,y.jsxs)(c.Row,{gap:10,children:[(0,y.jsx)(l.RestaurantLogo,{rid:e,size:44}),(0,y.jsx)(c.T,{weight:"bold",children:w.name})]}),(0,y.jsx)(n.default,{style:{backgroundColor:D,borderRadius:10,padding:10,alignItems:'center'},children:(0,y.jsx)(c.T,{weight:"semibold",colour:R.onAccent,children:"Book a table"})})]})]}),(0,y.jsxs)(n.default,{style:{width:380,gap:10},children:[(0,y.jsx)(c.T,{weight:"semibold",children:"Accent colour"}),(0,y.jsx)(s.ColourPicker,{value:D,onChange:B,onCommit:t=>{t!==w.accent&&(P.record('accent colour'),u.useOwner.getState().setBranding(e,{accent:t,recent:(0,h.pushRecent)(k,t)}),C(`Accent set to ${t}.`))},quick:l.ACCENTS,recent:k}),R.tips.length?(0,y.jsx)(c.Banner,{kind:"warn",children:R.tips.join(' ')}):(0,y.jsx)(c.Muted,{size:12,children:"Easy to read on the dark background."})]})]}),(0,y.jsxs)(n.default,{style:{maxWidth:760,gap:8},children:[(0,y.jsx)(c.T,{size:18,weight:"bold",children:"Display layout"}),(0,y.jsx)(p.DisplaySettingsPage,{})]})]})};var t=r(d[0]),o=e(r(d[1])),n=e(r(d[2])),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]),p=r(d[8]),x=r(d[9]),b=r(d[10]),j=r(d[11]),f=r(d[12]),y=r(d[13])},1568,[34,295,102,1502,873,794,891,829,1460,821,1569,1570,1571,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"dragData",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"readDrag",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"filesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"hasFiles",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"readDataUrl",{enumerable:!0,get:function(){return i}}),_e.shrinkImage=async function(e,t=1024,r="image/jpeg"){const n=await i(e),o=await new Promise((e,t)=>{const r=new Image;r.onload=()=>e(r),r.onerror=t,r.src=n}),s=Math.min(1,t/Math.max(o.width,o.height)),c=document.createElement('canvas');return c.width=Math.round(o.width*s),c.height=Math.round(o.height*s),c.getContext('2d').drawImage(o,0,0,c.width,c.height),c.toDataURL(r,.82)};const e=(e,t,r)=>{try{e.dataTransfer.setData('text/plain',`${t}:${r}`),e.dataTransfer.effectAllowed='copyMove'}catch{}},t=e=>{const t=e.dataTransfer?.getData('text/plain')??'',r=t.indexOf(':');return r>0?{kind:t.slice(0,r),id:t.slice(r+1)}:null},r=e=>Array.from(e.dataTransfer?.files??[]).filter(e=>/^image\//.test(e.type)),n=e=>Array.from(e.dataTransfer?.types??[]).includes('Files'),i=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>t(String(n.result)),n.onerror=()=>r(n.error),n.readAsDataURL(e)})},1569,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"activeUndo",{enumerable:!0,get:function(){return u}}),e.useHistory=function(u,c,s="change",l=60){const o=(0,t.useRef)([]),f=(0,t.useRef)([]),[,h]=(0,t.useState)(0),[v,b]=(0,t.useState)(''),w=(0,t.useRef)(u);w.current=u;const R=(0,t.useRef)(c);R.current=c;const p=(0,t.useCallback)((t=s)=>{o.current=[...o.current,{v:w.current(),what:t}].slice(-l),f.current=[],b(t),h(t=>t+1)},[s,l]),_=(0,t.useCallback)(()=>{const t=o.current.pop();t&&(f.current.unshift({v:w.current(),what:t.what}),R.current(t.v),b(`Undid: ${t.what}`),h(t=>t+1))},[]),k=(0,t.useCallback)(()=>{const t=f.current.shift();t&&(o.current.push({v:w.current(),what:t.what}),R.current(t.v),b(`Redid: ${t.what}`),h(t=>t+1))},[]),y={undo:_,redo:k,canUndo:o.current.length>0,canRedo:f.current.length>0,label:s,record:p,last:v};return(0,t.useEffect)(()=>(n=y,()=>{n===y&&(n=null)})),y};var t=r(d[0]);let n=null;const u=()=>n},1570,[34]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Tip=function({children:e}){return(0,c.jsxs)(t.default,{testID:"desk-tip",style:{flexDirection:'row',gap:8,alignItems:'flex-start',borderWidth:1,borderColor:n.colours.accentBorder,backgroundColor:n.colours.accentBg,borderRadius:10,paddingHorizontal:12,paddingVertical:8},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:n.colours.gold,children:"Tip"}),(0,c.jsx)(l.T,{size:13,colour:n.colours.text,style:{flex:1},children:e})]})},Object.defineProperty(_e,"box",{enumerable:!0,get:function(){return s}}),r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},l=r(d[2]),n=r(d[3]),c=r(d[4]);const s=(e={})=>({fontFamily:'Poppins_400Regular',color:n.colours.text,boxSizing:'border-box',...e})},1571,[34,102,794,821,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MenuEditor=function({rid:e,me:o,role:s}){const a=(0,d.useAllMenu)(e),c=(0,l.useStore)(o=>o.restaurants.find(o=>o.id===e)),[u,h]=(0,t.useState)('dishes'),[D,O]=(0,t.useState)(null),[k,w]=(0,t.useState)(null),[C,I]=(0,t.useState)(''),z=(0,t.useMemo)(()=>{const e=[...c?.sections??[]];return a.forEach(o=>{e.includes(o.section)||e.push(o.section)}),e},[c?.sections,a]),M=a.filter(e=>!e.hidden||e.recipeCardId),P=e=>(0,p.hasRecipeCards)()?(0,p.recipeCards)().byMenuItem(e):void 0,T={name:o,role:s},R=(0,b.useHistory)(()=>({sections:[...z],items:Object.fromEntries(l.useStore.getState().menu.filter(o=>o.restaurantId===e).map(e=>{const o=a.find(o=>o.id===e.id)??e;return[e.id,{section:o.section,sort:e.sort,price:o.price,allergens:{...o.allergens},soldOut:e.soldOut,photo:P(e.id)?.photo}]}))}),o=>{const t=l.useStore.getState();c&&o.sections.join('|')!==(c.sections??[]).join('|')&&t.updateRestaurant(e,{sections:o.sections});for(const[e,s]of Object.entries(o.items)){const o=a.find(o=>o.id===e),n=t.menu.find(o=>o.id===e);if(!o||!n)continue;const r={};o.section!==s.section&&(r.section=s.section),n.sort!==s.sort&&(r.sort=s.sort),o.price!==s.price&&(r.price=s.price),JSON.stringify(o.allergens)!==JSON.stringify(s.allergens)&&(r.allergens=s.allergens),n.soldOut!==s.soldOut&&(r.soldOut=s.soldOut),Object.keys(r).length&&t.updateMenuItem(e,r);const d=P(e);d&&d.photo!==s.photo&&(0,p.recipeCards)().update(d.id,{photo:s.photo},T)}},'menu change'),B=(e,o,t)=>{const s=a.find(o=>o.id===e);if(!s)return;R.record(`moved ${s.name}`);const n=l.useStore.getState(),r=a.map(t=>t.id===e?{...t,section:o}:t);s.section!==o&&n.updateMenuItem(e,{section:o}),(0,y.reorder)(r,e,o,t).forEach(e=>n.updateMenuItem(e.id,{sort:e.sort})),I(`${s.name} moved${s.section!==o?` to ${o}`:''}.`)},F=async(o,t)=>{const s=P(o),n=a.find(e=>e.id===o);if(s&&n)try{const o=await(0,f.shrinkImage)(t,1024);R.record(`photo for ${n.name}`);const r=await(0,p.recipeCards)().savePhoto(e,s.id,{dataUrl:o,width:0,height:0,bytes:Math.round(.75*o.length)});await(0,p.recipeCards)().update(s.id,{photo:r},T),I(`Photo added to ${n.name}. The dish needs the Head Chef\u2019s sign-off again.`)}catch{I('That picture couldn\u2019t be read. Try a JPEG or PNG.')}else I('This dish has no recipe card yet, so it can\u2019t hold a photo.')},_=a.find(e=>e.id===D),E=({m:e})=>{const o=P(e.id),t=o?.photo&&(0,p.hasRecipeCards)()?(0,p.recipeCards)().photoSource(o.photo):null,s=t?.uri,n=D===e.id,r=k===`d:${e.id}`;return(0,S.jsxs)("div",{"data-testid":`menu-dish-${e.id}`,draggable:!0,onDragStart:o=>(0,f.dragData)(o,'dish',e.id),onClick:()=>O(e.id),onDragOver:o=>{o.preventDefault(),w(`d:${e.id}`)},onDragLeave:()=>w(null),onDrop:o=>{o.preventDefault(),o.stopPropagation(),w(null);const t=(0,f.filesOf)(o)[0];if(t)return void F(e.id,t);const s=(0,f.readDrag)(o);'dish'===s?.kind&&s.id!==e.id&&B(s.id,e.section,e.id)},style:(0,j.box)({display:'flex',alignItems:'center',gap:10,padding:'8px 10px',borderRadius:10,cursor:'grab',userSelect:'none',marginBottom:6,background:n?x.colours.goldTint:x.colours.tile,border:`1px solid ${r?x.colours.gold:n?x.colours.accentBorder:x.colours.hairline}`,borderTop:r?`3px solid ${x.colours.gold}`:void 0}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted,fontSize:16}),children:"\u283f"}),(0,S.jsx)("div",{style:(0,j.box)({width:40,height:40,borderRadius:8,background:x.colours.surface2,backgroundImage:s?`url(${s})`:void 0,backgroundSize:'cover',backgroundPosition:'center',flexShrink:0,display:'flex',alignItems:'center',justifyContent:'center',fontSize:10,color:x.colours.muted}),children:s?'':'photo'}),(0,S.jsxs)("div",{style:(0,j.box)({flex:1,minWidth:0}),children:[(0,S.jsx)("div",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',fontSize:14,whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis',textDecoration:e.soldOut?'line-through':void 0}),children:e.name}),(0,S.jsxs)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[Object.keys(e.allergens).length?Object.keys(e.allergens).length+' allergens':'No allergens',e.hidden?' \xb7 hidden':'']})]}),e.soldOut?(0,S.jsx)("span",{style:(0,j.box)({fontSize:11,color:x.colours.amber,border:`1px solid ${x.colours.amber}`,borderRadius:6,padding:'1px 6px'}),children:"Sold out"}):null,(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_600SemiBold',color:x.colours.gold,fontSize:14}),children:v(e.price)})]})};return(0,S.jsxs)(n.default,{style:{flex:1,gap:10},testID:"desk-menu",children:[(0,S.jsx)(j.Tip,{children:"Drag a dish (\u283f) to put it in order or onto another section. Drag a section name to move the whole section. Drop a photo from Finder onto a dish. \u2318Z undoes."}),(0,S.jsxs)(r.Row,{gap:8,children:[(0,S.jsx)(r.Chip,{label:"Dishes",selected:'dishes'===u,onPress:()=>h('dishes'),testID:"menu-tab-dishes"}),(0,S.jsx)(r.Chip,{label:"Sold out & counts",selected:'soldout'===u,onPress:()=>h('soldout'),testID:"menu-tab-soldout"}),(0,S.jsx)(n.default,{style:{flex:1}}),C?(0,S.jsx)(r.T,{size:13,colour:x.colours.goldLight,children:C}):null,(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!R.canUndo,onPress:R.undo,testID:"menu-undo"}),(0,S.jsx)(r.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!R.canRedo,onPress:R.redo,testID:"menu-redo"})]}),'soldout'===u?(0,S.jsx)(n.default,{style:{maxWidth:760},children:(0,S.jsx)(m.SoldOutList,{rid:e,by:o})}):(0,S.jsxs)(n.default,{style:{flex:1,flexDirection:'row',gap:14,minHeight:0},children:[(0,S.jsx)("div",{style:(0,j.box)({flex:1,overflowY:'auto',paddingRight:6}),"data-testid":"menu-sections",children:z.map(o=>{const t=M.filter(e=>e.section===o),s=k===`s:${o}`;return(0,S.jsxs)("div",{style:(0,j.box)({marginBottom:14}),onDragOver:e=>{e.preventDefault(),w(`s:${o}`)},onDragLeave:()=>w(null),onDrop:t=>{t.preventDefault(),w(null);const s=(0,f.readDrag)(t);var n,r;'dish'===s?.kind&&B(s.id,o,null),'section'===s?.kind&&s.id!==o&&(n=s.id,r=o,c&&(R.record(`moved section ${n}`),l.useStore.getState().updateRestaurant(e,{sections:(0,y.moveSection)(z,n,r)}),I(`${n} moved.`)))},children:[(0,S.jsxs)("div",{draggable:!0,onDragStart:e=>(0,f.dragData)(e,'section',o),"data-testid":`menu-section-${o}`,style:(0,j.box)({display:'flex',alignItems:'center',gap:8,padding:'6px 4px',cursor:'grab',borderBottom:`${s?2:1}px solid ${s?x.colours.gold:x.colours.border}`,marginBottom:8}),children:[(0,S.jsx)("span",{style:(0,j.box)({color:x.colours.muted}),children:"\u283f"}),(0,S.jsx)("span",{style:(0,j.box)({fontFamily:'Poppins_700Bold',fontSize:16,color:x.colours.goldMuted,letterSpacing:.5,textTransform:'uppercase'}),children:o}),(0,S.jsxs)("span",{style:(0,j.box)({fontSize:12,color:x.colours.muted}),children:[t.length," dishes"]})]}),t.map(e=>(0,S.jsx)(E,{m:e},e.id)),t.length?null:(0,S.jsx)("div",{style:(0,j.box)({fontSize:12,color:x.colours.muted,padding:8,border:`1px dashed ${x.colours.border}`,borderRadius:8}),children:"Drop a dish here"})]},o)})}),(0,S.jsx)(n.default,{style:{width:340,gap:10},testID:"menu-inspector",children:_?(0,S.jsx)($,{rid:e,m:_,me:o,record:R.record,onPhoto:e=>{F(_.id,e)}},_.id):(0,S.jsx)(r.Muted,{children:"Click a dish to change its price, allergens and sold-out state."})})]})]})};var e,o=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),n=(e=s)&&e.__esModule?e:{default:e},r=_r(_d[3]),d=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),m=_r(_d[11]),x=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),S=_r(_d[17]);const v=e=>null==e?'Board':`\xa3${(e/100).toFixed(2)}`,D={none:'contains',contains:'may',may:void 0};function $({rid:e,m:s,me:d,record:p,onPhoto:m}){const[b,y]=(0,t.useState)(null==s.price?'':(s.price/100).toFixed(2)),v=(e,o)=>{p(o),l.useStore.getState().updateMenuItem(s.id,e)},$=(0,c.dishUsesFor)(e).find(e=>e.id===s.id),O=(0,c.itemsFor)(e),k=()=>{const e=b.trim(),o=''===e?null:Number(e.replace('\xa3',''));if(null!==o&&(!isFinite(o)||o<0))return void y(null==s.price?'':(s.price/100).toFixed(2));const t=null==o?null:Math.round(100*o);t!==s.price&&v({price:t},`price of ${s.name}`)},w=e=>{const o=s.allergens[e]??'none',t=D[o],n={...s.allergens};t?n[e]=t:delete n[e],v({allergens:n},`allergens on ${s.name}`)};return(0,S.jsxs)(n.default,{style:{gap:10,backgroundColor:x.colours.surface,borderRadius:12,borderWidth:1,borderColor:x.colours.border,padding:12},children:[(0,S.jsx)(r.T,{size:17,weight:"bold",children:s.name}),(0,S.jsxs)(r.Muted,{size:12,children:[s.section,s.signOff?` \xb7 signed off by ${s.signOff.by}`:' \xb7 awaiting Head Chef sign-off']}),(0,S.jsx)("div",{onDragOver:e=>{(0,f.hasFiles)(e)&&e.preventDefault()},onDrop:e=>{e.preventDefault();const o=(0,f.filesOf)(e)[0];o&&m(o)},"data-testid":"menu-photo-drop",style:(0,j.box)({border:`1px dashed ${x.colours.accentBorder}`,borderRadius:10,padding:12,textAlign:'center',fontSize:12,color:x.colours.muted}),children:"Drop a photo from Finder here"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Price (\xa3)"}),(0,S.jsx)(o.TextInput,{testID:"menu-price",value:b,onChangeText:y,onBlur:k,onSubmitEditing:k,placeholder:"Blank = on the specials board",placeholderTextColor:x.colours.muted,style:[r.styles.input,{width:160}]})]}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Allergens"}),(0,S.jsx)(r.Muted,{size:12,children:"Click to cycle: contains \u2192 may contain \u2192 none. Changes go to the recipe card and need the Head Chef\u2019s sign-off."}),(0,S.jsx)(r.Row,{gap:6,wrap:!0,children:h.ALLERGENS.map(e=>{const o=s.allergens[e.id];return(0,S.jsx)(r.Chip,{testID:`menu-al-${e.id}`,label:'may'===o?`${e.short} (may)`:e.short,selected:!!o,onPress:()=>w(e.id)},e.id)})})]}),(0,S.jsx)(r.Toggle,{label:"Sold out now",value:s.soldOut,onChange:e=>{p(`sold out ${s.name}`),(0,a.setSoldOut)(s.id,e,d)},testID:"menu-soldout"}),(0,S.jsxs)(n.default,{style:{gap:4},children:[(0,S.jsx)(r.T,{size:13,weight:"semibold",children:"Sold-out link"}),$&&$.uses.length?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(r.Muted,{size:12,children:(0,u.usesText)($.uses,O)}),(0,S.jsx)(r.Badge,{kind:"gold",label:"Sells out on its own when the count runs out"})]}):(0,S.jsx)(r.Muted,{size:12,children:"Not linked to a count. Link it in \u201cSold out & counts\u201d."})]})]})}},1572,[827,34,102,794,876,831,979,981,982,861,882,1174,821,1569,1570,1571,1573,25]); +__d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reorder=function(t,n,i,f){const c=t.filter(t=>t.section===i&&t.id!==n).map(t=>t.id),o=f?c.indexOf(f):-1;return c.splice(o<0?c.length:o,0,n),c.map((t,n)=>({id:t,sort:10*(n+1)}))},e.moveSection=function(t,n,i){const f=t.filter(t=>t!==n),c=i?f.indexOf(i):-1;return f.splice(c<0?f.length:c,0,n),f},e.moveShift=function(n,i,f,c,o,s){const u=n.find(t=>t.id===i);if(!u)return n;if(!o&&u.staffId===f&&u.date===c)return n;const l={...u,staffId:f,date:c,day:(0,t.weekdayOf)(c)};return o?[...n,{...l,id:s(),published:!1,changed:!1}]:n.map(t=>t.id===i?{...l,changed:!!u.published||u.changed}:t)};var t=r(d[0])},1573,[891]); +__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.RotaEditor=function({today:e}){const y=(0,i.useOwner)(e=>e.staff).filter(e=>e.active),S=(0,i.useOwner)(e=>e.shifts),[$,j]=(0,t.useState)((0,i.mondayOfDate)(e)),[v,k]=(0,t.useState)(null),[w,D]=(0,t.useState)(''),B=(0,c.useHistory)(()=>i.useOwner.getState().shifts,e=>i.useOwner.getState().setShifts(e),'rota change'),O=b.map((e,t)=>(0,i.addDays)($,t)),P=(e,t,o)=>{e.preventDefault(),k(null);const d=(0,u.readDrag)(e);if('shift'!==d?.kind)return;const s=S.find(e=>e.id===d.id);if(!s)return;const n=!!e.altKey,c=y.find(e=>e.id===t)?.name??'';(n||s.staffId!==t||s.date!==o)&&(S.some(e=>e.staffId===t&&e.date===o&&e.id!==s.id&&e.starte.date>=$&&e.date<=O[6]),I=T.filter(e=>!e.published||e.changed).length;return(0,p.jsxs)(d.default,{style:{flex:1,gap:10},testID:"desk-rota",children:[(0,p.jsx)(h.Tip,{children:"Drag a shift to another day or person. Hold Option (Alt) while you drop to copy it instead. Nothing goes to staff until you press Publish."}),(0,p.jsxs)(s.Row,{gap:8,children:[(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"\u2039 Week before",onPress:()=>j((0,i.addDays)($,-7))}),(0,p.jsxs)(s.T,{weight:"semibold",children:["Week of ",new Date($+'T12:00:00').toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Next week \u203a",onPress:()=>j((0,i.addDays)($,7))}),(0,p.jsx)(d.default,{style:{flex:1}}),w?(0,p.jsx)(s.T,{size:13,colour:n.colours.goldLight,children:w}):null,(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Undo",disabled:!B.canUndo,onPress:B.undo,testID:"rota-undo"}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Redo",disabled:!B.canRedo,onPress:B.redo,testID:"rota-redo"}),(0,p.jsx)(s.Button,{small:!0,label:I?`Publish (${I})`:'Published',disabled:!I,onPress:()=>{B.record('published the week');const e=i.useOwner.getState().publishWeek($);D(`${e} shifts published.`)},testID:"rota-publish"})]}),(0,p.jsx)("div",{style:(0,h.box)({flex:1,overflow:'auto',border:`1px solid ${n.colours.border}`,borderRadius:12}),"data-testid":"rota-grid",children:(0,p.jsxs)("div",{style:(0,h.box)({display:'grid',gridTemplateColumns:"180px repeat(7, minmax(110px, 1fr))",minWidth:960}),children:[(0,p.jsx)("div",{style:(0,h.box)({position:'sticky',top:0,background:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,zIndex:1})}),O.map((t,o)=>(0,p.jsxs)("div",{style:(0,h.box)({position:'sticky',top:0,zIndex:1,background:t===e?n.colours.goldTint:n.colours.surface,padding:8,borderBottom:`1px solid ${n.colours.border}`,fontFamily:'Poppins_600SemiBold',fontSize:13,color:t===e?n.colours.gold:n.colours.text}),children:[b[o]," ",Number(t.slice(8))]},t)),y.map(e=>(0,p.jsxs)(o.default.Fragment,{children:[(0,p.jsxs)("div",{style:(0,h.box)({padding:8,borderBottom:`1px solid ${n.colours.hairline}`,fontSize:13}),children:[(0,p.jsx)("div",{style:(0,h.box)({fontFamily:'Poppins_600SemiBold'}),children:e.name}),(0,p.jsx)("div",{style:(0,h.box)({fontSize:11,color:n.colours.muted}),children:e.job})]}),O.map(t=>{const o=`${e.id}|${t}`,d=T.filter(o=>o.staffId===e.id&&o.date===t);return(0,p.jsx)("div",{"data-testid":`rota-cell-${e.id}-${t}`,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=e.altKey?'copy':'move',k(o)},onDragLeave:()=>k(null),onDrop:o=>P(o,e.id,t),style:(0,h.box)({padding:5,minHeight:54,borderBottom:`1px solid ${n.colours.hairline}`,borderLeft:`1px solid ${n.colours.hairline}`,background:v===o?n.colours.accentBg:void 0,outline:v===o?`2px dashed ${n.colours.gold}`:void 0,outlineOffset:-3}),children:d.map(e=>(0,p.jsxs)("div",{draggable:!0,onDragStart:t=>(0,u.dragData)(t,'shift',e.id),"data-testid":`rota-shift-${e.id}`,title:e.note??'',style:(0,h.box)({cursor:'grab',userSelect:'none',borderRadius:8,padding:'4px 6px',marginBottom:4,fontSize:12,fontFamily:'Poppins_600SemiBold',background:e.published&&!e.changed?n.colours.gold:n.colours.goldTint,color:e.published&&!e.changed?n.colours.onGold:n.colours.goldLight,border:`1px solid ${n.colours.accentBorder}`}),children:[(0,l.fmtH)(e.start),"\u2013",(0,l.fmtH)(e.end),!e.published||e.changed?' \u2022':'']},e.id))},o)})]},e.id))]})}),(0,p.jsx)(s.Muted,{size:12,children:"Solid gold = published. Outlined with a dot = not yet published (new or changed)."})]})};var t=r(_d[0]),o=e(t),d=e(r(_d[1])),s=r(_d[2]),i=r(_d[3]),l=r(_d[4]),n=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]),f=r(_d[9]),p=r(_d[10]);const b=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],x=()=>`sh-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,7)}`},1574,[34,102,794,891,1091,821,1569,1570,1571,1573,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1575,[30,34,872,1576,25]); +__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1576,[1460,1577,828,997,1099,1511,1224,1055,1056,1512,1536,1514,1174,979,1016,1578,1013,2,1061,1062,1487,999,1039,1000,34,1176,1249,1253,1220,373,402,295,102,426,36,794,873,1157,891,821,1180,1417,1094,1112,1114,1108,1057,1040,1088,1505,1500,1520,1579,1426,1004,236,1255,1199,1205,1458,1219,1218,1474,1202,15,1225,1226,925,793,987,25]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1577,[34,102,794,1088,987,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1578,[236,1014]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1579,[860,34,102,794,891,1029,858,1091,1089,987,1090,5,1001,821,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1580,[30,34,872,25]); +__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1581,[1454,987,795,1411,1582,1026,30,1609,496,34,385,336,236,41,102,5,873,872,1611,36,874,1029,891,821,1426,1004,1024,1612,1613,1058,1614,1130,2,1039,999,1616,1379,25,1618,1619,1620,1621]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1582,[1583,1606,1608]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1583,[215,1584,1587,1601,1602,1603,1604,1605]); +__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1584,[215,1585]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1585,[1586]); +__d(function(g,r,i,a,m,e,d){},1586,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1587,[1588,215,1584,1601,1602]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1588,[1589,1590,1600]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1589,[1590,1594,1599]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1590,[215,372,1591,1595,1596,1597,1598,1594,1599]); +__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1591,[215,1592,339,280,1593,1594]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1592,[504]); +__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1593,[215,339]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1594,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1595,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1596,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1597,[1595]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1598,[]); +__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1599,[372,1593]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1600,[34,1590]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1601,[1588,215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1602,[1588,1601]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1603,[1584]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1604,[215,1584,1587,1585]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1605,[]); +__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1606,[215,54,1607]); +__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1607,[215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1608,[34,1583]); +__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]}})})},1609,[1610]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1610,[]); +__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1611,[34,41,102,426,794,873,1004,987,2,5,821,1551,1553,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1612,[990,883,882,987]); +__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1613,[828,796,827,34,1012,1461,1030,402,102,872,987,1014,1029,5,821,794,1357,976,2,25]); +__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1614,[5,796,827,34,385,283,364,380,236,402,295,426,102,1493,1157,2,797,1088,15,891,794,821,1526,932,1615,1524,1525,1481,1158,1491,931,1567,1534,25,277]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1615,[891,831,1029]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1616,[874,831,891,1039,15,1004,872,2,1617]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1617,[874,1039]); +__d(function(e,o,s,t,p,n,a){"use strict";p.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1618,[]); +__d(function(o,e,s,t,d,p,c){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1619,[]); +__d(function(o,e,s,t,d,p,f){"use strict";d.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1620,[]); +__d(function(o,s,e,d,t,p,n){"use strict";t.exports="/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1621,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1622,[30,34,872,25]); +__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1623,[1624]); +__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1624,[25,1625,591]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1625,[34,172]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1626,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1627,[25,499,34,270,651]); __r(501); __r(21); __r(0); \ No newline at end of file diff --git a/owner-desktop/index.html b/owner-desktop/index.html index b35937cdec0009bce92c15755c8e24cd9ae232f9..c7e105e4d8bd0e9cb22cd60455ae72b8492f4e51 100644 --- a/owner-desktop/index.html +++ b/owner-desktop/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-desktop/owner.html b/owner-desktop/owner.html index 2ad08a63a265c99b858a53a0ea8c7910e79ee261..f26a890e59806ab79fa3560688a34686d6144129 100644 --- a/owner-desktop/owner.html +++ b/owner-desktop/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/owner-desktop/sw.js b/owner-desktop/sw.js index c318baa407cb6d2efc0fd70a006dfa40152bb5fa..c017b7691c945ef108bca49ad73b1726b35bb750 100644 --- a/owner-desktop/sw.js +++ b/owner-desktop/sw.js @@ -1,7 +1,7 @@ // Anchorage owners desktop service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-desk-c8d09f11b9"; +const V = "cc-desk-628df372bc"; const BASE = "/owner-desktop/"; -const PRECACHE = ["/owner-desktop/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/owner-desktop/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/owner-desktop/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/owner-desktop/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/owner-desktop/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-desktop/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-desktop/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/owner-desktop/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/owner-desktop/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/owner-desktop/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/owner-desktop/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/owner-desktop/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/owner-desktop/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/owner-desktop/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/owner-desktop/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/owner-desktop/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/owner-desktop/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/owner-desktop/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/owner-desktop/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/owner-desktop/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/owner-desktop/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/owner-desktop/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/owner-desktop/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/owner-desktop/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/owner-desktop/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/owner-desktop/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/owner-desktop/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/owner-desktop/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/owner-desktop/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/owner-desktop/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/owner-desktop/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/owner-desktop/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/owner-desktop/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/owner-desktop/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-desktop/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-desktop/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-desktop/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-desktop/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-desktop/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-desktop/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-desktop/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-desktop/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-desktop/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-desktop/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-desktop/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-desktop/favicon.ico", "/owner-desktop/index.html", "/owner-desktop/_expo/static/js/web/bundle.js?v=c8d09f11b9af73534d09f88d0312642174a8dea1cf6c889149e0ac95a574ddfd"]; +const PRECACHE = ["/owner-desktop/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/owner-desktop/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/owner-desktop/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/owner-desktop/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/owner-desktop/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/owner-desktop/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/owner-desktop/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/owner-desktop/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/owner-desktop/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/owner-desktop/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/owner-desktop/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/owner-desktop/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/owner-desktop/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/owner-desktop/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/owner-desktop/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/owner-desktop/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/owner-desktop/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/owner-desktop/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/owner-desktop/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/owner-desktop/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/owner-desktop/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/owner-desktop/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/owner-desktop/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/owner-desktop/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/owner-desktop/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/owner-desktop/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/owner-desktop/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/owner-desktop/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/owner-desktop/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/owner-desktop/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/owner-desktop/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/owner-desktop/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/owner-desktop/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/owner-desktop/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/owner-desktop/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/owner-desktop/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/owner-desktop/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/owner-desktop/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/owner-desktop/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/owner-desktop/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/owner-desktop/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/owner-desktop/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/owner-desktop/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/owner-desktop/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/owner-desktop/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/owner-desktop/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/owner-desktop/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/owner-desktop/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/owner-desktop/favicon.ico", "/owner-desktop/index.html", "/owner-desktop/_expo/static/js/web/bundle.js?v=628df372bcaaeb0902b79bf94362f738ea8a349d7d118a11725e09c36039e686"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/staff-app/_expo/static/js/web/bundle.js b/staff-app/_expo/static/js/web/bundle.js index 06106ed7423d5bd17ae6da44cfc456405a141d42..8c961e5b55e28187900a4569952fa9c54abda6bc 100644 --- a/staff-app/_expo/static/js/web/bundle.js +++ b/staff-app/_expo/static/js/web/bundle.js @@ -23,11 +23,11 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PITCH_VENUE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PITCH_TEAM",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PITCH_TEXT",{enumerable:!0,get:function(){return o}}),e.pitchText=function(a,n=!1){let l=a;for(const[a,s]of o){if(n&&t.test(a.source.replace(/\\/g,'')))continue;a.test(l)?(a.lastIndex=0,l=l.replace(a,s)):a.lastIndex=0}return l};const a={name:'The Harbour Kitchen',tagline:'Harbourside seafood & seasonal plates',location:'12 Quay Street, Portmorran',phone:'01632 960 123',website:'harbourkitchen.example'},n={'st-tracy':{name:'Morgan',job:'Owner',hourlyPence:null,salaried:!0},'st-gordon':{name:'Alex',job:'General Manager',dept:'Management',hourlyPence:null,salaried:!0},'st-bisto':{name:'Ravi',job:'Head Chef',hourlyPence:null,salaried:!0},'st-agate':{name:'Priya',job:'Front of house supervisor',hourlyPence:1450},'st-lenny':{name:'Tom',job:'Commis Chef',hourlyPence:1325},'st-finn':{name:'Lewis',job:'Bar staff',hourlyPence:1290},'st-eilidh':{name:'Chloe',job:'Front of house',hourlyPence:1271},'st-emily':{name:'Ellie',job:'Front of house',hourlyPence:1271},'st-lillie':{name:'Jordan',job:'Kitchen porter (KP)',hourlyPence:1271},'st-jack':{name:'Sam',job:'Kitchen porter (KP)',hourlyPence:1271}},o=[['Harbour View, Dunure, South Ayrshire',a.location],['Harbour View, Dunure',a.location],['Harbour View mug','Harbour Kitchen mug'],['Harbour View','Quay Street'],['anchoragedunure.com',a.website],['01292 502826',a.phone],['Mini Anchors','Little Crew'],['The Anchorage',a.name],['Anchorage','Harbour Kitchen'],['ANCHORAGE','HARBOUR KITCHEN'],['South Ayrshire','the Firth coast'],['Ayrshire','the Firth coast'],['Dunure','Portmorran'],['Kittyfisher boat (Big Sean)','Coastal Fish Co'],['Kittyfisher','Coastal Fish Co'],['Big Sean','Coastal Fish Co'],['Example Fish Co.','Coastal Fish Co'],['Sample Dairy Ltd','Hillside Dairy'],['Sample Fruit & Veg','Fieldfare Veg'],['Mills milk','Hillside Dairy milk'],['Mills','Hillside Dairy'],['J. Pieroni & Sons','Fieldfare Veg'],["Pieroni's",'Fieldfare Veg'],['Pieroni','Fieldfare Veg'],['Alsons (drinks)','Drinks wholesaler'],['Alsons','the drinks wholesaler'],['Spes Bona','the deli wholesaler'],['Tarelgin','the butcher'],['Reids','the bakery'],['Reeds','the bakery'],['Example Butchers Ltd','Quayside Butchers'],['Example Dry Goods Wholesale','Dry goods wholesaler'],['Sample Brewing Co.','Harbourside Brewing'],['Example Cleaning Supplies','Cleaning supplies'],['Sample Packaging Ltd','Packaging supplier'],['Example Kitchen Repairs','Kitchen repairs'],['Preston','Ravi'],['Bisto','Ravi'],['Tracy','Morgan'],['James','Morgan'],['Gordon','Alex'],['Agate','Priya'],['Lenny','Tom'],['Finn','Lewis'],['Eilidh','Chloe'],['Emily','Ellie'],['Gabrielle','Ellie'],['Cameron Mc','Sam'],['Cameron','Sam'],['Lillie','Jordan'],['Lily','Jordan'],['Mia','Jordan'],['Jack','Sam'],['Harvey','Jordan'],['Anna','the supplier'],['(preview)',''],[' (example)','']].map(([a,n])=>[new RegExp(`${/^[A-Za-z]/.test(a)?'(?g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},23,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1516,1519]); +__d(function(g,r,i,a,m,e,d){"use strict";function n(){const t=r(d[0]);return n=function(){return t},t}function t(){const n=r(d[1]);return t=function(){return n},n}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"App",{enumerable:!0,get:function(){return c}}),r(d[2]);const o=r(d[3]),u=r(d[4]);function c(){return(0,n().jsx)(u.Head.Provider,{children:(0,n().jsx)(o.ExpoRoot,{context:t().ctx})})}r(d[5])},24,[25,27,34,709,1519,1522]); __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},25,[26]); __d(function(g,r,i,a,m,e,d){ /** @@ -41,8 +41,8 @@ __d(function(g,r,i,a,m,e,d){ */ "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},26,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},27,[28]); -__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1052,1245,1246,1250,1254,1256,1263,1319,1320,1321,1322,1323,1324,1326,1327,1328,1329,1330,1331,1332,1333,1336,1403,1404,1405,1407,1453,1454,1515]); -__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,993,25]); +__d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./(chef)/kitchen/[section].tsx":{enumerable:!0,get:()=>r(d[1])(d[0],d.paths)},"./(chef)/kitchen/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[2],d.paths)},"./(customer)/customer/[rid]/book.tsx":{enumerable:!0,get:()=>r(d[1])(d[3],d.paths)},"./(customer)/customer/[rid]/dish/[did].tsx":{enumerable:!0,get:()=>r(d[1])(d[4],d.paths)},"./(customer)/customer/[rid]/feedback.tsx":{enumerable:!0,get:()=>r(d[1])(d[5],d.paths)},"./(customer)/customer/[rid]/gift.tsx":{enumerable:!0,get:()=>r(d[1])(d[6],d.paths)},"./(customer)/customer/[rid]/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[7],d.paths)},"./(customer)/customer/[rid]/lost.tsx":{enumerable:!0,get:()=>r(d[1])(d[8],d.paths)},"./(customer)/customer/[rid]/loyalty.tsx":{enumerable:!0,get:()=>r(d[1])(d[9],d.paths)},"./(customer)/customer/[rid]/merch.tsx":{enumerable:!0,get:()=>r(d[1])(d[10],d.paths)},"./(customer)/customer/[rid]/offers.tsx":{enumerable:!0,get:()=>r(d[1])(d[11],d.paths)},"./(customer)/customer/[rid]/refer.tsx":{enumerable:!0,get:()=>r(d[1])(d[12],d.paths)},"./(customer)/customer/[rid]/waitlist.tsx":{enumerable:!0,get:()=>r(d[1])(d[13],d.paths)},"./(customer)/customer/[rid]/whatson.tsx":{enumerable:!0,get:()=>r(d[1])(d[14],d.paths)},"./(customer)/customer/basket.tsx":{enumerable:!0,get:()=>r(d[1])(d[15],d.paths)},"./(customer)/customer/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[16],d.paths)},"./(customer)/customer/order/[oid].tsx":{enumerable:!0,get:()=>r(d[1])(d[17],d.paths)},"./(customer)/customer/profile.tsx":{enumerable:!0,get:()=>r(d[1])(d[18],d.paths)},"./(customer)/demo.tsx":{enumerable:!0,get:()=>r(d[1])(d[19],d.paths)},"./(customer)/table/[n].tsx":{enumerable:!0,get:()=>r(d[1])(d[20],d.paths)},"./(customer)/table/live/[token].tsx":{enumerable:!0,get:()=>r(d[1])(d[21],d.paths)},"./(display)/display/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[22],d.paths)},"./(display)/staff/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[23],d.paths)},"./(owner)/admin/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[24],d.paths)},"./(owner)/owner/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[25],d.paths)},"./(staff)/team/index.tsx":{enumerable:!0,get:()=>r(d[1])(d[26],d.paths)},"./+not-found.tsx":{enumerable:!0,get:()=>r(d[1])(d[27],d.paths)},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])(d[28],d.paths)},"./index.tsx":{enumerable:!0,get:()=>r(d[1])(d[29],d.paths)}});function s(s){return t[s]}s.keys=function(){return Object.keys(t)},s.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=s},28,[29,1053,1246,1247,1251,1255,1257,1264,1320,1321,1322,1323,1324,1325,1327,1328,1329,1330,1333,1334,1335,1336,1339,1406,1407,1408,1410,1456,1457,1518]); +__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]);r(d[1]);var n=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]);function s(){const{section:s}=(0,t.useLocalSearchParams)();return(0,c.canShow)('chef')?s&&(0,o.chefSectionAllowed)(String(s))?(0,f.jsx)(n.ChefApp,{section:String(s)},String(s)):(0,f.jsx)(t.Redirect,{href:"/kitchen"}):(0,f.jsx)(t.Redirect,{href:c.ENTRY[c.APP_VARIANT]})}},29,[30,34,792,872,994,25]); __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)},30,[31,32,782,783,785]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},31,[]); __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}},32,[33,692,487,708,557,709,770,761,764,774,647,645,650,562,560,591,465,467,204,205,775,472,473,462,460,569,556,639,659,776,658,162,151,547,433,777,780]); @@ -872,9 +872,9 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{v __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},789,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},790,[]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},791,[]); -__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1054,1055,1015,2,1056,1060,1061,1093,858,1098,1102,1103,1106,1107,1110,1111,1113,1114,1115,1144,1146,1091,34,373,236,402,295,426,102,36,873,1156,794,867,821,1087,1158,1164,1167,1168,1171,1185,1184,1186,1187,1190,1191,1192,1195,1198,1211,1212,1216,1217,925,1003,1218,1177,1219,1226,1227,1236,1229,1175,1238,1242,1213,874,1243,1173,987,1244,25]); +__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:s,rid:i,me:n,now:M}=(0,z.useChef)(3e4);(0,me.useReviewAlerts)(i);const K=(0,W.useSignedIn)(),J=K?.id??z.CHEF_ID,X=K?.ownerAccess&&'owner'!==K.role?'owner privileges':K?.managerAccess&&'staff'===K.role?'manager privileges':'',je=(0,Ce.useSync)(e=>e.perms),ve=je.includes('*')||je.includes('takings.view');(0,o.useSoldOutLink)(!0,(K?.name??n).replace(' (example)',''));const De=e?He[e]:void 0,[$e,Be]=(0,A.useState)(De?.tab??'home'),[Oe,Ee]=(0,A.useState)(De?.k??null),[Fe,Le]=(0,A.useState)(De?.stock??'levels'),[Ne,Ge]=(0,A.useState)(void 0),[Me,We]=(0,A.useState)(De?.gp??'dishes'),Ke=(0,A.useRef)(null),ze=(0,f.ymd)(M),Ve=(0,f.ymd)(new Date(M.getTime()+864e5));(0,p.useTipsPosted)(i,ze);const Ue=(0,se.useTravelDay)('chef',ze),qe='home'===$e&&!Ue;(0,P.useKitchenTodoChime)(i,ze,()=>Xe('kitchen','bookings')),(0,fe.useAlertWatcher)(i,{kinds:['takeaway']}),(0,A.useEffect)(()=>{(0,W.ensureAttendance)((new Date).toISOString().slice(0,10),M)},[]);const Qe=(0,A.useRef)({t:'home',k:null});Qe.current={t:$e,k:Oe};const Ye=(0,A.useRef)([]),Je=(0,r.useScrollMemory)(Ke),Xe=(0,A.useCallback)((e,t=null)=>{'takings'!==t||ve||(t=null);const s=Qe.current;s.t===e&&s.k===t||(Ye.current=[...Ye.current,{...s,y:Je.leave()}].slice(-30),Je.restore(0)),Be(e),Ee(t)},[ve]),Ze=(0,A.useCallback)(()=>{if((0,l.runBackLayer)())return!0;const e=Qe.current;let t=Ye.current.pop();for(;t&&t.t===e.t&&t.k===e.k;)t=Ye.current.pop();if(!t&&'home'===e.t&&!e.k)return!1;const s=t??{t:'home',k:null};return Je.leave(),Be(s.t),Ee(s.k),Je.restore(s.y??0),!0},[]);(0,l.useWebBack)(Ze);const et=(0,l.useInnerBackShown)();(0,A.useEffect)(()=>{c.PITCH&&(globalThis.__pitchGo=(e,t=null,s)=>{'stock'===e&&s&&Le(s),'gp'===e&&s&&We(s),Xe(e,t)})},[Xe]),(0,k.useShiftReminders)({rid:i,staffId:J,name:n,kitchen:!0}),(0,C.useScheduledNotices)({rid:i,staffId:K?.id??'',name:n,onOpen:e=>{'orderlists'===e&&Xe('kitchen','orderlists'),'chat'===e&&Xe('kitchen','live')}}),(0,T.useOffRotaPrompt)({rid:i,staffId:K?.id??''}),(0,A.useEffect)(()=>{const e=D.default.addEventListener('hardwareBackPress',Ze);return()=>e.remove()},[Ze]),(0,A.useEffect)(()=>{'takings'!==Oe||ve||(Ee(null),Be('kitchen'))},[Oe,ve]),(0,Ce.useSync)(e=>e.perms.join(','));const tt=(0,H.kitchenHistoryAccess)(i),st=Re.filter(e=>('takings'!==e.id||ve)&&('bookinghistory'!==e.id||tt)&&('kitchensetup'!==e.id||tt)),it=Oe&&('takings'!==Oe||ve)?Re.find(e=>e.id===Oe):null,ot=((0,O.default)().width,it?it.title:{home:'Today in the kitchen',stock:c.PITCH?'Stock':'Deliveries & stock',gp:'GP & costing',creator:ue.CREATOR_TITLE,orders:'Orders',rota:'Rota',kitchen:'Kitchen'}[$e]);return(0,Pe.jsxs)(F.SafeAreaView,{style:{flex:1,backgroundColor:_.colours.bg},edges:['top','bottom'],children:[(0,Pe.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:_.colours.border,gap:6},children:[(0,Pe.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,Pe.jsx)(N.VoiceSlot,{size:44})}),(0,Pe.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,Pe.jsx)(E.default,{testID:"header-me",accessibilityLabel:`Signed in as ${n.replace(' (example)','')}, Head Chef${X?`, ${X}`:''}`,style:{borderWidth:1,borderColor:_.colours.gold,borderRadius:16,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%'},children:(0,Pe.jsxs)(G.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,Pe.jsx)(le.StaffAvatar,{id:z.CHEF_ID,size:24,ring:!1}),(0,Pe.jsxs)(E.default,{style:{flexShrink:1},children:[(0,Pe.jsxs)(G.T,{size:13,weight:"semibold",colour:_.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)','')," \xb7 Head Chef"]}),X?(0,Pe.jsx)(G.Muted,{center:!1,size:10,numberOfLines:1,children:X}):null]})]})})}),(0,Pe.jsx)(L.VenueHeaderBlock,{rid:i,name:s.name,badge:"CHEF",place:"Head Chef app"}),(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:"Open CoverCharge for Staff",onPress:()=>{const e=(0,de.appUrl)('staff');e&&window.location.assign(e)},style:{alignSelf:'center',borderWidth:1,borderColor:_.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:3,minHeight:44,justifyContent:'center'},children:(0,Pe.jsx)(G.T,{size:13,colour:_.colours.gold,children:"Staff app \u203a"})})]}),(0,Pe.jsxs)(B.default,{ref:Ke,...Je.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,Pe.jsx)(l.BackTitleRow,{back:!('home'===$e&&!Oe||et),onBack:Ze,title:ot}),'home'===$e?(0,Pe.jsx)(se.DayBar,{app:"chef",today:ze}):null,'home'===$e&&Ue?(0,Pe.jsx)(se.DayView,{rid:i,day:Ue,today:ze,app:"chef"}):null,'home'===$e?(0,Pe.jsx)(re.WhoBar,{}):null,qe&&K?(0,Pe.jsx)(h.MyTasksToday,{rid:i,staffId:K.id,name:K.name,onShift:(0,k.shiftNow)(K.id,M.getTime()).on}):null,qe?(0,Pe.jsx)(p.TodaysTipsCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(p.TipsPotCard,{rid:i,today:ze}):null,qe?(0,Pe.jsx)(b.CoversToday,{rid:i,onPress:()=>Xe('kitchen','bookings')}):null,qe?(0,Pe.jsx)(y.LastFoodBanner,{rid:i,now:M}):null,qe?(0,Pe.jsx)(x.NextTableFreeCard,{rid:i,now:M}):null,qe?(0,Pe.jsx)(j.KitchenSignoffs,{rid:i,today:ze,by:n,app:"chef"}):null,qe?(0,Pe.jsxs)(E.default,{style:{gap:4},children:[(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:ze,label:"Platters booked today"}),(0,Pe.jsx)(j.PlattersBooked,{rid:i,date:Ve,label:"Platters booked tomorrow"})]}):null,qe?(0,Pe.jsx)(we.ChefAssistantButton,{}):null,qe?(0,Pe.jsx)(Ae,{go:(e,t)=>{'stock'===e&&t&&Le(t),'gp'===e&&t&&We(t),'orders'===e&&Ge(t),Xe(e,'kitchen'===e?t??null:null)}}):null,'stock'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:'deliveries'===Fe?'deliveries':'take'===Fe?'count':'deliveries'},`s-${Fe}`),'gp'!==$e||c.PITCH?null:(0,Pe.jsx)(ee.KitchenCosts,{rid:i,me:(K?.name??n).replace(' (example)',''),actor:{name:(K?.name??n).replace(' (example)',''),role:'head-chef'},initial:"dishgp"},`g-${Me}`),'stock'===$e&&c.PITCH?(0,Pe.jsx)(Z.StockScreen,{initial:Fe},Fe):null,'gp'===$e&&c.PITCH?(0,Pe.jsx)(V.GpScreen,{initial:Me},Me):null,'creator'===$e?(0,Pe.jsx)(ue.DishCreator,{rid:i,canPublish:!1}):null,'orders'===$e?(0,Pe.jsx)(Q.OrdersScreen,{focus:Ne},Ne??'all'):null,'rota'===$e?(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(Y.KitchenRotaTab,{today:ze})}):null,'kitchen'!==$e||it?null:(0,Pe.jsxs)(E.default,{style:{gap:10},children:[(0,Pe.jsxs)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:_.colours.border,backgroundColor:_.colours.surface,overflow:'hidden'},children:[Ie.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.title}. ${e.sub}`,onPress:()=>Xe(e.id),style:({pressed:e})=>({padding:12,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id)),st.map(e=>(0,Pe.jsx)($.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>Xe($e,e.id),style:({pressed:e})=>({padding:12,borderTopWidth:1,borderColor:_.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,Pe.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Pe.jsxs)(E.default,{style:{flex:1},children:[(0,Pe.jsx)(G.T,{weight:"medium",children:e.title}),(0,Pe.jsx)(G.Muted,{children:e.sub})]}),(0,Pe.jsx)(G.T,{colour:_.colours.muted,children:"\u203a"})]})},e.id))]}),(0,Pe.jsx)(G.Muted,{children:"Head Chef sees kitchen, stock, food costs and GP. Payroll, wages and the restaurant's billing stay in CoverCharge for Managers."}),(0,Pe.jsxs)(G.Muted,{center:!0,children:["Head Chef app \xb7 ",d.APP_VERSION," \xb7 ",'live'===Ce.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),'myshift'===Oe&&J?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-myshift",children:[(0,Pe.jsx)(ae.ClockInOut,{}),(0,Pe.jsx)(ne.MyUpcomingShifts,{staffId:J,team:!0})]}):null,'mypay'===Oe?(0,Pe.jsxs)(E.default,{style:{gap:10},testID:"chef-mypay",children:[(0,Pe.jsx)(ie.MyPeriods,{staffId:J}),(0,Pe.jsx)(te.MyHoursPay,{staffId:J}),(0,Pe.jsx)(oe.MyTips,{staffId:J}),(0,Pe.jsx)(G.Card,{children:(0,Pe.jsx)(u.PhoneAlerts,{})})]}):null,'alerts'===Oe?(0,Pe.jsx)(E.default,{testID:"chef-alerts",children:(0,Pe.jsx)(u.PhoneAlerts,{})}):null,'avatar'===Oe?(0,Pe.jsx)(t.AvatarMaker,{meId:K?.id??z.CHEF_ID,me:n}):null,'reviews'===Oe?(0,Pe.jsx)(ye.ReviewsSection,{rid:i,mode:"read",venueName:s.name}):null,'bookinghistory'===Oe?(0,Pe.jsx)(I.BookingHistory,{rid:i,today:ze}):null,'bookings'===Oe?(0,Pe.jsx)(S.TodaysBookings,{rid:i,today:ze,by:n,app:"chef"}):null,'specials'===Oe?(0,Pe.jsx)(pe.SpecialsEditor,{rid:i,me:n,app:"chef",now:M}):null,'forecast'===Oe?(0,Pe.jsx)(U.ChefForecast,{openPrep:()=>Xe('kitchen','prep')}):null,'prep'===Oe?(0,Pe.jsx)(q.PrepScreen,{}):null,'live'===Oe?(0,Pe.jsx)(q.TeamScreen,{}):null,'waste'===Oe?(0,Pe.jsx)(q.WasteScreen,{}):null,'recipes'===Oe?(0,Pe.jsx)(be.RecipeCards,{rid:i,actor:{name:n,role:'head-chef'},mode:"edit"}):null,'allergens'===Oe?(0,Pe.jsx)(q.AllergenScreen,{openCards:()=>Xe('kitchen','recipes')}):null,'compliance'===Oe?(0,Pe.jsx)(q.ComplianceScreen,{}):null,'takings'===Oe&&ve?(0,Pe.jsx)(p.CashUpScreen,{rid:i,today:ze,canEdit:!1,chartsOnly:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'board'===Oe?(0,Pe.jsx)(xe.QuestionBoard,{rid:i,today:ze,manager:!1,by:""}):null,'teamtasks'===Oe?(0,Pe.jsx)(h.KitchenTeamTasks,{rid:i,actor:K}):null,'orderlists'===Oe?(0,Pe.jsx)(w.OrderListsScreen,{rid:i,today:ze,editor:!0,who:{id:J,name:n.replace(' (example)','')}}):null,'foodsafety'===Oe?(0,Pe.jsx)(v.FoodSafetyCard,{children:(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>Xe('kitchen','haccp'),children:(0,Pe.jsx)(G.T,{colour:_.colours.gold,children:"Today\u2019s temperature log \u203a"})})}):null,'kitchensetup'===Oe?tt?(0,Pe.jsx)(R.TempUnitsSetup,{}):(0,Pe.jsx)(G.T,{center:!0,children:"Kitchen setup is for the Head Chef, managers and owners."}):null,'haccp'===Oe?(0,Pe.jsx)(he.HaccpLog,{mode:"chef",me:n,meId:z.CHEF_ID,now:M}):null,'accidents'===Oe?(0,Pe.jsx)(ce.AccidentBook,{app:"chef",me:n,meId:z.CHEF_ID,now:M,seeAll:!1}):null]}),(0,Pe.jsx)(Te.BottomTabs,{tablist:!0,background:_.colours.surface,active:'orders'===$e?'kitchen':$e,onPress:e=>Xe(e),tabs:Se.map(e=>({id:e.id,label:e.label,short:'creator'===e.id?'Creator':void 0,icon:e.icon,a11y:'rota'===e.id?'Rota, the kitchen rota':void 0}))}),(0,Pe.jsx)(we.ChefAssistantSheet,{go:(e,t)=>{'orders'===e?(Ge(t),Xe('orders')):'gp'===e?Xe('gp'):Xe('kitchen',e)}}),(0,Pe.jsx)(ge.AlertHost,{variant:"chef",rid:i,skipTakeaway:!0}),(0,Pe.jsx)(ke.KitchenFlash,{rid:i,me:n})]})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),o=_r(_d[3]),n=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),k=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),v=_r(_d[19]),C=_r(_d[20]),T=_r(_d[21]),P=_r(_d[22]),S=_r(_d[23]),I=_r(_d[24]),R=_r(_d[25]),H=_r(_d[26]),A=_r(_d[27]),D=e(_r(_d[28]));_r(_d[29]);var $=e(_r(_d[30])),B=e(_r(_d[31])),O=e(_r(_d[32])),E=e(_r(_d[33])),F=_r(_d[34]),L=_r(_d[35]),N=_r(_d[36]),G=_r(_d[37]),M=_r(_d[38]),_=_r(_d[39]),W=_r(_d[40]),K=_r(_d[41]),z=_r(_d[42]),V=_r(_d[43]),U=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),Y=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),se=_r(_d[53]),ie=_r(_d[54]),oe=_r(_d[55]),ae=_r(_d[56]),ne=_r(_d[57]),re=_r(_d[58]),le=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),pe=_r(_d[64]),ge=_r(_d[65]),ke=_r(_d[66]),fe=_r(_d[67]),be=_r(_d[68]),ye=_r(_d[69]),me=_r(_d[70]),xe=_r(_d[71]),je=_r(_d[72]),we=_r(_d[73]),ve=_r(_d[74]),Ce=_r(_d[75]),Te=_r(_d[76]),Pe=_r(_d[77]);s.LIVE_HEAD_CHEF&&(0,i.requireRealData)();const Se=[{id:'home',label:'Home',icon:'home'},{id:'stock',label:'Stock',icon:'box'},{id:'gp',label:'GP',icon:'forecast'},{id:'creator',label:ue.CREATOR_TITLE,icon:'sparkle'},{id:'rota',label:'Rota',icon:'rota'},{id:'kitchen',label:'Kitchen',icon:'platter'}],Ie=[{id:'orders',title:'Orders',sub:'Supplier order sheets, what is due today and cut-off times. Nothing is sent until you press Send'}],Re=[{id:'alerts',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'avatar',title:'My avatar',sub:'Animals, Bar & kitchen, sea, sport, colours, patterns or your own photo'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'myshift',title:'My shifts & clock in',sub:'Clock in and out (checks you are at the venue), breaks, and your shifts on the rota'},{id:'mypay',title:'My pay & tips',sub:'Your hours, tips share, tip goal, paydays and payslip info. Only you see this'},{id:'takings',title:'Takings & tips graphs',sub:'Daily cash ups, weekly sales, this week vs last, categories and the Tips pot (view only)'},{id:'bookinghistory',title:'Booking history',sub:'Past days: bookings, covers and walk-ins, by day or week. Read-only'},{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:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'teamtasks',title:'Kitchen team tasks',sub:'Daily tasks for your chefs, commis and KPs'},{id:'orderlists',title:'Order lists',sub:'Alsons drinks, Cash and carry: add items, tick on the day, finish and carry over'},{id:'foodsafety',title:'Food safety (CookSafe)',sub:'Based on CookSafe (Food Standards Scotland). Full logs coming in the next update'},{id:'haccp',title:'Food safety log (HACCP)',sub:'Temperatures, cleaning and allergen checks; voice entry; limits; EHO export'},{id:'kitchensetup',title:'Kitchen setup',sub:'Fridges and freezers: add, rename, archive, type, location, safe limits and check times'},{id:'accidents',title:'Accident book',sub:'Accidents and near misses; you see your own entries'},{id:'forecast',title:'Forecast',sub:'Covers per day for the week ahead, and prep from the forecast'},{id:'prep',title:'Prep list',sub:'From the forecast and bookings, tick off as you go'},{id:'live',title:'Live tickets, sold out, 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'}],He={'booking-history':{tab:'kitchen',k:'bookinghistory'},'kitchen-setup':{tab:'kitchen',k:'kitchensetup'},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'},rota:{tab:'rota'},'kitchen-rota':{tab:'rota'},forecast:{tab:'kitchen',k:'forecast'},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 Ae({go:e}){const{k:t,c:s,menu:i,now:o,rid:r,me:l}=(0,z.useChef)(3e4),d=(0,J.useSheetReminders)(),u=(0,z.useWeek)(),{covers:h,label:p,enough:k,booked:f}=(0,z.useForecast)(),b=(0,Q.useSuggestions)(),y=t.ingredients.filter(e=>e.onHand<=0||(0,z.isLow)(e.onHand,e.par)),x=b.filter(e=>e.ordersToday&&!e.placedToday),j=(0,K.priceImpacts)(i,t.recipes,t.ingredients,t.targetGp).filter(e=>e.dropped.length),w=t.deliveries.filter(e=>'expected'===e.status),v=!t.recipes.length||!t.ingredients.length,C=v?[]:s.filter(e=>e.below),T=(0,n.useLiveState)(),P=(0,je.useRecipeCards)(r).filter(e=>!e.signOff),S=(0,ee.useKitchenSummary)(r),[I,R]=(0,A.useState)(!1);return(0,Pe.jsxs)(E.default,{style:{gap:12},testID:"chef-dashboard",children:[(0,Pe.jsx)(he.MissedBanner,{mode:"chef",now:o,onPress:()=>e('kitchen','haccp')}),d.map(t=>(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('orders',t.supplierId),children:(0,Pe.jsxs)(G.Banner,{kind:'red'===t.tone?'danger':'warn',title:`\u23f0 ${t.text}`,children:["Tap to open the ",t.name," order sheet. Nothing is sent until you press Send."]})},t.supplierId)),P.length?(0,Pe.jsx)($.default,{testID:"cards-awaiting",accessibilityRole:"button",onPress:()=>e('kitchen','recipes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${P.length} recipe card${1===P.length?'':'s'} awaiting your sign-off`,children:[P.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,Pe.jsx)(X.ShellfishTile,{rid:r,by:l,app:"chef",onOrder:()=>e('orders','os-kittyfisher')}),(0,Pe.jsx)(G.Button,{testID:"chef-add-soldout",label:"Add sold out",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>R(!0),style:{minHeight:56}}),(0,Pe.jsxs)(G.Row,{wrap:!0,gap:10,children:[c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"Dishes under target GP",value:S.costed?`${S.below} of ${S.costed}`:'Nothing yet',sub:S.costed?`Average ${(0,z.pct1)(S.avgGp??0)} \xb7 target ${S.target}%`:'Record a delivery, then cost your recipe cards',tone:S.costed?S.below?'amber':'ok':void 0,onPress:()=>e('gp','dishes')}),c.PITCH?v?(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:"Nothing yet",sub:"Add ingredients and recipe costs to see GP",onPress:()=>e('gp','week')}):(0,Pe.jsx)(z.Tile,{testID:"tile-gp",label:"GP this week vs target",value:(0,z.pct1)(u.theo),sub:`Target ${t.targetGp}% \xb7 actual ${(0,z.pct1)(u.actual)}`,tone:u.theoe('gp','week')}):null,c.PITCH?null:(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:null!=S.stockValue?(0,M.gbp)(S.stockValue):'Nothing yet',sub:S.lastCount?`At cost, counted ${S.lastCount}`:'No stock counted yet',onPress:()=>e('stock','take')}),c.PITCH?(0,Pe.jsx)(z.Tile,{testID:"tile-stock",label:"Stock value",value:t.ingredients.length?(0,M.gbp)((0,z.stockValue)(t.ingredients)):'Nothing yet',sub:t.ingredients.length?'At cost':'No stock counted yet',onPress:()=>e('stock','levels')}):null,(0,Pe.jsx)(z.Tile,{label:"Items low or out",value:t.ingredients.length?`${y.length}`:'Nothing yet',sub:t.ingredients.length?y.slice(0,3).map(e=>e.name).join(', '):'No stock counted yet',tone:y.some(e=>e.onHand<=0)?'red':y.length?'amber':'ok',onPress:()=>e('stock','levels')}),(0,Pe.jsx)(z.Tile,{label:"Waste this week",value:t.waste.length?(0,M.gbp)(u.wasteWeek):'Nothing yet',sub:u.sales?`${(0,z.pct1)(u.wasteWeek/u.sales*100)} of food sales`:'',onPress:()=>e('kitchen','waste')}),k?(0,Pe.jsx)(z.Tile,{testID:"tile-forecast",label:"Covers forecast today",value:`${h}`,sub:p,onPress:()=>e('kitchen','forecast')}):(0,Pe.jsx)(z.Tile,{testID:"tile-booked",label:"Booked so far today",value:'ready'===T?`${f}`:'connecting'===T?'Connecting\u2026':'Not connected',sub:"Not enough history for a forecast yet",onPress:()=>e('kitchen','bookings')}),(0,Pe.jsx)(z.Tile,{label:"Orders due today",value:`${x.length}`,sub:x.map(e=>`${e.s.name} by ${e.s.cutoff}`).join(' \xb7 ')||'None',tone:x.some(e=>e.cutPassed)?'red':x.length?'amber':'ok',onPress:()=>e('orders')})]}),j.map(e=>(0,Pe.jsxs)(G.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)),w.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('stock','deliveries'),children:(0,Pe.jsx)(G.Banner,{kind:"info",title:`${w.length} deliver${1===w.length?'y':'ies'} to check in today`,children:"Count in against the order, flag shorts and price changes."})}):null,C.length?(0,Pe.jsx)($.default,{accessibilityRole:"button",onPress:()=>e('gp','dishes'),children:(0,Pe.jsxs)(G.Banner,{kind:"warn",title:`${C.length} dishes below ${t.targetGp}% GP`,children:[C.slice(0,4).map(e=>e.item.name).join(', '),C.length>4?'\u2026':'']})}):null,(0,Pe.jsx)(G.Row,{wrap:!0,gap:8,children:[['Recipe cards','recipes'],['Food safety log','haccp'],['Specials board','specials'],[ue.CREATOR_TITLE,'creator'],['Forecast','forecast'],['Prep list','prep'],['Live tickets & sold out','live'],['Allergens','allergens'],['Accident book','accidents']].map(([t,s])=>(0,Pe.jsx)($.default,{accessibilityRole:"button",accessibilityLabel:t,onPress:()=>'creator'===s?e('creator'):e('kitchen',s),style:{flexGrow:1,flexBasis:140,padding:12,borderRadius:12,borderWidth:1.5,borderColor:_.colours.gold,backgroundColor:_.colours.surface},children:(0,Pe.jsxs)(G.T,{weight:"semibold",children:[t," \u203a"]})},s))}),(0,Pe.jsx)(G.Badge,{kind:"neutral",label:"Nothing is ordered or sent from here"}),(0,Pe.jsx)(ve.SoldOutSheet,{visible:I,onClose:()=>R(!1),rid:r,by:l,hideLinks:!0,testID:"chef-soldout-sheet"})]})}},792,[793,978,884,979,986,1055,1056,1016,2,1057,1061,1062,1094,858,1099,1103,1104,1107,1108,1111,1112,1114,1115,1116,1145,1147,1092,34,373,236,402,295,426,102,36,873,1157,794,867,821,1088,1159,1165,1168,1169,1172,1186,1185,1187,1188,1191,1192,1193,1196,1199,1212,1213,1217,1218,925,1004,1219,1178,1220,1227,1228,1237,1230,1176,1239,1243,1214,874,1244,1174,987,1245,25]); __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=b,_e.pickPhoto=p,_e.AvatarMaker=function({meId:e,me:u}){const g=(0,i.useAvatars)(t=>t.photos[e]),[f,v]=(0,t.useState)(null),[y,x]=(0,t.useState)(null),[j,w]=(0,t.useState)(!1),[I,P]=(0,t.useState)(!1),[k,M]=(0,t.useState)('');(0,t.useEffect)(()=>()=>{f&&URL.revokeObjectURL(f)},[f]);const R='undefined'!=typeof document,S=async e=>{M('');const t=await p(e);if(t){P(!0),w(!1);try{const e=await b(t);f&&URL.revokeObjectURL(f),v(URL.createObjectURL(t)),x(e)}catch{M("That photo couldn't be opened. Try a different one (JPEG or PNG).")}finally{P(!1)}}},U=()=>{f&&URL.revokeObjectURL(f),v(null),x(null),w(!1)},B=u.replace(' (example)','');return(0,h.jsxs)(o.default,{style:{gap:12},testID:"avatar-maker",children:[(0,h.jsxs)(d.Box,{children:[(0,h.jsxs)(s.Row,{gap:14,children:[(0,h.jsx)(l.StaffAvatar,{id:e,size:88}),(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:B}),(0,h.jsxs)(s.Muted,{children:[g?`Your chosen avatar (saved ${new Date(g.at).toLocaleDateString('en-GB')}).`:'Your original crew avatar.'," It shows on rotas, chat, clock-in and sign-offs."]})]})]}),g?(0,h.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to my default avatar",testID:"avatar-own-reset",onPress:()=>{i.useAvatars.getState().reset(e,{id:e,role:'staff',name:B}),M('Back to your default avatar.')}}):null]}),(0,h.jsx)(d.Box,{children:(0,h.jsx)(n.AvatarOptions,{value:g?.dataUrl,onSelect:t=>{const a=i.useAvatars.getState().setOwn(e,e,t.dataUrl,B);M(a?`${t.name} is your avatar now.`:'Could not save your avatar.')}})}),(0,h.jsxs)(d.Box,{testID:"avatar-create",children:[(0,h.jsx)(s.T,{weight:"semibold",size:17,children:"Create my avatar from a photo"}),(0,h.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."}),R?y?(0,h.jsxs)(o.default,{style:{gap:10},testID:"avatar-preview",children:[(0,h.jsxs)(s.Row,{gap:12,style:{justifyContent:'center'},children:[(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[f?(0,h.jsx)(a.default,{source:{uri:f},style:{width:96,height:96,borderRadius:12},accessibilityLabel:"Your photo"}):null,(0,h.jsx)(s.Muted,{children:"Your photo"})]}),(0,h.jsx)(s.T,{size:22,colour:c.colours.gold,children:"\u2192"}),(0,h.jsxs)(o.default,{style:{alignItems:'center',gap:4},children:[(0,h.jsx)(a.default,{source:{uri:y},style:{width:120,height:120,borderRadius:60,borderWidth:3,borderColor:c.colours.gold},accessibilityLabel:"Your new avatar preview",testID:"avatar-result"}),(0,h.jsx)(s.Muted,{children:"Your avatar"})]})]}),(0,h.jsxs)(r.default,{accessibilityRole:"checkbox",accessibilityState:{checked:j},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>w(!j),style:{flexDirection:'row',gap:10,alignItems:'flex-start',padding:10,borderRadius:12,borderWidth:1,borderColor:j?c.colours.gold:c.colours.border},children:[(0,h.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:c.colours.gold,backgroundColor:j?c.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:j?(0,h.jsx)(s.T,{size:15,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,h.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 CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:"Use as my avatar",testID:"avatar-save",disabled:!j,onPress:()=>{const t=i.useAvatars.getState().setOwn(e,e,y,B);M(t?'Saved: this is your avatar now.':"Couldn't save the avatar."),t&&U()}}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Try another photo",onPress:U})]})]}):(0,h.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(s.Button,{label:I?'Making your avatar\u2026':'Upload a photo',testID:"avatar-upload",disabled:I,onPress:()=>S(!1)}),(0,h.jsx)(s.Button,{kind:"secondary",label:"Take a selfie",testID:"avatar-selfie",disabled:I,onPress:()=>S(!0)})]}):(0,h.jsx)(s.Muted,{children:"Available in the web app."}),k?(0,h.jsx)(o.default,{testID:"avatar-msg",children:(0,h.jsx)(s.T,{size:14,colour:c.colours.ok,children:k})}):null]})]})};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]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]);const u=['#1B1B1B','#4A3F35','#B89A72','#E9B949','#FFF4E0'].map(e=>[1,3,5].map(t=>parseInt(e.slice(t,t+2),16))),g=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];function f(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 v(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 b(e){const{img:t,url:a}=await f(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),d=c[Math.floor(.04*c.length)],h=c[Math.floor(.96*c.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()})}},793,[34,336,236,402,102,794,925,929,926,821,930,25]); -__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=D,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(H,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(x.default,{style:{flex:1},children:u}),s?(0,B.jsx)(x.default,{style:N.footer,children:(0,B.jsx)(x.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=v,_e.Card=F,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(x.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:L?'center':'flex-start'}],children:(0,B.jsx)(D,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"ExampleAllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(x.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(D,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(D,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(D,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(x.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(D,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(D,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,p.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(D,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(D,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(x.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(D,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),x=e(_r(d[14])),p=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),L='display'!==S.APP_VARIANT;function D({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),x=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,p=f.default.flatten(t)||{},j=1===p.flex||1===p.flexGrow||'number'==typeof p.width||'left'===p.textAlign,k=c??(L&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,x,(0,W.webLine)(t,r),k&&'left'!==p.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(D,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(D,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(D,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??L});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(x.default,{style:N.brandBar,children:[(0,B.jsxs)(x.default,{style:N.row,children:[(0,B.jsx)(x.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(D,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(x.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(x.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function H(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(D,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function v({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],x={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:x,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(D,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(D,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function F({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(x.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(x.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(D,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(D,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,v.centreRow=!0;const V=()=>(0,B.jsx)(E,{kind:"example",title:"Allergens awaiting kitchen verification",children:"This allergen information has not been verified by the kitchen. Head chef sign-off is required. Always speak to staff about allergies."}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Card payments: not set up yet",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===F?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(L&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(x.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=L&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(x.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(x.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); +__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,"webLine",{enumerable:!0,get:function(){return W.webLine}}),_e.T=L,Object.defineProperty(_e,"H1",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"H2",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"Muted",{enumerable:!0,get:function(){return z}}),_e.BrandBar=A,_e.Screen=function({children:e,title:t,subtitle:r,back:o=!0,right:l,maxWidth:n=640,footer:s,scroll:c=!0}){const u=(0,B.jsxs)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center',padding:16,gap:12,alignItems:'stretch'},children:[e,'customer'===S.APP_VARIANT?(0,B.jsx)(v,{}):null]});return(0,B.jsxs)(j.SafeAreaView,{style:{flex:1,backgroundColor:C.colours.bg},edges:['top','left','right'],children:[(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:(0,B.jsx)(A,{title:t,subtitle:r,back:o,right:l})}),c?(0,B.jsx)(b.default,{contentContainerStyle:{paddingBottom:40},children:u}):(0,B.jsx)(p.default,{style:{flex:1},children:u}),s?(0,B.jsx)(p.default,{style:N.footer,children:(0,B.jsx)(p.default,{style:{width:'100%',maxWidth:n,alignSelf:'center'},children:s})}):null]})},_e.Button=F,_e.Card=H,_e.Badge=function({label:e,kind:t="neutral"}){const r={neutral:[C.colours.surface2,C.colours.muted,C.colours.border],gold:[C.colours.goldTint,C.colours.goldLight,C.colours.gold],red:[C.colours.redBg,'#FFD9D4',C.colours.red],amber:[C.colours.amberBg,'#FFE2A8',C.colours.amber],ok:[C.colours.okBg,C.colours.goldLight,C.colours.ok],blue:[C.colours.blueBg,C.colours.goldLight,C.colours.blue]}[t];return(0,B.jsx)(p.default,{style:[N.badge,{backgroundColor:r[0],borderColor:r[2],maxWidth:'100%',alignSelf:D?'center':'flex-start'}],children:(0,B.jsx)(L,{size:13,weight:"medium",colour:r[1],style:{flexShrink:1},children:e})})},_e.Banner=E,Object.defineProperty(_e,"AllergenNotice",{enumerable:!0,get:function(){return V}}),Object.defineProperty(_e,"DemoPaymentNotice",{enumerable:!0,get:function(){return $}}),_e.Row=O,Object.defineProperty(_e,"Divider",{enumerable:!0,get:function(){return _}}),_e.Field=function({label:e,...t}){return(0,B.jsxs)(p.default,{style:{gap:4,alignSelf:'stretch',width:'100%',minWidth:0,maxWidth:'100%'},children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:C.colours.muted,center:!0,children:e}),(0,B.jsx)(o.TextInput,{accessibilityLabel:e,placeholderTextColor:"#7D776C",...t,style:[N.input,t.multiline&&{minHeight:70,textAlignVertical:'top'},t.style]})]})},_e.Chip=function({label:e,selected:t,onPress:r,disabled:o,sub:l,testID:n,accessibilityLabel:s}){return(0,B.jsxs)(h.default,{testID:n,accessibilityRole:"button",accessibilityState:{selected:!!t,disabled:!!o},accessibilityLabel:`${s??e}${!s&&l?`, ${l}`:''}${t?', selected':''}`,'aria-pressed':!!t,disabled:o,onPress:r,style:[N.chip,t&&{backgroundColor:C.colours.gold,borderColor:C.colours.gold},o&&{opacity:.35}],children:[(0,B.jsx)(L,{size:C.font.small,weight:"medium",colour:t?C.colours.onGold:C.colours.text,center:!0,children:e.trim()}),l?(0,B.jsx)(L,{size:12,colour:t?C.colours.onGold:C.colours.muted,center:!0,children:l}):null]})},_e.Toggle=function({value:e,onChange:t,label:r,testID:o,disabled:l,a11y:n}){return(0,B.jsxs)(O,{style:{justifyContent:'space-between',flexShrink:1,minWidth:0},children:[(0,B.jsx)(L,{style:{flex:1,flexShrink:1},children:r}),(0,B.jsx)(y.default,{testID:o,disabled:l,accessibilityLabel:n??r,value:e,onValueChange:t,trackColor:{true:C.colours.gold,false:'#444'},thumbColor:e?'#FFF6E0':'#BBB',activeThumbColor:'#FFF6E0',activeTrackColor:C.colours.gold})]})},_e.Stepper=function({value:e,onChange:t,min:r=1,max:o=20,label:l,step:n=1,format:s,testID:c}){const u=s?s(e):String(e),b=e=>Math.round(e/n)*n;return(0,B.jsxs)(O,{gap:10,children:[(0,B.jsx)(h.default,{testID:c?`${c}-down`:void 0,accessibilityRole:"button",accessibilityLabel:`Decrease ${l??''}`,disabled:e<=r,onPress:()=>t(Math.max(r,b(e-n))),style:[N.stepBtn,e<=r?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"\u2212"})}),(0,B.jsx)(p.default,{testID:c?`${c}-value`:void 0,accessibilityLabel:l?`${l}: ${u}`:u,children:(0,B.jsx)(L,{weight:"semibold",size:C.font.large,style:{minWidth:s?64:28,textAlign:'center'},children:u})}),(0,B.jsx)(h.default,{testID:c?`${c}-up`:void 0,accessibilityRole:"button",accessibilityLabel:`Increase ${l??''}`,disabled:e>=o,onPress:()=>t(Math.min(o,b(e+n))),style:[N.stepBtn,e>=o?{opacity:.4}:null],children:(0,B.jsx)(L,{size:20,colour:C.colours.gold,children:"+"})})]})},_e.Sheet=function({visible:e,onClose:o,title:l,children:n,maxWidth:c,testID:f,footer:y}){const{height:w}=(0,x.default)(),W=s.default.useContext(j.SafeAreaInsetsContext)??{top:0,bottom:0,left:0,right:0},k=(0,r.useTyping)(),S=(0,r.useVisibleArea)(),I=k&&S&&S.height({minHeight:44,minWidth:72,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:e?'rgba(201,162,77,0.22)':'rgba(201,162,77,0.10)',alignItems:'center',justifyContent:'center'}),children:(0,B.jsx)(L,{size:15,weight:"semibold",colour:C.colours.goldLight,center:!0,children:"Done"})}):null,R?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Close",onPress:o,hitSlop:8,testID:"sheet-close",style:{minWidth:72,minHeight:48,alignItems:'center',justifyContent:'center',marginRight:-8},children:(0,B.jsx)(L,{size:18,colour:C.colours.text,children:"Close"})}):(0,B.jsx)(t.GoldClose,{onPress:o,testID:"sheet-close",style:{marginRight:-6,minWidth:48,minHeight:48}})]}),(0,B.jsx)(b.default,{style:{flexShrink:1},contentContainerStyle:{gap:12,paddingTop:2,paddingBottom:4},children:n}),y?(0,B.jsx)(p.default,{style:{borderTopWidth:1,borderTopColor:C.colours.border,paddingTop:10,marginTop:8},testID:f?`${f}-footer`:void 0,children:y}):null]})})})},_e.SectionTitle=function({children:e}){return(0,B.jsx)(L,{weight:"semibold",size:12,colour:C.colours.goldMuted,center:!0,style:{textTransform:'uppercase',letterSpacing:1.6,marginTop:8},children:e})},Object.defineProperty(_e,"styles",{enumerable:!0,get:function(){return N}}),_r(d[0]);var t=_r(d[1]),r=_r(d[2]),o=_r(d[3]),l=_r(d[4]),n=_r(d[5]),s=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8]));_r(d[9]);var h=e(_r(d[10])),b=e(_r(d[11])),f=e(_r(d[12])),y=e(_r(d[13])),p=e(_r(d[14])),x=e(_r(d[15])),j=_r(d[16]),C=_r(d[17]),w=_r(d[18]),W=_r(d[19]),k=_r(d[20]),S=_r(d[21]),I=_r(d[22]),B=_r(d[23]);const R=['kirkton','abbotsford'].includes(k.VENUE_RID),D='display'!==S.APP_VARIANT;function L({children:e,style:t,size:r=C.font.body,weight:l="regular",colour:n=C.colours.text,numberOfLines:s,center:c,testID:u,accessibilityRole:h,accessibilityLabel:b}){const y='string'==typeof e&&/^(https?:\/\/|www\.)\S+$/.test(e.trim()),p=y?{minWidth:0,maxWidth:'100%',overflowWrap:'anywhere',wordBreak:'break-all',alignSelf:'stretch'}:void 0,x=f.default.flatten(t)||{},j=1===x.flex||1===x.flexGrow||'number'==typeof x.width||'left'===x.textAlign,k=c??(D&&('semibold'===l||'bold'===l)&&!j);return(0,B.jsx)(o.Text,{testID:u??(y?'cc-url':void 0),...k?{dataSet:{centre:'heading'}}:{},accessibilityRole:h,accessibilityLabel:b,numberOfLines:s,style:[{minWidth:0,fontFamily:C.fonts[l],fontSize:r,color:n,lineHeight:(0,w.lineFor)(r)},k&&{textAlign:'center',alignSelf:'center',maxWidth:'100%'},t,p,(0,W.webLine)(t,r),k&&'left'!==x.textAlign?{textAlign:'center'}:null],children:e})}const P=e=>(0,B.jsx)(L,{size:C.font.title,weight:"semibold",center:!0,...e}),T=e=>(0,B.jsx)(L,{size:C.font.large,weight:"semibold",center:!0,...e}),z=e=>(0,B.jsx)(L,{colour:C.colours.muted,size:C.font.small,...e,center:e.center??D});function A({title:e,back:t=!0,right:r,subtitle:o}){return(0,B.jsxs)(p.default,{style:N.brandBar,children:[(0,B.jsxs)(p.default,{style:N.row,children:[(0,B.jsx)(p.default,{style:N.brandSide,children:t?(0,B.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Back",onPress:()=>l.router.canGoBack()?l.router.back():l.router.replace(S.ENTRY[S.APP_VARIANT]),style:N.backBtn,hitSlop:10,children:(0,B.jsx)(L,{size:18,weight:"semibold",colour:C.colours.gold,children:"\u2039 Back"})}):null}),(0,B.jsx)(h.default,{onPress:()=>l.router.push(S.ENTRY[S.APP_VARIANT]),accessibilityLabel:"Home",style:N.brandCenter,children:(0,B.jsx)(I.RestaurantBrand,{size:I.HEADER_LOGO})}),(0,B.jsx)(p.default,{style:[N.brandSide,{alignItems:'flex-end'}],children:r?(0,B.jsx)(p.default,{style:{flexShrink:0},children:r}):null})]}),e?(0,B.jsx)(P,{style:{marginTop:10,alignSelf:'stretch'},children:e}):null,o?(0,B.jsx)(z,{center:!0,style:{alignSelf:'stretch'},children:o}):null]})}function v(){const e=(0,l.useLocalSearchParams)().rid??k.VENUE_RID,t=(0,n.useStore)(t=>t.restaurants.find(t=>t.id===e)?.contactEmail);return t?(0,B.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:`Email ${t}`,onPress:()=>{c.default.openURL(`mailto:${t}`)},style:{minHeight:44,justifyContent:'center',alignItems:'center',maxWidth:'100%'},children:(0,B.jsx)(L,{center:!0,size:14,colour:C.colours.gold,children:t})}):null}function F({label:e,sub:t,onPress:r,kind:o="primary",disabled:l,small:n,style:s,accessibilityLabel:c,accessibilityHint:u,testID:b}){const f={primary:C.colours.gold,secondary:C.colours.tile,danger:C.colours.redSolid,ghost:'transparent',success:C.colours.accentBg}[o],y={primary:C.colours.onGold,secondary:C.colours.text,danger:'#FFFFFF',ghost:C.colours.gold,success:C.colours.goldLight}[o],p={primary:'transparent',secondary:C.colours.hairline,danger:'transparent',ghost:'transparent',success:C.colours.accentBorder}[o];return(0,B.jsxs)(h.default,{testID:b,accessibilityRole:"button",accessibilityLabel:c??e,accessibilityHint:u,accessibilityState:{disabled:!!l},disabled:l,onPress:r,style:({pressed:e})=>[N.btn,{backgroundColor:e&&'secondary'===o?C.colours.tilePressed:f,borderColor:p,opacity:l?.4:e?.85:1},n&&{paddingVertical:8,paddingHorizontal:14,minHeight:w.control.min,minWidth:44},s],children:[(0,B.jsx)(L,{weight:"semibold",size:n?C.font.small:C.font.body,colour:y,center:!0,children:e.trim()}),t?(0,B.jsx)(L,{size:n?C.font.small-2:C.font.small,colour:y,center:!0,testID:b?`${b}-sub`:void 0,children:t}):null]})}function H({children:e,style:t,onPress:r,highlight:o}){const l=o===C.colours.gold||o===C.colours.accentBorder,n=(0,B.jsx)(p.default,{testID:"cc-card",style:[N.card,{alignItems:'stretch'},o?{borderColor:l?C.colours.accentBorder:o,borderWidth:l?1:2}:null,t],children:e});return r?(0,B.jsx)(h.default,{accessibilityRole:"button",onPress:r,style:({pressed:e})=>({opacity:e?.85:1}),children:n}):n}function E({kind:e="info",title:t,children:r}){const o={info:[C.colours.surface,C.colours.gold,C.colours.text],warn:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],danger:[C.colours.redBg,C.colours.red,'#FFE3DF'],success:[C.colours.okBg,C.colours.ok,C.colours.goldLight],example:[C.colours.amberBg,C.colours.amber,'#FFE2A8'],demo:[C.colours.goldTint,C.colours.gold,C.colours.goldLight]}[e];return(0,B.jsxs)(p.default,{accessibilityRole:"summary",style:[N.banner,{backgroundColor:o[0],borderLeftColor:o[1]}],children:[t?(0,B.jsx)(L,{weight:"semibold",colour:o[2],center:!0,children:t}):null,s.default.Children.toArray(r).every(e=>'string'==typeof e||'number'==typeof e)?(0,B.jsx)(L,{size:C.font.small,colour:o[2],center:!0,children:r}):r]})}z.statusLine=!0,F.centreRow=!0;const V=({phone:e})=>(0,B.jsx)(E,{kind:"warn",title:"Allergies",children:"All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions. "+(e?`If you have an allergy, phone us on ${e} before ordering.`:'If you have an allergy, phone the restaurant before ordering.')}),$=()=>(0,B.jsx)(E,{kind:"demo",title:"Demo restaurant: no real payment",children:"No card is charged and no payment provider is contacted."});function O({children:e,style:t,gap:r=8,wrap:o}){const l=s.default.Children.map(e,e=>{if(!s.default.isValidElement(e))return e;const t=e,r=f.default.flatten(t.props.style)||{};return 1!==r.flex&&1!==r.flexGrow?e:s.default.cloneElement(t,{style:[t.props.style,{minWidth:Math.max(t.type===H?240:180,'number'==typeof r.minWidth?r.minWidth:0)}]})}),n=f.default.flatten(t)||{},c=s.default.Children.toArray(l).filter(s.default.isValidElement),u=e=>e.type;if(D&&'space-between'===n.justifyContent&&1!==n.flex&&2===c.length&&c.some(e=>u(e).statusLine))return(0,B.jsx)(p.default,{dataSet:{centre:'status'},style:{alignItems:'center',alignSelf:'stretch',width:'100%',gap:r},children:c});const h=D&&c.length>=2&&c.every(e=>u(e).centreRow)&&'flex-start'!==n.justifyContent&&'space-between'!==n.justifyContent;return(0,B.jsx)(p.default,{...h?{dataSet:{centre:'buttons'}}:{},style:[N.row,{gap:r},h&&{justifyContent:'center',flexWrap:'wrap'},o&&{flexWrap:'wrap',justifyContent:'center'},t],children:l})}const _=()=>(0,B.jsx)(p.default,{style:{height:1,backgroundColor:C.colours.border,marginVertical:4}});const N=f.default.create({row:{flexDirection:'row',alignItems:'center',flexWrap:'wrap',minWidth:0,maxWidth:'100%'},brandBar:{paddingHorizontal:16,paddingTop:8,paddingBottom:8,borderBottomWidth:1,borderBottomColor:C.colours.border},brandSide:{width:96,minHeight:48,justifyContent:'center'},brandCenter:{flex:1,alignItems:'center',justifyContent:'center',minHeight:48},backBtn:{paddingRight:12,minHeight:48,minWidth:88,justifyContent:'center'},btn:{minWidth:0,maxWidth:'100%',flexShrink:1,borderRadius:w.radii.button,paddingVertical:12,paddingHorizontal:18,borderWidth:1,alignItems:'center',justifyContent:'center',minHeight:w.control.min,alignSelf:'stretch'},card:{minWidth:0,maxWidth:'100%',backgroundColor:C.colours.surface,borderRadius:C.radius.l,padding:16,borderWidth:1,borderColor:C.colours.hairline,gap:8},badge:{borderRadius:999,paddingHorizontal:9,paddingVertical:2,borderWidth:1,alignSelf:'flex-start'},banner:{borderRadius:C.radius.m,padding:12,borderLeftWidth:5,gap:2},input:{minWidth:0,boxSizing:'border-box',backgroundColor:C.colours.surface2,borderColor:C.colours.border,borderWidth:1,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:10,color:C.colours.text,fontSize:C.font.body,fontFamily:C.fonts.regular},chip:{maxWidth:'100%',flexShrink:0,borderWidth:1,borderColor:C.colours.border,borderRadius:C.radius.m,paddingHorizontal:12,paddingVertical:8,backgroundColor:C.colours.surface2,minWidth:64,minHeight:44,justifyContent:'center'},stepBtn:{width:44,height:44,borderRadius:22,borderWidth:1.5,borderColor:C.colours.gold,alignItems:'center',justifyContent:'center'},overlay:{flex:1,backgroundColor:'rgba(0,0,0,0.7)',justifyContent:'center',alignItems:'center',padding:16},sheet:{backgroundColor:C.colours.surface,borderRadius:w.radii.xl,padding:18,width:'100%',maxWidth:520,maxHeight:'90%',borderWidth:1,borderColor:C.colours.gold},footer:{borderTopWidth:1,borderTopColor:C.colours.border,backgroundColor:C.colours.surface,padding:12}})},794,[795,796,830,827,30,831,34,379,395,236,402,295,41,410,102,426,36,821,826,871,5,872,873,25]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RESPONSIVE_CSS",{enumerable:!0,get:function(){return t}});const t="\n*,*::before,*::after { box-sizing:border-box !important; }\nhtml,body { max-width:100%; overflow-x:hidden; }\ninput,select,textarea { box-sizing:border-box !important; min-width:0; max-width:100%; }\n[dir=\"auto\"] { overflow-wrap:break-word; }\n[data-testid^=\"area-summary-\"] [dir=\"auto\"] { overflow-wrap:normal; word-break:keep-all; text-align:center; }\n[data-testid=\"venue-header-name\"],\n[data-testid^=\"avatar-option-\"] [dir=\"auto\"] { overflow-wrap:normal !important; word-break:keep-all !important; }\n[data-testid=\"cc-card\"] { min-width:0; max-width:100%; overflow-x:hidden; }\n[data-testid=\"cc-card\"] > [dir=\"auto\"] { text-align:center; }\n[data-testid=\"cc-card\"] > * { min-width:0; max-width:100%; }\n";if('undefined'!=typeof document&&!document.getElementById('cc-responsive-sizing')){const n=document.createElement('style');n.id='cc-responsive-sizing',n.textContent=t,document.head.appendChild(n)}},795,[]); __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.GoldX=h,_e.GoldClose=j,Object.defineProperty(_e,"TEXT_ONLY_CLOSE",{enumerable:!0,get:function(){return x}}),_e.ToastClose=function({onPress:e,label:o="Close",testID:s,size:l="md",style:c,colour:h}){return x?(0,b.jsx)(t.default,{testID:s,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:[{minWidth:64,minHeight:48,alignItems:'center',justifyContent:'center',paddingHorizontal:8},c],children:(0,b.jsx)(u.Text,{style:{fontSize:16,color:h??n.colours.text},children:"Close"})}):(0,b.jsx)(j,{onPress:e,label:o,testID:s,size:l,style:c})},r(d[0]);var t=e(r(d[1])),o=e(r(d[2])),s=r(d[3]),l=e(s),n=r(d[4]),c=r(d[5]),u=r(d[6]),b=r(d[7]);function h({size:e=16,colour:t=n.colours.gold,stroke:o}){const c=o??(e>=20?2.4:2.2);return(0,b.jsx)(l.default,{width:e,height:e,viewBox:"0 0 24 24",accessible:!1,focusable:!1,pointerEvents:"none",children:(0,b.jsx)(s.Path,{d:"M6 6 L18 18 M18 6 L6 18",stroke:t,strokeWidth:Math.min(4,c*(24/e)),strokeLinecap:"round",fill:"none"})})}const f={sm:32,md:38,lg:46},y={sm:13,md:15,lg:18};function j({onPress:e,label:s="Close",testID:l,size:c="md",style:u,disabled:j,hint:x}){const C=f[c],I=Math.max(44,C+8);return(0,b.jsx)(t.default,{testID:l,accessibilityRole:"button",accessibilityLabel:s,accessibilityHint:x,disabled:j,onPress:e,dataSet:{goldClose:'1'},style:[{width:I,height:I,alignItems:'center',justifyContent:'center',flexShrink:0,opacity:j?.4:1},u],children:({pressed:e,hovered:t})=>(0,b.jsx)(o.default,{style:{width:C,height:C,borderRadius:C/2,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:e||t?n.colours.gold:n.colours.accentBorder,backgroundColor:e?n.colours.goldTint:t?n.colours.accentBg:'rgba(0,0,0,0.18)'},children:(0,b.jsx)(h,{size:y[c],colour:e?n.colours.goldLight:n.colours.gold})})})}const x=['kirkton','abbotsford'].includes(c.VENUE_RID)},796,[34,402,102,797,821,5,827,25]); __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}},797,[798]); @@ -911,7 +911,7 @@ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule? __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SOUTERS_BG",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SOUTERS_SURFACE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SOUTERS_TYPE_SCALE",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"soutersFont",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"soutersSurface",{enumerable:!0,get:function(){return f}}),e.soutersInk=function(o){if(!t.IS_SOUTERS)return o;const c=(0,n.normaliseHex)(o);return c?'#A4622E'===c?'#D9AD8A':(0,n.contrast)(c,u)<4.5?'#FFFFFF':o:o};var t=r(d[0]),n=r(d[1]);const u='#56152A',o='#43122F',c=.88,S=n=>t.IS_SOUTERS?Math.round(n*c*100)/100:n,f=n=>t.IS_SOUTERS?o:n},828,[5,829]); __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normaliseHex=n,e.hexToRgb=r,e.rgbToHex=o,e.hsvToRgb=s,Object.defineProperty(e,"hsvToHex",{enumerable:!0,get:function(){return a}}),e.hexToHsv=function(t){const{r:n,g:o,b:s}=r(t),a=n/255,c=o/255,u=s/255,i=Math.max(a,c,u),h=Math.min(a,c,u),l=i-h;let p=0;l&&(p=i===a?(c-u)/l%6:i===c?(u-a)/l+2:(a-c)/l+4);return{h:(60*p+360)%360,s:i?l/i:0,v:i}},e.luminance=c,e.contrast=u,e.shade=i,e.checkAccent=function(t,r,o,s){const a=n(t)??'#CFA45F',c=u(a,o),h=u(a,s),l=c>=h?o:s,p=[];Math.max(c,h)<4.5?p.push('Button text may be hard to read on this colour. We picked the clearer text colour for you, but a lighter or darker shade will read better.'):l===s&&p.push('This is a dark colour, so buttons use light text.');let b=a,d=0;for(;u(b,r)<4.5&&d<20;)b=i(a,.05*(d+1)),d++;b!==a&&p.push('This colour is hard to read on the dark background, so header text uses a lighter shade of it.');return{onAccent:l,accentText:b,tips:p}},e.pushRecent=function(t,r,o=8){const s=n(r);return s?[s,...(t??[]).filter(t=>t!==s)].slice(0,o):t??[]};const t=(t,n=0,r=1)=>Math.min(r,Math.max(n,t));function n(t){const n=t.trim().replace(/^#/,'');return/^[0-9a-fA-F]{3}$/.test(n)?'#'+n.split('').map(t=>t+t).join('').toUpperCase():/^[0-9a-fA-F]{6}$/.test(n)?'#'+n.toUpperCase():null}function r(t){const r=(n(t)??'#000000').slice(1);return{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}}function o({r:n,g:r,b:o}){return'#'+[n,r,o].map(n=>Math.round(t(n,0,255)).toString(16).padStart(2,'0')).join('').toUpperCase()}function s({h:t,s:n,v:r}){const o=(t%360+360)%360/60,s=r*n,a=s*(1-Math.abs(o%2-1)),c=r-s,[u,i,h]=o<1?[s,a,0]:o<2?[a,s,0]:o<3?[0,s,a]:o<4?[0,a,s]:o<5?[a,0,s]:[s,0,a];return{r:255*(u+c),g:255*(i+c),b:255*(h+c)}}const a=t=>o(s(t));function c(t){const n=t=>{const n=t/255;return n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)},{r:o,g:s,b:a}=r(t);return.2126*n(o)+.7152*n(s)+.0722*n(a)}function u(t,n){const r=c(t),o=c(n);return(Math.max(r,o)+.05)/(Math.min(r,o)+.05)}function i(t,n){const{r:s,g:a,b:c}=r(t),u=n>0?255:0,i=Math.abs(n);return o({r:s+(u-s)*i,g:a+(u-a)*i,b:c+(u-c)*i})}},829,[]); __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,"isEditable",{enumerable:!0,get:function(){return u}}),_e.hideKeyboard=s,_e.installKeyboardHide=f,_e.useTyping=function(){const[e,n]=t.default.useState(c);return t.default.useEffect(()=>{if(!o)return;f();const e=()=>setTimeout(()=>n(c()),0);return document.addEventListener('focusin',e,!0),document.addEventListener('focusout',e,!0),()=>{document.removeEventListener('focusin',e,!0),document.removeEventListener('focusout',e,!0)}},[]),e},_e.useVisibleArea=function(){const e=o?window.visualViewport:null,n=()=>e?{height:Math.round(e.height),top:Math.round(e.offsetTop)}:null,[u,c]=t.default.useState(n);return t.default.useEffect(()=>{if(!e)return;const t=()=>c(e=>{const t=n();return e&&t&&e.height===t.height&&e.top===t.top?e:t});return e.addEventListener('resize',t),e.addEventListener('scroll',t),()=>{e.removeEventListener('resize',t),e.removeEventListener('scroll',t)}},[]),u};var t=e(r(d[0])),n=e(r(d[1]));r(d[2]);const o='undefined'!=typeof document,u=e=>!!e&&'function'==typeof e.matches&&e.matches("input:not([type=button]):not([type=submit]):not([type=checkbox]):not([type=radio]):not([type=range]), textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"]"),c=()=>!!o&&u(document.activeElement);function s(){try{n.default.dismiss()}catch{}o&&u(document.activeElement)&&document.activeElement.blur()}function a(){if(!o)return;const e=document.activeElement;if(u(e))try{e.scrollIntoView({block:'nearest',inline:'nearest'})}catch{}}let l=!1;function f(){o&&!l&&(l=!0,document.addEventListener('click',e=>{if(!c())return;const t=document.activeElement;if('function'!=typeof t.closest||!t.closest('[aria-modal="true"], [role="dialog"]'))return;const n=e.target;n&&!u(n)&&('function'==typeof n.closest&&n.closest('label, [data-keep-keyboard]')||s())},!0),document.addEventListener('focusin',e=>{u(e.target)&&setTimeout(a,300)},!0),window.visualViewport?.addEventListener('resize',()=>setTimeout(a,50)))}},830,[34,376,236]); -__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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 O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:u,phone:g,email:m})=>{const p=t(),b=p.basket,f=b.restaurantId,k=w(b,p.menu,p.customer.allergies),I=k.reduce((e,t)=>e+t.unitPrice*t.qty,0),S='table'===b.mode,h=$(p.orders.filter(e=>e.restaurantId===f).map(e=>e.ref),S?'Q-':'T-',S?p.counters.table:p.counters.order),O=u?n(o,f,I+i):0,C=I+i,v={id:(0,y.uuid)(),ref:`${S?'Q':'T'}-${h}`,restaurantId:f,customerId:p.customer.id,customerName:p.customer.name,type:b.mode,tableNo:b.tableNo,slotTime:s,lines:k,subtotal:I,tip:i,giftCardApplied:O,giftCardCode:O?o:void 0,total:C,paid:u?C:0,status:'new',createdAt:a().toISOString(),allergies:p.customer.allergies,readiness:{},notes:l,channel:'app',...'takeaway'===b.mode?{phone:g??p.customer.phone,email:m??p.customer.email}:{}};e(e=>({orders:[v,...e.orders],basket:{...e.basket,lines:[]},counters:S?{...e.counters,table:h}:{...e.counters,order:h}}));const A=k.filter(e=>e.overridden);return r(f,'order',`Order ${v.ref} placed (${S?`Table ${b.tableNo}`:'takeaway'})${A.length?` \u2014 ALLERGY OVERRIDE on ${A.map(e=>e.name).join(', ')}`:''}`),v.allergies.length&&r(f,'allergy',`Allergies declared and confirmed by customer on ${v.ref}: ${v.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),c(v),v},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); +__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 y.uuid}}),_e.nowFrom=S,_e.linesFromBasket=w,Object.defineProperty(_e,"useStore",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"DEMO_CUSTOMER_ID",{enumerable:!0,get:function(){return u.DEMO_CUSTOMER_ID}});var e,t=_r(d[0]),a=_r(d[1]),r=_r(d[2]),n=_r(d[3]),s=_r(d[4]),i=_r(d[5]),o=(e=i)&&e.__esModule?e:{default:e},l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),g=_r(d[9]),m=_r(d[10]),p=_r(d[11]),b=_r(d[12]),f=_r(d[13]),k=_r(d[14]),y=_r(d[15]);const $=(e,t,a)=>e.reduce((e,a)=>a.startsWith(t)?Math.max(e,Number(a.slice(t.length))||0):e,a)+1,I=e=>`${e}-${Math.random().toString(36).slice(2,8)}${Date.now().toString(36).slice(-3)}`;function S(e){return'live'===e.mode?new Date:new Date(e.simStartMs+(Date.now()-e.anchorRealMs))}function h(){const e=(0,u.defaultSimStart)();return{clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},...(0,u.buildSeed)(e),outbox:[],msgTemplates:{}}}function w(e,t,a){return e.lines.flatMap(e=>{const r=t.find(t=>t.id===e.itemId);if(!r)return[];const n=(0,b.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,p.conflictsFor)((0,p.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,choiceIds:s.map(e=>e.id)}]})}const O=e=>{const t='ABCDEFGHJKLMNPQRSTUVWXYZ23456789',a=()=>Array.from({length:4},()=>t[Math.floor(32*Math.random())]).join('');return`${e}-${a()}-${a()}-${a()}`},C=(0,l.create)()((0,c.persist)((e,t)=>{const a=()=>S(t().clock),r=(t,r,n)=>e(e=>({audit:[{id:I('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},s=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)')},i=e=>(0,f.templatesFor)(t().msgTemplates[e]),o=a=>{a.length&&(e(e=>({outbox:[...a,...e.outbox].slice(0,300)})),(0,f.deliverQueued)(a.filter(e=>'queued'===e.status),(e,a)=>t().updateOutbox(e,a)))},l=(e,r)=>{const n=t().restaurants.find(e=>e.id===r.restaurantId);n&&o((0,f.composeBooking)(e,r,n,i(n.id),a().toISOString()))},c=e=>{const r=t().restaurants.find(t=>t.id===e.restaurantId);r&&o((0,f.composeOrder)(e,r,i(r.id),a().toISOString()))};return{...h(),resetDemo:()=>e(h()),setClockMode:()=>e({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),skipMinutes:()=>{},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:I('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:n,tip:s,notes:i,phone:o,email:l,customerName:u})=>{const g=t(),m=g.basket,p=m.restaurantId,b=w(m,g.menu,g.customer.allergies),f=b.reduce((e,t)=>e+t.unitPrice*t.qty,0),k='table'===m.mode,I=$(g.orders.filter(e=>e.restaurantId===p).map(e=>e.ref),k?'Q-':'T-',k?g.counters.table:g.counters.order),S=!k,h=f+(S?0:s),O=(u??'').trim()||g.customer.name,C={id:(0,y.uuid)(),ref:`${k?'Q':'T'}-${I}`,restaurantId:p,customerId:g.customer.id,customerName:O,type:m.mode,tableNo:m.tableNo,slotTime:n,lines:b,subtotal:f,tip:S?0:s,giftCardApplied:0,giftCardCode:void 0,total:h,paid:0,status:S?'awaiting_payment':'new',createdAt:a().toISOString(),allergies:g.customer.allergies,readiness:{},notes:i,channel:'app',...'takeaway'===m.mode?{phone:o??g.customer.phone,email:l??g.customer.email}:{}};e(e=>({orders:[C,...e.orders],basket:{...e.basket,lines:[]},counters:k?{...e.counters,table:I}:{...e.counters,order:I}}));const v=b.filter(e=>e.overridden);return r(p,'order',`Order ${C.ref} placed (${k?`Table ${m.tableNo}`:'takeaway'})${v.length?` \u2014 ALLERGY OVERRIDE on ${v.map(e=>e.name).join(', ')}`:''}`),C.allergies.length&&r(p,'allergy',`Allergies declared and confirmed by customer on ${C.ref}: ${C.allergies.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),'awaiting_payment'!==C.status&&c(C),C},setOrderStatus:(a,n,i)=>{const o=t().orders.find(e=>e.id===a);o&&((0,k.statusBlock)(o,n,(0,k.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}${i?` by ${i}`:''}`),'collected'===n&&'takeaway'===o.type&&s(o)))},ackOrderAllergy:(n,s)=>{const i=t().orders.find(e=>e.id===n);if(!i||!(0,k.canSign)(i,'kitchen',(0,k.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,k.statusBlock)(o,'preparing',(0,k.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,k.canSign)(i,'table',(0,k.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,k.linkedBooking)(o,t().bookings);if(!(0,k.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,k.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:i,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)+i),m=g>=c,p=m?l.total-l.paid:Math.min(l.total-l.paid,u*i),b=n(o,l.restaurantId,p),f={...l,giftCardApplied:l.giftCardApplied+b,giftCardCode:b?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?f:e)})),r(l.restaurantId,'order',`${l.ref} (Table ${l.tableNo}) ${m?'bill paid in full':`share ${g}/${c} paid`} (paid at the till)`),m&&s(f)},createBooking:n=>{const s=$(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()),c={...n,id:(0,y.uuid)(),ref:`BK-${s}`,status:o?'pending':'confirmed',createdAt:a().toISOString()};return e(e=>({bookings:[...e.bookings,c],counters:{...e.counters,booking:s}})),r(c.restaurantId,'booking',`Booking ${o?'request ':''}${c.ref}: ${c.name}, ${c.partySize} on ${c.date} ${c.time}${c.source?` (${c.source})`:''}${c.allergies.length?' \u2014 allergies declared':''}`),l(o?'booking-request':'booking-confirmation',c),c},decideBooking:(n,s,i)=>{const o=t().bookings.find(e=>e.id===n);if(!o||'pending'!==o.status)return;const c={by:i,at:a().toISOString(),outcome:s},u='confirmed'===s?'confirmed':'cancelled';e(e=>({bookings:e.bookings.map(e=>e.id===n?{...e,status:u,decided:c}:e)})),r(o.restaurantId,'booking',`Booking request ${o.ref} (${o.name}, ${o.partySize}) ${s} by ${i}`),l('confirmed'===s?'booking-confirmation':'booking-declined',{...o,status:u})},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,k.statusBlock)(o,'acknowledged',(0,k.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,m={id:(0,y.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,m]})),r(n,'walkin',`Walk-in ${m.ref} seated: ${s} cover(s)${i?`, Table ${i}`:', table to assign'}`),m},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 ${n?n.includes('+')?`Tables ${n.split('+').join(' + ')}`:`Table ${n}`:'no table'}`)},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:I('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:I('gc'),code:O(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:I('gc'),code:n.trim().toUpperCase(),restaurantId:t,initial:s,balance:s,ownerId:'legacy',recipientName:'Legacy website bookings 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 website bookings gift card ${o.code} honoured (\xa3${(s/100).toFixed(2)}) by ${i}`),o},addEvent:t=>e(e=>({events:[...e.events,{...t,id:I('ev')}]})),addRating:t=>{e(e=>({ratings:[{...t,id:I('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:c,...u}=n,g={};void 0!==s&&(g.dish=s),void 0!==i&&(g.section=i),'price'in n&&(g.price=o??null),void 0!==l&&(g.allergens=l),'allergenNotes'in n&&(g.allergenNotes=c);const m='optionGroups'in n,p=(0,b.menuCardBridge)();p&&(Object.keys(g).length||m)&&p.menuEdited(a,g,'CoverCharge for Managers',m);const f=p?u:n;Object.keys(f).length&&e(e=>({menu:e.menu.map(e=>e.id===a?{...e,...f}:e)}));const k=t().menu.find(e=>e.id===a);k&&Object.keys(f).length&&r(k.restaurantId,'menu',`Menu: ${(0,b.resolveItem)(k).name} updated`)},setSignOff:(t,r)=>{const n=(0,b.menuCardBridge)();n?r?n.signOff(t,r):n.menuEdited(t,{},'CoverCharge 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=I('m');return e(e=>({menu:[...e.menu,{...t,id:a}]})),(0,b.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:l,email:u,tableNo:g,slotTime:m,lines:f,allergies:k,notes:I,by:S})=>{const h=t(),w=f.flatMap(({itemId:e,qty:t})=>{const a=h.menu.find(t=>t.id===e);if(!a||t<=0)return[];const r=(0,b.resolveItem)(a),n=(0,p.conflictsFor)((0,p.effectiveAllergens)(r),k);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,v=$(h.orders.filter(e=>e.restaurantId===n).map(e=>e.ref),C?'Q-':'T-',C?h.counters.table:h.counters.order),A={id:(0,y.uuid)(),ref:`${C?'Q':'T'}-${v}`,restaurantId:n,customerId:`manual-${i}`,customerName:o||(C?`Table ${g}`:'Walk-in'),type:s,tableNo:g,slotTime:m,lines:w,subtotal:O,tip:0,giftCardApplied:0,total:O,paid:0,status:'new',createdAt:a().toISOString(),allergies:k,readiness:{},notes:I,channel:i,...l?{phone:l}:{},...u?{email:u}:{},...k.length?{allergyChain:{booked:{by:S,at:a().toISOString()}}}:{}};return e(e=>({orders:[A,...e.orders],counters:C?{...e.counters,table:v}:{...e.counters,order:v}})),r(n,'order',`Order ${A.ref} taken by ${S} (${'phone'===i?'phone':'walk-in'===i?'walk-in takeaway':`Table ${g}`})`),k.length&&r(n,'allergy',`Allergen sign-off 1/5 Booked on ${A.ref}: ${S} recorded ${k.map(e=>`${e.allergen} (${e.severity})`).join(', ')}`),(l||u)&&c(A),A},ackAlert:(t,r)=>e(e=>({alertAcks:{...e.alertAcks,[t]:{by:r,at:a().toISOString()}}}))}},{name:'covercharge-demo-v1',version:9,migrate:async(e,t)=>{if(!e)return e;if(n.LIVE_VENUE_BUILD)return await(0,s.archiveChefCache)('core',e),Object.assign(e,(0,r.stripCoreLiveSamples)(e)),e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},e;if(e.clock={mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()},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(g.ANCHORAGE_KITCHEN_OLD)?{...e,kitchenHours:g.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:g.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,u.buildSeed)((0,u.defaultSimStart)()),a=new Map(t.bookings.map(e=>[e.id,e])),r=new Set((0,m.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},merge:(e,r)=>{const n={...r,...e};return a.IS_WILDINGS&&(n.restaurants=n.restaurants.map(t.withWildingsAddress)),n},storage:(0,c.createJSONStorage)(()=>o.default)}))},831,[832,5,833,837,838,839,846,849,850,3,859,861,862,864,869,870]); __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WILDINGS_LOCATION",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WILDINGS_ADDRESS",{enumerable:!0,get:function(){return t}}),e.withWildingsAddress=function(r){return'wildings'===r.id?{...r,location:n,address:t}:r},e.withWildingsQuestionnaireAddress=function(n,r){return'wildings'===n&&r?{...r,venue:{...r.venue,address:t}}:r};const n='Maidens, KA26 9NR',t='Maidens Road, Maidens, KA26 9NR'},832,[]); __d(function(g,r,_i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sampleFingerprint=i,e.stripOwnerLiveSamples=function(n){const a={};for(const[s,o]of Object.entries(t.OWNER_SAMPLE_HASHES)){const t=n[s]||[];a[s]=t.filter(t=>!o.includes(i(t)))}a.chat=(n.chat||[]).filter(t=>!(0,s.isSeedChefChat)(t));const o=(n.changeRequests||[]).length-a.changeRequests.length;o&&(a.changesUsed=Math.max(0,(n.changesUsed||0)-o));return a},e.stripCoreLiveSamples=function(a){const c={...(0,n.stripCoreChefSamples)(a)};c.giftCards=(a.giftCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.giftCards.includes(i(s))),c.stampCards=(a.stampCards||[]).filter(s=>!t.CORE_SAMPLE_HASHES.stampCards.includes(i(s))),c.ratings=(a.ratings||[]).filter(t=>!(/^rt-[123]$/.test(t.id)&&(0,s.demoActor)(t.customerName))),i(a.customer)===t.LEGACY_CUSTOMER_HASH&&(c.customer={...a.customer,id:'',name:'',email:'',phone:'',allergies:[],allergyConsent:!1,referralCode:'',marketingOptIn:{}});return c.restaurants=(a.restaurants||[]).filter(t=>!('saltmarsh'===t.id&&['The Venue','Saltmarsh Bistro'].includes(t.name))),c.menu=(c.menu||a.menu||[]).filter(t=>'saltmarsh'!==t.restaurantId).map(t=>t.signOff?t:o(t)),c};var t=r(d[0]),s=r(d[1]),n=r(d[2]);const a=t=>Array.isArray(t)?t.map(a):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).filter(([,t])=>void 0!==t&&'function'!=typeof t).sort(([t],[s])=>ts?1:0).map(([t,s])=>[t,a(s)])):t;function i(t){const s=JSON.stringify(a(t))??"null";let n=2166136261;for(let t=0;t>>0).toString(16)}const o=t=>Array.isArray(t)?t.map(o):t&&'object'==typeof t?Object.fromEntries(Object.entries(t).map(([t,s])=>[t,'allergenNotes'===t&&'string'==typeof s&&/\(example\)/i.test(s)?'':o(s)])):t},833,[834,835,836]); __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"OWNER_SAMPLE_HASHES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CORE_SAMPLE_HASHES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"LEGACY_CUSTOMER_HASH",{enumerable:!0,get:function(){return b}});const c={referrals:["43f09bc0","c438fbad","96bf8c62","3399d421"],coats:["f51097ad","2f7efa3a"],merch:["ef6e14e","dbbc0999","dc233c1d"],merchOrders:["13b15512","bc27f242"],offers:["ad0fcde0","59e6c0cf"],photos:["53a60fd9","ab778a74","95de43cd"],changeRequests:["81c5be12","6819542c"],lost:["5bbf0d77","7d3aa9ed","850c049e"],campaigns:["9cdf8346","82150e7"],suppliers:["41df06e7","466e32ac","fa3d8eea","dfafa674","1e26fbd0","c195b120","5fc49e74","6aa8b0af","602fc2e4"],supplierOrders:["22636226","464d6a6a"]},f={giftCards:["b1bba36d","f029bc0e"],stampCards:["e7bedf6f","a3c8404d"]},b="4b1e9971"},834,[]); @@ -1067,540 +1067,543 @@ __d(function(g,r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModul __d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KG_PER_STONE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"HALF_STONE_KG",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFishName",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"fishInStone",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"halfStone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"toStone",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"fromStone",{enumerable:!0,get:function(){return c}}),e.stoneText=b,e.stoneSpeech=h,Object.defineProperty(e,"fishQtyText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"fishQtySpeech",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantityStep",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"stepQuantity",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"inputQuantity",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"quantityUnit",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"displayedCost",{enumerable:!0,get:function(){return k}}),e.parseStoneAmount=function(t){if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.toLowerCase().trim();if(/\b(?:kg|kilos?|kilograms?|grams?)\b/.test(n))return;const i=n.match(/(?:^|\s)(\d+(?:[.,]\d+)?)(\xbd)?(?:\s*(?:stone|st)\b|$)/);if(i)return Number(i[1].replace(',','.'))+(i[2]?.5:0);const o=n.match(/\b(zero|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)(?: and a half)?(?: stone| st|$)/);return o?l.indexOf(o[1])+(/and a half/.test(o[0])?.5:0):/(?:^|\s)(?:\xbd|(?:a )?half(?: a)?)(?: stone| st|$)/.test(n)?.5:void 0};var t=r(d[0]);const n=6.35029318,i=3.17514659,o=(t="")=>!/\b(?:vegan|vegetarian|banana|blossom|mushroom|sauce|stock|oil)\b|\(vg\)/i.test(t)&&/\b(?:fish|haddock|salmon|cod|hake|halibut|plaice|sole|turbot|trout|mackerel|monkfish|seabass|sea bass|seabream|sea bream|tuna|pollock|coley|whiting|sardines?|anchov(?:y|ies)|herring)\b/i.test(t),u=(n,i)=>(0,t.isAnchorage)(n)&&/^(kg|kilos?|kilograms?|st|stone)$/i.test(i.unit||'')&&o(i.name),s=t=>Math.round(2*(t+Number.EPSILON))/2,f=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t/n,c=(t,i="kg")=>/^(st|stone)$/i.test(i)?t:t*n;function b(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'\u2212':''}${n%1?`${i||''}\xbd`:i} stone`}const l=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];function h(t){const n=s(Math.abs(t)),i=Math.floor(n);return`${t<0&&n?'minus ':''}${n%1?i?`${l[i]||i} and a half`:'half a':l[i]||i} stone`}const y=(t,n,i)=>u(t,n)?b(f(i,n.unit)):`${i} ${n.unit||''}`.trim(),p=(t,n,i)=>u(t,n)?h(f(i,n.unit)):y(t,n,i),O=(t,n)=>u(t,n)?c(.5,n.unit):'kg'===n.unit?.5:1,v=(t,n,i,o)=>u(t,n)?c(Math.max(0,s(f(i,n.unit))+.5*o),n.unit):Math.max(0,i+o*O(t,n)),P=(t,n,i)=>u(t,n)?c(s(i),n.unit):i,j=(t,n)=>u(t,n)?'stone':n.unit||'',k=(t,n,i)=>u(t,n)?i*c(1,n.unit):i},984,[835]); __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 t}}),Object.defineProperty(_e,"stockKey",{enumerable:!0,get:function(){return n}}),_e.countsOf=function(e,t=[],n={}){const u={...n};for(const e of t)u[e.key]=u[e.key]??0;for(const t of e)u[t.kind]=(u[t.kind]??0)+t.delta;const i=new Map(t.map(e=>[e.key,e]));return Object.fromEntries(Object.entries(u).map(([e,t])=>[e,o(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 u}}),Object.defineProperty(_e,"fmtStockCount",{enumerable:!0,get:function(){return i}}),Object.defineProperty(_e,"speakStockCount",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"isLowItem",{enumerable:!0,get:function(){return c}}),_e.describe=function(e,t){const n=(t?.name??e.kind).toLowerCase(),o=(t?.plural??`${e.kind}s`).toLowerCase(),s=t?i(e.rid,t,Math.abs(e.delta)):u(Math.abs(e.delta));return'delivery'===e.reason?`Delivery in: +${s} ${1===Math.abs(e.delta)?n:o}`:'sold-half'===e.reason?`Sold: half ${n}`:'sold'===e.reason?`Sold: ${s} ${1===Math.abs(e.delta)?n:o}`:'undo'===e.reason?`Undo (${e.delta>0?'+':'\u2212'}${s} ${n})`:`Count: ${s} ${o}`},Object.defineProperty(_e,"isRoastItem",{enumerable:!0,get:function(){return l}}),_e.isSundayIn=function(e,t="Europe/London"){try{return'Sun'===new Intl.DateTimeFormat('en-GB',{weekday:'short',timeZone:t}).format(e)}catch{return 0===e.getDay()}};var e=r(_d[0]);const t=[{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}],n=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'').slice(0,40)||'item',o=(e,t)=>Math.max(0,'kg'===e?.unit?t:'half'===e?.unit?Math.round(2*t)/2:Math.round(t));const u=e=>{const t=Math.floor(e);return e-t>=.5?t?`${t}\xbd`:'\xbd':String(t)},i=(t,n,o)=>'kg'===n.unit?(0,e.fishQtyText)(t,n,o):u(o),s=(t,n,o)=>'kg'===n.unit?(0,e.fishQtySpeech)(t,n,o):u(o),c=(e,t)=>t<=(e?.lowAt??4);const l=e=>'roast'===e.group},985,[984]); __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLiveState=function(){const e=(0,s.useSync)(e=>e.mode),n=(0,s.useSync)(e=>e.venueId),o=(0,s.useSync)(e=>e.lastSyncAt);return c.PITCH||n&&o?'ready':'signin'===e||'local'===e||'off'===e||'unpaired'===e?'nolink':'offline'===e?'offline':'connecting'},_e.LiveWait=function({state:n,title:o,testID:s}){const c=e.IS_CAR?b[n]:'nolink'===n&&'display'===e.APP_VARIANT?p:f[n];return(0,h.jsxs)(t.default,{testID:s,accessible:!0,accessibilityLabel:`${o}: ${c}`,style:{borderRadius:16,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface,padding:14,gap:4},children:[(0,h.jsx)(u.T,{size:12,weight:"semibold",colour:l.colours.goldMuted,children:o.toUpperCase()}),(0,h.jsx)(u.T,{size:18,weight:"semibold",children:c})]})};var e=r(d[0]);r(d[1]);var n,o=r(d[2]),t=(n=o)&&n.__esModule?n:{default:n},s=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),h=r(d[7]);const f={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when this phone is back online.',nolink:'Not connected to the venue. Open your personal link from your manager on this phone to see live numbers.'},p="This Display isn't paired yet. Tap Not paired to pair it.",b={connecting:'Connecting\u2026',offline:'No connection. The live numbers show again when the car is back online.',nolink:'Not connected yet. Check the car has internet. If this stays, sign the car in again from Managers on your phone.'}},986,[872,34,102,987,2,821,794,25]); -__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return W.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return W.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return W.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return W.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return W.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return I.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return I.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return It}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ne.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ne.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ne.useOwner.getState().chatSeen(t,e)),Ft(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ne.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ne.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...St(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(le.PITCH)return pe.unlockCashUp(e,t,a);const s=Oe.getState().venueId;if(!s||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?oe.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):oe.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(le.PITCH)return pe.cashAudit(e);const t=Oe.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(ma.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=fa,i.readAccessLog=async function(){const e=Oe.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Oe.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return pa}}),i.uploadOrderLogo=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(pa).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ga.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(pa).createSignedUrl(e,3600);if(t?.signedUrl)return ga.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(pa).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return ma}}),i.claimInvite=Da,i.makeChromeHandover=async function(){const e=Oe.getState();if(le.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ue});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(le.PITCH||!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ue});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),Pe&&xa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Te();const t=await x.kv.get(ka,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Te(),await x.kv.get(Ia,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Oe.getState();if(!o.IS_WILDINGS||'staff'!==e.kind||e.venueId!==o.VENUE_UUID||e.staffRef!==O.useSession.getState().meId)return null;Te();const t=await x.kv.get(Ia,null);return t?(0,O.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Te(),await x.kv.remove(ka),await x.kv.remove(Ia),Ae({mode:'signin',perms:[]});try{await Ma()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Oe.getState().venueId;if(le.PITCH||!s||'staff'!==Oe.getState().kind)return{ok:!0};if(!(0,ie.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Ka('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Da(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(le.PITCH)return pe.reissueInvite(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Ka('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Ka('staff_app_link_history',{p_venue:Oe.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Ka('revoke_staff_app_link',{p_venue:Oe.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(le.PITCH)return pe.linkPhones();const e=Oe.getState().venueId;if(!e||'staff'!==Oe.getState().kind)return{};try{const t=await Ka('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(le.PITCH)return pe.resetPhone(e);const t=Oe.getState().venueId;if(!t||'staff'!==Oe.getState().kind)throw new Error('Connect to the venue first.');return Number(await Ka('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(le.PITCH)return pe.inviteStatus();const e=Oe.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:t,error:a}=await Re().rpc(o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_pairing_code':o.IS_GREENSIDE?'claim_greenside_pairing_code':o.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':o.IS_KIRKTON?'claim_kirkton_pairing_code':o.IS_WILDINGS?'claim_wildings_pairing_code':o.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':o.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await x.kv.set(ba,n),xa(),{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}`}}},i.carPairStart=async function(){if(!(0,T.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Ca();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await x.kv.set(Ua,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ea(e)}}},i.carPairPoll=async function(e){try{Te();const t=e??await x.kv.get(Ua,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,G.carPairApproved)(n)){const e=(0,G.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await x.kv.get(ba,null);await x.kv.set(ba,e),await x.kv.remove(ka),O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||xa()}return'revoked'!==i&&'unknown'!==i||await Ta(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Te(),await Re().rpc('car_sign_out')}catch{}await Ta(),await Ma();try{await Re().auth.signOut({scope:'local'})}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Oe.getState().venueId;if(!a||'staff'!==Oe.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Ka('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ea(e)}}},i.carList=async function(){const e=Oe.getState().venueId;if(!e)return[];return(await Ka('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Oe.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Ka('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ea(e)}}},i.unpairDisplay=async function(){await x.kv.remove(ba),await Ma();try{await Re().auth.signOut()}catch{}Ae({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await x.kv.remove(ka),await x.kv.remove(Ia),await Ma();try{await Re().auth.signOut()}catch{}Ae({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.'})},i.wipeThisDevice=async function(e={}){try{await Ma()}catch{}try{(0,T.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${o.VENUE_RID}:`)):(0,I.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!o.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ae({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Na,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Ka}}),i.mendSession=qa,i.startAppSync=async function(e=o.VENUE_RID){if(o.IS_ISOLATED_VENUE&&e!==o.VENUE_RID)return;if(Pe)return;Pe=!0,La=e,'customer'===Ue&&'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Te(),'customer'!==Ue){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ue&&(0,h.isAnchorage)(e)?[H.useStore,ne.useOwner,ae.useKitchen,se.useSafety,Y.useCardStore,m.useGpCalc,X.useOrderSheets,S.useSpecials,A.useHr]:[H.useStore,ne.useOwner,ae.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ue&&(0,h.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ae({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await vs(e)}catch{if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e))return void Ae({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,T.isSupabaseConfigured)())return void Ae({mode:'off'});j.mutationQueue.subscribe(()=>{const e=j.mutationQueue.waiting,t=e[0];Ae({pending:j.mutationQueue.pending.length,failed:j.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,L.describeWrite)(t)}: ${(0,L.plainReason)({...t.lastErr},'retry')}`:void 0})}),j.mutationQueue.onFailed(e=>Ae({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:j.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,L.describeWrite)(e),why:'conflict'===e.reason?(0,L.plainReason)({code:'conflict'},'refused'):(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Ke.push((0,N.onConnectivity)(e=>Ae({mode:e?Oe.getState().venueId?'live':Oe.getState().mode:Oe.getState().venueId?'offline':Oe.getState().mode}))),await Ba()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Wa}}),Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return za}}),i.stockSaveBlocker=Za,i.stockEventStatus=function(e){if(ze(e))return{state:'saved'};const t=j.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,L.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=Ya,i.saveStockEventsNow=Xa,i.bookingSaveBlocker=ts,i.resendUnsavedBookings=ns,i.saveBookingsNow=is,i.waitForBookingSave=function(e,t=12e3){if(!De())return Promise.resolve({state:'local'});const a=ts();if(a)return Promise.resolve({state:'refused',why:a});const s=as()[0]?.venueId??'',n=()=>es.some(t=>j.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=F.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,N.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(j.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(j.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||as().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||as().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=cs,i.tempLogState=function(){const e=ls()[0]?.venueId??'',t=ls().find(e=>'temp_readings'===e.spec.table),a=j.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!j.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values($.useTempSaves.getState().notSaved),i=se.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=fs,i.waitForTempSave=function(e,t,a=1e4){if(!De()||!ls().length)return Promise.resolve({state:'local'});const s=cs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ls()[0]?.venueId??'',i=ls().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>$.useTempSaves.getState().notSaved[(0,$.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>j.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=_s,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ts}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Es.get(a);if('customer'!==Ue||!(0,T.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Es.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Ka('public_day',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:qe(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:qe(a.from_time),to:qe(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Es.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ts.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Es.get(a);e&&!e.ok&&Es.delete(a)}));const n=Es.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Oe.getState().venueId;if(!n||'staff'!==Oe.getState().kind)throw new Error('Connect to your venue first.');const i=await Ka('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});H.useStore.getState().updateRestaurant(e,{...i,id:e})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),R=t(r[18]),O=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(fe),ge=t(r[60]),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]);const Re=()=>(0,E.getSupabase)();j.mutationQueue.setExecutor(q.executeMutation),(0,P.setClockServer)(()=>'staff'===Oe.getState().kind);const Oe=(0,U.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ae=e=>Oe.setState(e),Ce=e=>{const t=Oe.getState().perms;return t.includes('*')||t.includes(e)},De=()=>{const e=Oe.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Oe.subscribe(()=>(0,ve.setLiveData)(De()));let Ue=V.IS_CAR?'car':V.APP_VARIANT,Ee=!1;const Te=()=>{Ee||((0,x.setSyncNamespace)(Ue),Ee=!0)};let Ne=[],Ke=[],Pe=!1;const Me=()=>(new Date).toISOString().slice(0,10),xe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),qe=e=>e?e.slice(0,5):'',Le=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))):[],Be=e=>JSON.parse(JSON.stringify(e));function je(e,t){const a=xe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>H.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=Be(e);if(t)return{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:Le(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,ie.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:Le(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function Fe(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>H.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>'guest'!==Oe.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,ie.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:Be(e.lines??[]),allergies:Le(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:Be(e.allergyChain??{}),readiness:Be(e.readiness??{}),allergy_ticks:Be(e.allergyTicks??{}),handover_check:e.handoverCheck?Be(e.handoverCheck):null,accepted:e.accepted?Be(e.accepted):null,doc:Be(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)=>H.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>H.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function $e(e){const t=xe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...J.useBlocks.getState().blocks,...J.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Oe.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:Be(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,J.blockClock)(t.from_time)??a?.from,n=(0,J.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>J.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>J.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let We=null,Qe='Main plan';function He(e){const t=e=>Be({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(z.useFloor.getState().plans[e]??(0,z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>Ce('floor.manage')||Ce('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:We??(0,be.uuidFrom)(`plan:${a}`),venue_id:a,name:Qe||'Main plan',is_active:!0,...t(e),updated_by:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>(We=String(e.id),Qe=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,ke.withSeedBest)(e,t[0]):void 0;a&&z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ve(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Z.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>Ce('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,ie.isUuid)(e.supplierId)?e.supplierId:(0,be.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),ot.get(t)??t)}:{}};var t},apply:(t,a)=>Z.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Ge=new Set,Je=new Set;j.mutationQueue.onDone(e=>{'stock_events'===e.table&&Je.add(e.rowKey)});const ze=e=>Je.has(e)||Ge.has(e),Ze=()=>Ce('*')||Ce('staff.manage')||Ce('recipes.edit')||Ce('recipes.signoff'),Ye=()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('device.write'));function Xe(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Z.useShellStore.getState().events.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,ie.isUuid)(t.id)&&!!(Z.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Oe.getState().kind&&('device'!==Oe.getState().kind||Ce('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,ie.isUuid)(e.undoes)&&(ze(e.undoes)||j.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Ge.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)=>Z.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Z.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function et(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Z.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={...Z.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Z.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Ge]}}}))},afterRead:()=>{Z.useShellStore.getState().server[e]||Z.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Ge]}}}))},subscribe:()=>()=>{}}}const tt=new Set;function at(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=H.useStore.getState().menu;return Y.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:t=>(0,ie.isUuid)(t.card.id)&&!((0,h.isAnchorage)(e)&&(0,h.isDemoCard)(t.card))&&!(0,h.isPlaceholderCard)(t.card),writable:()=>Ce('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,h.isAnchorage)(e)&&(s={...s,signOff:(0,h.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,h.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,h.isAnchorage)(e)&&(0,h.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,be.photoPath)(a,s),t=st(s.photo);t&&((0,Y.cachePhotoAs)(e,t),nt(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,be.cardToRow)(s,a);return{...i,...r,doc:Be({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,h.isPlaceholderCard)(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,signOff:(0,h.isAnchorage)(e)&&(0,h.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!Ce('recipes.edit')&&t.length){const e=new Set(t);Y.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);Y.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&H.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&H.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=Y.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=H.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const st=e=>(0,Y.readLocalPhoto)(e);async function nt(e,t){if(!tt.has(e)){tt.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(be.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){tt.delete(e),Ae({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const it=new Map,rt=(0,U.create)(()=>({n:0}));(0,Y.setStoragePhotoResolver)(e=>{const t=it.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,T.isSupabaseConfigured)()&&'off'!==Oe.getState().mode?(t||(it.set(e,{url:'',at:Date.now()}),Re().storage.from(be.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(it.set(e,{url:t.signedUrl,at:Date.now()}),rt.setState(e=>({n:e.n+1})),Y.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const ot=new Map;const dt=(e,t)=>{const a=(0,ie.isUuid)(t)?t:(0,be.uuidFrom)(`sup:${e}:${t}`);return ot.set(a,t),a};function ut(e){return{name:'order_sheets',table:'suppliers',list:()=>X.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,h.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>Ce('suppliers.manage'),toRow:(e,t)=>({id:dt(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:Be(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(ot.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>X.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>X.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,ie.isUuid)(e)?e:(0,be.uuidFrom)(`sup:${Oe.getState().venueId}:${e}`)})}}let ct=!1,lt=!1;const ft=new Map,pt=new Map,gt=new Map,mt=new Map,_t=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',St=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'},ht=(e,t)=>({...e,managerAccess:t}),yt=()=>({nickname:ct,display:lt}),wt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=ht({role:e.role,level:e.level??St(_t(e)).level},!0===e.managerAccess);return(0,B.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},yt())};const vt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},bt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},kt=e=>{const t=ne.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,d.isKitchenTeam)(t)},It=2e3;function Rt(e,t){return t||!e.length||e.length>=It?null:e=>(0,ie.isUuid)(e.id)}function Ot(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,Ce('rota.manage')):null,keepOnEmpty:()=>e&&!Ce('rota.manage'),list:()=>ne.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&ft.has(e.staffId)&&(Ce('rota.manage')||kt(e.staffId)),writable:()=>Ce('rota.manage')||Ce('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(vt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:bt(e.start),end_time:bt(e.end),published:!!e.published,doc:Be(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function At(){const e=xe(62),t=e=>Ce('rota.manage')||e.staffId===Oe.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ne.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&t(e),writable:()=>'staff'===Oe.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=xe(2)&&e.staffId===Oe.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:Be(e.breaks??[]),break_mins:e.breakMins??0,doc:Be((0,y.privateAttendance)(o.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,y.privateAttendance)(o.VENUE_RID,{...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Ct(){const e=xe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&e.staffId===Oe.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Oe.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:ft.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,ie.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:Be({...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)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Dt(e){ne.leaveRemote.decide=t=>!(!Ce('rota.manage')||!(0,ie.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(j.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Ke.push(()=>{ne.leaveRemote.decide=null})}function Ut(e){ne.timesheetRemote.send=(t,a)=>{if(!Ce('rota.manage')||!(0,ie.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return j.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:Be(s)}}),!0}const s=a;if('attendance_void'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return j.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return j.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:Be(s.breaks??[]),p_reason:n,p_doc:Be((0,y.privateAttendance)(o.VENUE_RID,s))}}),!0},Ke.push(()=>{ne.timesheetRemote.send=null})}function Et(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>H.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Oe.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,ie.isUuid)(a)?a:(0,be.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,ie.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:Be(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>H.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=>H.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Tt=e=>H.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Nt(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}));H.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Kt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=H.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[Be({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Tt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>Ce('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...Mt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...Mt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...Mt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Pt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Pt=t.feature_flags??{},Mt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),Be({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}:{}})},apply:t=>{const a=t[0];a&&(H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,l.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Nt(e,a.events))},subscribe:e=>{const t=H.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Pt=null,Mt=null;const xt=()=>new Date(Date.now()-2592e6).toISOString(),qt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>ft.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Lt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?(0,Se.dmId)(t[0],t[1]):null},Bt=()=>Oe.getState().perms.includes('*');function jt(){const e=()=>Oe.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ne.useOwner.getState().chat.filter(e=>(0,ie.isUuid)(e.id)).map(e=>Be({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=>!!qt(t.ch)&&(t.from===e()||Bt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('created_at',xt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=xt(),toRow:(e,t)=>{const a=qt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:ft.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=Lt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?pt.get(String(e.from_staff)):'system';return s?Be({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ne.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?pt.get(String(t.from_staff)):'system',i=Lt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ne.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,Se.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,he.soundAllowed)())try{(0,he.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,b.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function Ft(e,t,a){const s=Oe.getState();if(!_e.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=ft.get(e),i='*'===t?'*':qt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function $t(e){const t=Oe.getState().staffRef,a=t?ft.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Lt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ne.useOwner.getState().chatMarkRead(t,i)}catch{}}function Wt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=C.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:Be(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>C.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,D.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Qt(e){const t=xe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>C.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.reminderId)&&e.staffRef===Oe.getState().staffRef,writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>C.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>C.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Ht(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Vt=e=>null==e||''===e?null:Number(e),Gt=e=>e.filter(e=>!e.startsWith('data:')),Jt=()=>Ce('takings.view');function zt(e){const t=!Jt();return{name:'cash_ups',table:'cash_ups',list:()=>oe.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,v.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,v.tradingDay)()&&!e.onServer),writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,v.tradingDay)()):e.gte('for_date',xe(400)),...t?{inWindow:e=>e.date===(0,v.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:Be(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({cashUps:Ht(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Zt(e){return{name:'sales_reports',table:'sales_reports',list:()=>oe.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>Ce('wages.manage')||(0,w.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:Be(e.vals),categories:e.categories,photos:Gt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>oe.useCashUp.setState(s=>({sales:Ht(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Yt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=oe.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,oe.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:Be({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,oe.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>oe.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function Xt(e){return{name:'day_tips',table:'day_tips',list:()=>oe.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',xe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>oe.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ea(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>oe.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Vt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>oe.useCashUp.setState(s=>({pot:Ht(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function ta(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=oe.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>Ce('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>oe.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>oe.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function aa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>re.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:Be(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>re.useNotifs.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>re.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function sa(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=de.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,ie.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:Be(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:Be(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>de.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ue.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Ht(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function na(e){const t=()=>Ce('venue.settings')||Ce('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>de.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,ie.isUuid)(a.id)&&(0,ie.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,de.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Oe.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Oe.getState().staffRef)||null,doc:Be(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({items:Ht(s.items,t,a,t=>t.rid===e)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ia(e){const t=xe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>de.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('venue.settings')||Ce('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:Be(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>de.useOrderLists.setState(s=>({history:Ht(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>de.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function ra(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=ce.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:Be(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>Ce('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&ce.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,y.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>ce.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function oa(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=ge.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,ge.libraryRowId)(e),kind:'library',doc:Be({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,ge.personRowId)(e,i),kind:'person',staffRef:i,doc:Be({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ne.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,me.canEditTasks)(t,a)},writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>ge.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,ge.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function da(e){const t=xe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>ge.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Oe.getState();return e.byRef===t.staffRef||Ce('staff.manage')},writable:()=>'staff'===Oe.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>ge.useDailyTasks.setState(s=>({ticks:Ht(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>ge.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ua(e,t=!1){const a=xe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>ye.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind||Ce('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,be.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>ye.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>ye.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{we.autoSync.soldOutRead.add(e)}}}function ca(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>we.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:(0,be.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>we.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>we.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{we.autoSync.linksRead.add(e)}}}async function la(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&x.kv.get(a,!1):(x.kv.set(a,!0),!0)}catch{return x.kv.get(a,!1)}}async function fa(){const e=Oe.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();ma.setState({live:!!t?.push_live,known:!0})}catch{}}const pa='order-list-logos';const ga=new Map;const ma=(0,U.create)(()=>({live:!1,known:!1}));async function _a(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('reminders:ok',!1):(x.kv.set('reminders:ok',!0),!0)}catch{return x.kv.get('reminders:ok',!1)}}async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&x.kv.get('chat:ok',!1):(x.kv.set('chat:ok',!0),!0)}catch{return x.kv.get('chat:ok',!1)}}const ha=(e,t)=>Be({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),ya='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function wa(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>A.useHr.getState().questions.filter(t=>t.venue===e&&(0,ie.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ha(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);A.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>A.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function va(e,t){const a=(t,a,s)=>{j.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(A.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(ya).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||A.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ha(e,t)))}catch{}}}),Ke.push(()=>{Object.assign(A.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ba='pair:v1',ka='staff:v1',Ia='staff:rejoin:v1';async function Ra(e){const t=o.IS_QUEUED_VENUE?'claim_'+o.VENUE_RID+'_invite':o.IS_GREENSIDE?'claim_greenside_invite':o.IS_ABBOTSFORD?'claim_abbotsford_invite':o.IS_KIRKTON?'claim_kirkton_invite':o.IS_WILDINGS?'claim_wildings_invite':o.IS_KIRKMICHAEL?'claim_kirkmichael_invite':o.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ue,p_device:(0,O.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,O.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Oa(){if('display'===Ue||'customer'===Ue||le.PITCH)return'none';const e=await x.kv.get(Ia,null);if(!e)return'none';try{await Ca();const{data:t,error:a}=await Ra(e);if(a)return(0,I.inviteRefusal)(a.message)?(await x.kv.remove(Ia),await x.kv.remove(ka),'refused'):'offline';const s=t?.[0];return s?(await x.kv.set(ka,{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,displayName:s.display_name}),'ok'):(await x.kv.remove(Ia),'refused')}catch{return'offline'}}const Aa=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Ca(){Te();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ae({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 Da(e){if(le.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,I.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,T.isSupabaseConfigured)())return{status:'off'};try{await Ca();const{data:t,error:a}=await Ra(e);if(a){const e=(0,I.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,o.venueKey)(`cc-pending-invite:${Ue}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await x.kv.set(ka,n),await x.kv.set(Ia,e),Pe&&xa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ae({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ua='car:request:v1',Ea=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Ta(){await x.kv.remove(ba),await x.kv.remove(ka),await x.kv.remove(Ua),O.useSession.getState().meId&&O.useSession.getState().signOut()}async function Na(){if(!(0,T.isSupabaseConfigured)())return!1;try{return await Ca(),!0}catch{return!1}}const Ka=async(e,t={})=>{if(le.PITCH)return(0,fe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Pa=null;async function Ma(){for(const e of Ke)try{e()}catch{}Ke=[],Ne.forEach(e=>e.stop()),Ne=[],Pa&&(clearInterval(Pa),Pa=null)}async function xa(){await Ma(),await Ba()}async function qa(){if(!(0,T.isSupabaseConfigured)()||'customer'===Ue||le.PITCH)return!1;try{Te();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ue)return!1;if(!await x.kv.get(Ia,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Oa()&&(xa(),!0)}catch{return!1}}(0,u.setSessionMender)(qa);let La=o.VENUE_RID;async function Ba(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=La;try{if(Ae({mode:'connecting'}),await j.mutationQueue.load(),'customer'===Ue)return void await Ha(e);let t=await x.kv.get(ba,null),a=await x.kv.get(ka,null);if(V.IS_CAR&&!t&&a){const e=(0,G.migrateCarStaffIdentity)(a);e&&(t=e,await x.kv.set(ba,t)),await x.kv.remove(ka),a=null,O.useSession.getState().meId&&O.useSession.getState().signOut()}if(o.IS_ISOLATED_VENUE&&(t&&!(0,o.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,o.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ae({mode:'display'===Ue?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ue&&!V.IS_CAR&&a&&!s.session){const t=await Oa();if('offline'===t)return Ae({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{La===e&&xa()},6e4);'refused'===t&&a.staffRef&&O.useSession.getState().meId===a.staffRef&&O.useSession.getState().signOut(),a=await x.kv.get(ka,null),({data:s}=await Re().auth.getSession())}const n='display'===Ue||V.IS_CAR?t:a;if(!s.session||!n)return void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Ka('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ue||V.IS_CAR?await x.kv.remove(ba):(await x.kv.remove(ka),await x.kv.remove(Ia)),'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId===n.staffRef&&O.useSession.getState().signOut(),void Ae({mode:'display'===Ue||V.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ue?'This display was unpaired by a manager.':V.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,N.isOnline)()||/fetch|network/i.test(String(t?.message)))Ae({mode:'offline'});else if(Aa(t)&&'display'!==Ue){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Oa()&&setTimeout(()=>{La===e&&xa()},500)}i=Oe.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ae({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!V.IS_CAR&&'staff'===n.kind&&n.staffRef&&O.useSession.getState().meId!==n.staffRef&&(O.useSession.getState().signIn(n.staffRef),ne.useOwner.setState({staffAs:n.staffRef})),V.IS_CAR&&(O.useSession.getState().meId&&O.useSession.getState().signOut(),ne.useOwner.setState({previewRole:'owner'})),await Fa(n.venueId,e,n.kind)}catch(e){Ae({mode:'local',lastError:String(e?.message??e)})}}const ja=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','venue_reminders','reminder_done']);async function Fa(e,a,s){if(!(0,o.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||V.IS_CAR&&'device'===s;await _s(a),Ke.push(Us(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])gt.set(e.key,e.id),mt.set(e.id,e.key)}catch{}const i=[Kt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ne.useOwner.getState().staff.map(wt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>Ce('staff.manage'),deletes:!1,revision:e=>(0,B.staffRevision)(e,yt()),toRow:(e,t)=>(0,B.staffRow)(e,t,yt(),e.managerAccess||e.ownerAccess?null:gt.get(_t(e))),fromRow:e=>{if(!e.external_ref)return null;ft.set(String(e.external_ref),String(e.id)),pt.set(String(e.id),String(e.external_ref)),Os.set(String(e.external_ref),e.avatar_path??null);const t=ht(St(mt.get(String(e.role_id))),!0===e.manager_access);return(0,B.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},yt())},apply:e=>ne.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=>ne.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ds()},onRemote:()=>{Ds()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ne.useOwner.getState(),t=te.useSetup.getState().sites[La]?.staffGrade??{};return e.staff.filter(e=>ft.has(e.id)).map(a=>Be({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=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:ft.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=pt.get(String(e.staff_id));return t?Be({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=>ne.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=te.useSetup.getState().sites[La],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&&te.useSetup.getState().patch(La,{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=ne.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=te.useSetup.subscribe((t,a)=>{t.sites[La]?.staffGrade!==a.sites[La]?.staffGrade&&e()});return()=>{t(),a()}}},je(a,!1),je(a,!0),$e(a),He(a),Fe(a),Ve(a),Xe(a),et(a),ut(a),{name:'supplier_directory',table:'suppliers',list:()=>ne.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,ie.isUuid)(e.id),writable:()=>Ce('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:Be(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ne.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId),writable:()=>Ce('suppliers.order')||Ce('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||Me(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:Be(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},at(a),ks(a)];Ce('wages.view')&&i.push(Is(a)),n&&(i.push(Ot(!0),At(),Ct(),Et(a)),Ut(e)),n&&await la('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ne.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,ie.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Oe.getState().staffRef&&'pending'===e.status||Ce('rota.manage')),writable:()=>'staff'===Oe.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:Be(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ne.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ne.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),ja.add('staff_leave'),Dt(e));const d=n&&await Sa();if(_e.useChatSync.setState({synced:d,checked:!0}),Ke.push(()=>_e.useChatSync.setState({synced:!1})),d&&i.push(jt(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(Se.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>pt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>ft.has(e.id),writable:()=>Ce('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:ft.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:ft.get(e.id),include:e.include}),fromRow:e=>{const t=pt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>Se.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=>Se.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await la('hr_questions')&&(i.push(wa(a)),ja.add('hr_questions'),va(e,a)),'guest'!==s&&'customer'!==Ue&&await la('temp_readings')&&(i.push((0,W.tempUnitsSpec)(se.useSafety,Ze),(0,W.tempReadingsSpec)(se.useSafety,Ye)),ja.add('temp_units'),ja.add('temp_readings')),'guest'!==s&&await la('sold_out_items')?(i.push(ua(a,await la('sold_out_items','auto'))),ja.add('sold_out_items')):we.autoSync.soldOutRead.add(a),'guest'!==s&&await la('sold_out_links')?(i.push(ca(a)),ja.add('sold_out_links')):we.autoSync.linksRead.add(a),C.useReminders.getState().ensure(a),'guest'!==s&&await _a()&&(i.push(Wt(a)),n&&i.push(Qt(a))),re.useNotifs.getState().ensure(a),de.useOrderLists.getState().ensure(a),n){ct=await la('staff','nickname'),lt=await la('staff','display_clock');const[e,t,s,n]=await Promise.all([la('scheduled_notifications'),la('order_lists'),la('venue_clock_area'),la('daily_tasks')]);ge.useDailyTasks.getState().ensure(a),n&&(i.push(oa(a),da(a)),ja.add('daily_tasks'),ja.add('daily_task_ticks')),e&&(i.push(aa(a)),fa()),t&&i.push(sa(a),na(a),ia(a)),s&&i.push(ra(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&ja.add(n)}if('guest'!==s&&await la('day_tips')){i.push(Xt(a));for(const e of['day_tips','tips_pot_events','tips_settings'])ja.add(e);await la('tips_pot_events')&&i.push(ea(a),ta(a)),n&&(Jt()||(0,oe.forgetPastTakings)(a,(0,v.tradingDay)()),i.push(zt(a),Yt(a)),ja.add('cash_ups'),Jt()&&(i.push(Zt(a)),ja.add('sales_reports')),t(r[72])(r[71],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(Ot(),At()),await la('scheduled_notifications')&&i.push(aa(a)));let u=!1;const c=()=>{if(V.IS_CAR&&n&&Ce('recipes.edit'))return!0;const e=ne.useOwner.getState().staff.find(e=>e.id===Oe.getState().staffRef);return!!e&&e.active&&Ce('recipes.edit')&&(0,_.costsAllowedFor)(e)};n&&c()&&await la('ingredient_prices')&&(i.push((0,m.gpSyncSpec)('ing',c)),ja.add('ingredient_prices'),await la('card_costs')&&(i.push((0,m.gpSyncSpec)('card',c)),ja.add('card_costs')),await la('kitchen_deliveries')&&(i.push((0,m.gpSyncSpec)('del',c)),ja.add('kitchen_deliveries')),await la('kitchen_stock_counts')&&(i.push((0,m.gpSyncSpec)('count',c)),ja.add('kitchen_stock_counts'))),(0,Ie.specialsSyncOn)()&&'guest'!==s&&await la('specials_boards')&&(i.push((0,Ie.specialsBoardSpec)(a,()=>Ce('recipes.edit')||Ce('floor.manage')||Ce('*'))),ja.add('specials_boards'));const l={onActivity:()=>Ae({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ae({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ae({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Ka('whoami')??[]).some(t=>t.venue_id===e))return void(La===a&&xa());for(const a of Ne){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||F.useBookingSaves.getState().mark({id:t,table:e,why:ts()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||$.useTempSaves.getState().mark({id:t,table:e,why:cs(e)??'this screen could not send it'})}};Ne=i.map(t=>new Q.EntityBridge(t,e,l)),await Promise.all(Ne.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,N.isOnline)())try{const t=await Ka('whoami');if(!t?.some(t=>t.venue_id===e))return void(La===a&&xa())}catch(e){if(Aa(e)){if(V.IS_CAR)return void(La===a&&xa());const e=await Oa();return void('ok'!==e&&'refused'!==e||La===a&&xa())}}let t=0;for(const[a,s]of Ne.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(_e.useChatSync.getState().error&&_e.useChatSync.setState({error:void 0}),await $t(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&_e.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({mode:'live',lastSyncAt:e,lastServerAt:e}),j.mutationQueue.flush()}else Ae({mode:'offline'});if(!Ce('wages.view')){const e=Oe.getState().staffRef;ne.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const S=new Map;for(const e of Ne)S.set(e.spec.table,[...S.get(e.spec.table)??[],e]);const h=[...S.keys()].filter(e=>ja.has(e)).map(e=>({table:e,venueColumn:S.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,Q.venueChannel)(e,h,(e,t,a)=>{for(const s of S.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ae({lastSyncAt:s,lastServerAt:s})},e=>{Ae({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Ke.push(()=>{Re().removeChannel(w)}),Ke.push((0,N.onConnectivity)(e=>{e&&p()}));const b=Ne.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,K.superviseSync)({fastMs:Wa(Ue),readFast:async()=>{for(const e of b)await e.read()},readAll:p,flush:()=>{j.mutationQueue.flush()},wake:()=>{j.mutationQueue.retryNow()},restart:()=>{La===a&&xa()},realtime:()=>Oe.getState().realtime,lastServerAt:()=>{const e=Oe.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,N.setOnline)(!0),Ae({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Aa,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>$a(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Ke.push(k.stop)}async function $a(e){const t=Oe.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Ka('sync_heartbeat',{p_venue:e,p_device:(0,O.deviceId)()??'unknown',p_app:Ue,p_version:M.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Wa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Oe.getState(),queue:j.mutationQueue.pending.map(e=>e.table),failedTables:j.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),le.PITCH&&(window.__ccSyncPreview=e=>Ae(e)));const Qa='guest:sent:v1';async function Ha(e){Ae({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Ka('public_venue',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!o.IS_ISOLATED_VENUE||t.id===o.VENUE_UUID)){Ae({venueId:t.id,venueName:t.name}),await _s(e);const a=t.app?.restaurant;a&&H.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,l.withWildingsAddress)({...a,id:e}):t)})),Nt(e,t.app?.events)}await Va(e),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ae({mode:(0,N.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Va(e).catch(()=>{})},6e4);Ke.push(()=>clearInterval(t)),o.IS_ISOLATED_VENUE||await Ga(e)}async function Va(e){const t=await Ka('public_menu',{p_venue_slug:(0,c.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));Y.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&H.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))]}})}async function Ga(e){let t=await x.kv.get(Qa,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=H.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,ie.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Na())return;for(const a of n)try{const s=(await Ka('guest_create_booking',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_booking:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(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&&H.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'},Ae({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{await Ka('guest_create_takeaway',{p_venue_slug:(0,c.queuedDatabaseSlug)(e),p_order:{...Be(a),...(0,k.takeGuard)(a.id),allergies:Le(a.allergies)}}),t={...t,[a.id]:'order'}}catch(e){/fetch|network/i.test(String(e?.message))||(t={...t,[a.id]:'failed'},Ae({lastError:`Order: ${e?.message}`}))}await x.kv.set(Qa,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Ka('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await x.kv.set(Qa,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Ka('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));H.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 Ja(n)===Ja(e)?e:n})})),Ae({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ae({mode:(0,N.isOnline)()?Oe.getState().mode:'offline'})}finally{a=!1}}};Ke.push(H.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Pa=setInterval(()=>{n()},15e3),n()}const Ja=e=>JSON.stringify([e.status,e.readyBy,e.accepted]),za={bridges:()=>Ne,restart:xa};function Za(){const e=Oe.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!Ce('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function Ya(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(!e||Za())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(j.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function Xa(){const e=Ne.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}Ya();try{await j.mutationQueue.retryNow()}catch{}}Oe.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{Xa()},3e3)});const es=['bookings','walk_ins'];function ts(){const e=Oe.getState();return De()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const as=()=>Ne.filter(e=>es.includes(e.spec.table)),ss=e=>j.mutationQueue.failed.some(t=>es.includes(t.table)&&t.rowKey===e);function ns(e=!1){return ts()?0:as().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&ss(t)&&!!F.useBookingSaves.getState().notSaved[t]),0)}async function is(e=!1){const t=ts();if(t)return t;for(const e of as())try{await e.read()}catch{}ns(e);try{await j.mutationQueue.retryNow()}catch{}return e&&rs(),null}function rs(){const e=as()[0]?.venueId??'',t=F.useBookingSaves.getState(),a=new Set(as().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||ss(s)||es.some(t=>j.mutationQueue.hasPending(t,e,s))||t.clear(s)}j.mutationQueue.onFailed(e=>{es.includes(e.table)&&F.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{es.includes(e.table)&&F.useBookingSaves.getState().clear(e.rowKey)});let os=null;const ds=(e=2500)=>{os&&clearTimeout(os),os=setTimeout(()=>{os=null,is(!1)},e)};(0,N.onConnectivity)(e=>{e&&ds()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&ds(3e3)});const us=['temp_readings','temp_units'];function cs(e="temp_readings"){const t=Oe.getState();return De()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ze()?'device'!==t.kind||Ce('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ls=()=>Ne.filter(e=>us.includes(e.spec.table));async function fs(e=!1){const t=cs();if(t)return t;for(const e of ls())try{await e.read()}catch{}const a=ls()[0]?.venueId??'';for(const t of ls())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,j.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await j.mutationQueue.retryNow()}catch{}if(e){const e=$.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ls().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||j.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,$.tempKey)(t.table,t.id))}}return null}j.mutationQueue.onFailed(e=>{us.includes(e.table)&&$.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,L.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),j.mutationQueue.onDone(e=>{us.includes(e.table)&&$.useTempSaves.getState().clear((0,$.tempKey)(e.table,e.rowKey))});let ps=null;const gs=(e=3e3)=>{ps&&clearTimeout(ps),ps=setTimeout(()=>{ps=null,fs(!1)},e)};(0,N.onConnectivity)(e=>{e&&gs()}),Oe.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&Ce('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&gs(3500)});const ms='golive:v1:';async function _s(e){'live'!==H.useStore.getState().clock.mode&&H.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)?await vs(e):(await x.kv.get(ms+e,!1)||await vs(e),await x.kv.get(ys+e,!1)||(ws(e),await x.kv.set(ys+e,!0)),await x.kv.get(Ss+e,!1)||(hs(),await x.kv.set(Ss+e,!0)))}const Ss='golive:v3:';function hs(){const e=e=>JSON.stringify(e).includes('(example)');try{ae.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ys='golive:v2:';function ws(e){const t=e=>JSON.stringify(e).includes('(example)');H.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)))})),ne.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 vs(e){if(f.LIVE_VENUE_BUILD&&(0,f.isLiveVenue)(e)){const t=(0,p.stripCoreLiveSamples)(H.useStore.getState()),a=(0,ae.stripKitchenExamples)(ae.useKitchen.getState()),s=ne.useOwner.getState(),n=(0,p.stripOwnerLiveSamples)(s),i={accidents:se.useSafety.getState().accidents.filter(e=>!(0,se.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(H.useStore.getState(),t)&&(await(0,g.archiveChefCache)('core',H.useStore.getState()),H.useStore.setState(t)),r(ae.useKitchen.getState(),a)&&(await(0,g.archiveChefCache)('kitchen',ae.useKitchen.getState()),ae.useKitchen.setState(a)),r(s,n)&&(await(0,g.archiveChefCache)('owner',s),ne.useOwner.setState(n)),r(se.useSafety.getState(),i)&&(await(0,g.archiveChefCache)('safety',se.useSafety.getState()),se.useSafety.setState(i));const o=(0,A.stripHrSamples)(A.useHr.getState());r(A.useHr.getState(),o)&&(await(0,g.archiveChefCache)('hr',A.useHr.getState()),A.useHr.setState(o));const d=(0,m.stripGpSamples)(m.useGpCalc.getState());r(m.useGpCalc.getState(),d)&&(await(0,g.archiveChefCache)('gp',m.useGpCalc.getState()),m.useGpCalc.setState(d));const u=X.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,g.archiveChefCache)('order-sheets',u),X.useOrderSheets.setState(c));const l=Y.useCardStore.getState(),_={cards:l.cards.filter(e=>!(0,f.isLiveVenue)(e.restaurantId)||!(0,h.isDemoCard)(e)),log:l.log.filter(e=>!(0,h.demoActor)(e.by))};return r(l,_)&&(await(0,g.archiveChefCache)('recipe-cards',l),Y.useCardStore.setState(_)),void await x.kv.set(ms+e,!0)}const t=t=>t.restaurantId===e&&!(0,ie.isUuid)(t.id);H.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)))})),J.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,ie.isUuid)(t.id))})),z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ne.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,ie.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,ie.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,ie.isUuid)(e.id)),leave:e.leave.filter(e=>(0,ie.isUuid)(e.id)),swaps:[]}));try{ae.useKitchen.setState(e=>(0,ae.stripKitchenExamples)(e))}catch{}ne.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,ie.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,ie.isUuid)(e.id)&&(0,ie.isUuid)(e.supplierId))}));try{se.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await x.kv.set(ms+e,!0)}const bs=(e,t)=>Be({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function ks(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(z.useFloor.getState().live[e]??{}).map(([e,t])=>bs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Oe.getState().kind||Ce('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:(0,G.actorStamp)({isCar:V.IS_CAR,kind:Oe.getState().kind,staffRef:Oe.getState().staffRef,fallback:Ue})}),fromRow:e=>bs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>z.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=>z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Is(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(te.useSetup.getState().sites[e]?.grades??te.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:()=>Ce('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=te.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));te.useSetup.getState().patch(e,{grades:i})},subscribe:t=>te.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Rs='staff-avatars',Os=new Map;let As=!1;const Cs=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ds(){if(!As){As=!0;try{for(const[e,t]of Os){const a=ee.useAvatars.getState().photos[e];if(!t){a?.path&&ee.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Oe.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Rs).download(t);if(n||!s)continue;const i=await Cs(s);i.startsWith('data:image/')&&ee.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{As=!1}}}function Us(e){const t=async()=>{const t=Oe.getState().staffRef,a=t?ft.get(t)??Oe.getState().staffUuid:void 0;if(!t||!a||'staff'!==Oe.getState().kind)return;const s=ee.useAvatars.getState().photos[t];try{const n=Os.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Rs).remove([t]).catch(()=>{})};if(!s){const e=!!ee.useAvatars.getState().clears?.[t];return e&&n&&(await Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}),Os.set(t,null),i(n)),void(e&&ee.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ae({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Rs).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Ka('set_staff_avatar',{p_staff_ref:t,p_path:d}),Os.set(t,d),n!==d&&i(n),ee.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ae({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:ee.useAvatars.getState().photos},s=ee.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),Ce('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Oe.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Os.set(t,null),ee.useAvatars.getState().doneClear(t),Ka('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Rs).remove([e])).catch(()=>{})}});return t(),s}const Es=new Map,Ts=(0,U.create)(()=>({n:0}))},987,[5,988,932,6,832,837,833,838,989,993,994,835,996,998,999,1000,1001,1002,13,1003,1005,1008,1009,846,933,976,1010,1011,1012,1015,977,1016,1014,1019,1013,1020,1021,1022,1023,831,872,1024,1025,1028,983,883,1030,926,927,1032,1033,891,870,1035,1038,1039,1040,1041,2,1042,1043,1044,1045,1046,1047,979,981,884,863,859,1048,1051,1052]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},989,[837,34,838,5,839,846,849,990,863,870,991,992]); -__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},990,[984]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},991,[990]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},992,[990,991]); -__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},993,[]); -__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},994,[835,837,838,5,839,846,849,995,831,884]); -__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'}}]},995,[]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},996,[6,997]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},997,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},998,[846]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},999,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1000,[846]); -__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1001,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1002,[]); -__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1003,[839,846,849,5,872,1004,15,1002]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1004,[]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1005,[838,835,837,5,839,846,849,1006,870]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1007,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1008,[839,846,849,863,1009,870]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1009,[]); -__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)))},1010,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1011,[]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1012,[34,1013]); -__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1013,[1010,977,1014]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1014,[1010]); -__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.3.12.171'},1015,[]); -__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1016,[1017,1018,933,977,1013]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1018,[977]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1019,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1020,[846,849,839]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1021,[846,849,839]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1022,[1023]); -__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1023,[1017,933,1010,977,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1024,[]); -__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1025,[860,839,870,846,849,858,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1026,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1027,[891,1003,1026]); -__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1028,[5,860,839,1029,846,849,859]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1029,[1007]); -__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1030,[837,838,5,839,846,849,1031]); -__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1031,[984]); -__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1032,[837,984,838,835,5,839,846,849]); -__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1033,[837,838,5,839,846,849,1034]); -__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1034,[]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1035,[839,846,849,863,1036,15,870,1037]); -__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1036,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1037,[]); -__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1038,[34,839,846,849,863,13,870]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1039,[839,846,849,863,1040,870,1037]); -__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1040,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1041,[5,996,839,846,849,997]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1042,[1038]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1043,[839,846,849,863,1044,870]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1044,[]); -__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},1045,[846]); -__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(':')}`},1046,[839,846,849]); -__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{}}},1047,[236,872]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1048,[994,1049,1050,976,933]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1049,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1050,[]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1051,[933,987,998]); -__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1052,[1053]); -__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1053,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1054,[34]); -__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1055,[34,236,402,102,846,821,794,1054,25]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1056,[34,102,794,1057,821,1058,25]); -__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1057,[827,34,379,236,402,102,821,987,1058,2,872,1015,5,796,797,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1058,[1059,933,987,872,236]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1059,[]); -__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1060,[827,796,34,402,102,794,821,1043,1044,1009,1000,870,891,25]); -__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1061,[828,1062,796,827,34,281,283,364,336,402,102,426,794,821,1038,831,13,1063,1064,1000,1074,1079,1080,1083,1084,1085,1092,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1062,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1063,[]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1064,[34,876,1065,1066,1063]); -__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1065,[839,846,849]); -__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1066,[6,1067,1068,1069,1070,1071,1072,1073,3]); -__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1067,[]); -__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1068,[]); -__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1069,[]); -__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1070,[]); -__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1071,[]); -__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1072,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1073,[1063]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1074,[236,933,987,1075]); -__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})},1075,[499,1076,1078,1077]); -__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1076,[499,1077,1078]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1077,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1078,[1077]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1079,[933,987]); -__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1080,[34,281,236,102,794,1038,13,1081,821,1082,25]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1081,[13]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1082,[]); -__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1083,[827,2,34,102,794,821,1038,891,13,987,1000,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1084,[13]); -__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1085,[34,1062,281,402,102,794,1086,1087,1091,1092,821,25]); -__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1086,[34,402,102,794,821,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1087,[837,34,874,891,858,872,1024,987,1088,1003,15,1090]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1088,[1089]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1089,[1090]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1090,[858]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1091,[34,872,1092,858,987,933]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1092,[]); -__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1093,[34,1094,891,1008,1009,1000,1046,831,1097]); -__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1094,[996,1041,891,997,1095,1096]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1095,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1096,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1097,[]); -__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1098,[34,986,402,102,1099,794,874,1100,858,1101,821,25]); -__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)'}})]})}},1099,[34,281,283,364,102,1047,821,25]); -__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1100,[861,859]); -__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1101,[34,402,102,794,1100,858,821,25]); -__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1102,[34,102,794,874,877,821,25]); -__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1103,[860,34,102,794,874,1025,1028,1104,1105,877,821,25]); -__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1104,[1028,859,1100]); -__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1105,[860,877]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1106,[860,34,102,794,874,983,891,1100,858,821,25]); -__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1107,[828,827,1055,34,336,379,236,402,102,794,821,1039,1040,1000,1108,1109,987,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1108,[1075,236]); -__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1109,[839,846,849]); -__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1110,[827,996,34,379,402,102,794,821,1035,1036,891,1039,1040,1041,997,1095,987,1058,1000,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1111,[34,1035,891,1039,1112,1008,831,1036,1000,1093]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1112,[846]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1113,[996,34,1041,891,831,997,1009,1095,1000,1094]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1114,[860,34,1000,874,1100,1047]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1115,[860,1116,34,102,794,874,1100,821,1117,1106,1118,1139,1142,1098,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1116,[34,102,14,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1117,[821]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1118,[34,102,1119,821,1120,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1119,[860,1104]); -__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1120,[1121,860,34,1122,987,1124,402,102,874,1028,1119,1123,821,858,794,1125,1025,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1121,[34,859,821,794,25]); -__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1122,[34,402,102,874,1123,1124,987,1020,821,1120,794,25]); -__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1123,[860,1104]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1124,[281,236]); -__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1125,[827,1126,1127,860,867,14,1128,1129,34,859,402,102,872,1087,874,1130,1104,858,821,864,794,1028,1025,1131,1132,1137,1106,1100,1138,1123,1122,25]); -__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1126,[34,402,412,102,1127,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1127,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1128,[34,102,794,25]); -__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1129,[34,236,402,295,102,426,821,794,1000,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1130,[878,858,877]); -__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1131,[34,402,102,878,858,821,794,25]); -__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1132,[860,877,34,102,879,1133,1134,1136,794,874,1028,983,861,867,872,1100,821,25]); -__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1133,[34,402,821,794,25]); -__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1134,[828,860,1135,34,281,236,102,1028,1104,821,794,1106,859,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1136,[34,402,102,874,861,863,821,794,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1137,[1127,1119,1123]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1138,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1139,[1140,34,102,874,1028,1123,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1140,[34,102,874,1028,1119,1141,1123,821,1003,891,872,794,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1141,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1142,[34,1062,1126,102,874,1028,1025,876,872,1137,861,1003,891,1026,1119,821,858,1131,1116,1128,1143,14,1140,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1143,[34,102,874,872,1137,14,1124,821,794,25]); -__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1144,[34,102,794,1062,1092,1145,1091,1085,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1145,[]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1146,[34,102,794,827,1033,891,835,1147,821,1148,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1147,[1034]); -__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1148,[34,402,102,1124,987,1149,1021,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1149,[933,976,1010,1018,1013,1016,1150,1151,1152,1153,1154,1155,977]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1150,[1018,933,1016]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1151,[1018,933,976,1013]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1152,[1010,976,1151,1013,1016,1150]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1153,[933,977]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1154,[34,1013]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1155,[933]); -__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1156,[30,34,426,102,846,872,1087,1157,25]); -__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1157,[839,846,849]); -__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()},1158,[1159]); -__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1159,[1160,858,884]); -__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1160,[1161,877,1162,878,858,884,1163]); -__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1161,[858]); -__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'},1162,[]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1163,[858]); -__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1164,[978,34,835,402,102,874,891,1165,1160,794,821,1087,1158,1032,15,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1165,[34,102,794,874,1038,884,1166,831,13,1163,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1166,[34,884]); -__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1167,[34,402,102,794,867,821,1159,1158,1164,1032,25]); -__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1168,[34,402,102,794,874,1160,858,821,1169,1165,1164,25]); -__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1169,[828,34,283,364,236,102,426,797,794,827,821,1170,25]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1170,[]); -__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1171,[827,984,1172,835,860,1173,1174,34,402,295,102,794,874,882,1175,891,993,861,867,1178,858,821,1179,1112,1087,1159,1158,1180,869,1164,1032,925,1181,1003,987,1184,988,1097,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1172,[1158,984]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1173,[827,34,102,794,874,979,891,980,981,982,831,821,25]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1174,[]); -__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1175,[827,796,34,336,402,102,821,794,874,1176,1055,882,861,863,885,1108,1177,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1176,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1177,[]); -__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])},1178,[858]); -__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1179,[928,828,827,837,5,34,1055,336,402,102,794,891,858,821,1087,1024,925,1046,1045,987,1112,1097,25]); -__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1180,[828,34,102,794,876,831,869,821,925,25]); -__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1181,[928,828,34,395,236,402,102,925,794,926,891,1182,927,831,5,1183,987,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1182,[]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1183,[933,976,987,977]); -__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1184,[34,402,102,794,891,988,1097,993,987,1090,858,1124,821,25]); -__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1185,[1172,984,34,379,102,794,891,993,867,821,1087,1164,1032,1186,25]); -__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1186,[827,835,984,34,379,236,402,102,794,1030,983,985,867,1031,821,1164,25]); -__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1187,[984,872,34,986,1188,336,402,102,1189,794,985,983,1030,821,874,1100,858,1124,987,25]); -__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1188,[5,822,823,828,236,826]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1189,[]); -__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1190,[827,1030,1172,984,34,402,102,794,891,867,821,1164,1032,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1191,[]); -__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1192,[827,1193,34,402,102,426,794,891,867,858,821,1194,1087,1064,25]); -__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:d,accent:u,children:a,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:d?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:u??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:u??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,a]});return d?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:d,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const d=e.key===n,u=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.note??String(u)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:d?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(u?2:0,e.a/t*c),backgroundColor:d?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:d?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,d=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',u=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,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1194,[34,402,102,794,821,5,25]); -__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1195,[860,1101,1098,1116,34,102,846,794,874,1100,878,877,858,821,1106,1196,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1196,[34,794,874,1197,25]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1197,[379]); -__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1198,[827,1062,1193,34,1199,236,402,426,102,1201,1202,1203,794,831,891,867,1063,821,930,1211,1194,1087,1064,1204,872,1205,1209,25]); -__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1199,[34,402,102,1200,821,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1200,[34,797,25]); -__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1201,[]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1202,[34,102,794,827,891,867,1201,821,25]); -__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1203,[827,1201,34,402,102,794,925,891,1097,858,821,1194,1087,1204,872,1205,1206,1208,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1204,[1062,1084,1092]); -__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1205,[34,102,794,891,1038,1062,1092,1086,1204,821,872,1203,1085,1087,25]); -__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1206,[1063,1207]); -__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1207,[1063,1201]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1208,[34,102,794,827,1062,1063,1206,1124,821,1209,25]); -__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1209,[1062,34,402,102,794,827,891,1207,1063,1210,1124,821,1198,1087,1201,1206,1064,25]); -__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1210,[]); -__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1211,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1179,1194,1087,1064,1159,987,1038,1061,13,1084,1063,2,25]); -__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1212,[828,891,1213,1193,1005,1006,34,1012,1013,236,402,295,102,794,874,1097,1203,1181,1214,1089,5,1215,1160,867,858,821,1194,1179,1087,925,1041,996,997,1094,1000,1096,1165,1163,1206,1208,1090,25]); -__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1213,[827,34,402,102,794,821,891,831,876,1005,1006,25]); -__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1214,[34,102,794,891,1089,821,1097,25]); -__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1215,[34,402,102,794,891,858,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1216,[34,102,794,891,821,1087,1090,1214,1097,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1217,[34,102,1087,821,794,25]); -__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1218,[827,1062,34,402,102,794,1033,821,930,25]); -__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1219,[827,796,1220,1148,835,891,34,336,402,102,794,1033,1034,821,925,930,1221,1224,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1220,[34,1033,891,835]); -__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1221,[828,1062,796,827,1220,835,891,34,336,402,102,797,794,925,1033,1034,1222,821,930,1223,25]); -__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1222,[]); -__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1223,[831,891,5]); -__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1224,[34,1062,379,236,102,794,891,1033,1223,1034,1225,821,930,1220,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1225,[1034]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1226,[]); -__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1227,[860,1057,34,236,402,102,797,874,821,794,1228,1129,1229,25]); -__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1228,[860,34,380,236,402,102,36,821,794,796,1129,874,25,277]); -__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1229,[1230,1231,1233,1232,1234,1047,1235]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1230,[]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1231,[839,5,846,849,872,1047,1232]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1232,[860,236,872,1230]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1233,[34,874,861,869,867,1231,1230]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1234,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1235,[34,1231,987,933]); -__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1236,[34,402,102,426,874,861,821,794,1227,1129,1237,25]); -__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1237,[34,102,426,874,861,1229,1047,821,794,1129,25]); -__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1238,[34,236,402,102,879,794,821,1000,1239,1240,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1239,[872,6,933,976,1000,1229,1240]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1240,[839,1241,846,849]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1241,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1242,[34,872,1239]); -__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1243,[827,796,1220,835,984,34,931,1199,395,236,402,295,102,846,794,861,1034,867,882,1033,821,1164,1158,1185,932,25]); -__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1244,[34,402,346,102,426,821,1200,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1245,[30,34,792,872,25]); -__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1246,[860,1126,877,30,34,1247,1001,102,14,1128,1137,794,861,867,1130,858,874,987,821,1197,864,1025,1028,1104,1132,1100,1248,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1247,[827,34,236,102,25]); -__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1248,[34,402,102,878,858,1062,1249,821,794,796,25]); -__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1249,[1062]); -__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:"ok",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"})]})]})}},1250,[30,34,336,102,1251,1253,794,861,867,874,882,821,25]); -__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1251,[34,1252,102,861,821,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1252,[2,987]); -__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])},1253,[30,34,402,874,821,794,25]); -__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1254,[30,34,794,1255,874,1238,25]); -__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])},1255,[34,402,821,794,25]); -__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1256,[837,30,34,1257,794,867,874,821,1258,1262,25]); -__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:x=!0,onPaid:f,title:g="Pay"}){const y=(0,o.useGiftCards)(b).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,M]=(0,s.useState)(!1),_=y.find(e=>e.code===m),v=_?Math.min(_.balance,p):0,R=p-v;return(0,h.jsxs)(u.Sheet,{visible:e,onClose:j,title:g,children:[(0,h.jsx)(u.DemoPaymentNotice,{}),x&&y.length>0?(0,h.jsxs)(l.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:!m,onPress:()=>w(void 0)}),y.map(e=>(0,h.jsx)(u.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,h.jsx)(u.T,{weight:"semibold",children:"Payment method"}),(0,h.jsx)(u.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,h.jsx)(u.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,h.jsxs)(l.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)})]}),v?(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.ok,children:["\u2212",(0,n.gbp)(v)]})]}):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)})]})]}),T?(0,h.jsx)(t.default,{color:c.colours.gold}):(0,h.jsx)(u.Button,{label:`Pay ${(0,n.gbp)(R)} \u2014 demo`,onPress:()=>{M(!0),setTimeout(()=>{M(!1),f({giftCardCode:m,giftApplied:v,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=r(d[3]),n=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1257,[34,385,102,874,867,821,794,25]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1258,[34,102,794,867,1259,1260,1261,821,25]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1259,[]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1260,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1261,[933,987,1260]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1262,[846,933,976,987,2,1259]); -__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),r=e(_r(_d[4])),o=e(_r(_d[5])),i=e(_r(_d[6])),d=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),b=e(c);_r(_d[10]);var h=e(_r(_d[11])),f=e(_r(_d[12])),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]),w=_r(_d[19]),S=_r(_d[20]),T=_r(_d[21]),I=_r(_d[22]),O=_r(_d[23]),R=_r(_d[24]),A=_r(_d[25]),B=_r(_d[26]),P=_r(_d[27]),C=_r(_d[28]),_=_r(_d[29]),v=_r(_d[30]),N=_r(_d[31]);const $=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let E=!1,M=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,u.useLocalSearchParams)(),d=(0,w.useRestaurant)(e),c=s.IS_QUEUED_VENUE?(0,N.jsx)(t.default,{}):s.IS_ABBOTSFORD?(0,N.jsx)(o.default,{}):s.IS_KIRKTON?(0,N.jsx)(i.default,{}):s.IS_GREENSIDE?(0,N.jsx)(r.default,{}):l.IsolatedCustomerHome&&(s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS)?(0,N.jsx)(l.IsolatedCustomerHome,{}):(0,N.jsx)(K,{});return s.IS_ABBOTSFORD||s.IS_KIRKTON||s.IS_WILDINGS||!d?.settings.hotel?.enabled?c:(0,N.jsx)(n.HotelRequestGate,{rid:e,hotel:d.settings.hotel,children:c})}function K(){const{rid:e}=(0,u.useLocalSearchParams)(),t=(0,w.useRestaurant)(e),l=(0,w.useMenu)(e),s=(0,w.useCustomer)(),n=(0,w.useBasket)(),r=(0,w.useStore)(e=>e.startBasket),o=(0,w.useNow)(3e4),[i,H]=(0,c.useState)('All'),[K,W]=(0,c.useState)(null),[G,F]=(0,c.useState)(!1),[U,Q]=(0,c.useState)(!1),[V,Y]=(0,c.useState)('takeaway'===$?'takeaway':'main');b.default.useEffect(()=>{$&&!E&&(E=!0,'book'===$?setTimeout(()=>u.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,w.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,v.guestServer)();b.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>u.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),b.default.useEffect(()=>{C.START_LOYALTY_CODE&&!M&&(M=!0,setTimeout(()=>u.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,w.useOrderAtTable)(e);if(b.default.useEffect(()=>{te||n.restaurantId!==e||'table'!==n.mode||w.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,n.mode,n.restaurantId,e]),!t)return(0,N.jsx)(x.Screen,{title:"Not found",children:(0,N.jsx)(x.T,{children:"Restaurant not found."})});const le=te&&n.restaurantId===t.id&&'table'===n.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ae=e=>!(e.soldOut||!e.signOff||null===e.price),ne=l.filter(e=>('All'===i||e.section===i)&&('takeaway'!==V||ae(e))),re=(0,k.hoursFor)(t,o),oe=e=>()=>u.router.push(`/customer/${t.id}${e}`),ie=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),le&&r(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>Q(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:oe('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:oe('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:oe('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:oe('/refer')},{icon:'gift',label:'Gift cards',on:oe('/gift')},{icon:'alert',label:'My allergens',sub:s.allergies.length?`${s.allergies.length} declared`:'None declared',on:()=>u.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:s.marketingOptIn[t.id]?'Opted in':'Opt in',on:oe('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:oe('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:oe('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:oe('/feedback')},{icon:'hanger',label:'Lost property',on:oe('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:oe('/merch')}];return(0,N.jsxs)(x.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,N.jsxs)(x.Row,{children:[(0,N.jsx)(m.BasketButton,{}),(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>u.router.push('/customer/profile')})]}),children:[t.fictional?(0,N.jsx)(x.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,le?(0,N.jsx)(x.Banner,{kind:"success",title:`Ordering at ${(0,d.tableNumbers)(n.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,N.jsx)(x.Card,{children:(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(f.default,{style:{flex:1},children:[(0,N.jsx)(x.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,N.jsxs)(x.Muted,{children:[re?`Kitchen today ${(0,k.kitchenHoursOn)(t,o)[0]}\u2013${(0,k.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,N.jsx)(x.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,N.jsx)(x.Row,{wrap:!0,gap:8,children:ie.slice(2,7).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,N.jsx)(f.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:ie.map(e=>(0,N.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),le?(0,N.jsx)(x.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,N.jsx)(x.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,N.jsx)(x.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,N.jsx)(x.ExampleAllergenNotice,{}),(0,N.jsxs)(x.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,N.jsx)(f.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=V===e.id;return(0,N.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,N.jsx)(x.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,N.jsx)(f.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===V?(0,N.jsx)(A.SpecialsTab,{rid:t.id,declared:s.allergies,now:o}):null,'takeaway'===V?(0,N.jsx)(x.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==V?(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,N.jsx)(x.Chip,{label:"All",selected:'All'===i,onPress:()=>H('All')}),se.map(e=>(0,N.jsx)(x.Chip,{label:e,selected:i===e,onPress:()=>H(e)},e))]}):null,'specials'!==V?se.filter(e=>('All'===i||e===i)&&ne.some(t=>t.section===e)).map(e=>(0,N.jsxs)(f.default,{style:{gap:10},children:[(0,N.jsx)(x.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),ne.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,s.allergies),o=e.soldOut||!e.signOff||null===e.price;return(0,N.jsxs)(x.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,N.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)},children:[(0,N.jsxs)(x.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,N.jsx)(x.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,N.jsx)(x.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,j.gbp)(e.price)})]}),(0,N.jsx)(x.Muted,{numberOfLines:2,children:e.description})]}),(0,N.jsxs)(x.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,N.jsx)(x.Badge,{kind:"ok",label:e},e)),e.special?(0,N.jsx)(x.Badge,{kind:"gold",label:"Special"}):null,e.soldOut?(0,N.jsx)(x.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,N.jsx)(x.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,N.jsx)(x.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,N.jsx)(x.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,N.jsx)(p.AllergenChips,{map:e.allergens,declared:s.allergies}),K===e.id?(0,N.jsx)(p.AllergenPanel,{item:e,map:e.allergens,declared:s.allergies}):null,(0,N.jsxs)(x.Row,{gap:8,children:[(0,N.jsx)(x.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,N.jsx)(f.default,{style:{flex:1}}),(0,N.jsx)(x.Button,{small:!0,label:o?e.soldOut?'Sold out':'Not available online':'Choose',disabled:o,onPress:()=>{n.restaurantId&&n.restaurantId===t.id||r(t.id,'takeaway'),u.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,N.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,N.jsx)(x.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,N.jsx)(x.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,N.jsx)(T.LauncherLine,{}),te?(0,N.jsxs)(x.Sheet,{visible:U,onClose:()=>Q(!1),title:"Order at your table",children:[(0,N.jsx)(x.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,N.jsx)(x.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,N.jsx)(x.Button,{small:!0,kind:"secondary",label:`${(0,d.tableNumbers)(e)}`,onPress:()=>{Q(!1),r(t.id,'table',e)}},e))}),(0,N.jsx)(x.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1263,[1264,1273,5,1274,1275,1276,1279,860,30,34,236,402,102,1251,1253,794,861,867,878,874,821,1280,1238,872,891,1281,994,995,1003,1283,1262,25]); -__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1264,[34,379,794,873,1265,1266,1272,874,5,6,25]); -__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1265,[34,379,102,794,996,997,1095,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1266,[6,34,933,794,1267,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1267,[6,1062,1268,1269,1270,34,102,827,794,821,11,1271,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1269,[4,11]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1270,[11]); -__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1271,[6,933]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1272,[34,794,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1273,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1274,[34,102,794,1267,25]); -__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1275,[34,379,933,794,873,1265,1267,4,25]); -__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1276,[34,379,794,1265,873,1266,8,1277,25]); -__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1277,[34,102,794,1278,25]); -__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1278,[]); -__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1279,[34,794,873,1265,1266,874,9,25]); -__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1280,[34,402,102,426,794,821,1200,25]); -__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1281,[828,34,336,395,402,295,102,1251,794,994,861,995,858,821,1048,25,1282]); -__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1282,[]); -__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1283,[34,102,1284,794,874,1003,1259,1262,821,25]); -__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1284,[34,102,1285,821,25]); -__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1285,[1286]); -__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1286,[34,797,1287,1316,1317,25]); -__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1287,[1288]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1288,[1289,1290,1313,1315]); -__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1289,[]); -__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1290,[1291,1292,1293,1294,1295,1296,1297,1298,1299,1302,1306,1303,1307]); -__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1291,[]); -__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1292,[]); -__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1293,[]); -__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1294,[]); -__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1299,[1300]); -__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1303,[1304,1305]); -__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1304,[]); -__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1305,[]); -__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1308,[1303]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1309,[1303]); -__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1311,[1303,1291]); -__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1312,[]); -__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1313,[1314]); -__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1315,[1314]); -__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1316,[]); -__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1317,[34,797,1318,25]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1318,[]); -__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1319,[30,34,794,874,891,25]); -__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1320,[837,30,34,102,1284,794,867,874,821,1283,1262,25]); -__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1321,[837,30,34,102,1257,794,874,891,867,858,821,1258,1262,25]); -__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1322,[837,30,34,794,874,891,858,821,1283,1262,25]); -__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1323,[837,30,34,794,874,891,821,1283,1262,25]); -__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1324,[30,34,794,858,1160,1325,874,821,25]); -__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}},1325,[]); -__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1326,[30,1100,34,402,102,794,858,874,821,25]); -__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 l=_r(d[0]),t=_r(d[1]),n=_r(d[2]),s=e(n),a=_r(d[3]),o=_r(d[4]),r=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),p=_r(d[15]),k=_r(d[16]);function f(){const e=(0,y.useBasket)(),f=(0,y.useRestaurant)(e.restaurantId??void 0),w=(0,y.useAllMenu)(e.restaurantId??void 0),v=(0,y.useCustomer)(),C=(0,y.useOrders)(f?.id),S=(0,y.useStore)(e=>e.setLineQty),T=(0,y.useStore)(e=>e.overrideLine),B=(0,y.useStore)(e=>e.startBasket),P=(0,y.useNow)(15e3),[$,O]=(0,n.useState)(null),[I,M]=(0,n.useState)(!1),[N,F]=(0,n.useState)(''),[L]=(0,n.useState)(()=>(0,o.startForm)()),[R,z]=(0,n.useState)(''),[A,D]=(0,n.useState)(v.phone??''),[E,Y]=(0,n.useState)(v.email??''),[_,q]=(0,n.useState)(!1),H=(0,y.useOrderAtTable)(e.restaurantId??void 0);s.default.useEffect(()=>{H||'table'!==e.mode||y.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[H,e.mode]);const[G,K]=(0,n.useState)(null),[Q,J]=(0,n.useState)(!1),U=(0,n.useMemo)(()=>(0,j.linesFromBasket)(e,w,v.allergies),[e,w,v.allergies]);if(!f||!e.lines.length)return(0,k.jsxs)(u.Screen,{title:"Your basket",children:[(0,k.jsx)(u.Muted,{children:"Your basket is empty."}),(0,k.jsx)(u.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const V=H&&'table'===e.mode,W=(0,m.takeawaySlots)(f,C,P),X=U.reduce((e,l)=>e+l.unitPrice*l.qty,0),Z=U.some(e=>e.contains.length&&!e.overridden),ee=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff}),le=!V&&!$,te=!V&&f.settings.takeawayPaused,ne=(0,p.ukPhone)(A),se=!Z&&!ee.length&&I&&!le&&!te&&(V||ne.ok&&(0,p.emailOk)(E)),ae=async e=>{const l=await y.repo.orders.placeFromBasket({slotTime:V?void 0:$,tip:0,giftCardCode:e?.giftCardCode,notes:N,paidNow:!V,phone:V?void 0:ne.pretty,email:V?void 0:E.trim()||void 0});(0,o.rememberGuard)(l.id,(0,o.guardFor)({...L,hp:R})),q(!1),t.router.replace(`/customer/order/${l.id}`)},oe=e.lines.find(e=>e.key===G),re=oe?U[e.lines.indexOf(oe)]:void 0;return(0,k.jsxs)(u.Screen,{title:"Your basket",subtitle:`${f.name} \xb7 ${V?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,k.jsxs)(r.default,{style:{gap:8},children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.T,{weight:"semibold",children:"Subtotal"}),(0,k.jsx)(u.T,{weight:"bold",size:20,colour:x.colours.gold,children:(0,h.gbp)(X)})]}),Z?(0,k.jsx)(u.T,{size:14,colour:x.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):I?le&&!te?(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Choose a collection time."}):null:(0,k.jsx)(u.T,{size:14,colour:x.colours.amber,children:"Confirm your allergies to continue."}),V?(0,k.jsx)(u.Button,{label:"Send order to the kitchen",disabled:!se,onPress:()=>ae(),testID:"send-table-order"}):(0,k.jsx)(u.Button,{label:`Continue to payment \xb7 ${(0,h.gbp)(X)}`,disabled:!se,onPress:()=>q(!0),testID:"checkout"})]}),children:[(V||e.tableNo,null),V?(0,k.jsx)(u.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,f.fictional?null:(0,k.jsx)(u.ExampleAllergenNotice,{}),U.map((l,t)=>{const n=e.lines[t],s=l.contains.length&&!l.overridden;return(0,k.jsxs)(u.Card,{highlight:l.contains.length?x.colours.red:l.may.length?x.colours.amber:void 0,children:[(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(r.default,{style:{flex:1,paddingRight:8},children:[(0,k.jsx)(u.T,{weight:"semibold",children:l.name}),l.choices.length?(0,k.jsx)(u.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,k.jsxs)(u.Muted,{children:["Note: ",l.notes]}):null]}),(0,k.jsx)(u.T,{weight:"semibold",children:(0,h.gbp)(l.unitPrice*l.qty)})]}),s?(0,k.jsxs)(u.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:[(0,k.jsx)(u.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${v.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} (${(0,c.severityLabel)(e.severity)})`).join(', ')}.`}),(0,k.jsxs)(u.Row,{gap:8,style:{marginTop:6},children:[(0,k.jsx)(u.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{J(!1),K(n.key)}})]})]}):l.contains.length?(0,k.jsx)(u.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(c.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,k.jsx)(u.Banner,{kind:"warn",title:`May contain ${l.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ee.includes(n)?(0,k.jsx)(u.Badge,{kind:"amber",label:"No longer available online \u2014 please remove"}):null,(0,k.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>S(n.key,0)}),(0,k.jsx)(u.Stepper,{value:n.qty,onChange:e=>S(n.key,e),min:1,label:l.name})]})]},n.key)}),(0,k.jsx)(u.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${f.id}`)}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsxs)(u.H2,{children:["Collection time \u2014 ",(0,b.niceDate)(P)]}),te?(0,k.jsx)(u.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===W.length?(0,k.jsx)(u.Banner,{kind:"warn",children:"No collection slots left today."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(u.Muted,{children:["15-minute slots, max ",f.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:W.slice(0,16).map(e=>(0,k.jsx)(u.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:$===e.time.toISOString(),onPress:()=>O(e.time.toISOString())},e.label))})]})]}),(0,k.jsxs)(u.Card,{highlight:I?void 0:x.colours.amber,children:[(0,k.jsx)(u.H2,{children:"Confirm allergies for this order"}),(0,k.jsx)(u.Row,{wrap:!0,gap:6,children:v.allergies.length?v.allergies.map(e=>(0,k.jsx)(u.Badge,{kind:"red",label:`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`},e.allergen)):(0,k.jsx)(u.Muted,{children:"No allergies declared on your profile."})}),(0,k.jsx)(u.Toggle,{label:v.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:I,onChange:M}),(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),V?null:(0,k.jsxs)(u.Card,{children:[(0,k.jsx)(u.H2,{children:"Your details"}),(0,k.jsx)(u.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:A,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!ne.ok&&A?(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:ne.error}):null,(0,k.jsx)(u.Field,{label:"Email (optional)",value:E,onChangeText:Y,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,p.emailOk)(E)?null:(0,k.jsx)(u.T,{size:13,colour:x.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,k.jsx)(u.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,k.jsx)(u.Field,{label:"Order notes (optional)",value:N,onChangeText:F,placeholder:"e.g. cutlery please"}),V?(0,k.jsx)(u.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>B(f.id,'takeaway')}):null,(0,k.jsx)(i.MockPay,{visible:_,onClose:()=>q(!1),amount:X,restaurantId:f.id,onPaid:e=>ae({giftCardCode:e.giftCardCode}),title:"Pay for your takeaway"}),(0,k.jsxs)(u.Sheet,{visible:!!oe,onClose:()=>K(null),title:"Allergy override",children:[re?(0,k.jsx)(u.Banner,{kind:"danger",title:`${re.name} contains ${re.contains.map(c.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,k.jsx)(u.Toggle,{label:"I understand and want to add it anyway",value:Q,onChange:J}),(0,k.jsx)(u.Button,{kind:"danger",disabled:!Q,label:"Confirm override",onPress:()=>{oe&&re&&T(oe.key,re.contains),K(null)}})]}),(0,k.jsx)(a.Honeypot,{value:R,onChange:z})]})}},1327,[860,30,34,1247,1001,102,1257,794,861,867,1130,858,874,831,821,864,25]); -__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1328,[30,34,102,1253,794,861,878,874,821,1280,5,25]); -__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 f}});var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},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]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,s.useLocalSearchParams)(),r=(0,b.useOrder)(e),f=(0,b.useRestaurant)(r?.restaurantId),[C,S]=(0,l.useState)(0),[k,T]=(0,l.useState)(''),[v,P]=(0,l.useState)(!1),[M,$]=(0,l.useState)(!1),[R,A]=(0,l.useState)(1),[I,N]=(0,l.useState)(0),[O,B]=(0,l.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(c.Screen,{title:"Order",children:(0,j.jsx)(c.T,{children:"Order not found."})});const H='takeaway'===r.type?x:w,_=Math.max(0,H.findIndex(([e])=>e===r.status)),D=Math.round(r.subtotal*I/100),F='table'===r.type?r.subtotal+(r.split?r.tip:D):r.total,q=F-r.paid,L=r.split?.ways??O,W=r.split?.paidShares??0,Y=Math.ceil(F/L),E='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(c.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,p.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(c.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Status"}),H.map(([e,t],s)=>(0,j.jsxs)(c.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:s<=_?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(c.T,{weight:s===_?'semibold':'regular',colour:s<=_?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(c.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,p.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(c.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||E?null:(0,j.jsxs)(c.Row,{gap:8,children:[(0,j.jsx)(c.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>b.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(c.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>b.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(c.Card,{children:[(0,j.jsx)(c.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(c.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(c.T,{children:(0,h.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(c.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(c.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(u.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Subtotal"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Of which gift card"}),(0,j.jsxs)(c.T,{colour:y.colours.ok,children:["\u2212",(0,h.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.Muted,{children:"Tip"}),(0,j.jsx)(c.T,{children:(0,h.gbp)(r.tip)})]}):null,(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(c.T,{weight:"semibold",colour:y.colours.gold,children:(0,h.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(c.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(F)," \xb7 split ",L," way",L>1?'s':''," \xb7 ",(0,h.gbp)(Y)," each"]}),(0,j.jsxs)(c.T,{children:["Shares paid: ",W," of ",L," \xb7 remaining ",(0,h.gbp)(q)]}),L>1?(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{children:"Shares to pay now"}),(0,j.jsx)(c.Stepper,{value:R,onChange:A,min:1,max:L-W,label:"shares"})]}):null,(0,j.jsx)(c.Button,{label:`Pay ${L>1?`${R} share${R>1?'s':''}`:'bill'} \xb7 ${(0,h.gbp)(Math.min(q,Y*R))}`,onPress:()=>$(!0),testID:"pay-bill"})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(c.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(c.Chip,{label:e?`${e}%`:'No tip',selected:I===e,onPress:()=>N(e)},e))}),(0,j.jsx)(c.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(c.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(c.Stepper,{value:O,onChange:B,min:1,max:8,label:"people"})]}),(0,j.jsxs)(c.T,{children:["Total ",(0,h.gbp)(r.subtotal+D),O>1?` \xb7 ${(0,h.gbp)(Math.ceil((r.subtotal+D)/O))} each`:'']}),(0,j.jsx)(c.Button,{label:"Get the bill",onPress:()=>b.repo.orders.setSplit(r.id,O,D),testID:"get-bill"})]})]}):null,!E||r.rated||v?null:(0,j.jsxs)(c.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(c.H2,{children:"How was everything?"}),(0,j.jsxs)(c.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(i.Stars,{value:C,onChange:S}),C?(0,j.jsx)(c.Field,{label:"Anything to add? (optional)",value:k,onChangeText:T}):null,(0,j.jsx)(c.Button,{label:"Send feedback",disabled:!C,onPress:()=>{b.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:C,comment:k,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),P(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(c.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,E?(0,j.jsx)(c.Button,{kind:"secondary",label:"View stamp card",onPress:()=>s.router.push(`/customer/${f.id}/loyalty`)}):null,(0,j.jsx)(o.MockPay,{visible:M,onClose:()=>$(!1),amount:Math.min(q,Y*R),restaurantId:f.id,title:`Pay \u2014 ${(0,t.tableNumbers)(r.tableNo)}`,onPaid:e=>{b.repo.orders.payTable(r.id,{shares:R,giftCardCode:e.giftCardCode}),$(!1),A(1)}})]})}},1329,[860,30,34,102,1257,1255,794,861,867,858,874,821,25]); -__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1330,[860,1262,30,34,102,794,861,867,858,874,879,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1331,[30,34,872,25]); -__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1332,[837,30,34,794,874,5,1262,25]); -__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1333,[30,34,794,1334,1174,1262,25]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1334,[827,860,34,102,794,861,867,1174,1335,874,821,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1335,[933,987,1174]); -__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1336,[30,34,872,1337,1401,25]); -__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1337,[1161,796,5,6,1338,828,853,1121,860,1160,1339,1340,1341,1118,1142,1342,1343,1348,1349,1350,872,1351,1173,979,1129,1352,34,1098,1195,1047,1114,1156,1353,395,380,402,295,102,426,36,794,1238,1242,873,861,858,874,821,1117,891,1125,1087,1028,1104,1134,1354,1133,1355,1362,1364,1367,1370,1366,1371,1373,1374,1139,1122,1123,878,1378,1227,1379,1237,1229,1025,1384,1392,1393,1101,1141,1395,1396,1397,1097,1188,1398,1187,1180,869,1399,1400,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1339,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1340,[1026,1087]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1341,[34,102,1104,794,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1342,[860,34,102,794,874,1174,821,25]); -__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1343,[34,395,402,426,102,1284,794,1188,796,1028,1344,1345,1347,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1344,[]); -__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1345,[34,395,402,295,412,102,426,796,794,821,1346,1347,25]); -__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1346,[]); -__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1347,[1024,872,1346,933,987]); -__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1348,[846]); -__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1349,[828,34,379,395,402,102,794,1188,821,25]); -__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1350,[34,236,402,102,794,821,891,1003,858,1097,25]); -__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1351,[828,827,34,236,402,295,102,794,1173,874,979,831,981,982,872,980,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1352,[828,34,102,821,794,25]); -__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1353,[34,102,797,821,25]); -__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1354,[]); -__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1355,[828,796,827,1121,860,1129,34,236,402,295,426,102,859,821,794,1356,1357,1028,891,1133,1359,987,872,25]); -__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1356,[828,860,34,1357,102,859,821,794,1134,1358,25]); -__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1357,[859]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1358,[1357,859]); -__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1359,[34,385,295,102,859,1360,1361,821,796,827,794,25]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1360,[]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1361,[1360,1024,872,933,987]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1362,[34,236,402,102,821,794,1188,1363,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1363,[]); -__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1364,[828,860,1122,34,281,236,295,102,1135,874,1028,1104,14,858,1123,1365,821,794,1366,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1365,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1366,[]); -__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1367,[5,828,34,283,336,236,402,102,426,821,873,794,1029,1000,1348,1368,2,1369,1370,874,858,25]); -__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1368,[236]); -__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1370,[34,846,933,987,1369]); -__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1371,[860,14,1028,1372]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1372,[861]); -__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1373,[34,102,797,821,25]); -__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1374,[1375,860,1122,1028,34,102,794,1125,874,1377,1371,1123,858,1120,1139,1140,1141,821,1340,25]); -__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1375,[34,379,402,102,874,1003,891,1026,1376,872,821,794,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1376,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1377,[1028,1104]); -__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1378,[1375,828,1122,827,860,1160,1118,1139,858,34,1106,236,402,295,102,794,1125,1366,874,1028,861,1116,1104,1325,821,1340,25]); -__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1379,[827,34,236,402,102,794,874,1028,1380,821,1381,1383,25]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1380,[]); -__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1381,[846,874,1028,1380,1382,1383]); -__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1382,[860]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1383,[236,1382]); -__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1384,[860,34,1199,1188,402,102,1025,1028,878,858,821,794,1385,1388,25]); -__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1385,[1386,870,860,34,281,395,402,295,102,874,1025,1028,1387,858,821,1055,794,1388,1389,987,1340,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1386,[]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1387,[878,858,877]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1388,[5,1028,933,987]); -__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1389,[846,933,987,1390,2,1391]); -__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1390,[]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1391,[15]); -__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1393,[]); -__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1394,[1104]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1395,[860,1372]); -__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1396,[34,402,102,794,1395,821,1353,25]); -__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1397,[34,102,925,794,1188,858,821,25]); -__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1398,[34,1188,402,102,426,794,25]); -__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1399,[828,1062,827,2,1188,34,402,102,426,794,821,891,997,858,1000,1389,987,25]); -__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1400,[34,1035,891,1008,831,1036,1000,1389,1093]); -__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1401,[5,828,873,34,236,402,102,426,987,821,794,1348,1402,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1402,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1403,[30,34,872,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1404,[30,34,872,25]); -__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1405,[30,34,1406,872,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1406,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1407,[30,34,872,1408,25]); -__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1408,[1409,1413,828,996,1098,1414,1217,1054,1055,1415,1417,1420,1173,979,1015,1422,1012,2,1060,1061,1423,998,1038,999,34,1175,1238,1242,1213,373,402,295,102,426,36,794,873,1156,891,821,1179,1424,1093,1111,1113,1107,1056,1039,1087,1432,1433,1434,1442,1443,1003,236,1244,1192,1198,1439,1212,1211,1452,1195,15,1218,1219,925,793,987,25]); -__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1409,[827,34,1047,395,102,1133,1134,1355,1384,794,1025,1028,858,821,1087,1029,1410,1411,1049,25]); -__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1410,[827,34,402,102,794,821,1028,5,1029,872,987,25]); -__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1411,[34,102,794,1028,1412,859,821,1074,933,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1412,[]); -__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1413,[34,102,794,1087,987,25]); -__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1414,[860,34,102,794,861,867,1174,874,869,821,25]); -__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1415,[987,34,281,236,102,1284,794,1259,1262,821,1416,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1416,[34,236,102,794,1259,25]); -__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1417,[34,796,102,794,861,1259,1418,1419,821,25]); -__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1418,[861]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1419,[987,1418,1262]); -__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1420,[5,1421,34,102,794,867,1259,1260,1261,987,1262,821,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1421,[34,794,25]); -__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1422,[236,1013]); -__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1423,[34,102,794,821,998,1051,987,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1424,[5,1421,1122,11,1425,827,837,1139,1140,1118,1142,1426,1137,1141,1395,1396,1087,1340,1026,1116,14,1143,1428,1238,1429,1384,1106,1100,1117,34,102,794,1353,874,861,867,858,1325,821,1194,1125,1028,1430,1086,1180,1431,1229,987,1196,1392,878,25]); -__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1425,[6,34,102,794,987,1271,25]); -__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1426,[34,402,102,1427,987,933,821,794,25]); -__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1427,[]); -__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1428,[827,5,34,379,236,102,794,876,14,867,1031,933,821,1197,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1429,[34,402,1188,794,821,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1430,[34,102,874,1028,794,821,25]); -__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1431,[34,102,879,874,864,821,794,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1432,[34,1385,1087,25]); -__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1433,[860,34,102,1180,794,874,861,869,858,821,1194,1087,25]); -__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1434,[835,984,1435,34,236,102,794,831,891,983,1030,985,987,1441,821,2,1181,25]); -__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1435,[827,979,1160,987,797,1227,1229,34,281,379,236,402,102,426,879,794,874,1238,891,867,858,821,1194,1087,869,1436,1179,1439,1440,1159,1166,1165,1038,13,1163,1169,1223,25]); -__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1436,[927,796,831,828,837,878,1075,1437,34,993,336,379,236,402,102,794,874,891,858,821,1194,1087,1223,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1437,[499,1438]); -__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 t={}},1438,[]); -__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1439,[827,34,1252,1055,870,379,402,102,794,891,867,858,821,1194,1087,1223,25]); -__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1440,[1015,34,402,102,794,891,821,1087,987,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1441,[]); -__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1442,[860,34,102,794,891,1028,858,1090,1088,987,1089,5,1000,821,25]); -__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1443,[5,1444,1445,1446,1447,1448,34,236,41,102,872,1449,1003,821,1451,794,987,2,1096,1002,891,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1444,[34,102,873,794,5,6,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1445,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1446,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1447,[34,102,873,794,25]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1448,[34,102,873,794,25]); -__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1449,[34,295,102,794,873,821,1450,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1450,[]); -__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1451,[929,828,34,1096,336,236,402,295,41,102,872,926,891,831,987,1003,15,793,821,925,794,25]); -__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1452,[1195,1098,1139,1116,34,402,102,794,891,858,821,1117,1187,1087,1192,1436,1180,876,1196,869,1194,925,1430,1028,860,1125,1211,1215,1097,25]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1453,[30,34,872,25]); -__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1454,[1455,987,795,1402,1457,1025,30,1484,496,34,385,336,236,41,102,5,873,872,1486,36,874,1028,891,821,1443,1003,1023,1489,1490,1057,1491,1129,2,1038,998,1509,1370,25,1511,1512,1513,1514]); -__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1455,[2,827,34,236,383,102,794,1456,987,821,1198,1003,891,993,25]); -__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1456,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1457,[1458,1481,1483]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1458,[215,1459,1462,1476,1477,1478,1479,1480]); -__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1459,[215,1460]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1460,[1461]); -__d(function(g,r,i,a,m,e,d){},1461,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1462,[1463,215,1459,1476,1477]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1463,[1464,1465,1475]); -__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1464,[1465,1469,1474]); -__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1465,[215,372,1466,1470,1471,1472,1473,1469,1474]); -__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1466,[215,1467,339,280,1468,1469]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1467,[504]); -__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1468,[215,339]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1469,[]); -__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1470,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1471,[]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1472,[1470]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1473,[]); -__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1474,[372,1468]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1475,[34,1465]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1476,[1463,215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1477,[1463,1476]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1478,[1459]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1479,[215,1459,1462,1460]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1480,[]); -__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1481,[215,54,1482]); -__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1482,[215]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1483,[34,1458]); -__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]}})})},1484,[1485]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1485,[]); -__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1486,[34,41,102,426,794,873,1003,987,2,5,821,1487,1488,25]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1487,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1488,[34,102,794,821,25]); -__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1489,[989,883,882,987]); -__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1490,[828,796,827,34,1011,1410,1029,402,102,872,987,1013,1028,5,821,794,1348,976,2,25]); -__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1491,[5,796,827,34,385,283,364,380,236,402,295,426,102,1492,1156,2,797,1087,15,891,794,821,1493,932,1505,1501,1502,1506,1157,1507,931,1508,1504,25,277]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"useAssistantUi",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AssistantFab",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AssistantSheet",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"AssistantPage",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"AssistantSettings",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"AssistantPlanCard",{enumerable:!0,get:function(){return c}});const t=!1,n={getState:()=>({open:!1,setOpen:t=>{}})},u=()=>null,s=()=>null,l=()=>null,o=()=>null,c=()=>null},1492,[]); -__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1493,[1494,1127,860,1495,1496,891,874,1028,1500,1501,1502,1498,1497,1503,1504,1026,1027]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1494,[1092,1091,1052]); -__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1495,[984,1127,835,860,874,831,1028,983,985,1039,891,1094,882,863,861]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1496,[835,874,831,1028,891,1033,1043,1044,1009,1008,1038,13,1063,1064,1065,1034,1094,882,1104,1025,870,1497,1495]); -__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1497,[835,979,1127,860,1160,1262,874,831,1028,1033,994,862,861,1104,1105,1025,1034,867,1498,1499]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1498,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1499,[839,846,849]); -__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1500,[828,34,283,364,236,402,102,846,794,821,25]); -__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1501,[]); -__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1502,[]); -__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1503,[831,891,994,867,1497,1046,1097]); -__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1504,[]); -__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1505,[891,831,1028]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1506,[846]); -__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1507,[839,846,849]); -__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1508,[846]); -__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1509,[874,831,891,1038,15,1003,872,2,1510]); -__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1510,[874,1038]); -__d(function(e,s,o,p,t,a,f){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1511,[]); -__d(function(s,o,e,p,t,c,d){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1512,[]); -__d(function(o,s,e,f,p,t,d){"use strict";p.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1513,[]); -__d(function(o,s,p,t,d,e,n){"use strict";d.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1514,[]); -__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1515,[30,34,872,25]); -__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1516,[1517]); -__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1517,[25,1518,591]); -__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1518,[34,172]); -__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1519,[]); -__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1520,[25,499,34,270,651]); +__d(function(e,t,a,s,n,i,r){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"pointFromRow",{enumerable:!0,get:function(){return Q.pointFromRow}}),Object.defineProperty(i,"pointToRow",{enumerable:!0,get:function(){return Q.pointToRow}}),Object.defineProperty(i,"readingFromRow",{enumerable:!0,get:function(){return Q.readingFromRow}}),Object.defineProperty(i,"readingToRow",{enumerable:!0,get:function(){return Q.readingToRow}}),Object.defineProperty(i,"sameReading",{enumerable:!0,get:function(){return Q.sameReading}}),Object.defineProperty(i,"inviteRefusal",{enumerable:!0,get:function(){return O.inviteRefusal}}),Object.defineProperty(i,"keysToWipe",{enumerable:!0,get:function(){return O.keysToWipe}}),Object.defineProperty(i,"changedFields",{enumerable:!0,get:function(){return R.changedFields}}),Object.defineProperty(i,"useSync",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(i,"can",{enumerable:!0,get:function(){return De}}),Object.defineProperty(i,"isLive",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(i,"stockEventSaved",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(i,"ROTA_READ_CAP",{enumerable:!0,get:function(){return Ot}}),i.rotaReconcile=Rt,i.markChatRead=function(e,t){if(!e)return;const a=(new Date).toISOString();ie.useOwner.getState().chatMarkRead(e,{[t]:a});const s=ie.useOwner.getState();new Set(s.chat.filter(a=>('*'===t||a.ch===t)&&!a.seenBy.includes(e)).map(e=>e.ch)).forEach(t=>ie.useOwner.getState().chatSeen(t,e)),$t(e,t,a)},i.setTempManagerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_manager_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,managerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setTempOwnerAccess=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{error:n}=await Re().rpc('set_staff_owner_access',{p_venue:s,p_staff_ref:e,p_on:t,p_reason:a.trim()||null});return n?{ok:!1,message:/owner/i.test(n.message)?'Only an owner can change this.':'Could not save. Try again.'}:(ie.useOwner.setState(a=>({staff:a.staff.map(a=>a.id===e?{...a,ownerAccess:t}:a)})),{ok:!0})}catch{return{ok:!1,message:'Could not save. Try again when the app is online.'}}},i.setManagerAccess=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:s,error:n}=await Re().rpc('set_manager_access',{p_venue:a,p_staff_ref:e,p_on:t});if(n)return{ok:!1,message:n.message.replace(/^.*?:\s*/,'')||'Not allowed'};const i=String(s??'');return ie.useOwner.setState(t=>({staff:t.staff.map(t=>t.id===e?{...t,...ht(i)}:t)})),{ok:!0,role:i}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.unlockCashUp=async function(e,t,a){if(fe.PITCH)return ge.unlockCashUp(e,t,a);const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:n,error:i}=await Re().rpc('unlock_cash_up',{p_venue:s,p_kind:e,p_id:t,p_reason:a});if(i)return{ok:!1,message:i.message};const r=String(n);return'cashup'===e?de.useCashUp.setState(e=>({cashUps:e.cashUps.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})):de.useCashUp.setState(e=>({sales:e.sales.map(e=>e.id===t?{...e,unlockedUntil:r}:e)})),{ok:!0,until:r}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.readCashAudit=async function(e){if(fe.PITCH)return ge.cashAudit(e);const t=Ae.getState().venueId;if(!t)return[];let a=Re().from('cash_up_audit').select('at, action, changed_by_name, tbl, for_date, reason, old_row, new_row').eq('venue_id',t).order('at',{ascending:!1}).limit(50);e&&(a=a.eq('row_id',e));const{data:s,error:n}=await a;return n||!Array.isArray(s)?[]:s.map(e=>({at:String(e.at),action:String(e.action),by:String(e.changed_by_name??'\u2014'),tbl:String(e.tbl),forDate:e.for_date??void 0,reason:e.reason??void 0,changed:(0,R.changedFields)(e.old_row,e.new_row)}))},i.setPushLive=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Connect to the venue first.'};const{data:a,error:s}=await Re().rpc('set_push_live',{p_venue:t,p_on:e});return s?{ok:!1,message:s.message}:(_a.setState({live:!!a,known:!0}),{ok:!0})},i.readPushLive=pa,i.readAccessLog=async function(){const e=Ae.getState().venueId;if(!e)return[];try{const{data:t}=await Re().from('staff_access_log').select('*').eq('venue_id',e).order('changed_at',{ascending:!1}).limit(30);return t??[]}catch{return[]}},i.readSyncHeartbeats=async function(){const e=Ae.getState().venueId;if(!e)return[];const{data:t,error:a}=await Re().from('device_sync_heartbeats').select('device_id,app,who,version,last_synced_at,realtime,pending,failed,user_agent,seen_at').eq('venue_id',e).order('seen_at',{ascending:!1}).limit(50);if(a)throw a;return t??[]},Object.defineProperty(i,"ORDER_LOGO_BUCKET",{enumerable:!0,get:function(){return ga}}),i.uploadOrderLogo=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'offline'};try{const s=await(await fetch(t)).blob(),n=`${a}/${e}-${Date.now()}.jpg`,{error:i}=await Re().storage.from(ga).upload(n,s,{upsert:!0,contentType:'image/jpeg'});return i?{ok:!1,message:i.message}:{ok:!0,path:n}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.orderLogoUrl=async function(e){const t=ma.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await Re().storage.from(ga).createSignedUrl(e,3600);if(t?.signedUrl)return ma.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},i.removeOrderLogo=async function(e){try{await Re().storage.from(ga).remove([e])}catch{}},Object.defineProperty(i,"usePushLive",{enumerable:!0,get:function(){return _a}}),i.claimInvite=Ua,i.makeChromeHandover=async function(){const e=Ae.getState();if(fe.PITCH)return{ok:!0,code:'pitch-handover-code-aaaaaaaaaaaa'};if('staff'!==e.kind||!e.venueId)return{ok:!1,message:'Sign in from your personal link first.'};try{const{data:t,error:a}=await Re().rpc('make_chrome_handover',{p_venue:e.venueId,p_app:Ee});return a||'string'!=typeof t?{ok:!1,message:a?.message?.replace(/^.*?:\s*/,'')||'Could not open Chrome. Check your connection and try again.'}:{ok:!0,code:t}}catch{return{ok:!1,message:'Could not open Chrome. Check your connection and try again.'}}},i.claimChromeHandover=async function(e){if(fe.PITCH||!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Re().rpc('claim_chrome_handover',{p_code:e,p_app:Ee});if(a){if(/expired|no longer active/i.test(a.message))return{status:'refused',message:a.message.replace(/^.*?:\s*/,'')};throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This Chrome link has expired. Open CoverCharge on your phone and tap Open in Chrome again.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),Me&&qa(),{status:'ok',id:n}}catch(e){return{status:'offline',message:String(e?.message??e)}}},i.signedInHereAs=async function(e){Ne();const t=await q.kv.get(Ia,null);return!!t&&'staff'===t.kind&&t.staffRef===e},i.rememberedInviteHere=async function(e){return Ne(),await q.kv.get(Oa,null)===e},i.kirkmichaelStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_KIRKMICHAEL||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.wildingsStaffAppUrl=async function(){const e=Ae.getState();if(!d.IS_WILDINGS||'staff'!==e.kind||e.venueId!==d.VENUE_UUID||e.staffRef!==A.useSession.getState().meId)return null;Ne();const t=await q.kv.get(Oa,null);return t?(0,A.appUrl)('staff',t):null},i.forgetSignInHere=async function(){Ne(),await q.kv.remove(Ia),await q.kv.remove(Oa),Ce({mode:'signin',perms:[]});try{await xa()}catch{}},i.approveShiftSwap=async function(e,t,a){const s=Ae.getState().venueId;if(fe.PITCH||!s||'staff'!==Ae.getState().kind)return{ok:!0};if(!(0,re.isUuid)(e))return{ok:!1,message:'This shift isn\u2019t on the shared rota yet.'};try{return await Pa('approve_shift_swap',{p_venue:s,p_shift:e,p_to_ref:t,p_kind:a}),{ok:!0}}catch(e){return{ok:!1,message:String(e?.message??e).replace(/^.*?:\s*/,'')||'Not allowed'}}},i.claimInviteForSync=async function(e){const t=await Ua(e);return'ok'===t.status?t.id:null},i.reissueInvite=async function(e){if(fe.PITCH)return ge.reissueInvite(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)return{ok:!1,message:'Connect to the venue first (sign in from your link).'};try{const{data:a,error:s}=await Re().rpc('reissue_invite',{p_venue:t,p_staff_ref:e});if(s)return{ok:!1,message:s.message.replace(/^.*?:\s*/,'')||'Not allowed'};const n=a,i=String(n.app??'staff');return{ok:!0,token:String(n.token),expiresAt:String(n.expiresAt),app:'owner'===i||'chef'===i?i:'staff'}}catch(e){return{ok:!1,message:String(e?.message??e)}}},i.currentStaffAppLinks=async function(e){const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('current_staff_app_links',{p_venue:t,p_staff_ref:e})},i.makeStaffAppLink=async function(e,t){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Pa('make_staff_app_link',{p_venue:a,p_staff_ref:e,p_platform:t})},i.staffAppLinkHistory=async function(e){return Pa('staff_app_link_history',{p_venue:Ae.getState().venueId,p_staff_ref:e})},i.revokeStaffAppLink=async function(e){await Pa('revoke_staff_app_link',{p_venue:Ae.getState().venueId,p_link_id:e})},i.staffLinkPhones=async function(){if(fe.PITCH)return ge.linkPhones();const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return{};try{const t=await Pa('staff_link_phones',{p_venue:e}),a={};for(const e of t??[])a[String(e.staff_ref)]={phones:Number(e.phones??0),since:String(e.since)};return a}catch{return{}}},i.resetStaffLinkPhone=async function(e){if(fe.PITCH)return ge.resetPhone(e);const t=Ae.getState().venueId;if(!t||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');return Number(await Pa('reset_staff_link_phone',{p_venue:t,p_staff_ref:e}))},i.readInviteStatus=async function(){if(fe.PITCH)return ge.inviteStatus();const e=Ae.getState().venueId;if(!e)return{};const{data:t,error:a}=await Re().rpc('invite_status',{p_venue:e});if(a||!Array.isArray(t))return{};const s={};for(const e of t)s[String(e.staff_ref)]={state:e.state,expiresAt:e.expires_at??void 0,usedAt:e.used_at??void 0,devices:Number(e.devices??0)};return s},i.pairWithCode=async function(e){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:t,error:a}=await Re().rpc(d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_pairing_code':d.IS_GREENSIDE?'claim_greenside_pairing_code':d.IS_ABBOTSFORD?'claim_abbotsford_pairing_code':d.IS_KIRKTON?'claim_kirkton_pairing_code':d.IS_WILDINGS?'claim_wildings_pairing_code':d.IS_KIRKMICHAEL?'claim_kirkmichael_pairing_code':d.IS_ISOLATED_VENUE?'claim_souters_pairing_code':'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. It may have expired. Ask a manager for a new one.'};const n={kind:'device',venueId:s.venue_id,venueSlug:s.venue_slug,venueName:s.venue_name,canWrite:s.can_write,label:s.label};return await q.kv.set(ka,n),qa(),{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}`}}},i.carPairStart=async function(){if(!(0,N.isSupabaseConfigured)())return{ok:!1,error:'This build has no shared backend.'};try{await Da();const{data:e,error:t}=await Re().rpc('car_pair_start',{p_venue_slug:'anchorage'});if(t)throw t;const a=e?.[0];return a?(await q.kv.set(Ea,a.request_id),{ok:!0,requestId:a.request_id,code:a.code,expiresAt:a.expires_at}):{ok:!1,error:'No code came back. Try again.'}}catch(e){return{ok:!1,error:Ta(e)}}},i.carPairPoll=async function(e){try{Ne();const t=e??await q.kv.get(Ea,null);if(!t)return'unknown';const{data:a,error:s}=await Re().rpc('car_pair_poll',{p_request:t});if(s)throw s;const n=a?.[0],i=String(n?.status??'unknown');if((0,J.carPairApproved)(n)){const e=(0,J.carDeviceIdentity)({venue_id:n.venue_id,venue_slug:n.venue_slug,venue_name:n.venue_name,role_key:n.role_key,label:n.label}),t=await q.kv.get(ka,null);await q.kv.set(ka,e),await q.kv.remove(Ia),A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({staffAs:void 0,previewRole:'owner'}),t&&t.venueId===e.venueId&&'device'===t.kind||qa()}return'revoked'!==i&&'unknown'!==i||await Na(),i}catch(e){return/fetch|network/i.test(String(e?.message??e))?'offline':'unknown'}},i.carSignOut=async function(){try{Ne(),await Re().rpc('car_sign_out')}catch{}await Na(),await xa();try{await Re().auth.signOut({scope:'local'})}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This car is unpaired.'})},i.carApprove=async function(e,t="Tesla"){const a=Ae.getState().venueId;if(!a||'staff'!==Ae.getState().kind)return{ok:!1,message:'Your phone needs to be connected first. Check your signal and try again.'};try{const s=(await Pa('car_pair_approve',{p_venue:a,p_code:e,p_label:t}))?.[0];return s?.id?{ok:!0}:{ok:!1,message:String(s?.message??'That code isn\u2019t right or has run out.')}}catch(e){return{ok:!1,message:Ta(e)}}},i.carList=async function(){const e=Ae.getState().venueId;if(!e)return[];return(await Pa('car_devices_list',{p_venue:e})??[]).map(e=>({id:e.id,label:e.label,staffName:e.staff_name,approvedAt:e.approved_at,lastSeenAt:e.last_seen_at??void 0}))},i.carRevoke=async function(e){const t=Ae.getState().venueId;if(!t)return{ok:!1,message:'Not connected.'};try{return await Pa('car_revoke',{p_venue:t,p_id:e}),{ok:!0}}catch(e){return{ok:!1,message:Ta(e)}}},i.unpairDisplay=async function(){await q.kv.remove(ka),await xa();try{await Re().auth.signOut()}catch{}Ce({mode:'unpaired',venueId:void 0,venueName:void 0,perms:[]})},i.disconnectStaff=async function(){await q.kv.remove(Ia),await q.kv.remove(Oa),await xa();try{await Re().auth.signOut()}catch{}Ce({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.'})},i.wipeThisDevice=async function(e={}){try{await xa()}catch{}try{(0,N.isSupabaseConfigured)()&&await Re().auth.signOut({scope:'local'})}catch{}let t=0;try{const e='undefined'!=typeof navigator?navigator:null,t=await(e?.serviceWorker?.getRegistration?.()),a=await(t?.pushManager?.getSubscription?.());a&&await a.unsubscribe()}catch{}for(const e of['undefined'!=typeof localStorage?localStorage:null,'undefined'!=typeof sessionStorage?sessionStorage:null])if(e)try{const a=[];for(let t=0;te.startsWith(`cc-venue:${d.VENUE_RID}:`)):(0,O.keysToWipe)(a).filter(e=>!e.startsWith('cc-venue:')))e.removeItem(s),t++}catch{}try{const e='undefined'!=typeof caches?caches:null;if(e)for(const t of await e.keys())!d.IS_ISOLATED_VENUE&&/data|api|photo/i.test(t)&&await e.delete(t)}catch{}Ce({mode:'signin',venueId:void 0,venueName:void 0,perms:[],kind:void 0,role:void 0,staffRef:void 0,message:'This device has been wiped.'}),!1!==e.reload&&'undefined'!=typeof window&&window.location&&window.location.replace(window.location.pathname);return t},i.guestSession=Ka,Object.defineProperty(i,"rpc",{enumerable:!0,get:function(){return Pa}}),i.mendSession=La,i.startAppSync=async function(e=d.VENUE_RID){if(d.IS_ISOLATED_VENUE&&e!==d.VENUE_RID)return;if(Me)return;Me=!0,Ba=e,'customer'===Ee&&'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}});if(Ne(),'customer'!==Ee){const t=e=>new Promise(t=>{try{if(!e?.persist||e.persist.hasHydrated())return t();const a=e.persist.onFinishHydration(()=>{a?.(),t()});setTimeout(t,3e3)}catch{t()}}),a='chef'===Ee&&(0,y.isAnchorage)(e)?[V.useStore,ie.useOwner,se.useKitchen,ne.useSafety,X.useCardStore,_.useGpCalc,ee.useOrderSheets,h.useSpecials,C.useHr]:[V.useStore,ie.useOwner,se.useKitchen];if(await Promise.all(a.map(t)),'chef'===Ee&&(0,y.isAnchorage)(e)&&a.some(e=>!e.persist.hasHydrated()))return void Ce({mode:'offline',message:'Saved kitchen data could not be backed up. Nothing was cleared. Free some device storage, then reopen.',lastError:'Legacy kitchen archive not ready'});try{await Os(e)}catch{if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e))return void Ce({mode:'offline',message:'Device backup failed. Nothing was cleared. Free some storage, then reopen.',lastError:'Legacy kitchen archive failed'})}'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}})}if(!(0,N.isSupabaseConfigured)())return void Ce({mode:'off'});F.mutationQueue.subscribe(()=>{const e=F.mutationQueue.waiting,t=e[0];Ce({pending:F.mutationQueue.pending.length,failed:F.mutationQueue.failed.length,waiting:e.length,waitingWhat:t?`${(0,B.describeWrite)(t)}: ${(0,B.plainReason)({...t.lastErr},'retry')}`:void 0})}),F.mutationQueue.onFailed(e=>Ce({lastError:`${e.table}: ${e.lastError??'rejected'}`,failed:F.mutationQueue.failed.length,...'temp_readings'===e.table||'temp_units'===e.table?{}:{refused:{what:(0,B.describeWrite)(e),why:'conflict'===e.reason?(0,B.plainReason)({code:'conflict'},'refused'):(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused'),at:e.failedAt}}})),Pe.push((0,K.onConnectivity)(e=>Ce({mode:e?Ae.getState().venueId?'live':Ae.getState().mode:Ae.getState().venueId?'offline':Ae.getState().mode}))),await ja()},Object.defineProperty(i,"BOOKINGS_POLL_MS",{enumerable:!0,get:function(){return Qa}}),i.serverOrder=Za,Object.defineProperty(i,"guestWords",{enumerable:!0,get:function(){return Ya}}),i.nudgeGuestSync=function(){Xa?.()},Object.defineProperty(i,"syncInternals",{enumerable:!0,get:function(){return es}}),i.stockSaveBlocker=ts,i.stockEventStatus=function(e){if(Ze(e))return{state:'saved'};const t=F.mutationQueue.failed.find(t=>'stock_events'===t.table&&t.rowKey===e);return t?{state:'refused',why:(0,B.plainReason)({...t.lastErr,message:t.lastErr?.message??t.lastError},'refused')}:{state:'waiting'}},i.resendUnsavedStockEvents=as,i.saveStockEventsNow=ss,i.bookingSaveBlocker=is,i.resendUnsavedBookings=ds,i.saveBookingsNow=us,i.waitForBookingSave=function(e,t=12e3){if(!Ue())return Promise.resolve({state:'local'});const a=is();if(a)return Promise.resolve({state:'refused',why:a});const s=rs()[0]?.venueId??'',n=()=>ns.some(t=>F.mutationQueue.hasPending(t,s,e));return new Promise(a=>{let s=!1;const i=[],r=e=>{s||(s=!0,i.forEach(e=>e()),clearTimeout(d),a(e))},o=()=>{const t=$.useBookingSaves.getState().notSaved[e];if(t)return r({state:'refused',why:t.why});n()||r((0,K.isOnline)()?{state:'saved'}:{state:'waiting'})};i.push(F.mutationQueue.onDone(t=>{t.rowKey===e&&setTimeout(o,0)})),i.push(F.mutationQueue.onFailed(t=>{t.rowKey===e&&setTimeout(o,0)}));const d=setTimeout(()=>r(n()||rs().some(t=>t.unsavedKeys().includes(e))?{state:'waiting'}:{state:'saved'}),t);setTimeout(()=>{n()||rs().some(t=>t.unsavedKeys().includes(e))||o()},400)})},i.tempSaveBlocker=gs,i.tempLogState=function(){const e=ms()[0]?.venueId??'',t=ms().find(e=>'temp_readings'===e.spec.table),a=F.mutationQueue.pending.filter(t=>'temp_readings'===t.table&&t.venueId===e).length,s=t&&t.spec.writable()?t.unsavedKeys().filter(t=>!F.mutationQueue.hasPending('temp_readings',e,t)).length:0,n=Object.values(W.useTempSaves.getState().notSaved),i=ne.useSafety.getState().points??[];return{waiting:a+s,refused:n.filter(e=>'temp_readings'===e.table).length,refusedUnits:n.filter(e=>'temp_units'===e.table).map(e=>i.find(t=>t.id===e.id)?.name??'a unit'),why:n[0]?.why}},i.saveTempNow=_s,i.waitForTempSave=function(e,t,a=1e4){if(!Ue()||!ms().length)return Promise.resolve({state:'local'});const s=gs(e);if(s)return Promise.resolve({state:'refused',why:s});const n=ms()[0]?.venueId??'',i=ms().find(t=>t.spec.table===e),r=Date.now();return new Promise(s=>{const o=()=>{const d=t.map(t=>W.useTempSaves.getState().notSaved[(0,W.tempKey)(e,t)]).find(Boolean);if(d)return s({state:'refused',why:d.why});return t.some(t=>F.mutationQueue.hasPending(e,n,t)||!!i?.unsavedKeys().includes(t))?Date.now()-r>a?s({state:'waiting'}):void setTimeout(o,300):s({state:'saved'})};setTimeout(o,400)})},i.goLive=ws,Object.defineProperty(i,"usePublicDayStore",{enumerable:!0,get:function(){return Ms}}),i.publicDay=function(e,t){const a=`${e}|${t}`,s=Ps.get(a);if('customer'!==Ee||!(0,N.isSupabaseConfigured)())return null;(!s||Date.now()-s.at>6e4)&&(s?s.at=Date.now():Ps.set(a,{at:Date.now(),v:{bookings:[],blocks:[]}}),Pa('public_day',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_date:t}).then(s=>{const n=[],i=[];(s??[]).forEach((a,s)=>{'booking'===a.kind?n.push({id:`pub-${t}-${s}`,ref:'',restaurantId:e,customerId:null,name:'',date:t,time:Le(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:''}):i.push({id:`pubblk-${t}-${s}`,rid:e,date:t,from:Le(a.from_time),to:Le(a.to_time),areaId:a.area_id??void 0,tables:Array.isArray(a.table_ids)&&a.table_ids.length?a.table_ids.map(String):void 0,by:'',createdAt:''})}),Ps.set(a,{at:Date.now(),v:{bookings:n,blocks:i},ok:!0}),Ms.setState(e=>({n:e.n+1}))}).catch(()=>{const e=Ps.get(a);e&&!e.ok&&Ps.delete(a)}));const n=Ps.get(a);return n?.ok?n.v:null},i.saveStaffBookingTimes=async function(e,t,a,s){const n=Ae.getState().venueId;if(!n||'staff'!==Ae.getState().kind)throw new Error('Connect to your venue first.');const i=await Pa('save_staff_booking_times',{p_venue:n,p_hours:t,p_turn:a,p_covers:s});V.useStore.getState().updateRestaurant(e,{...i,id:e})},i.staffTakeawayMenu=async function(){const e=Ae.getState().venueId;if(!e||'staff'!==Ae.getState().kind)return null;return(await Pa('takeaway_menu_staff',{p_venue:e})??[]).map(e=>({itemId:String(e.item_id),dish:String(e.dish??e.item_id),section:String(e.section??''),pricePence:null==e.price_pence?null:Number(e.price_pence),signedOff:!!e.signed_off,onMenu:!!e.on_menu,soldOut:!!e.sold_out}))},i.setStaffTakeawayDish=async function(e,t,a){const s=Ae.getState().venueId;if(!s||'staff'!==Ae.getState().kind)throw new Error('Connect to the venue first.');await Pa('takeaway_menu_set',{p_venue:s,p_item:e,p_on:t,p_by:a})};var o=t(r[0]),d=t(r[1]),u=t(r[2]),c=t(r[3]),l=t(r[4]),f=t(r[5]),p=t(r[6]),g=t(r[7]),m=t(r[8]),_=t(r[9]),S=t(r[10]),h=t(r[11]),y=t(r[12]),w=t(r[13]),v=t(r[14]),b=t(r[15]),k=t(r[16]),I=t(r[17]),O=t(r[18]),R=t(r[19]),A=t(r[20]),C=t(r[21]),D=t(r[22]),U=t(r[23]),E=t(r[24]),T=t(r[25]),N=t(r[26]),K=t(r[27]),P=t(r[28]),M=t(r[29]),x=t(r[30]),q=t(r[31]),L=t(r[32]),B=t(r[33]),j=t(r[34]),F=t(r[35]),$=t(r[36]),W=t(r[37]),Q=t(r[38]),H=t(r[39]),V=t(r[40]),G=t(r[41]),J=t(r[42]),z=t(r[43]),Z=t(r[44]),Y=t(r[45]),X=t(r[46]),ee=t(r[47]),te=t(r[48]),ae=t(r[49]),se=t(r[50]),ne=t(r[51]),ie=t(r[52]),re=t(r[53]),oe=t(r[54]),de=t(r[55]),ue=t(r[56]),ce=t(r[57]),le=t(r[58]),fe=t(r[59]),pe=t(r[60]),ge=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(a){if('default'!==a){var s=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,s.get?s:{enumerable:!0,get:function(){return e[a]}})}}),t.default=e,t})(pe),me=t(r[61]),_e=t(r[62]),Se=t(r[63]),he=t(r[64]),ye=t(r[65]),we=t(r[66]),ve=t(r[67]),be=t(r[68]),ke=t(r[69]),Ie=t(r[70]),Oe=t(r[71]);const Re=()=>(0,T.getSupabase)();F.mutationQueue.setExecutor(L.executeMutation),(0,M.setClockServer)(()=>'staff'===Ae.getState().kind);const Ae=(0,E.create)(()=>({mode:'off',perms:[],pending:0,failed:0})),Ce=e=>Ae.setState(e),De=e=>{const t=Ae.getState().perms;return t.includes('*')||t.includes(e)},Ue=()=>{const e=Ae.getState().mode;return'live'===e||'offline'===e||'connecting'===e};Ae.subscribe(()=>(0,be.setLiveData)(Ue()));let Ee=G.IS_CAR?'car':G.APP_VARIANT,Te=!1;const Ne=()=>{Te||((0,q.setSyncNamespace)(Ee),Te=!0)};let Ke=[],Pe=[],Me=!1;const xe=()=>(new Date).toISOString().slice(0,10),qe=e=>new Date(Date.now()-864e5*e).toISOString().slice(0,10),Le=e=>e?e.slice(0,5):'',Be=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))):[],je=e=>JSON.parse(JSON.stringify(e));function Fe(e,t){const a=qe(120);return{name:t?'walk_ins':'bookings',table:t?'walk_ins':'bookings',list:()=>V.useStore.getState().bookings.filter(a=>a.restaurantId===e&&!!a.walkIn===t),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write')),filter:e=>e.gte(t?'walk_date':'booking_date',a),inWindow:e=>e.date>=a,toRow:(e,a)=>{const s=je(e);if(t)return{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:Be(e.allergies),note:e.notes??'',status:'finished'===e.status?'left':'cancelled'===e.status||'noshow'===e.status?'undone':'seated',created_at:e.createdAt,doc:s};const n=e,i='Wix'===n.importedFrom||Array.isArray(e.tags)&&e.tags.includes('Wix'),r=n.externalSource??(i?'Wix':null),o=n.externalId??(i?e.id:null);return{id:e.id,venue_id:a,ref:e.ref,customer_id:(0,re.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:Be(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,...r?{external_source:r}:{},...o?{external_id:o}:{}}},fromRow:a=>{if(!a.doc||'object'!=typeof a.doc)return null;const s={...a.doc,id:String(a.id),restaurantId:e};if(!t&&a.status&&'declined'!==a.status&&(s.status=a.status),!t){const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];s.table=e.length?e.join('+'):void 0}if(t){s.walkIn=!0,'left'===a.status?s.status='finished':'undone'===a.status?s.status='cancelled':'seated'===a.status&&(s.status='seated');const e=Array.isArray(a.table_ids)?a.table_ids.map(String).map(e=>e.trim()).filter(Boolean):[];e.length&&(s.table=e.join('+'))}return'saved-card'===s.security&&(s.security='none'),s},apply:(e,t)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.bookings.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{bookings:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.bookings!==a.bookings&&e()}),protect:!0}}function $e(e){const t=new Date(Date.now()-18144e5).toISOString();return{name:'orders',table:'takeaway_orders',list:()=>V.useStore.getState().orders.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>'guest'!==Ae.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,re.isUuid)(e.customerId)?e.customerId:null,customer_name:e.customerName||'Guest',phone:e.phone??null,email:e.email??null,items:je(e.lines??[]),allergies:Be(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:je(e.allergyChain??{}),readiness:je(e.readiness??{}),allergy_ticks:je(e.allergyTicks??{}),handover_check:e.handoverCheck?je(e.handoverCheck):null,accepted:e.accepted?je(e.accepted):null,doc:je(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)=>V.useStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.orders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{orders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>V.useStore.subscribe((t,a)=>{t.orders!==a.orders&&e()})}}function We(e){const t=qe(60);return{protect:!0,name:'blocks',table:'blocks',list:()=>[...z.useBlocks.getState().blocks,...z.useBlocks.getState().removed].filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.to>e.from,writable:()=>'guest'!==Ae.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:je(e)}),fromRow:t=>{const a=t.doc&&'object'==typeof t.doc?{...t.doc}:null,s=(0,z.blockClock)(t.from_time)??a?.from,n=(0,z.blockClock)(t.to_time)??a?.to,i='string'==typeof t.block_date?t.block_date.slice(0,10):a?.date;return s&&n&&i?{...a??{by:t.created_by??'',createdAt:t.created_at},id:String(t.id),rid:e,date:i,from:s,to:n,reason:(t.reason??a?.reason)||void 0,note:t.note??a?.note,areaId:t.area_id??a?.areaId,areaName:t.area_name??a?.areaName}:a?{...a,id:String(t.id),rid:e}:null},apply:(e,t)=>z.useBlocks.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=[...a.blocks,...a.removed].filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id)),o=[...i,...e.filter(e=>!r.has(e.id))];return{blocks:o.filter(e=>!e.removedAt),removed:o.filter(e=>!!e.removedAt)}}),subscribe:e=>z.useBlocks.subscribe((t,a)=>{t.blocks===a.blocks&&t.removed===a.removed||e()})}}let Qe=null,He='Main plan';function Ve(e){const t=e=>je({areas:e.areas??[],tables:e.tables??[],joins:e.joins??[],sections:e.sections??[],fixtures:e.fixtures??[]});return{name:'table_plan',table:'table_plans',list:()=>[t(Z.useFloor.getState().plans[e]??(0,Z.planOf)(e))],key:()=>'plan',rowKey:()=>'plan',syncable:()=>!0,writable:()=>De('floor.manage')||De('device.write'),filter:e=>e.eq('is_active',!0),deletes:!1,toRow:(e,a)=>({id:Qe??(0,ke.uuidFrom)(`plan:${a}`),venue_id:a,name:He||'Main plan',is_active:!0,...t(e),updated_by:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>(Qe=String(e.id),He=String(e.name||'Main plan'),t({areas:e.areas,tables:e.tables,joins:e.joins,sections:e.sections,fixtures:e.fixtures})),apply:t=>{const a=t[0]?(0,Ie.withSeedBest)(e,t[0]):void 0;a&&Z.useFloor.setState(t=>({plans:{...t.plans,[e]:a}}))},subscribe:e=>Z.useFloor.subscribe((t,a)=>{t.plans!==a.plans&&e()})}}function Ge(e){return{protect:!0,name:'stock_items',table:'stock_items',conflict:'venue_id,key',list:()=>Y.useShellStore.getState().items[e]??[],key:e=>e.key,rowKey:e=>String(e.key),syncable:()=>!0,writable:()=>De('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,re.isUuid)(e.supplierId)?e.supplierId:(0,ke.uuidFrom)(`sup:${t}:${e.supplierId}`):null,icon:e.icon,sort:e.sort,active:e.active,display_group:e.group??null}),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,...'roast'===e.display_group?{group:'roast'}:{},...e.supplier_id?{supplierId:(t=String(e.supplier_id),dt.get(t)??t)}:{}};var t},apply:(t,a)=>Y.useShellStore.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.key,e])),r=(s.items[e]??[]).filter(e=>!n.has(e.key)).map(e=>i.get(e.key)??e),o=new Set(r.map(e=>e.key));return{items:{...s.items,[e]:[...r,...t.filter(e=>!o.has(e.key))]}}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.items!==a.items&&e()})}}const Je=new Set,ze=new Set;F.mutationQueue.onDone(e=>{'stock_events'===e.table&&ze.add(e.rowKey)});const Ze=e=>ze.has(e)||Je.has(e),Ye=()=>De('*')||De('staff.manage')||De('recipes.edit')||De('recipes.signoff'),Xe=()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('device.write'));function et(e){const t=new Date(Date.now()-2592e5).toISOString();return{name:'stock_events',table:'stock_events',mode:'insert',list:()=>Y.useShellStore.getState().events.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:t=>(0,re.isUuid)(t.id)&&!!(Y.useShellStore.getState().items[e]??[]).find(e=>e.key===t.kind),writable:()=>'guest'!==Ae.getState().kind&&('device'!==Ae.getState().kind||De('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,re.isUuid)(e.undoes)&&(Ze(e.undoes)||F.mutationQueue.hasPending('stock_events',t,e.undoes))?e.undoes:null,by_name:e.by||'Team',app:e.app,at:e.at}),fromRow:t=>(Je.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)=>Y.useShellStore.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.events.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{events:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,500)}}),subscribe:e=>Y.useShellStore.subscribe((t,a)=>{t.events!==a.events&&e()})}}function tt(e){let t={};return{name:'stock_counts',table:'stock_counts',list:()=>Object.entries(Y.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={...Y.useShellStore.getState().server[e]?.counts??{}};for(const e of s)delete t[e];for(const e of a)t[e.item]=e.quantity;Y.useShellStore.setState(a=>({server:{...a.server,[e]:{counts:t,seen:[...Je]}}}))},afterRead:()=>{Y.useShellStore.getState().server[e]||Y.useShellStore.setState(t=>({server:{...t.server,[e]:{counts:{},seen:[...Je]}}}))},subscribe:()=>()=>{}}}const at=new Set;function st(e){return{name:'recipe_cards',table:'recipe_cards',list:()=>{const t=V.useStore.getState().menu;return X.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:t=>(0,re.isUuid)(t.card.id)&&!((0,y.isAnchorage)(e)&&(0,y.isDemoCard)(t.card))&&!(0,y.isPlaceholderCard)(t.card),writable:()=>De('recipes.edit'),toRow:(t,a)=>{let s=t.card;(0,y.isAnchorage)(e)&&(s={...s,signOff:(0,y.demoActor)(s.signOff?.by)?null:s.signOff,allergensConfirmed:(0,y.demoActor)(s.allergensConfirmed?.by)?void 0:s.allergensConfirmed});const n=t.item&&(0,y.isAnchorage)(e)&&(0,y.demoActor)(t.item.signOff?.by)?{...t.item,signOff:null}:t.item;if(s.photo?.startsWith('local:')){const e=(0,ke.photoPath)(a,s),t=nt(s.photo);t&&((0,X.cachePhotoAs)(e,t),it(e,t)),s={...s,photo:e}}const{row:i,extra:r}=(0,ke.cardToRow)(s,a);return{...i,...r,doc:je({card:s,item:n})}},fromRow:t=>{const a=t.doc;if(!a?.card||(0,y.isPlaceholderCard)(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,signOff:(0,y.isAnchorage)(e)&&(0,y.demoActor)(a.item.signOff?.by)?null:a.item.signOff}:void 0}},supersededBy:(e,t)=>t.some(t=>t.card.menuItemId===e.card.menuItemId&&t.card.id!==e.card.id),apply:(e,t)=>{if(!De('recipes.edit')&&t.length){const e=new Set(t);X.useCardStore.setState(t=>({cards:t.cards.map(t=>e.has(t.id)&&t.signOff?{...t,signOff:null}:t)})),t=[]}const a=new Set(t);X.useCardStore.setState(t=>{const s=new Map(e.map(e=>[e.card.id,e.card])),n=new Set(e.map(e=>e.card.menuItemId)),i=t.cards.filter(e=>a.has(e.id)).map(e=>e.menuItemId),r=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(r.map(e=>e.id));return i.length&&V.useStore.setState(e=>({menu:e.menu.map(e=>i.includes(e.id)?{...e,hidden:!0}:e)})),{cards:[...r,...e.filter(e=>!o.has(e.card.id)).map(e=>e.card)],removed:[...t.removed,...i]}});const s=e.map(e=>e.item).filter(Boolean);s.length&&V.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=X.useCardStore.subscribe((t,a)=>{t.cards!==a.cards&&e()}),a=V.useStore.subscribe((t,a)=>{t.menu!==a.menu&&e()});return()=>{t(),a()}}}}const nt=e=>(0,X.readLocalPhoto)(e);async function it(e,t){if(!at.has(e)){at.add(e);try{const a=await(await fetch(t)).blob(),{error:s}=await Re().storage.from(ke.RECIPE_PHOTO_BUCKET).upload(e,a,{upsert:!0,contentType:a.type||'image/jpeg'});if(s)throw s}catch(t){at.delete(e),Ce({lastError:`Photo upload: ${String(t?.message??t)}`})}}}const rt=new Map,ot=(0,E.create)(()=>({n:0}));(0,X.setStoragePhotoResolver)(e=>{const t=rt.get(e);return t&&Date.now()-t.at<3e6?t.url:(0,N.isSupabaseConfigured)()&&'off'!==Ae.getState().mode?(t||(rt.set(e,{url:'',at:Date.now()}),Re().storage.from(ke.RECIPE_PHOTO_BUCKET).createSignedUrl(e,3600).then(({data:t})=>{t?.signedUrl&&(rt.set(e,{url:t.signedUrl,at:Date.now()}),ot.setState(e=>({n:e.n+1})),X.useCardStore.setState(e=>({cards:[...e.cards]})))}).catch(()=>{})),t?.url||null):null});const dt=new Map;const ut=(e,t)=>{const a=(0,re.isUuid)(t)?t:(0,ke.uuidFrom)(`sup:${e}:${t}`);return dt.set(a,t),a};function ct(e){return{name:'order_sheets',table:'suppliers',list:()=>ee.useOrderSheets.getState().sheets[e]??[],key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:t=>!((0,y.isAnchorage)(e)&&'os-veg'===t.id&&t.placeholder),writable:()=>De('suppliers.manage'),toRow:(e,t)=>({id:ut(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:je(e)}}),fromRow:e=>'sheet'!==e.doc?.kind?null:(dt.set(String(e.id),String(e.doc.localId)),e.doc.sheet),apply:(t,a)=>ee.useOrderSheets.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=(s.sheets[e]??[]).filter(e=>!n.has(e.id)).map(e=>i.get(e.id)??e),o=new Set(r.map(e=>e.id));return{sheets:{...s.sheets,[e]:[...r,...t.filter(e=>!o.has(e.id))]}}}),subscribe:e=>ee.useOrderSheets.subscribe((t,a)=>{t.sheets!==a.sheets&&e()}),matchKey:e=>({id:(0,re.isUuid)(e)?e:(0,ke.uuidFrom)(`sup:${Ae.getState().venueId}:${e}`)})}}let lt=!1,ft=!1;const pt=new Map,gt=new Map,mt=new Map,_t=new Map,St=e=>'owner'===e.role?'owner':'manager'===e.role?'Supervisor'===e.level?'supervisor':'manager':'Head Chef'===e.level?'head_chef':'staff',ht=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'},yt=(e,t)=>({...e,managerAccess:t}),wt=()=>({nickname:lt,display:ft}),vt=e=>{const t=!!(e.temp&&e.tempUntil&&e.tempUntil<(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'})),a=yt({role:e.role,level:e.level??ht(St(e)).level},!0===e.managerAccess);return(0,j.staffSyncItem)({...e,...a,active:!t&&e.active,ownerAccess:!0===e.ownerAccess},wt())};const bt=(e=new Date)=>{const t=new Date(e);return t.setDate(t.getDate()-(t.getDay()+6)%7),t.toISOString().slice(0,10)},kt=e=>{const t=Math.round(60*e)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},It=e=>{const t=ie.useOwner.getState().staff.find(t=>t.id===e);return!!t&&(0,u.isKitchenTeam)(t)},Ot=2e3;function Rt(e,t){return t||!e.length||e.length>=Ot?null:e=>(0,re.isUuid)(e.id)}function At(e=!1){return{name:'rota',table:'rota_shifts',authoritative:t=>e?Rt(t,De('rota.manage')):null,keepOnEmpty:()=>e&&!De('rota.manage'),list:()=>ie.useOwner.getState().shifts,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&pt.has(e.staffId)&&(De('rota.manage')||It(e.staffId)),writable:()=>De('rota.manage')||De('rota.kitchen'),toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId),staff_ref:e.staffId,shift_date:e.date??(()=>{const t=new Date(bt());return t.setDate(t.getDate()+(e.day??0)),t.toISOString().slice(0,10)})(),start_time:kt(e.start),end_time:kt(e.end),published:!!e.published,doc:je(e)}),fromRow:e=>{if(!e.doc)return null;const t=e.doc,a=t.date??String(e.shift_date).slice(0,10),[s,n,i]=a.split('-').map(Number);return{...t,id:String(e.id),date:a,day:(new Date(s,n-1,i).getDay()+6)%7,published:!!e.published}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.shifts.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{shifts:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.shifts!==a.shifts&&e()})}}function Ct(){const e=qe(62),t=e=>De('rota.manage')||e.staffId===Ae.getState().staffRef;return{name:'attendance',table:'attendance',list:()=>ie.useOwner.getState().attendance,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&t(e),writable:()=>'staff'===Ae.getState().kind,deletes:!1,filter:t=>t.gte('work_date',e),inWindow:t=>t.date>=e,writeBeforeRead:!0,urgent:e=>e.date>=qe(2)&&e.staffId===Ae.getState().staffRef&&!e.adjusted&&!e.signOff&&!e.voided,toRow:(e,t)=>({id:e.id,venue_id:t,staff_id:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,clock_in:e.in??null,clock_out:e.out??null,breaks:je(e.breaks??[]),break_mins:e.breakMins??0,doc:je((0,w.privateAttendance)(d.VENUE_RID,e))}),fromRow:e=>{if(!e.doc)return null;const t=(0,w.privateAttendance)(d.VENUE_RID,{...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.attendance.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{attendance:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.attendance!==a.attendance&&e()})}}function Dt(){const e=qe(62);return{name:'time_requests',table:'time_requests',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().timeRequests,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&e.staffId===Ae.getState().staffRef&&'open'===e.status,writable:()=>'staff'===Ae.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:pt.get(e.staffId)??null,staff_ref:e.staffId,work_date:e.date,attendance_id:e.attendanceId&&(0,re.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:je({...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)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.timeRequests.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{timeRequests:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.timeRequests!==a.timeRequests&&e()})}}function Ut(e){ie.leaveRemote.decide=t=>!(!De('rota.manage')||!(0,re.isUuid)(t.id)||'approved'!==t.status&&'declined'!==t.status)&&(F.mutationQueue.enqueue({table:'staff_leave',venueId:e,kind:'rpc',fn:'staff_leave_decide',rowKey:t.id,values:{p_id:t.id,p_status:t.status}}),!0),Pe.push(()=>{ie.leaveRemote.decide=null})}function Et(e){ie.timesheetRemote.send=(t,a)=>{if(!De('rota.manage')||!(0,re.isUuid)(a.id))return!1;if('time_request_resolve'===t){const s=a;return F.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:je(s)}}),!0}const s=a;if('attendance_void'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e,p_reason:s.voided?.reason??'Removed',p_void:!0}}),!0;if('attendance_delete'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_venue:e}}),!0;if('attendance_add_past'===t)return!(!s.in||!s.out)&&(F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,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,p_break_mins:s.breakMins??0,p_note:s.adjusted?.reason??'',p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0);if('attendance_confirm'===t)return F.mutationQueue.enqueue({table:'attendance',venueId:e,kind:'rpc',fn:t,rowKey:s.id,values:{p_id:s.id,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0;if(!s.in)return!1;const n=s.adjusted?.reason??'';return F.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:je(s.breaks??[]),p_reason:n,p_doc:je((0,w.privateAttendance)(d.VENUE_RID,s))}}),!0},Pe.push(()=>{ie.timesheetRemote.send=null})}function Tt(e){return{name:'outbox',table:'outbox',mode:'insert',list:()=>V.useStore.getState().outbox.filter(t=>t.restaurantId===e),key:e=>e.id,rowKey:e=>String(e.local_id??e.id),syncable:()=>!0,writable:()=>'staff'===Ae.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,re.isUuid)(a)?a:(0,ke.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,re.isUuid)(e.refId)?e.refId:null,ref:e.ref,status:e.status,provider:e.provider,error:e.error??null,created_at:e.at,doc:je(e)};var a},fromRow:t=>t.doc?{...t.doc,restaurantId:e}:null,apply:e=>V.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=>V.useStore.subscribe((t,a)=>{t.outbox!==a.outbox&&e()})}}const Nt=e=>V.useStore.getState().events.filter(t=>t.restaurantId===e&&!t.example);function Kt(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}));V.useStore.setState(t=>({events:[...t.events.filter(t=>!(t.restaurantId===e&&!t.example)),...a]}))}function Pt(e){return{name:'venue',table:'venues',venueColumn:'id',mode:'update',list:()=>{const t=V.useStore.getState(),a=t.restaurants.find(t=>t.id===e);return[je({restaurant:a,msgTemplates:t.msgTemplates[e]??{},display:Z.useFloor.getState().settings[e]??{},games:!1!==a?.settings?.games,events:Nt(e)})]},key:()=>'venue',rowKey:()=>'venue',syncable:()=>!0,writable:()=>De('venue.settings'),matchKey:()=>({}),toRow:e=>({name:e.restaurant?.name,settings:{...xt??{},whatsapp:e.restaurant?.settings?.whatsapp||null,app:{...xt?.app??{},restaurant:e.restaurant,events:e.events??[]},ops:{...xt?.ops??{},msgTemplates:e.msgTemplates,display:e.display}},feature_flags:{...Mt??{},games:e.games,takeaway:!e.restaurant?.settings?.takeawayPaused}}),fromRow:t=>{Mt=t.feature_flags??{},xt=t.settings??{};const a=t.settings?.app?.restaurant;if(!a)return null;const s='string'==typeof t.settings?.whatsapp?t.settings.whatsapp:void 0;return s&&!a.settings?.whatsapp&&(a.settings={...a.settings,whatsapp:s}),je({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}:{}})},apply:t=>{const a=t[0];a&&(V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e&&a.restaurant?(0,f.withWildingsAddress)({...a.restaurant,id:e,settings:{...a.restaurant.settings,games:a.games}}):t),msgTemplates:{...t.msgTemplates,[e]:a.msgTemplates??{}}})),a.display&&Object.keys(a.display).length&&Z.useFloor.setState(t=>({settings:{...t.settings,[e]:a.display}})),a.events&&Kt(e,a.events))},subscribe:e=>{const t=V.useStore.subscribe((t,a)=>{t.restaurants===a.restaurants&&t.msgTemplates===a.msgTemplates&&t.events===a.events||e()}),a=Z.useFloor.subscribe((t,a)=>{t.settings!==a.settings&&e()});return()=>{t(),a()}}}}let Mt=null,xt=null;const qt=()=>new Date(Date.now()-2592e6).toISOString(),Lt=e=>{if(!e.startsWith('dm:'))return['all','kitchen','foh','managers'].includes(e)?e:null;const t=e.split(':').slice(1).map(e=>pt.get(e));return 2===t.length&&t[0]&&t[1]?`dm:${[t[0],t[1]].sort().join(':')}`:null},Bt=e=>{if(!e.startsWith('dm:'))return e;const t=e.split(':').slice(1).map(e=>gt.get(e));return 2===t.length&&t[0]&&t[1]?(0,he.dmId)(t[0],t[1]):null},jt=()=>Ae.getState().perms.includes('*');function Ft(){const e=()=>Ae.getState().staffRef;return{name:'chat',table:'chat_messages',deletes:!1,list:()=>ie.useOwner.getState().chat.filter(e=>(0,re.isUuid)(e.id)).map(e=>je({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=>!!Lt(t.ch)&&(t.from===e()||jt()&&!t.ch.startsWith('dm:')&&t.removed),writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('created_at',qt()).order('created_at',{ascending:!1}),inWindow:e=>e.at>=qt(),toRow:(e,t)=>{const a=Lt(e.ch);if(!a)throw new Error('chat: unknown person');const s='system'===e.from?null:pt.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=Bt(String(e.channel));if(!t)return null;const a=String(e.from_device??''),s='car'===a?'car-device':'display'===a?'display-device':e.from_staff?gt.get(String(e.from_staff)):'system';return s?je({id:String(e.id),ch:t,from:s,text:e.body??void 0,photo:e.photo??void 0,at:new Date(e.created_at).toISOString(),removed:!!e.removed}):null},apply:(t,a)=>ie.useOwner.setState(s=>{const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e(),o=s.chat.filter(e=>!n.has(e.id)).map(e=>i.has(e.id)?{...e,...i.get(e.id)}:e),d=new Set(o.map(e=>e.id)),u=r&&s.chatRead?.[r]||{},c=t.filter(e=>!d.has(e.id)).map(e=>{return{...e,reactions:{},seenBy:e.from===r?[e.from]:r&&Date.parse(e.at)<=(t=e.ch,Math.max(Date.parse(u['*']??'')||0,Date.parse(u[t]??'')||0))?[r]:[]};var t});return{chat:c.length?[...o,...c].sort((e,t)=>e.at.localeCompare(t.at)):o}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.chat!==a.chat&&e()}),onRemote:(t,a)=>{if('upsert'!==a||t.removed)return;const s=String(t.from_device??''),n='car'===s?'car-device':'display'===s?'display-device':t.from_staff?gt.get(String(t.from_staff)):'system',i=Bt(String(t.channel)),r=e();if(!i||!r||n===r||Date.now()-new Date(t.created_at).getTime()>12e4)return;const o=ie.useOwner.getState();if((o.chatMuted[r]??[]).includes(i))return;if(!(0,he.inChannel)(i,o.staff.find(e=>e.id===r)))return;if((0,ye.soundAllowed)())try{(0,ye.chime)('soft')}catch{}const d='car-device'===n?'Car':'display-device'===n?'Display':'system'===n?'CoverCharge':o.staff.find(e=>e.id===n)?.name?.replace(' (example)','')??'The team',u=i.startsWith('dm:')?'sent you a message':`in ${'all'===i?'Everyone':'foh'===i?'Front of house':'kitchen'===i?'Kitchen':'managers'===i?'Managers':i}`,c=String(t.body??t.text??'').slice(0,120);(0,k.notify)({id:`chat:${t.id}`,icon:'\ud83d\udcac',kicker:'NEW MESSAGE',title:`${d} ${u}`,body:c||void 0,timeoutMs:7e3,testID:'chat-notice'})}}}async function $t(e,t,a){const s=Ae.getState();if(!Se.useChatSync.getState().synced||!s.venueId||'staff'!==s.kind||s.staffRef!==e)return;const n=pt.get(e),i='*'===t?'*':Lt(t);if(n&&i)try{await Re().from('chat_reads').upsert({venue_id:s.venueId,staff_id:n,channel:i,read_at:a},{onConflict:'staff_id,channel'})}catch{}}async function Wt(e){const t=Ae.getState().staffRef,a=t?pt.get(t):void 0;if(t&&a)try{const{data:s,error:n}=await Re().from('chat_reads').select('channel,read_at').eq('venue_id',e).eq('staff_id',a);if(n||!s?.length)return;const i={};for(const e of s){const t='*'===e.channel?'*':Bt(String(e.channel));t&&(i[t]=new Date(e.read_at).toISOString())}Object.keys(i).length&&ie.useOwner.getState().chatMarkRead(t,i)}catch{}}function Qt(e){return{name:'reminders',table:'venue_reminders',list:()=>{const t=D.useReminders.getState(),a=t.reminders.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'reminder',doc:je(a)}}),s=t.rules[e];return s?[...a,{id:s.id,kind:'break_rules',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'break_rules'===e.kind?'break_rules':'reminder',doc:e.doc??{}}),apply:(t,a)=>D.useReminders.setState(s=>{const n=new Set(a),i={...s.rules},r=t.filter(e=>'break_rules'===e.kind);for(const t of r)i[e]={...(0,U.clampRules)(t.doc),id:t.id,updatedAt:t.doc.updatedAt};i[e]&&n.has(i[e].id)&&delete i[e];const o=new Map(t.filter(e=>'reminder'===e.kind).map(t=>[t.id,{...t.doc,id:t.id,rid:e}])),d=s.reminders.filter(e=>!n.has(e.id)).map(e=>o.get(e.id)??e),u=new Set(d.map(e=>e.id));return{rules:i,reminders:[...d,...[...o.values()].filter(e=>!u.has(e.id))]}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.reminders===a.reminders&&t.rules===a.rules||e()})}}function Ht(e){const t=qe(14);return{name:'reminder_done',table:'reminder_done',mode:'insert',deletes:!1,list:()=>D.useReminders.getState().done.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.reminderId)&&e.staffRef===Ae.getState().staffRef,writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t).order('done_at',{ascending:!1}),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,reminder_id:e.reminderId,for_date:e.forDate,staff_ref:e.staffRef,staff_name:e.staffName.slice(0,80),done_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,reminderId:String(t.reminder_id),forDate:String(t.for_date).slice(0,10),staffRef:t.staff_ref??'',staffName:t.staff_name??'Team',at:new Date(t.done_at).toISOString()}),apply:(e,t)=>D.useReminders.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.done.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{done:[...e.filter(e=>!r.has(e.id)),...i].sort((e,t)=>t.at.localeCompare(e.at)).slice(0,400)}}),subscribe:e=>D.useReminders.subscribe((t,a)=>{t.done!==a.done&&e()})}}function Vt(e,t,a,s=()=>!0){const n=new Set(a),i=new Map(t.map(e=>[e.id,e])),r=e.filter(e=>!s(e)||!n.has(e.id)).map(e=>s(e)&&i.has(e.id)?i.get(e.id):e),o=new Set(r.map(e=>e.id));return[...r,...t.filter(e=>!o.has(e.id))]}const Gt=e=>null==e||''===e?null:Number(e),Jt=e=>e.filter(e=>!e.startsWith('data:')),zt=()=>De('takings.view');function Zt(e){const t=!zt();return{name:'cash_ups',table:'cash_ups',list:()=>de.useCashUp.getState().cashUps.filter(a=>a.rid===e&&(!t||a.date===(0,b.tradingDay)())),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt&&(!t||e.date===(0,b.tradingDay)()&&!e.onServer),writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,filter:e=>t?e.eq('for_date',(0,b.tradingDay)()):e.gte('for_date',qe(400)),...t?{inWindow:e=>e.date===(0,b.tradingDay)()}:{},toRow:(e,t)=>({id:e.id,venue_id:t,for_date:e.date,vals:je(e.vals),cash_tips:'number'==typeof e.vals.cashTips?e.vals.cashTips:null,card_tips:'number'==typeof e.vals.cardTips?e.vals.cardTips:null,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,date:String(t.for_date),vals:t.vals??{},photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({cashUps:Vt(s.cashUps,t.map(e=>{const t=s.cashUps.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.cashUps!==a.cashUps&&e()})}}function Yt(e){return{name:'sales_reports',table:'sales_reports',list:()=>de.useCashUp.getState().sales.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&!!e.confirmedAt,writable:()=>De('wages.manage')||(0,v.hasCashUpAccess)(),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,week_start:e.weekStart,vals:je(e.vals),categories:e.categories,photos:Jt(e.photos),read_by:e.readBy??null,confirmed_by:e.confirmedBy??null,confirmed_at:e.confirmedAt??null,updated_at:(new Date).toISOString()}),fromRow:t=>({id:String(t.id),rid:e,weekStart:String(t.week_start),vals:t.vals??{},categories:t.categories??[],photos:t.photos??[],readBy:t.read_by??null,confirmedBy:t.confirmed_by??void 0,confirmedAt:t.confirmed_at??void 0,onServer:!0,unlockedUntil:t.unlocked_until??void 0,unlockedBy:t.unlocked_by??void 0}),apply:(t,a)=>de.useCashUp.setState(s=>({sales:Vt(s.sales,t.map(e=>{const t=s.sales.find(t=>t.id===e.id);return t&&!e.photos.length?{...e,photos:t.photos}:e}),a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.sales!==a.sales&&e()})}}function Xt(e){return{name:'cashup_settings',table:'cashup_settings',conflict:'venue_id',list:()=>{const t=de.useCashUp.getState().settings[e];return t?[t]:[]},key:e=>e.id,rowKey:()=>(0,de.cashSettingsId)(e),syncable:e=>!!e.updatedAt,writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({venue_id:t,doc:je({cashFields:e.cashFields,salesFields:e.salesFields}),updated_at:(new Date).toISOString()}),fromRow:t=>({...t.doc,id:(0,de.cashSettingsId)(e),updatedAt:t.updated_at??void 0}),apply:t=>de.useCashUp.setState(a=>t[0]?{settings:{...a.settings,[e]:t[0]}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.settings!==a.settings&&e()})}}function ea(e){return{name:'day_tips',table:'day_tips',list:()=>de.useCashUp.getState().tips.filter(t=>t.rid===e).map(e=>({...e,id:e.date})),key:e=>e.id,rowKey:e=>String(e.for_date),syncable:()=>!1,writable:()=>!1,deletes:!1,filter:e=>e.gte('for_date',qe(120)),toRow:()=>({}),fromRow:t=>({id:String(t.for_date),rid:e,date:String(t.for_date),total:Number(t.total),postedAt:String(t.posted_at),postedBy:t.posted_by??void 0}),apply:t=>de.useCashUp.setState(a=>{const s=new Map(t.map(e=>[e.date,e])),n=a.tips.filter(t=>!(t.rid===e&&s.has(t.date)));return{tips:[...t.map(({id:e,...t})=>t),...n]}}),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.tips!==a.tips&&e()})}}function ta(e){return{name:'tips_pot_events',table:'tips_pot_events',mode:'insert',deletes:!1,list:()=>de.useCashUp.getState().pot.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('wages.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,for_date:e.forDate??null,through_date:e.throughDate??null,amount:e.amount,reason:e.reason??null,by_name:e.by,at:e.at}),fromRow:t=>({id:String(t.id),rid:e,kind:'payout'===t.kind?'payout':'correction',forDate:t.for_date??void 0,throughDate:t.through_date??void 0,amount:Gt(t.amount)??0,reason:t.reason??void 0,by:String(t.by_name),at:String(t.at)}),apply:(t,a)=>de.useCashUp.setState(s=>({pot:Vt(s.pot,t,a,t=>t.rid===e)})),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.pot!==a.pot&&e()})}}function aa(e){return{name:'tips_settings',table:'tips_settings',conflict:'venue_id',deletes:!1,list:()=>{const t=de.useCashUp.getState().show[e];return t?[{id:'show',...t}]:[]},key:e=>e.id,rowKey:()=>'show',syncable:()=>!0,writable:()=>De('wages.manage'),toRow:(e,t)=>({venue_id:t,show_today:e.showToday,show_pot:e.showPot,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'show',showToday:!1!==e.show_today,showPot:!1!==e.show_pot}),apply:t=>de.useCashUp.setState(a=>t[0]?{show:{...a.show,[e]:{showToday:t[0].showToday,showPot:t[0].showPot}}}:a),subscribe:e=>de.useCashUp.subscribe((t,a)=>{t.show!==a.show&&e()})}}function sa(e){return{name:'scheduled_notifications',table:'scheduled_notifications',list:()=>oe.useNotifs.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings'),deletes:!1,toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,doc:je(s),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>oe.useNotifs.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>oe.useNotifs.subscribe((t,a)=>{t.items!==a.items&&e()})}}function na(e){return{name:'order_lists',table:'order_lists',list:()=>{const t=ue.useOrderLists.getState(),a=t.lists.filter(t=>t.rid===e&&(0,re.isUuid)(t.id)).map(e=>{const{rid:t,...a}=e;return{id:e.id,kind:'list',doc:je(a)}}),s=t.settings[e];return s?[...a,{id:s.id,kind:'settings',doc:je(s)}]:a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),deletes:!1,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'settings'===e.kind?'settings':'list',doc:e.doc??{}}),apply:(t,a)=>ue.useOrderLists.setState(s=>{const n={...s.settings};for(const a of t.filter(e=>'settings'===e.kind))n[e]={...ce.DEFAULT_ORDER_LIST_SETTINGS,...a.doc,id:a.id};const i=t.filter(e=>'list'===e.kind).map(t=>({...t.doc,id:t.id,rid:e}));return{settings:n,lists:Vt(s.lists,i,a,t=>t.rid===e)}}),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.lists===a.lists&&t.settings===a.settings||e()})}}function ia(e){const t=()=>De('venue.settings')||De('suppliers.order');return{name:'order_list_items',table:'order_list_items',list:()=>ue.useOrderLists.getState().items.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:a=>(0,re.isUuid)(a.id)&&(0,re.isUuid)(a.listId)&&(t()||'open'===a.status&&(0,ue.orderSettingsOf)(e).allowStaff),writable:()=>'staff'===Ae.getState().kind,deletes:!0,toRow:(e,a)=>{const{rid:s,...n}=e;return{id:e.id,venue_id:a,list_id:e.listId,status:e.status,added_by_ref:(t()?e.addedBy:Ae.getState().staffRef)||null,doc:je(n),updated_at:(new Date).toISOString()}},fromRow:t=>({...t.doc,id:String(t.id),listId:String(t.list_id),status:t.status??'open',rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({items:Vt(s.items,t,a,t=>t.rid===e)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.items!==a.items&&e()})}}function ra(e){const t=qe(400);return{name:'order_list_history',table:'order_list_history',mode:'insert',deletes:!1,list:()=>ue.useOrderLists.getState().history.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('venue.settings')||De('suppliers.order'),filter:e=>e.gte('finished_at',t).order('finished_at',{ascending:!1}).limit(300),toRow:(e,t)=>{const{rid:a,...s}=e;return{id:e.id,venue_id:t,list_id:e.listId,finished_at:e.finishedAt,finished_by:e.finishedByName.slice(0,80),doc:je(s)}},fromRow:t=>({...t.doc,id:String(t.id),rid:e}),apply:(t,a)=>ue.useOrderLists.setState(s=>({history:Vt(s.history,t,a,t=>t.rid===e).sort((e,t)=>t.finishedAt.localeCompare(e.finishedAt)).slice(0,300)})),subscribe:e=>ue.useOrderLists.subscribe((t,a)=>{t.history!==a.history&&e()})}}function oa(e){return{name:'venue_clock_area',table:'venue_clock_area',conflict:'venue_id',deletes:!1,list:()=>{const t=le.useClockArea.getState().areas[e];return t&&t.updatedAt?[{id:'area',doc:je(t)}]:[]},key:()=>'area',rowKey:()=>'area',syncable:()=>!0,matchKey:()=>({}),writable:()=>De('venue.settings'),toRow:(e,t)=>({venue_id:t,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:'area',doc:e.doc??{}}),apply:t=>{const a=t[0];a&&le.useClockArea.setState(t=>({areas:{...t.areas,[e]:{...(0,w.venueClockArea)(e,a.doc),updatedAt:a.doc.updatedAt,updatedBy:a.doc.updatedBy}}}))},subscribe:e=>le.useClockArea.subscribe((t,a)=>{t.areas!==a.areas&&e()})}}function da(e){return{name:'daily_tasks',table:'daily_tasks',deletes:!1,list:()=>{const t=me.useDailyTasks.getState(),a=[],s=t.library[e];s?.updatedAt&&a.push({id:(0,me.libraryRowId)(e),kind:'library',doc:je({items:s.items,updatedAt:s.updatedAt})});for(const[s,n]of Object.entries(t.people)){const[t,i]=s.split('|');t===e&&n.updatedAt&&a.push({id:(0,me.personRowId)(e,i),kind:'person',staffRef:i,doc:je({tasks:n.tasks,updatedAt:n.updatedAt})})}return a},key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);if(!t)return!1;if('staff'!==t.role)return!0;if('person'!==e.kind)return!1;const a=ie.useOwner.getState().staff.find(t=>t.id===e.staffRef);return!!a&&(0,_e.canEditTasks)(t,a)},writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,kind:e.kind,staff_ref:e.staffRef??null,doc:e.doc,updated_at:(new Date).toISOString()}),fromRow:e=>({id:String(e.id),kind:'library'===e.kind?'library':'person',staffRef:e.staff_ref??void 0,doc:e.doc??{}}),apply:t=>me.useDailyTasks.setState(a=>{const s={...a.library},n={...a.people};for(const a of t)'library'===a.kind?s[e]={items:a.doc.items??[],updatedAt:a.doc.updatedAt}:a.staffRef&&(n[(0,me.personKey)(e,a.staffRef)]={tasks:a.doc.tasks??[],updatedAt:a.doc.updatedAt});return{library:s,people:n}}),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.library===a.library&&t.people===a.people||e()})}}function ua(e){const t=qe(7);return{name:'daily_task_ticks',table:'daily_task_ticks',list:()=>me.useDailyTasks.getState().ticks.filter(t=>t.rid===e),key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>{const t=Ae.getState();return e.byRef===t.staffRef||De('staff.manage')},writable:()=>'staff'===Ae.getState().kind,filter:e=>e.gte('for_date',t),inWindow:e=>e.forDate>=t,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffRef,task_id:e.taskId,for_date:e.forDate,ticked_by_ref:e.byRef,ticked_by_name:e.byName.slice(0,80),ticked_at:e.at}),fromRow:t=>({id:String(t.id),rid:e,staffRef:String(t.staff_ref),taskId:String(t.task_id),forDate:String(t.for_date).slice(0,10),byRef:String(t.ticked_by_ref??''),byName:String(t.ticked_by_name??''),at:String(t.ticked_at)}),apply:(t,a)=>me.useDailyTasks.setState(s=>({ticks:Vt(s.ticks,t,a,t=>t.rid===e)})),subscribe:e=>me.useDailyTasks.subscribe((t,a)=>{t.ticks!==a.ticks&&e()})}}function ca(e,t=!1){const a=qe(14);return{name:'sold_out_items',table:'sold_out_items',conflict:'venue_id,item_id',list:()=>we.useSoldOut.getState().entries.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind||De('device.write'),filter:e=>e.gte('marked_at',a),inWindow:e=>e.at.slice(0,10)>=a,toRow:(e,a)=>({id:(0,ke.uuidFrom)(`soldout:${a}:${e.itemId}`),venue_id:a,item_id:e.itemId.slice(0,80),name:e.name.slice(0,120),is_on:e.on,marked_at:e.at,by_name:(e.by||'Staff').slice(0,80),clear_after:e.clearAfter??null,...t?{auto:!!e.auto,kept:!!e.kept}:{}}),fromRow:a=>({rid:e,itemId:String(a.item_id),name:String(a.name??''),on:!0===a.is_on,at:String(a.marked_at),by:String(a.by_name??''),clearAfter:a.clear_after?String(a.clear_after):void 0,...t?{auto:!0===a.auto,kept:!0===a.kept}:{}}),apply:(t,a)=>we.useSoldOut.setState(s=>{const n=new Set(a);return{entries:[...s.entries.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>{return s=a,(t=e).rid===s.rid&&t.itemId===s.itemId;var t,s})))),...t]}}),subscribe:e=>we.useSoldOut.subscribe((t,a)=>{t.entries!==a.entries&&e()}),afterRead:()=>{ve.autoSync.soldOutRead.add(e)}}}function la(e){return{name:'sold_out_links',table:'sold_out_links',conflict:'venue_id,item_id',list:()=>ve.useSoldOutLinks.getState().links.filter(t=>t.rid===e),key:e=>e.itemId,rowKey:e=>String(e.item_id),syncable:()=>!0,deletes:!1,writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:(0,ke.uuidFrom)(`soldoutlink:${t}:${e.itemId}`),venue_id:t,item_id:e.itemId.slice(0,80),uses:e.uses.slice(0,10).map(e=>({key:String(e.key).slice(0,40),qty:Math.max(0,Math.min(99,Number(e.qty)||0))})),auto:!!e.auto,updated_at:e.at,updated_by:(e.by||'Staff').slice(0,80)}),fromRow:t=>({rid:e,itemId:String(t.item_id),uses:(Array.isArray(t.uses)?t.uses:[]).map(e=>({key:String(e.key??''),qty:Number(e.qty)||0})).filter(e=>e.key&&e.qty>0),at:String(t.updated_at??''),by:String(t.updated_by??''),...!0===t.auto?{auto:!0}:{}}),apply:(t,a)=>ve.useSoldOutLinks.setState(s=>{const n=new Set(a);return{links:[...s.links.filter(a=>!(a.rid===e&&(n.has(a.itemId)||t.some(e=>e.itemId===a.itemId)))),...t]}}),subscribe:e=>ve.useSoldOutLinks.subscribe((t,a)=>{t.links!==a.links&&e()}),afterRead:()=>{ve.autoSync.linksRead.add(e)}}}async function fa(e,t="*"){const a='*'===t?`table:${e}`:`table:${e}.${t}`;try{const s=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:n}=await Promise.race([Re().from(e).select(t,{head:!0,count:'exact'}).limit(1),s]);return n?!!/fetch|network|Failed/i.test(n.message)&&q.kv.get(a,!1):(q.kv.set(a,!0),!0)}catch{return q.kv.get(a,!1)}}async function pa(){const e=Ae.getState().venueId;if(e)try{const{data:t}=await Re().from('push_settings').select('push_live').eq('venue_id',e).maybeSingle();_a.setState({live:!!t?.push_live,known:!0})}catch{}}const ga='order-list-logos';const ma=new Map;const _a=(0,E.create)(()=>({live:!1,known:!1}));async function Sa(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('venue_reminders').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('reminders:ok',!1):(q.kv.set('reminders:ok',!0),!0)}catch{return q.kv.get('reminders:ok',!1)}}async function ha(){try{const e=new Promise(e=>setTimeout(()=>e({error:{message:'Failed: timed out'}}),5e3)),{error:t}=await Promise.race([Re().from('chat_messages').select('id').limit(1),e]);return t?!!/fetch|network|Failed/i.test(t.message)&&q.kv.get('chat:ok',!1):(q.kv.set('chat:ok',!0),!0)}catch{return q.kv.get('chat:ok',!1)}}const ya=(e,t)=>je({id:String(e.id),venue:t,body:String(e.body??''),kind:'yesno'===e.kind?'yesno':'up',up:Number(e.up_count??0),yes:Number(e.yes_count??0),no:Number(e.no_count??0),hidden:!!e.hidden,reply:e.reply??void 0,replyAt:e.reply_at??void 0,postedOn:String(e.posted_on??'').slice(0,10)}),wa='id,body,kind,up_count,yes_count,no_count,hidden,reply,reply_at,posted_on';function va(e){return{name:'hr_questions',table:'hr_questions',deletes:!1,list:()=>C.useHr.getState().questions.filter(t=>t.venue===e&&(0,re.isUuid)(t.id)),key:e=>e.id,rowKey:e=>String(e.id),syncable:()=>!1,writable:()=>!1,toRow:e=>({id:e.id}),fromRow:t=>ya(t,e),filter:e=>e.gte('posted_on',new Date(Date.now()-10368e6).toISOString().slice(0,10)),apply:(e,t)=>{const a=new Set(t);C.useHr.setState(t=>{const s=new Map(e.map(e=>[e.id,e])),n=t.questions.filter(e=>!a.has(e.id)).map(e=>s.get(e.id)??e),i=new Set(n.map(e=>e.id));return{questions:[...n,...e.filter(e=>!i.has(e.id))]}})},subscribe:e=>C.useHr.subscribe((t,a)=>{t.questions!==a.questions&&e()})}}function ba(e,t){const a=(t,a,s)=>{F.mutationQueue.enqueue({table:'hr_questions',venueId:e,kind:'rpc',fn:t,rowKey:a,values:s})};Object.assign(C.hrRemote,{live:!0,checkout:t=>a('hr_checkout',t.token,{p_venue:e,p_day:t.day,p_token:t.token,p_morale:t.morale,p_staffing:t.staffing,p_question:t.question??null,p_kind:t.kind??'up',p_shout_to:t.shoutTo??null,p_shout_body:t.shoutBody??null}),post:(t,s,n,i)=>a('hr_post_question',s,{p_venue:e,p_id:s,p_body:n,p_kind:i}),vote:(e,t,s)=>a('hr_vote',e,{p_question:e,p_token:t,p_vote:s}),moderate:(e,t,s)=>a('hr_moderate',e,{p_question:e,p_action:t,p_reason:s}),reply:(e,t)=>a('hr_reply',e,{p_question:e,p_reply:t}),trend:async(t,a,s)=>{try{const{data:t,error:n}=await Re().rpc('hr_trend',{p_venue:e,p_from:a,p_to:s});return n?null:(t??[]).map(e=>({day:String(e.day).slice(0,10),answers:Number(e.answers),morale:Number(e.morale),staffing:null==e.staffing?null:Number(e.staffing),short:Number(e.short),perfect:Number(e.perfect),over:Number(e.over)}))}catch{return null}},shouts:async(a,s)=>{try{const{data:a,error:n}=await Re().from('hr_shoutouts').select('id,day,to_name,body').eq('venue_id',e).gte('day',s).order('day',{ascending:!1}).limit(20);return n?null:(a??[]).map(e=>({id:String(e.id),venue:t,day:String(e.day).slice(0,10),to:String(e.to_name),body:e.body??void 0}))}catch{return null}},log:async()=>{try{const{data:a,error:s}=await Re().from('hr_mod_log').select('id,question_id,action,reason,by_name,at').eq('venue_id',e).order('at',{ascending:!1}).limit(30);return s?null:(a??[]).map(e=>({id:String(e.id),venue:t,questionId:String(e.question_id??''),action:e.action,reason:e.reason??void 0,by:String(e.by_name??'A manager'),at:String(e.at)}))}catch{return null}},refresh:async()=>{try{const{data:a,error:s}=await Re().from('hr_questions').select(wa).eq('venue_id',e).order('posted_on',{ascending:!1}).limit(200);s||C.useHr.getState().setRemoteBoard(t,(a??[]).map(e=>ya(e,t)))}catch{}}}),Pe.push(()=>{Object.assign(C.hrRemote,{live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null})})}const ka='pair:v1',Ia='staff:v1',Oa='staff:rejoin:v1';async function Ra(e){const t=d.IS_QUEUED_VENUE?'claim_'+d.VENUE_RID+'_invite':d.IS_GREENSIDE?'claim_greenside_invite':d.IS_ABBOTSFORD?'claim_abbotsford_invite':d.IS_KIRKTON?'claim_kirkton_invite':d.IS_WILDINGS?'claim_wildings_invite':d.IS_KIRKMICHAEL?'claim_kirkmichael_invite':d.IS_ISOLATED_VENUE?'claim_souters_invite':'claim_invite',a={p_token:e,p_app:Ee,p_device:(0,A.deviceId)()},s=await Re().rpc(t,{...a,p_phone:(0,A.phoneKey)()});return s.error&&('PGRST202'===s.error.code||/could not find the function/i.test(s.error.message))?Re().rpc(t,a):s}async function Aa(){if('display'===Ee||'customer'===Ee||fe.PITCH)return'none';const e=await q.kv.get(Oa,null);if(!e)return'none';try{await Da();const{data:t,error:a}=await Ra(e);if(a)return(0,O.inviteRefusal)(a.message)?(await q.kv.remove(Oa),await q.kv.remove(Ia),'refused'):'offline';const s=t?.[0];return s?(await q.kv.set(Ia,{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,displayName:s.display_name}),'ok'):(await q.kv.remove(Oa),'refused')}catch{return'offline'}}const Ca=e=>/jwt|refresh|token|401|not authenticated|invalid claim|session/i.test(String(e?.message??e))&&!/fetch|network/i.test(String(e?.message??e));async function Da(){Ne();const{data:e}=await Re().auth.getSession();if(!e.session)for(let e=0;;e++){const{error:t}=await Re().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}Ce({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 Ua(e){if(fe.PITCH)return{status:'refused',message:/^pitch-other-phone/.test(e)?(0,O.inviteRefusal)('already linked to another phone'):'This link has been replaced or switched off. Ask your manager for a new one.'};if(!(0,N.isSupabaseConfigured)())return{status:'off'};try{await Da();const{data:t,error:a}=await Ra(e);if(a){const e=(0,O.inviteRefusal)(a.message);if(e){try{localStorage.removeItem((0,d.venueKey)(`cc-pending-invite:${Ee}`))}catch{}return{status:'refused',message:e}}throw a}const s=t?.[0];if(!s)return{status:'refused',message:'This link has been replaced or switched off. Ask your manager for a new one.'};const n={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,displayName:s.display_name};return await q.kv.set(Ia,n),await q.kv.set(Oa,e),Me&&qa(),{status:'ok',id:n}}catch(e){const t=String(e?.message??e);return Ce({lastError:`Sign-in: ${t}`}),{status:'offline',message:t}}}const Ea='car:request:v1',Ta=e=>{const t=String(e?.message??e);return/fetch|network/i.test(t)?'No connection. Check the car has Wi-Fi or mobile data, then try again.':t.replace(/^.*?:\s*(?=[A-Z])/,'')};async function Na(){await q.kv.remove(ka),await q.kv.remove(Ia),await q.kv.remove(Ea),A.useSession.getState().meId&&A.useSession.getState().signOut()}async function Ka(){if(!(0,N.isSupabaseConfigured)())return!1;try{return await Da(),!0}catch{return!1}}const Pa=async(e,t={})=>{if(fe.PITCH)return(0,pe.pitchRpc)(e,t);const{data:a,error:s}=await Re().rpc(e,t);if(s)throw s;return a};let Ma=null;async function xa(){for(const e of Pe)try{e()}catch{}Pe=[],Ke.forEach(e=>e.stop()),Ke=[],Ma&&(clearInterval(Ma),Ma=null)}async function qa(){await xa(),await ja()}async function La(){if(!(0,N.isSupabaseConfigured)()||'customer'===Ee||fe.PITCH)return!1;try{Ne();const{data:e}=await Re().auth.getSession();if(e.session){const{error:e}=await Re().auth.refreshSession();if(!e)return!0}if('display'===Ee)return!1;if(!await q.kv.get(Oa,null))return!1;if(e.session)try{await Re().auth.signOut({scope:'local'})}catch{}return'ok'===await Aa()&&(qa(),!0)}catch{return!1}}(0,c.setSessionMender)(La);let Ba=d.VENUE_RID;async function ja(){try{const e='undefined'!=typeof navigator?navigator.storage:null;e?.persist&&e.persist()}catch{}try{const e='undefined'!=typeof window?window.CoverChargeNative:null;e&&'function'==typeof e.checkUpdate&&/CoverChargePhone\//.test(navigator.userAgent)&&e.checkUpdate()}catch{}const e=Ba;try{if(Ce({mode:'connecting'}),await F.mutationQueue.load(),'customer'===Ee)return void await Va(e);let t=await q.kv.get(ka,null),a=await q.kv.get(Ia,null);if(G.IS_CAR&&!t&&a){const e=(0,J.migrateCarStaffIdentity)(a);e&&(t=e,await q.kv.set(ka,t)),await q.kv.remove(Ia),a=null,A.useSession.getState().meId&&A.useSession.getState().signOut()}if(d.IS_ISOLATED_VENUE&&(t&&!(0,d.venueIdentityAllowed)(t.venueId,t.venueSlug)||a&&!(0,d.venueIdentityAllowed)(a.venueId,a.venueSlug)))return void Ce({mode:'display'===Ee?'unpaired':'signin',perms:[],message:'This sign-in belongs to a different venue.'});let{data:s}=await Re().auth.getSession();if('display'!==Ee&&!G.IS_CAR&&a&&!s.session){const t=await Aa();if('offline'===t)return Ce({venueId:a.venueId,venueSlug:a.venueSlug,venueName:a.venueName,kind:a.kind,role:a.role,staffRef:a.staffRef,staffUuid:a.staffUuid,mode:'offline'}),void setTimeout(()=>{Ba===e&&qa()},6e4);'refused'===t&&a.staffRef&&A.useSession.getState().meId===a.staffRef&&A.useSession.getState().signOut(),a=await q.kv.get(Ia,null),({data:s}=await Re().auth.getSession())}const n='display'===Ee||G.IS_CAR?t:a;if(!s.session||!n)return void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[]});let i=[];try{const e=(await Pa('whoami')??[]).filter(e=>e.venue_id===n.venueId);if(!e.length)return'display'===Ee||G.IS_CAR?await q.kv.remove(ka):(await q.kv.remove(Ia),await q.kv.remove(Oa)),'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId===n.staffRef&&A.useSession.getState().signOut(),void Ce({mode:'display'===Ee||G.IS_CAR?'unpaired':'signin',perms:[],message:'display'===Ee?'This display was unpaired by a manager.':G.IS_CAR?'This car was unpaired by an owner. Make a new code and approve it from Managers.':'Open your invite link again to connect.'});i=[...new Set(e.flatMap(e=>e.permissions??[]))],'device'===n.kind&&n.canWrite&&i.push('device.write')}catch(t){if(!(0,K.isOnline)()||/fetch|network/i.test(String(t?.message)))Ce({mode:'offline'});else if(Ca(t)&&'display'!==Ee){const{error:t}=await Re().auth.refreshSession();t&&'ok'===await Aa()&&setTimeout(()=>{Ba===e&&qa()},500)}i=Ae.getState().perms,'device'===n.kind&&n.canWrite&&!i.includes('device.write')&&(i=[...i,'device.write'])}Ce({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,kind:n.kind,role:n.role,staffRef:n.staffRef,staffUuid:n.staffUuid,perms:i}),!G.IS_CAR&&'staff'===n.kind&&n.staffRef&&A.useSession.getState().meId!==n.staffRef&&(A.useSession.getState().signIn(n.staffRef),ie.useOwner.setState({staffAs:n.staffRef})),G.IS_CAR&&(A.useSession.getState().meId&&A.useSession.getState().signOut(),ie.useOwner.setState({previewRole:'owner'})),await $a(n.venueId,e,n.kind)}catch(e){Ce({mode:'local',lastError:String(e?.message??e)})}}const Fa=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','venue_reminders','reminder_done']);async function $a(e,a,s){if(!(0,d.venueIdentityAllowed)(e,a))throw new Error('Different venue: sync refused.');const n='staff'===s||G.IS_CAR&&'device'===s;await ws(a),Pe.push(Ks(e));try{const{data:t}=await Re().from('roles').select('id,key').eq('venue_id',e);for(const e of t??[])mt.set(e.key,e.id),_t.set(e.id,e.key)}catch{}const i=[Pt(a),{protect:!0,name:'staff',table:'staff',conflict:'venue_id,external_ref',list:()=>ie.useOwner.getState().staff.map(vt),key:e=>e.id,rowKey:e=>String(e.external_ref??e.id),syncable:e=>!e.name.includes('(example)'),writable:()=>De('staff.manage'),deletes:!1,revision:e=>(0,j.staffRevision)(e,wt()),toRow:(e,t)=>(0,j.staffRow)(e,t,wt(),e.managerAccess||e.ownerAccess?null:mt.get(St(e))),fromRow:e=>{if(!e.external_ref)return null;pt.set(String(e.external_ref),String(e.id)),gt.set(String(e.id),String(e.external_ref)),Us.set(String(e.external_ref),e.avatar_path??null);const t=yt(ht(_t.get(String(e.role_id))),!0===e.manager_access);return(0,j.staffSyncItem)({id:String(e.external_ref),name:e.display_name,job:e.job_title??'',active:!1!==e.active,dept:e.department??'',nickname:e.nickname??null,displayClock:!!e.display_clock,temp:!!e.temp,tempUntil:e.temp_until??null,...t,ownerAccess:!0===e.owner_access,bookingWrite:'boolean'==typeof e.can_change_bookings?e.can_change_bookings:void 0},wt())},apply:e=>ie.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=>ie.useOwner.subscribe((t,a)=>{t.staff!==a.staff&&e()}),afterRead:()=>{Ns()},onRemote:()=>{Ns()}},{name:'pay',table:'staff_private',conflict:'staff_id',list:()=>{const e=ie.useOwner.getState(),t=ae.useSetup.getState().sites[Ba]?.staffGrade??{};return e.staff.filter(e=>pt.has(e.id)).map(a=>je({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=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('wages.manage'),deletes:!1,toRow:(e,t)=>({staff_id:pt.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=gt.get(String(e.staff_id));return t?je({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=>ie.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=ae.useSetup.getState().sites[Ba],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&&ae.useSetup.getState().patch(Ba,{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=ie.useOwner.subscribe((t,a)=>{t.hourly===a.hourly&&t.staff===a.staff||e()}),a=ae.useSetup.subscribe((t,a)=>{t.sites[Ba]?.staffGrade!==a.sites[Ba]?.staffGrade&&e()});return()=>{t(),a()}}},Fe(a,!1),Fe(a,!0),We(a),Ve(a),$e(a),Ge(a),et(a),tt(a),ct(a),{name:'supplier_directory',table:'suppliers',list:()=>ie.useOwner.getState().suppliers,key:e=>e.id,rowKey:e=>String(e.doc?.localId??e.id),syncable:e=>(0,re.isUuid)(e.id),writable:()=>De('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:je(e)}}),fromRow:e=>'directory'===e.doc?.kind?e.doc.supplier:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.suppliers.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{suppliers:[...i,...e.filter(e=>!r.has(e.id))]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.suppliers!==a.suppliers&&e()})},{name:'supplier_orders',table:'supplier_orders',list:()=>ie.useOwner.getState().supplierOrders,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId),writable:()=>De('suppliers.order')||De('suppliers.manage'),toRow:(e,t)=>({id:e.id,venue_id:t,supplier_id:e.supplierId,order_date:e.date||xe(),items:[{text:e.items}],amount:Math.round(e.amount||0),status:'sent',by_name:e.by,doc:je(e)}),fromRow:e=>e.doc?{...e.doc,id:String(e.id)}:null,apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.supplierOrders.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{supplierOrders:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.supplierOrders!==a.supplierOrders&&e()})},st(a),As(a)];De('wages.view')&&i.push(Cs(a)),n&&(i.push(At(!0),Ct(),Dt(),Tt(a)),Et(e)),n&&await fa('staff_leave')&&(i.push({name:'staff_leave',table:'staff_leave',mode:'insert',deletes:!1,list:()=>ie.useOwner.getState().leave,key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>(0,re.isUuid)(e.id)&&/^\d{4}-\d{2}-\d{2}$/.test(e.from)&&/^\d{4}-\d{2}-\d{2}$/.test(e.to)&&e.to>=e.from&&(e.staffId===Ae.getState().staffRef&&'pending'===e.status||De('rota.manage')),writable:()=>'staff'===Ae.getState().kind,toRow:(e,t)=>({id:e.id,venue_id:t,staff_ref:e.staffId,from_date:e.from,to_date:e.to,reason:(e.reason??'').slice(0,200)||null,status:e.status,doc:je(e)}),fromRow:e=>{const t=e.doc??{};return{...t,id:String(e.id),staffId:String(e.staff_ref),from:String(e.from_date).slice(0,10),to:String(e.to_date).slice(0,10),reason:e.reason??t.reason??'Holiday',status:e.status,by:e.requested_by_name??t.by,decidedBy:e.decided_by_name??void 0}},apply:(e,t)=>ie.useOwner.setState(a=>{const s=new Set(t),n=new Map(e.map(e=>[e.id,e])),i=a.leave.filter(e=>!s.has(e.id)).map(e=>n.get(e.id)??e),r=new Set(i.map(e=>e.id));return{leave:[...e.filter(e=>!r.has(e.id)),...i]}}),subscribe:e=>ie.useOwner.subscribe((t,a)=>{t.leave!==a.leave&&e()})}),Fa.add('staff_leave'),Ut(e));const o=n&&await ha();if(Se.useChatSync.setState({synced:o,checked:!0}),Pe.push(()=>Se.useChatSync.setState({synced:!1})),o&&i.push(Ft(),{name:'chat_extra',table:'chat_channel_extra',conflict:'venue_id,channel,staff_id',list:()=>Object.entries(he.useKitchenExtra.getState().extra).map(([e,t])=>({id:e,include:t})),key:e=>e.id,rowKey:e=>gt.get(String(e.staff_id))??String(e.staff_id),syncable:e=>pt.has(e.id),writable:()=>De('staff.manage'),filter:e=>e.eq('channel','kitchen'),matchKey:e=>({channel:'kitchen',staff_id:pt.get(e)??e}),toRow:(e,t)=>({venue_id:t,channel:'kitchen',staff_id:pt.get(e.id),include:e.include}),fromRow:e=>{const t=gt.get(String(e.staff_id));return t?{id:t,include:!!e.include}:null},apply:(e,t)=>he.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=>he.useKitchenExtra.subscribe((t,a)=>{t.extra!==a.extra&&e()})}),n&&await fa('hr_questions')&&(i.push(va(a)),Fa.add('hr_questions'),ba(e,a)),'guest'!==s&&'customer'!==Ee&&await fa('temp_readings')&&(i.push((0,Q.tempUnitsSpec)(ne.useSafety,Ye),(0,Q.tempReadingsSpec)(ne.useSafety,Xe)),Fa.add('temp_units'),Fa.add('temp_readings')),'guest'!==s&&await fa('sold_out_items')?(i.push(ca(a,await fa('sold_out_items','auto'))),Fa.add('sold_out_items')):ve.autoSync.soldOutRead.add(a),'guest'!==s&&await fa('sold_out_links')?(i.push(la(a)),Fa.add('sold_out_links')):ve.autoSync.linksRead.add(a),D.useReminders.getState().ensure(a),'guest'!==s&&await Sa()&&(i.push(Qt(a)),n&&i.push(Ht(a))),oe.useNotifs.getState().ensure(a),ue.useOrderLists.getState().ensure(a),n){lt=await fa('staff','nickname'),ft=await fa('staff','display_clock');const[e,t,s,n]=await Promise.all([fa('scheduled_notifications'),fa('order_lists'),fa('venue_clock_area'),fa('daily_tasks')]);me.useDailyTasks.getState().ensure(a),n&&(i.push(da(a),ua(a)),Fa.add('daily_tasks'),Fa.add('daily_task_ticks')),e&&(i.push(sa(a)),pa()),t&&i.push(na(a),ia(a),ra(a)),s&&i.push(oa(a));for(const[a,n]of[[e,'scheduled_notifications'],[t,'order_lists'],[t,'order_list_items'],[t,'order_list_history'],[s,'venue_clock_area']])a&&Fa.add(n)}if('guest'!==s&&await fa('day_tips')){i.push(ea(a));for(const e of['day_tips','tips_pot_events','tips_settings'])Fa.add(e);await fa('tips_pot_events')&&i.push(ta(a),aa(a)),n&&(zt()||(0,de.forgetPastTakings)(a,(0,b.tradingDay)()),i.push(Zt(a),Xt(a)),Fa.add('cash_ups'),zt()&&(i.push(Yt(a)),Fa.add('sales_reports')),t(r[73])(r[72],r.paths).then(e=>e.refreshCashAccess()))}'device'!==s||n||(i.push(At(),Ct()),await fa('scheduled_notifications')&&i.push(sa(a)));let u=!1;const c=()=>{if(G.IS_CAR&&n&&De('recipes.edit'))return!0;const e=ie.useOwner.getState().staff.find(e=>e.id===Ae.getState().staffRef);return!!e&&e.active&&De('recipes.edit')&&(0,S.costsAllowedFor)(e)};n&&c()&&await fa('ingredient_prices')&&(i.push((0,_.gpSyncSpec)('ing',c)),Fa.add('ingredient_prices'),await fa('card_costs')&&(i.push((0,_.gpSyncSpec)('card',c)),Fa.add('card_costs')),await fa('kitchen_deliveries')&&(i.push((0,_.gpSyncSpec)('del',c)),Fa.add('kitchen_deliveries')),await fa('kitchen_stock_counts')&&(i.push((0,_.gpSyncSpec)('count',c)),Fa.add('kitchen_stock_counts'))),(0,Oe.specialsSyncOn)()&&'guest'!==s&&await fa('specials_boards')&&(i.push((0,Oe.specialsBoardSpec)(a,()=>De('recipes.edit')||De('floor.manage')||De('*'))),Fa.add('specials_boards'));const l={onActivity:()=>Ce({lastSyncAt:(new Date).toISOString()}),onError:(e,t)=>Ce({lastError:`${e}: ${t}`}),onSuspect:(t,s)=>{Ce({lastError:`${t}: held back, ${s}`}),u||(u=!0,(async()=>{try{if(!(await Pa('whoami')??[]).some(t=>t.venue_id===e))return void(Ba===a&&qa());for(const a of Ke){if(a.spec.name!==t)continue;const{count:s,error:n}=await Re().from(a.spec.table).select('*',{count:'exact',head:!0}).eq(a.spec.venueColumn??'venue_id',e);!n&&(s??0)>0&&a.allowMassRemoveOnce()}}catch{}finally{u=!1}})())},onSkipped:(e,t)=>{'bookings'!==e&&'walk_ins'!==e||$.useBookingSaves.getState().mark({id:t,table:e,why:is()??'this screen could not send it'}),'temp_readings'!==e&&'temp_units'!==e||W.useTempSaves.getState().mark({id:t,table:e,why:gs(e)??'this screen could not send it'})}};Ke=i.map(t=>new H.EntityBridge(t,e,l)),await Promise.all(Ke.map(e=>e.start()));let f=0;const p=async()=>{if(!(f&&Date.now()-f<6e4)){f=Date.now();try{await g()}finally{f=0}}},g=async()=>{if(n&&(0,K.isOnline)())try{const t=await Pa('whoami');if(!t?.some(t=>t.venue_id===e))return void(Ba===a&&qa())}catch(e){if(Ca(e)){if(G.IS_CAR)return void(Ba===a&&qa());const e=await Aa();return void('ok'!==e&&'refused'!==e||Ba===a&&qa())}}let t=0;for(const[a,s]of Ke.entries()){const n='chat'===i[a]?.name;try{await s.read(),t++,n&&(Se.useChatSync.getState().error&&Se.useChatSync.setState({error:void 0}),await Wt(e))}catch(e){const t=String(e?.message??e);if((n||/fetch|network|Failed/i.test(t))&&Se.useChatSync.setState({error:t||'unknown error'}),/fetch|network|Failed/i.test(t))break}}if(t){const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({mode:'live',lastSyncAt:e,lastServerAt:e}),F.mutationQueue.flush()}else Ce({mode:'offline'});if(!De('wages.view')){const e=Ae.getState().staffRef;ie.useOwner.setState(t=>({hourly:e&&null!=t.hourly[e]?{[e]:t.hourly[e]}:{}}))}};await Promise.race([p(),new Promise(e=>setTimeout(e,3e4))]);const m=new Map;for(const e of Ke)m.set(e.spec.table,[...m.get(e.spec.table)??[],e]);const h=[...m.keys()].filter(e=>Fa.has(e)).map(e=>({table:e,venueColumn:m.get(e)[0].spec.venueColumn}));let y=!1;const w=(0,H.venueChannel)(e,h,(e,t,a)=>{for(const s of m.get(e)??[])s.remote(t,a);const s=(new Date).toISOString();Ce({lastSyncAt:s,lastServerAt:s})},e=>{Ce({realtime:e}),'SUBSCRIBED'===e?(y&&p(),y=!1):'CHANNEL_ERROR'!==e&&'TIMED_OUT'!==e&&'CLOSED'!==e||(y=!0)});Pe.push(()=>{Re().removeChannel(w)}),Pe.push((0,K.onConnectivity)(e=>{e&&p()}));const v=Ke.filter(e=>'bookings'===e.spec.table||'walk_ins'===e.spec.table),k=(0,P.superviseSync)({fastMs:Qa(Ee),readFast:async()=>{for(const e of v)await e.read()},readAll:p,flush:()=>{F.mutationQueue.flush()},wake:()=>{F.mutationQueue.retryNow()},restart:()=>{Ba===a&&qa()},realtime:()=>Ae.getState().realtime,lastServerAt:()=>{const e=Ae.getState().lastServerAt;return e?Date.parse(e):0},markServer:()=>{const e=(new Date).toISOString();(0,K.setOnline)(!0),Ce({lastSyncAt:e,lastServerAt:e,mode:'live'})},isAuthError:Ca,refreshAuth:async()=>{await Re().auth.refreshSession()},heartbeat:()=>Wa(e),doc:'undefined'!=typeof document?document:null,win:'undefined'!=typeof window?window:null});Pe.push(k.stop)}async function Wa(e){const t=Ae.getState(),a='undefined'!=typeof navigator?String(navigator.userAgent??''):'';await Pa('sync_heartbeat',{p_venue:e,p_device:(0,A.deviceId)()??'unknown',p_app:Ee,p_version:x.APP_VERSION,p_last_synced_at:t.lastServerAt??null,p_realtime:t.realtime??null,p_pending:(t.waiting??0)+(t.pending??0),p_failed:t.failed??0,p_user_agent:a.slice(0,300)})}const Qa=e=>'display'===e?15e3:3e4;'undefined'!=typeof window&&(window.__ccSync=()=>({...Ae.getState(),queue:F.mutationQueue.pending.map(e=>e.table),failedTables:F.mutationQueue.failed.map(e=>`${e.table}: ${e.lastError??''}`.slice(0,200))}),fe.PITCH&&(window.__ccSyncPreview=e=>Ce(e)));const Ha='guest:sent:v1';async function Va(e){Ce({kind:'guest',venueSlug:e,perms:[]});try{const t=(await Pa('public_venue',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)}))?.[0];if(t&&(!d.IS_ISOLATED_VENUE||t.id===d.VENUE_UUID)){Ce({venueId:t.id,venueName:t.name}),await ws(e);const a=t.app?.restaurant;a&&V.useStore.setState(t=>({restaurants:t.restaurants.map(t=>t.id===e?(0,f.withWildingsAddress)({...a,id:e}):t)})),Kt(e,t.app?.events)}await Ga(e),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}catch{Ce({mode:(0,K.isOnline)()?'local':'offline'})}const t=setInterval(()=>{Ga(e).catch(()=>{})},6e4);Pe.push(()=>clearInterval(t)),d.IS_ISOLATED_VENUE||await Ja(e)}async function Ga(e){const t=await Pa('public_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];if(t.length){const a=new Map(t.map(e=>[String(e.menu_item_id??e.doc?.item?.id??''),e]));X.useCardStore.setState(t=>({cards:t.cards.map(t=>{if(t.restaurantId!==e)return t;const s=a.get(t.menuItemId);if(!s)return t.signOff?{...t,signOff:null}:t;const n=s.updated_at?new Date(s.updated_at).toISOString():t.updatedAt;return{...t,photo:s.photo_url||void 0,signOff:t.signOff??{by:'Head chef',at:n}}})}))}const a=t.map(e=>e.doc?.item).filter(e=>!!e&&!!e.id).map(t=>({...t,restaurantId:e}));a.length&&V.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))]}});try{const t=await Pa('public_takeaway_menu',{p_venue_slug:(0,l.queuedDatabaseSlug)(e)})??[];o.useTakeawayMenu.getState().set(e,{on:t.filter(e=>e.on_menu).map(e=>String(e.item_id)),soldOut:t.filter(e=>e.sold_out).map(e=>String(e.item_id)),at:(new Date).toISOString()})}catch{}}async function Ja(e){let t=await q.kv.get(Ha,{}),a=!1;const s=new Date(Date.now()-1728e5).toISOString(),n=async()=>{if(!a){a=!0;try{const a=V.useStore.getState(),n=a.bookings.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!a.walkIn&&!t[a.id]&&a.createdAt>=s),i=a.orders.filter(a=>a.restaurantId===e&&(0,re.isUuid)(a.id)&&!t[a.id]&&a.createdAt>=s&&'table'!==a.type);if(n.length||i.length){if(!await Ka())return;for(const a of n)try{const s=(await Pa('guest_create_booking',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_booking:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(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&&V.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'},Ce({lastError:`Booking: ${e?.message}`}))}for(const a of i)try{const s=(await Pa('guest_create_takeaway',{p_venue_slug:(0,l.queuedDatabaseSlug)(e),p_order:{...je(a),...(0,I.takeGuard)(a.id),allergies:Be(a.allergies)}}))?.[0];t={...t,[a.id]:'order'},s&&V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?Za(e,s):e)}))}catch(e){const s=String(e?.message??'');/fetch|network/i.test(s)||(t={...t,[a.id]:'failed'},Ce({lastError:`Order: ${s}`}),V.useStore.setState(e=>({orders:e.orders.map(e=>e.id===a.id?{...e,status:'cancelled',payment:{state:'refused',error:Ya(s)}}:e)})))}await q.kv.set(Ha,t)}for(const e of a.bookings)if('booking'===t[e.id]&&'cancelled'===e.status)try{await Pa('guest_cancel_booking',{p_id:e.id}),t={...t,[e.id]:'cancelled'},await q.kv.set(Ha,t)}catch{}if(Object.values(t).some(e=>'booking'===e||'order'===e)){const e=await Pa('guest_my_items')??[],t=new Map(e.map(e=>[String(e.id),e]));V.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=Za(e,a);return za(s)===za(e)?e:s})})),Ce({mode:'live',lastSyncAt:(new Date).toISOString()})}}catch{Ce({mode:(0,K.isOnline)()?Ae.getState().mode:'offline'})}finally{a=!1}}};Pe.push(V.useStore.subscribe((e,t)=>{e.bookings===t.bookings&&e.orders===t.orders||setTimeout(()=>{n()},200)})),Ma=setInterval(()=>{n()},15e3),Xa=()=>{n()},n()}const za=e=>JSON.stringify([e.status,e.readyBy,e.accepted,e.payment,e.total,e.paid,e.ref]);function Za(e,t){const a=t.doc??{},s=(e,t)=>'number'==typeof e&&Number.isFinite(e)?e:t;return{...e,status:t.status??a.status??e.status,readyBy:a.readyBy??e.readyBy,accepted:a.accepted??e.accepted,...a.payment?{payment:a.payment}:{},...Array.isArray(a.lines)&&a.lines.length?{lines:a.lines}:{},subtotal:s(a.subtotal,e.subtotal),total:s(a.total,e.total),paid:s(a.paid,e.paid),tip:s(a.tip,e.tip),giftCardApplied:s(a.giftCardApplied,e.giftCardApplied),ref:'string'==typeof a.ref&&a.ref?a.ref:'string'==typeof t.ref&&t.ref?t.ref:e.ref}}const Ya=e=>{const t=e.replace(/^.*?:\s*(?=[A-Z])/,'').trim();return/^[A-Z][^{}<>]{3,200}[.!?]$/.test(t)?t:'The restaurant\u2019s system couldn\u2019t take this order. Nothing has been charged. Please try again or ring the restaurant.'};let Xa=null;const es={bridges:()=>Ke,restart:qa};function ts(){const e=Ae.getState();return'offline'===e.mode?'there is no connection right now. It saves by itself when the connection is back':'live'!==e.mode&&'connecting'!==e.mode?'this screen is not connected to the shared venue':'guest'===e.kind||'device'===e.kind&&!De('device.write')?'this screen can only read. A manager can allow changes for it in Managers':null}function as(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(!e||ts())return 0;const t=new Date(Date.now()-2592e5).toISOString();let a=0;for(const s of[...e.spec.list()].sort((e,t)=>e.at.localeCompare(t.at)))s.at'stock_events'===e.table&&e.rowKey===s.id)&&e.spec.syncable(s)&&(F.mutationQueue.enqueue({table:'stock_events',venueId:e.venueId,kind:'insert',rowKey:s.id,values:e.spec.toRow(s,e.venueId),conflictKey:'id'}),a++);return a}async function ss(){const e=Ke.find(e=>'stock_events'===e.spec.table);if(e)try{await e.read()}catch{}as();try{await F.mutationQueue.retryNow()}catch{}}Ae.subscribe((e,t)=>{e.perms!==t.perms&&e.perms.includes('device.write')&&!t.perms.includes('device.write')&&setTimeout(()=>{ss()},3e3)});const ns=['bookings','walk_ins'];function is(){const e=Ae.getState();return Ue()?'guest'===e.kind?'this screen can only read bookings, so the change would stay on this screen only':'device'!==e.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'unpaired'===e.mode||'signin'===e.mode?'this screen is not connected to the venue, so the change would stay on this screen only':null}const rs=()=>Ke.filter(e=>ns.includes(e.spec.table)),os=e=>F.mutationQueue.failed.some(t=>ns.includes(t.table)&&t.rowKey===e);function ds(e=!1){return is()?0:rs().reduce((t,a)=>t+a.resendUnsaved(t=>!e&&os(t)&&!!$.useBookingSaves.getState().notSaved[t]),0)}async function us(e=!1){const t=is();if(t)return t;for(const e of rs())try{await e.read()}catch{}ds(e);try{await F.mutationQueue.retryNow()}catch{}return e&&cs(),null}function cs(){const e=rs()[0]?.venueId??'',t=$.useBookingSaves.getState(),a=new Set(rs().flatMap(e=>e.unsavedKeys()));for(const s of Object.keys(t.notSaved))a.has(s)||os(s)||ns.some(t=>F.mutationQueue.hasPending(t,e,s))||t.clear(s)}F.mutationQueue.onFailed(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ns.includes(e.table)&&$.useBookingSaves.getState().clear(e.rowKey)});let ls=null;const fs=(e=2500)=>{ls&&clearTimeout(ls),ls=setTimeout(()=>{ls=null,us(!1)},e)};(0,K.onConnectivity)(e=>{e&&fs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&fs(3e3)});const ps=['temp_readings','temp_units'];function gs(e="temp_readings"){const t=Ae.getState();return Ue()?'guest'===t.kind?'this screen can only read the food safety log':'temp_units'!==e||Ye()?'device'!==t.kind||De('device.write')?null:'this screen can only read. A manager can allow changes for it in Managers \u203a Displays':'only the Head Chef, managers and owners can change the units':'unpaired'===t.mode||'signin'===t.mode?'this screen is not connected to the venue, so it is kept on this screen only':null}const ms=()=>Ke.filter(e=>ps.includes(e.spec.table));async function _s(e=!1){const t=gs();if(t)return t;for(const e of ms())try{await e.read()}catch{}const a=ms()[0]?.venueId??'';for(const t of ms())t.resendUnsaved(a=>{return!e&&(s=t.spec.table,n=a,F.mutationQueue.failed.some(e=>e.table===s&&e.rowKey===n));var s,n});try{await F.mutationQueue.retryNow()}catch{}if(e){const e=W.useTempSaves.getState();for(const t of Object.values(e.notSaved)){const s=ms().find(e=>e.spec.table===t.table);!s||s.unsavedKeys().includes(t.id)||F.mutationQueue.hasPending(t.table,a,t.id)||e.clear((0,W.tempKey)(t.table,t.id))}}return null}F.mutationQueue.onFailed(e=>{ps.includes(e.table)&&W.useTempSaves.getState().mark({id:e.rowKey,table:e.table,why:(0,B.plainReason)({...e.lastErr,message:e.lastErr?.message??e.lastError},'refused')})}),F.mutationQueue.onDone(e=>{ps.includes(e.table)&&W.useTempSaves.getState().clear((0,W.tempKey)(e.table,e.rowKey))});let Ss=null;const hs=(e=3e3)=>{Ss&&clearTimeout(Ss),Ss=setTimeout(()=>{Ss=null,_s(!1)},e)};(0,K.onConnectivity)(e=>{e&&hs()}),Ae.subscribe((e,t)=>{('live'===e.mode&&'live'!==t.mode||e.perms!==t.perms&&De('device.write')&&!t.perms.includes('device.write')&&!t.perms.includes('*'))&&hs(3500)});const ys='golive:v1:';async function ws(e){'live'!==V.useStore.getState().clock.mode&&V.useStore.setState({clock:{mode:'live',simStartMs:Date.now(),anchorRealMs:Date.now()}}),p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)?await Os(e):(await q.kv.get(ys+e,!1)||await Os(e),await q.kv.get(ks+e,!1)||(Is(e),await q.kv.set(ks+e,!0)),await q.kv.get(vs+e,!1)||(bs(),await q.kv.set(vs+e,!0)))}const vs='golive:v3:';function bs(){const e=e=>JSON.stringify(e).includes('(example)');try{se.useKitchen.setState(t=>({waste:t.waste.filter(t=>!e(t)),stockTakes:t.stockTakes.filter(t=>!e(t)),deliveries:t.deliveries.filter(e=>'dl-today-fish'!==e.id&&'dl-today-veg'!==e.id)}))}catch{}}const ks='golive:v2:';function Is(e){const t=e=>JSON.stringify(e).includes('(example)');V.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)))})),ie.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 Os(e){if(p.LIVE_VENUE_BUILD&&(0,p.isLiveVenue)(e)){const t=(0,g.stripCoreLiveSamples)(V.useStore.getState()),a=(0,se.stripKitchenExamples)(se.useKitchen.getState()),s=ie.useOwner.getState(),n=(0,g.stripOwnerLiveSamples)(s),i={accidents:ne.useSafety.getState().accidents.filter(e=>!(0,ne.isSeedAccident)(e))},r=(e,t)=>Object.keys(t).some(a=>JSON.stringify(e[a])!==JSON.stringify(t[a]));r(V.useStore.getState(),t)&&(await(0,m.archiveChefCache)('core',V.useStore.getState()),V.useStore.setState(t)),r(se.useKitchen.getState(),a)&&(await(0,m.archiveChefCache)('kitchen',se.useKitchen.getState()),se.useKitchen.setState(a)),r(s,n)&&(await(0,m.archiveChefCache)('owner',s),ie.useOwner.setState(n)),r(ne.useSafety.getState(),i)&&(await(0,m.archiveChefCache)('safety',ne.useSafety.getState()),ne.useSafety.setState(i));const o=(0,C.stripHrSamples)(C.useHr.getState());r(C.useHr.getState(),o)&&(await(0,m.archiveChefCache)('hr',C.useHr.getState()),C.useHr.setState(o));const d=(0,_.stripGpSamples)(_.useGpCalc.getState());r(_.useGpCalc.getState(),d)&&(await(0,m.archiveChefCache)('gp',_.useGpCalc.getState()),_.useGpCalc.setState(d));const u=ee.useOrderSheets.getState(),c={sheets:{...u.sheets,anchorage:(u.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}};r(u,c)&&(await(0,m.archiveChefCache)('order-sheets',u),ee.useOrderSheets.setState(c));const l=X.useCardStore.getState(),f={cards:l.cards.filter(e=>!(0,p.isLiveVenue)(e.restaurantId)||!(0,y.isDemoCard)(e)),log:l.log.filter(e=>!(0,y.demoActor)(e.by))};return r(l,f)&&(await(0,m.archiveChefCache)('recipe-cards',l),X.useCardStore.setState(f)),void await q.kv.set(ys+e,!0)}const t=t=>t.restaurantId===e&&!(0,re.isUuid)(t.id);V.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)))})),z.useBlocks.setState(t=>({blocks:t.blocks.filter(t=>t.rid!==e||(0,re.isUuid)(t.id))})),Z.useFloor.setState(t=>({live:{...t.live,[e]:{}}})),ie.useOwner.setState(e=>({shifts:e.shifts.filter(e=>(0,re.isUuid)(e.id)),attendance:e.attendance.filter(e=>(0,re.isUuid)(e.id)),timeRequests:e.timeRequests.filter(e=>(0,re.isUuid)(e.id)),leave:e.leave.filter(e=>(0,re.isUuid)(e.id)),swaps:[]}));try{se.useKitchen.setState(e=>(0,se.stripKitchenExamples)(e))}catch{}ie.useOwner.setState(e=>({suppliers:e.suppliers.filter(e=>(0,re.isUuid)(e.id)),supplierOrders:e.supplierOrders.filter(e=>(0,re.isUuid)(e.id)&&(0,re.isUuid)(e.supplierId))}));try{ne.useSafety.setState(e=>({accidents:e.accidents.filter(e=>{return!String(e.id).startsWith('acc-ex')&&(t=e,!JSON.stringify(t).includes('(example)'));var t})}))}catch{}await q.kv.set(ys+e,!0)}const Rs=(e,t)=>je({name:e,stage:t.stage||void 0,dirty:t.dirty||void 0,blocked:t.blocked||void 0,note:t.note||void 0});function As(e){return{name:'floor_live',table:'floor_live',conflict:'venue_id,table_name',list:()=>Object.entries(Z.useFloor.getState().live[e]??{}).map(([e,t])=>Rs(e,t)),key:e=>e.name,rowKey:e=>String(e.table_name),syncable:e=>e.name.length>0&&e.name.length<=20,writable:()=>'staff'===Ae.getState().kind||De('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:(0,J.actorStamp)({isCar:G.IS_CAR,kind:Ae.getState().kind,staffRef:Ae.getState().staffRef,fallback:Ee})}),fromRow:e=>Rs(String(e.table_name),{stage:e.stage??void 0,dirty:!!e.dirty,blocked:!!e.blocked,note:e.note??void 0}),apply:(t,a)=>Z.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=>Z.useFloor.subscribe((t,a)=>{t.live!==a.live&&e()})}}function Cs(e){return{name:'pay_grades',table:'pay_grades',conflict:'venue_id,grade_id',list:()=>(ae.useSetup.getState().sites[e]?.grades??ae.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:()=>De('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=ae.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 i=[...n.values()].sort((e,t)=>e.sort-t.sort).map(e=>({id:e.id,name:e.name,pence:e.pence}));ae.useSetup.getState().patch(e,{grades:i})},subscribe:t=>ae.useSetup.subscribe((a,s)=>{a.sites[e]?.grades!==s.sites[e]?.grades&&t()})}}const Ds='staff-avatars',Us=new Map;let Es=!1;const Ts=e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>t(String(s.result)),s.onerror=a,s.readAsDataURL(e)});async function Ns(){if(!Es){Es=!0;try{for(const[e,t]of Us){const a=te.useAvatars.getState().photos[e];if(!t){a?.path&&te.useAvatars.setState(t=>{const a={...t.photos};return delete a[e],{photos:a}});continue}if(a?.path===t)continue;if(a&&!a.path&&e===Ae.getState().staffRef)continue;const{data:s,error:n}=await Re().storage.from(Ds).download(t);if(n||!s)continue;const i=await Ts(s);i.startsWith('data:image/')&&te.useAvatars.setState(a=>({photos:{...a.photos,[e]:{dataUrl:i,at:(new Date).toISOString(),path:t}}}))}}catch{}finally{Es=!1}}}function Ks(e){const t=async()=>{const t=Ae.getState().staffRef,a=t?pt.get(t)??Ae.getState().staffUuid:void 0;if(!t||!a||'staff'!==Ae.getState().kind)return;const s=te.useAvatars.getState().photos[t];try{const n=Us.get(t),i=t=>{t&&t.startsWith(`${e}/${a}-`)&&Re().storage.from(Ds).remove([t]).catch(()=>{})};if(!s){const e=!!te.useAvatars.getState().clears?.[t];return e&&n&&(await Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}),Us.set(t,null),i(n)),void(e&&te.useAvatars.getState().doneClear(t))}if(s.path)return;const r=await(await fetch(s.dataUrl)).blob();if(r.size>512e3)return void Ce({lastError:'Avatar: picture too large to share'});const o='image/jpeg'===r.type?'jpg':'image/webp'===r.type?'webp':'png',d=`${e}/${a}-${Date.now().toString(36)}.${o}`,{error:u}=await Re().storage.from(Ds).upload(d,r,{upsert:!1,contentType:r.type||'image/png'});if(u)throw u;await Pa('set_staff_avatar',{p_staff_ref:t,p_path:d}),Us.set(t,d),n!==d&&i(n),te.useAvatars.setState(e=>e.photos[t]?.dataUrl===s.dataUrl?{photos:{...e.photos,[t]:{...s,path:d}}}:e)}catch(e){Ce({lastError:`Avatar: ${String(e?.message??e)}`})}},a={photos:te.useAvatars.getState().photos},s=te.useAvatars.subscribe(e=>{const s=a.photos;if(a.photos=e.photos,t(),De('staff.manage'))for(const t of Object.keys(s))if(!e.photos[t]&&s[t]?.path&&t!==Ae.getState().staffRef&&e.clears?.[t]){const e=s[t].path;Us.set(t,null),te.useAvatars.getState().doneClear(t),Pa('set_staff_avatar',{p_staff_ref:t,p_path:null}).then(()=>Re().storage.from(Ds).remove([e])).catch(()=>{})}});return t(),s}const Ps=new Map,Ms=(0,E.create)(()=>({n:0}))},987,[988,5,989,932,6,832,837,833,838,990,994,995,835,997,999,1000,1001,1002,1003,13,1004,1006,1009,1010,846,933,976,1011,1012,1013,1016,977,1017,1015,1020,1014,1021,1022,1023,1024,831,872,1025,1026,1029,983,883,1031,926,927,1033,1034,891,870,1036,1039,1040,1041,1042,2,1043,1044,1045,1046,1047,1048,979,981,884,863,859,1049,1052,1053]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_WINDOW_MINS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ALLERGEN_LINE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"allergyPhoneLine",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useTakeawayMenu",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"takesCardTakeaway",{enumerable:!0,get:function(){return s}}),e.takeawayAvail=function(t,n){return t.hidden||!t.signOff||null==t.price||t.price<=0?'off':n&&n.on.includes(t.id)?t.soldOut||n.soldOut.includes(t.id)?'sold-out':'on':'off'},e.payView=function(t,n){if('takeaway'!==t.type)return{kind:'none'};const r=t.payment;if('refused'===r?.state)return{kind:'refused',reason:r.error||'The restaurant could not take this order.'};if('paid'===r?.state)return{kind:'paid',amount:r.paidPence??t.paid,late:!!r.late};if('expired'===r?.state||'cancelled'===t.status&&'waiting'===r?.state)return{kind:'expired'};if('awaiting_payment'!==t.status)return{kind:'none'};if(!r?.expiresAt)return{kind:'sending'};const o=Math.floor((Date.parse(r.expiresAt)-n)/1e3);return o>0?{kind:'pay',secondsLeft:o,expiresAt:r.expiresAt}:{kind:'expired'}},Object.defineProperty(e,"mmss",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"paidBadge",{enumerable:!0,get:function(){return l}});var t=_r(d[0]);const n=15,r='All our products are made with ingredients that contain allergens. Please speak to a member of our team before ordering if you have any questions.',o=t=>t?`If you have an allergy, phone us on ${t} before ordering.`:'If you have an allergy, phone the restaurant before ordering.',u=(0,t.create)(t=>({byVenue:{},set:(n,r)=>t(t=>({byVenue:{...t.byVenue,[n]:r}}))})),s=(t,n)=>!!t&&!t.fictional&&!n;const f=t=>`${Math.floor(Math.max(0,t)/60)}:${String(Math.max(0,t)%60).padStart(2,'0')}`,l=t=>'paid'===t.payment?.state?`Paid by card online \xb7 \xa3${((t.payment.paidPence??t.paid)/100).toFixed(2)}${t.payment.late?' (paid late: check the slot)':''}`:null},988,[846]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isKitchenTeam",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"canEditKitchenRota",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"kitchenTeam",{enumerable:!0,get:function(){return c}}),e.kitchenPending=function(t,n,c,s){return t.filter(t=>n.has(t.staffId)&&!!t.date&&t.date>=c&&t.date<=s&&(!t.published||t.changed))},e.publishKitchen=function(t,n,c,s){let u=0;return{shifts:t.map(t=>!n.has(t.staffId)||!t.date||t.dates||t.published&&!t.changed?t:(u++,{...t,published:!0,changed:!1})),n:u}},Object.defineProperty(e,"clashes",{enumerable:!0,get:function(){return s}});const t=t=>'kitchen'===String(t.dept??'').trim().toLowerCase()&&'owner'!==t.role&&'manager'!==t.role&&!t.managerAccess&&!t.ownerAccess,n=t=>t.includes('*')||t.includes('rota.kitchen')||t.includes('rota.manage'),c=n=>n.filter(n=>!1!==n.active&&t(n));const s=(t,n,c,s,u,o)=>t.some(t=>t.staffId===n&&t.date===c&&t.id!==o&&t.startt.LIVE_VENUE_BUILD?{...e,...b(e)}:e,[e])},Object.defineProperty(_e,"GP_TABLES",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"GP_EPOCH",{enumerable:!0,get:function(){return E}}),_e.gpSyncItems=D,_e.gpSyncFromRow=L,_e.mergeGpItems=N,_e.gpSyncSpec=function(e,t){const i=C[e];return{name:i,table:i,deletes:!1,list:()=>D(P.getState(),e),key:e=>e.id,rowKey:t=>String('ing'===e?t.local_id:t.id),syncable:t=>'ing'===e?t.id.length>0&&t.id.length<=80:(0,u.isUuid)(t.id),writable:t,toRow:(t,i)=>({id:'ing'===e?(0,u.isUuid)(t.id)?t.id:(0,p.uuidFrom)(`gi:${i}:${t.id}`):t.id,venue_id:i,...'ing'===e?{local_id:t.id,name:String(t.doc?.name??'').slice(0,120)}:{},doc:_(t),updated_at:t.updatedAt,deleted_at:t.deletedAt??null}),fromRow:t=>L(e,t),apply:(t,i)=>P.setState(n=>N(n,e,t,i)),subscribe:t=>P.subscribe((i,n)=>{i.gone===n.gone&&('ing'===e?i.ingredients===n.ingredients:i[w[e]]===n[w[e]])||t()})}};var e,t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),d=(e=r)&&e.__esModule?e:{default:e},a=_r(_d[5]),c=_r(_d[6]),o=_r(_d[7]),p=_r(_d[8]),u=_r(_d[9]),l=_r(_d[10]),f=_r(_d[11]);let h=0;const m=e=>`${e}-${Date.now().toString(36)}${(h++).toString(36)}`,S=(e,t,i,n,s,r=0,d=[])=>({id:e,name:t,packSize:i,packUnit:n,packPrice:s,wastePct:r,allergens:d}),k=e=>new Date(Date.now()-864e5*e).toISOString(),y={'gi-haddock':[8100,8700,8500],'gi-chicken':[4500,4600,4750],'gi-steak':[6200,5900,6e3],'gi-potato':[1450,1500,1600],'gi-oil':[3400,3300,3200]},v=[S('gi-haddock','Haddock fillet',5,'kg',8500,5,['fish']),S('gi-potato','Potatoes (chipping)',25,'kg',1600,20),S('gi-batter','Batter mix',3.5,'kg',770,0,['gluten']),S('gi-oil','Rapeseed oil',20,'L',3200),S('gi-peas','Garden peas (frozen)',2.5,'kg',450),S('gi-lemon','Lemons',80,'each',1600),S('gi-mayo','Mayonnaise',5,'L',1250,0,['eggs','mustard']),S('gi-capers','Capers',1,'kg',900,0,['sulphites']),S('gi-gherkin','Gherkins',2,'kg',700,0,['sulphites']),S('gi-steak','Braising steak',5,'kg',6e3,10),S('gi-pastry','Puff pastry',5,'kg',2250,0,['gluten','milk']),S('gi-onion','Onions',10,'kg',1e3,10),S('gi-stock','Beef stock',1,'L',350,0,['celery']),S('gi-chicken','Chicken breast',5,'kg',4750),S('gi-leaves','Cos lettuce',12,'each',960,15),S('gi-parmesan','Parmesan',1,'kg',1800,0,['milk']),S('gi-bread','Sourdough loaf',1,'each',300,0,['gluten']),S('gi-anchovy','Anchovies',.5,'kg',900,0,['fish']),S('gi-sponge','Date sponge (tray of 12)',1,'each',600,0,['gluten','eggs','milk']),S('gi-toffee','Toffee sauce',2,'L',1100,0,['milk']),S('gi-icecream','Vanilla ice cream',4,'L',1800,0,['milk','eggs']),{...S('gi-haddock-stone','Haddock (by the stone)',1,'stone',11e3,0,['fish']),servings:30,servingName:'serving',supplier:'Local fish merchant',updatedAt:'2026-11-02T09:00:00.000Z'},{...S('gi-chicken-case','Chicken breast (5 kg case)',5,'kg',4e3),servings:25,servingName:'breast',supplier:'Butcher',updatedAt:'2026-11-02T09:00:00.000Z'}].map(e=>({...e,prices:(y[e.id]??[e.packPrice]).map((e,t,i)=>({p:e,at:k(7*(i.length-t))}))})),I=(e,t,i,n,s,r,d,a="")=>({id:e,name:t,category:i,lines:n.map(([e,t,i])=>({ingId:e,qty:t,unit:i})),portions:s,target:70,menuPrice:r,status:d,description:a,allergens:[]}),O=[I('gd-chips','Chips (portion)','Sides',[['gi-potato',300,'g'],['gi-oil',50,'ml']],1,450,'ready','Hand-cut, twice-cooked chips.'),I('gd-tartare','Tartare sauce (batch of 20)','Sauces & extras',[['gi-mayo',1,'L'],['gi-capers',100,'g'],['gi-gherkin',150,'g'],['gi-lemon',2,'each']],20,void 0,'draft'),I('gd-fish','Fish & chips (example)','Mains',[['gi-haddock',220,'g'],['gi-batter',60,'g'],['dish:gd-chips',1,'each'],['gi-peas',80,'g'],['dish:gd-tartare',1,'each'],['gi-lemon',1,'each']],1,1695,'ready','Beer-battered haddock, chips, peas and tartare sauce.'),I('gd-pie','Steak pie (example)','Mains',[['gi-steak',2,'kg'],['gi-pastry',800,'g'],['gi-onion',500,'g'],['gi-stock',1,'L']],10,1595,'draft','Slow-braised steak under a puff pastry lid. Batch of 10.'),I('gd-caesar','Chicken Caesar (example)','Starters',[['gi-chicken',160,'g'],['gi-leaves',.5,'each'],['gi-parmesan',15,'g'],['gi-bread',.1,'each'],['gi-anchovy',8,'g']],1,1150,'draft'),I('gd-stp','Sticky toffee pudding (example)','Desserts',[['gi-sponge',.083,'each'],['gi-toffee',60,'ml'],['gi-icecream',70,'ml']],1,695,'ready','Warm date sponge, toffee sauce, vanilla ice cream.')],A={[(0,p.uuidFrom)('card:anchorage:a-fishsupper')]:{portions:1,lines:[{ingId:'gi-haddock-stone',qty:1,unit:'serving',recipeIngId:'a-fishsupper-i0'},{ingId:'gi-batter',qty:80,unit:'g',recipeIngId:'a-fishsupper-i1'},{ingId:'gi-potato',qty:250,unit:'g',recipeIngId:'a-fishsupper-i3'},{ingId:'gi-peas',qty:80,unit:'g',recipeIngId:'a-fishsupper-i4'},{ingId:'gi-mayo',qty:40,unit:'ml',recipeIngId:'a-fishsupper-i6'},{ingId:'gi-lemon',qty:.25,unit:'each',recipeIngId:'a-fishsupper-i7'}]}};function b(e){const t=e=>O.some(t=>t.id===e.id&&JSON.stringify(t)===JSON.stringify(e))||/\(example\)/i.test(e.name),i=new Set(e.dishes.filter(e=>!t(e)).map(e=>e.id));let n=!0;for(;n;){n=!1;for(const t of e.dishes.filter(e=>i.has(e.id)))for(const e of t.lines)e.ingId.startsWith('dish:')&&!i.has(e.ingId.slice(5))&&(i.add(e.ingId.slice(5)),n=!0)}const s=e.dishes.filter(e=>i.has(e.id)),r=new Set(s.flatMap(e=>e.lines.map(e=>e.ingId))),d=e=>{const t=v.find(t=>t.id===e.id);if(!t)return!1;const i=({prices:e,...t})=>JSON.stringify(t);return i(t)===i(e)&&(!e.prices?.length||JSON.stringify(e.prices.map(e=>e.p))===JSON.stringify(t.prices?.map(e=>e.p)))},a=Object.fromEntries(Object.entries(e.cardCosts??{}).filter(([e,t])=>!(A[e]&&JSON.stringify(A[e])===JSON.stringify(t))));return Object.values(a).forEach(e=>e.lines.forEach(e=>r.add(e.ingId))),{dishes:s,ingredients:e.ingredients.filter(e=>r.has(e.id)||!d(e)),cardCosts:a}}const P=(0,a.create)()((0,c.persist)((e,i)=>({ingredients:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:v,dishes:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:O,settings:{vatPct:20,pricePoints:!0,defaultTarget:70,multipleBasis:'inc',priceBasis:'latest',avgOf:5},alerts:[],cardCosts:s.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{}:A,gone:{},saveCardCost:(t,i)=>e(e=>{const n={...e.gone};return delete n[`card:${t}`],{cardCosts:{...e.cardCosts,[t]:{...i,updatedAt:(new Date).toISOString()}},gone:n}}),removeCardCost:t=>e(e=>{if(!e.cardCosts[t])return{};const{[t]:i,...n}=e.cardCosts;return{cardCosts:n,gone:{...e.gone,[`card:${t}`]:(new Date).toISOString()}}}),removeIngredient:t=>e(e=>({ingredients:e.ingredients.filter(e=>e.id!==t),gone:{...e.gone,[`ing:${t}`]:(new Date).toISOString()}})),saveIngredient:t=>{const n=i(),s=n.ingredients.find(e=>e.id===t.id),r=n.ingredients.map(e=>e.id===t.id?t:e);let d=n.alerts;if(s&&(s.packPrice!==t.packPrice||s.packSize!==t.packSize||s.wastePct!==t.wastePct)){const e=n.settings.vatPct,i=n.dishes.filter(e=>e.menuPrice).map(t=>{const i=(0,o.gpOf)((0,o.portionCost)(t,n.ingredients,n.dishes),t.menuPrice,e).gpPct,s=(0,o.gpOf)((0,o.portionCost)(t,r,n.dishes),t.menuPrice,e).gpPct;return{id:t.id,name:t.name,before:i,after:s,belowTarget:se.aftere.packPrice/e.packSize/(1-(e.wastePct||0)/100),c=(a(t)-a(s))/a(s)*100;i.length&&(d=[{id:m('ma'),at:(new Date).toISOString(),ingredient:t.name,change:`${c>=0?'+':''}${c.toFixed(0)}%`,dishes:i},...d].slice(0,20))}const a=s&&JSON.stringify({...s,updatedAt:void 0})!==JSON.stringify({...t,updatedAt:void 0});e({ingredients:a?r.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):r,alerts:d})},addPricePaid:(e,t,n)=>{const s=i(),r=s.ingredients.find(t=>t.id===e);if(!(r&&t>0))return;const d=[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:Math.round(t),at:n??(new Date).toISOString()}].slice(-20),a={...r,prices:d};i().saveIngredient({...a,packPrice:(0,o.costingPrice)(a,s.settings.priceBasis,s.settings.avgOf??5)})},addIngredient:t=>{const i=m('gi');return e(e=>({ingredients:[...e.ingredients,{updatedAt:(new Date).toISOString(),...t,id:i}]})),i},saveDish:t=>e(e=>({dishes:e.dishes.some(e=>e.id===t.id)?e.dishes.map(e=>e.id===t.id?{...t,updatedAt:(new Date).toISOString()}:e):[{...t,updatedAt:(new Date).toISOString()},...e.dishes]})),removeDish:t=>e(e=>({dishes:e.dishes.filter(e=>e.id!==t)})),setSettings:t=>{const n={...i().settings,...t};if(e({settings:n}),void 0!==t.priceBasis||void 0!==t.avgOf)for(const e of i().ingredients){const t=(0,o.costingPrice)(e,n.priceBasis,n.avgOf??5);t!==e.packPrice&&i().saveIngredient({...e,packPrice:t})}},dismissAlert:t=>e(e=>({alerts:e.alerts.filter(e=>e.id!==t)})),deliveries:{},counts:{},saveDelivery:(t,n)=>{const s=i(),r=(new Date).toISOString(),d=s.deliveries[t.id],a=n?(0,f.gpImpact)(s.ingredients,s.cardCosts??{},n,s.settings,t,d).snap:t.gp??d?.gp,{ingredients:c,lines:o}=(0,l.applyDelivery)(s.ingredients,t,s.settings,()=>m('gi'),r,d),p={...t,lines:o,updatedAt:r,...a?{gp:{...a,at:r}}:{}},u={...s.gone};return delete u[`del:${t.id}`],e({ingredients:c,deliveries:{...s.deliveries,[t.id]:p},gone:u}),p},removeDelivery:t=>e(e=>{if(!e.deliveries[t])return{};const{[t]:i,...n}=e.deliveries;return{deliveries:n,ingredients:(0,l.removeDeliveryPrices)(e.ingredients,t,e.settings,void 0,e.deliveries[t]),gone:{...e.gone,[`del:${t}`]:(new Date).toISOString()}}}),saveCount:t=>e(e=>{const i={...e.gone};return delete i[`count:${t.id}`],{counts:{...e.counts,[t.id]:{...t,updatedAt:(new Date).toISOString()}},gone:i}}),removeCount:t=>e(e=>{if(!e.counts[t])return{};const{[t]:i,...n}=e.counts;return{counts:n,gone:{...e.gone,[`count:${t}`]:(new Date).toISOString()}}})}),{name:'covercharge-gpcalc-v1',storage:(0,c.createJSONStorage)(()=>d.default),version:4,migrate:async(e,i)=>(t.LIVE_VENUE_BUILD&&e&&(await(0,n.archiveChefCache)('gpcalc',e),e={...e,...b({...e,dishes:e.dishes||[],ingredients:e.ingredients||[],cardCosts:e.cardCosts||{}})}),i<2&&e&&(e.ingredients=(e.ingredients??[]).map(e=>e.prices?.length?e:{...e,prices:[{p:e.packPrice,at:(new Date).toISOString()}]}),e.settings={priceBasis:'latest',avgOf:5,...e.settings??{}}),e&&!e.cardCosts&&(e.cardCosts={}),e&&!e.gone&&(e.gone={}),e&&!e.deliveries&&(e.deliveries={}),e&&!e.counts&&(e.counts={}),e)}));'undefined'!=typeof window&&'undefined'!=typeof document&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,s.venueKey)('covercharge-gpcalc-v1')&&P.persist.rehydrate()});const w={card:'cardCosts',del:'deliveries',count:'counts'},C={ing:'ingredient_prices',card:'card_costs',del:'kitchen_deliveries',count:'kitchen_stock_counts'},E='1970-01-01T00:00:00.000Z',_=e=>JSON.parse(JSON.stringify(e));function D(e,t){const i=b(e),n='ing'===t?i.ingredients.map(e=>({id:e.id,updatedAt:e.updatedAt??E,doc:_({...e,updatedAt:e.updatedAt??E})})):Object.entries('card'===t?i.cardCosts:e[w[t]]??{}).map(([e,t])=>({id:e,updatedAt:t.updatedAt??E,doc:_({...t,updatedAt:t.updatedAt??E})})),s=new Set(n.map(e=>e.id)),r=Object.entries(e.gone??{}).filter(([e])=>e.startsWith(`${t}:`)).map(([e,i])=>({id:e.slice(t.length+1),updatedAt:i,deletedAt:i})).filter(e=>!s.has(e.id));return[...n,...r]}function L(e,t){const i=t?.doc,n=String('ing'===e?t?.local_id??'':t?.id??'');if(!i||'object'!=typeof i||i.id!==n||'string'!=typeof i.updatedAt||!n)return null;if(i.deletedAt)return'string'==typeof i.deletedAt?{id:n,updatedAt:i.updatedAt,deletedAt:i.deletedAt}:null;const s=i.doc;return s&&'object'==typeof s&&('ing'!==e||'string'==typeof s.name&&s.id===n&&Number(s.packSize)>0&&'string'==typeof s.packUnit&&Number.isFinite(Number(s.packPrice)))&&('ing'===e||Array.isArray(s.lines))&&('del'!==e&&'count'!==e||'string'==typeof s.date&&s.id===n)?{id:n,updatedAt:i.updatedAt,doc:i.doc}:null}function N(e,t,i,n){const s={...e.gone??{}},r=new Map('ing'===t?e.ingredients.map(e=>[e.id,e]):Object.entries(e[w[t]]??{})),d=[];for(const e of i){const i=`${t}:${e.id}`,n=r.get(e.id),a=n?n.updatedAt??E:void 0,c=s[i];if(e.deletedAt){if(n&&a>e.deletedAt)continue;r.delete(e.id),(!c||ce.updatedAt)continue;if(n&&a>e.updatedAt)continue;const o='ing'===t?{...e.doc,id:e.id,updatedAt:e.updatedAt}:{...e.doc,updatedAt:e.updatedAt};n?r.set(e.id,o):d.push([e.id,o]),delete s[i]}for(const e of n)r.delete(e),delete s[`${t}:${e}`];if('ing'===t){return{ingredients:[...r.values(),...d.map(([,e])=>e)],gone:s}}return{[w[t]]:Object.fromEntries([...r.entries(),...d]),gone:s}}},990,[837,34,838,5,839,846,849,991,863,870,992,993]); +__d(function(_g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DISH_CATEGORIES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pricesOf",{enumerable:!0,get:function(){return i}}),e.priceStats=c,Object.defineProperty(e,"costingPrice",{enumerable:!0,get:function(){return o}}),e.avgMenuPrice=function(t,n,i){const c=t.filter(t=>t.category===n&&t.menuPrice&&t.id!==i).map(t=>t.menuPrice);return c.length?{avg:Math.round(c.reduce((t,n)=>t+n,0)/c.length),count:c.length}:null},Object.defineProperty(e,"GRAMS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PACK_UNITS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"unitName",{enumerable:!0,get:function(){return l}}),e.convert=function(t,n,i){const c=u[n],o=u[i];return c&&o&&c.dim===o.dim?t*c.f/o.f:null},Object.defineProperty(e,"unitsFor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"perServing",{enumerable:!0,get:function(){return d}}),e.perBaseUnit=function(t){const n=u[t.packUnit];if(!(n&&t.packSize>0))return null;const i=t.packSize*n.f;return'mass'===n.dim?{pence:t.packPrice/i*1e3,per:'kg'}:'vol'===n.dim?{pence:t.packPrice/i*1e3,per:'litre'}:{pence:t.packPrice/i,per:'item'}},Object.defineProperty(e,"servingWord",{enumerable:!0,get:function(){return g}}),e.lineCost=m,Object.defineProperty(e,"portionCost",{enumerable:!0,get:function(){return p}}),e.suggestAllergens=function t(n,i,c=[],o=0){const s=new Set;for(const u of n.lines)if(u.ingId.startsWith('dish:')){const n=c.find(t=>t.id===u.ingId.slice(5));n&&o<4&&((n.allergens??[]).forEach(t=>s.add(t)),t(n,i,c,o+1).forEach(t=>s.add(t)))}else i.find(t=>t.id===u.ingId)?.allergens?.forEach(t=>s.add(t));return[...s]},Object.defineProperty(e,"exVat",{enumerable:!0,get:function(){return h}}),e.gpOf=P,e.toPricePoint=b,e.suggestPrice=y,Object.defineProperty(e,"toneFor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"money",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pct",{enumerable:!0,get:function(){return O}}),e.multipleOf=function(t,n,i,c="inc"){return t<=0?0:('inc'===c?n:h(n,i))/t},Object.defineProperty(e,"fmtX",{enumerable:!0,get:function(){return S}}),e.suggestForMultiple=function(t,n,i,c,o){const s=t*Math.max(0,n)*('ex'===c?1+i/100:1);return o?b(Math.ceil(s)):Math.ceil(s)},e.amountLabel=k,e.cardCostSummary=function(t,n,i,c){const o=(t?.lines??[]).map(t=>{const i=n.find(n=>n.id===t.ingId);return{line:t,name:i?.name??'Removed ingredient',cost:m(t,n),label:k(t,i)}}),s=o.reduce((t,n)=>t+n.cost,0),u=Math.max(1,t?.portions||1),a=s/u,l=t?.target??i.defaultTarget??70,f=a>0?y(a,l,i.vatPct,i.pricePoints):null,d=t?.menuPrice&&t.menuPrice>0?t.menuPrice:null,g=d??(c&&c>0?c:f),p=g&&a>0?P(a,g,i.vatPct):null;return{lines:o,batch:s,perPortion:a,target:l,suggested:f,price:g,priceIsSuggested:!(d||c&&c>0),gp:p?p.gpPct:null,cashGp:p?p.cashGp:null,foodCostPct:p?p.foodCostPct:null,tone:p?v(p.gpPct,l):null,missing:o.filter(t=>t.cost<=0).length}};var t=r(_d[0]);const n=['Starters','Mains','From the Grill','Sides','Desserts','Specials','Kids','Sauces & extras'],i=t=>t.prices?.length?t.prices:[{p:t.packPrice,at:''}];function c(t,n=5){const c=i(t),o=c.slice(-Math.max(1,n)),s=Math.round(o.reduce((t,n)=>t+n.p,0)/o.length);return{latest:c[c.length-1].p,avg:s,count:o.length,min:Math.min(...o.map(t=>t.p)),max:Math.max(...o.map(t=>t.p))}}const o=(t,n="latest",i=5)=>'average'===n?c(t,i).avg:c(t,i).latest;const s={g:1,kg:1e3,oz:28.349523125,lb:453.59237,stone:1e3*t.KG_PER_STONE},u={kg:{dim:'mass',f:s.kg},g:{dim:'mass',f:s.g},oz:{dim:'mass',f:s.oz},lb:{dim:'mass',f:s.lb},stone:{dim:'mass',f:s.stone},L:{dim:'vol',f:1e3},ml:{dim:'vol',f:1},each:{dim:'each',f:1}},a=['kg','g','stone','lb','oz','L','ml','each'],l=(t,n=1)=>'L'===t?1===n?'litre':'litres':'stone'===t?'stone':'each'===t?'each':t;const f=(t,n)=>[...'mass'===u[t].dim?['g','kg','oz','lb']:'vol'===u[t].dim?['ml','L']:['each'],...n&&n>0?['serving']:[]],d=t=>t.servings&&t.servings>0?t.packPrice/t.servings:null;const g=(t,n)=>{const i=(t?.servingName||'serving').trim().toLowerCase();return 1===n?i:/(s|sh|ch|x)$/.test(i)?`${i}es`:`${i}s`};function m(t,n,i=[],c=0){if(t.ingId.startsWith('dish:')){const o=i.find(n=>n.id===t.ingId.slice(5));return o&&c<4?p(o,n,i,c+1)*t.qty:0}const o=n.find(n=>n.id===t.ingId);if(!o||!o.packSize)return 0;if('serving'===t.unit){const n=d(o);return null==n?0:t.qty*n}const s=u[o.packUnit],a=u[t.unit];if(!a||s.dim!==a.dim)return 0;const l=o.packPrice/(o.packSize*s.f),f=Math.min(95,Math.max(0,t.wastePct??o.wastePct??0));return t.qty*a.f*l/(1-f/100)}const p=(t,n,i=[],c=0)=>t.lines.reduce((t,o)=>t+m(o,n,i,c),0)/Math.max(1,t.portions||1);const h=(t,n)=>t/(1+n/100);function P(t,n,i){const c=h(n,i);return{ex:c,gpPct:c>0?(c-t)/c*100:0,cashGp:c-t,foodCostPct:c>0?t/c*100:0}}function b(t){const n=Math.floor(t/100),i=t-100*n;return i<=50?100*n+50:i<=95?100*n+95:100*(n+1)+50}function y(t,n,i,c){const o=t/(1-Math.min(95,Math.max(0,n))/100)*(1+i/100);return c?b(Math.ceil(o)):Math.ceil(o)}const v=(t,n)=>t>=n-.05?'ok':t>=n-5?'amber':'red',M=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,O=t=>`${t.toFixed(1)}%`;const S=t=>`${t.toFixed(1)}x`;function k(t,n){const i=Number.isInteger(t.qty)?String(t.qty):String(Math.round(1e3*t.qty)/1e3);return'serving'===t.unit?`${i} ${g(n,t.qty)}`:'each'===t.unit?`${i} ${1===t.qty?'item':'items'}`:`${i} ${l(t.unit,t.qty)}`}},991,[984]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"piecesPerPack",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"pieceName",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"lineTotal",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"deliveryTotal",{enumerable:!0,get:function(){return l}}),e.countPacks=u,Object.defineProperty(e,"countLineValue",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"countValue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"countUnitsFor",{enumerable:!0,get:function(){return p}}),e.applyDelivery=function(i,c,l,u,a=(new Date).toISOString(),o){let p=v(i,c.id,l,a,o);const f=`${c.date}T12:00:00.000Z`,k=c.lines.map(i=>{const o=i.name.trim();let v=p.find(n=>n.id===i.ingId)??p.find(n=>n.name.trim().toLowerCase()===o.toLowerCase());const k={p:Math.round(i.packPrice),at:f,src:c.id},h=t(i),P=h?{servings:Math.round(1e3*h)/1e3,servingName:s(i)}:{};if(!v){const n=u();return v={id:n,name:o,packSize:i.packSize,packUnit:i.packUnit,packPrice:k.p,wastePct:0,prices:[k],...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a},p=[...p,v],{...i,ingId:n,name:o,...h?{prevServings:null,prevServingName:null}:{}}}const b=d([...v.prices?.length?v.prices:[{p:v.packPrice,at:''}],k]).slice(-20),y=h?{prevServings:v.servings??null,prevServingName:v.servingName??null}:{},S={...v,packSize:i.packSize,packUnit:i.packUnit,prices:b,...P,...c.supplier.trim()?{supplier:c.supplier.trim()}:{},updatedAt:a};return S.packPrice=(0,n.costingPrice)(S,l.priceBasis,l.avgOf??5),p=p.map(n=>n.id===v.id?S:n),{...i,ingId:v.id,name:v.name,...y}});return{ingredients:p,lines:k}},e.removeDeliveryPrices=v,e.matchIngredient=function(n,t){const i=f(n);if(!i.length)return null;let s=null,c=0;for(const l of t){const t=f(l.name),u=(n,t)=>n===t||Math.min(n.length,t.length)>=5&&(n.startsWith(t)||t.startsWith(n)),a=i.filter(n=>t.some(t=>u(n,t))).length,o=a?a/Math.max(i.length,t.length)+(l.name.trim().toLowerCase()===n.trim().toLowerCase()?1:0):0;o>c&&(c=o,s=l)}return c>=.5?s:null},e.cardUnit=k,e.suggestAmount=function(t,i,s){const c=(0,n.unitsFor)(s.packUnit,s.servings),l=Number(String(t).replace(',','.').trim()),u=k(i);if(Number.isFinite(l)&&l>0&&u){if('each'===u&&!c.includes('each')&&c.includes('serving'))return{qty:l,unit:'serving'};if(c.includes(u))return{qty:l,unit:u}}return{qty:0,unit:c[0]}};var n=r(_d[0]);const t=n=>n.count&&n.count>0&&n.packs>0?n.count/n.packs:null,i=n=>{const t=n.trim().toLowerCase();return t.length>3&&/ies$/.test(t)?`${t.slice(0,-3)}y`:t.length>3&&/(sh|ch|x)es$/.test(t)?t.slice(0,-2):t.length>3&&/s$/.test(t)&&!/ss$/.test(t)?t.slice(0,-1):t},s=n=>i(n.countName||'piece')||'piece',c=n=>Math.round((n.packs||0)*(n.packPrice||0)),l=n=>n.lines.reduce((n,t)=>n+c(t),0);function u(t){if(!(t.qty>=0))return null;if('pack'===t.unit)return t.qty;if('serving'===t.unit)return t.servings&&t.servings>0?t.qty/t.servings:null;const i=(0,n.convert)(t.qty,t.unit,t.packUnit);return null!=i&&t.packSize>0?i/t.packSize:null}const a=n=>{const t=u(n);return null==t?0:Math.round(t*n.packPrice)},o=n=>n.lines.reduce((n,t)=>n+a(t),0),p=t=>['pack',...(0,n.unitsFor)(t.packUnit,t.servings)],d=n=>[...n].sort((n,t)=>(n.at||'').localeCompare(t.at||''));function v(t,i,s,c=(new Date).toISOString(),l){return t.map(t=>{if(!t.prices?.some(n=>n.src===i))return t;const u=t.prices.filter(n=>n.src!==i),a=l?.lines.find(n=>n.ingId===t.id&&void 0!==n.prevServings),o=a?{servings:a.prevServings??void 0,servingName:a.prevServingName??void 0}:{},p={...t,...o,prices:u.length?u:[{p:t.packPrice,at:''}],updatedAt:c};return a&&null==a.prevServings&&(delete p.servings,delete p.servingName),p.packPrice=(0,n.costingPrice)(p,s.priceBasis,s.avgOf??5),p})}const f=n=>n.toLowerCase().replace(/\([^)]*\)/g,' ').replace(/[^a-z\s]/g,' ').split(/\s+/).filter(n=>n.length>2&&!['the','and','with','cooked','fresh','chopped','diced','sliced','cleaned','whole'].includes(n)).map(n=>n.replace(/(es|s)$/,''));function k(n){const t=n.trim().toLowerCase().replace(/\.$/,'');return['g','gram','grams','gr'].includes(t)?'g':['kg','kilo','kilos','kgs'].includes(t)?'kg':['ml','mls'].includes(t)?'ml':['l','litre','litres','liter','liters','ltr'].includes(t)?'L':['oz','ounce','ounces'].includes(t)?'oz':['lb','lbs','pound','pounds'].includes(t)?'lb':['','whole','each','single','singles','piece','pieces','slice','slices','sliced','portion','portions','wedge','wedges','x'].includes(t)?'each':null}},992,[991]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"normRead",{enumerable:!0,get:function(){return r}}),e.rememberedMatch=i,e.matchLine=function(t,r,a,s,c){const o=i(t,a,s,c);if(o)return{ing:o,how:'remembered'};const l=r.trim().toLowerCase(),u=c.find(t=>t.name.trim().toLowerCase()===l);if(u)return{ing:u,how:'exact'};const p=(0,n.matchIngredient)(r,c)??(0,n.matchIngredient)(t,c);return p?{ing:p,how:'close'}:{ing:null,how:'new'}},e.packUnitOf=s,e.lineFlags=function(t,n){const r=[];t.sure||r.push('Not sure it read this line right');t.item||r.push('Item name not read');t.packs&&t.packs>0||r.push('Quantity not read');t.packSize&&t.packSize>0&&s(t.packUnit)||r.push('Pack size not read');null==t.unitPrice&&r.push('Price not read');null!=t.unitPrice&&t.packs&&null!=t.lineTotal&&Math.abs(t.packs*t.unitPrice-t.lineTotal)>Math.max(2,.01*t.lineTotal)&&r.push('Quantity times price does not match the line total');'new'===n&&r.push('New item: not on your price list yet');'close'===n&&r.push('Matched to a similar name: check it is the same item');return r},e.costView=c,e.lineCostChange=function(r,a,i){const s=(0,n.piecesPerPack)(a),o=s?{servings:s,servingName:(a.countName||'piece').replace(/s$/i,'')}:{},l=r?{...r,packSize:a.packSize,packUnit:a.packUnit,...o,prices:[...r.prices?.length?r.prices:[{p:r.packPrice,at:''}],{p:a.packPrice,at:'z'}]}:{id:'',name:'',packSize:a.packSize,packUnit:a.packUnit,packPrice:a.packPrice,wastePct:0,...o};l.packPrice=r?(0,t.costingPrice)(l,i.priceBasis,i.avgOf??5):a.packPrice;const u=c(r),p=c(l),d=u?.base&&p?.base&&u.base.per===p.base.per&&u.base.pence>0?(p.base.pence-u.base.pence)/u.base.pence*100:null;return{before:u,after:p,changePct:d}},e.menuGp=o,Object.defineProperty(e,"NOTICEABLE_DROP",{enumerable:!0,get:function(){return l}}),e.gpImpact=function(t,r,a,i,s,c){const u=o(t,r,a,i),{ingredients:p}=(0,n.applyDelivery)(t,s,i,()=>`tmp-${Math.random()}`,void 0,c),d=o(p,r,a,i),m=d.dishes.map(t=>{const n=u.dishes.find(n=>n.id===t.id),r=n?.gp??t.gp,a=r-t.gp;return{id:t.id,name:t.name,before:r,after:t.gp,target:t.target,drop:a,flagged:a>=l||r>=t.target-.05&&t.gpMath.abs(t.before-t.after)>=.05).sort((t,n)=>n.drop-t.drop);return{snap:{at:`${s.date}T12:00:00.000Z`,before:u.menu,after:d.menu,dishes:d.dishes.map(t=>({id:t.id,name:t.name,before:u.dishes.find(n=>n.id===t.id)?.gp??null,after:t.gp}))},dishes:m,after:p}},Object.defineProperty(e,"RANGE_WEEKS",{enumerable:!0,get:function(){return u}}),e.mondayOf=m,e.gpHistory=function(t,n,r,a=d(new Date)){const i=[],s=m(a),[c,o,l]=s.split('-').map(Number);for(let t=u[r]-1;t>=0;t--)i.push(d(new Date(c,o-1,l-7*t)));const p=[...t].sort((t,n)=>t.date.localeCompare(n.date)||(t.createdAt??'').localeCompare(n.createdAt??'')),f={};let h=null;for(const t of p)t.datenull!=t.after).map(t=>[t.id,t.after]))});const b=[],k=[];for(const t of i){const r=d(new Date(Number(t.slice(0,4)),Number(t.slice(5,7))-1,Number(t.slice(8,10))+7)),a=p.filter(n=>n.date>=t&&n.datenull!=t.after).map(t=>[t.id,t.after]))},n.gp.dishes.forEach(t=>{f[t.id]=t.name}));const r=n.gp&&null!=n.gp.before&&null!=n.gp.after?n.gp.after-n.gp.before:null;(!n.gp||null==r||Math.abs(r)>=.05)&&k.push({week:t,date:n.date,id:n.id,supplier:n.supplier,change:r})}t!==s?b.push(h?{...h,week:t}:{week:t,menu:null,dishes:{}}):b.push({week:t,menu:n.menu,dishes:Object.fromEntries(n.dishes.map(t=>[t.id,t.gp]))})}return{points:b,markers:k,names:f}},Object.defineProperty(e,"RANGE_SAID",{enumerable:!0,get:function(){return f}}),e.gpSummary=function(t,n){const r=t.filter(t=>null!=t.menu);if(!r.length)return'No GP history yet. It starts with the first delivery that changes a cost.';const a=r[r.length-1].menu,i=t=>Math.abs(t)<.05?'steady':`${t>0?'up':'down'} ${Math.abs(t).toFixed(1)} points`,s=r.length>1?r[r.length-2].menu:null,c=r[0].menu;return null==s?`Menu GP now ${a.toFixed(1)} percent. Not enough history to compare yet.`:`Menu GP now ${a.toFixed(1)} percent, ${i(a-s)} on the week before, ${i(a-c)} over ${f[n]}.`};var t=_r(_d[0]),n=_r(_d[1]);const r=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,' ').replace(/\s+/g,' ').trim(),a=(t,n)=>r(t)===r(n)&&!!r(t);function i(t,n,i,s){const c=r(t);if(!c)return null;const o=(Array.isArray(i)?i:Object.values(i)).filter(t=>a(t.supplier,n)).sort((t,n)=>(n.updatedAt??n.createdAt).localeCompare(t.updatedAt??t.createdAt));for(const t of o)for(const n of t.lines)if(n.read&&r(n.read)===c){const t=s.find(t=>t.id===n.ingId);if(t)return t}return null}function s(n){const r=(n??'').trim().toLowerCase().replace(/\.$/,'');return r?['kg','kgs','kilo','kilos','kilogram','kilograms'].includes(r)?'kg':['g','gr','gram','grams','gm','gms'].includes(r)?'g':['l','lt','ltr','litre','litres','liter','liters'].includes(r)?'L':['ml','mls'].includes(r)?'ml':['lb','lbs','pound','pounds'].includes(r)?'lb':['oz','ounce','ounces'].includes(r)?'oz':['st','stone'].includes(r)?'stone':['each','ea','x','unit','units','pc','pcs','piece','pieces','item','items','case','cases','box','boxes','tray','trays','pack','packs','bottle','bottles','can','cans','tin','tins','jar','jars','tub','tubs','bag','bags','dozen','doz'].includes(r)?'each':t.PACK_UNITS.includes(r)?r:null:null}function c(n){if(!n)return null;const r=(0,t.perServing)(n);return{base:(0,t.perBaseUnit)(n),piece:null!=r?{pence:r,name:(n.servingName||'piece').toLowerCase()}:null}}function o(n,r,a,i){const s=a.map(a=>{const s=(0,t.cardCostSummary)(r[a.id],n,i,a.price);return{id:a.id,name:a.dish,gp:s.gp,target:s.target}}).filter(t=>null!=t.gp);return{menu:s.length?s.reduce((t,n)=>t+n.gp,0)/s.length:null,dishes:s}}const l=2;const u={'4w':4,'3m':13,'12m':52},p=t=>String(t).padStart(2,'0'),d=t=>`${t.getFullYear()}-${p(t.getMonth()+1)}-${p(t.getDate())}`;function m(t){const[n,r,a]=t.split('-').map(Number),i=new Date(n,r-1,a);return i.setDate(i.getDate()-(i.getDay()+6)%7),d(i)}const f={'4w':'4 weeks','3m':'3 months','12m':'12 months'}},993,[991,992]); +__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 f}}),Object.defineProperty(_e,"CARD_ROLE_APP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"cardCostsVisible",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"ownJobSeesCosts",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"costsAllowedFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"ownJobManagesLinks",{enumerable:!0,get:function(){return h}});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',forecast:'prep',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,...e.nickname?{nickname:e.nickname}:{},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:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})=>({id:e,ref:t,type:n,tableNo:a,slotTime:s,lines:c,status:l,allergies:o,allergyAck:f,handoverCheck:u,allergyChain:p,bookingId:b,readiness:m,createdAt:h,restaurantId:k,notes:y,accepted:w,allergyTicks:O})),o=(e,n)=>t(e,'supplier-email')?n:n.map(e=>({...e,email:''})),f=(e,n)=>t(e,'audit-all')?n:n.filter(e=>'menu'===e.kind&&/allergen|sign-off|recipe card/i.test(e.text)),u={'head-chef':'chef',manager:'manager',owner:'owner',staff:'staff'},p=(e,n="edit")=>'edit'===n&&t(u[e]??'staff','costing'),b=e=>'owner'===e.role||'manager'===e.role||'Head Chef'===e.level,m=e=>!e||b(e),h=e=>'owner'===e.role||'manager'===e.role},994,[]); +__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 _}});var e,t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),n=r(_d[3]),o=r(_d[4]),c=(e=o)&&e.__esModule?e:{default:e},l=r(_d[5]),d=r(_d[6]),h=r(_d[7]),u=r(_d[8]),y=r(_d[9]);const p=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock)}catch{return new Date}};let S=0;const f=()=>`sb-${Date.now().toString(36)}${(S++).toString(36)}`,b=(e,t)=>u.useStore.setState(s=>({audit:[{id:`au-${f()}`,restaurantId:e,at:p().toISOString(),kind:'allergy',text:t},...s.audit].slice(0,300)})),_=(0,l.create)()((0,d.persist)((e,t)=>({...n.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{current:{},history:[]}:(0,h.seedSpecials)(p()),post:(t,s,i,n)=>{e(e=>(0,h.postBoard)(e,t,s,i,n,p(),f())),s.items.length&&b(t,`Specials board: allergens for ${s.items.length} typed special${1===s.items.length?'':'s'} checked and signed off by ${i}`)},clear:(t,s)=>{e(e=>(0,h.clearBoard)(e,t)),b(t,`Specials board cleared by ${s}`)},reuse:(s,i,n,o)=>{const c=t().history.find(e=>e.id===i);e(e=>(0,h.reuseBoard)(e,s,i,n,o,p(),f())),c?.items.length&&b(s,`Specials board re-used: ${c.items.length} typed special${1===c.items.length?'':'s'}, allergens as previously checked, signed off by ${n}`)},remove:t=>e(e=>(0,h.deleteFromHistory)(e,t))}),{name:'covercharge-specials-v1',storage:(0,d.createJSONStorage)(()=>c.default),version:1,partialize:e=>({current:e.current,history:e.history})})),E=async()=>{if(!(0,y.liveData)())return;const e=_.getState(),n=e=>String(e.id).startsWith('sb-seed')&&(!s.LIVE_VENUE_BUILD||(0,t.demoActor)(e.postedBy)&&(!e.allergenCheck||(0,t.demoActor)(e.allergenCheck.by))&&(!e.photo||e.photo===h.SAMPLE_PHOTO)&&e.items.every(e=>/\(sample\)/i.test(e.name))),o=Object.fromEntries(Object.entries(e.current).filter(([,e])=>!(e&&n(e)))),c=e.history.filter(e=>!n(e));Object.keys(o).length===Object.keys(e.current).length&&c.length===e.history.length||(s.LIVE_VENUE_BUILD&&await(0,i.archiveChefCache)('specials',{current:e.current,history:e.history}),_.setState({current:o,history:c}))};(0,y.onDataModeChange)(E);try{_.persist?.onFinishHydration?.(E)}catch{}E()},995,[835,837,838,5,839,846,849,996,831,884]); +__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'}}]},996,[]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PUB_LOCATIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"privateClockVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"pubLocation",{enumerable:!0,get:function(){return s}}),e.venueClockArea=function(a,o={}){if((0,t.isQueuedVenue)(a)&&!t.queuedVenues[a].clockArea.on)return(0,n.cleanArea)({...o,on:!0===o.on&&'number'==typeof o.lat&&'number'==typeof o.lng,offRotaPrompt:!1});const l=s(a);if(!l)return(0,n.cleanArea)(o);const c=(0,n.cleanArea)({lat:l.lat,lng:l.lng,radius:150,...o});return{...c,lat:c.lat??l.lat,lng:c.lng??l.lng,on:!0,offRotaPrompt:!1}},e.venueClockGeo=l,e.privateAttendance=function(n,a){if(!o(n)&&!(0,t.isQueuedVenue)(n))return a;const s={...a};for(const t of['lat','lng','latitude','longitude','coords','position','location','acc','dist','accuracy','distance','outSite'])delete s[t];a.geo&&(s.geo=a.geo.map(t=>l(n,t)).filter(t=>!!t));return s};var t=r(d[0]),n=r(d[1]);const a={"3idiots":{name:"3 Idiots",address:"10 George Street, Ayr, KA8 0BL",lat:55.4650286,lng:-4.6283062,source:"Verified exact-address venue pack"},cecchinis:{name:"Cecchinis",address:"72 Fort Street, Wellington Square, Ayr, South Ayrshire KA7 1EH",lat:55.461505,lng:-4.6345736,source:"Verified exact-address venue pack"},williewastles:{name:"Willie Wastle's",address:"16-18 New Bridge Street, Ayr, South Ayrshire, KA7 1JX",lat:55.4646261,lng:-4.6323929,source:"Verified exact-address venue pack"},smokinggoat:{name:"Smoking Goat",address:"2A Academy Street, Ayr KA7 1HS",lat:55.464226,lng:-4.6326035,source:"Verified exact-address venue pack"},drunkencoo:{name:"The Drunken Coo",address:"22 Beresford Terrace, Ayr KA7 2EG",lat:55.4570308,lng:-4.6294663,source:"Verified exact-address venue pack"},abbotsford:{name:'The Abbotsford Hotel',address:'14 Corsehill Road, Ayr KA7 2ST',lat:55.4488797,lng:-4.6314856,source:'Official FSA1696388, exact address match verified6 Nov2026'},kirkton:{name:'The Kirkton Inn',address:'1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF',lat:55.3971215,lng:-4.5920177,source:'Public FSA establishment1955433 verified6 November2026'},greenside:{name:'The Greenside Restaurant',address:'5 Greenside, Maybole, South Ayrshire KA19 7DG',lat:55.3542369,lng:-4.6851418,source:'Official Find us Google Maps link, place point, verified 6 November 2026'},kirkmichael:{name:'The Kirkmichael Arms',address:'3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH',lat:55.3458202,lng:-4.6180793,source:'venue-profile.json geo, matched to the venue address'},souters:{name:"Souter\u2019s Inn",address:'47 Main Road, Kirkoswald, South Ayrshire KA19 8HY',lat:55.3297218,lng:-4.7772979,source:'Food Standards Agency establishment 1863840, address matched'}},o=t=>Object.prototype.hasOwnProperty.call(a,t),s=t=>o(t)?a[t]:void 0;function l(n,a){return o(n)||(0,t.isQueuedVenue)(n)?'in'===a.action?{action:'in',at:a.at,inside:a.inside,...a.override?{override:{by:a.override.by,byId:a.override.byId,reason:a.override.reason}}:{}}:void 0:a}},997,[6,998]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_RADIUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ACCURACY_CAP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_BREAK_OPTIONS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_CLOCK_AREA",{enumerable:!0,get:function(){return r}}),e.distanceM=s,Object.defineProperty(e,"validLat",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validLng",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"areaSet",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"clampRadius",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"accuracyAllowance",{enumerable:!0,get:function(){return p}}),e.isInside=h,e.cleanArea=function(t){const n=(t.breakOptions??a).map(t=>Math.round(Number(t))).filter(t=>Number.isFinite(t)&&t>0&&t<=180);return{...r,...t,lat:c(t.lat)?t.lat:null,lng:l(t.lng)?t.lng:null,radius:f(t.radius??r.radius),on:!1!==t.on,offRotaPrompt:!1!==t.offRotaPrompt,breakOptions:[...new Set(n)].sort((t,n)=>t-n).slice(0,12),offRotaTitle:(t.offRotaTitle??'').trim().slice(0,80)||r.offRotaTitle,offRotaBody:(t.offRotaBody??'').trim().slice(0,160)||r.offRotaBody}},Object.defineProperty(e,"ACTION_WORD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"DENIED_TEXT",{enumerable:!0,get:function(){return m}}),e.gate=function(t,n,o,a,r="browser"){if(!t.on||!d(t)){const r={action:n,at:a,inside:null,unchecked:!0};return'object'==typeof o&&Object.assign(r,{lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc)}),{allowed:!0,geo:r,warn:t.on?'The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':void 0}}if('object'!=typeof o){const t='app-phone-off'===r?m['app-phone-off']:'denied'===o?m[r]:'timeout'===o?'Your phone couldn\u2019t find your location in time. Step outside or near a window and try again.':'unsupported'===o?'This phone or browser can\u2019t share its location. Ask a manager to record it for you.':'Your phone couldn\u2019t find your location. Check Location is on, then try again.';return{allowed:!1,message:`You need to be at the venue to ${b[n]}. ${t}`,geo:{action:n,at:a,inside:!1}}}const u=h(t,o),s={action:n,at:a,lat:y(o.lat),lng:y(o.lng),acc:Math.round(o.acc),dist:u.dist,inside:u.inside};if(u.inside)return{allowed:!0,geo:s};const c=u.dist>=1e3?`${(u.dist/1e3).toFixed(1)} km`:`${u.dist} m`;return{allowed:!1,geo:s,message:`You need to be at the venue to ${b[n]}. You look to be about ${c} away (allowed ${u.limit} m). If you\u2019re at the venue, try again in a moment or ask a manager to record it for you.`}},e.overrideGeo=function(t,n,o,a){const r=a.trim();return r.length<3?null:{action:t,at:n,inside:null,override:{by:o.name,byId:o.id,reason:r.slice(0,200)}}},e.offRotaDue=function(t){return!(!(t.area.offRotaPrompt&&d(t.area)&&t.inside)||t.clockedIn||t.dismissedToday)&&!t.shifts.some(n=>t.nowHours>=n.start-1&&t.nowHours<(n.end<=n.start?n.end+24:n.end))},Object.defineProperty(e,"breakLabel",{enumerable:!0,get:function(){return O}});const t=50,n=2e3,o=50,a=[5,10,15,20,30,45,60],r={lat:null,lng:null,radius:100,on:!0,breakOptions:[...a],offRotaPrompt:!0,offRotaTitle:'Do you want to sign in?',offRotaBody:'Should you be on the rota?'},u=t=>t*Math.PI/180;function s(t,n){const o=u(n.lat-t.lat),a=u(n.lng-t.lng),r=Math.sin(o/2)**2+Math.cos(u(t.lat))*Math.cos(u(n.lat))*Math.sin(a/2)**2;return 12742017.6*Math.asin(Math.min(1,Math.sqrt(r)))}const c=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-90&&t<=90,l=t=>'number'==typeof t&&Number.isFinite(t)&&t>=-180&&t<=180,d=t=>c(t.lat)&&l(t.lng),f=o=>Number.isFinite(o)?Math.min(n,Math.max(t,Math.round(o))):r.radius,p=t=>Number.isFinite(t)&&t>0?Math.min(t,o):0;function h(t,n){const o=s({lat:t.lat,lng:t.lng},n),a=f(t.radius)+p(n.acc);return{inside:o<=a,dist:Math.round(o),limit:Math.round(a)}}const b={in:'clock in',out:'clock out',break_start:'start a break',break_end:'end your break'},m={browser:'Location is turned off for this browser. Turn it on in your phone\u2019s settings (Location \u203a allow for this browser), then try again.',iphone:'Location is turned off for this app. On your iPhone open Settings \u203a Privacy & Security \u203a Location Services \u203a Safari Websites and choose While Using the App, then try again.',app:'Location is turned off for this app. Tap Open app settings, then Permissions \u203a Location \u203a Allow only while using the app. Then come back and try again.','app-old':'This version of the app can\u2019t use location. Tap Update the app at the bottom of the screen, then tap Allow when your phone asks.','app-phone-off':'Location is switched off on your phone. Tap Open location settings, turn on Use location, then come back and try again.'};const y=t=>Math.round(1e6*t)/1e6;const O=t=>60===t?'1 hour':t%60==0?t/60+" hours":t>60?`${Math.floor(t/60)} h ${t%60} min`:`${t} min`},998,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useCashAccess",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"hasCashUpAccess",{enumerable:!0,get:function(){return n}});const t=(0,r(d[0]).create)(()=>({byRef:{},mine:null,loaded:!1,takings:null,tradingDate:null,photos:null})),n=()=>!0===t.getState().mine},999,[846]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PERM_CATALOG",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PERM_KEYS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PERM_GROUPS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"permLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ROLE_ORDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLE_LABEL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ownerLevel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"has",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ticks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"toggle",{enumerable:!0,get:function(){return f}}),e.effectivePerms=function(t,n,a){const o=[...new Set([...t,...n])];return(o.includes('*')?o:o.filter(t=>!a.includes(t))).sort()},e.tickSource=function(t,n){return t.extra.includes(n)?'extra':t.removed.includes(n)&&!t.base.includes('*')?'removed':c(t.base,n)?'role':'off'},Object.defineProperty(e,"SOURCE_WORDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"isCloser",{enumerable:!0,get:function(){return p}}),e.tradingDay=function(t=new Date,n="Europe/London"){const a=new Date(t.getTime()-216e5),o=new Intl.DateTimeFormat('en-GB',{timeZone:n,year:'numeric',month:'2-digit',day:'2-digit'}).formatToParts(a),s=t=>o.find(n=>n.type===t)?.value??'';return`${s('year')}-${s('month')}-${s('day')}`},Object.defineProperty(e,"ukDay",{enumerable:!0,get:function(){return b}}),e.logWords=function(t){const n=t=>Array.isArray(t)?t:[],a=t=>t&&'object'==typeof t&&!Array.isArray(t)?t:{};let s=[],u=[];if('role'===t.target_kind){const a=n(t.before),o=n(t.after);s=o.filter(t=>!a.includes(t)),u=a.filter(t=>!o.includes(t))}else{const o=a(t.before),l=a(t.after),c=n(o.extra),g=n(l.extra),f=n(o.removed),d=n(l.removed);s=[...g.filter(t=>!c.includes(t)),...f.filter(t=>!d.includes(t))],u=[...d.filter(t=>!f.includes(t)),...c.filter(t=>!g.includes(t))]}const c='role'===t.target_kind?`${l[t.target_ref??'']??t.target_name??'Role'} role`:t.target_name??'Someone',g=[...s.map(t=>`+ ${o(t)}`),...u.map(t=>`\u2212 ${o(t)}`)];return`${t.changed_by_name??'Admin'}: ${c}${g.length?`, ${g.join(', ')}`:', back to their role'}`},e.logWhen=function(t){const n=new Date(t);return new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'2-digit',month:'2-digit',year:'numeric',hour:'2-digit',minute:'2-digit',hour12:!1}).format(n).replace(',','')};const t=[{key:'bookings.manage',label:'Take and change bookings',group:'Bookings & floor'},{key:'bookings.settings',label:'Booking settings: times, tables and blocks',group:'Bookings & floor'},{key:'floor.manage',label:'Edit the table plan and seat tables',group:'Bookings & floor'},{key:'orders.manage',label:'Kitchen and table orders',group:'Bookings & floor'},{key:'stock.manage',label:'Stock and deliveries',group:'Kitchen & stock'},{key:'suppliers.manage',label:'Suppliers',group:'Kitchen & stock'},{key:'suppliers.order',label:'Order from suppliers',group:'Kitchen & stock'},{key:'recipes.edit',label:'Edit recipe cards and allergens',group:'Kitchen & stock'},{key:'recipes.signoff',label:'Sign off recipe cards',group:'Kitchen & stock'},{key:'attendance.view',label:'See everyone\u2019s hours',group:'Team'},{key:'rota.manage',label:'Make the rota and approve timesheets',group:'Team'},{key:'rota.kitchen',label:'Make the kitchen rota (kitchen team only)',group:'Team',note:'Add, change and publish shifts for the kitchen team in the Head Chef app. No hours, pay or takings.'},{key:'rota.swap',label:'Approve shift swaps',group:'Team'},{key:'shift.manager',label:'Shift manager features in the Staff app',group:'Team'},{key:'staff.manage',label:'Add staff and change their details',group:'Team'},{key:'takings.view',label:'See takings, past cash ups and sales reports',group:'Money',note:'Without this, \u201cCan use cash up\u201d is tonight\u2019s cash up only.'},{key:'wages.view',label:'See pay and wages',group:'Money'},{key:'wages.manage',label:'Change pay, cash-up settings and any day\u2019s cash up',group:'Money'},{key:'venue.settings',label:'Change venue settings',group:'Venue'},{key:'devices.manage',label:'Pair and remove screens',group:'Venue'},{key:'outbox.view',label:'See messages sent to guests',group:'Venue'}],n=t.map(t=>t.key),a=[...new Set(t.map(t=>t.group))],o=n=>t.find(t=>t.key===n)?.label??n,s=['owner','manager','supervisor','head_chef','staff'],l={owner:'Owner',manager:'Manager',supervisor:'Supervisor',head_chef:'Head Chef',staff:'Staff'},u=t=>t.includes('*'),c=(t,n)=>t.includes('*')||t.includes(n),g=t=>u(t)?[...n]:n.filter(n=>t.includes(n)),f=(t,n,a)=>(a?[...new Set([...t,n])]:t.filter(t=>t!==n)).sort();const d={role:'from their role',extra:'added just for them',removed:'taken off just for them',off:'off'},p=t=>t.cashUp&&!t.takings;const b=t=>/^\d{4}-\d{2}-\d{2}$/.test(t)?`${t.slice(8,10)}/${t.slice(5,7)}/${t.slice(0,4)}`:t},1000,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useSliders",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"notify",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"dismissNotice",{enumerable:!0,get:function(){return c}});var t=r(d[0]);let u=0;const s=t=>'urgent'===t.tone?0:'warn'===t.tone?1:2,n=(0,t.create)()((t,n)=>({queue:[],push:n=>t(t=>{const o=t.queue.find(t=>t.id===n.id),c=o?t.queue.map(t=>t.id===n.id?{...n,seq:o.seq}:t):[...t.queue,{...n,seq:++u}];return{queue:(f=c,[...f].sort((t,u)=>s(t)-s(u)||(t.seq??0)-(u.seq??0))).slice(0,40)};var f}),dismiss:u=>{const s=n().queue.find(t=>t.id===u);if(s){t(t=>({queue:t.queue.filter(t=>t.id!==u)}));try{s.onClose?.()}catch{}}},dismissWhere:t=>{for(const u of n().queue.filter(t))n().dismiss(u.id)}})),o=t=>n.getState().push(t),c=t=>n.getState().dismiss(t)},1001,[846]); +__d(function(_g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startForm=function(t=Date.now()){return{openedAt:t,hp:''}},e.guardFor=function(t,n=Date.now()){return{hp:t.hp,formMs:Math.max(0,Math.round(n-t.openedAt))}},e.rememberGuard=function(n,o){t.set(n,o)},e.takeGuard=function(n){const o=t.get(n);return o?(t.delete(n),o):{}};const t=new Map},1002,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteFromLocation=function(n,t){const o=new URLSearchParams(n).get('invite');if(o)return o;const s=(t||'').match(/[#&]invite=([A-Za-z0-9_-]{10,})/);return s?s[1]:null},e.addressWithoutInvite=function(n){try{const t=new URL(n);t.searchParams.delete('invite');const o=t.hash.replace(/^#/,'').split('&').filter(n=>n&&!n.startsWith('invite=')&&!n.startsWith('ccchrome=')).join('&');return t.hash=o?`#${o}`:'',t.toString()}catch{return n}},Object.defineProperty(e,"PHONE_LINKED_TEXT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"isPhoneLinked",{enumerable:!0,get:function(){return t}}),e.inviteRefusal=function(t){return/already linked to another phone/i.test(t)?n:/update the app/i.test(t)?'Update the app: close it, then open your personal link again.':/already been used/i.test(t)?'This link has already been used on another device. Ask your manager for a new one.':/expired/i.test(t)?'This link has expired. Ask your manager for a new one.':/replaced|switched off|not valid|invalid|unknown invite/i.test(t)?'This link has been replaced or switched off. Ask your manager for a new one.':/personal app link is incomplete/i.test(t)?'Open the complete personal iPhone link your manager sent.':/no longer active/i.test(t)?'This person is no longer on the team. Ask your manager if this is wrong.':null},Object.defineProperty(e,"WIPE_PREFIXES",{enumerable:!0,get:function(){return o}}),e.keysToWipe=function(n){return n.filter(n=>o.some(t=>n.startsWith(t)))},e.handoverFromHash=function(n){const t=(n||'').match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|$)/);return t?t[1]:null};const n='This link is already linked to another phone. Ask a manager to reset it or send you a new link.',t=n=>!!n&&/already linked to another phone/i.test(n);const o=['covercharge-','cc-sync:','cc-','sb-']},1003,[]); +__d(function(g,r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"addressWithoutInvite",{enumerable:!0,get:function(){return s.addressWithoutInvite}}),Object.defineProperty(_e,"inviteFromLocation",{enumerable:!0,get:function(){return s.inviteFromLocation}}),Object.defineProperty(_e,"useSession",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"rosterPerson",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"APP_NAME",{enumerable:!0,get:function(){return h}}),_e.sha256Hex=m,_e.inviteFromText=function(e){const t=e.trim(),n=t.match(/[?&#](?:invite|i)=([A-Za-z0-9_-]{10,})/);return n?n[1]:/^[A-Za-z0-9_-]{10,}$/.test(t)?t:null},_e.personForInvite=async function(e){if(a.IS_ISOLATED_VENUE)return;const t=await m(e);return t?u.ROSTER.find(e=>e.tokenHash===t):void 0},Object.defineProperty(_e,"DEVICE_KEY",{enumerable:!0,get:function(){return y}}),_e.deviceId=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(y);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(y,e)}return e}catch{return null}},Object.defineProperty(_e,"PHONE_KEY",{enumerable:!0,get:function(){return S}}),_e.phoneKey=function(){try{if('undefined'==typeof localStorage)return null;let e=localStorage.getItem(S);if(!e||!/^[A-Za-z0-9_-]{16,64}$/.test(e)){const t=new Uint8Array(18);if(globalThis.crypto?.getRandomValues?.(t),!t.some(e=>e))for(let e=0;ee.toString(16).padStart(2,'0')).join(''),localStorage.setItem(S,e)}return e}catch{return null}},Object.defineProperty(_e,"START_INVITE",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"START_HANDOVER",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"START_GO",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"START_LOYALTY_CODE",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"START_TABLE_TOKEN",{enumerable:!0,get:function(){return b}}),_e.appUrl=function(e,t){if('undefined'==typeof window||!window.location)return null;const{origin:n,pathname:o}=window.location,i=o.match(/^(.*?\/)(owner|staff|chef|display|customer)-app(\/|$)/),a=i?i[1]:'/';return`${n}${a}${e}-app/index.html${t?`#invite=${encodeURIComponent(t)}`:''}`},_e.levelJob=function(e,t){const n=(e??'').trim(),o=(t??'').trim();return n?!o||o.toLowerCase().startsWith(n.toLowerCase())?o||n:`${n} \xb7 ${o}`:o};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]),a=r(d[3]),c=r(d[4]),l=r(d[5]),u=r(d[6]),s=r(d[7]);const f=(0,o.create)()((0,i.persist)(e=>({meId:null,welcomed:{},signIn:t=>e({meId:t,signedInAt:(new Date).toISOString()}),signOut:()=>e({meId:null,signedInAt:void 0}),markWelcomed:t=>e(e=>({welcomed:{...e.welcomed,[t]:(new Date).toISOString()}}))}),{name:c.IS_CAR?'covercharge-car-session-v1':'covercharge-session-v1',storage:(0,i.createJSONStorage)(()=>n.default),version:c.IS_CAR?2:1,partialize:e=>(0,l.persistedSessionSlice)(c.IS_CAR,e),migrate:e=>c.IS_CAR?(0,l.migrateCarSession)(e):e})),w=e=>!a.IS_ISOLATED_VENUE&&e?u.ROSTER.find(t=>t.id===e):void 0,h={owner:'CoverCharge for Managers',staff:'CoverCharge for Staff',chef:'CoverCharge for Head Chef'};async function m(e){const t=globalThis.crypto?.subtle;if(!t)return null;const n=await t.digest('SHA-256',(new TextEncoder).encode(e));return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,'0')).join('')}const y=(0,a.venueKey)('covercharge-device-id');const S=(0,a.venueKey)('covercharge-phone-key');const p=(()=>{try{if('undefined'==typeof window||!window.location)return null;if(c.IS_CAR){try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(null,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}return null}const e=(0,a.venueKey)(`cc-pending-invite:${c.APP_VARIANT}`);let t=(0,s.inviteFromLocation)(window.location.search,window.location.hash);try{t?localStorage.setItem(e,t):t=localStorage.getItem(e)}catch{}if(t&&!/^[A-Za-z0-9_-]{10,64}$/.test(t)&&(t=null),t&&window.history?.replaceState){const e=()=>{try{/[?&#]invite=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};e();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[?&#]invite=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const t of[300,1e3,2500,5e3,1e4,2e4])setTimeout(e,t)}return t}catch{return null}})(),v=(()=>{try{if('undefined'==typeof window||!window.location||c.IS_CAR)return null;const e=(0,s.handoverFromHash)(window.location.hash);if(!e)return null;const t=()=>{try{/[#&]ccchrome=/.test(window.location.href)&&window.history.replaceState(window.history.state,'',(0,s.addressWithoutInvite)(window.location.href))}catch{}};t();try{const e=window.history;for(const t of['pushState','replaceState']){const n=e[t].bind(e);e[t]=(e,t,o)=>n(e,t,null==o?o:/[#&]ccchrome=/.test(String(o))?(0,s.addressWithoutInvite)(new URL(String(o),window.location.href).toString()):o)}}catch{}for(const e of[300,1e3,2500,5e3])setTimeout(t,e);return e}catch{return null}})(),I=(()=>{try{return'undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('go'):null}catch{return null}})(),A=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('loyalty'):null;return e&&/^[A-Za-z0-9-]{4,12}$/.test(e)?e.toUpperCase():null}catch{return null}})(),b=(()=>{try{const e='undefined'!=typeof window&&window.location?new URLSearchParams(window.location.search).get('table'):null;return e&&/^[A-Za-z2-9]{16}$/.test(e)?e.toUpperCase():null}catch{return null}})()},1004,[839,846,849,5,872,1005,15,1003]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.persistedSessionSlice=function(n,o){return n?{welcomed:o.welcomed}:{meId:o.meId,signedInAt:o.signedInAt,welcomed:o.welcomed}},e.migrateCarSession=function(n){return{meId:null,signedInAt:void 0,welcomed:(n&&'object'==typeof n?n:{}).welcomed??{}}},e.carResetsSessionOnLoad=function(n,o){return n&&!o}},1005,[]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"hrRemote",{enumerable:!0,get:function(){return y}}),_e.exampleHr=f,_e.stripHrSamples=m,Object.defineProperty(_e,"useHr",{enumerable:!0,get:function(){return q}});var e,t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),i=r(_d[4]),u=(e=i)&&e.__esModule?e:{default:e},d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const y={live:!1,checkout:null,post:null,vote:null,moderate:null,reply:null,trend:null,shouts:null,log:null,refresh:null},v=(e,t,s)=>(0,c.oneWayToken)(e,`shift:${t}:${s}`),p=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function f(e,t){const s=[];for(let n=14;n>=1;n--){const o=p(t,-n),i=4===n?2:4+7*n%4;for(let t=0;t!((0,s.isAnchorage)(e.venue)&&e.example)),questions:e.questions.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrq-ex-[123]$/.test(e.id))),shouts:e.shouts.filter(e=>!((0,s.isAnchorage)(e.venue)&&/^hrs-ex-[123]$/.test(e.id)))}}const q=(0,d.create)()((0,l.persist)((e,t)=>({secret:(0,c.newSecret)(),answered:[],voted:{},checkins:[],questions:[],shouts:[],log:[],seeded:{},ensure:(s,i)=>{if(n.LIVE_VENUE_BUILD||o.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(s)||t().seeded[s]||y.live)return;const u=f(s,i);e(e=>({seeded:{...e.seeded,[s]:!0},checkins:[...e.checkins,...u.checkins],questions:[...e.questions,...u.questions],shouts:[...e.shouts,...u.shouts]}))},hasAnswered:(e,s)=>t().answered.includes(v(t().secret,e,s)),submit:s=>{const n=t(),o=v(n.secret,s.rid,s.shiftKey);if(n.answered.includes(o))return'already';const i=(0,c.checkInPayload)({venue:s.rid,day:s.day,token:o,morale:s.morale,staffing:s.staffing}),u=s.question?(0,c.cleanQuestion)(s.question):null,d=s.shoutTo?.trim().slice(0,80)||void 0,l=s.shoutBody?.trim().slice(0,280)||void 0;return e({answered:[...n.answered,o].slice(-300)}),y.live&&y.checkout?(y.checkout({rid:s.rid,shiftKey:'',day:i.day,morale:i.morale,staffing:i.staffing,question:u??void 0,kind:s.kind??'up',shoutTo:d,shoutBody:l,token:o}),'queued'):(e(e=>({checkins:[...e.checkins,{venue:i.venue,day:i.day,morale:i.morale,staffing:i.staffing}],questions:u?[...e.questions,{id:(0,h.uuid)(),venue:s.rid,body:u,kind:s.kind??'up',up:0,yes:0,no:0,hidden:!1,postedOn:s.day}]:e.questions,shouts:d?[...e.shouts,{id:(0,h.uuid)(),venue:s.rid,day:s.day,to:d,body:l}]:e.shouts})),'ok')},skip:(s,n)=>{const o=t(),i=v(o.secret,s,n);o.answered.includes(i)||e({answered:[...o.answered,i].slice(-300)})},post:(t,s,n,o)=>{const i=(0,c.cleanQuestion)(s);if(!i)return null;const u=(0,h.uuid)();return e(e=>({questions:[...e.questions,{id:u,venue:t,body:i,kind:n,up:0,yes:0,no:0,hidden:!1,postedOn:o}]})),y.live&&y.post&&y.post(t,u,i,n),u},vote:(s,n)=>{const o=t();if(o.voted[s])return!1;const i=o.questions.find(e=>e.id===s);if(!i||i.hidden)return!1;const u='up'===i.kind?1:n;return e({voted:{...o.voted,[s]:u},questions:o.questions.map(e=>e.id===s?(0,c.applyVote)(e,u):e)}),y.live&&y.vote&&y.vote(s,(0,c.oneWayToken)(o.secret,`vote:${s}`),u),!0},moderate:(s,n,o,i)=>{const u=t().questions.find(e=>e.id===s);u&&(e(e=>({questions:e.questions.map(e=>e.id===s?{...e,hidden:'hide'===n}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:n,reason:o.trim()||void 0,by:i,at:(new Date).toISOString()},...e.log].slice(0,500)})),y.live&&y.moderate&&y.moderate(s,n,o.trim()))},reply:(s,n,o)=>{const i=n.trim().slice(0,600),u=t().questions.find(e=>e.id===s);if(!u)return;const d=(new Date).toISOString();e(e=>({questions:e.questions.map(e=>e.id===s?{...e,reply:i||void 0,replyAt:i?d:void 0}:e),log:[{id:(0,h.uuid)(),venue:u.venue,questionId:s,action:'reply',by:o,at:d},...e.log].slice(0,500)})),y.live&&y.reply&&y.reply(s,i)},setRemoteBoard:(t,s)=>e(e=>({questions:[...e.questions.filter(e=>e.venue!==t),...s]})),upsertRemote:t=>e(e=>({questions:e.questions.some(e=>e.id===t.id)?e.questions.map(e=>e.id===t.id?t:e):[...e.questions,t]}))}),{name:'covercharge-hr-v1',version:3,storage:(0,l.createJSONStorage)(()=>u.default),migrate:async e=>n.LIVE_VENUE_BUILD&&e?(await(0,t.archiveChefCache)('hr',e),{...e,...m(e)}):e}))},1006,[838,835,837,5,839,846,849,1007,870]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANSWERS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_WORDING",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DEFAULT_HR",{enumerable:!0,get:function(){return r}}),e.hrSettingsOf=function(t){const n=t??{},r=n.wording??{},s=Object.fromEntries(Object.entries(o).map(([t,n])=>[t,a(r[t],'intro'===t||'staffing'===t||'question'===t?160:60,n)]));return{on:!1!==n.on,askQuestion:!1!==n.askQuestion,askShout:!1!==n.askShout,board:!1!==n.board,wording:s}},Object.defineProperty(e,"MORALE_STEPS",{enumerable:!0,get:function(){return s}}),e.moraleWord=function(t,n=o){return t<=1?n.moraleLow:t>=5?n.moraleHigh:2===t?'Fairly low':3===t?'OK':'Good'},Object.defineProperty(e,"STAFF_STOPS",{enumerable:!0,get:function(){return u}}),e.snapStaffing=i,e.staffingWord=function(t,n=o){const r=i(t);return r<=12?n.staffLow:r<45?"A bit short":r<=55?n.staffMid:r<88?"A bit over":n.staffHigh},e.oneWayToken=function(n,o){return(0,t.sha256HexSync)(`cc-hr:${n}:${o}`).slice(0,40)},e.newSecret=function(){let t='';const n=globalThis.crypto;if(n?.getRandomValues){return n.getRandomValues(new Uint8Array(24)).forEach(n=>{t+=n.toString(16).padStart(2,'0')}),t}for(let n=0;n<48;n++)t+=Math.floor(16*Math.random()).toString(16);return t},e.checkInPayload=function(t){const n=Math.max(1,Math.min(5,Math.round(t.morale)));return{venue:t.venue,day:t.day,token:t.token,morale:n,staffing:null==t.staffing?null:i(t.staffing)}},e.dayResults=function(t,o=n){const r=new Map;for(const n of t){const t=r.get(n.day)??[];t.push(n),r.set(n.day,t)}const a=[];let s=0;for(const[t,n]of[...r.entries()].sort(([t],[n])=>t.localeCompare(n))){if(n.lengtht.staffing).filter(t=>null!=t);a.push({day:t,answers:n.length,morale:Math.round(n.reduce((t,n)=>t+n.morale,0)/n.length*10)/10,staffing:r.length?Math.round(r.reduce((t,n)=>t+n,0)/r.length):null,short:r.filter(t=>t<45).length,perfect:r.filter(t=>t>=45&&t<=55).length,over:r.filter(t=>t>55).length})}return{shown:a,held:s}},Object.defineProperty(e,"QUESTION_MAX",{enumerable:!0,get:function(){return f}}),e.cleanQuestion=function(t){const n=t.replace(/\s+/g,' ').trim().slice(0,f);return n.length>=3?n:null},e.boardOrder=function(t,n){const o=t=>'up'===t.kind?t.up:t.yes+t.no;return t.filter(t=>n||!t.hidden).sort((t,n)=>Number(t.hidden)-Number(n.hidden)||o(n)-o(t)||n.postedOn.localeCompare(t.postedOn)||t.id.localeCompare(n.id))},e.applyVote=function(t,n){return'up'===t.kind?{...t,up:t.up+1}:1===n?{...t,yes:t.yes+1}:{...t,no:t.no+1}};var t=_r(d[0]);const n=3,o={intro:'Before you go: 3 quick taps, about 15 seconds. Your name is never saved with your answers.',morale:'How was team morale today?',moraleLow:'Low',moraleHigh:'High',staffing:'Was there enough staff on today for the number of customers?',staffLow:'Not enough',staffMid:'Perfect',staffHigh:'Overstaffed',question:'Got a question you\u2019d like to post anonymously for the team to vote on?',shout:'Shout out a teammate?'},r={on:!0,askQuestion:!0,askShout:!0,board:!0,wording:o},a=(t,n,o)=>('string'==typeof t?t.trim().slice(0,n):'')||o;const s=[1,2,3,4,5];const u=[0,12.5,25,37.5,50,62.5,75,87.5,100].map(t=>Math.round(t));function i(t){const n=Math.max(0,Math.min(100,Number.isFinite(t)?t:50));return u.reduce((t,o)=>Math.abs(o-n)>>0;o.push(c>>>24&255,c>>>16&255,c>>>8&255,255&c,h>>>24&255,h>>>16&255,h>>>8&255,255&h);const l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=new Uint32Array(64),f=(t,n)=>t>>>n|t<<32-n;for(let n=0;n>>3,e=f(u[t-2],17)^f(u[t-2],19)^u[t-2]>>>10;u[t]=u[t-16]+n+u[t-7]+e>>>0}let e=l[0],s=l[1],c=l[2],h=l[3],a=l[4],i=l[5],p=l[6],d=l[7];for(let n=0;n<64;n++){const o=d+(f(a,6)^f(a,11)^f(a,25))+(a&i^~a&p)+t[n]+u[n]>>>0,l=(f(e,2)^f(e,13)^f(e,22))+(e&s^e&c^s&c)>>>0;d=p,p=i,i=a,a=h+o>>>0,h=c,c=s,s=e,e=o+l>>>0}l[0]=l[0]+e>>>0,l[1]=l[1]+s>>>0,l[2]=l[2]+c>>>0,l[3]=l[3]+h>>>0,l[4]=l[4]+a>>>0,l[5]=l[5]+i>>>0,l[6]=l[6]+p>>>0,l[7]=l[7]+d>>>0}return Array.from(l).map(t=>t.toString(16).padStart(8,'0')).join('')};const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function n(t){const n=[];for(let e=0;e=55296&&o<=56319&&e+1=56320&&n<=57343&&(o=65536+(o-55296<<10)+(n-56320),e++)}o<128?n.push(o):o<2048?n.push(192|o>>6,128|63&o):o<65536?n.push(224|o>>12,128|o>>6&63,128|63&o):n.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}return n}},1008,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"chairsId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rulesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useReminders",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"rulesOf",{enumerable:!0,get:function(){return A}});var e,r=_r(d[0]),t=(e=r)&&e.__esModule?e:{default:e},n=_r(d[1]),s=_r(d[2]),u=_r(d[3]),o=_r(d[4]),l=_r(d[5]);const c=e=>(0,u.uuidFrom)(`reminder:chairs:${e}`),p=e=>(0,u.uuidFrom)(`break-rules:${e}`),f=()=>(new Date).toISOString(),b=(0,n.create)()((0,s.persist)((e,r)=>({reminders:[],rules:{},done:[],snooze:{},ensure:t=>{const n=r(),s={};n.reminders.some(e=>e.id===c(t))||(s.reminders=[...n.reminders,{...(0,o.defaultChairs)(c(t),t),rid:t}]),n.rules[t]||(s.rules={...n.rules,[t]:{...o.DEFAULT_BREAK_RULES,id:p(t)}}),Object.keys(s).length&&e(s)},add:(r,t)=>{const n=(0,l.uuid)();return e(e=>({reminders:[...e.reminders,{...t,id:n,rid:r,updatedAt:f()}]})),n},update:(r,t)=>e(e=>({reminders:e.reminders.map(e=>e.id===r?{...e,...t,updatedAt:f()}:e)})),remove:r=>e(e=>({reminders:e.reminders.flatMap(e=>e.id!==r?[e]:e.builtIn?[{...e,removed:!0,paused:!0,updatedAt:f()}]:[])})),resetReminder:r=>e(e=>({reminders:e.reminders.map(e=>e.id===r&&'chairs'===e.builtIn?{...(0,o.defaultChairs)(r,e.rid),rid:e.rid,updatedAt:f()}:e)})),setRules:(r,t)=>e(e=>({rules:{...e.rules,[r]:{...(0,o.clampRules)({...e.rules[r]??o.DEFAULT_BREAK_RULES,...t}),id:p(r),updatedAt:f()}}})),resetRules:r=>e(e=>({rules:{...e.rules,[r]:{...o.DEFAULT_BREAK_RULES,id:p(r),updatedAt:f()}}})),markDone:r=>e(e=>({done:[{...r,id:(0,l.uuid)(),at:r.at??f()},...e.done].slice(0,400)})),setSnooze:(r,t)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[r,t]])}))}),{name:'covercharge-reminders-v1',version:1,storage:(0,s.createJSONStorage)(()=>t.default)})),A=e=>(0,o.clampRules)(b.getState().rules[e]??o.DEFAULT_BREAK_RULES)},1009,[839,846,849,863,1010,870]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"LEGAL_LIMIT_MINS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_BREAK_RULES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"REMINDER_WINDOW_MINS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CHAIRS_TEXT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ANCHORAGE_CHAIRS_DAYS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"defaultChairs",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AUDIENCE_LABEL",{enumerable:!0,get:function(){return s}}),e.clampRules=c,Object.defineProperty(e,"validTime",{enumerable:!0,get:function(){return d}}),e.ukClock=l,e.reminderDue=function(t,n){const i=l(n);if(t.paused||!d(t.time)||!t.days.includes(i.dow))return{due:!1,forDate:i.ymd};const o=f(t.time);return{due:i.mins>=o&&i.mins=t.shiftEnd))return null;const r=b(t).filter(n=>n.at<=t.now),i=r.length?r[r.length-1]:null;if(!i)return null;if(t.nowr?i:null}return i};const t=360,n={on:!0,afterMins:240,repeatMins:30,snoozeMins:15},r=180,i='Time to put the chairs up on the tables',o=[4,0],a=(t,n)=>'anchorage'===n?{id:t,text:i,days:[...o],time:'21:00',audience:'all',builtIn:'chairs',push:!0}:{id:t,text:i,days:[5,0],time:'21:00',audience:'all',builtIn:'chairs'},u=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],s={all:'Everyone on shift',foh:'Front of house',kitchen:'Kitchen'};function c(r){const i=(t,n,r,i)=>{const o=Math.round(Number(t));return Number.isFinite(o)?Math.min(i,Math.max(r,o)):n};return{on:!1!==r.on,afterMins:i(r.afterMins,n.afterMins,30,t),repeatMins:i(r.repeatMins,n.repeatMins,5,120),snoozeMins:i(r.snoozeMins,n.snoozeMins,5,60)}}const d=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t);function l(t){const n='number'==typeof t?new Date(t):t,r=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(n).map(t=>[t.type,t.value]));return{dow:u.indexOf(String(r.weekday).slice(0,3)),mins:60*Number(r.hour)+Number(r.minute),ymd:`${r.year}-${r.month}-${r.day}`}}const f=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));const m=(t,n)=>'all'===t||('kitchen'===t?n:!n);function b(t){const n=c(t.rules),r=t.clockIn??t.shiftStart;if(!n.on||void 0===r||t.hadBreak)return[];const i=r+216e5,o=Math.min(void 0!==t.rotaBreak&&t.rotaBreak>r?t.rotaBreak:r+6e4*n.afterMins,i),a=[{stage:1,at:o,label:void 0!==t.rotaBreak&&t.rotaBreak>r&&t.rotaBreak<=i?'Your break on the rota is now.':'Time for your break.'}],u=o+6e4*n.repeatMins;return a.push({stage:2,at:u,label:'Reminder: you haven\u2019t had your break yet.'}),i>u&&a.push({stage:3,at:i,label:'You\u2019ve worked 6 hours without a break. You need a 20-minute break (UK law).'}),a}},1010,[]); +__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)))},1011,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"SYNC_STALE_MS",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"READ_GIVE_UP_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"FAST_GIVE_UP_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"RETRY_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"LIVE_DOWN_MS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"SILENT_MS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"REBUILD_GAP_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"HEARTBEAT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"TICK_MS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"SLEEP_GAP_MS",{enumerable:!0,get:function(){return b}}),_e.syncStale=function(t,n,s=e){const o='string'==typeof t?Date.parse(t):t??0;return!o||!Number.isFinite(o)||n-o>s},_e.superviseSync=function(e){const t=e.now??(()=>Date.now()),d=e.setInterval??((e,t)=>setInterval(e,t)),h=e.clearInterval??(e=>clearInterval(e)),S=e.setTimeout??((e,t)=>setTimeout(e,t));let _=!1,v=!1;const y={fastReads:0,fullReads:0,rebuilds:0,wakes:0,authRefreshes:0,heartbeats:0,givenUp:0};let p=0,E=0,P=0,w=0,A=t(),M=0;const O=async t=>{try{await t()}catch(n){if(!e.isAuthError(n))throw n;y.authRefreshes++,await e.refreshAuth(),await t()}},R=()=>{if(_)return;if(p&&t()-p{e.markServer(),e.flush()},()=>{v||_||(v=!0,S(()=>{v=!1,R()},s))}).finally(()=>{p===o&&(p=0)})},j=()=>{if(E&&t()-E<6e4)return;E&&y.givenUp++;const n=E=t();y.fullReads++,O(e.readAll).then(()=>{e.flush()},()=>{}).finally(()=>{E===n&&(E=0)})},I=t=>{e.wake?.(),R(),j(),e.flush()},L=[d(R,e.fastMs),d(j,6e4),d(()=>{const n=t();n-A>b&&(y.wakes++,I()),A=n,'SUBSCRIBED'===e.realtime()?w=0:w||(w=n);const s=e.lastServerAt()?n-e.lastServerAt():0;(w&&n-w>o||s>u)&&(t()-P=f&&e.heartbeat&&(M=t(),y.heartbeats++,e.heartbeat().catch(()=>{}))},l)],T=()=>{e.doc&&'hidden'===e.doc.visibilityState||I()},U=()=>I();e.doc?.addEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.addEventListener?.(t,U);return{kick:I,stats:()=>({...y}),stop:()=>{_=!0;for(const e of L)h(e);e.doc?.removeEventListener?.('visibilitychange',T);for(const t of['online','focus','pageshow'])e.win?.removeEventListener?.(t,U)}}};const e=6e4,t=3e4,n=1e4,s=2e3,o=45e3,u=9e4,c=12e4,f=6e4,l=5e3,b=2e4},1012,[]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.setClockServer=function(t){s=t,c()},e.markClockUnsent=function(t){o.set(t,Date.now()),c()},e.markClockSent=function(t){o.delete(t)&&c()},e.clockNotSent=l,e.useClockNotSent=function(o){const[,c]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const t=()=>c(t=>t+1);u.add(t);const o=n.mutationQueue.subscribe(t);return()=>{u.delete(t),o()}},[]),l(o)};var t=r(d[0]),n=r(d[1]);const o=new Map,u=new Set,c=()=>{for(const t of u)t()};let s=()=>!1;function l(t){if(!t)return!1;return n.mutationQueue.pending.some(n=>'attendance'===n.table&&n.rowKey===t)||o.has(t)&&s()}n.mutationQueue.onDone(t=>{'attendance'===t.table&&o.delete(t.rowKey)&&c()})},1013,[34,1014]); +__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 l}}),Object.defineProperty(_e,"mutationQueue",{enumerable:!0,get:function(){return o}});var t=_r(d[0]),e=_r(d[1]),s=_r(d[2]);const n='queue:v1',r='queue:failed:v1',h=t=>`${t.table}|${t.venueId}|${t.rowKey}`;class l{items=[];failedItems=[];loaded=null;flushing=null;flushingSince=0;exec=null;listeners=new Set;onFailure=new Set;onSaved=new Set;retryTimer=null;waitTimer=null;backoffMs=2e3;now=()=>Date.now();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(n,[]);this.items=[...t.map(t=>({...t,nextAt:void 0})),...this.items],this.failedItems=await e.kv.get(r,[]),this.emit()})()),this.loaded}get pending(){return this.items}get waiting(){return this.items.filter(t=>t.attempts>0)}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}nextReady(){const t=new Set,e=this.now();for(const s of this.items){const n=h(s);if(!t.has(n)){if(!(s.nextAt&&s.nextAt>e))return s;t.add(n)}}}remove(t){this.items=this.items.filter(e=>e!==t)}flush(){if(this.flushing&&Date.now()-this.flushingSince<6e4)return this.flushing;this.flushingSince=Date.now();let e=null;return e=(async()=>{for(await this.load();this.exec;){if(this.flushing&&this.flushing!==e)return;const n=this.nextReady();if(!n)break;if(!(0,t.isOnline)()){this.scheduleRetry();break}try{const t=await this.exec(n);this.remove(n),this.backoffMs=2e3,'conflict'===t?this.fail(n,'conflict','Row changed on the server (version conflict) or is not visible to you'):this.onSaved.forEach(t=>t(n))}catch(e){n.attempts+=1,n.lastError=String(e?.message??e);const r=e??{};n.lastErr={code:r.code?String(r.code):void 0,status:Number(r.status)||void 0,message:n.lastError.slice(0,300)};const h=(0,s.classifyWriteError)(e);if('network'===h){n.attempts-=1,(0,t.setOnline)(!1),this.scheduleRetry(),await this.persist();break}'retry'===h?n.nextAt=this.now()+(0,s.retryDelayMs)(n.attempts):(this.remove(n),this.fail(n,'rejected',n.lastError))}await this.persist()}this.flushing===e&&(this.flushing=null),this.scheduleWaiting()})(),this.flushing=e,e}retryNow(){for(const t of this.items)t.nextAt=void 0;return this.flush()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}onFailed(t){return this.onFailure.add(t),()=>{this.onFailure.delete(t)}}onDone(t){return this.onSaved.add(t),()=>{this.onSaved.delete(t)}}async clearFailed(){this.failedItems=[],await e.kv.set(r,[]),this.emit()}fail(t,s,n){const h={...t,lastError:n,failedAt:(new Date).toISOString(),reason:s};this.failedItems=[h,...this.failedItems].slice(0,100),e.kv.set(r,this.failedItems),this.onFailure.forEach(t=>t(h))}scheduleWaiting(){this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null);const t=this.items.map(t=>t.nextAt??0).filter(t=>t>0);if(!t.length)return;const e=Math.max(500,Math.min(...t)-this.now());this.waitTimer=setTimeout(()=>{this.waitTimer=null,this.flush()},e)}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(n,this.items),this.emit()}emit(){this.listeners.forEach(t=>t())}}const o=new l},1014,[1011,977,1015]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.classifyWriteError=function(o){if((0,e.isNetworkError)(o))return'network';const{code:n,status:c,msg:l}=t(o);return s(o)?'refused':/^(08|53|57|58)/.test(n)||['40001','40P01','55P03','23505','23503'].includes(n)||/^PGRST30[0-3]$/.test(n)||/jwt|token.*expired/i.test(l)||401===c||408===c||425===c||429===c||c>=500?'retry':409!==c||n?'refused':'retry'},Object.defineProperty(_e,"retryDelayMs",{enumerable:!0,get:function(){return o}}),_e.describeWrite=function(e){const t='rpc'===e.kind?(e.fn??'change').replace(/_/g,' '):n[e.table]??e.table.replace(/_/g,' ').replace(/s$/,''),s=e.values??{},o=s.guest_name??s.name??s.display_name??s.title??s.reason,c='string'==typeof o&&o.trim()?` for ${o.trim().slice(0,60)}`:'';return'delete'===e.kind?`deleting a ${t}${c}`:`the ${t}${c}`},_e.plainReason=function(e,o){const{code:n,status:c,msg:l}=t(e);if('refused'===o)return s(e)?'more than 20 deletes in 10 minutes from one sign-in are stopped to keep your data safe':'42501'===n||403===c||/row-level security|permission/i.test(l)?'your sign-in isn\u2019t allowed to change this':'conflict'===n?'it was changed or removed on another device first':/^(22|23)/.test(n)?'the shared system says some of the details aren\u2019t valid':'P0001'===n&&l?l.slice(0,140):l?`the shared system said: ${l.slice(0,120)}`:'the shared system refused it';return'23505'===n?'the shared system already has another copy of it':'23503'===n?'a related change has to save first':/^PGRST30/.test(n)||401===c||/jwt/i.test(l)?'your sign-in is being refreshed':'the shared system is busy'};var e=r(d[0]);const t=e=>{const t=e&&'object'==typeof e?e:{};return{msg:String(t.message??e??''),code:String(t.code??''),status:Number(t.status??0)||0,hint:String(t.hint??'')}},s=e=>{const s=t(e);return/delete guard/i.test(s.hint)||/too many .* deleted in 10 minutes/i.test(s.msg)};const o=e=>Math.min(5e3*Math.pow(3,Math.max(0,e-1)),3e5),n={bookings:'booking',walk_ins:'walk-in',blocks:'blocked time',sold_out_items:'sold-out mark',sold_out_links:'dish stock link',staff:'staff details',rota_shifts:'rota shift',stock_items:'stock item',stock_events:'stock count',stock_counts:'stock count',chat_messages:'chat message',recipe_cards:'recipe card',order_lists:'order list',order_list_items:'order list item',daily_task_ticks:'task tick',daily_tasks:'daily task',attendance:'clock in or out',cash_ups:'cash-up',table_plans:'table plan',guest_profiles:'guest profile',floor_live:'table status',venues:'venue settings',time_requests:'clock correction request',staff_leave:'time off',scheduled_notifications:'reminder',suppliers:'supplier',supplier_orders:'supplier order',takeaway_orders:'takeaway order'}},1015,[1011]); +__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.3.12.172'},1016,[]); +__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 c}}),e.executeMutation=async function(t){const s=(t,s)=>{throw Object.assign(t,{status:s})};if('rpc'===t.kind){const{error:n,status:r}=await u().rpc(t.fn,t.values??{});return n&&s(n,r),'ok'}const n=u().from(t.table);if('upsert'===t.kind||'insert'===t.kind){const{error:r,status:o}=await n.upsert(t.values??{},{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});if(r&&'stock_events'===t.table&&'23503'===r.code&&/undoes/i.test(String(r.message??''))&&t.values?.undoes){t.values={...t.values,undoes:null};const r=await n.upsert(t.values,{onConflict:t.conflictKey??'id',ignoreDuplicates:'insert'===t.kind});return r.error&&s(r.error,r.status),'ok'}return r&&s(r,o),'ok'}let r='update'===t.kind?n.update(t.values??{}):n.delete();for(const[s,n]of Object.entries(t.match??{}))r=r.eq(s,n);const{data:o,error:c,status:l}=await r.select();c&&s(c,l);return'update'!==t.kind||o&&0!==o.length?'ok':'conflict'};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]);const u=()=>(0,n.getSupabase)();class c{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(t){return s.cache.rows(this.table,t)}get(t,n){return s.cache.get(this.table,t,n)}subscribe(t,n){return s.cache.subscribe(this.table,t,n)}hydrate(t){return s.cache.hydrate(this.table,t)}async refresh(n,r={}){const c=()=>{let t=u().from(this.table).select('*').eq(this.venueCol,n);return this.opts.orderBy&&(t=t.order(this.opts.orderBy.column,{ascending:this.opts.orderBy.ascending??!0})),r.filter&&(t=r.filter(t)),t},l='bookings'===this.table?await(0,t.readPages)(async(t,s)=>{const{data:n,error:r}=await c().order('id').range(t,s);if(r)throw r;return n??[]}):await(async()=>{const{data:t,error:s}=await c().limit(this.opts.limit??1e3);if(s)throw s;return t??[]})();return s.cache.replace(this.table,n,l.map(t=>[this.keyOf(t),t]),t=>o.mutationQueue.hasPending(this.table,n,t)),l}async create(t,n){const u={...1===this.keyColumns.length&&'id'===this.keyColumns[0]?{id:(0,r.uuid)()}:{},...n,[this.venueCol]:t},c=this.keyOf(u);return s.cache.put(this.table,t,c,u),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'insert'===this.opts.writeMode?'insert':'upsert',rowKey:c,values:u,conflictKey:this.opts.conflictKey??'id'}),u}async update(t,n,r,u={}){const c=s.cache.get(this.table,t,n),l={...this.matchFor(n,c),...u,[this.venueCol]:t};s.cache.patch(this.table,t,n,{...r,updated_at:(new Date).toISOString()}),await o.mutationQueue.enqueue({table:this.table,venueId:t,kind:'update',rowKey:n,values:r,match:l})}async remove(t,n){const r=s.cache.get(this.table,t,n),u={...this.matchFor(n,r),[this.venueCol]:t};s.cache.remove(this.table,t,n),await o.mutationQueue.enqueue({table:this.table,venueId:t,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}}},1017,[1018,1019,933,977,1014]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readPages=async function(t,n=1e3){const s=[];for(let c=0;;c+=n){const o=await t(c,c+n-1);if(s.push(...o),o.length`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())}}}},1019,[977]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.staffNickname=t,_e.staffDate=l,_e.staffSyncItem=c,_e.staffRevision=o,_e.staffEdited=function(e,n,t){return o(e,t)!==o(n,t)},_e.staffRow=function(e,t,l,o){const s=c(e,l),m={venue_id:t,external_ref:s.id,display_name:s.name||'Staff',job_title:s.job||null,department:s.dept||null,active:!1!==s.active};l.nickname&&(m.nickname=s.nickname??null);l.display&&(m.display_clock=!0===s.displayClock,m.temp=!0===s.temp,m.temp_until=s.temp?s.tempUntil??null:null);o&&n.test(o)&&!s.ownerAccess&&!s.managerAccess&&(m.role_id=o);return m};const e=/^\d{4}-\d{2}-\d{2}$/,n=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function t(e){if('string'!=typeof e)return null;return e.trim().slice(0,40)||null}function l(n){return'string'==typeof n&&e.test(n)?n:null}function c(e,n={nickname:!0,display:!0}){const c='owner'===e.role||'manager'===e.role||'staff'===e.role?e.role:'staff',o=!0===e.temp,s={id:e.id,name:(e.name??'').trim(),role:c,level:(e.level??'').trim(),job:(e.job??'').trim(),dept:(e.dept??'').trim(),active:!1!==e.active,managerAccess:!0===e.managerAccess,ownerAccess:!0===e.ownerAccess};return'boolean'==typeof e.bookingWrite&&(s.bookingWrite=e.bookingWrite),n.nickname&&(s.nickname=t(e.nickname)),n.display&&(s.displayClock=!0===e.displayClock,s.temp=o,s.tempUntil=o?l(e.tempUntil):null),s}function o(e,n={nickname:!0,display:!0}){const t=c(e,n);return JSON.stringify({name:t.name??'',job:t.job??'',dept:t.dept??'',active:!1!==t.active,...n.nickname?{nickname:t.nickname??null}:{},...n.display?{displayClock:!0===t.displayClock,temp:!0===t.temp,tempUntil:t.tempUntil??null}:{}})}},1020,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useBookingSaves",{enumerable:!0,get:function(){return s}}),_e.notSavedWhat=u,Object.defineProperty(_e,"notSavedLine",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),l=(e=o)&&e.__esModule?e:{default:e};const s=(0,t.create)()((0,n.persist)((e,t)=>({count:()=>Object.keys(t().notSaved).length,notSaved:{},mark:t=>e(e=>({notSaved:{...e.notSaved,[t.id]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}}),clearAll:()=>e({notSaved:{}})}),{name:'covercharge-booking-saves-v1',storage:(0,n.createJSONStorage)(()=>l.default),version:1,partialize:e=>({notSaved:e.notSaved})})),c=e=>{const t=(e??'').split('+').map(e=>e.trim()).filter(Boolean);return t.length?`${t.length>1?'Tables':'Table'} ${t.join(' + ')}`:''};function u(e){const t=c(e.table);if(e.walkIn)return`Walk-in of ${e.partySize}${t?` on ${t}`:''}`;const n=(e.name||'Guest').trim();return t?`${t} for ${n}`:`Booking for ${n} at ${e.time}`}const v=e=>`${u(e)} did not save. Tap to try again.`},1021,[846,849,839]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useTempSaves",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"tempKey",{enumerable:!0,get:function(){return l}}),_e.tempNotSavedLine=function(e,t){const n=[];e&&n.push(1===e?'1 temperature reading':`${e} temperature readings`);t.length&&n.push(1===t.length?`the change to ${t[0]}`:`${t.length} unit changes`);const o=n.join(' and ');return`${o.charAt(0).toUpperCase()}${o.slice(1)} did not save. Tap to try again.`},_e.tempWaitingLine=function(e){return`${1===e?'1 temperature reading is':`${e} temperature readings are`} waiting to send. ${1===e?'It sends':'They send'} by itself when the connection is back.`.replace('They send by itself','They send by themselves')};var e,t=r(d[0]),n=r(d[1]),o=r(d[2]),s=(e=o)&&e.__esModule?e:{default:e};const c=(e,t)=>`${e}:${t}`,u=(0,t.create)()((0,n.persist)((e,t)=>({notSaved:{},count:()=>Object.keys(t().notSaved).length,mark:t=>e(e=>({notSaved:{...e.notSaved,[c(t.table,t.id)]:{...t,at:(new Date).toISOString()}}})),clear:t=>e(e=>{if(!e.notSaved[t])return e;const n={...e.notSaved};return delete n[t],{notSaved:n}})}),{name:'covercharge-temp-saves-v1',storage:(0,n.createJSONStorage)(()=>s.default),version:1,partialize:e=>({notSaved:e.notSaved})})),l=c},1022,[846,849,839]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.pointFromRow=i,_e.pointToRow=n,_e.readingFromRow=r,_e.readingToRow=o,Object.defineProperty(_e,"sameReading",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"readingRev",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"pointRev",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"TEMP_WINDOW_DAYS",{enumerable:!0,get:function(){return l}}),_e.tempUnitsSpec=function(e,t){return{name:'temp_units',table:'temp_units',conflict:'venue_id,id',deletes:!1,list:()=>e.getState().points??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id),writable:t,matchKey:e=>({id:e}),revision:s,knownByRevision:!0,filter:e=>e.order('sort',{ascending:!0}),toRow:(t,i)=>n(t,i,10*Math.max(0,(e.getState().points??[]).findIndex(e=>e.id===t.id))),fromRow:e=>i(e),apply:t=>e.setState(e=>{const i=new Map(t.map(e=>[e.id,e])),n=(e.points??[]).map(e=>i.get(e.id)??e),r=new Set(n.map(e=>e.id));return{points:[...n,...t.filter(e=>!r.has(e.id))]}}),afterRead:t=>{const i=new Map(t.map((e,t)=>[String(e.id),Number(e.sort??t)]));e.setState(e=>{const t=e.points??[],n=[...t.filter(e=>i.has(e.id)).sort((e,t)=>i.get(e.id)-i.get(t.id)),...t.filter(e=>!i.has(e.id))];return n.every((e,i)=>e===t[i])?e:{points:n}})},subscribe:t=>e.subscribe((e,i)=>{e.points!==i.points&&t()})}},_e.tempReadingsSpec=function(e,t){const i=()=>new Date(Date.now()-6912e7).toISOString();return{name:'temp_readings',table:'temp_readings',mode:'insert',conflict:'venue_id,id',deletes:!1,protect:!0,list:()=>e.getState().entries??[],key:e=>e.id,rowKey:e=>String(e.id),syncable:e=>/^[A-Za-z0-9_.:-]{1,64}$/.test(e.id)&&!!e.pointId&&!!e.at,writable:t,matchKey:e=>({id:e}),revision:c,knownByRevision:!0,filter:e=>e.gte('taken_at',i()),inWindow:e=>e.at>=i(),toRow:(e,t)=>o(e,t),fromRow:e=>r(e),supersededBy:(e,t)=>t.some(t=>t.id!==e.id&&a(t,e)),apply:(t,i)=>e.setState(e=>{const n=new Map(t.map(e=>[e.id,e])),r=new Set(i),o=e.entries??[],c=o.filter(e=>n.has(e.id)||!t.some(t=>t.id!==e.id&&a(t,e))).filter(e=>!r.has(e.id)||!o.some(t=>t.id!==e.id&&!r.has(t.id)&&a(t,e))).map(e=>{const t=n.get(e.id);return t?e.photo?{...t,photo:e.photo}:t:e}),s=new Set(c.map(e=>e.id));return{entries:[...t.filter(e=>!s.has(e.id)),...c].sort((e,t)=>t.at.localeCompare(e.at))}}),subscribe:t=>e.subscribe((e,i)=>{e.entries!==i.entries&&t()})}};var e=_r(d[0]);const t=e=>null==e||''===e?void 0:Number(e);function i(e){const i={id:String(e.id),name:String(e.name),kind:e.kind,due:Array.isArray(e.due)?e.due.map(String):[],aliases:Array.isArray(e.aliases)?e.aliases.map(String):[]},n=t(e.min_c),r=t(e.max_c);return void 0!==n&&(i.min=n),void 0!==r&&(i.max=r),e.section&&(i.section=e.section),e.location&&(i.location=String(e.location)),e.archived&&(i.archived=!0),i}function n(e,t,i){return{venue_id:t,id:e.id,name:e.name.slice(0,80),kind:e.kind,location:e.location?.trim()||null,min_c:e.min??null,max_c:e.max??null,due:e.due??[],aliases:e.aliases??[],section:e.section??null,archived:!!e.archived,sort:i}}function r(e){const i={id:String(e.id),pointId:String(e.point_id),name:String(e.point_name),kind:e.kind,at:new Date(e.taken_at).toISOString(),by:String(e.by_name??''),byId:String(e.by_ref??''),app:e.app??'chef',ok:!!e.ok,source:e.source??'typed'},n=t(e.value);void 0!==n&&(i.value=n),null!==e.done&&void 0!==e.done&&(i.done=!!e.done),e.corrective&&(i.corrective=String(e.corrective)),e.note&&(i.note=String(e.note)),e.initials&&(i.initials=String(e.initials)),e.probe_id&&(i.probeId=String(e.probe_id)),e.archived&&(i.archived=!0);const r=t(e.corrected_value);return void 0!==r&&(i.correctedValue=r),e.correction_note&&(i.correctionNote=String(e.correction_note)),e.corrected_by&&(i.correctedBy=String(e.corrected_by)),i}function o(e,t){return{venue_id:t,id:e.id,point_id:e.pointId,point_name:(e.name||'Check').slice(0,200),kind:e.kind,taken_at:e.at,value:e.value??null,done:e.done??null,ok:!!e.ok,by_name:(e.by??'').slice(0,120),by_ref:e.byId||null,app:e.app??null,source:e.source??null,corrective:e.corrective?.slice(0,1e3)||null,note:e.note?.slice(0,1e3)||null,initials:e.initials||null,probe_id:e.probeId||null}}const a=(e,t)=>e.pointId===t.pointId&&e.at===t.at&&(e.value??null)===(t.value??null)&&(e.done??null)===(t.done??null),c=t=>(0,e.hashOf)(r({...o(t,''),archived:t.archived??!1,corrected_value:t.correctedValue??null,correction_note:t.correctionNote??null,corrected_by:t.correctedBy??null})),s=t=>(0,e.hashOf)(i(n(t,'',0))),l=800},1023,[1024]); +__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 c}}),Object.defineProperty(_e,"MASS_REMOVE",{enumerable:!0,get:function(){return l}}),_e.quietly=async function(e){u++;try{await e()}finally{u--;for(const e of p)e.resnapshot()}},Object.defineProperty(_e,"isQuiet",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EntityBridge",{enumerable:!0,get:function(){return w}}),_e.venueChannel=function(e,t,n,s){let i=o().channel(`cc-live:${e}:${Math.random().toString(36).slice(2,8)}`);for(const{table:s,venueColumn:o}of t)i=i.on('postgres_changes',{event:'*',schema:'public',table:s,filter:`${o??'venue_id'}=eq.${e}`},e=>{n(s,'DELETE'===e.eventType?'delete':'upsert','DELETE'===e.eventType?e.old:e.new)});return i.subscribe(e=>s(e)),i},Object.defineProperty(_e,"onConnectivity",{enumerable:!0,get:function(){return n.onConnectivity}});var e=r(d[0]),t=r(d[1]),n=r(d[2]),s=r(d[3]),i=r(d[4]);const o=()=>(0,t.getSupabase)(),h=e=>{if(null===e||'object'!=typeof e)return JSON.stringify(e)??'null';if(Array.isArray(e))return`[${e.map(h).join(',')}]`;const t=e;return`{${Object.keys(t).filter(e=>void 0!==t[e]).sort().map(e=>`${JSON.stringify(e)}:${h(t[e])}`).join(',')}}`},c=e=>{const t=h(e);let n=2166136261;for(let e=0;e>>0;return`${n.toString(36)}.${t.length}`},l=5;let u=0;const p=new Set;const f=()=>u>0;class w{known={};last=new Map;lastRev=new Map;reconciled=!1;applying=!1;massOk=!1;unsub=null;constructor(e,t,n={}){this.spec=e,this.venueId=t,this.ev=n,this.kvKey=`known:${t}:${e.name}`}unsubDone=null;async start(){this.known=await s.kv.get(this.kvKey,{}),this.snapshotLocal(),p.add(this),this.spec.writeBeforeRead&&this.pushUrgent(),this.unsub=this.spec.subscribe(()=>{u>0?this.snapshotLocal():this.applying||!this.reconciled&&!this.spec.writeBeforeRead||this.pushLocalChanges()}),this.unsubDone=i.mutationQueue.onDone(e=>{if(e.table!==this.spec.table||e.venueId!==this.venueId)return;const t=this.spec.list().find(t=>this.spec.key(t)===e.rowKey);t&&(this.known[this.spec.key(t)]=this.kh(t),this.saveKnown())})}pushUrgent(){const e=this.spec;if(e.writable())for(const t of e.list()){const n=e.key(t);!e.syncable(t)||e.urgent&&!e.urgent(t)||this.pending(n)||this.known[n]===this.kh(t)||this.write(t)}}unsavedKeys(){const e=this.spec;return e.list().filter(t=>e.syncable(t)&&(!e.inWindow||e.inWindow(t))&&this.known[e.key(t)]!==this.kh(t)&&!this.pending(e.key(t))).map(t=>e.key(t))}resendUnsaved(e=()=>!1){const t=this.spec;if(!t.writable())return 0;const n=new Set(this.unsavedKeys().filter(t=>!e(t)));let s=0;for(const e of t.list())n.has(t.key(e))&&(this.write(e),s++);return s}stop(){this.unsub?.(),this.unsub=null,this.unsubDone?.(),this.unsubDone=null,p.delete(this)}resnapshot(){this.snapshotLocal()}allowMassRemoveOnce(){this.massOk=!0}rev(e){return this.spec.revision?this.spec.revision(e):c(e)}kh(e){return this.spec.knownByRevision?this.rev(e):c(e)}snapshotLocal(){const e=this.spec.list();this.last=new Map(e.map(e=>[this.spec.key(e),c(e)])),this.lastRev=new Map(e.map(e=>[this.spec.key(e),this.rev(e)]))}saveKnown(){s.kv.set(this.kvKey,this.known)}pending(e){return i.mutationQueue.hasPending(this.spec.table,this.venueId,e)}async read(){const t=()=>{let e=o().from(this.spec.table).select('*').eq(this.spec.venueColumn??'venue_id',this.venueId);return this.spec.filter&&(e=this.spec.filter(e)),e},n=['bookings','walk_ins','temp_readings','temp_units'].includes(this.spec.table)?await(0,e.readPages)(async(e,n)=>{const{data:s,error:i}=await t().order('id').range(e,n);if(i)throw i;return s??[]}):await(async()=>{const{data:e,error:n}=await t().limit(2e3);if(n)throw n;return e??[]})();this.merge(n,!this.reconciled),this.reconciled=!0,this.spec.afterRead?.(n)}merge(e,t){const n=this.spec,s=new Map(n.list().map(e=>[n.key(e),e])),i=new Set,o=[],h=[],u=[],p=[];for(const t of e){const e=n.rowKey(t),h=n.fromRow(t);if(!h)continue;i.add(e),p.push(h);const l=c(h),f=this.kh(h),w=s.get(e);if(!this.pending(e)){if(w){const t=this.kh(w);if(this.rev(w)===this.rev(h)){this.known[e]=f,c(w)!==l&&o.push(h);continue}if(this.known[e]&&t!==this.known[e]&&n.writable()&&n.syncable(w)){u.push(w);continue}}o.push(h),this.known[e]=f}}const f=n.authoritative?.(e)??null,w=[];for(const[e,t]of s)i.has(e)||this.pending(e)||(!f||!f(t)||n.writable()&&n.syncable(t)||n.inWindow&&!n.inWindow(t)?n.syncable(t)&&(n.inWindow&&!n.inWindow(t)||(this.known[e]?h.push(e):n.writable()&&!n.supersededBy?.(t,p)&&u.push(t))):w.push(e));!e.length&&n.keepOnEmpty?.()&&(h.length=0,w.length=0);const v=this.massOk;if(this.massOk=!1,h.length>l&&!v)this.ev.onSuspect?.(n.name,`read would remove ${h.length} of ${s.size}`),h.length=0,u.length=0;else for(const e of h)delete this.known[e];for(const e of w)delete this.known[e],h.push(e);this.applyRemote(o,h);for(const e of u)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=c(i);this.known[s]=this.kh(i),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=c(s),i=this.rev(s);if(this.last.get(n)===t)continue;const o=this.lastRev.get(n);this.last.set(n,t),this.lastRev.set(n,i),void 0!==o&&o===i||(e.syncable(s)&&e.writable()&&this.known[n]!==this.kh(s)&&(!this.pending(n)||e.writeBeforeRead)?this.write(s):e.syncable(s)&&!e.writable()&&this.known[n]!==this.kh(s)&&this.ev.onSkipped?.(e.name,n))}const n=[...this.last.keys()].filter(e=>!t.has(e));for(const e of n)this.last.delete(e),this.lastRev.delete(e);const s=e.writable()&&!1!==e.deletes&&'insert'!==e.mode&&'update'!==e.mode?n.filter(e=>this.known[e]):[];if(e.protect&&s.length>l)return this.ev.onSuspect?.(e.name,`${s.length} items vanished at once; not deleted`),void this.saveKnown();for(const t of s)delete this.known[t],i.mutationQueue.enqueue({table:e.table,venueId:this.venueId,kind:'delete',rowKey:t,match:{...this.deleteMatch(t),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 s;try{s=t.toRow(e,this.venueId)}catch(e){return void this.ev.onError?.(t.name,String(e?.message??e))}if('update'===t.mode){const e=t.venueColumn??'venue_id';i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'update',rowKey:n,values:s,match:{...t.matchKey?t.matchKey(n):{},[e]:this.venueId}})}else i.mutationQueue.enqueue({table:t.table,venueId:this.venueId,kind:'insert'===t.mode?'insert':'upsert',rowKey:n,values:s,conflictKey:t.conflict??'id'});this.ev.onActivity?.()}}},1024,[1018,933,1011,977,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_ACTOR",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CAR_DEVICE_ID",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"CAR_DEFAULT_LABEL",{enumerable:!0,get:function(){return t}}),e.carDeviceIdentity=u,e.actorStamp=function(r){if(r.isCar)return n;if('device'===r.kind)return'Display';return r.staffRef&&String(r.staffRef).trim()||r.fallback||'Staff'},e.migrateCarStaffIdentity=function(n){return n?.venueId?u({venueId:n.venueId,venueSlug:n.venueSlug,venueName:n.venueName,label:n.label}):null},e.carPairApproved=function(n){return'approved'===String(n?.status??'')&&!(!n?.venue_id&&!n?.venueId)};const n='Car',r='car-device',t='Tesla';function u(r){return{kind:'device',venueId:String(r.venue_id??r.venueId??''),venueSlug:String(r.venue_slug??r.venueSlug??'anchorage'),venueName:String(r.venue_name??r.venueName??'The Anchorage'),canWrite:!0,role:'owner',displayName:n,label:r.label&&String(r.label).trim()||t}}},1025,[]); +__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 b}}),Object.defineProperty(_e,"useBlocks",{enumerable:!0,get:function(){return m}}),_e.blockClock=function(e){if('string'==typeof e){const t=/(\d{1,2}):(\d{2})/.exec(e);if(t)return`${t[1].padStart(2,'0')}:${t[2]}`}return e instanceof Date&&!Number.isNaN(e.getTime())?`${String(e.getHours()).padStart(2,'0')}:${String(e.getMinutes()).padStart(2,'0')}`:void 0},Object.defineProperty(_e,"venueWide",{enumerable:!0,get:function(){return k}}),_e.blockedTablesAt=v,Object.defineProperty(_e,"blocksOn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"areaBlocksOn",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tableKey",{enumerable:!0,get:function(){return M}}),_e.closedAreasAt=function(e,t,o,n){const a=(0,u.toMins)(n),s=p(e,t,o).filter(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).map(e=>e.areaId);return new Set([...s,...[...v(e,t,o,n)].map(M)])},_e.blockAt=S,_e.currentBlocks=function(e,t,o,n){return e.filter(e=>e.rid===t&&!e.removedAt&&(e.date>o||e.date===o&&(0,u.toMins)(e.to)>(0,u.toMins)(n))).sort((e,t)=>e.date===t.date?(0,u.toMins)(e.from)-(0,u.toMins)(t.from):e.date({blocks:[],removed:[],add:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o={...t,id:(0,a.uuid)(),createdAt:(new Date).toISOString(),source:'covercharge'};return e(e=>({blocks:[...e.blocks,o]})),o},addMany:t=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);const o=(new Date).toISOString(),n=t.map(e=>({...e,id:(0,a.uuid)(),createdAt:o,source:'covercharge'}));return e(e=>({blocks:[...e.blocks,...n]})),n},update:(t,o,n)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>({blocks:e.blocks.map(e=>e.id===t?{...e,...o,id:t,editedAt:(new Date).toISOString(),editedBy:n}:e)}))},remove:(t,o)=>{if(!(0,f.currentCanChangeBookings)())throw new Error(l.BOOKING_VIEW_ONLY);e(e=>{const n=e.blocks.find(e=>e.id===t);return n?{blocks:e.blocks.filter(e=>e.id!==t),removed:[...e.removed,{...n,removedAt:(new Date).toISOString(),removedBy:o??n.by}]}:e})},put:t=>e(e=>{const o=e.blocks.filter(e=>e.id!==t.id),n=e.removed.filter(e=>e.id!==t.id);return t.removedAt?{blocks:o,removed:[...n,t]}:{blocks:[...o,t],removed:n}})}),{name:'covercharge-blocks-v1',storage:(0,c.createJSONStorage)(()=>n.default),version:2,migrate:e=>{const t=e??{};return{blocks:t.blocks??[],removed:t.removed??[]}}}));const k=e=>!e.areaId&&!e.tables?.length;function v(e,t,o,n){const a=(0,u.toMins)(n);return new Set(e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&e.tables?.length&&a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to)).flatMap(e=>e.tables))}const O=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&k(e)).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),p=(e,t,o)=>e.filter(e=>e.rid===t&&e.date===o&&!e.removedAt&&!!e.areaId).sort((e,t)=>(0,u.toMins)(e.from)-(0,u.toMins)(t.from)),M=e=>`tbl:${e}`;function S(e,t,o,n){const a=(0,u.toMins)(n);return O(e,t,o).find(e=>a>=(0,u.toMins)(e.from)&&a<(0,u.toMins)(e.to))}const $=(e,t,o,n)=>S(e,t,o,n),h=e=>e.privateFunction?`${e.privateFunction.title} \xb7 ${e.privateFunction.covers} Covers \xb7 ${e.areaName??'Whole venue'} \xb7 until ${e.to}`:e.tables?.length?`${e.tables.map(t.tableNumbers).join(', ')} blocked until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:e.areaId?`${e.areaName??'Area'} closed until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`:`Bookings paused until ${e.to}${e.reason?` \xb7 ${e.reason}`:''}`,y=(e,t)=>{const o=m(e=>e.blocks);return O(o,e,t)}},1026,[860,839,870,846,849,858,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BOOKING_VIEW_ONLY",{enumerable:!0,get:function(){return n}}),e.isKitchenPorter=o,e.canChangeBookings=function(n){return!n||(!('owner'!==n.role&&'manager'!==n.role&&!n.ownerAccess&&!n.managerAccess)||('boolean'==typeof n.bookingWrite?n.bookingWrite:!o(n)))},Object.defineProperty(e,"BOOKING_CHANGE_ACTIONS",{enumerable:!0,get:function(){return t}});const n='View only. Ask a manager to change bookings.';function o(n){return!(!n||'staff'!==n.role)&&/porter|KP/i.test(n.job??'')}const t=new Set(['add_walkin','seat_booking','finish_booking','no_show','cancel_booking','move_booking','change_booking','decide_booking','block_table','waitlist_seat'])},1027,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.currentCanChangeBookings=function(){const o=t.useSession.getState().meId;if(!o)return!0;const u=n.useOwner.getState().staff.find(n=>n.id===o&&n.active);return(0,s.canChangeBookings)(u)};var n=r(d[0]),t=r(d[1]),s=r(d[2])},1028,[891,1004,1027]); +__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 u}}),Object.defineProperty(_e,"seedPlan",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"useFloor",{enumerable:!0,get:function(){return p}}),_e.hashOldPins=f,Object.defineProperty(_e,"usePlan",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useDisplaySettings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"planOf",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return j}}),_e.tablesLabel=v,_e.tableCardLabel=function(e){return(0,t.withTableWord)(v(e))},Object.defineProperty(_e,"joinTables",{enumerable:!0,get:function(){return S}});var e,n=r(d[0]),t=r(d[1]),a=r(d[2]),s=(e=a)&&e.__esModule?e:{default:e},i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);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]}})});const u={privacy:!0,idleMins:2,pinOn:!1,...i.DEFAULT_WAKE,tonightCards:!0},b=e=>'souters'===e||n.IS_ISOLATED_VENUE&&'souters'===n.VENUE_RID?{areas:[{id:'su-restaurant',name:'Restaurant'},{id:'su-bar',name:'Bar'},{id:'su-mezzanine',name:'Mezzanine / private dining'},{id:'su-garden',name:'Beer garden',outdoor:!0},{id:'su-icecream',name:'Ice cream & cake corner'}],tables:[],joins:[],sections:[],fixtures:[]}:'kirkmichael'===e||n.IS_ISOLATED_VENUE&&'kirkmichael'===n.VENUE_RID?{areas:[{id:'km-restaurant',name:'Restaurant'},{id:'km-bar',name:'Bar'},{id:'km-private',name:'Private dining',label:'The Room (about 18 covers) \u2014 table plan to confirm'}],tables:[],joins:[],sections:[],fixtures:[]}:['wildings','greenside'].includes(e)||n.IS_ISOLATED_VENUE?{areas:[],tables:[],joins:[],sections:[],fixtures:[]}:'anchorage'===e?(0,c.anchoragePlan)():(0,c.starterPlan)(),p=(0,l.create)()((0,o.persist)((e,t)=>{const a=e=>t().plans[e]??b(e);return{plans:n.IS_ISOLATED_VENUE?{[n.VENUE_RID]:b(n.VENUE_RID)}:{anchorage:(0,c.anchoragePlan)()},live:{},settings:{},smsLog:[],setPlan:(n,t)=>e(e=>({plans:{...e.plans,[n]:t}})),updateTable:(n,t,s)=>{const i=a(n);e(e=>({plans:{...e.plans,[n]:{...i,tables:i.tables.map(e=>e.id===t?{...e,...s}:e)}}}))},addTable:(n,t)=>{const s=a(n);e(e=>({plans:{...e.plans,[n]:{...s,tables:[...s.tables,t]}}}))},removeTable:(n,t)=>{const s=a(n),i=s.tables.find(e=>e.id===t);e(e=>({plans:{...e.plans,[n]:{...s,tables:s.tables.filter(e=>e.id!==t),joins:s.joins.filter(e=>!i||!e.tables.includes(i.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]:{...u,...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]:b(n)}}))}},{name:'covercharge-floor-v1',version:6,storage:(0,o.createJSONStorage)(()=>s.default),migrate:(e,n)=>{const t=e??{};let a=t;if(n<2){const e={};for(const[n,a]of Object.entries(t.plans??{}))e[n]='anchorage'===n?(0,c.anchoragePlan)():(0,c.normalisePlan)(a);e.anchorage=(0,c.anchoragePlan)(),a={...t,plans:e,live:{}}}else if(n<3)a={...t,plans:{...t.plans??{},anchorage:(0,c.anchoragePlan)()}};else if(n<4){const e=t.plans?.anchorage;e&&(a={...t,plans:{...t.plans,anchorage:{...e,joins:(e.joins??[]).filter(e=>!(2===e.tables.length&&e.tables.includes('1')&&e.tables.includes('2')))}}})}return n<5&&(a={...a,settings:f(a.settings)}),n<6&&a.plans?.anchorage&&(a={...a,plans:{...a.plans,anchorage:(0,c.withSeedBest)('anchorage',a.plans.anchorage)}}),a}}));function f(e){const n={};for(const[t,a]of Object.entries(e??{})){const{pin:e,...s}=a??{};n[t]={...u,...s,...'pinHash'in s?{}:(0,i.fromOldPin)(e)}}return n}const h=e=>p(n=>n.plans[e])??E(e),N={};function E(e){return N[e]??=b(e)}const O=e=>{const n=p(n=>n.settings[e]);return n?{...u,...n}:u},P=e=>p.getState().plans[e]??E(e),j=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[];function v(e){const n=j((0,t.tableNumbers)(e));if(!n.length)return'';if(1===n.length)return n[0];const a=n.map(e=>/^\d+$/.test(e)?Number(e):NaN),s=a.every(e=>!Number.isNaN(e))?[...n].sort((e,n)=>Number(e)-Number(n)):n;return a.every(e=>!Number.isNaN(e))&&s.length>=3&&s.every((e,n)=>0===n||Number(e)===Number(s[n-1])+1)?`${s[0]}\u2013${s[s.length-1]}`:s.join(' + ')}const S=e=>[...new Set(e)].sort((e,n)=>/^\d+$/.test(e)&&/^\d+$/.test(n)?Number(e)-Number(n):e.localeCompare(n)).join('+')},1029,[5,860,839,1030,846,849,859]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_WAKE_PIN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_WAKE_SALT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"hashWakePin",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"DEFAULT_WAKE",{enumerable:!0,get:function(){return o}}),e.newSalt=u,e.wakePinProblem=function(n){return/^\d{6,8}$/.test(n)?/^(\d)\1+$/.test(n)||'0123456789012'.includes(n)||'9876543210987'.includes(n)?'Pick a PIN that is harder to guess (not all the same digit or a run like 123456).':n===t?'Pick a new PIN, not the starting one.':null:'The wake PIN must be 6 to 8 digits.'},e.makeWakePin=function(n,t=u()){return{pinHash:a(n,t),pinSalt:t,pinLen:n.length,pinDefault:!1}},Object.defineProperty(e,"wakePinMatches",{enumerable:!0,get:function(){return l}}),e.fromOldPin=function(n){const i='string'==typeof n&&/^\d{4,8}$/.test(n)?n:t;if(i===t)return{...o};const l=u();return{pinHash:a(i,l),pinSalt:l,pinLen:i.length,pinDefault:!1}};var n=r(d[0]);const t='2580',i='cc-wake-default',a=(t,i)=>(0,n.sha256HexSync)(`cc-wake:${i}:${t}`),o={pinHash:a(t,i),pinSalt:i,pinLen:4,pinDefault:!0};function u(){const n=globalThis.crypto,t=new Uint8Array(12);if(n?.getRandomValues)n.getRandomValues(t);else for(let n=0;nn.toString(16).padStart(2,'0')).join('')}const l=(n,t)=>a(t,n.pinSalt)===n.pinHash},1030,[1008]); +__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 l}}),Object.defineProperty(_e,"useSheets",{enumerable:!0,get:function(){return f}});var e,s=r(d[0]),t=r(d[1]),h=r(d[2]),n=r(d[3]),o=(e=n)&&e.__esModule?e:{default:e},c=r(d[4]),i=r(d[5]),u=r(d[6]);const p=()=>h.IS_ISOLATED_VENUE||s.LIVE_VENUE_BUILD?{}:{anchorage:u.ANCHORAGE_SHEETS.filter(e=>!e.placeholder).map(e=>({...e,items:e.items.map(e=>({...e}))}))},l=(0,c.create)()((0,i.persist)(e=>({sheets:p(),opened:{},upsert:(s,t)=>e(e=>{const h=e.sheets[s]??[];return{sheets:{...e.sheets,[s]:h.some(e=>e.id===t.id)?h.map(e=>e.id===t.id?t:e):[...h,t]}}}),patch:(s,t,h)=>e(e=>({sheets:{...e.sheets,[s]:(e.sheets[s]??[]).map(e=>e.id===t?{...e,...h}: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&&p().anchorage||[]}}))}),{name:'covercharge-ordersheets-v1',storage:(0,i.createJSONStorage)(()=>o.default),version:3,migrate:async e=>{const h=e;return s.LIVE_VENUE_BUILD?(await(0,t.archiveChefCache)('order-sheets',h),{...h,sheets:{...h.sheets,anchorage:(h.sheets.anchorage||[]).filter(e=>!('os-veg'===e.id&&e.placeholder))}}):h}})),_=[],f=e=>l(s=>s.sheets[e])??_},1031,[837,838,5,839,846,849,1032]); +__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 n}}),Object.defineProperty(e,"DAY3",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAYS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"wd",{enumerable:!0,get:function(){return i}}),e.dayRange=function(t){const n=[...new Set(t)].sort((t,n)=>t-n);if(!n.length)return'';if(7===n.length)return'every day';return n.every((t,o)=>o===0||t===n[o-1]+1)&&n.length>=3?`${o[n[0]]} to ${o[n[n.length-1]]}`:n.map(t=>o[t]).join(', ')},e.nextDelivery=a,Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return d}}),e.remindersFor=function(t,n,o={}){const d=i(n);return t.filter(t=>t.orderDays.includes(d)).flatMap(t=>{if(o[t.id]&&new Date(o[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=a(t,n),c=t.reminder||`Order ${t.name} today${l?` for ${s[i(l)]}`:''}`;return[{supplierId:t.id,name:t.name,text:`${c}${t.cutoff?d?` (cut-off ${t.cutoff} passed)`:` by ${t.cutoff}`:''}`,tone:d?'red':'amber',cutoffPassed:d}]})},e.orderLines=function(n,o,s,i=""){const a=n.items.filter(t=>(o[t.id]??0)>0).map(n=>`${(0,t.fishInStone)(i,n)?(0,t.fishQtyText)(i,n,o[n.id]):`${l(o[n.id])} ${n.unit}`} ${n.name}`.replace(/\s+/g,' ').trim());return s.split('\n').map(t=>t.trim()).filter(Boolean).forEach(t=>a.push(t)),a},e.orderMessage=function(t,n,o,s,i,l){const c=a(t,l);return[`Hi ${t.contact||t.name.split(' (')[0]}, order from ${n}${o?`, ${o}`:''}${c?` for ${d(c)}`:''}:`,...s.map(t=>`- ${t}`),'',`Thanks, ${i}`].join('\n')},e.intlDigits=c,Object.defineProperty(e,"smsLink",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"waLink",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"telLink",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"sid",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"ANCHORAGE_SHEETS",{enumerable:!0,get:function(){return k}});var t=r(_d[0]);const n={online:'Online',phone:'Phone',text:'Text message',whatsapp:'WhatsApp',tbc:'To be decided'},o=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],s=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],i=t=>(t.getDay()+6)%7;function a(t,n){const o=null!=t.deliversOn?[t.deliversOn]:t.deliveryDays;if(!o.length)return null;for(let t=1;t<=7;t++){const s=new Date(n);if(s.setDate(s.getDate()+t),o.includes(i(s)))return s}return null}const d=t=>t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'});const l=t=>Number.isInteger(t)?String(t):t.toFixed(1).replace(/\.0$/,'');function c(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)}`,m=(t,n)=>`https://wa.me/${c(t)}?text=${encodeURIComponent(n)}`,f=t=>`tel:${t.replace(/[^\d+]/g,'')}`;let p=0;const h=(t="os")=>`${t}-${Date.now().toString(36)}${(p++).toString(36)}`,y=(t,n,o)=>({id:t,name:n,unit:o}),b=t=>({number:'',url:'',deliveryDays:[],orderDays:[],cutoff:'',frequency:'',reminder:'',priceCapPerKg:0,seller:'',items:[],notes:'',...t}),k=[b({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:[y('rd-chips','Frozen chips','boxes'),y('rd-oil','Fryer oil','tubs'),y('rd-flour','Flour','bags'),y('rd-rice','Rice','bags'),y('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.'}),b({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.'}),b({id:'os-peroni',name:'J. Pieroni & Sons',goods:'Seafood (fish merchant, Ayr)',method:'phone',url:'https://pieronis.com',urlLabel:'Open pieronis.com',deliveryDays:[0,1,2,3,4,5],frequency:'Phone order',items:[y('pa-haddock','Haddock fillets','kg'),y('pa-mussels','Mussels','kg'),y('pa-scallops','Scallops','kg'),y('pa-salmon','Salmon','kg')],notes:'Phone order. Press Call, then read the order from the screen.'}),b({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:[y('sb-langs','Langoustines','kg'),y('sb-smoked','Smoked haddock','kg')]}),b({id:'os-tarelgin',name:'Tarelgin',goods:'Butcher',method:'text',frequency:'Text order',items:[y('tg-steak','Ribeye steaks',''),y('tg-mince','Steak mince','kg'),y('tg-chicken','Chicken breasts',''),y('tg-sausage','Sausages','kg')]}),b({id:'os-mills',name:'Mills',goods:'Milk',method:'whatsapp',frequency:'WhatsApp message',items:[y('ml-milk','Milk','litres'),y('ml-cream','Double cream','litres'),y('ml-butter','Butter','kg')]}),b({id:'os-kittyfisher',name:'Kittyfisher boat (Big Sean)',goods:'Lobsters and crabs',method:'text',contact:'Sean',frequency:'Whenever stock is low',shellfish:!0,items:[y('kf-lobster','Lobsters',''),y('kf-crab','Crabs','')],notes:'Text Big Sean whenever the lobster or crab count runs low.'}),b({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:[y('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.'})]},1032,[984]); +__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 u}}),Object.defineProperty(_e,"SEED_RECIPES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"WASTE_REASONS",{enumerable:!0,get:function(){return f}}),_e.stripKitchenExamples=S,Object.defineProperty(_e,"useKitchen",{enumerable:!0,get:function(){return w}});var e,t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),d=(e=o)&&e.__esModule?e:{default:e},c=_r(_d[6]),l=_r(_d[7]);const p=(e,t,s,i,n,r,o,d=[],c)=>({id:e,name:t,unit:s,cost:i,supplierId:n,par:r,onHand:o,allergens:d,prevCost:c}),u=[p('haddock','Haddock fillet','kg',1848,'sup-1',14,9.5,['fish'],1650),p('smk-haddock','Smoked haddock','kg',1500,'sup-1',4,3.2,['fish']),p('smk-salmon','Smoked salmon','kg',2800,'sup-1',3,1.1,['fish']),p('crab','White and brown crab meat','kg',3800,'sup-1',3,2.4,['crustaceans']),p('mussels','Rope mussels','kg',450,'sup-1',12,0,['molluscs']),p('langoustine','Langoustines','kg',2600,'sup-1',6,4.5,['crustaceans']),p('lobster','Lobster (whole)','each',1800,'sup-1',6,4,['crustaceans']),p('prawns','Prawns (cooked, peeled)','kg',1400,'sup-1',3,2.6,['crustaceans']),p('beef-fillet','Beef fillet','kg',4800,'sup-2',4,2.9),p('steak','Braising steak','kg',1200,'sup-2',8,6.2),p('patty','Burger patty 6 oz','each',160,'sup-2',40,18),p('chicken','Chicken breast','kg',950,'sup-2',10,7.5),p('chorizo','Chorizo','kg',1400,'sup-2',2,1.6,['sulphites']),p('haggis','Haggis','kg',900,'sup-2',4,3.5,['gluten','celery']),p('potatoes','Potatoes (chipping)','kg',90,'sup-3',75,40),p('onions','Onions','kg',110,'sup-3',15,11),p('leaves','Salad leaves','kg',700,'sup-3',3,.8),p('lemons','Lemons','each',25,'sup-3',60,44),p('milk','Whole milk','L',110,'sup-4',20,14,['milk']),p('cream','Double cream','L',380,'sup-4',12,9,['milk']),p('butter','Butter','kg',850,'sup-4',6,4.5,['milk']),p('cheddar','Mature cheddar','kg',900,'sup-4',5,3.8,['milk']),p('parmesan','Parmesan','kg',1800,'sup-4',2,1.4,['milk']),p('eggs','Free-range eggs','each',28,'sup-4',120,90,['eggs']),p('ice-cream','Vanilla ice cream','L',450,'sup-4',10,7,['milk','eggs']),p('flour','Plain flour','kg',90,'sup-5',16,12,['gluten']),p('batter','Beer batter mix','kg',220,'sup-5',12,3.5,['gluten']),p('pastry','Puff pastry','kg',450,'sup-5',6,4.2,['gluten','milk']),p('macaroni','Macaroni','kg',180,'sup-5',6,5,['gluten']),p('penne','Penne','kg',180,'sup-5',6,4.5,['gluten']),p('buns','Brioche buns','each',45,'sup-5',40,30,['gluten','eggs','milk','sesame']),p('baguette','Garlic baguette','each',90,'sup-5',24,16,['gluten','milk']),p('oil','Rapeseed oil (fryer)','L',200,'sup-5',60,32),p('sponge','Sticky toffee sponge (portion)','each',95,'sup-5',30,22,['gluten','eggs','milk']),p('truffle-oil','Truffle oil','L',3e3,'sup-5',1,.6)],k=(e,t,s)=>({dishId:e,yield:t,lines:s.map(([e,t])=>({ing:e,qty:t}))}),h=[k('a-fishsupper','1 portion (220 g fillet)',[['haddock',.22],['batter',.06],['potatoes',.35],['oil',.05],['lemons',1]]),k('a-skink','1 bowl',[['smk-haddock',.08],['potatoes',.1],['milk',.15],['cream',.05],['onions',.03],['butter',.01]]),k('a-salmon','1 plate',[['smk-salmon',.07],['cream',.03],['leaves',.02],['lemons',1]]),k('a-haggis','1 plate',[['haggis',.1],['flour',.02],['eggs',1],['oil',.03]]),k('a-crabcakes','2 cakes',[['crab',.08],['potatoes',.06],['flour',.02],['eggs',1],['leaves',.02]]),k('a-tempura','1 plate',[['haddock',.07],['prawns',.05],['onions',.05],['batter',.06],['oil',.04],['lemons',1]]),k('a-mini','Kids fish & chips + ice cream',[['haddock',.1],['potatoes',.2],['batter',.03],['oil',.03],['ice-cream',.05]]),k('a-pie','1 pie',[['steak',.22],['pastry',.08],['onions',.05],['potatoes',.3],['oil',.03]]),k('a-chicken','1 plate',[['chicken',.22],['potatoes',.25],['cream',.05],['butter',.02]]),k('a-maccheese','1 bowl',[['macaroni',.12],['cheddar',.08],['milk',.2],['butter',.02],['flour',.015]]),k('a-penne','1 bowl',[['penne',.12],['chicken',.15],['chorizo',.04],['cream',.08],['parmesan',.01]]),k('a-caesar','1 plate',[['chicken',.16],['leaves',.08],['parmesan',.015],['eggs',1],['baguette',.25]]),k('a-moules','1 pot',[['mussels',.5],['cream',.08],['onions',.03],['baguette',.5]]),k('a-fillet','8 oz steak',[['beef-fillet',.227],['potatoes',.35],['onions',.05],['oil',.05],['butter',.02]]),k('a-claymore','1 burger',[['patty',1],['buns',1],['cheddar',.03],['potatoes',.3],['onions',.06],['batter',.03],['oil',.05]]),k('a-langoustines','1 plate',[['langoustine',.35],['butter',.03],['baguette',.5],['leaves',.03],['lemons',1]]),k('a-lobster','1 lobster',[['lobster',1],['butter',.04],['potatoes',.3],['oil',.04],['leaves',.03],['lemons',1]]),k('a-smorgasbord','Serves one',[['langoustine',.3],['mussels',.3],['crab',.08],['prawns',.1],['smk-salmon',.06],['leaves',.05],['lemons',2]]),k('a-deluxe','Serves two',[['lobster',1],['langoustine',.5],['crab',.15],['mussels',.5],['prawns',.15],['smk-salmon',.1],['leaves',.1],['lemons',3],['baguette',1]]),k('a-chips','1 side',[['potatoes',.35],['oil',.05]]),k('a-onionrings','1 side',[['onions',.15],['batter',.06],['oil',.04]]),k('a-garlicbread','1 side',[['baguette',.5],['butter',.02]]),k('a-truffle','1 side',[['potatoes',.35],['oil',.05],['parmesan',.015],['truffle-oil',.005]]),k('a-salad','1 side',[['leaves',.06],['lemons',.5]]),k('a-stp','1 portion',[['sponge',1],['cream',.05],['butter',.02],['ice-cream',.08]])],f=['Out of date','Spoiled','Over-production','Dropped / burnt','Returned by customer','Prep trim'],b=(e,t=10)=>{const s=new Date;return s.setDate(s.getDate()-e),s.setHours(t,0,0,0),s.toISOString()},y=e=>`${e}-${Math.random().toString(36).slice(2,8)}`;function v(){return{ingredients:u.map(e=>({...e})),recipes:h,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:b(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:b(1,21),by:'Head Chef (example)',item:'Haddock fillet',ing:'haddock',qty:.6,unit:'kg',reason:'Over-production',cost:1109},{id:'w2',at:b(2,15),by:'Head Chef (example)',item:'Salad leaves',ing:'leaves',qty:.5,unit:'kg',reason:'Spoiled',cost:350},{id:'w3',at:b(3,20),by:'Head Chef (example)',item:'Fish supper',qty:1,unit:'portion',reason:'Dropped / burnt',cost:517},{id:'w4',at:b(4,11),by:'Head Chef (example)',item:'Double cream',ing:'cream',qty:1,unit:'L',reason:'Out of date',cost:380},{id:'w5',at:b(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:b(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:b(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:b(0,9),by:'Head Chef (example)',kind:'fridge',unit:'Walk-in fridge',temp:3},{id:'t2',at:b(0,9),by:'Head Chef (example)',kind:'freezer',unit:'Chest freezer',temp:-20}]}}function S(e){const t=v(),s=(e,t)=>t.some(t=>JSON.stringify(t)===JSON.stringify(e)),i=e.recipes.filter(e=>!s(e,t.recipes)),r=e.deliveries.filter(e=>!t.deliveries.some(t=>t.id===e.id&&t.supplierId===e.supplierId&&t.due===e.due&&'expected'===e.status&&!e.checkedBy&&!e.note&&JSON.stringify(t.lines)===JSON.stringify(e.lines))),o=e.stockTakes.filter(e=>!(0,n.demoActor)(e.by)),d=e.waste.filter(e=>!(0,n.demoActor)(e.by)),c=e.orders.filter(e=>!(0,n.demoActor)(e.by)),l=e.temps.filter(e=>!(0,n.demoActor)(e.by)),p=new Set([...i,...r,...o,...c].flatMap(e=>e.lines.map(e=>e.ing)));return d.forEach(e=>{e.ing&&p.add(e.ing)}),{ingredients:e.ingredients.filter(e=>p.has(e.id)||!s(e,t.ingredients)),recipes:i,deliveries:r,stockTakes:o,waste:d,orders:c,temps:l}}const w=(0,c.create)()((0,l.persist)(e=>({...r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v(),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,i,n,o)=>e(e=>({deliveries:e.deliveries.map(e=>e.id===t?{...e,lines:i,status:'accepted',checkedBy:n,at:(new Date).toISOString(),note:o}:e),ingredients:e.ingredients.map(e=>{const t=i.find(t=>t.ing===e.id);return t?{...e,onHand:(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand+t.received: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:y('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:y('w'),at:(new Date).toISOString()},...e.waste],ingredients:t.ing?e.ingredients.map(e=>e.id===t.ing?{...e,onHand:Math.max(0,(0,s.fishInStone)(r.VENUE_RID,e)?e.onHand-t.qty:Math.round(100*(e.onHand-t.qty))/100)}:e):e.ingredients})),addOrder:t=>{const s=y('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:y('t'),at:(new Date).toISOString()},...e.temps]})),reset:()=>e(r.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?{targetGp:70,ingredients:[],recipes:[],deliveries:[],stockTakes:[],waste:[],orders:[],prepTicks:{},temps:[]}:v())}),{name:'covercharge-kitchen-v1',version:3,storage:(0,l.createJSONStorage)(()=>d.default),migrate:async e=>{const s=e;return t.LIVE_VENUE_BUILD?(await(0,i.archiveChefCache)('kitchen',s),{...s,...S(s)}):s}}))},1033,[837,984,838,835,5,839,846,849]); +__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 l}}),Object.defineProperty(_e,"RIDDOR_CATEGORIES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"sid",{enumerable:!0,get:function(){return u}}),_e.isSeedAccident=S,_e.upgradeTempUnits=k,Object.defineProperty(_e,"useSafety",{enumerable:!0,get:function(){return w}});var e,t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),a=r(_d[3]),s=(e=a)&&e.__esModule?e:{default:e},o=r(_d[4]),d=r(_d[5]),c=r(_d[6]);const l=['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'],p=['Fall from height','Fracture or dislocation','Taken to hospital','Lost consciousness','Off work more than 7 days'];let f=0;const u=e=>`${e}-${Date.now().toString(36)}${(f++).toString(36)}`,h=(e,t,i)=>({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`,...i});function y(){const e=new Date,t=(t,i)=>{const n=new Date(e);return n.setDate(n.getDate()-t),`${n.toISOString().slice(0,10)}T${i}`};return[h('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'}),h('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'})]}function S(e){const t=({when:e,createdAt:t,...i})=>JSON.stringify(i);return y().some(i=>i.id===e.id&&t(i)===t(e))}function k(e){const t=Object.fromEntries(c.DEFAULT_POINTS.map(e=>[e.id,e])),i=new Set(['cp-prep','cp-bar','cp-freezer']);let n=e.map(e=>'cp-walkin'===e.id?{...e,archived:!0,due:[],aliases:[]}:i.has(e.id)?{...e,name:t[e.id].name,location:t[e.id].location,kind:t[e.id].kind,max:t[e.id].max,due:t[e.id].due,aliases:t[e.id].aliases,archived:!1}:e);const a=new Set(n.map(e=>e.id)),s=c.DEFAULT_POINTS.filter(e=>!a.has(e.id)),o=c.DEFAULT_POINTS.filter(e=>s.includes(e)&&('fridge'===e.kind||'freezer'===e.kind)),d=s.filter(e=>!o.includes(e));let l=-1;n.forEach((e,t)=>{'fridge'!==e.kind&&'freezer'!==e.kind||(l=t)}),n=[...n.slice(0,l+1),...o,...n.slice(l+1),...d];const p=n.filter(e=>'fridge'===e.kind||'freezer'===e.kind),f=[...p.filter(e=>'fridge'===e.kind),...p.filter(e=>'freezer'===e.kind)];let u=0;return n.map(e=>'fridge'===e.kind||'freezer'===e.kind?f[u++]:e)}const w=(0,o.create)()((0,d.persist)(e=>({points:c.DEFAULT_POINTS,entries:[],accidents:n.IS_ISOLATED_VENUE||t.LIVE_VENUE_BUILD?[]:y(),probes:[],diary:[],daySigns:[],weekly:[],inspectorSends:[],logInspectorSend:t=>e(e=>({inspectorSends:[{...t,id:u('ins')},...e.inspectorSends??[]]})),addNote:t=>e(e=>({diary:[{...t,id:u('dn')},...e.diary??[]]})),signDay:t=>e(e=>({daySigns:[...(e.daySigns??[]).filter(e=>e.date!==t.date),t]})),signWeek:t=>e(e=>({weekly:[{...t,id:u('wk')},...(e.weekly??[]).filter(e=>e.week!==t.week)]})),addProbe:t=>e(e=>({probes:[...e.probes??[],{...t,id:u('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:`${u('hc')}${Math.random().toString(36).slice(2,7)}`})),...e.entries]})),setPoint:(t,i)=>e(e=>({points:e.points.map(e=>e.id===t?{...e,...i}:e)})),addPoint:t=>e(e=>({points:[...e.points,{...t,id:`${u('cp')}${Math.random().toString(36).slice(2,6)}`}]})),resetPoints:()=>e({points:c.DEFAULT_POINTS}),addAccident:t=>e(e=>({accidents:[{...t,id:u('acc'),createdAt:(new Date).toISOString()},...e.accidents]})),setRiddorNote:(t,i)=>e(e=>({accidents:e.accidents.map(e=>e.id===t?{...e,riddorNote:i}:e)}))}),{name:'covercharge-safety-v1',storage:(0,d.createJSONStorage)(()=>s.default),version:5,migrate:async(e,n)=>{if(t.LIVE_VENUE_BUILD&&e&&await(0,i.archiveChefCache)('safety',e),e&&n<2){const t=new Set((e.points??[]).map(e=>e.id));e.points=[...e.points??[],...c.DEFAULT_POINTS.filter(e=>!t.has(e.id))],e.diary=e.diary??[],e.daySigns=e.daySigns??[],e.weekly=e.weekly??[]}return e&&n<5&&(e.points=k(e.points??[])),t.LIVE_VENUE_BUILD&&e&&(e.accidents=(e.accidents||[]).filter(e=>!S(e))),e}}))},1034,[837,838,5,839,846,849,1035]); +__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 s}}),Object.defineProperty(_e,"initialsOf",{enumerable:!0,get:function(){return l}}),_e.unitAliases=u,Object.defineProperty(_e,"DEFAULT_POINTS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"limitText",{enumerable:!0,get:function(){return f}}),_e.inRange=p,_e.spokenNumber=y,_e.parseQuick=function(e,n){const r=n.filter(e=>!e.archived);return e.split(/[,;\n]+|\s+and\s+|\.\s+/i).map(e=>e.trim()).filter(Boolean).map(e=>{const n=e.toLowerCase().replace(/[\u2010\u2013]/g,'-').replace(/-(?!\d)/g,' '),o=` ${n.replace(/[^a-z0-9.\- ]/g,' ').replace(/\s+/g,' ')} `;let a,s=0,l='';for(const e of r)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>s&&(a=e,s=t.length,l=t)}const c=y(l?n.replace(new RegExp(`(^|[^a-z0-9])${l.split(' ').map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('[^a-z0-9]+')}(?=$|[^a-z0-9])`),'$1 '):n);return/ (walk ?in|cold room) /.test(o)&&!/(walk|cold room)/.test(l)?{text:e,value:null,problem:'The walk-in is a dry store, not on the temperature log. Pick a fridge or freezer below.'}:a?t(a.kind)?null==c?{text:e,point:a,value:null,problem:'No temperature heard \u2014 type it in.'}:{text:e,point:a,value:c}:{text:e,point:a,value:null}:{text:e,value:c,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 s of e){if(s.archived)continue;const e=s.due.filter(e=>k(e)<=o);if(!e.length)continue;const l=e[e.length-1],c=r.getTime()+6e4*k(e[0])-108e5,d=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=c&&new Date(e.at).getTime()<=t.getTime()),u=e.length;d.lengthe.map(w).join(',')).join('\r\n')+'\r\n'},Object.defineProperty(_e,"SLOTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"SLOT_LABEL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"SLOT_HINT",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"slotOf",{enumerable:!0,get:function(){return $}}),_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 s of e){const e=s.archived?[]:[...s.due].sort();if(!e.length)continue;const l=r.getTime()+6e4*k(e[0])-108e5,c=n.filter(e=>e.pointId===s.id&&new Date(e.at).getTime()>=l&&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=k(e),l=t?'done':o>=r?'overdue':o>=r-60?'due':'upcoming';a.push({key:`${s.id}@${e}`,point:s,due:e,slot:$(e),status:l,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(!p(e,a))return{rag:'red',latest:o,history:r,why:'Out of range'};const s=new Date(t);if(s.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'},s=e=>e.section??a[e.kind],l=e=>e.replace(' (example)','').split(/\s+/).filter(Boolean).map(e=>e[0]).join('').slice(0,3).toUpperCase(),c={1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten'},d={1:'first',2:'second',3:'third',4:'fourth',5:'fifth',6:'sixth',7:'seventh',8:'eighth',9:'ninth',10:'tenth'};function u(e,n){const t=e.trim().toLowerCase().replace(/\s+/g,' ');if(!t)return[];const r=(n??'').trim().toLowerCase(),o=t.replace(/^(downstairs|upstairs|kitchen|cellar|basement|back|front|bar)\s+/,'').replace(r&&t.startsWith(r+' ')?new RegExp('^'+r.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')+'\\s+'):/^$/,''),a=new Set([t,o]);for(const e of[t,o]){const n=e.match(/^(.*\S)\s+(\d{1,2})$/);n&&c[n[2]]&&(a.add(`${n[1]} ${c[n[2]]}`),a.add(`${n[1]} number ${n[2]}`),e!==o||/\s/.test(n[1])||a.add(`${d[n[2]]} ${n[1]}`))}return[...a].filter(Boolean)}const m=[{id:'cp-walkin',name:'Walk-in fridge',kind:'fridge',max:5,due:[],aliases:[],archived:!0},{id:'cp-prep',name:'Downstairs fridge 1',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 1')},{id:'cp-bar',name:'Downstairs fridge 2',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 2')},{id:'cp-fridge3',name:'Downstairs fridge 3',location:'Downstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Downstairs fridge 3')},{id:'cp-fridge4',name:'Upstairs fridge 4',location:'Upstairs',kind:'fridge',max:5,due:['09:00','16:00'],aliases:u('Upstairs fridge 4')},{id:'cp-freezer',name:'Downstairs freezer 1',location:'Downstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Downstairs freezer 1')},{id:'cp-freezer2',name:'Upstairs freezer 2',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 2')},{id:'cp-freezer3',name:'Upstairs freezer 3',location:'Upstairs',kind:'freezer',max:-18,due:['09:00','16:00'],aliases:u('Upstairs freezer 3')},{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']}],f=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 p(e,n){return(null==e.min||n>=e.min)&&(null==e.max||n<=e.max)}const h={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 y(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,s=null,l=!1;for(const e of o)if('point'!==e){if(e in h){if(l){s=h[e];break}a=(a??0)+h[e]}}else l=!0;if(null==a)return null;const c=null!=s?Number(`${a}.${s}`):a;return t?-c:c}const k=e=>{const[n,t]=e.split(':').map(Number);return 60*n+t};const b=e=>null!=e.value?`${e.value}\xb0C`:e.done?'Done':'Not done',w=e=>{const n=null==e?'':String(e);return/[",\n]/.test(n)?`"${n.replace(/"/g,'""')}"`:n},v=['Date','Time','Check','Type','Reading','Safe limit','Result','Corrective action','Note','Recorded by','Entry'];function D(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],b(n),o?f(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 O=['opening','midday','closing'],x={opening:'Opening',midday:'Midday',closing:'Closing'},C={opening:'until 11:00',midday:'11:00 to 16:00',closing:'from 16:00'},$=e=>{const n=k(e);return n<660?'opening':n<960?'midday':'closing'};const z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=['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']},1035,[]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"notifSeedId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"headChefId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"gmId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"seedsFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"useNotifs",{enumerable:!0,get:function(){return v}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),p=r(d[5]),f=r(d[6]),c=r(d[7]);const l=(e,t)=>(0,o.uuidFrom)(`sched-notif:${t}:${e}`),S=()=>p.ROSTER.find(e=>'Head Chef'===e.level)?.id??p.ROSTER.find(e=>'chef'===e.app)?.id??'',b=()=>p.ROSTER.find(e=>'Manager'===e.level)?.id??'',h=e=>'anchorage'===e?(0,u.anchorageSeeds)(t=>l(e,t),S(),b()):[],O=()=>(new Date).toISOString(),v=(0,s.create)()((0,n.persist)((e,t)=>({items:[],snooze:{},ensure:i=>{const s=t().items,n=s.map(e=>(0,c.fixSupplierNames)(e.title)!==e.title||(0,c.fixSupplierNames)(e.message)!==e.message?{...e,title:(0,c.fixSupplierNames)(e.title),message:(0,c.fixSupplierNames)(e.message),updatedAt:O()}:e);n.some((e,t)=>e!==s[t])&&e({items:n});const o=new Set(t().items.map(e=>e.id)),u=h(i).filter(e=>!o.has(e.id)).map(e=>({...e,rid:i}));u.length&&e(e=>({items:[...e.items,...u]}))},add:(t,i)=>{const s=(0,f.uuid)();return e(e=>({items:[...e.items,{...i,id:s,rid:t,updatedAt:O()}]})),s},update:(t,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...i,updatedAt:O()}:e)})),remove:t=>e(e=>({items:e.items.flatMap(e=>e.id!==t?[e]:e.seed?[{...e,removed:!0,paused:!0,updatedAt:O()}]:[])})),resetSeeds:t=>{const i=new Map(h(t).map(e=>[e.id,e]));e(e=>{const s=e.items.map(e=>i.has(e.id)?{...i.get(e.id),rid:t,updatedAt:O()}:e),n=new Set(s.map(e=>e.id));return{items:[...s,...[...i.values()].filter(e=>!n.has(e.id)).map(e=>({...e,rid:t,updatedAt:O()}))]}})},setSnooze:(t,i)=>e(e=>({snooze:Object.fromEntries([...Object.entries(e.snooze).filter(([,e])=>e>Date.now()-864e5),[t,i]])}))}),{name:'covercharge-sched-notifs-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)}))},1036,[839,846,849,863,1037,15,870,1038]); +__d(function(_g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_FILTER_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NOTIF_DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOTIF_GROUP_LABEL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IN_APP_WINDOW_MINS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PUSH_WINDOW_MINS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"KITCHEN_OPEN_DAYS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TITLE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MESSAGE_MAX",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"validHm",{enumerable:!0,get:function(){return u}}),e.ukNow=p,Object.defineProperty(e,"timeOn",{enumerable:!0,get:function(){return m}}),e.notifDue=function(t,n,r=s){const o=p(n),d=m(t,o.dow);if(t.paused||t.removed||!u(d)||!t.days.includes(o.dow))return{due:!1,forDate:o.ymd,at:d};const f=l(d);return{due:o.mins>=f&&o.minst.days.includes(n));if(!r.length)return'No days ticked';const s=new Map;for(const n of r){const r=m(t,n);s.set(r,[...s.get(r)??[],n])}const o=t=>7===t.length?'Every day':t.map(t=>n[t]).join(', ');return[...s.entries()].map(([t,n])=>`${o(n)} at ${t}`).join('; ')+' (UK time)'},e.validateNotif=function(t){if(!t.title.trim())return'Give it a name.';if(t.title.length>f)return`Keep the name under ${f} letters.`;if(!t.message.trim())return'Type the message people will see.';if(t.message.length>c)return`Keep the message under ${c} letters.`;if(!u(t.time))return'Type the time as HH:MM, e.g. 21:00.';for(const n of Object.values(t.dayTimes??{}))if(!u(n))return'Type each day\u2019s time as HH:MM.';return t.days.length?t.recipients.staff.length||t.recipients.groups.length||(t.recipients.onShiftIn??[]).length?t.sendBy.inApp||t.sendBy.push?null:'Choose how to send it.':'Tick at least one person or group.':'Tick at least one day.'},e.anchorageSeeds=function(t,n,r){const s={staff:[n,r].filter(Boolean),groups:[]},o={inApp:!0,push:!0};return[{id:t('mills-milk'),seed:'mills-milk',title:'Mills milk order',message:'Make sure an order before 9:30',days:[...d],time:'21:00',dayTimes:{5:'20:55',0:'20:55'},recipients:s,sendBy:o},{id:t('peronis'),seed:'peronis',title:"Pieroni's order",message:"order Pieroni's by phone",days:[...d],time:'21:05',recipients:s,sendBy:o},{id:t('veg-second'),seed:'veg-second',title:'Veg order',message:'Order veg on the app before 11 PM',days:[...d],time:'21:15',recipients:s,sendBy:o},{id:t('reeds'),seed:'reeds',title:'Reeds order',message:'Order reeds',days:[3,4],time:'21:25',recipients:s,sendBy:o},{id:t('spezbona'),seed:'spezbona',title:'Spes Bona order',message:'Do we need anything from Spes Bona for this week? Message Anna if we do for Friday delivery.',days:[3],time:'15:00',recipients:s,sendBy:o},{id:t('olsens'),seed:'olsens',title:"Olsen's order",message:"Place Olsen's order before 3:30 PM. By phone.",days:[2],time:'13:00',recipients:{staff:[r],groups:[]},sendBy:o},{id:t('allsons-list'),seed:'allsons-list',title:'Alsons drinks list',message:'Add anything extra to the Alsons drinks list.',days:[0],time:'20:00',recipients:{staff:['st-finn'],groups:[]},sendBy:o,open:{page:'orderlists',list:'allsons'}},{id:t('tea-towels'),seed:'tea-towels',title:'Tea towels',message:'Put a load of tea towels on to wash.',days:[...d],time:'15:00',recipients:{staff:[],groups:[],onShiftIn:['kp'],fallback:{staff:[],groups:['head_chef']}},sendBy:o},{id:t('rota-upload'),seed:'rota-upload',title:'Rota upload',message:"Make sure you have uploaded next week's rota.",days:[0],time:'20:50',recipients:s,sendBy:o}]};const t={kitchen:'On shift: Kitchen',foh:'On shift: Front of house',bar:'On shift: Bar',kp:'On shift: KPs',chefs:'On shift: Chefs'},n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],r={on_shift:'Everyone on shift',everyone:'Everyone',managers:'Owners and managers',head_chef:'Head Chef',kitchen:'Kitchen team',foh:'Front of house'},s=120,o=15,d=[3,4,5,6,0],f=60,c=160,u=t=>/^([01]\d|2[0-3]):[0-5]\d$/.test(t),l=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5));function p(t){const r='number'==typeof t?new Date(t):t,s={};for(const t of new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',weekday:'short',year:'numeric',month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(r))s[t.type]=t.value;return{dow:n.indexOf(String(s.weekday).slice(0,3)),mins:60*Number(s.hour)+Number(s.minute),ymd:`${s.year}-${s.month}-${s.day}`}}const m=(t,n)=>{const r=t.dayTimes?.[String(n)];return r&&u(r)?r:t.time};const h=t=>t.open?`./?open=${t.open.page}${t.open.list?`&list=${encodeURIComponent(t.open.list)}`:''}`:'./',y=(t,n)=>`${t.id}:${n}`,g=t=>(t??'').toLowerCase(),b=t=>t.level?['owner','manager'].includes(g(t.level)):['owner','manager'].includes(g(t.role)),O=t=>'head_chef'===g(t.role)||'head chef'===g(t.level)||'chef'===g(t.app)||/head chef/.test(g(t.job)),P=t=>'kitchen'===g(t.department)||/chef|kitchen|kp|porter/.test(g(t.job))||O(t),k=t=>/\bkp\b|kitchen porter/.test(g(t.job));function j(t,n){const r=g(n.department);return'kitchen'===t?P(n):'kp'===t?k(n):'chefs'===t?O(n)||/chef|commis/.test(g(n.job)):'bar'===t?'bar'===r||/\bbar/.test(g(n.job)):'front of house'===r||!r&&!P(n)&&!b(n)}function _(t,n,r=[]){const s=v(t.recipients,n,r),o=t.recipients.fallback;return s.length||!o?s:v({staff:o.staff,groups:o.groups},n,r)}const w=(t,n,r=[])=>!!t.recipients.fallback&&!v(t.recipients,n,r).length;function v(t,n,r){const s=t,o=n.filter(t=>!1!==t.active),d=new Set;for(const t of s.staff)o.some(n=>n.id===t)&&d.add(t);for(const t of s.groups)for(const n of o)('everyone'===t||'on_shift'===t&&r.includes(n.id)||'managers'===t&&b(n)||'head_chef'===t&&O(n)||'kitchen'===t&&P(n)||'foh'===t&&!P(n)&&!b(n))&&d.add(n.id);for(const t of s.onShiftIn??[])for(const n of o)r.includes(n.id)&&j(t,n)&&d.add(n.id);return[...d].sort()}const M=t=>({id:t.external_ref,role:t.roles?.key??void 0,job:t.job_title??'',department:t.department??'',active:!1!==t.active}),T=(t,n,r,s=[])=>_(t,r,s).includes(n)},1037,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fixSupplierNames=function(n){return n?s.reduce((s,[n,b])=>s.replace(n,b),n):n};const s=[[/\bAl{2}sons?'?s?\b|\bAlson's\b/g,'Alsons'],[/\bSpe[zs] ?[Bb]ona\b|\bSpezbona\b/g,'Spes Bona']]},1038,[]); +__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,"cashUpId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"salesId",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"cashSettingsId",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"defaultCashSettings",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useCashUp",{enumerable:!0,get:function(){return b}}),_e.forgetPastTakings=function(e,t){const s=b.getState(),n=s.cashUps.filter(s=>s.rid!==e||s.date===t),r=s.sales.filter(t=>t.rid!==e);n.length===s.cashUps.length&&r.length===s.sales.length||b.setState({cashUps:n,sales:r})},Object.defineProperty(_e,"useCashSettings",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"useTipsShow",{enumerable:!0,get:function(){return y}});var t=e(_r(d[0])),s=e(_r(d[1])),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),u=_r(d[5]),l=_r(d[6]);const c=(e,t)=>(0,o.uuidFrom)(`cashup:${e}:${t}`),p=(e,t)=>(0,o.uuidFrom)(`sales:${e}:${t}`),h=e=>(0,o.uuidFrom)(`cashup-settings:${e}`),f=e=>({id:h(e),cashFields:u.DEFAULT_CASHUP_FIELDS.map(e=>({...e})),salesFields:u.DEFAULT_SALES_FIELDS.map(e=>({...e}))}),S=e=>{const t='number'==typeof e.vals.cashTips?e.vals.cashTips:null,s='number'==typeof e.vals.cardTips?e.vals.cardTips:null;return!e.confirmedAt||null==t&&null==s?null:{rid:e.rid,date:e.date,total:Math.round(100*((t??0)+(s??0)))/100,postedAt:e.confirmedAt,postedBy:e.confirmedBy}},b=(0,n.create)()((0,r.persist)((e,t)=>({cashUps:[],sales:[],tips:[],pot:[],settings:{},show:{},seen:{},saveCashUp:t=>{const s={...t,id:c(t.rid,t.date)},n=S(s);return e(e=>({cashUps:[s,...e.cashUps.filter(e=>e.id!==s.id)],tips:n?[n,...e.tips.filter(e=>!(e.rid===n.rid&&e.date===n.date))]:e.tips})),s},saveSales:t=>{const s={...t,id:p(t.rid,t.weekStart)};return e(e=>({sales:[s,...e.sales.filter(e=>e.id!==s.id)]})),s},setFields:(t,s,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??f(t),[s]:n,updatedAt:(new Date).toISOString()}}})),resetFields:t=>e(e=>({settings:{...e.settings,[t]:{...f(t),updatedAt:(new Date).toISOString()}}})),setShow:(t,s)=>e(e=>({show:{...e.show,[t]:{...e.show[t]??{showToday:!0,showPot:!0},...s}}})),addPotEvent:t=>e(e=>({pot:[{...t,id:(0,l.uuid)(),at:(new Date).toISOString()},...e.pot]})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:s}}))}),{name:'covercharge-cashup-v1',storage:(0,r.createJSONStorage)(()=>s.default),partialize:e=>({...e,cashUps:e.cashUps.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))})),sales:e.sales.map(e=>({...e,photos:e.photos.filter(e=>!e.startsWith('data:'))}))})}));const w=e=>{const s=b(t=>t.settings[e])??f(e);return t.default.useMemo(()=>({...s,cashFields:(0,u.withTakingsFields)(s.cashFields)}),[s])},y=e=>b(t=>t.show[e])??{showToday:!0,showPot:!0}},1039,[34,839,846,849,863,13,870]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"orderListSeedId",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"orderListSettingsId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"orderListSeeds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"useOrderLists",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"orderSettingsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"useListOpen",{enumerable:!0,get:function(){return y}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),u=r(d[3]),o=r(d[4]),p=r(d[5]),l=r(d[6]);const c=(e,t)=>(0,u.uuidFrom)(`order-list:${t}:${e}`),S=e=>(0,u.uuidFrom)(`order-list-settings:${e}`),f=e=>'anchorage'===e?[{id:c(e,'allsons'),seed:'allsons',name:'Alsons (drinks)',kind:'running'},{id:c(e,'cash-carry'),seed:'cash-carry',name:'Cash and carry',kind:'trip',tripDay:5}]:[],A=()=>(new Date).toISOString(),O=(0,i.create)()((0,n.persist)((e,t)=>({lists:[],items:[],history:[],settings:{},ensure:s=>{const i=t(),n=new Set(i.lists.map(e=>e.id)),u=f(s).filter(e=>!n.has(e.id)).map(e=>({...e,rid:s})),p={},c=i.lists.map(e=>(0,l.fixSupplierNames)(e.name)!==e.name?{...e,name:(0,l.fixSupplierNames)(e.name),updatedAt:A()}:e);c.some((e,t)=>e!==i.lists[t])&&(p.lists=c),u.length&&(p.lists=[...p.lists??i.lists,...u]),i.settings[s]||(p.settings={...i.settings,[s]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(s)}}),Object.keys(p).length&&e(p)},addList:(t,s)=>{const i=(0,p.uuid)();return e(e=>({lists:[...e.lists,{...s,id:i,rid:t,updatedAt:A()}]})),i},updateList:(t,s)=>e(e=>({lists:e.lists.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),addItem:(t,s)=>{const i=(0,p.uuid)(),n=s.addedAt??A();return e(e=>({items:[...e.items,{...s,id:i,rid:t,status:'open',addedAt:n,updatedAt:n}]})),i},bump:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...(0,o.bumpQty)(e,s,i.id,i.name,A()),rid:e.rid}:e)})),updateItem:(t,s)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,...s,updatedAt:A()}:e)})),setStatus:(t,s,i)=>e(e=>({items:e.items.map(e=>e.id===t?{...e,status:s,statusBy:'open'===s?void 0:i.name,statusAt:'open'===s?void 0:A(),updatedAt:A()}:e)})),removeItem:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!0,updatedAt:A()}:e)})),undoRemove:t=>e(e=>({items:e.items.map(e=>e.id===t?{...e,removed:!1,updatedAt:A()}:e)})),finish:(s,i,n,u)=>{const l=t().lists.find(e=>e.id===i);if(!l)return null;const c=A(),{round:S,drop:f,carriedOver:O}=(0,o.finishOrder)(l,t().items,n,u,c,p.uuid),_=new Set(f),y=new Map(O.map(e=>[e.id,e])),T={...S,rid:s};return e(e=>({items:e.items.filter(e=>!_.has(e.id)).map(e=>y.has(e.id)?{...y.get(e.id),rid:e.rid}:e),history:[T,...e.history].slice(0,300),lists:e.lists.map(e=>e.id===i?{...e,nextTrip:void 0,updatedAt:c}:e)})),T},setSettings:(t,s)=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,...e.settings[t],...s,id:S(t),updatedAt:A()}}})),resetSettings:t=>e(e=>({settings:{...e.settings,[t]:{...o.DEFAULT_ORDER_LIST_SETTINGS,id:S(t),updatedAt:A()}}}))}),{name:'covercharge-order-lists-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)})),_=e=>({...o.DEFAULT_ORDER_LIST_SETTINGS,...O.getState().settings[e]}),y=(0,i.create)()(e=>({request:t=>e({seed:t})}))},1040,[839,846,849,863,1041,870,1038]); +__d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_ORDER_LIST_SETTINGS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"UNITS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DAY_FULL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"normName",{enumerable:!0,get:function(){return a}}),e.findDuplicate=function(t,n,i,s){return t.find(t=>t.listId===n&&!t.removed&&'open'===t.status&&a(t.name)===a(i)&&u(t.unit)===u(s))},e.bumpQty=function(t,n,i,a,u){return{...t,qty:Math.round(100*(t.qty+n))/100,bumps:[...t.bumps??[],{by:i,name:a,qty:n,at:u}],updatedAt:u}},Object.defineProperty(e,"qtyText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"validQty",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"liveItems",{enumerable:!0,get:function(){return d}}),e.finishOrder=function(t,n,i,a,u,s){const o=d(n,t.id),l=o.filter(t=>'got'!==t.status),c={id:s(),listId:t.id,listName:t.name,finishedAt:u,finishedBy:a.id,finishedByName:a.name,items:o.map(t=>({name:t.name,qty:t.qty,unit:t.unit,note:t.note,status:t.status,addedByName:t.addedByName})),carried:i?l.length:0},p=i?l.map(t=>({...t,status:'open',carried:'missing'===t.status?'missing':'not-got',statusBy:void 0,statusAt:void 0,updatedAt:u})):[],m=new Set(p.map(t=>t.id));return{round:c,drop:o.filter(t=>!m.has(t.id)).map(t=>t.id),carriedOver:p}},e.nextTripDate=p,e.tripText=function(t,n,a){const u=p(t,n,a);if(!u)return'Running list';const[,s,o]=u.split('-').map(Number);return"Next trip "+(u===n?'today':u===l(n,1)?'tomorrow':`${i[c(u)]} ${o} ${['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][s-1]}`)},e.initials=function(t){const n=t.replace(/\(.*?\)/g,' ').split(/[^A-Za-z0-9]+/).filter(t=>t&&!['and','the','of','&'].includes(t.toLowerCase()));return n.length?(1===n.length?n[0].slice(0,2):n[0][0]+n[1][0]).toUpperCase():'?'},e.telHref=function(t){if(!t)return null;const n=t.trim().replace(/[^\d+]/g,'').replace(/(?!^)\+/g,'');return n.replace(/\D/g,'').length>=6?`tel:${n}`:null};const t={allowStaff:!0,defaultTripDay:5},n=['','cases','bottles','kegs','boxes','bags','packs','kg','litres','each'],i=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],a=t=>t.trim().toLowerCase().replace(/[\u2019']/g,"'").replace(/\s+/g,' ').replace(/s$/,''),u=t=>t.trim().toLowerCase().replace(/s$/,'');const s=t=>`${Number.isInteger(t.qty)?t.qty:t.qty.toFixed(2).replace(/0$/,'')}${t.unit?` ${t.unit}`:''}`,o=t=>Number.isFinite(t)&&t>0&&t<=9999,d=(t,n)=>t.filter(t=>t.listId===n&&!t.removed).sort((t,n)=>('open'===t.status?0:1)-('open'===n.status?0:1)||t.addedAt.localeCompare(n.addedAt));const l=(t,n)=>{const[i,a,u]=t.split('-').map(Number);return new Date(Date.UTC(i,a-1,u+n)).toISOString().slice(0,10)},c=t=>{const[n,i,a]=t.split('-').map(Number);return new Date(Date.UTC(n,i-1,a)).getUTCDay()};function p(n,i,a=t.defaultTripDay){if('trip'!==n.kind)return null;if(n.nextTrip&&n.nextTrip>=i)return n.nextTrip;const u=n.tripDay??a;return l(i,(u-c(i)+7)%7)}},1041,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useClockArea",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"areaOf",{enumerable:!0,get:function(){return _}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),u=(e=s)&&e.__esModule?e:{default:e},c=r(d[3]),l=r(d[4]),E=r(d[5]);const o=(0,c.create)()((0,l.persist)(e=>({areas:(0,n.privateClockVenue)(t.VENUE_RID)?{[t.VENUE_RID]:(0,n.venueClockArea)(t.VENUE_RID)}:{},visiting:{},set:(s,u,c)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{...e.areas[s]??{},...u}),updatedAt:(new Date).toISOString(),updatedBy:c}}}),reset:(s,u)=>e(e=>t.IS_ISOLATED_VENUE&&s!==t.VENUE_RID?e:{areas:{...e.areas,[s]:{...(0,n.venueClockArea)(s,{lat:e.areas[s]?.lat??null,lng:e.areas[s]?.lng??null}),updatedAt:(new Date).toISOString(),updatedBy:u}}}),setVisiting:t=>e(e=>({visiting:Object.fromEntries([...Object.entries(e.visiting).slice(-60),[t,!0]])}))}),{name:'covercharge-clock-area-v1',version:1,storage:(0,l.createJSONStorage)(()=>u.default)})),_=e=>t.IS_ISOLATED_VENUE&&e!==t.VENUE_RID?(0,E.cleanArea)(E.DEFAULT_CLOCK_AREA):(0,n.venueClockArea)(e,o.getState().areas[e]??{})},1042,[5,997,839,846,849,998]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inviteStatus=function(){return{'st-tracy':{state:'used',usedAt:s(3e3),devices:2},'st-gordon':{state:'used',usedAt:s(2940),devices:2},'st-bisto':{state:'used',usedAt:s(1800),devices:1},'st-agate':{state:'used',usedAt:s(1680),devices:1},'st-lenny':{state:'used',usedAt:s(1560),devices:1},'st-finn':{state:'unused',expiresAt:n(52),devices:0},'st-eilidh':{state:'used',usedAt:s(1200),devices:1},'st-emily':{state:'expired',devices:0},'st-lillie':{state:'used',usedAt:s(480),devices:1},'st-jack':{state:'unused',expiresAt:n(70),devices:0}}},e.linkPhones=async function(){return{...a}},e.resetPhone=async function(t){const s=a[t]?.phones??0;return delete a[t],s},e.reissueInvite=async function(t){const s='st-bisto'===t?'chef':['st-tracy','st-gordon','st-agate'].includes(t)?'owner':'staff';return{ok:!0,token:'DEMO-link-not-real-0000',expiresAt:n(72),app:s}},e.unlockCashUp=async function(s,n,a){const c=new Date(Date.now()+18e5).toISOString();'cashup'===s?t.useCashUp.setState(t=>({cashUps:t.cashUps.map(t=>t.id===n?{...t,unlockedUntil:c}:t)})):t.useCashUp.setState(t=>({sales:t.sales.map(t=>t.id===n?{...t,unlockedUntil:c}:t)}));return{ok:!0,until:c}},e.cashAudit=async function(t){return[{at:s(780),action:'unlocked',by:'Morgan',tbl:'cash_ups',reason:'Card total keyed as 1,284 not 1,248',changed:[]},{at:s(768),action:'changed',by:'Alex',tbl:'cash_ups',changed:['card']},{at:s(840),action:'created',by:'Alex',tbl:'cash_ups',changed:[]}]},e.pitchRpc=function(t,s){switch(t){case'list_displays':return c;case'create_display_code':case'new_code_for_display':return[{code:'DEMO7K2QX',expires_at:n(24*Number(s.p_hours?Number(s.p_hours)/24:7))}];default:return[]}};var t=r(d[0]);const s=t=>new Date(Date.now()-6e4*t).toISOString(),n=t=>new Date(Date.now()+36e5*t).toISOString();const a={'st-tracy':{phones:1,since:s(4445)},'st-bisto':{phones:1,since:s(2920)},'st-agate':{phones:1,since:s(1680)},'st-lenny':{phones:1,since:s(1560)},'st-eilidh':{phones:1,since:s(1200)}};const c=[{id:'pd-1',label:'Front desk tablet',can_write:!0,created_at:s(17280),last_seen_at:s(2),revoked_at:null,sessions:1,open_codes:0},{id:'pd-2',label:'Kitchen pass tablet',can_write:!1,created_at:s(12960),last_seen_at:s(5),revoked_at:null,sessions:1,open_codes:0}]},1043,[1039]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"libraryRowId",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"personRowId",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"tickId",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"personKey",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"useDailyTasks",{enumerable:!0,get:function(){return L}}),Object.defineProperty(_e,"tasksOf",{enumerable:!0,get:function(){return O}});var e,t=r(d[0]),i=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),n=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]);const l=e=>(0,o.uuidFrom)(`daily-task-library:${e}`),y=(e,t)=>(0,o.uuidFrom)(`daily-tasks:${e}:${t}`),b=(e,t,i,s)=>(0,o.uuidFrom)(`daily-task-tick:${e}:${(0,u.tickKey)(t,i,s)}`),f=()=>(new Date).toISOString(),k=(e,t)=>`${e}|${t}`,p=e=>u.DEFAULT_LIBRARY.map((t,i)=>({id:(0,o.uuidFrom)(`daily-task-lib:${e}:${i}`),text:t})),L=(0,s.create)()((0,n.persist)((e,t)=>({library:{},people:{},ticks:[],ensure:i=>{t().library[i]||e(e=>({library:{...e.library,[i]:{items:p(i)}}}))},setLibrary:(t,i)=>e(e=>({library:{...e.library,[t]:{items:i,updatedAt:f()}}})),addLibrary:(e,i)=>{const s=(0,u.cleanTaskText)(i);if(!s)return;const n=t().library[e]?.items??p(e);n.some(e=>e.text.toLowerCase()===s.toLowerCase()&&!e.archived)||t().setLibrary(e,[...n,{id:(0,c.uuid)(),text:s}])},setTasks:(t,i,s)=>e(e=>({people:{...e.people,[k(t,i)]:{tasks:s,updatedAt:f()}}})),addTask:(e,i,s,n)=>{const o=(0,u.cleanTaskText)(s);if(!o)return;const l=t().people[k(e,i)]?.tasks??[];l.some(e=>e.text.toLowerCase()===o.toLowerCase())||t().setTasks(e,i,[...l,{id:(0,c.uuid)(),text:o,...n?{libraryId:n}:{}}])},toggleTick:(t,i,s,n,o)=>e(e=>{const u=b(t,i,s,n);if(e.ticks.some(e=>e.id===u))return{ticks:e.ticks.filter(e=>e.id!==u)};const c=new Date(Date.now()-12096e5).toISOString().slice(0,10);return{ticks:[...e.ticks.filter(e=>e.forDate>=c),{id:u,rid:t,staffRef:i,taskId:s,forDate:n,byRef:o.id,byName:o.name,at:f()}]}}),resetLibrary:e=>t().setLibrary(e,p(e))}),{name:'covercharge-daily-tasks-v1',version:1,storage:(0,n.createJSONStorage)(()=>i.default)})),O=(e,t)=>L.getState().people[k(e,t)]?.tasks??[]},1044,[839,846,849,863,1045,870]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TASK_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"cleanTaskText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"appliesOn",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tasksFor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"tickKey",{enumerable:!0,get:function(){return u}}),e.progress=function(t,n,o,u,c){const s=i(t,c),f=new Set(n.filter(t=>t.staffRef===o&&t.forDate===u).map(t=>t.taskId));return{done:s.filter(t=>f.has(t.id)).length,total:s.length}},e.move=function(t,n,o){const i=n+o;if(n<0||i<0||n>=t.length||i>=t.length)return t;const u=[...t];return[u[n],u[i]]=[u[i],u[n]],u},Object.defineProperty(e,"hasTask",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEFAULT_LIBRARY",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TASK_DAY_NAMES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isHeadChefP",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isKitchenP",{enumerable:!0,get:function(){return d}}),e.canEditTasks=function(t,n){return!!t&&('owner'===t.role||'manager'===t.role||!!l(t)&&(t.id!==n.id&&'staff'===n.role&&!l(n)&&d(n)))};const t=80,n=n=>n.replace(/\s+/g,' ').trim().slice(0,t),o=(t,n)=>!t.days||0===t.days.length||t.days.includes(n),i=(t,n)=>t.filter(t=>o(t,n)),u=(t,n,o)=>`${t}|${n}|${o}`;const c=(t,o)=>t.some(t=>t.text.toLowerCase()===n(o).toLowerCase()),s=['Restock the bar fridges','Wipe down the menus','Check the toilets','Set the tables','Polish glasses','Empty the bins','Clean the coffee machine','Take out the recycling'],f=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=t=>'staff'===t.role&&('Head Chef'===t.level||/^head chef/i.test(t.job??'')),d=t=>'kitchen'===(t.dept??'').trim().toLowerCase()},1045,[]); +__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},1046,[846]); +__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(':')}`},1047,[839,846,849]); +__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{}}},1048,[236,872]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.specialsBoardSpec=function(r,s){return{name:'specials_boards',table:'specials_boards',conflict:'venue_id',deletes:!1,list:()=>[{id:r,board:t.useSpecials.getState().current[r]??null}],key:()=>r,rowKey:()=>r,syncable:t=>!t.board||!String(t.board.id).startsWith('sb-seed'),writable:s,toRow:(t,s)=>({venue_id:s,doc:{board:t.board?{...t.board,restaurantId:r}:null},updated_at:(new Date).toISOString()}),fromRow:t=>({id:r,board:t.doc?.board??null}),apply:s=>{const n=s[0];if(!n)return;const o=n.board;o&&o.restaurantId&&o.restaurantId!==r||t.useSpecials.setState(t=>({current:{...t.current,[r]:o}}))},subscribe:r=>t.useSpecials.subscribe((t,s)=>{t.current!==s.current&&r()})}},Object.defineProperty(e,"specialsSyncOn",{enumerable:!0,get:function(){return c}}),e.watchGuestSpecials=function(c,l=()=>{}){if(!r.RELEASE.specialsSync||!(0,n.isSupabaseConfigured)())return()=>{};let u=!1;const p=async()=>{const r=t.useSpecials.getState().current[c]??null;let n;try{const t=(0,o.getSupabase)(),{data:r,error:l}=await t.rpc('guest_specials',{p_slug:c});if(l)n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE};else if(r&&'object'==typeof r){const t=r,s='string'==typeof t.postedAt?t.postedAt:'',o=Array.isArray(t.items)?t.items:[],l=t.photo??null;n=s||l||o.length?{ok:!0,board:{id:`sb-sync-${c}`,restaurantId:c,photo:l,items:o,postedAt:s||new Date(0).toISOString(),postedBy:'',app:'managers',allergenCheck:null}}:{ok:!0,board:null}}else n={ok:!0,board:null}}catch{n={ok:!1,message:s.GUEST_SPECIALS_OFFLINE}}if(u)return;const p=(0,s.guestSpecialsAfter)(t.useSpecials.getState().current[c]??null,n);p.board!==r&&t.useSpecials.setState(t=>({current:{...t.current,[c]:p.board}})),l(p.note)};p();const S=setInterval(()=>{p()},6e4);return()=>{u=!0,clearInterval(S)}};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]),o=_r(d[4]);const c=()=>r.RELEASE.specialsSync},1049,[995,1050,1051,976,933]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"RELEASE",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"nightlyEmailAllowed",{enumerable:!0,get:function(){return t}});const n={specialsSync:!0,nightlyEmail:!1,nightlyPush:!1,supportSync:!0,planPhoto:!0},t=(t,l)=>'anchorage'!==t&&l&&n.nightlyEmail},1050,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestSpecialsAfter=function(t,n){return n.ok?n.board?t&&t.postedAt>n.board.postedAt?{board:t,note:''}:{board:n.board,note:''}:{board:null,note:''}:{board:t,note:n.message}},Object.defineProperty(e,"GUEST_SPECIALS_OFFLINE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SUPPORT_NOT_SENT",{enumerable:!0,get:function(){return n}}),e.supportAfterWrite=function(t,o){return t.trim()?o.ok?{text:t,sent:!0,note:''}:{text:t,sent:!1,note:o.message||n}:{text:t,sent:!1,note:''}};const t='The specials board could not be loaded. What is already on this phone is unchanged.',n='Saved on this phone. It was not sent.'},1051,[]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.refreshCashAccess=r,e.setStaffCashUp=async function(o,c){const u=s.useSync.getState().venueId;if(!u)return{ok:!1,error:'Not connected. Try again when the app is online.'};const f=(0,t.getSupabase)();try{const{data:t}=await f.from('staff').select('id').eq('venue_id',u).eq('external_ref',o).maybeSingle();if(!t?.id)return{ok:!1,error:'This person isn\u2019t on the shared team list yet.'};const{error:s}=await f.rpc('set_staff_cash_up',{p_staff:t.id,p_on:c});return s?{ok:!1,error:/owner or manager/i.test(s.message)?'Only an owner or manager can change this.':'Could not save. Try again.'}:(n.useCashAccess.setState(t=>({byRef:{...t.byRef,[o]:c}})),r(),{ok:!0})}catch{return{ok:!1,error:'Could not save. Try again when the app is online.'}}};var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]);async function r(){const r=s.useSync.getState().venueId;if(!r||'staff'!==s.useSync.getState().kind)return;const o=(0,t.getSupabase)();try{const[{data:t},{data:s},c]=await Promise.all([o.rpc('my_cash_up_access',{p_venue:r}),o.from('staff').select('external_ref, can_cash_up').eq('venue_id',r),o.rpc('my_cash_up_scope',{p_venue:r}).then(t=>t,()=>({data:null}))]),u=c?.data??null;u&&'boolean'==typeof u.takings&&n.useCashAccess.setState({takings:u.takings,tradingDate:'string'==typeof u.tradingDate?u.tradingDate:null,photos:!0===u.photos});const f={};if(Array.isArray(s))for(const t of s)t.external_ref&&(f[t.external_ref]=!!t.can_cash_up);n.useCashAccess.setState({mine:'boolean'==typeof t?t:n.useCashAccess.getState().mine,byRef:Array.isArray(s)?f:n.useCashAccess.getState().byRef,loaded:!0})}catch{}}},1052,[933,987,999]); +__d(function(g,r,i,a,m,e,d){m.exports=r(d[0])},1053,[1054]); +__d(function(g,r,i,a,m,e,d){function n(n,t){const o=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(null!=o){const s=String(n);if(null!=t){const n=t[s];if(null!=n)return o(n)}}}function t(t,o,s){const u=()=>r.importAll(t,s);{const l=o?.[String(t)];if(Array.isArray(l)){const c=globalThis[`${__METRO_GLOBAL_PREFIX__??''}__loadBundleAsync`];if(c?.isReady?.(l))return u();const f=n(t,o);if(null!=f)return f.then(u);throw new Error(`Cannot import module ${s??t}: the async bundle loader is unavailable. Load the initial Expo bundle before importing these chunks: ${l.join(', ')}`)}try{return u()}catch(s){const l=n(t,o);if(null!=l)return l.then(u);throw s}}const l=n(t,o);return null!=l?l.then(u):u()}function o(n,o,s){const u=t(n,o,s),l=Promise.resolve(u);return l._result=u,l}o.unstable_importMaybeSync=function(n,o){return t(n,o)},o.prefetch=function(t,o,s){n(t,o)?.then(()=>{},()=>{})},o.unstable_resolve=function(n,t){if(!t)throw new Error('Bundle splitting is required for Web Worker imports');const o=t[n];if(!o)throw new Error('Worker import is missing from split bundle paths: '+o);return o},o.unstable_createWorker=function(n,t){if('undefined'==typeof crossOriginIsolated||!crossOriginIsolated)return new Worker(n,t);try{const s=(o=n,`\n const ASYNC_WORKER_BASE = ${JSON.stringify(o)};\n const IMPORT_SCRIPTS = importScripts;\n const FETCH = fetch;\n const fromBaseURL = (input) => new URL(input, ASYNC_WORKER_BASE).href;\n self.fetch = function(input, init) {\n return FETCH(typeof input === 'string' ? fromBaseURL(input) : input, init);\n };\n self.importScripts = function(...urls) {\n return IMPORT_SCRIPTS.apply(self, urls.map(fromBaseURL));\n };\n importScripts(ASYNC_WORKER_BASE);\n `);return n=URL.createObjectURL(new Blob([s],{type:'text/javascript'})),new Worker(n,t)}finally{URL.revokeObjectURL(n)}var o},m.exports=o},1054,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"currentScrollY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"screenGeneration",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"restoreScroll",{enumerable:!0,get:function(){return o}}),_e.useScrollMemory=function(u){const c=(0,e.useRef)(0),o=(0,e.useRef)(0),l=(0,e.useRef)(0),s=(0,e.useRef)(0),f=(0,e.useRef)(0),v=(0,e.useRef)(null),y=(0,e.useRef)([]),h=()=>{y.current.forEach(clearTimeout),y.current=[]},b=()=>{const e=v.current;null!=e&&(u.current?.scrollTo({y:e,animated:!1}),f.current-s.current>=e-2&&(c.current=e,o.current=e,v.current=null,h()))},p=(0,e.useCallback)(e=>{if(h(),v.current=Math.max(0,e),e<=0)return v.current=null,u.current?.scrollTo({y:0,animated:!1}),c.current=0,void(o.current=0);for(const e of[0,30,80,160,320,600,1e3,1600,2500])y.current.push(setTimeout(b,e));y.current.push(setTimeout(()=>{v.current=null},2600))},[]);t={y:()=>o.current,restore:p};const R=(0,e.useCallback)(()=>{n++;return o.current},[]);return{props:{scrollEventThrottle:32,onScroll:e=>{const t=e.nativeEvent.contentOffset.y;c.current=t,s.current=e.nativeEvent.layoutMeasurement.height,f.current=e.nativeEvent.contentSize.height,Date.now()-l.current>250&&null==v.current&&(o.current=t)},onScrollBeginDrag:()=>{v.current=null,h()},onContentSizeChange:(e,t)=>{f.current=t,l.current=Date.now(),b()},onLayout:e=>{s.current=e.nativeEvent.layout.height}},restore:p,leave:R}};var e=r(d[0]);let t=null,n=0;const u=()=>t?t.y():0,c=()=>n,o=e=>t?.restore(e)},1055,[34]); +__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,"useBackLayers",{enumerable:!0,get:function(){return f}}),_e.runBackLayer=function(){const e=f.getState().layers,t=e[e.length-1];return!!t&&(t.fn(),!0)},_e.useBackLayer=function(e,n,o=!0){const s=(0,t.useRef)(n);s.current=n,(0,t.useEffect)(()=>{if(!e)return;const t=++y,n=(0,u.currentScrollY)(),l=(0,u.screenGeneration)();return f.setState(e=>({layers:[...e.layers,{id:t,fn:()=>s.current(),own:o}]})),()=>{f.setState(e=>({layers:e.layers.filter(e=>e.id!==t)})),(0,u.screenGeneration)()===l&&(0,u.restoreScroll)(n)}},[e,o])},Object.defineProperty(_e,"useInnerBackShown",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BACK_GUTTER",{enumerable:!0,get:function(){return p}}),_e.BackTitleRow=function({back:e,onBack:n,title:s}){const[l,u]=(0,t.useState)(0),[f,y]=(0,t.useState)({w:96,h:48}),[w,b]=(0,t.useState)(0),S=Array.from(new Set(String(s??'').split(/\s+/).filter(Boolean)));String(s??'').length>=20&&S.length>=3&&S.push('00000000');const v=Math.max(p,Math.ceil(f.w)+4),j=e&&l>0&&l-2*vu(Math.round(e.nativeEvent.layout.width)),style:{minHeight:44,justifyContent:'center',alignItems:'center',paddingHorizontal:e&&!j?v:0,paddingTop:j?f.h:0},children:[e?(0,h.jsx)(o.default,{style:{position:'absolute',left:0,top:0},onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width),n=Math.round(e.nativeEvent.layout.height);y(e=>e.w===t&&e.h===n?e:{w:t,h:n})},children:(0,h.jsx)(g,{onPress:n})}):null,(0,h.jsx)(c.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:s}),e&&S.length?(0,h.jsx)(o.default,{"aria-hidden":!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{position:'absolute',left:0,top:0,opacity:0,alignItems:'flex-start'},onLayout:e=>b(Math.ceil(e.nativeEvent.layout.width)),children:S.map(e=>(0,h.jsx)(c.T,{size:22,weight:"bold",numberOfLines:1,style:{alignSelf:'flex-start'},children:e},e))}):null]})},_e.BackButton=g,_e.useWebBack=function(e){const n=(0,t.useRef)(e);n.current=e,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.history?.pushState)return;const e=()=>{try{window.history.pushState({...window.history.state??{},ccBack:Date.now()},'',window.location.href)}catch{}};e();const t=t=>{n.current()&&(t.stopImmediatePropagation?.(),e())};return window.addEventListener('popstate',t,!0),()=>window.removeEventListener('popstate',t,!0)},[])};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]);const f=(0,s.create)(()=>({layers:[]}));let y=0;const w=()=>f(e=>e.layers.some(e=>e.own)),p=100;function g({onPress:e,testID:t="screen-back",label:o="Back"}){return(0,h.jsx)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:o,onPress:e,hitSlop:8,style:({pressed:e})=>({minHeight:48,minWidth:96,justifyContent:'center',paddingRight:12,opacity:e?.6:1,alignSelf:'flex-start'}),children:(0,h.jsxs)(c.T,{size:18,weight:"semibold",colour:l.colours.gold,children:["\u2039 ",o]})})}},1056,[34,236,402,102,846,821,794,1055,25]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PhoneAlerts=function({what:e="reminders and alerts set for you"}){const[s,h]=(0,t.useState)(null),[u,p]=(0,t.useState)(null),[y,f]=(0,t.useState)(null);(0,t.useEffect)(()=>{let e=!0;return(0,r.inApkWebView)()?h('apk'):(0,r.pushState)().then(t=>{e&&h(t)}).catch(()=>{e&&p('Could not check alerts. Try again.')}),()=>{e=!1}},[]);const b='on'===s?'Alerts are on for this phone.':'blocked'===s?'Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them:':'ios-home-screen'===s?'iPhone: add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.':'unsupported'===s?'This browser can\u2019t get alerts when the phone is locked. Open CoverCharge in Chrome.':null;return(0,c.jsxs)(n.default,{testID:"phone-alerts",style:{gap:10,alignItems:'center'},children:[(0,c.jsxs)(l.T,{center:!0,size:16,children:["Get the ",e," on this phone, even when the app is closed."]}),'apk'===s?(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i.colours.gold,center:!0,testID:"alerts-open-chrome",children:"Open CoverCharge in Chrome to turn on alerts"}):null,b?(0,c.jsx)(l.T,{center:!0,size:15,testID:"alerts-status",children:b}):null,'off'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Turn on alerts",testID:"turn-on-alerts",accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{const e=await(0,r.turnOnPush)();p(e.message),e.ok?h('on'):h(await(0,r.pushState)())}catch{p('Could not turn on alerts. Please try again.')}}}),(0,c.jsx)(l.T,{size:16,center:!0,testID:"alerts-allow-line",children:"When your phone asks, tap Allow."})]}):null,'blocked'===s?(0,c.jsx)(n.default,{style:{gap:6,alignItems:'center',alignSelf:'stretch'},testID:"alerts-blocked-steps",accessible:!0,accessibilityLabel:o.BLOCKED_SPOKEN,children:o.BLOCKED_STEPS.map((e,t)=>(0,c.jsx)(l.T,{size:15,center:!0,children:`${t+1}. ${e}`},t))}):null,'blocked'===s?(0,c.jsx)(l.Button,{label:"I\u2019ve allowed it, check again",testID:"alerts-recheck",accessibilityLabel:"I\u2019ve allowed it. Check again.",style:{minHeight:64,minWidth:260},onPress:async()=>{p(null);try{if('blocked'===await(0,r.pushState)())return void p('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,r.turnOnPush)();p(e.message),h(e.ok?'on':await(0,r.pushState)())}catch{p('Could not check alerts. Please try again.')}}}):null,'on'===s?(0,c.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,c.jsx)(l.Button,{label:"Send me a test notification",testID:"push-test",accessibilityLabel:"Send me a test notification. It goes only to your own phone.",style:{minHeight:56,minWidth:260},onPress:async()=>{f('Sending\u2026'),f((await(0,r.sendTestPush)()).message)}}),y?(0,c.jsx)(n.default,{accessibilityLiveRegion:"polite",children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-test-msg",children:y})}):null,(0,c.jsx)(l.Button,{small:!0,kind:"ghost",label:"Turn off alerts on this phone",testID:"turn-off-alerts",onPress:async()=>{const e=await(0,r.turnOffPush)();p(e.message),h(await(0,r.pushState)())}})]}):null,u?(0,c.jsx)(n.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,c.jsx)(l.T,{size:15,center:!0,testID:"push-msg",children:u})}):null,(0,c.jsx)(l.Muted,{center:!0,size:13,children:"For this phone only. Each person turns it on on their own phone."})]})};var e,t=_r(d[0]),s=_r(d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),c=_r(d[6])},1057,[34,102,794,1058,821,1059,25]); +__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,"BLOCKED_STEPS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"BLOCKED_SPOKEN",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"ALERTS_PROMPT_ON",{enumerable:!0,get:function(){return I}}),_e.chromeUrlFor=R,_e.PushPrompt=function(){const e=(0,s.useSync)(e=>e.kind),p=(0,s.useSync)(e=>e.staffRef),f=(0,s.useSync)(e=>e.venueId),[m,b]=(0,o.useState)(null),[C,I]=(0,o.useState)(null),[v,E]=(0,o.useState)(!1);if((0,o.useEffect)(()=>{if(!j.includes(u.APP_VARIANT)||!T)return;if(h.PITCH)return void(globalThis.__pitchPushPrompt=e=>{I(null),b(e)});if('staff'!==e||!p||!f)return;let t=!0;return(async()=>{let e='unsupported';if(!(0,c.inApkWebView)()){try{e=await(0,c.pushState)()}catch{return}if(!t)return;if('undefined'!=typeof Notification&&'granted'===Notification.permission&&('on'===e||'off'===e))return void(0,c.turnOnPush)()}const o=O(e);o&&t&&Date.now()-P()>k&&b(o)})(),()=>{t=!1}},[e,p,f]),!m)return null;const L=()=>{A(),b(null)},D='apk'===m||'webview'===m?'Open CoverCharge in Chrome to turn on alerts':'ios'===m?'Add CoverCharge to your Home Screen':'blocked'===m?'Allow alerts in Chrome so you don\u2019t miss orders and reminders':'Turn on alerts so you don\u2019t miss orders and reminders',z={minHeight:64,borderRadius:16,justifyContent:'center',alignItems:'center',paddingHorizontal:20,backgroundColor:i.colours.gold,alignSelf:'stretch'},B=(e,o)=>(0,x.jsxs)(l.default,{style:{flexDirection:'row',gap:12,alignItems:'center',alignSelf:'stretch'},children:[(0,x.jsx)(l.default,{style:{width:30,height:30,borderRadius:15,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:15,fontWeight:'700'},children:e})}),(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,flex:1,lineHeight:22},children:o})]},e);return(0,x.jsx)(l.default,{testID:"alerts-prompt-backdrop",style:{position:'fixed',left:0,right:0,top:0,bottom:0,zIndex:2147483100,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:18},children:(0,x.jsxs)(l.default,{testID:"alerts-prompt",accessibilityRole:'dialog',accessibilityLabel:D,style:{width:'100%',maxWidth:380,backgroundColor:i.colours.surface2,borderColor:i.colours.accentBorder,borderWidth:1,borderRadius:22,paddingHorizontal:22,paddingTop:22,paddingBottom:18,alignItems:'center',gap:14,shadowColor:'#000',shadowOpacity:.5,shadowRadius:24,shadowOffset:{width:0,height:10}},children:[(0,x.jsx)(l.default,{style:{position:'absolute',top:10,right:10},children:(0,x.jsx)(y.GoldClose,{testID:"alerts-prompt-close",label:"Close. Ask me again tomorrow",onPress:L})}),(0,x.jsx)(l.default,{style:{width:64,height:64,borderRadius:32,borderWidth:1.5,borderColor:i.colours.gold,alignItems:'center',justifyContent:'center',marginTop:6},children:(0,x.jsx)(_,{})}),(0,x.jsx)(t.Text,{testID:"alerts-prompt-title",accessibilityRole:"header",style:{color:i.colours.goldLight,fontSize:22,fontWeight:'700',textAlign:'center',lineHeight:28,paddingHorizontal:8},children:D}),'off'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(r.default,{testID:"alerts-prompt-turn-on",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"Turn on alerts. Your phone will then ask to allow notifications: tap Allow.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t||null)}catch{I('Could not turn on alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Turning on\u2026':'Turn on alerts'})}),(0,x.jsxs)(t.Text,{testID:"alerts-prompt-allow",style:{color:'#F2E6C9',fontSize:17,textAlign:'center'},children:["When your phone asks, tap ",(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontWeight:'700'},children:"Allow"}),"."]})]}):null,'blocked'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-blocked",accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"assertive",accessibilityLabel:S,style:{alignSelf:'stretch',gap:8},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:17,textAlign:'center',fontWeight:'700'},children:"Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again."}),w.map((e,t)=>B(t+1,e))]}):null,'blocked'===m?(0,x.jsx)(r.default,{testID:"alerts-prompt-recheck",accessibilityRole:"button",disabled:v,accessibilityState:{disabled:v,busy:v},accessibilityLabel:"I\u2019ve allowed it. Check again.",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{if('blocked'===await(0,c.pushState)())return void I('Still blocked. Follow the steps above in Chrome\u2019s settings, then tap check again.');const e=await(0,c.turnOnPush)();if(e.ok)return void b(null);I(e.message);const t=O(await(0,c.pushState)());b(t)}catch{I('Could not check alerts. Please try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Checking\u2026':'I\u2019ve allowed it, check again'})}):null,'ios'===m?(0,x.jsxs)(l.default,{testID:"alerts-prompt-ios",style:{alignSelf:'stretch',gap:10},children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:"iPhone only sends alerts to apps on the Home Screen. First:"}),B(1,'Tap the Share button (the square with the arrow) in Safari.'),B(2,'Tap Add to Home Screen, then Add.'),B(3,'Open CoverCharge from your Home Screen.'),B(4,'Tap Turn on alerts, then Allow.')]}):null,'apk'===m||'webview'===m?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(t.Text,{style:{color:'#F2E6C9',fontSize:16,textAlign:'center'},children:'apk'===m?'The phone app can\u2019t show alerts when it\u2019s closed. Chrome can. You\u2019ll stay signed in as you.':'This browser can\u2019t get alerts. Open CoverCharge in Chrome.'}),(0,x.jsx)(r.default,{testID:"alerts-prompt-open-chrome",accessibilityRole:"button",disabled:v,accessibilityLabel:"Open CoverCharge in Chrome to turn on alerts",style:[z,v?{opacity:.7}:null],onPress:async()=>{E(!0),I(null);try{let e=null;if('apk'===m){const t=await(0,s.makeChromeHandover)();if(!t.ok)return void I(t.message);e=t.code}const t=R(window.location.href,e,'apk'===m);if(h.PITCH)return I('Opening Chrome\u2026'),void(globalThis.__pitchLastChromeUrl=t);I('Opening Chrome\u2026 Then tap Turn on alerts there, and Allow.');try{window.location.href=t}catch{await n.default.openURL(t)}}catch{I('Could not open Chrome. Check your connection and try again.')}finally{E(!1)}},children:(0,x.jsx)(t.Text,{style:{color:'#0B0B0B',fontSize:20,fontWeight:'700'},children:v?'Opening\u2026':'Open in Chrome'})}),(0,x.jsx)(t.Text,{style:{color:'#CFC6B4',fontSize:14,textAlign:'center'},children:"In Chrome: tap Turn on alerts, then Allow."})]}):null,C?(0,x.jsx)(l.default,{accessibilityLiveRegion:"assertive",accessibilityRole:'alert',children:(0,x.jsx)(t.Text,{testID:"alerts-prompt-msg",style:{color:i.colours.goldLight,fontSize:15,textAlign:'center'},children:C})}):null,(0,x.jsx)(r.default,{testID:"alerts-prompt-later",accessibilityRole:"button",accessibilityLabel:"Not now. Ask me again tomorrow",onPress:L,style:{minHeight:48,justifyContent:'center',paddingHorizontal:24},children:(0,x.jsx)(t.Text,{style:{color:i.colours.goldLight,fontSize:17,textDecorationLine:'underline'},children:"Not now"})})]})})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2]));_r(d[3]);var r=e(_r(d[4])),l=e(_r(d[5])),i=_r(d[6]),s=_r(d[7]),c=_r(d[8]),h=_r(d[9]),u=_r(d[10]),p=_r(d[11]),f=_r(d[12]),y=_r(d[13]),m=_r(d[14]),b=e(m),x=_r(d[15]);const C='cc-alerts-prompt-v1',w=['In Chrome, tap the three dots at the top right, then Settings.','Tap Site settings, then Notifications.','Find CoverCharge (covercharge-apps) under Blocked, tap it, and choose Allow.','Come back here and tap \u201cI\u2019ve allowed it, check again\u201d.'],S=`Alerts are blocked in Chrome for this app, so your phone can\u2019t ask again. To allow them: ${w.map((e,t)=>`${t+1}. ${e}`).join(' ')}`,k=864e5,j=['owner','staff','chef'],T=!(f.IS_ISOLATED_VENUE||f.IS_QUEUED_VENUE||f.IS_GREENSIDE||f.IS_ABBOTSFORD||f.IS_KIRKTON),I=j.includes(u.APP_VARIANT)&&T&&!h.PITCH,v=()=>'undefined'!=typeof navigator&&/CoverChargePhone\//.test(navigator.userAgent);function P(){try{const e=JSON.parse(localStorage.getItem(C)||'{}');return Number(e.later||0)}catch{return 0}}function A(){try{localStorage.setItem(C,JSON.stringify({later:Date.now(),version:p.APP_VERSION}))}catch{}}function O(e){return v()?'apk':(0,c.inApkWebView)()?'webview':'off'===e?'off':'blocked'===e?'blocked':'ios-home-screen'===e?'ios':null}function R(e,t,o){const n=new URL(e),r=`${n.origin}${n.pathname.replace(/[^/]*$/,'')}index.html${t?`#ccchrome=${t}`:''}`;return o?`googlechrome://navigate?url=${encodeURIComponent(r)}`:`intent://${n.host}${n.pathname.replace(/[^/]*$/,'')}index.html#Intent;scheme=https;package=com.android.chrome;end`}function _(){return(0,x.jsxs)(b.default,{width:32,height:32,viewBox:"0 0 24 24",accessible:!1,pointerEvents:"none",children:[(0,x.jsx)(m.Path,{d:"M6 16 V11 a6 6 0 0 1 12 0 V16 l1.5 2 H4.5 Z",stroke:i.colours.gold,strokeWidth:1.7,strokeLinejoin:"round",fill:"none"}),(0,x.jsx)(m.Path,{d:"M10 20.5 a2 2 0 0 0 4 0",stroke:i.colours.gold,strokeWidth:1.7,strokeLinecap:"round",fill:"none"})]})}},1058,[827,34,379,236,402,102,821,987,1059,2,872,1016,5,796,797,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.inApkWebView=function(){return'undefined'!=typeof navigator&&(/; wv\)/.test(navigator.userAgent)||/CoverChargePhone\//.test(navigator.userAgent))},e.sendTestPush=async function(){if('staff'!==o.useSync.getState().kind)return{ok:!1,message:'Sign in from your personal link first.'};try{const t=(0,n.getSupabase)(),{data:o,error:s}=await t.functions.invoke('push-test',{body:{app:i.APP_VARIANT}});if(s)return{ok:!1,message:'Test notifications aren\u2019t switched on yet. Alerts still show while the app is open.'};const u=o?.sent??0;return u?{ok:!0,message:`Sent. It should appear on this phone in a few seconds${u>1?` (and ${u-1} other device${u>2?'s':''} of yours)`:''}.`}:{ok:!1,message:'No phone is connected for you yet. Tap Turn on alerts first.'}}catch{return{ok:!1,message:'Could not send a test. Check your connection and try again.'}}},e.pushState=f,e.turnOnPush=async function(){const u=await f();if('ios-home-screen'===u)return{ok:!1,message:'On iPhone, add this app to your Home Screen first (Share \u203a Add to Home Screen, iOS 16.4 or later), then open it from there.'};if('unsupported'===u)return{ok:!1,message:'This browser can\u2019t get phone notifications. Try Chrome on Android, or the app from your iPhone Home Screen.'};if('blocked'===u)return{ok:!1,message:'Notifications are blocked for this app. Allow them in your phone\u2019s settings, then try again.'};const c=o.useSync.getState();if('staff'!==c.kind||!c.venueId||!c.staffRef)return{ok:!1,message:'Sign in from your personal link first.'};if('granted'!==await Notification.requestPermission())return{ok:!1,message:'You didn\u2019t allow notifications, so nothing changed.'};const p=await navigator.serviceWorker.ready,h=(await p.pushManager.getSubscription()??await p.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:s(t.VAPID_PUBLIC_KEY)})).toJSON();if(!h.endpoint||!h.keys?.p256dh||!h.keys?.auth)return{ok:!1,message:'Your browser didn\u2019t give a usable subscription. Try again.'};const l=(0,n.getSupabase)(),{error:y}=await l.from('push_subscriptions').upsert({venue_id:c.venueId,staff_ref:c.staffRef,app:i.APP_VARIANT,endpoint:h.endpoint,p256dh:h.keys.p256dh,auth:h.keys.auth,user_agent:navigator.userAgent.slice(0,200)},{onConflict:'user_id,endpoint'});return y?{ok:!1,message:`Couldn\u2019t save this phone: ${y.message}`}:{ok:!0,message:'Phone notifications are on for this device.'}},e.turnOffPush=async function(){const t=await(navigator.serviceWorker?.getRegistration()),o=await(t?.pushManager.getSubscription());if(!o)return{ok:!0,message:'Phone notifications are off for this device.'};const i=o.endpoint;await o.unsubscribe();try{const t=(0,n.getSupabase)();await t.from('push_subscriptions').delete().eq('endpoint',i)}catch{}return{ok:!0,message:'Phone notifications are off for this device.'}};var t=r(d[0]),n=r(d[1]),o=r(d[2]),i=r(d[3]);r(d[4]);const s=t=>{const n=atob(t.replace(/-/g,'+').replace(/_/g,'/')+'='.repeat((4-t.length%4)%4)),o=new Uint8Array(n.length);for(let t=0;t'undefined'!=typeof navigator&&/iPhone|iPad|iPod/.test(navigator.userAgent),c=()=>'undefined'!=typeof window&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);async function f(){if('undefined'==typeof window||!('serviceWorker'in navigator))return'unsupported';if(!('PushManager'in window)||'undefined'==typeof Notification)return u()&&!c()?'ios-home-screen':'unsupported';if('denied'===Notification.permission)return'blocked';const t=await navigator.serviceWorker.getRegistration();return await(t?.pushManager.getSubscription())?'on':'off'}},1059,[1060,933,987,872,236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VAPID_PUBLIC_KEY",{enumerable:!0,get:function(){return t}});const t='BC3MoXpycbFY4Nf3czfBMaiD0iaMd1ugc70iUWZUiaScERZibFBsI9cmPAiNrlPN0b2_wJR-wgutj4eC8suarQ0'},1060,[]); +__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.useTasksProgress=function(e,s){const t=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],i=(0,r.useDailyTasks)(e=>e.ticks),{ymd:l,dow:o}=T();return(0,c.progress)(t,i,s,l,o)},_e.DailyTasksEditor=j,_e.MyTasksToday=function({rid:e,staffId:s,name:t,onShift:i}){const u=(0,r.useDailyTasks)(t=>t.people[(0,r.personKey)(e,s)]?.tasks)??[],h=(0,r.useDailyTasks)(e=>e.ticks),{ymd:y,dow:x}=T(),p=(0,c.tasksFor)(u,x);if(!s||!p.length)return null;const f=(0,c.progress)(u,h,s,y,x);return(0,k.jsx)(o.default,{testID:"my-tasks-today",children:(0,k.jsxs)(n.Card,{children:[(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(n.T,{weight:"semibold",colour:d.colours.gold,children:"My tasks today"}),(0,k.jsx)(n.Badge,{kind:f.done===f.total?'gold':'neutral',label:`${f.done} of ${f.total}`})]}),i?null:(0,k.jsx)(n.Muted,{size:12,children:"You\u2019re not on shift right now. You can still tick these when you are."}),p.map(c=>{const u=h.find(t=>t.id===(0,r.tickId)(e,s,c.id,y));return(0,k.jsxs)(l.default,{testID:`my-task-${c.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:!!u},disabled:!i,onPress:()=>r.useDailyTasks.getState().toggleTick(e,s,c.id,y,{id:s,name:t.replace(' (example)','')}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:8,opacity:i?1:.6},children:[(0,k.jsx)(o.default,{style:{width:24,height:24,borderRadius:6,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:u?'#2a2414':'transparent'},children:u?(0,k.jsx)(n.T,{colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsxs)(o.default,{style:{flex:1},children:[(0,k.jsx)(n.T,{style:{textDecorationLine:u?'line-through':'none'},children:c.text}),u?(0,k.jsxs)(n.Muted,{size:12,children:["Done at ",b(u.at)]}):null]})]},c.id)}),(0,k.jsx)(n.Muted,{size:12,children:"Tip: tick each one as you finish it. Your manager sees how you\u2019re getting on. They start fresh every day."})]})})},_e.TaskLibrarySettings=function({rid:e}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const t=(0,r.useDailyTasks)(s=>s.library[e]?.items)??[],[l,u]=(0,i.useState)(''),[h,x]=(0,i.useState)({}),f=r.useDailyTasks.getState(),b=s=>f.setLibrary(e,s);return(0,k.jsxs)(o.default,{style:{gap:8},testID:"task-library",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: these are quick picks when you add someone\u2019s daily tasks (Staff & roles \u203a a person \u203a Daily tasks). You can always type a new one there too."}),t.map((e,i)=>(0,k.jsxs)(n.Row,{gap:6,style:{opacity:e.archived?.5:1},children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:`Rename ${e.text}`,value:h[e.id]??e.text,onChangeText:s=>x(t=>({...t,[e.id]:s})),onBlur:()=>{const s=(0,c.cleanTaskText)(h[e.id]??'');s&&s!==e.text&&b(t.map(t=>t.id===e.id?{...t,text:s}:t))},style:{...p,flex:1,minWidth:0}}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",disabled:0===i,onPress:()=>b((0,c.move)(t,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",disabled:i===t.length-1,onPress:()=>b((0,c.move)(t,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>b(t.map(s=>s.id===e.id?{...s,archived:!s.archived}:s))})]},e.id)),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New library task",testID:"task-lib-new",value:l,onChangeText:u,placeholder:"e.g. Check the beer garden",placeholderTextColor:d.colours.muted,style:{...p,flex:1}}),(0,k.jsx)(n.Button,{small:!0,label:"Add",disabled:!(0,c.cleanTaskText)(l),onPress:()=>{b([...t,{id:(0,y.uuid)(),text:(0,c.cleanTaskText)(l)}]),u('')}})]})]})},_e.KitchenTeamTasks=function({rid:e,actor:s}){const t=(0,x.useOwner)(e=>e.staff).filter(e=>e.active&&s&&(0,c.canEditTasks)(s,e));return(0,k.jsxs)(o.default,{style:{gap:10},testID:"kitchen-team-tasks",children:[(0,k.jsx)(n.Muted,{size:13,children:"Tip: set the daily tasks for your kitchen team here. They see them as \u2018My tasks today\u2019 when they\u2019re on shift and tick them off. Your own list and front of house lists are set by a manager."}),s?null:(0,k.jsx)(n.Muted,{children:"Sign in to change your team\u2019s tasks."}),s&&!t.length?(0,k.jsx)(n.Muted,{children:"No kitchen staff found. A manager can set each person\u2019s department in Staff & roles."}):null,t.map(t=>(0,k.jsxs)(n.Card,{children:[(0,k.jsx)(n.T,{weight:"semibold",children:(0,x.staffLabel)(t).replace(' (example)','')}),(0,k.jsxs)(n.Muted,{size:12,children:[t.job,t.dept?` \xb7 ${t.dept}`:'']}),(0,k.jsx)(j,{rid:e,person:t,actor:s})]},t.id))]})};var s=_r(_d[0]),t=_r(_d[1]),i=_r(_d[2]),l=e(_r(_d[3])),o=e(_r(_d[4])),n=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),y=_r(_d[11]),x=_r(_d[12]),k=_r(_d[13]);const p={minHeight:42,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},f=[1,2,3,4,5,6,0],b=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),T=(e=Date.now())=>{const s=(0,u.ukClock)(e);return{ymd:s.ymd,dow:new Date(`${s.ymd}T12:00:00Z`).getUTCDay()}};function j({rid:e,person:u,actor:y}){(0,i.useEffect)(()=>{r.useDailyTasks.getState().ensure(e)},[e]);const x=(0,r.useDailyTasks)(s=>s.people[(0,r.personKey)(e,u.id)]?.tasks)??[],j=((0,r.useDailyTasks)(s=>s.library[e]?.items)??[]).filter(e=>!e.archived),w=(0,r.useDailyTasks)(e=>e.ticks),[D,v]=(0,i.useState)(!1),[C,S]=(0,i.useState)(''),[$,I]=(0,i.useState)(null),M=r.useDailyTasks.getState(),P=(0,c.canEditTasks)(y,u),{ymd:R,dow:L}=T(),z=(0,c.progress)(x,w,u.id,R,L),B=s=>M.setTasks(e,u.id,s),A=e=>{const s=x;B(x.filter(s=>s.id!==e.id)),(0,h.notify)({id:`task-undo-${e.id}`,title:`Removed \u201c${e.text}\u201d`,timeoutMs:8e3,actions:[{label:'Undo',testID:'task-undo',onPress:()=>B(s)}]})};return(0,k.jsxs)(o.default,{testID:`tasks-${u.id}`,style:{gap:6},children:[(0,k.jsx)(l.default,{accessibilityRole:"button",testID:`tasks-open-${u.id}`,onPress:()=>v(!D),children:(0,k.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsxs)(n.T,{weight:"semibold",colour:d.colours.gold,children:["Daily tasks ",D?'\u25b4':'\u25be']}),(0,k.jsx)(n.Muted,{size:12,children:x.length?`${z.done} of ${z.total} done today`:'None yet'})]})}),D?(0,k.jsxs)(o.default,{style:{gap:6},children:[x.map((s,i)=>{const l=w.find(t=>t.id===(0,r.tickId)(e,u.id,s.id,R));return(0,k.jsxs)(o.default,{testID:`task-row-${i}`,style:{borderTopWidth:1,borderColor:d.colours.hairline,paddingTop:6,gap:4},children:[(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsxs)(n.T,{style:{flex:1},colour:l?d.colours.gold:d.colours.text,children:[l?'\u2713 ':'',s.text]}),P?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2191",accessibilityLabel:`Move ${s.text} up`,disabled:0===i,onPress:()=>B((0,c.move)(x,i,-1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u2193",accessibilityLabel:`Move ${s.text} down`,disabled:i===x.length-1,onPress:()=>B((0,c.move)(x,i,1))}),(0,k.jsx)(n.Button,{small:!0,kind:"ghost",label:"Days",onPress:()=>I($===s.id?null:s.id)}),(0,k.jsx)(t.GoldClose,{size:"sm",testID:`task-remove-${i}`,label:`Remove ${s.text}`,onPress:()=>A(s)})]}):null]}),(0,k.jsxs)(n.Muted,{size:12,children:[s.days?.length?s.days.map(e=>c.TASK_DAY_NAMES[e]).join(', '):'Every day',l?` \xb7 ticked by ${l.byName.split(' ')[0]} at ${b(l.at)}`:'']}),$===s.id?(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:f.map(e=>{const t=!!s.days?.includes(e);return(0,k.jsx)(n.Chip,{label:c.TASK_DAY_NAMES[e],selected:t,onPress:()=>B(x.map(i=>i.id===s.id?{...i,days:t?(i.days??[]).filter(s=>s!==e):[...i.days??[],e].sort()}:i))},e)})}):null]},s.id)}),P?(0,k.jsxs)(o.default,{style:{gap:6},children:[(0,k.jsx)(n.Row,{wrap:!0,gap:4,children:j.filter(e=>!x.some(s=>s.text.toLowerCase()===e.text.toLowerCase())).slice(0,12).map(s=>(0,k.jsx)(n.Chip,{testID:"task-lib-chip",label:`${s.text}`,onPress:()=>M.addTask(e,u.id,s.text,s.id)},s.id))}),(0,k.jsxs)(n.Row,{gap:6,children:[(0,k.jsx)(s.TextInput,{accessibilityLabel:"New task",testID:`task-new-${u.id}`,value:C,onChangeText:S,placeholder:"Type a task, e.g. Restock the bar fridges",placeholderTextColor:d.colours.muted,style:{...p,flex:1},onSubmitEditing:()=>{(0,c.cleanTaskText)(C)&&(M.addTask(e,u.id,C),S(''))}}),(0,k.jsx)(n.Button,{small:!0,testID:`task-add-${u.id}`,label:"Add",disabled:!(0,c.cleanTaskText)(C),onPress:()=>{M.addTask(e,u.id,C),S('')}})]})]}):(0,k.jsx)(n.Muted,{size:12,children:'staff'===y?.role?'You can\u2019t change this list.':''})]}):null]})}},1061,[827,796,34,402,102,794,821,1044,1045,1010,1001,870,891,25]); +__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.readBack=B,_e.ReviewSheet=L,_e.Bars=z,_e.CashCharts=A,_e.CashUpScreen=function(e){return e.closer?(0,$.jsx)(N,{rid:e.rid,tonight:e.today,who:e.who}):(0,$.jsx)(E,{...e})},_e.CloserCashUp=N,_e.PastDayCard=O,_e.TodaysTipsCard=function({rid:e,today:t,big:s}){const a=(0,f.useTipsShow)(e),o=(0,f.useCashUp)(e=>e.tips).filter(s=>s.rid===e&&(s.date===t||s.date===(0,x.addDaysYmd)(t,-1))).sort((e,t)=>t.date.localeCompare(e.date))[0],l=G(o?.total??0);return a.showToday&&o?(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"todays-tips",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(o.total/25)}),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:o.date===t?'TODAY\u2019S TIPS':'LAST NIGHT\u2019S TIPS'}),(0,$.jsx)(p.T,{size:s?40:32,weight:"bold",colour:y.colours.goldLight,children:P(l)}),(0,$.jsxs)(p.Muted,{children:["Cash + card tips for the whole team \xb7 ",M(o.date),". Thank you, everyone."]})]})]})}):null},_e.TipsPotCard=V,_e.postTipsNotice=K,_e.latestDayTips=Z,_e.useTipsPosted=function(e,t,s=!0){const a=(0,f.useCashUp)(e=>e.tips),o=(0,f.useTipsShow)(e);(0,l.useEffect)(()=>{if(!s||!o.showToday)return;const l=Z(a,e,t);l&&K(e,l.date,l.total,t)},[e,t,a,o.showToday,s])},_e.CashUpSettings=function({rid:e}){const t=U(e),s=(t,s)=>f.useCashUp.getState().setFields(e,t,s),l=(e,l)=>(0,$.jsxs)(c.default,{style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",children:l}),t[e].map((l,n)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{testID:`cf-${e}-${l.key}`,value:l.label,onChangeText:a=>s(e,t[e].map((e,t)=>t===n?{...e,label:a.slice(0,40)}:e)),style:{flex:1,minHeight:38,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',color:y.colours.text,paddingHorizontal:8}}),(0,$.jsx)(p.Muted,{children:'money'===l.kind?'\xa3':'number'===l.kind?'#':'text'}),l.fixed?(0,$.jsx)(p.Muted,{children:"needed"}):(0,$.jsx)(a.GoldClose,{size:"sm",label:`Remove ${l.label}`,onPress:()=>s(e,t[e].filter((e,t)=>t!==n))})]},l.key)),(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Money figure",onPress:()=>s(e,[...t[e],{key:`f${Date.now().toString(36)}`,label:'New figure',kind:'money'}])}),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",label:"Number",onPress:()=>s(e,[...t[e],{key:`n${Date.now().toString(36)}`,label:'New number',kind:'number'}])})]})]});return(0,$.jsxs)(c.default,{testID:"cashup-settings",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: match these to the boxes on your paper cash up sheet and till printout. Cash tips total and Card tips total are needed for Today\u2019s tips and the Tips pot."}),l('cashFields','Cash up sheet'),l('salesFields','Weekly sales report')]})},_e.TipsSettings=function({rid:e}){const t=(0,f.useTipsShow)(e);return(0,$.jsxs)(c.default,{testID:"tips-settings",style:{gap:8},children:[(0,$.jsx)(p.Muted,{children:"Staff only ever see the team total: never anyone\u2019s share or pay. The Display never shows tips or money."}),(0,$.jsx)(p.Toggle,{testID:"tips-show-today",label:"Show Today\u2019s tips in the staff apps",value:t.showToday,onChange:t=>f.useCashUp.getState().setShow(e,{showToday:t})}),(0,$.jsx)(p.Toggle,{testID:"tips-show-pot",label:"Show the Tips pot in the staff apps",value:t.showPot,onChange:t=>f.useCashUp.getState().setShow(e,{showPot:t})})]})};var t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),n=e(_r(_d[5])),r=e(_r(_d[6])),i=e(_r(_d[7])),d=e(_r(_d[8])),h=e(_r(_d[9])),c=e(_r(_d[10])),u=e(_r(_d[11])),p=_r(_d[12]),y=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),x=_r(_d[16]),k=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),C=_r(_d[21]),T=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),I=_r(_d[26]),$=_r(_d[27]);const P=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,M=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'});function B(e){const t=t=>'number'==typeof e[t]?e[t]:null,s=(0,x.combinedTips)(e);return[['Gross',t('gross')],['card',t('card')],['cash',t('cash')],['tips',s],['food',t('food')],['drink',t('drink')]].filter(([,e])=>null!=e).map(([e,t])=>`${e} ${P(t)}`).join(', ')}function R({p:e,h:s}){const[a,o]=(0,l.useState)(e.startsWith('data:')?e:null),n=e.startsWith('data:')||(0,w.photosAllowed)();return(0,l.useEffect)(()=>{!a&&n&&(0,w.photoUrl)(e).then(o)},[e,n]),n?a?(0,$.jsx)(d.default,{source:{uri:a},style:{width:'100%',height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#111')},resizeMode:"contain"}):(0,$.jsx)(c.default,{style:{height:s,borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center'},children:(0,$.jsx)(p.Muted,{children:"Photo"})}):(0,$.jsx)(c.default,{testID:"photo-owners-only",accessible:!0,accessibilityLabel:"Taking-sheet photo. Only owners can view saved photos.",style:{height:Math.min(s,90),borderRadius:10,backgroundColor:(0,t.soutersSurface)('#1B1A18'),alignItems:'center',justifyContent:'center',padding:10},children:(0,$.jsx)(p.Muted,{center:!0,children:"Photo saved. Only owners can view it."})})}function L({draft:e,fields:t,onClose:s,onConfirm:n,keyLabel:r,onKey:i,keyChoices:d}){const{width:h,height:f}=(0,u.default)(),m=h>=820;e.only&&(t=t.filter(t=>e.only.includes(t.key)));const[k,b]=(0,l.useState)(()=>Object.fromEntries(t.map(t=>[t.key,(0,x.isBlank)(e.vals[t.key])?'':String(e.vals[t.key])]))),[j,w]=(0,l.useState)(()=>e.categories.map(e=>({name:e.name,amount:String(e.amount)}))),[C,T]=(0,l.useState)(!1),v=Object.fromEntries(t.map(e=>[e.key,'text'===e.kind?k[e.key]?.trim()||null:(0,x.parseAmount)(k[e.key]??'',e.kind)])),S=t.filter(e=>'text'!==e.kind&&(k[e.key]??'').trim()&&null==v[e.key]).map(e=>e.key),D=(0,x.missing)(t,v),I=j.map(e=>({name:e.name.trim(),amount:(0,x.parseAmount)(e.amount)})).filter(e=>e.name),P=I.some(e=>null==e.amount),M=e=>({minHeight:42,borderRadius:10,borderWidth:e?2:1,borderColor:e?y.colours.amber:'rgba(255,255,255,0.15)',backgroundColor:e?'rgba(232,168,56,0.08)':'#141312',color:y.colours.text,paddingHorizontal:10,fontSize:17}),B=(0,$.jsx)(c.default,{testID:"review-photos",style:{gap:8,flex:m?1:void 0},children:e.photos.length?e.photos.map((t,s)=>(0,$.jsx)(R,{p:t,h:m?Math.max(300,.62*f/Math.min(2,e.photos.length)):260},s)):(0,$.jsx)(p.Muted,{children:"No photo: typed by hand."})}),L=(0,$.jsxs)(c.default,{testID:"review-fields",style:{gap:8,flex:m?1:void 0},children:[(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Muted,{children:r}),d.map(t=>(0,$.jsx)(p.Chip,{label:t.label,selected:e.key===t.value,onPress:()=>i(t.value)},t.value))]}),t.map(e=>{const t='text'!==e.kind&&!(k[e.key]??'').trim()||S.includes(e.key);return(0,$.jsxs)(c.default,{style:{gap:3},children:[(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:e.label}),t&&'text'!==e.kind?(0,$.jsx)(p.Badge,{kind:"amber",label:S.includes(e.key)?'Check this':'Not read: type it'}):null]}),(0,$.jsx)(o.TextInput,{testID:`review-${e.key}`,value:k[e.key]??'',onChangeText:t=>b(s=>({...s,[e.key]:t})),keyboardType:'text'===e.kind?'default':'decimal-pad',placeholder:'money'===e.kind?'\xa3':'number'===e.kind?'Number':'Optional',placeholderTextColor:"#777",style:M(t)})]},e.key)}),'sales'===e.kind?(0,$.jsxs)(c.default,{testID:"review-categories",style:{gap:6},children:[(0,$.jsx)(p.T,{weight:"semibold",size:14,children:"Sales by category (if the printout has them)"}),j.map((e,t)=>(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(o.TextInput,{value:e.name,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,name:e}:s)),placeholder:"e.g. Food",placeholderTextColor:"#777",style:[M(!1),{flex:2}]}),(0,$.jsx)(o.TextInput,{value:e.amount,onChangeText:e=>w(s=>s.map((s,a)=>a===t?{...s,amount:e}:s)),placeholder:"\xa3",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:[M(!e.amount.trim()||null==(0,x.parseAmount)(e.amount)),{flex:1}]}),(0,$.jsx)(a.GoldClose,{size:"sm",label:"Remove category",onPress:()=>w(e=>e.filter((e,s)=>s!==t))})]},t)),(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"review-add-cat",label:"Add a category",onPress:()=>w(e=>[...e,{name:'',amount:''}])})]}):null]});return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:s,title:'cashup'===e.kind?'Check the cash up':'Check the weekly sales',maxWidth:1100,testID:"review-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: check each figure against the photo. Nothing is saved until you tap Confirm. Amber boxes weren\u2019t read: type them, or leave them blank if the sheet doesn\u2019t have them."}),'edit'===e.reader||e.only?null:e.reader?(0,$.jsx)(p.Banner,{kind:"info",title:"Read from the photo",children:e.note}):e.photos.length?(0,$.jsx)(p.Banner,{kind:"info",title:"Type it from the photo",children:e.note}):null,m?(0,$.jsxs)(c.default,{style:{flexDirection:'row',gap:14},children:[B,L]}):(0,$.jsxs)($.Fragment,{children:[B,L]}),D.length?(0,$.jsxs)(p.Muted,{children:[D.length," figure",1===D.length?'':'s'," still blank. Blank means \u201cnot on the sheet\u201d, never zero."]}):null,(0,$.jsxs)(p.Row,{gap:8,children:[(0,$.jsx)(p.Button,{testID:"review-confirm",label:C?'Saving\u2026':'Confirm and save',disabled:C||!!S.length||P||!t.some(e=>'text'!==e.kind&&null!=v[e.key]),onPress:async()=>{T(!0),await n(v,I.map(e=>({name:e.name,amount:e.amount}))),T(!1)}}),(0,$.jsx)(p.Button,{kind:"secondary",label:"Cancel",onPress:s})]})]})}function z({data:e,height:t=140,testID:s,fmt:a=P}){const o=Math.max(1,...e.map(e=>e.value??0));return(0,$.jsxs)(c.default,{testID:s,style:{gap:4},children:[(0,$.jsx)(c.default,{style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:t},children:e.map((e,s)=>(0,$.jsxs)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'flex-end',height:t},children:[null!=e.value?(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,children:a(e.value).replace('.00','')}):null,(0,$.jsx)(c.default,{style:{width:'80%',height:null==e.value?2:Math.max(3,e.value/o*(t-16)),borderRadius:4,backgroundColor:null==e.value?'#333':e.hi?y.colours.goldLight:y.colours.gold,opacity:null==e.value?.6:1}})]},s))}),(0,$.jsx)(c.default,{style:{flexDirection:'row',gap:4},children:e.map((e,t)=>(0,$.jsx)(p.T,{size:9,colour:y.colours.muted,style:{flex:1,textAlign:'center'},children:e.label},t))})]})}function A({rid:e,today:s}){const a=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e),o=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e),l=(0,x.dailySeries)(a,s,14),n=(0,x.dailySeries)(a,s,14,x.combinedTips),r=(0,x.weekStartOf)(s),i=Array.from({length:8},(e,t)=>(0,x.addDaysYmd)(r,7*(t-7))).map(e=>{const t=o.find(t=>t.weekStart===e&&t.confirmedAt),s=t?.vals.net;return{label:M(e).split(' ').slice(1).join(' '),value:'number'==typeof s?s:null,hi:e===r}}),d=[...o].filter(e=>e.confirmedAt).sort((e,t)=>t.weekStart.localeCompare(e.weekStart))[0],h=d?(0,x.weekCompare)(o,d.weekStart):null,u=d?.categories??[],m=Math.max(1,...u.map(e=>e.amount)),k=d?(0,x.weekCompare)(o,d.weekStart,'covers'):null;return(0,$.jsxs)(c.default,{testID:"cash-charts",style:{gap:12},children:[(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Takings, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Card + cash from confirmed cash ups. A grey line means no cash up that day."}),(0,$.jsx)(z,{testID:"chart-daily",data:l.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Tips, last 14 days"}),(0,$.jsx)(p.Muted,{children:"Cash + card tips, team total."}),(0,$.jsx)(z,{testID:"chart-tips",height:100,data:n.map(e=>({label:M(e.date).split(' ')[1],value:e.value,hi:e.date===s}))})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly net sales"}),h&&null!=h.now?(0,$.jsx)(c.default,{testID:"week-compare",children:(0,$.jsxs)(p.T,{size:15,children:["Week of ",M(d.weekStart),": ",P(h.now),null!=h.prev?` \xb7 week before ${P(h.prev)}`:'',null!=h.change?` \xb7 ${h.change>=0?'\u25b2':'\u25bc'} ${Math.abs(h.change)}%`:'']})}):(0,$.jsx)(p.Muted,{children:"No weekly sales report yet."}),k&&null!=k.now?(0,$.jsxs)(p.Muted,{children:["Covers ",k.now,null!=k.prev?` (week before ${k.prev})`:'']}):null,(0,$.jsx)(z,{testID:"chart-weekly",data:i})]}),u.length?(0,$.jsxs)(p.Card,{children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["By category, week of ",M(d.weekStart)]}),(0,$.jsx)(c.default,{testID:"chart-categories",style:{gap:6},children:u.map(e=>(0,$.jsxs)(c.default,{style:{gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{size:14,children:e.name}),(0,$.jsx)(p.T,{size:14,colour:y.colours.goldLight,children:P(e.amount)})]}),(0,$.jsx)(c.default,{style:{height:10,borderRadius:5,backgroundColor:(0,t.soutersSurface)('#2A2826')},children:(0,$.jsx)(c.default,{style:{width:e.amount/m*100+"%",height:10,borderRadius:5,backgroundColor:y.colours.gold}})})]},e.name))})]}):null]})}function U(e){const t=(0,f.useCashSettings)(e),s=(0,m.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings.cashUpRecord);return(0,l.useMemo)(()=>({...t,record:s,cashFields:(0,x.cashFieldsForRecord)(t.cashFields,s)}),[t,s])}const F=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}):'',W=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`;function N({rid:e,tonight:t,who:s}){const a=U(e),o=(0,f.useCashUp)(e=>e.cashUps).find(s=>s.rid===e&&s.date===t),[r,i]=(0,l.useState)(null),[d,u]=(0,l.useState)(null),[m,k]=(0,l.useState)(!1),b=!!o?.confirmedAt,j=async e=>{if(b)return;const s=e?await(0,w.pickPhotos)({source:e}):[];if(e&&!s.length)return void u('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');let o,l={vals:{},reader:null,note:'Type the figures from the sheet.'};s.length&&(k(!0),u('Reading the photo\u2026'),o=await Promise.all(s.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=await(0,C.readSheet)('cashup',o.filter(e=>!!e),a.cashFields),k(!1),u(null)),i({kind:'cashup',key:t,photos:s,vals:l.vals,categories:[],unread:(0,x.missing)(a.cashFields,l.vals),note:l.note,reader:l.reader,uploaded:o})},T=async a=>{if(!r||b)return void i(null);const o=r.uploaded&&r.uploaded.length===r.photos.length?r.uploaded:await Promise.all(r.photos.map((e,s)=>(0,w.uploadPhoto)('cashup',t,e,s))),l=r.photos.map((e,t)=>o[t]??e);f.useCashUp.getState().saveCashUp({rid:e,date:t,vals:a,photos:l,confirmedBy:s.name,confirmedAt:(new Date).toISOString(),readBy:r.reader});const d=B(a);u(`Tonight\u2019s cash up is saved and signed off${d?`: ${d}`:''}.${o.some(e=>null==e)&&r.photos.length?' The photo will be sent when this phone is back online.':''}`);try{n.default.announceForAccessibility?.(`Saved and signed off. ${d}`)}catch{}i(null)};return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12,alignItems:'center',width:'100%'},children:[d?(0,$.jsx)(p.Banner,{kind:"info",children:d}):null,(0,$.jsx)(p.Card,{highlight:y.colours.gold,children:(0,$.jsxs)(c.default,{testID:"closer-cashup",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Tonight\u2019s cash up"}),(0,$.jsxs)(p.T,{center:!0,size:15,colour:y.colours.muted,testID:"closer-day",children:[M(t)," \xb7 ",W(t)]}),b?(0,$.jsxs)(c.default,{testID:"closer-done",accessible:!0,accessibilityLabel:`Tonight's cash up is done. Submitted by ${o?.confirmedBy??'someone'} at ${F(o?.confirmedAt)}. ${B(o.vals)}. It is signed off. If something is wrong, ask an owner to unlock it.`,style:{alignItems:'center',gap:6,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:18,weight:"semibold",colour:y.colours.goldLight,children:"Done and signed off"}),(0,$.jsxs)(p.T,{center:!0,size:15,children:["Submitted by ",o?.confirmedBy??'\u2014'," at ",F(o?.confirmedAt)]}),(0,$.jsx)(p.T,{center:!0,size:15,children:B(o.vals)||'No figures'}),o.photos.length?(0,$.jsxs)(p.Muted,{center:!0,size:13,children:[o.photos.length," photo",o.photos.length>1?'s':''," of the taking sheet sent to the owners."]}):null,(0,$.jsx)(p.Muted,{center:!0,size:13,children:"If something is wrong, ask an owner to unlock it."})]}):(0,$.jsxs)($.Fragment,{children:[a.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${a.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record"}),a.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:m,onPress:()=>{j('camera')},style:({pressed:e})=>({minHeight:64,width:'100%',borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:m?.5:1}),children:(0,$.jsx)(p.T,{center:!0,size:20,weight:"semibold",colour:y.colours.onGold,children:m?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{j('gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{j(null)}})]}),(0,$.jsx)(p.Muted,{center:!0,size:13,children:"Check the figures, then Confirm. Once confirmed it\u2019s signed off, and the photo goes to the owners only."})]})]})}),(0,$.jsx)(p.Muted,{center:!0,size:12,testID:"closer-note",children:"You can do tonight\u2019s cash up only. Past takings, charts and sales reports are for owners and managers."}),r?(0,$.jsx)(L,{draft:r,fields:a.cashFields,onClose:()=>i(null),onConfirm:e=>T(e),keyLabel:"Day",keyChoices:[{label:'Tonight',value:t}],onKey:()=>{}},`closer-${r.photos.length}`):null]})}function E({rid:e,today:t,canEdit:s,who:a,chartsOnly:o,backdate:r}){const i=U(e),d=(0,f.useCashUp)(e=>e.cashUps).filter(t=>t.rid===e).sort((e,t)=>t.date.localeCompare(e.date)),u=(0,f.useCashUp)(e=>e.sales).filter(t=>t.rid===e).sort((e,t)=>t.weekStart.localeCompare(e.weekStart)),[m,k]=(0,l.useState)(null),[b,j]=(0,l.useState)(null),D=(0,v.useLockedFor)(e),[I,R]=(0,l.useState)(!1),[z,F]=(0,l.useState)(null),W=async(e,s,a,o)=>{const l=a??('cashup'===e?t:(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7)));if(D(e,l))return void j((0,v.lockedMessage)(e,l));const n=s?await(0,w.pickPhotos)({source:s}):[];if(s&&!n.length)return void j('No photo taken. Try again, choose one from the gallery, or type the figures by hand.');const r='cashup'===e?i.cashFields:i.salesFields;let h,c={vals:{},reader:null,note:'Type the figures from the sheet.',categories:[]};n.length&&(R(!0),j('Reading the photo\u2026'),h=await Promise.all(n.map((t,s)=>(0,w.uploadPhoto)(e,l,t,s))),c=await(0,C.readSheet)(e,h.filter(e=>!!e),r),R(!1),j(null));const u=o&&'cashup'===e?d.find(e=>e.date===l)?.vals:void 0;k({kind:e,key:l,photos:n,vals:u?{...c.vals,...u}:c.vals,categories:c.categories??[],unread:(0,x.missing)(r,c.vals),note:c.note,reader:o?'edit':c.reader,uploaded:h,only:o})},N=[0,1,2].map(e=>({label:0===e?'Today':1===e?'Yesterday':M((0,x.addDaysYmd)(t,-e)),value:(0,x.addDaysYmd)(t,-e)}));'cashup'!==m?.kind||N.some(e=>e.value===m.key)||N.push({label:M(m.key),value:m.key});const E=[0,1,2].map(e=>{const s=(0,x.weekStartOf)((0,x.addDaysYmd)(t,-7*e));return{label:0===e?'This week':1===e?'Last week':`w/c ${M(s)}`,value:s}});return(0,$.jsxs)(c.default,{testID:"cashup-screen",style:{gap:12},children:[(0,$.jsx)(p.Muted,{children:"Tip: at the end of the night, tap Take a picture of the taking sheet: the figures are filled in from the photo for you to check beside it, then Confirm. Bigger venues can Upload a spreadsheet (CSV or Excel) for one night or several. Gross takings feed Spend per head. Head Chefs can see the graphs."}),b?(0,$.jsx)(p.Banner,{kind:"info",children:b}):null,(0,$.jsx)(V,{rid:e,today:t,manage:s,who:a}),s&&!o?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"End of night cash up"}),i.record?.length?(0,$.jsxs)(c.default,{testID:"cashup-record",accessibilityLabel:`What to record at nightly cash up. ${i.record.join(', ')}`,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,weight:"bold",colour:y.colours.gold,children:"What to record at nightly cash up"}),i.record.map(e=>(0,$.jsx)(p.T,{center:!0,children:e},e))]}):null,(0,$.jsx)(h.default,{testID:"upload-cashup",accessibilityRole:"button",accessibilityLabel:"Take a picture of the taking sheet. Opens the camera; the figures are filled in for you to check.",disabled:I,onPress:()=>{W('cashup','camera')},style:({pressed:e})=>({minHeight:64,borderRadius:16,backgroundColor:e?y.colours.goldLight:y.colours.gold,alignItems:'center',justifyContent:'center',paddingHorizontal:18,opacity:I?.5:1}),children:(0,$.jsx)(p.T,{size:20,weight:"semibold",colour:y.colours.onGold,children:I?'Reading the photo\u2026':'Take a picture of the taking sheet'})}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"cashup-gallery",kind:"secondary",label:"Choose from gallery",accessibilityLabel:"Choose a photo of the cash up from the gallery",onPress:()=>{W('cashup','gallery')}}),(0,$.jsx)(p.Button,{testID:"cashup-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('cashup',null)}}),(0,$.jsx)(p.Button,{testID:"cashup-sheet",kind:"secondary",label:"Upload a spreadsheet",accessibilityLabel:"Upload a spreadsheet of takings, CSV or Excel, for one night or several",onPress:async()=>{const e=await(0,T.pickSpreadsheet)();e&&('error'in e?j(e.error):F(e))}}),(0,$.jsx)(p.Button,{testID:"cashup-takings",kind:"secondary",label:"Enter takings",accessibilityLabel:"Enter tonight's takings: gross, and food and drink if you have them",onPress:()=>{W('cashup',null,t,x.TAKINGS_KEYS)}})]}),(0,$.jsx)(p.T,{weight:"semibold",style:{marginTop:8},children:"Weekly sales report"}),(0,$.jsxs)(p.Row,{wrap:!0,gap:8,children:[(0,$.jsx)(p.Button,{testID:"upload-sales",label:"Upload weekly sales report",onPress:()=>{W('sales','camera')}}),(0,$.jsx)(p.Button,{testID:"sales-gallery",kind:"secondary",label:"Choose from gallery",onPress:()=>{W('sales','gallery')}}),(0,$.jsx)(p.Button,{testID:"sales-by-hand",kind:"secondary",label:"Type it in",onPress:()=>{W('sales',null)}})]}),(0,$.jsx)(p.Muted,{children:"Several pages? Pick them all at once. Fields can be changed in Settings \u203a Advanced \u203a Cash up."})]}):null,s&&r&&!o?(0,$.jsx)(O,{today:t,has:e=>d.some(t=>t.date===e),paid:t=>(0,S.paidOutFor)(t,f.useCashUp.getState().pot,e),onOpen:e=>{if(D('cashup',e))return void j((0,v.lockedMessage)('cashup',e));const t=d.find(t=>t.date===e);k({kind:'cashup',key:e,photos:t?.photos??[],vals:t?.vals??{},categories:[],unread:[],note:t?'':'Type the figures for that day.',reader:'edit'})}}):null,(0,$.jsx)(A,{rid:e,today:t}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Recent cash ups"}),d.length?d.slice(0,10).map(e=>(0,$.jsxs)(c.default,{testID:`cashup-row-${e.date}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)',gap:2},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsx)(p.T,{weight:"semibold",children:M(e.date)}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P((0,x.takings)(e.vals))})]}),(0,$.jsx)(p.Muted,{children:i.cashFields.filter(e=>'text'!==e.kind&&'card'!==e.key&&'cash'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),(0,$.jsxs)(p.Muted,{children:["Confirmed by ",e.confirmedBy??'\u2014',e.photos.length?` \xb7 ${e.photos.length} photo${e.photos.length>1?'s':''}`:'']}),(0,S.historyLines)(e.vals).slice(0,3).map(t=>(0,$.jsx)(p.Muted,{size:12,testID:`cashup-later-${e.date}`,children:t},t)),s&&!D('cashup',e.date)?(0,$.jsxs)(p.Row,{gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit",onPress:()=>k({kind:'cashup',key:e.date,photos:e.photos,vals:e.vals,categories:[],unread:[],note:'',reader:'edit'})}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:`takings-edit-${e.date}`,label:null==(0,x.grossOf)(e.vals)?'Add takings':'Edit takings',onPress:()=>k({kind:'cashup',key:e.date,photos:[],vals:e.vals,categories:[],unread:[],note:'',reader:'edit',only:x.TAKINGS_KEYS})})]}):null,s?(0,$.jsx)(v.CashLockControls,{kind:"cashup",item:e,label:M(e.date)}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),(0,$.jsxs)(p.Card,{children:[(0,$.jsx)(p.T,{weight:"semibold",children:"Weekly sales reports"}),u.length?u.slice(0,8).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:6,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,$.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,$.jsxs)(p.T,{weight:"semibold",children:["w/c ",M(e.weekStart)]}),(0,$.jsx)(p.T,{colour:y.colours.goldLight,children:P('number'==typeof e.vals.net?e.vals.net:null)})]}),(0,$.jsx)(p.Muted,{children:i.salesFields.filter(e=>'net'!==e.key).map(t=>`${t.label} ${(0,x.isBlank)(e.vals[t.key])?'\u2014':'money'===t.kind?P(e.vals[t.key]):e.vals[t.key]}`).join(' \xb7 ')}),s?(0,$.jsx)(v.CashLockControls,{kind:"sales",item:e,label:`w/c ${M(e.weekStart)}`}):null]},e.id)):(0,$.jsx)(p.Muted,{children:"None yet."})]}),z?(0,$.jsx)(T.SpreadsheetImport,{rid:e,file:z,who:a,locked:e=>D('cashup',e),onClose:()=>F(null),onSaved:e=>{j(e),F(null)}}):null,m?(0,$.jsx)(L,{draft:m,fields:'cashup'===m.kind?i.cashFields:i.salesFields,onClose:()=>k(null),onConfirm:async(s,o)=>{if(!m)return;if(D(m.kind,m.key))return j((0,v.lockedMessage)(m.kind,m.key)),void k(null);const l=m.uploaded&&m.uploaded.length===m.photos.length?m.uploaded:await Promise.all(m.photos.map((e,t)=>(0,w.uploadPhoto)(m.kind,m.key,e,t))),r=m.photos.map((e,t)=>l[t]??e),i=(new Date).toISOString();if('cashup'===m.kind){const o=d.find(e=>e.date===m.key),l=m.only&&o?{...o.vals,...s}:s,h=m.keynull==e)&&m.photos.length&&j(e=>`${e??''} The photo is kept on this device only (not signed in or offline).`),k(null)},keyLabel:'cashup'===m.kind?'Day':'Week starting',keyChoices:'cashup'===m.kind?N:E,onKey:e=>k({...m,key:e})},`${m.kind}-${m.photos.length}`):null]})}function O({today:e,has:t,paid:a,onOpen:o}){const[n,r]=(0,l.useState)((0,x.addDaysYmd)(e,-1)),[i,d]=(0,l.useState)((0,I.ukHistoryDate)((0,x.addDaysYmd)(e,-1))),[h,u]=(0,l.useState)(!1),f=(0,I.parseHistoryInput)(i)??'',m=(0,S.backdateProblem)(f,e),k=m?n:f,b=!m&&t(k),j=m?null:a(k),w=e=>{r(e),d((0,I.ukHistoryDate)(e))};return(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"cashup-backdate",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,$.jsx)(p.T,{center:!0,size:20,weight:"bold",colour:y.colours.gold,accessibilityRole:"header",children:"Cash up for another day"}),(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.text,children:"Missed a night? Enter or correct takings and tips for any past day. It counts on that day everywhere."}),(0,$.jsx)(c.default,{style:{width:'100%',maxWidth:360},children:(0,$.jsx)(p.Field,{label:"Day (DD/MM/YYYY)",value:i,onChangeText:e=>d((0,s.slashDate)(e,i)),placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"cashup-backdate-date",style:{textAlign:'center'},accessibilityLabel:"Day of the cash up, as day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1})}),m?(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.amber,testID:"cashup-backdate-problem",children:m}):(0,$.jsx)(c.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cashup-backdate-status",children:(0,$.jsx)(p.T,{center:!0,size:15,colour:y.colours.goldLight,children:b?`There is already a cash up for ${M(k)}: it opens for editing.`:`No cash up yet for ${M(k)}.`})}),j?(0,$.jsx)(c.default,{testID:"cashup-backdate-paid",style:{borderWidth:1,borderColor:y.colours.amber,borderRadius:10,padding:10,maxWidth:520},children:(0,$.jsxs)(p.T,{center:!0,size:14,colour:y.colours.amber,children:["Tips up to ",M(j.throughDate)," were already paid out. Tips you add for this day won\u2019t be in the pot automatically: add a correction in the Tips pot if they should still be shared."]})}):null,(0,$.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:[(0,$.jsx)(p.Button,{kind:"secondary",label:"Pick a date",testID:"cashup-backdate-pick",accessibilityLabel:`Pick a day from a calendar. Now ${m?'no valid day':M(k)}`,onPress:()=>u(!0),style:{minHeight:56}}),(0,$.jsx)(p.Button,{label:m?'Open cash up':b?`Edit cash up for ${M(k)}`:`Add cash up for ${M(k)}`,testID:"cashup-backdate-open",disabled:!!m,accessibilityLabel:m?'Open cash up, enter a valid past day first':`${b?'Edit':'Add'} the cash up for ${M(k)}`,onPress:()=>{w(k),o(k)},style:{minHeight:56}})]}),(0,$.jsxs)(p.Muted,{center:!0,children:["Saved with your name and the time, e.g. \u201cAdded later by you, ",M(e),"\u201d. Nothing is sent to anyone."]})]}),(0,$.jsx)(D.LookBackCalendar,{visible:h,today:e,selected:m?n:k,purpose:"Cash up for another day",idPrefix:"cashup-backdate",onClose:()=>u(!1),onPick:e=>{w(e),u(!1)}})]})}function Y({n:e,testID:t}){const s=Math.max(1,Math.min(14,e));return(0,$.jsx)(c.default,{testID:t,style:{width:64,height:114,justifyContent:'flex-end'},children:Array.from({length:s}).map((e,t)=>(0,$.jsx)(H,{delay:50*t},t))})}function H({delay:e}){const t=(0,l.useRef)(new r.default.Value(1)).current;return(0,l.useEffect)(()=>{r.default.timing(t,{toValue:0,duration:420,delay:e,easing:i.default.out(i.default.back(1.6)),useNativeDriver:!1}).start()},[]),(0,$.jsx)(r.default.View,{style:{height:7,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[0,-120]})}],opacity:t.interpolate({inputRange:[0,1],outputRange:[1,0]})},children:(0,$.jsx)(c.default,{style:{width:60,height:12,borderRadius:30,backgroundColor:y.colours.gold,borderWidth:1,borderColor:y.colours.goldLight}})})}function G(e){const[t,s]=(0,l.useState)(e),a=(0,l.useRef)(e);return(0,l.useEffect)(()=>{const t=a.current,o=e;if(t===o)return;const l=Date.now(),n=setInterval(()=>{const e=Math.min(1,(Date.now()-l)/1200);s(Math.round(100*(t+(o-t)*(1-Math.pow(1-e,3))))/100),e>=1&&(clearInterval(n),a.current=o)},40);return()=>clearInterval(n)},[e]),t}function V({rid:e,today:t,manage:s,who:a,big:o}){const n=(0,f.useTipsShow)(e),r=(0,f.useCashUp)(e=>e.tips).filter(t=>t.rid===e),i=(0,f.useCashUp)(e=>e.pot).filter(t=>t.rid===e),d=(0,b.useVenuePay)(e).pay,h=(0,k.tipsPeriod)(d,t),u=(0,l.useMemo)(()=>(0,x.tipsPot)(r,i,h.start,t),[r,i,h.start,t]),m=G(u.total),[j,w]=(0,l.useState)(null);return n.showPot||s?(0,$.jsxs)(p.Card,{highlight:y.colours.gold,children:[(0,$.jsxs)(c.default,{testID:"tips-pot",style:{flexDirection:'row',alignItems:'center',gap:14},children:[(0,$.jsx)(Y,{n:Math.ceil(u.total/100),testID:"tips-pot-coins"},u.total),(0,$.jsxs)(c.default,{style:{flex:1,gap:2},children:[(0,$.jsx)(p.T,{size:12,weight:"semibold",colour:y.colours.gold,style:{letterSpacing:1.5},children:"TIPS POT"}),(0,$.jsx)(p.T,{size:o?40:32,weight:"bold",colour:y.colours.goldLight,children:P(m)}),(0,$.jsxs)(p.Muted,{children:["Tips held for the team since ",M(u.from),h.payday?` \xb7 next tip payday ${M(h.payday)}`:'',". Confirmed cash ups only.",n.showPot?'':' (Hidden from staff.)']})]})]}),s?(0,$.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,$.jsx)(p.Button,{small:!0,kind:"secondary",testID:"pot-payout",label:"Mark payout done",onPress:()=>w('payout')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-correct",label:"Correct an entry",onPress:()=>w('correct')}),(0,$.jsx)(p.Button,{small:!0,kind:"ghost",testID:"pot-history",label:"Past pots",onPress:()=>w('history')})]}):null,'payout'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Mark payout done",maxWidth:520,testID:"pot-payout-sheet",children:[(0,$.jsxs)(p.T,{children:["Pay out ",P(u.total)," (tips from ",M(u.from)," to ",M(t),")?"]}),(0,$.jsx)(p.Muted,{children:"The pot goes back to \xa30.00 for the next period. This is logged and kept in Past pots. No money is moved by the app."}),(0,$.jsx)(p.Button,{testID:"pot-payout-confirm",label:"Yes, payout done",onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'payout',throughDate:t,amount:u.total,by:a?.name??'Manager'}),w(null)}})]}):null,'correct'===j?(0,$.jsx)(_,{rid:e,today:t,who:a,onClose:()=>w(null)}):null,'history'===j?(0,$.jsxs)(p.Sheet,{visible:!0,onClose:()=>w(null),title:"Past pots and corrections",maxWidth:560,testID:"pot-history-sheet",children:[u.history.length||i.some(e=>'correction'===e.kind)?null:(0,$.jsx)(p.Muted,{children:"No payouts or corrections yet."}),i.slice().sort((e,t)=>t.at.localeCompare(e.at)).map(e=>(0,$.jsxs)(c.default,{style:{paddingVertical:4},children:[(0,$.jsx)(p.T,{weight:"semibold",children:'payout'===e.kind?`Paid out ${P(e.amount)}`:`Correction ${e.amount>=0?'+':'\u2212'}${P(Math.abs(e.amount))} for ${M(e.forDate)}`}),(0,$.jsxs)(p.Muted,{children:['payout'===e.kind?`Tips to ${M(e.throughDate)}`:`\u201c${e.reason}\u201d`," \xb7 ",e.by," \xb7 ",new Date(e.at).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})]})]},e.id))]}):null]}):null}function _({rid:e,today:s,who:a,onClose:n}){const[r,i]=(0,l.useState)(s),[d,h]=(0,l.useState)(''),[c,u]=(0,l.useState)(''),m=(0,x.parseAmount)(d),k={minHeight:42,borderRadius:10,borderWidth:1,borderColor:'rgba(255,255,255,0.15)',backgroundColor:(0,t.soutersSurface)('#141312'),color:y.colours.text,paddingHorizontal:10,fontSize:16};return(0,$.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Correct an entry",maxWidth:520,testID:"pot-correct-sheet",children:[(0,$.jsx)(p.Muted,{children:"Tip: add or take off an amount for a day (use a minus for less, e.g. -5). Every correction is logged with your name and the reason."}),(0,$.jsx)(p.Row,{wrap:!0,gap:6,children:[0,1,2,3].map(e=>{const t=(0,x.addDaysYmd)(s,-e);return(0,$.jsx)(p.Chip,{label:0===e?'Today':M(t),selected:r===t,onPress:()=>i(t)},t)})}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-amount",value:d,onChangeText:h,placeholder:"\xa3 e.g. -5.00",placeholderTextColor:"#777",keyboardType:"numbers-and-punctuation",style:k}),(0,$.jsx)(o.TextInput,{testID:"pot-correct-reason",value:c,onChangeText:u,placeholder:"Reason (required)",placeholderTextColor:"#777",maxLength:200,style:k}),(0,$.jsx)(p.Button,{testID:"pot-correct-save",label:"Save correction",disabled:null==m||0===m||!c.trim(),onPress:()=>{f.useCashUp.getState().addPotEvent({rid:e,kind:'correction',forDate:r,amount:m,reason:c.trim(),by:a?.name??'Manager'}),n()}})]})}function K(e,t,s,a){if(!Number.isFinite(s))return;const o=`${e}:${t}`;f.useCashUp.getState().seen[o]!==s&&(f.useCashUp.getState().markSeen(o,s),(0,j.notify)({id:`tips-${o}`,icon:'\ud83e\ude99',kicker:'TIPS',title:`${t===a?'Today\u2019s':'Last night\u2019s'} tips: ${P(s)}`,body:'Cash + card tips for the whole team. Added to the Tips pot. Thank you, everyone.',testID:'tips-notice',timeoutMs:12e3,actions:[{label:'Nice',testID:'tips-notice-ok',onPress:()=>{}}]}))}function Z(e,t,s){return e.filter(e=>e.rid===t&&e.date>=(0,x.addDaysYmd)(s,-1)&&e.date<=s).sort((e,t)=>t.date.localeCompare(e.date))[0]}},1062,[828,1063,796,827,34,281,283,364,336,402,102,426,794,821,1039,831,13,1064,1065,1001,1075,1080,1081,1084,1085,1086,1093,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DATE_FORMAT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"slashDay",{enumerable:!0,get:function(){return n}}),e.slashDate=s,e.dayFromSlash=c,e.slashBox=function(t,l){const i=n(t??'');return{value:i,onChangeText:t=>{const n=s(t,i);l(''===n?'':c(n)??n)}}};const t='DD/MM/YYYY',n=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t??'');return n?`${n[3]}/${n[2]}/${n[1]}`:t??''};function s(t,n=""){const s=(t??'').length<(n??'').length,c=/^\s*(\d{4})[\s/.-](\d{1,2})[\s/.-](\d{1,2})\s*$/.exec(t??'');if(c)return`${c[3].padStart(2,'0')}/${c[2].padStart(2,'0')}/${c[1]}`;let l=(t??'').trim().replace(/[\s.\-\\]+/g,'/').replace(/[^\d/]/g,'').replace(/\/{2,}/g,'/').replace(/^\//,'');if(!l.includes('/')){const t=l.slice(0,8);return t.length<2||s&&2===t.length?t:(l=t.slice(0,2)+'/'+t.slice(2,4)+(t.length>4||4===t.length&&!s?'/'+t.slice(4):''),l)}const i=l.split('/');2===i.length&&i[1].length>2&&i.splice(1,1,i[1].slice(0,2),i[1].slice(2));const o=i.slice(0,3).map((t,n)=>t.slice(0,2===n?4:2));let u=o.join('/');return!s&&o.length<3&&2===o[o.length-1].length&&(u+='/'),u}function c(t){const n=/^\s*(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})\s*$/.exec(t??'');if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,c=new Date(s+'T12:00:00Z');return Number.isNaN(c.getTime())||c.toISOString().slice(0,10)!==s?void 0:s}},1063,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FALLBACK_PAY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"ymdOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"dateOf",{enumerable:!0,get:function(){return a}}),Object.defineProperty(_e,"plusDays",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"daysBetween",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"isValidYmd",{enumerable:!0,get:function(){return y}}),_e.cleanPay=function(t){const n={...e,...t??{}};return{tipsFrequency:['weekly','fortnightly','monthly'].includes(n.tipsFrequency)?n.tipsFrequency:'fortnightly',tipsAnchorPayday:y(String(n.tipsAnchorPayday))?n.tipsAnchorPayday:e.tipsAnchorPayday,tipsEndsDaysBefore:Math.max(0,Math.min(13,Math.round(Number(n.tipsEndsDaysBefore)||0))),wagePayDay:Math.max(1,Math.min(31,Math.round(Number(n.wagePayDay)||28))),wageCutoffDay:Math.max(1,Math.min(28,Math.round(Number(n.wageCutoffDay)||1))),weekendRule:'before'===n.weekendRule||'after'===n.weekendRule?n.weekendRule:'none'}},_e.adjustWeekend=s,_e.wagePeriod=f,_e.tipsPeriod=m,_e.nextToPay=function(e,t,n){for(let a=-2;a<=2;a++){const u='wage'===t?f(e,n,a):m(e,n,a);if((u.payday??u.end)>=n)return{period:u,offset:a}}return{period:'wage'===t?f(e,n,0):m(e,n,0),offset:0}},_e.customPeriod=function(e,t){return{kind:'custom',start:e,end:t,key:`c-${e}-${t}`}},Object.defineProperty(_e,"ukDate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"dayMonth",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"dm",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"rangeText",{enumerable:!0,get:function(){return $}}),_e.parseUk=function(e){const n=e.trim();if(y(n))return n;const a=/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})$/.exec(n);if(!a)return null;const u=`${2===a[3].length?2e3+Number(a[3]):Number(a[3])}-${t(Number(a[2]))}-${t(Number(a[1]))}`;return y(u)?u:null},Object.defineProperty(_e,"decH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"hMm",{enumerable:!0,get:function(){return F}});const e={tipsFrequency:'weekly',tipsAnchorPayday:'2026-01-05',tipsEndsDaysBefore:1,wagePayDay:31,wageCutoffDay:1,weekendRule:'none'},t=e=>String(e).padStart(2,'0'),n=e=>`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}`,a=e=>{const[t,n,a]=e.split('-').map(Number);return new Date(t,n-1,a,12)},u=(e,t)=>{const u=a(e);return u.setDate(u.getDate()+t),n(u)},o=(e,t)=>Math.round((a(t).getTime()-a(e).getTime())/864e5),i=(e,t)=>new Date(e,t+1,0).getDate(),c=(e,t,a)=>{const u=new Date(e,t,1,12),o=u.getFullYear(),c=u.getMonth();return n(new Date(o,c,Math.min(a,i(o,c)),12))},y=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&n(a(e))===e;function s(e,t="none"){if('none'===t)return e;const n=a(e).getDay();return 6===n?u(e,'before'===t?-1:2):0===n?u(e,'before'===t?-2:1):e}function d(e,t,n){const o=c(t,n,e.wageCutoffDay),i=u(c(t,n+1,e.wageCutoffDay),-1),y=a(i);let d=c(y.getFullYear(),y.getMonth(),e.wagePayDay);return dn.end))break;a++}}return a}function m(e,t,n=0){return p(e,h(e,t)+n)}const b=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],D=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],w=e=>{const[t,n,a]=e.split('-');return`${a}/${n}/${t}`},P=e=>{const t=a(e);return`${b[t.getDay()]} ${t.getDate()} ${D[t.getMonth()]}`},M=e=>{const t=a(e);return`${t.getDate()} ${D[t.getMonth()]}`},$=(e,t,n=" to ")=>e.slice(0,4)===t.slice(0,4)?`${M(e)}${n}${M(t)}`:`${M(e)} ${e.slice(0,4)}${n}${M(t)} ${t.slice(0,4)}`;const k=e=>(Math.round(e/60*100)/100).toFixed(2),F=e=>`${Math.floor(e/60)}:${t(Math.round(e)%60)}`},1064,[]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.payFor=u,_e.useVenuePay=function(s){const r=(0,n.useRestaurant)(s),o=(0,t.useOnboard)(e=>e.answers);return(0,e.useMemo)(()=>u(s,r?.settings.pay,o),[s,r?.settings.pay,o])},_e.venueRange=function(e,n,t,s){const u='wage'===n?(0,r.wagePeriod)(e,(0,r.ymdOf)(s),t):(0,r.tipsPeriod)(e,(0,r.ymdOf)(s),t),o=(0,r.dateOf)(u.start);o.setHours(0,0,0,0);const y=(0,r.dateOf)(u.end);return y.setHours(0,0,0,0),{s:o,e:y,key:u.key,payday:u.payday}};var e=_r(d[0]),n=_r(d[1]),t=_r(d[2]),s=_r(d[3]),r=_r(d[4]);function u(e,n,t){if(n)return{pay:(0,r.cleanPay)(n),source:'settings'};const u=t[e]?.pay??s.SEEDED_ANSWERS[e]?.pay;return u?{pay:(0,r.cleanPay)(u),source:'questionnaire'}:{pay:r.FALLBACK_PAY,source:'none'}}},1065,[34,876,1066,1067,1064]); +__d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useOnboard",{enumerable:!0,get:function(){return l}});var e,s=r(_d[0]),t=(e=s)&&e.__esModule?e:{default:e},p=r(_d[1]),u=r(_d[2]);const n=()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`},l=(0,p.create)()((0,u.persist)(e=>({setup:{},answers:{},goals:{},replay:null,markStep:(s,t,p)=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},steps:{...e.setup[s]?.steps??{},[t]:p}}}})),welcome:s=>e(e=>({setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:n()}}})),finish:s=>e(e=>({replay:null,setup:{...e.setup,[s]:{...e.setup[s]??{steps:{}},welcomed:e.setup[s]?.welcomed??n(),finished:n()}}})),restart:s=>e(e=>({setup:{...e.setup,[s]:{steps:{}}}})),setReplay:s=>e({replay:s}),saveAnswers:(s,t)=>e(e=>({answers:{...e.answers,[s]:t}})),setGoal:(s,t)=>e(e=>{const p={...e.goals};return t?p[s]=t:delete p[s],{goals:p}})}),{name:'covercharge-onboard-v1',version:1,storage:(0,u.createJSONStorage)(()=>t.default),partialize:e=>({setup:e.setup,answers:e.answers,goals:e.goals})}))},1066,[839,846,849]); +__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,"SEEDED_ANSWERS",{enumerable:!0,get:function(){return f}});var n=r(d[0]),t=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=e(r(d[5])),p=e(r(d[6])),h=r(d[7]),c=r(d[8]);const f={...Object.fromEntries(Object.entries(n.queuedVenues).map(([e,n])=>[e,(0,h.cleanQuestionnaire)(n.questionnaire,e)??{}])),greenside:(0,h.cleanQuestionnaire)(t.default,'greenside')??{},abbotsford:(0,h.cleanQuestionnaire)(l.default,'abbotsford')??{},kirkton:(0,h.cleanQuestionnaire)(o.default,'kirkton')??{},wildings:(0,h.cleanQuestionnaire)(s.default,'wildings')??{},kirkmichael:(0,h.cleanQuestionnaire)(u.default,'kirkmichael')??{},souters:(0,h.cleanQuestionnaire)(p.default,'souters')??{},anchorage:{source:'from-config',submittedAt:'2026-10-01',onboardedAt:'2026-10-01',pay:c.ANCHORAGE_PAY},saltmarsh:{source:'signup-form',submittedAt:'2026-10-27',venue:{name:'The Venue',tagline:'Seasonal small plates by the harbour (fictional)',address:'4 Quay Street, Port Ailsa (fictional)',phone:'01632 960 418',email:'hello@thevenue.example',website:'thevenue.example'},tables:{template:'bistro',tables:14,covers:48,areas:['Inside','Terrace']},team:[{name:'Morven Reid (example)',role:'owner',job:'Owner',email:'morven@thevenue.example'},{name:'Callum Shaw (example)',role:'manager',job:'General manager',email:'callum@thevenue.example'},{name:'Isla Grant (example)',role:'staff',job:'Head chef'},{name:'Ruaridh Bell (example)',role:'staff',job:'Waiter',phone:'07700 900 311'},{name:'Ellie Muir (example)',role:'staff',job:'Waiter'}],suppliers:[{name:'Ailsa Fish Co (example)',category:'Fish',phone:'01632 960 101'},{name:'Hillside Dairy (example)',category:'Dairy',email:'orders@hillside.example'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-06',tipsEndsDaysBefore:5,wagePayDay:28,wageCutoffDay:20,weekendRule:'before'},accounts:[{provider:'gmail',handle:'hello@thevenue.example'},{provider:'wix',handle:'thevenue.example'},{provider:'instagram',handle:'@thevenue.demo'},{provider:'facebook',handle:'The Venue'},{provider:'google-business',handle:'The Venue'},{provider:'sumup',handle:'The Venue'},{provider:'xero',handle:'The Venue Ltd'}],features:{bookings:!0,takeaway:!0,orderAtTable:!0,tips:!0,rota:!0,games:!1,specials:!0},notes:'Fictional example answers for the demo venue.'}}},1067,[6,1068,1069,1070,1071,1072,1073,1074,3]); +__d(function(e,a,n,s,o,r,t){o.exports={version:1,venueId:"greenside",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Greenside Restaurant",tagline:"Restaurant \u2022 Wood Fired Pizza \u2022 Maybole",address:"5 Greenside, Maybole, South Ayrshire KA19 7DG",phone:"01655 889685",email:"info@thegreensiderestaurant.co.uk",website:"https://thegreensiderestaurant.co.uk/",hasLogo:!0,emailNeedsConfirmation:!0},hours:{days:{0:["10:00","00:00"],1:null,2:null,3:["10:00","23:00"],4:["10:00","23:00"],5:["10:00","00:00"],6:["10:00","00:00"]},note:"Closed Monday and Tuesday. Venue Wednesday and Thursday 10:00\u201323:00, Friday to Sunday 10:00\u201300:00. Kitchen Wednesday, Thursday and Sunday 10:00\u201320:00; Friday and Saturday 10:00\u201321:00. Cash only."},tables:{template:"restaurant",tables:null,covers:null,areas:["Restaurant","Beer garden"],needsConfirmation:!0,note:"Historical figure about 50 covers inside and about 48 in seasonal beer garden (former GM LinkedIn). Names, tables and covers need Gordon's confirmation. Bar and restaurant only \u2014 no accommodation."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate greenside tenant. No staff, invites or table plan yet. Cash only; no card payments or deposits. CoverCharge manager-confirmed table requests only, with Call01655 889685 as backup. Menu, allergens, public email, pay settings and deposit policy need confirmation. No external booking or ordering links."}},1068,[]); +__d(function(e,o,a,t,r,n,s){r.exports={version:1,venueId:"abbotsford",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Abbotsford Hotel",tagline:"Get Hungry. Get Curious.",address:"14 Corsehill Road, Ayr KA7 2ST",phone:"01292 261506",email:"info@abbotsfordhotel.co.uk",website:"https://www.abbotsfordhotel.co.uk/",hasLogo:!0},hours:{days:{0:["10:00","20:30"],1:["10:00","20:30"],2:["10:00","20:30"],3:["10:00","20:30"],4:["10:00","20:30"],5:["10:00","20:30"],6:["10:00","20:30"]},note:"Daily 10:00\u201320:30 \u2014 to confirm with the hotel. Copper Bar hours to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Rowan seats up to 120 (published). Restaurant and bar covers/tables unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"TheAbbotsfordHotel"},{provider:"instagram",handle:"@abbotsfordhotelayr"},{provider:"tiktok",handle:"@the.abbotsford.hotel.ayr"}],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate abbotsford tenant. Epicurious restaurant and The Copper Bar. CoverCharge dining and room requests require manager confirmation. No external booking links, no room inventory module or external booking integrations. Zero staff/invites/sample data. Deposit, manager, team, table plan/covers, Copper Bar hours, dog policy and allergens to confirm."}},1069,[]); +__d(function(e,n,t,a,o,r,i){o.exports={version:1,venueId:"kirkton",source:"from-config",submittedAt:"2026-11-06",venue:{name:"The Kirkton Inn",tagline:"Bar and restaurant in Dalrymple, Ayrshire \u2014 Burns country hospitality",address:"1-3 Main Street, Dalrymple, East Ayrshire KA6 6DF",phone:"",email:"",website:"",hasLogo:!0},hours:{days:{0:null,1:null,2:null,3:null,4:null,5:null,6:null},note:"Current opening and kitchen hours to confirm. No service times set."},tables:{template:"restaurant",tables:null,covers:null,areas:[],needsConfirmation:!0,note:"Table plan and capacity to confirm."},team:[],suppliers:[],accounts:[],features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate kirkton tenant. No staff or personal links. Room inventory and current letting to confirm; room functionality deferred. No external booking integrations. Phone, public email, website, current hours, capacity, table plan, takeaway, pay and deposit policy to confirm. Archived 2019 menus are provisional and not saleable stock."}},1070,[]); +__d(function(e,n,a,o,s,t,i){s.exports={version:1,venueId:"wildings",source:"from-config",submittedAt:"2026-11-05",venue:{name:"Wildings Hotel & Restaurant",tagline:"Coastal cuisine with character",address:"Maidens Road, Maidens, KA26 9NR",phone:"01655 331 401",email:"bookings@wildingsrestaurant-hotel.co.uk",website:"https://www.wildingshotel.com/",hasLogo:!0},hours:{days:{0:["12:00","21:00"],1:["12:00","21:00"],2:["12:00","21:00"],3:["12:00","21:00"],4:["12:00","21:00"],5:["12:00","21:00"],6:["12:00","21:00"]},note:"Lunch Mon\u2013Sat 12:00\u201314:00, Sun 12:00\u201314:30; dinner daily 18:00\u201321:00 (closed 14:00\u201318:00). Bar hours not published. Sunday lunch end time to confirm."},tables:{template:"restaurant",tables:null,covers:null,areas:["Dining room 1","Dining room 2"],needsConfirmation:!0,note:"Two dining rooms per website; names, tables and covers unknown."},team:[],suppliers:[],accounts:[{provider:"facebook",handle:"profile.php?id=100057663900963"},{provider:"instagram",handle:"@wildingsmaidens"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Separate tenant, venue id wildings. Accent #FFE3A5 (logo star gold) on ink #272A2F. No demo/local roster. Authorised real team is loaded from this venue\u2019s server; remaining staff list and personal manager contacts are to confirm. Deposit off until confirmed. Bookings are by phone/email today; site is Duda, so no Wix sync. Pay settings are app defaults, to confirm. Never blend with other venues' data.",onboardedAt:"2026-11-05"}},1071,[]); +__d(function(e,a,i,n,r,o,s){r.exports={version:1,venueId:"kirkmichael",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"The Kirkmichael Arms",tagline:"Michelin-listed restaurant and bar in Kirkmichael, Ayrshire",address:"3-5 Straiton Road, Kirkmichael, South Ayrshire KA19 7PH",phone:"01655 750 200",email:"enquiries@thekirkmichaelarms.co.uk",website:"https://www.kirkmichaelarms.co.uk/",hasLogo:!0},hours:{days:{0:["13:00","22:30"],1:null,2:null,3:null,4:["13:00","22:30"],5:["13:00","22:30"],6:["13:00","22:30"]},note:"Thu\u2013Sun from 1pm; schema close 22:30. Michelin lists Sunday from 12:30 \u2014 confirm. Closed Mon\u2013Wed."},tables:{template:"restaurant",tables:null,covers:56,areas:["Restaurant","Bar","Private dining (The Room)"],needsConfirmation:!0,note:"56 covers from historical sale listing; private dining about 18. Table count unknown \u2014 ask Gordon/Justin."},team:[{name:"Justin Galea",role:"owner",job:"Chef & Owner",email:"enquiries@thekirkmichaelarms.co.uk",phone:"01655 750 200"}],suppliers:[],accounts:[{provider:"instagram",handle:"@kirkmichaelarms_unfiltered"},{provider:"facebook",handle:"kirkmichaelarms"},{provider:"gmail",handle:"enquiries@thekirkmichaelarms.co.uk"},{provider:"tripadvisor",handle:"The Kirkmichael Arms"},{provider:"google-business",handle:"The Kirkmichael Arms"}],pay:{tipsFrequency:"fortnightly",tipsAnchorPayday:"2026-11-07",tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:"none"},features:{bookings:!0,takeaway:!1,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Seed as venue_id kirkmichael (separate tenant). Chef-owner Justin Galea. Brand accent #B87754 (whisky amber); lion emblem + wordmark in branding/. Deposit amount unknown \u2014 leave off until Gordon confirms. Bookings currently via own site /booking (own website booking page noted in research only). Menu from live Sample menus 2026-11-05; specials board changes often. Never blend with other venues' data."}},1072,[]); +__d(function(e,o,r,s,a,t,n){a.exports={version:1,venueId:"souters",source:"from-config",submittedAt:"2026-11-05",onboardedAt:"2026-11-05",venue:{name:"Souter's Inn",tagline:"Culinary excellence meets country hospitality in Kirkoswald",address:"47 Main Road, Kirkoswald, South Ayrshire KA19 8HY",phone:"01655 760653",email:"souters@southernayr.com",website:"https://www.soutersinn.com/",hasLogo:!0},hours:{days:{0:["09:00","21:00"],1:["09:00","21:00"],2:["09:00","21:00"],3:["09:00","21:00"],4:["09:00","21:00"],5:["09:00","21:00"],6:["09:00","21:00"]},note:"Open daily 9am\u20139pm. Breakfast 9\u201311.45am; main food service from noon. Confirm last orders with the venue."},tables:{template:"restaurant",tables:0,covers:130,areas:[]},team:[],suppliers:[{name:"Pollok Williamson Butchers",category:"Meat",phone:"",email:""}],accounts:[{provider:"instagram",handle:"@soutersinn"},{provider:"facebook",handle:"Souter's Inn"},{provider:"gmail",handle:"souters@southernayr.com"},{provider:"tripadvisor",handle:"Souter's Inn Kirkoswald"},{provider:"google-business",handle:"Souter's Inn"}],features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0},notes:"Part of Southern Ayr Limited (Brian Daly). Sister venues: Abbotsford Hotel, The Brig, Bridges Bar, Wellingtons. Bookings: guests request a table in CoverCharge. Deposit default suggested \xa310pp from party of 6 \u2014 confirm with venue (published \xa310pp for some events). Regional Scottish Thistle Award Best Eating Experience 2026. Brand accent from official logo SVG fill #A4622E. Real table plan, manager contact, team, priced menu and deposit confirmation still required; no tables or staff seeded."}},1073,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STEP_IDS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"STEP_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"TEMPLATE_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"DAY_NAMES",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"WEEK_ORDER",{enumerable:!0,get:function(){return l}}),e.cleanQuestionnaire=function(t,s){if(!t||'object'!=typeof t)return null;const o=t,n=o.venue??{},l=u(n.name,80);if(!l)return null;const y={};for(let a=0;a<7;a++){const t=o.hours?.days?.[a],s=Array.isArray(t)?p(t[0]):null,n=Array.isArray(t)?p(t[1]):null;y[a]=s&&n?[s,n]:null}const b=['cafe','bistro','restaurant','custom'].includes(o.tables?.template)?o.tables.template:'custom',f=(a,t)=>'number'==typeof a&&a>=0&&a<=t?Math.round(a):void 0,h=o.features??{};return{version:1,venueId:u(s??o.venueId,60)||'venue',source:'signup-form'===o.source||'from-config'===o.source?o.source:'imported',submittedAt:u(o.submittedAt,10),onboardedAt:u(o.onboardedAt,10),venue:{name:l,tagline:u(n.tagline,120),address:u(n.address,200),phone:u(n.phone,30),email:u(n.email,120),website:u(n.website,120),hasLogo:!!n.hasLogo},hours:{days:y,note:u(o.hours?.note,300)},tables:{template:b,tables:f(o.tables?.tables,300),covers:f(o.tables?.covers,2e3),areas:Array.isArray(o.tables?.areas)?o.tables.areas.map(a=>u(a,40)).filter(Boolean).slice(0,12):void 0},team:Array.isArray(o.team)?o.team.map(a=>({name:u(a?.name,60)??'',role:d.includes(a?.role)?a.role:'staff',job:u(a?.job,60),email:u(a?.email,120),phone:u(a?.phone,30)})).filter(a=>a.name).slice(0,200):[],suppliers:Array.isArray(o.suppliers)?o.suppliers.map(a=>({name:u(a?.name,80)??'',category:u(a?.category,40),phone:u(a?.phone,30),email:u(a?.email,120)})).filter(a=>a.name).slice(0,100):[],pay:o.pay&&'object'==typeof o.pay?(0,a.cleanPay)(o.pay):void 0,accounts:Array.isArray(o.accounts)?o.accounts.map(a=>({provider:u(a?.provider,40)??'',handle:u(a?.handle,120)})).filter(a=>/^[a-z0-9-]+$/.test(a.provider)).slice(0,40):void 0,features:{bookings:c(h.bookings,!0),takeaway:c(h.takeaway,!0),orderAtTable:c(h.orderAtTable,!1),tips:c(h.tips,!0),rota:c(h.rota,!0),games:c(h.games,!0),specials:c(h.specials,!0)},notes:u(o.notes,1e3),...Array.isArray(o.cashUp)?{cashUp:o.cashUp.map(a=>u(a,40)).filter(a=>!!a).slice(0,12)}:{}}},e.questionnaireFromFacts=function(a,t){const s=a.tables??0,o=0===s?'custom':s<=9?'cafe':s<=16?'bistro':'restaurant';return{version:1,venueId:a.id,source:'from-config',venue:{name:a.name,tagline:a.tagline,address:a.address,phone:a.phone,email:a.email,website:a.website,hasLogo:a.hasLogo},hours:{days:{...a.hours},note:a.hoursNote},tables:{template:a.tables?'custom':o,tables:a.tables,covers:a.covers,areas:a.areas},team:a.team,suppliers:a.suppliers,pay:a.pay,features:{bookings:!0,takeaway:!1!==a.takeaway,orderAtTable:!!a.orderAtTable,tips:!0,rota:!0,games:!1!==a.games,specials:!0},...a.cashUp?.length?{cashUp:a.cashUp.slice(0,12)}:{},...t}},e.mergeQuestionnaire=function(a,t){if(!t)return a;const s={},o=Object.values(t.hours?.days??{}).some(Boolean);for(let n=0;n<7;n++)s[n]=o?t.hours.days[n]??null:a.hours.days[n]??null;return{...a,...t,venue:{...a.venue,...Object.fromEntries(Object.entries(t.venue).filter(([,a])=>void 0!==a&&''!==a))},hours:{days:s,note:t.hours?.note??a.hours.note},tables:{...a.tables,...Object.fromEntries(Object.entries(t.tables).filter(([,a])=>void 0!==a))},team:t.team.length?t.team:a.team,suppliers:t.suppliers.length?t.suppliers:a.suppliers,pay:t.pay??a.pay,accounts:t.accounts?.length?t.accounts:a.accounts,features:{...a.features,...t.features},cashUp:t.cashUp?.length?t.cashUp:a.cashUp}},e.hoursLines=function(a){return l.map(t=>({day:n[t],text:a[t]?`${a[t][0]} to ${a[t][1]}`:'Closed'}))},Object.defineProperty(e,"EXAMPLE_QUESTIONNAIRE",{enumerable:!0,get:function(){return y}});var a=r(_d[0]);const t=['venue','hours','tables','team','suppliers','accounts','pay','features'],s={venue:'Your venue',hours:'Opening hours',tables:'Table plan',team:'Your team',suppliers:'Suppliers',accounts:'Connected accounts',pay:'Pay & tips',features:'Features'},o={cafe:'Small caf\xe9 (about 8 tables)',bistro:'Bistro (about 14 tables)',restaurant:'Restaurant (about 24 tables, 2 areas)',custom:'My own layout'},n=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],l=[1,2,3,4,5,6,0],u=(a,t=200)=>'string'==typeof a?a.trim().slice(0,t):void 0,c=(a,t)=>'boolean'==typeof a?a:t,p=a=>'string'==typeof a&&/^([01]\d|2[0-3]):[0-5]\d$/.test(a)?a:null,d=['owner','manager','staff'];const y={version:1,venueId:'example',source:'signup-form',submittedAt:'2026-10-20',venue:{name:'Example Harbour Caf\xe9',tagline:'Coffee, cakes and crab rolls',address:'1 Example Quay, Exampletown',phone:'01632 960000',email:'hello@example.com',website:'example.com',hasLogo:!1},hours:{days:{0:['10:00','16:00'],1:null,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']},note:'Shorter hours in winter'},tables:{template:'cafe',tables:8,covers:30,areas:['Inside','Terrace']},team:[{name:'Alex Example',role:'owner'},{name:'Sam Example',role:'manager',job:'Front of house manager'},{name:'Jo Example',role:'staff',job:'Barista'}],suppliers:[{name:'Example Dairy',category:'Dairy'},{name:'Example Fish Co',category:'Fish & seafood'}],pay:{tipsFrequency:'fortnightly',tipsAnchorPayday:'2026-11-02',tipsEndsDaysBefore:1,wagePayDay:28,wageCutoffDay:23,weekendRule:'none'},features:{bookings:!0,takeaway:!0,orderAtTable:!1,tips:!0,rota:!0,games:!0,specials:!0}}},1074,[1064]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pickPhotos=function(t={}){const a=t.source??'camera';return'undefined'==typeof document?n(a):new Promise(t=>{const n=document.createElement('input');n.type='file',n.accept='image/*',n.multiple=!0,'camera'===a&&n.setAttribute('capture','environment'),n.setAttribute('data-testid','camera'===a?'photo-input':'gallery-input'),n.style.display='none',n.onchange=async()=>{const a=Array.from(n.files??[]).slice(0,8),o=[];for(const t of a)try{o.push(await r(t))}catch{}n.remove(),t(o)},document.body.appendChild(n),n.click()})},e.shrink=r,e.uploadPhoto=async function(n,r,o,c){const i=a.useSync.getState();if('staff'!==i.kind||!i.venueId)return null;try{const a=await(await fetch(o)).blob(),s=`${i.venueId}/${n}/${r}-${Date.now()}-${c}.jpg`,{error:u}=await(0,t.getSupabase)().storage.from('cashup-photos').upload(s,a,{contentType:'image/jpeg',upsert:!1});return u?null:s}catch{return null}},e.photosAllowed=function(){const t=a.useSync.getState();return'staff'!==t.kind||!t.venueId||'off'===t.mode||'local'===t.mode||t.perms.includes('*')},e.photoUrl=async function(a){if(a.startsWith('data:'))return a;try{const{data:n}=await(0,t.getSupabase)().storage.from('cashup-photos').createSignedUrl(a,600);return n?.signedUrl??null}catch{return null}},_r(d[0]);var t=_r(d[1]),a=_r(d[2]);async function n(t){try{const a=_r(d[3],"expo-image-picker"),n={mediaTypes:['images'],quality:.7,base64:!0,allowsMultipleSelection:'gallery'===t,selectionLimit:8};if('camera'===t){if(!(await a.requestCameraPermissionsAsync()).granted)return[]}const r='camera'===t?await a.launchCameraAsync(n):await a.launchImageLibraryAsync(n);return r.canceled?[]:r.assets.filter(t=>t.base64).map(t=>`data:image/jpeg;base64,${t.base64}`)}catch{return[]}}function r(t,a=1600,n=.78){return new Promise((r,o)=>{const c=URL.createObjectURL(t),i=new Image;i.onload=()=>{const t=Math.min(1,a/Math.max(i.width,i.height)),o=document.createElement('canvas');o.width=Math.round(i.width*t),o.height=Math.round(i.height*t),o.getContext('2d').drawImage(i,0,0,o.width,o.height),URL.revokeObjectURL(c),r(o.toDataURL('image/jpeg',n))},i.onerror=()=>{URL.revokeObjectURL(c),o(new Error('not an image'))},i.src=c})}},1075,[236,933,987,1076]); +__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})},1076,[499,1077,1079,1078]); +__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 c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]);const o={images:'image/*',videos:'video/mp4,video/quicktime,video/x-m4v,video/*',livePhotos:''};var c={launchImageLibraryAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,base64:s}),launchCameraAsync:async({mediaTypes:t=['images'],allowsMultipleSelection:n=!1,base64:s=!1,cameraType:o})=>'undefined'==typeof window||'undefined'==typeof document?{canceled:!0,assets:null}:await u({mediaTypes:t,allowsMultipleSelection:n,capture:o??!0,base64:s}),getCameraPermissionsAsync:async()=>l(),requestCameraPermissionsAsync:async()=>l(),getMediaLibraryPermissionsAsync:async t=>l(),requestMediaLibraryPermissionsAsync:async t=>l()};function l(){return{status:t.PermissionStatus.GRANTED,expires:'never',granted:!0,canAskAgain:!0}}function u({mediaTypes:t,capture:o=!1,allowsMultipleSelection:c=!1,base64:l}){const u=w((0,s.parseMediaTypes)(t)),p=document.createElement('input');if(p.style.display='none',p.setAttribute('type','file'),p.setAttribute('accept',u),p.setAttribute('id',String(Math.random())),p.setAttribute('data-testid','file-input'),c&&p.setAttribute('multiple','multiple'),o)switch(o){case!0:p.setAttribute('capture','camera');break;case n.CameraType.front:p.setAttribute('capture','user');break;case n.CameraType.back:p.setAttribute('capture','environment')}return document.body.appendChild(p),new Promise(t=>{p.addEventListener('change',async()=>{if(p.files?.length){const n=c?p.files:[p.files[0]];try{const s=await Promise.all(Array.from(n).filter(t=>null!=t).map(t=>f(t,{base64:l})));t({canceled:!1,assets:s})}catch(n){t(Promise.reject(n))}}else t({canceled:!0,assets:null});document.body.removeChild(p)}),p.addEventListener('cancel',()=>{p.dispatchEvent(new Event('change'))});const n=new MouseEvent('click');p.dispatchEvent(n)})}async function p(t){return new Promise(n=>{const s=new Image;s.onload=()=>{n({width:s.naturalWidth??s.width,height:s.naturalHeight??s.height})},s.onerror=()=>n({width:0,height:0}),s.src=t})}async function y(t){return new Promise(n=>{const s=document.createElement('video');s.preload='metadata',s.onloadedmetadata=()=>{n({width:s.videoWidth,height:s.videoHeight,duration:s.duration})},s.onerror=()=>n({width:0,height:0,duration:0}),s.src=t})}async function h(t){return new Promise((n,s)=>{const o=new FileReader;o.onerror=()=>{s(new Error('Failed to read the selected media because the operation failed.'))},o.onload=t=>{const o=t.target?.result;'string'==typeof o?n(o.split(',')?.[1]??''):s(new Error('Failed to read file as base64'))},o.readAsDataURL(t)})}async function f(t,n){const s=t.type,o=URL.createObjectURL(t);let c,l;if(s.startsWith('image/'))c=await p(o);else{if(!s.startsWith('video/'))throw new Error(`Unsupported file type: ${s}. Only images and videos are supported.`);c=await y(o)}return n.base64&&(l=await h(t)),{uri:o,width:c.width,height:c.height,type:s.startsWith('image/')?'image':'video',mimeType:s,fileName:t.name,fileSize:t.size,file:t,...void 0!==c.duration&&{duration:c.duration},...l&&{base64:l}}}function w(t){const n=t.filter(t=>'livePhotos'!==t);if(0===n.length)return'image/*';let s='';for(const t of n)s.includes(o[t])||(s=s.concat(',',o[t]));return s}},1077,[499,1078,1079]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MediaTypeOptions",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"VideoExportPreset",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"UIImagePickerControllerQualityType",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UIImagePickerPresentationStyle",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"UIImagePickerPreferredAssetRepresentationMode",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"CameraType",{enumerable:!0,get:function(){return l}});let t=(function(t){return t.All="All",t.Videos="Videos",t.Images="Images",t})({}),n=(function(t){return t[t.Passthrough=0]="Passthrough",t[t.LowQuality=1]="LowQuality",t[t.MediumQuality=2]="MediumQuality",t[t.HighestQuality=3]="HighestQuality",t[t.H264_640x480=4]="H264_640x480",t[t.H264_960x540=5]="H264_960x540",t[t.H264_1280x720=6]="H264_1280x720",t[t.H264_1920x1080=7]="H264_1920x1080",t[t.H264_3840x2160=8]="H264_3840x2160",t[t.HEVC_1920x1080=9]="HEVC_1920x1080",t[t.HEVC_3840x2160=10]="HEVC_3840x2160",t})({}),u=(function(t){return t[t.High=0]="High",t[t.Medium=1]="Medium",t[t.Low=2]="Low",t[t.VGA640x480=3]="VGA640x480",t[t.IFrame1280x720=4]="IFrame1280x720",t[t.IFrame960x540=5]="IFrame960x540",t})({}),o=(function(t){return t.FULL_SCREEN="fullScreen",t.PAGE_SHEET="pageSheet",t.FORM_SHEET="formSheet",t.CURRENT_CONTEXT="currentContext",t.OVER_FULL_SCREEN="overFullScreen",t.OVER_CURRENT_CONTEXT="overCurrentContext",t.POPOVER="popover",t.AUTOMATIC="automatic",t})({}),c=(function(t){return t.Automatic="automatic",t.Compatible="compatible",t.Current="current",t})({}),l=(function(t){return t.back="back",t.front="front",t})({})},1078,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseMediaTypes=p,e.mapDeprecatedOptions=function(s){if(!s.mediaTypes)return s;return{...s,mediaTypes:p(s.mediaTypes??[])}};var s=r(d[0]);function p(p){const n={Images:['images'],Videos:['videos'],All:['images','videos']};return p===s.MediaTypeOptions.Images||p===s.MediaTypeOptions.Videos||p===s.MediaTypeOptions.All?(console.warn('[expo-image-picker] `ImagePicker.MediaTypeOptions` have been deprecated. Use `ImagePicker.MediaType` or an array of `ImagePicker.MediaType` instead.'),n[p]):'string'==typeof p?[p]:p}},1079,[1078]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readSheet=async function(l,u,c){const f=u.filter(t=>!t.startsWith('data:'));try{const u=n.useSync.getState();if('staff'!==u.kind||!u.venueId||!f.length)return{vals:o(c),reader:null,note:s};const{data:h,error:y}=await(0,t.getSupabase)().functions.invoke('cashup-read',{body:{kind:l,venueId:u.venueId,paths:f,fields:c.filter(t=>'text'!==t.kind).map(t=>({key:t.key,label:t.label,kind:t.kind}))}});if(y||!h||'object'!=typeof h||!h.vals)return{vals:o(c),reader:null,note:s};const p=o(c);for(const t of c){const n=h.vals[t.key];'number'==typeof n&&Number.isFinite(n)&&(p[t.key]=Math.round(100*n)/100)}const v=Object.values(p).filter(t=>null!=t).length;return v?{vals:p,categories:Array.isArray(h.categories)?h.categories:[],reader:String(h.reader??'photo reader'),note:`${v} figure${1===v?'':'s'} read from the photo. Check each one against the photo before you confirm.`}:{vals:p,reader:null,note:'The photo couldn\u2019t be read clearly, so type the figures from it.'}}catch{return{vals:o(c),reader:null,note:s}}};var t=r(d[0]),n=r(d[1]);const o=t=>Object.fromEntries(t.map(t=>[t.key,null])),s='Automatic reading isn\u2019t switched on yet, so type the figures from the photo. Nothing is filled in for you.'},1080,[933,987]); +__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.pickSpreadsheet=function(){return'undefined'==typeof document?Promise.resolve({error:'Upload a spreadsheet from the Managers app in a web browser.'}):new Promise(e=>{const s=document.createElement('input');s.type='file',s.accept='.csv,.xlsx,text/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',s.setAttribute('data-testid','sheet-input'),s.style.display='none',s.onchange=async()=>{const t=s.files?.[0];if(s.remove(),!t)return e(null);if(t.size>5242880)return e({error:'That file is over 5 MB. Export just the takings columns and try again.'});try{const s=/\.xlsx$/i.test(t.name)?await(0,c.readXlsx)(await t.arrayBuffer()):(0,r.parseCsv)(await t.text());e(s.length?{name:t.name,rows:s}:{error:'The file looks empty.'})}catch(s){e({error:s instanceof Error?s.message:'The file couldn\u2019t be read. Try saving it as CSV.'})}},document.body.appendChild(s),s.click()})},_e.SpreadsheetImport=function({rid:e,file:t,who:c,onClose:v,onSaved:w,locked:x}){const[y,$]=(0,s.useState)(!0),b=y?t.rows[0]:t.rows[0].map((e,s)=>`Column ${s+1}`),[j,k]=(0,s.useState)(()=>(0,r.guessMapping)(t.rows[0])),[C,T]=(0,s.useState)(!1),[D,S]=(0,s.useState)('map'),B=(0,n.useCashUp)(e=>e.cashUps),I=(0,s.useMemo)(()=>new Set(B.filter(s=>s.rid===e&&s.confirmedAt&&null!=(0,i.grossOf)(s.vals)).map(e=>e.date)),[B,e]),M=(0,s.useMemo)(()=>(0,r.buildPreview)(t.rows,j,y,I),[t.rows,j,y,I]),P=M.filter(e=>e.ok&&!(e.date&&x(e.date))),R=P.filter(e=>'saved'!==e.dup||C),z=P.filter(e=>'saved'===e.dup).length,L=M.filter(e=>!e.ok).length,U=M.filter(e=>e.ok&&e.date&&x(e.date)).length,E=null!=j.date&&null!=j.gross;return(0,u.jsxs)(l.Sheet,{visible:!0,onClose:v,title:"Upload a spreadsheet",maxWidth:1e3,testID:"sheet-import",children:[(0,u.jsx)(l.Muted,{children:`${t.name} \xb7 ${t.rows.length-(y?1:0)} row${t.rows.length-(y?1:0)==1?'':'s'}`}),'map'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-map",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"1. Which column is which?"}),(0,u.jsx)(l.Muted,{children:"Tip: Date and Gross takings are needed. Food, drink, card and cash are optional. Leave a column as \u201cNot in the file\u201d if you don\u2019t have it."}),(0,u.jsx)(l.Toggle,{testID:"sheet-header",label:"The first row is headings",value:y,onChange:$}),r.COLS.map(e=>(0,u.jsxs)(o.default,{style:{gap:4},testID:`sheet-col-${e.key}`,children:[(0,u.jsxs)(l.Row,{gap:6,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.label}),e.required?(0,u.jsx)(l.Badge,{kind:"gold",label:"NEEDED"}):(0,u.jsx)(l.Muted,{children:"optional"})]}),(0,u.jsxs)(l.Row,{wrap:!0,gap:6,children:[e.required?null:(0,u.jsx)(l.Chip,{label:"Not in the file",selected:null==j[e.key],onPress:()=>k({...j,[e.key]:void 0})}),b.map((s,o)=>(0,u.jsx)(l.Chip,{testID:`sheet-col-${e.key}-${o}`,label:s||`Column ${o+1}`,sub:y?void 0:t.rows[0][o],selected:j[e.key]===o,onPress:()=>{const s={...j};Object.keys(s).forEach(e=>{s[e]===o&&delete s[e]}),s[e.key]=o,k(s)}},o))]})]},e.key)),(0,u.jsx)(l.Button,{testID:"sheet-to-preview",label:"Preview",disabled:!E,onPress:()=>{S('preview'),f(`${M.filter(e=>e.ok).length} rows ready, ${L} with problems.`)}})]}):null,'preview'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-preview",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"2. Check the preview"}),(0,u.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,u.jsx)(l.T,{testID:"sheet-summary",children:`${P.length} night${1===P.length?'':'s'} ready${L?` \xb7 ${L} row${1===L?'':'s'} with a problem (not saved)`:''}${U?` \xb7 ${U} signed off and locked (not changed)`:''}`})}),z?(0,u.jsx)(l.Banner,{kind:"warn",title:`${z} date${1===z?' already has':'s already have'} takings in CoverCharge`,children:(0,u.jsxs)(o.default,{style:{gap:6},children:[(0,u.jsx)(l.Toggle,{testID:"sheet-replace",label:"Replace those nights\u2019 takings with the spreadsheet",value:C,onChange:T}),(0,u.jsx)(l.Muted,{children:C?'Those nights will be replaced (the change is logged).':'Those nights are skipped; their saved takings are kept.'})]})}):null,M.slice(0,62).map(e=>{const s=e.ok&&'saved'===e.dup&&!C,t=e.ok&&!!e.date&&x(e.date),n=e.ok?t?'Locked: not changed':s?'Already saved: skipped':'saved'===e.dup?'Replaces saved takings':'Ready':e.errors.join('; ');return(0,u.jsxs)(o.default,{testID:`sheet-row-${e.line}`,accessible:!0,accessibilityLabel:`Row ${e.line}: ${e.date?m(e.date):'no date'}, gross ${p(e.vals.gross)}. ${n}`,style:{paddingVertical:8,gap:2,borderBottomWidth:1,borderBottomColor:h.colours.hairline,opacity:!e.ok||s||t?.75:1},children:[(0,u.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(l.T,{size:15,weight:"semibold",children:`Row ${e.line} \xb7 ${e.date?m(e.date):'no date'}`}),(0,u.jsx)(l.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:p(e.vals.gross)})]}),(()=>{const s=['food','drink','card','cash'].filter(s=>null!=j[s]&&null!=e.vals[s]).map(s=>`${s[0].toUpperCase()}${s.slice(1)} ${p(e.vals[s])}`);return s.length?(0,u.jsx)(l.T,{size:13,colour:h.colours.text,children:s.join(' \xb7 ')}):null})(),(0,u.jsx)(l.T,{size:13,colour:e.ok?h.colours.muted:h.colours.amber,children:n})]},e.line)}),M.length>62?(0,u.jsx)(l.Muted,{children:`\u2026and ${M.length-62} more rows.`}):null,(0,u.jsxs)(o.default,{style:{gap:8},children:[(0,u.jsx)(l.Button,{testID:"sheet-to-confirm",label:`Next: save ${R.length} night${1===R.length?'':'s'}`,disabled:!R.length,onPress:()=>S('confirm')}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Change columns",onPress:()=>S('map')})]})]}):null,'confirm'===D?(0,u.jsxs)(o.default,{style:{gap:10},testID:"sheet-confirm",children:[(0,u.jsx)(l.T,{size:17,weight:"semibold",children:"3. Confirm"}),(0,u.jsxs)(o.default,{style:{borderWidth:1.5,borderColor:h.colours.gold,borderRadius:14,padding:12,gap:4,backgroundColor:h.colours.goldTint},accessibilityLiveRegion:"polite",children:[(0,u.jsx)(l.T,{size:18,weight:"semibold",colour:h.colours.gold,children:`Save takings for ${R.length} night${1===R.length?'':'s'}`}),(0,u.jsx)(l.T,{children:R.length?`${m(R.map(e=>e.date).sort()[0])} to ${m(R.map(e=>e.date).sort().slice(-1)[0])} \xb7 gross ${p(Math.round(100*R.reduce((e,s)=>e+(s.vals.gross??0),0))/100)} in total`:''}),(0,u.jsx)(l.Muted,{children:`Saved as confirmed by ${c.name}. Each night is logged. ${C&&z?`${z} saved night${1===z?' is':'s are'} replaced.`:z?`${z} already-saved night${1===z?' is':'s are'} skipped.`:''}`})]}),(0,u.jsx)(l.Button,{testID:"sheet-save",label:"Confirm and save",onPress:()=>{const s=(new Date).toISOString(),o=n.useCashUp.getState();for(const l of R){const n=o.cashUps.find(s=>s.rid===e&&s.date===l.date);o.saveCashUp({rid:e,date:l.date,vals:{...n?.vals??{},...(0,r.rowVals)(l)},photos:n?.photos??[],confirmedBy:c.name,confirmedAt:s,readBy:`spreadsheet: ${t.name}`.slice(0,80)})}const l=R.length,i=`Takings saved for ${l} night${1===l?'':'s'} from ${t.name}.`;f(i),w(i)}}),(0,u.jsx)(l.Button,{kind:"secondary",label:"Back to the preview",onPress:()=>S('preview')})]}):null]})};var s=_r(d[0]),t=e(_r(d[1]));_r(d[2]);var o=e(_r(d[3])),l=_r(d[4]),n=_r(d[5]),i=_r(d[6]),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]);const p=e=>null==e?'\u2014':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,m=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric',timeZone:'UTC'}),f=e=>{try{t.default.announceForAccessibility?.(e)}catch{}}},1081,[34,281,236,102,794,1039,13,1082,821,1083,25]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"COLS",{enumerable:!0,get:function(){return n}}),e.parseCsv=function(t){const n=t.replace(/^\uFEFF/,''),r=n.split(/\r?\n/,1)[0]??'',s=t=>r.split(t).length-1,a=[',',';','\t'].sort((t,n)=>s(n)-s(t))[0],o=[];let l=[],d='',i=!1;for(let t=0;tt.some(t=>''!==t.trim())).map(t=>t.map(t=>t.trim()))},e.guessMapping=function(t){const n={},s=new Set;for(const a of['date','food','drink','card','cash','gross']){const o=t.findIndex((t,n)=>!s.has(n)&&r[a].test(t)&&!('gross'===a&&/tips?/i.test(t))&&!('cash'===a&&/tips?|float/i.test(t)));o>=0&&(n[a]=o,s.add(o))}return n},e.parseDateCell=l,e.buildPreview=function(r,s,a,o){const d=a?r.slice(1):r,i=new Map,u=d.map((r,o)=>{const d=[],i=t=>null==s[t]?'':(r[s[t]]??'').trim(),u=null==s.date?null:l(i('date'));u||d.push(i('date')?`Date \u201c${i('date')}\u201d not understood`:'No date');const c={};for(const r of n){if('date'===r.key||null==s[r.key])continue;const n=i(r.key);if(!n){c[r.key]=null,r.required&&d.push(`No ${r.label.toLowerCase()}`);continue}const a=(0,t.parseAmount)(n.replace(/^\((.*)\)$/,'-$1'));null==a&&d.push(`${r.label} \u201c${n}\u201d not a \xa3 amount`),c[r.key]=a}return null==s.gross&&d.push('No gross column'),{line:o+(a?2:1),date:u,vals:c,errors:d,dup:null,ok:!1}});for(const t of u)t.date&&i.set(t.date,(i.get(t.date)??0)+1);for(const t of u)t.date&&(i.get(t.date)??0)>1?(t.dup='file',t.errors.push('This date is in the file more than once')):t.date&&o.has(t.date)&&(t.dup='saved'),t.ok=!t.errors.length;return u},e.rowVals=function(t){const n={};for(const r of['gross','food','drink','card','cash'])r in t.vals&&(n[r]=t.vals[r]??null);return n};var t=_r(_d[0]);const n=[{key:'date',label:'Date',required:!0},{key:'gross',label:'Gross takings',required:!0},{key:'food',label:'Food'},{key:'drink',label:'Drink'},{key:'card',label:'Card'},{key:'cash',label:'Cash'}];const r={date:/^(date|day|night|trading ?date|business ?date)\b/i,gross:/(gross|total ?takings|takings|total ?sales|sales ?total|turnover|^total$)/i,food:/\bfood\b|kitchen/i,drink:/\bdrinks?\b|\bbar\b|bev(erage)?s?|wet/i,card:/\bcard\b|pdq|debit|credit/i,cash:/\bcash\b/i};const s=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],a=t=>String(t).padStart(2,'0'),o=(t,n,r)=>{const s=new Date(Date.UTC(t,n-1,r));return s.getUTCFullYear()===t&&s.getUTCMonth()===n-1&&s.getUTCDate()===r?`${t}-${a(n)}-${a(r)}`:null};function l(t){const n=t.trim();let r;if(r=n.match(/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[ T].*)?$/))return o(+r[1],+r[2],+r[3]);if(r=n.match(/^(\d{1,2})[/.-](\d{1,2})[/.-](\d{2}|\d{4})(?: .*)?$/))return o(2===r[3].length?+r[3]+2e3:+r[3],+r[2],+r[1]);if(r=n.match(/^(?:[a-z]+,? )?(\d{1,2})(?:st|nd|rd|th)? ([a-z]{3})[a-z]*,? (\d{4})$/i)){const t=s.indexOf(r[2].toLowerCase());return t<0?null:o(+r[3],t+1,+r[1])}if(/^\d{5}(\.\d+)?$/.test(n)){const t=Math.floor(+n);if(t<36526||t>73050)return null;const r=new Date(Date.UTC(1899,11,30)+864e5*t);return o(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate())}return null}},1082,[13]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";async function t(t){const r=globalThis.DecompressionStream;if(!r)throw new Error('This browser can\u2019t open .xlsx files. Save the sheet as CSV and upload that.');const n=new Blob([t]).stream().pipeThrough(new r('deflate-raw'));return new Uint8Array(await new Response(n).arrayBuffer())}async function r(r,n){const s=new Uint8Array(r),o=new DataView(r),i={};let c=-1;for(let t=s.length-22;t>=Math.max(0,s.length-66e3);t--)if(101010256===o.getUint32(t,!0)){c=t;break}if(c<0)throw new Error('This isn\u2019t a readable .xlsx file.');const l=o.getUint16(c+10,!0);let h=o.getUint32(c+16,!0);const f=new TextDecoder;for(let r=0;r'xl/sharedStrings.xml'===t||/^xl\/worksheets\/sheet\d+\.xml$/.test(t)),i=Object.keys(o).filter(t=>t.startsWith('xl/worksheets/')).sort()[0];if(!i)throw new Error('No worksheet found in this file.');const c=[...(o['xl/sharedStrings.xml']??'').matchAll(/([\s\S]*?)<\/si>/g)].map(t=>n([...t[1].matchAll(/]*>([\s\S]*?)<\/t>/g)].map(t=>t[1]).join(''))),l=[];for(const t of o[i].matchAll(/]*>([\s\S]*?)<\/row>/g)){const r=[];for(const o of t[1].matchAll(/]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)){const t=o[1],i=o[2]??'',l=t.match(/r="([A-Z]+\d+)"/)?.[1],h=t.match(/t="(\w+)"/)?.[1],f=i.match(/([\s\S]*?)<\/v>/)?.[1],w=i.match(/]*>([\s\S]*?)<\/t>/)?.[1],m='s'===h?c[Number(f)]??'':n('inlineStr'===h?w??'':f??'');r[l?s(l):r.length]=m}l.push(Array.from(r,t=>(t??'').trim()))}return l.filter(t=>t.some(t=>''!==t))};const n=t=>t.replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,"'").replace(/&#(\d+);/g,(t,r)=>String.fromCharCode(+r)).replace(/&/g,'&'),s=t=>{const r=t.replace(/\d+/g,'');let n=0;for(const t of r)n=26*n+(t.charCodeAt(0)-64);return n-1}},1083,[]); +__d(function(g,_r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useLockedFor=function(e){const n=(0,c.useCashUp)(e=>e.cashUps),s=(0,c.useCashUp)(e=>e.sales);return(0,o.useCallback)((o,l)=>{const i='cashup'===o?n.find(n=>n.rid===e&&n.date===l):s.find(n=>n.rid===e&&n.weekStart===l);return!!i&&(0,h.cashLocked)(t.PITCH&&i.confirmedAt?{...i,onServer:!0}:i)},[n,s,e])},Object.defineProperty(_e,"lockedMessage",{enumerable:!0,get:function(){return y}}),_e.auditLine=j,_e.CashLockControls=function({kind:e,item:s,label:c}){const y=(0,k.useSync)(e=>'staff'===e.kind&&!!e.venueId)||t.PITCH,b=(0,k.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),x=(0,u.useOwner)(e=>e.previewRole),C=b||t.PITCH&&'owner'===x,[$,w]=(0,o.useState)(!1),[I,S]=(0,o.useState)(''),[P,L]=(0,o.useState)(!1),[T,U]=(0,o.useState)(null);if(!y||!(s.onServer||t.PITCH&&s.confirmedAt))return null;const v=(0,h.cashLocked)(t.PITCH?{...s,onServer:!0}:s),H=async()=>{L(!0);const n=await(0,k.unlockCashUp)(e,s.id,I.trim());L(!1),n.ok?(w(!1),S(''),(0,f.notify)({id:'cash-unlock',icon:'\ud83d\udd11',title:`${c} unlocked for 30 minutes`,body:'Correct it now. It locks again by itself, and the change is logged with your name.',timeoutMs:8e3})):(0,f.notify)({id:'cash-unlock',tone:'warn',title:'Not unlocked',body:n.message,timeoutMs:8e3})};return(0,p.jsxs)(l.default,{testID:`cash-lock-${s.id}`,style:{gap:4},children:[(0,p.jsxs)(i.Row,{gap:6,wrap:!0,children:[v?(0,p.jsx)(i.Badge,{kind:"gold",label:"Signed off"}):(0,p.jsx)(i.Badge,{kind:"neutral",label:`Unlocked until ${new Date(s.unlockedUntil??'').toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'})}`}),v&&C&&!$?(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-unlock-${s.id}`,label:"Unlock to correct",onPress:()=>w(!0)}):null,(0,p.jsx)(i.Button,{small:!0,kind:"ghost",testID:`cash-history-${s.id}`,label:T?'Hide history \u25b4':'History \u25be',onPress:()=>{T?U(null):(0,k.readCashAudit)(s.id).then(U)}})]}),v&&!C?(0,p.jsx)(i.Muted,{size:12,children:"Only an owner can unlock it to make a correction."}):null,$?(0,p.jsxs)(l.default,{style:{gap:4},children:[(0,p.jsx)(n.TextInput,{testID:`cash-unlock-reason-${s.id}`,value:I,onChangeText:S,placeholder:"Why does it need changing?",placeholderTextColor:r.colours.muted,maxLength:200,style:{minHeight:36,borderRadius:8,borderWidth:1,borderColor:r.colours.hairline,color:r.colours.text,paddingHorizontal:8}}),(0,p.jsxs)(i.Row,{gap:6,children:[(0,p.jsx)(i.Button,{small:!0,testID:`cash-unlock-yes-${s.id}`,label:P?'Unlocking\u2026':'Unlock for 30 minutes',disabled:P||I.trim().length<3,onPress:()=>{H()}}),(0,p.jsx)(i.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>{w(!1),S('')}})]})]}):null,T?T.length?T.map((e,n)=>(0,p.jsx)(i.Muted,{size:12,children:j(e)},n)):(0,p.jsx)(i.Muted,{size:12,children:"No history yet."}):null]})};var e,n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),l=(e=s)&&e.__esModule?e:{default:e},i=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),k=_r(d[9]),f=_r(d[10]),p=_r(d[11]);const y=(e,n)=>`The ${'cashup'===e?'cash up':'weekly sales report'} for ${n} is signed off and locked. An owner can tap \u201cUnlock to correct\u201d on it.`,b={created:'signed off',changed:'changed',unlocked:'unlocked',deleted:'removed'},x=e=>new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'});function j(e){const n=e.changed.length&&'changed'===e.action?` (${e.changed.slice(0,6).join(', ')}${e.changed.length>6?'\u2026':''})`:'';return`${x(e.at)} \xb7 ${e.by} ${b[e.action]??e.action}${n}${e.reason?`: \u201c${e.reason}\u201d`:''}`}},1084,[827,2,34,102,794,821,1039,891,13,987,1001,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"BACKDATE_MAX_DAYS",{enumerable:!0,get:function(){return t}}),_e.backdateProblem=function(e,n){return a(e)?e>=n?e===n?'That is today: use End of night cash up above.':'That date is in the future. Pick today or an earlier day.':o(e,n)>t?`Pick a day within the last ${t} days.`:null:'Enter a date as DD/MM/YYYY, for example 11/11/2026.'},_e.londonStamp=u,_e.laterLine=function(e,t,n){return`${e} later by ${(t||'a manager').slice(0,60)}, ${u(n)}`},Object.defineProperty(_e,"HISTORY_KEY",{enumerable:!0,get:function(){return c}}),_e.historyLines=d,_e.withHistory=function(e,t,n){return{...e,[c]:[t,...d(n??e)].slice(0,20).join('\n')}},_e.paidOutFor=function(e,t,n){return t.filter(t=>t.rid===n&&'payout'===t.kind&&t.throughDate&&t.throughDate>=e).sort((e,t)=>e.at.localeCompare(t.at))[0]??null},_e.cashUpTipsBetween=function(t,n,a,o){const u=t.filter(e=>e.rid===n&&e.confirmedAt&&e.date>=a&&e.date<=o).reduce((t,n)=>t+((0,e.combinedTips)(n.vals)??0),0);return Math.round(100*u)/100};var e=r(_d[0]);const t=400,n=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],a=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&new Date(`${e}T12:00:00Z`).toISOString().slice(0,10)===e,o=(e,t)=>Math.round((Date.parse(`${t}T12:00:00Z`)-Date.parse(`${e}T12:00:00Z`))/864e5);function u(e){const t=new Date(e),a=Object.fromEntries(new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',day:'numeric',month:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}).formatToParts(t).map(e=>[e.type,e.value]));return`${Number(a.day)} ${n[Number(a.month)-1]} ${a.hour}:${a.minute}`}const c='_history';function d(e){const t=e?.[c];return'string'==typeof t&&t.trim()?t.split('\n').filter(Boolean):[]}},1085,[13]); +__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.LookBackResult=k,_e.monthCells=v,_e.calendarDayLabel=C,_e.LookBackCalendar=T,_e.LookBack=function(){const{rid:e,today:s}=(0,u.useCtx)(3e4),[l,i]=(0,t.useState)((0,c.addDays)(s,-1)),[j,p]=(0,t.useState)((0,y.ukHistoryDate)(l)),[f,m]=(0,t.useState)(0),[D,$]=(0,t.useState)(!1),v=(0,b.useHistoricalBookingDay)(e,l,s,f),C=(0,y.parseHistoryInput)(j),w=!!C&&(0,y.validPastDate)(C,s);if(!v.allowed)return(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"Sign in to the Managers app with manager or owner access to Look back."})});const L=e=>{i(e),p((0,y.ukHistoryDate)(e))};return(0,x.jsxs)(n.default,{style:{gap:14},testID:"look-back",children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:12},children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:"Look back"}),(0,x.jsx)(d.T,{size:18,center:!0,children:"Find bookings for one exact past date. Read-only; nothing is sent or changed."}),(0,x.jsx)(d.Field,{label:"Past booking date (DD/MM/YYYY)",value:j,onChangeText:e=>p((0,o.slashDate)(e,j)),placeholder:"05/11/2025",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Exact past booking date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"look-back-date",style:{textAlign:'center'}}),w?null:(0,x.jsx)(d.T,{size:18,center:!0,children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026, including the four-digit year."}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Pick a date",testID:"look-back-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,c.longDay)(l)}`,onPress:()=>$(!0)}),(0,x.jsx)(d.Button,{label:"Show bookings",accessibilityLabel:`Look back at bookings for ${w&&C?(0,y.historyDateLabel)(C):'a valid past date'}`,disabled:!w,onPress:()=>{C&&L(C),m(f+1)}})]}),(0,x.jsxs)(d.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{kind:"secondary",label:"Previous day",accessibilityLabel:`Previous day, ${(0,c.longDay)((0,c.addDays)(l,-1))}`,onPress:()=>L((0,c.addDays)(l,-1))}),(0,x.jsx)(d.Button,{kind:"secondary",label:"Next day",accessibilityLabel:`Next day, ${(0,c.longDay)((0,c.addDays)(l,1))}`,disabled:!(0,y.validPastDate)((0,c.addDays)(l,1),s),onPress:()=>L((0,c.addDays)(l,1))})]})]})}),(0,x.jsx)(T,{visible:D,today:s,selected:l,onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),v.data?(0,x.jsx)(k,{day:v.data}):(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:v.error||'Loading booking history\u2026'})})]})};var t=r(_d[0]),s=e(t),o=r(_d[1]),l=e(r(_d[2])),i=e(r(_d[3])),n=e(r(_d[4])),d=r(_d[5]),c=r(_d[6]),u=r(_d[7]),b=r(_d[8]),y=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function k({day:e}){return(0,x.jsxs)(n.default,{testID:"look-back-result",style:{gap:14},children:[(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{style:{gap:10},children:[(0,x.jsx)(d.T,{size:24,weight:"bold",colour:h.colours.gold,accessibilityRole:"header",children:(0,y.historyDateLabel)(e.date)}),(0,x.jsxs)(n.default,{accessible:!0,accessibilityLabel:`Booked Covers: ${null===e.booked_covers?'not recorded':e.booked_covers}`,children:[(0,x.jsx)(d.T,{size:20,children:"Booked Covers"}),(0,x.jsx)(d.T,{size:36,weight:"bold",colour:h.colours.gold,children:null===e.booked_covers?'Not recorded':e.booked_covers})]}),e.historical_records?(0,x.jsx)(d.T,{size:20,colour:h.colours.gold,weight:"semibold",children:y.HISTORY_LABEL}):null,(0,x.jsx)(d.T,{size:18,children:y.HISTORY_NOTE}),e.missing_covers?(0,x.jsxs)(d.T,{size:18,children:[e.missing_covers," booking records have no party size; not filled in."]}):null]})}),e.bookings.length?null:(0,x.jsx)(d.Card,{children:(0,x.jsx)(d.T,{size:20,children:"No booking records found for this date. The history is incomplete; this does not prove there were no bookings."})}),e.bookings.map((e,t)=>(0,x.jsx)(d.Card,{children:(0,x.jsxs)(n.default,{testID:"look-back-booking",style:{gap:8},accessible:!0,accessibilityLabel:`${e.time??'Time not recorded'}, party size ${null===e.covers?'not recorded':`${e.covers} Covers`}, ${e.table?`table ${e.table}`:'table not recorded'}, ${e.status??'status not recorded'}${e.counted?'':', excluded from Booked Covers'}`,children:[(0,x.jsxs)(d.Row,{wrap:!0,gap:20,children:[(0,x.jsx)(d.T,{size:26,weight:"bold",colour:h.colours.gold,children:e.time??'Time not recorded'}),(0,x.jsxs)(d.T,{size:22,children:["Party size: ",null===e.covers?'Not recorded':`${e.covers} Covers`]})]}),(0,x.jsxs)(d.T,{size:20,children:["Table: ",e.table??'Not recorded']}),(0,x.jsxs)(d.T,{size:18,children:[e.status??'Status not recorded',e.counted?'':' \xb7 excluded from Booked Covers']}),(0,x.jsxs)(d.T,{size:18,colour:h.colours.muted,children:['favourite_table'===e.source?'previous booking system':'CoverCharge'," \xb7 ",e.ref]})]})},`${e.source}:${e.ref}:${t}`))]})}const j=['January','February','March','April','May','June','July','August','September','October','November','December'],p=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>String(e).padStart(2,'0'),m=e=>{const[t,s,o]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,o,12)).getUTCDay()+6)%7},D=(e,t)=>{const[s,o]=e.split('-').map(Number),l=new Date(Date.UTC(s,o-1+t,1,12));return`${l.getUTCFullYear()}-${f(l.getUTCMonth()+1)}`},$=e=>{const[t,s]=e.split('-').map(Number);return`${j[s-1]} ${t}`};function v(e){const[t,s]=e.split('-').map(Number),o=new Date(Date.UTC(t,s,0)).getUTCDate();return[...Array(m(`${e}-01`)).fill(null),...Array.from({length:o},(t,s)=>`${e}-${f(s+1)}`)]}function C(e,t,s,o="Look back"){const l=(0,y.validPastDate)(e,t);return`${(0,c.longDay)(e)}${e===t?', today':''}${e===s?', selected':''}${l?'':`, not available. ${o} is for past days only`}`}function T({visible:e,today:o,selected:u,onPick:b,onClose:k,purpose:j="Look back",idPrefix:f="look-back"}){const[m,T]=(0,t.useState)(u.slice(0,7)),[w,L]=(0,t.useState)(0);s.default.useEffect(()=>{e&&T(u.slice(0,7))},[e,u]);const P=v(m),z=D(m,-1),I=D(m,1),S=`${I}-01`N>=46?e.slice(0,3):e.slice(0,2);return(0,x.jsx)(d.Sheet,{visible:e,onClose:k,title:"Pick a day",maxWidth:420,testID:`${f}-calendar`,footer:(0,x.jsx)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:(0,x.jsx)(d.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close calendar",testID:`${f}-cal-close`,onPress:k})}),children:(0,x.jsxs)(n.default,{style:{gap:10,alignItems:'stretch'},children:[(0,x.jsx)(d.T,{size:20,weight:"bold",colour:h.colours.goldLight,center:!0,accessibilityRole:"header",testID:`${f}-cal-month`,children:$(m)}),(0,x.jsxs)(d.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Previous month",accessibilityLabel:`Previous month, ${$(z)}`,testID:`${f}-cal-prev`,onPress:()=>T(z)}),(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Next month",accessibilityLabel:S?`Next month, ${$(I)}`:`Next month, ${$(I)}, not available. ${j} is for past days only`,disabled:!S,testID:`${f}-cal-next`,onPress:()=>T(I)})]}),(0,x.jsxs)(n.default,{onLayout:e=>L(e.nativeEvent.layout.width),style:{width:'100%'},children:[(0,x.jsx)(n.default,{style:{flexDirection:'row'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:p.map(e=>(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,x.jsx)(d.T,{size:13,colour:h.colours.muted,center:!0,children:B(e)})},e))}),(0,x.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap'},testID:`${f}-cal-grid`,children:P.map((e,t)=>{if(!e)return(0,x.jsx)(n.default,{style:{width:"14.285714285714286%",height:48}},`blank-${t}`);const s=(0,y.validPastDate)(e,o),k=e===u;return(0,x.jsx)(i.default,{testID:`${f}-cal-${e}`,accessibilityRole:"button",accessibilityLabel:C(e,o,u,j),accessibilityState:{selected:k,disabled:!s},disabled:!s,onPress:()=>{b(e),l.default.announceForAccessibility?.('Look back'===j?`Looking back at ${(0,c.longDay)(e)}`:`${j}: ${(0,c.longDay)(e)}`)},style:{width:"14.285714285714286%",height:48,minHeight:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:k||e===o?1.5:0,borderColor:h.colours.gold,backgroundColor:k?h.colours.goldTint:'transparent',opacity:s?1:.35},children:(0,x.jsx)(d.T,{size:17,weight:k?'bold':'regular',colour:k?h.colours.goldLight:h.colours.text,center:!0,children:Number(e.slice(8))})},e)})})]})]})})}},1086,[34,1063,281,402,102,794,1087,1088,1092,1093,821,25]); +__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.addDays=b,Object.defineProperty(_e,"longDay",{enumerable:!0,get:function(){return h}}),_e.BookingsDayNav=function({today:e,date:p,onDate:j,sub:w,count:x}){const[f,D]=(0,t.useState)(pb(e,6)?p:e),[$,k]=(0,t.useState)(!1),[T,C]=(0,t.useState)(p.slice(0,7)),L=Array.from({length:7},(e,t)=>b(f,t)),I=e=>{j(e),L.includes(e)||D(e)},P=t=>t===e?'Today':t===b(e,1)?'Tomorrow':t===b(e,-1)?'Yesterday':m(t),[U,S]=T.split('-').map(Number),B=y(`${T}-01`),N=new Date(Date.UTC(U,S,0)).getUTCDate(),M=[...Array(B).fill(null),...Array.from({length:N},(e,t)=>`${T}-${u(t+1)}`)],R=e=>{const t=new Date(Date.UTC(U,S-1+e,1,12));C(`${t.getUTCFullYear()}-${u(t.getUTCMonth()+1)}`)};return(0,i.jsxs)(l.default,{style:{gap:8},testID:"bookings-day-nav",children:[(0,i.jsxs)(o.Row,{wrap:!0,gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Earlier week",testID:"week-earlier",accessibilityLabel:`Earlier week, from ${h(b(f,-7))}`,onPress:()=>{D(b(f,-7)),j(b(f,-7))}}),(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Later week",testID:"week-later",accessibilityLabel:`Later week, from ${h(b(f,7))}`,onPress:()=>{D(b(f,7)),j(b(f,7))}}),p!==e?(0,i.jsx)(o.Button,{small:!0,kind:"secondary",label:"Today",testID:"day-today",accessibilityLabel:`Back to today, ${h(e)}`,onPress:()=>{D(e),j(e),k(!1)}}):null,(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:$?'Close calendar':'Pick a date',testID:"day-pick",onPress:()=>{$||C(p.slice(0,7)),k(!$)}})]}),$?(0,i.jsxs)(l.default,{testID:"day-calendar",style:{gap:6,borderWidth:1.5,borderColor:n.colours.gold,borderRadius:12,padding:10},children:[(0,i.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:6,children:[(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Earlier month",accessibilityLabel:"Earlier month",onPress:()=>R(-1)}),(0,i.jsxs)(o.T,{size:18,weight:"bold",colour:n.colours.goldLight,children:[d[S-1]," ",U]}),(0,i.jsx)(o.Button,{small:!0,kind:"ghost",label:"Later month",accessibilityLabel:"Later month",onPress:()=>R(1)})]}),(0,i.jsx)(o.Row,{children:c.map(e=>(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",alignItems:'center'},children:(0,i.jsx)(o.T,{size:13,colour:n.colours.muted,children:e.slice(0,3)})},e))}),(0,i.jsx)(l.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:M.map((t,d)=>{if(!t)return(0,i.jsx)(l.default,{style:{width:"14.285714285714286%",height:48}},`e${d}`);const c=t===p,u=x(t);return(0,i.jsxs)(s.default,{accessibilityRole:"button",testID:`cal-${t}`,accessibilityState:{selected:c},accessibilityLabel:`${h(t)}${t===e?', today':''}, ${u} booking${1===u?'':'s'}`,onPress:()=>{I(t),D(t),k(!1)},style:{width:"14.285714285714286%",height:48,alignItems:'center',justifyContent:'center',borderRadius:10,borderWidth:t===e?1.5:0,borderColor:n.colours.gold,backgroundColor:c?n.colours.goldTint:'transparent'},children:[(0,i.jsx)(o.T,{size:17,weight:c||t===e?'bold':'regular',colour:c?n.colours.goldLight:n.colours.text,children:Number(t.slice(8))}),u?(0,i.jsx)(o.T,{size:11,colour:n.colours.goldLight,children:u}):null]},t)})})]}):null,(0,i.jsx)(o.Row,{wrap:!0,gap:6,children:L.map(e=>(0,i.jsx)(o.Chip,{label:P(e),sub:w(e),selected:p===e,onPress:()=>j(e)},e))}),(0,i.jsx)(l.default,{testID:"bookings-day-title",children:(0,i.jsxs)(o.T,{size:17,weight:"semibold",colour:n.colours.goldLight,children:[h(p),pString(e).padStart(2,'0');function b(e,t){const[s,l,o]=e.split('-').map(Number),n=new Date(Date.UTC(s,l-1,o+t,12));return`${n.getUTCFullYear()}-${u(n.getUTCMonth()+1)}-${u(n.getUTCDate())}`}const y=e=>{const[t,s,l]=e.split('-').map(Number);return(new Date(Date.UTC(t,s-1,l,12)).getUTCDay()+6)%7},h=e=>{const[t,s,l]=e.split('-').map(Number);return`${c[y(e)]} ${l} ${d[s-1]} ${t}`},m=e=>{const[,t,s]=e.split('-').map(Number);return`${c[y(e)].slice(0,3)} ${s} ${d[t-1].slice(0,3)}`}},1087,[34,402,102,794,821,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"fmtH",{enumerable:!0,get:function(){return d.fmtH}}),Object.defineProperty(_e,"fmtHDay",{enumerable:!0,get:function(){return d.fmtHDay}}),Object.defineProperty(_e,"authorityRole",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"clampRole",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"StaffAppCtx",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useInStaffApp",{enumerable:!0,get:function(){return D}}),Object.defineProperty(_e,"ShiftMgrScope",{enumerable:!0,get:function(){return b}}),_e.useShiftManager=h,_e.useSignedIn=S,_e.useCtx=function(e=1e4){const u=(0,t.useContext)(y),i=(0,r.useOwner)(e=>e.site),f=(0,r.useOwner)(e=>e.previewRole),c=(0,r.useOwner)(e=>e.staffAs),d=S(),l=u||'staff'===o.APP_VARIANT,D=(0,t.useContext)(b),O=h(),A=o.IS_CAR?'owner':l?D&&O?'manager':'staff':d?w(f,p(d)):f,I=(0,r.useOwner)(e=>e.staff),R=(0,n.useRestaurant)(i),M=(0,n.useNow)(e),C=o.IS_CAR?s.CAR_DEVICE_ID:d?d.id:l&&c?c:m[A],P=o.IS_CAR?s.CAR_ACTOR:I.find(e=>e.id===C)?.name??'Team member';return{rid:i,r:R,now:M,role:A,me:P,meId:C,today:(0,a.venueYmd)(M),signedIn:!o.IS_CAR&&!!d}},Object.defineProperty(_e,"weekday",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"DAY3",{enumerable:!0,get:function(){return A}}),_e.ensureAttendance=function(t,n){if(e.LIVE_VENUE_BUILD||(0,u.isLive)())return;const o=r.useOwner.getState(),s=[],i=o.staff.find(e=>e.active&&'manager'===e.role)??o.staff.find(e=>e.active&&'owner'===e.role),f=new Date(n);f.setDate(n.getDate()-O(n));const c=(0,a.ymd)(f),d=(0,a.ymd)(new Date(f.getFullYear(),f.getMonth(),f.getDate()+6)),m=(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 t=new Date(n);t.setDate(t.getDate()-e);const r=(0,a.ymd)(t);if(o.attendance.some(e=>e.date===r))continue;const u=o.shifts.filter(e=>e.date===r&&!1!==e.published);(u.length?u:o.shifts.filter(e=>e.day===O(t)&&e.date>=c&&e.date<=d&&!1!==e.published)).forEach((n,a)=>{const o=e=>Math.round((7*r.charCodeAt(9)+13*a+e)%17-5),u=n.end-n.start,f=u>8?30:u>6?20:0,c=e>2&&i?{signOff:{by:i.name,byId:i.id,at:m(t,34,a)}}:{};s.push({id:`at-${r}-${n.staffId}`,staffId:n.staffId,date:r,in:m(t,n.start,o(1)),out:m(t,n.end,o(2)),inSite:!0,outSite:!0,breakMins:f,...c})})}s.length&&r.useOwner.setState({attendance:[...r.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 I}}),_e.payRange=function(e,t,n){const r=new Date(n);if(r.setHours(0,0,0,0),'monthly'===e){const e=new Date(r.getFullYear(),r.getMonth()+t,1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return{s:e,e:n,key:`m-${(0,a.ymd)(e)}`}}const o='weekly'===e?7:14,s=new Date(r);s.setDate(r.getDate()-O(r));let u=new Date(s);if('fortnightly'===e){const e=new Date(2026,0,5);(Math.round((s.getTime()-e.getTime())/6048e5)%2+2)%2==1&&u.setDate(u.getDate()-7)}u.setDate(u.getDate()+t*o);const i=new Date(u);return i.setDate(u.getDate()+o-1),{s:u,e:i,key:`${e[0]}-${(0,a.ymd)(u)}`}},_e.useHourly=function(){const e=S(),t=(0,r.useOwner)(e=>e.hourly);return o.IS_CAR||e?t:R};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]),u=_r(_d[7]),i=_r(_d[8]),f=_r(_d[9]),c=_r(_d[10]),d=_r(_d[11]);const m={owner:c.ROSTER.find(e=>'owner'===e.role)?.id??'',manager:c.ROSTER.find(e=>'manager'===e.role)?.id??'',staff:c.ROSTER.find(e=>'staff'===e.app)?.id??''},l={staff:0,manager:1,owner:2},p=e=>e.ownerAccess?'owner':e.managerAccess&&'staff'===e.role?'manager':e.role,w=(e,t)=>l[e]>l[t]?t:e,y=(0,t.createContext)(!1),D=()=>(0,t.useContext)(y),b=(0,t.createContext)(!1);function h(){const e=(0,t.useContext)(y)||'staff'===o.APP_VARIANT,n=S(),r=(0,u.useSync)(e=>!!e.venueId&&'staff'===e.kind),a=(0,u.useSync)(e=>e.perms);return(0,i.shiftManagerOn)({inStaffApp:e,managerAccess:n?.managerAccess,role:n?.role,app:(0,f.rosterPerson)(n?.id)?.app,live:r,perms:a})}function S(){const e=(0,f.useSession)(e=>e.meId),t=(0,r.useOwner)(e=>e.staff);return e?t.find(t=>t.id===e&&t.active):void 0}const O=e=>(e.getDay()+6)%7,A=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];const I=e=>`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`;const R={}},1088,[837,34,874,891,858,872,1025,987,1089,1004,15,1091]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHIFT_MANAGER_PERMS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHIFT_MANAGER_FEATURES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MANAGER_EXCLUDED_WORDS",{enumerable:!0,get:function(){return c}}),e.shiftManagerOn=function(n){return!(!n.inStaffApp||!n.managerAccess||'owner'===n.role)&&(n.live?n.perms.includes('shift.manager'):'staff'===n.app)},e.swapTargets=function(t,s,o){const c=t.find(n=>n.id===s);return t.filter(t=>(0,n.canSwapWith)(c,t,o))};var n=r(d[0]);const t=['bookings.manage','floor.manage','stock.manage','attendance.view','rota.swap','shift.manager'],s=['New, edit and cancel bookings; walk-ins; seat, move and finish tables; deposit status','Tables to clear','Block bookings and close the garden','Allergy checks','Sold out (86) and tracked stock','Who\u2019s clocked in','Approve shift swaps and cover'],o=['wages.view','wages.manage','orders.manage','staff.manage','roles.manage','venue.settings','devices.manage','rota.manage','suppliers.manage','suppliers.order','recipes.edit','recipes.signoff','outbox.view'],c='takings, wages, tips and payouts, HR, billing, venue settings and owner access'},1089,[1090]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"deptKey",{enumerable:!0,get:function(){return n}}),e.sameDept=function(t,a){const o=n(t?.dept),s=n(a?.dept);return!!o&&o===s},Object.defineProperty(e,"teamKey",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"ANCHORAGE_VENUE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ANCHORAGE_SWAP_EDGES",{enumerable:!0,get:function(){return s}}),e.isAnchorageVenue=d,e.canSwapWith=function(t,n,o){if(!t||!n||!1===t.active||!1===n.active||'owner'===t.role||'owner'===n.role)return!1;const c=l(t),f=l(n);if(!c.length||!f.length||c.some(t=>f.includes(t)))return!1;if(d(o))return s.some(([t,n])=>c.includes(t)&&f.includes(n)||c.includes(n)&&f.includes(t));const b=a(t.dept),u=a(n.dept);return!!b&&b===u},Object.defineProperty(e,"SWAP_DEPT_NOTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANCHORAGE_SWAP_NOTE",{enumerable:!0,get:function(){return u}}),e.teamOnDay=function(a,o,s,c){const f=o.find(t=>t.id===c),d=new Map;for(const f of a){if(f.date!==s||!0!==f.published||f.staffId===c)continue;const a=o.find(t=>t.id===f.staffId);if(!a||!1===a.active)continue;const l=String(a.dept??'').trim()||'Department not set',b=n(a.dept)||p,u=d.get(b)??{dept:l,people:[]};u.people.push({id:a.id,name:g(a.name),job:String(a.job??'').trim(),start:f.start,end:f.end,times:`${(0,t.fmtH)(f.start)}\u2013${(0,t.fmtH)(f.end)}`}),d.set(b,u)}const l=n(f?.dept);return[...d.entries()].sort(([t],[n])=>t===l?-1:n===l||t===p?1:n===p?-1:t.localeCompare(n)).map(([,t])=>({...t,people:t.people.sort((t,n)=>t.start-n.start||t.name.localeCompare(n.name))}))},e.teamOnDaySpoken=function(n,a){return a.length?`${n}, also on. `+a.map(n=>`${n.dept}: `+n.people.map(n=>`${n.name}${n.job?`, ${n.job}`:''}, ${(0,t.fmtH)(n.start)} to ${(0,t.fmtH)(n.end)}`).join('; ')).join('. ')+'.':`${n}: nobody else is on the rota.`};var t=r(_d[0]);const n=t=>String(t??'').trim().toLowerCase().replace(/\s+/g,' ');const a=t=>{const a=n(t);return'bar'===a||'foh'===a?'front of house':a},o='6349aa07-3fec-46e9-8c69-7b1b08494793',s=[['st-finn','st-agate'],['st-finn','st-eilidh'],['st-agate','st-eilidh'],['st-gabrielle','st-emily'],['st-gabrielle','st-agate'],['st-emily','st-agate'],['st-gordon','st-lenny'],['st-gordon','st-bisto'],['st-mia','st-lillie']],c={'st-finn':'0db9c5d4-f989-4ce8-838a-54c7735f83f0','st-agate':'fce268d0-63ab-42cd-a298-68e3ec5bcae4','st-eilidh':'88f41ae2-dd2f-41c2-b75d-fa735a77e703','st-gabrielle':'71174004-40de-4477-a157-04858a009baa','st-emily':'6b6f09b4-a65e-4390-b86e-b8c57eabe178','st-gordon':'456e0738-dea5-47a8-813e-7b13a0e6c10e','st-lenny':'4dfc8938-7c90-4667-92d2-410807f791f8','st-bisto':'ea2e4b54-ce06-465a-b796-4fa7cde99004','st-mia':'260f4c7b-e78a-45ba-9f8e-f6e33921762b','st-lillie':'636735ff-0d19-4c47-9bfa-3e13c261acc2','st-jack':'ce6f4391-ec69-4782-aac6-8500eb899cc2','st-cameron':'683888b9-2b3d-4225-b028-12cf577decbb','st-harvey':'3ad10d28-78c0-457d-9238-f4a27fb30170','st-james':'6ffe4ae0-2bc1-4355-b3b5-f6e79884d0dc','st-tracy':'79fbfe9e-1d64-412c-a191-42e94b35c1c7'},f=Object.fromEntries(Object.entries(c).map(([t,n])=>[n,t]));function d(t){const n=String(t??'').trim().toLowerCase();return'anchorage'===n||n===o}function l(t){if(!t)return[];const n=[t.id,t.ref,t.externalRef].map(t=>String(t??'').trim().toLowerCase()).filter(Boolean),a=new Set(n);for(const t of n){const n=c[t]?t:f[t];n&&(a.add(n),a.add(c[n]))}return[...a]}const b='Swaps and cover stay in your department. Bar counts as front of house. A manager can still move a shift on the rota.',u='You can only swap with the people named for you. A manager can still move a shift on the rota.',p='\0unset',g=t=>t.replace(/\s*\(example\)$/,'').trim()},1090,[1091]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"fmtH",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"fmtHDay",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SHIFT_MIN_START",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SHIFT_MAX_END",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"shiftTitle",{enumerable:!0,get:function(){return f}});var t=r(d[0]);const n=t=>{const n=(Math.round(60*t)%1440+1440)%1440;return`${String(Math.floor(n/60)).padStart(2,'0')}:${String(n%60).padStart(2,'0')}`},u=t=>`${n(t)}${t>=24?' (next day)':''}`,o=7,c=28,f=(n,u)=>`${n.replace(' (example)','')} \xb7 ${(0,t.niceDate)((0,t.parseYmd)(u))}`},1091,[858]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.historyAccess=c,_e.lookupBookingDay=l,_e.useHistoricalBookingDay=function(t,o,u,y=0){const f=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),k=c(t),h=k&&(0,n.validPastDate)(o,u)?`${f}:${o}:${y}`:'',[p,v]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!h)return void v({key:'',data:null,error:''});let e=!0;return l(t,o).then(t=>{e&&v({key:h,data:t,error:''})}).catch(t=>{e&&v({key:h,data:null,error:t.message})}),()=>{e=!1}},[h,t,o]),{allowed:k,data:h&&p.key===h?p.data:null,error:h&&p.key===h?p.error:''}},_e.kitchenHistoryAccess=y,_e.lookupKitchenHistory=f,_e.useKitchenHistory=function(t,o,u,c,l=0){const k=(0,s.useSync)(e=>[e.kind,e.venueId,e.venueSlug,e.perms.join(',')].join(':')),h=y(t),p=h&&(0,n.validPastDate)(o,c)&&(0,n.validPastDate)(u,c)&&o<=u?`${k}:${o}:${u}:${l}`:'',[v,w]=(0,e.useState)({key:'',data:null,error:''});return(0,e.useEffect)(()=>{if(!p)return void w({key:'',data:null,error:''});let e=!0;return f(t,o,u).then(t=>{e&&w({key:p,data:t,error:''})}).catch(t=>{e&&w({key:p,data:null,error:t.message})}),()=>{e=!1}},[p,t,o,u]),{allowed:h,data:p&&v.key===p?v.data:null,error:p&&v.key===p?v.error:''}};var e=r(d[0]),t=r(d[1]),n=r(d[2]),o=r(d[3]),s=r(d[4]),u=r(d[5]);function c(e){const n=s.useSync.getState();return'owner'===t.APP_VARIANT&&'staff'===n.kind&&n.venueSlug===e&&!!n.venueId&&(n.perms.includes('*')||n.perms.includes('staff.manage'))}async function l(e,t){if(!c(e))throw new Error('Sign in to the Managers app with manager or owner access to Look back.');if(!(0,n.validPastDate)(t,(0,o.venueYmd)(new Date)))throw new Error('Choose an exact past date, with day, month and year.');const l=(0,u.getSupabase)(),{data:y,error:f}=await l.rpc('historical_booking_day',{p_venue:s.useSync.getState().venueId,p_date:t});if(f||!y||!Array.isArray(y.bookings))throw new Error('Booking history could not be loaded. Reconnect and try again.');return y}function y(e){const t=s.useSync.getState();return'staff'===t.kind&&t.venueSlug===e&&!!t.venueId&&['*','staff.manage','recipes.signoff','recipes.edit'].some(e=>t.perms.includes(e))}async function f(e,t,n){if(!y(e))throw new Error('Booking history needs the Head Chef app signed in to the venue.');const o=(0,u.getSupabase)(),{data:c,error:l}=await o.rpc('kitchen_booking_history',{p_venue:s.useSync.getState().venueId,p_from:t,p_to:n});if(l||!c||!Array.isArray(c.days))throw new Error('Booking history could not be loaded. Check the connection and try again.');return c}},1092,[34,872,1093,858,987,933]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HISTORY_NOTE",{enumerable:!0,get:function(){return o}}),e.validPastDate=n,Object.defineProperty(e,"ukHistoryDate",{enumerable:!0,get:function(){return s}}),e.parseHistoryInput=function(t){const o=t.trim();if(/^\d{4}-\d{2}-\d{2}$/.test(o))return o;const n=/^(\d{1,2})[\s/.-]+(\d{1,2})[\s/.-]+(\d{4})$/.exec(o);if(!n)return;const s=`${n[3]}-${n[2].padStart(2,'0')}-${n[1].padStart(2,'0')}`,d=new Date(s+'T12:00:00Z');return Number.isNaN(d.getTime())||d.toISOString().slice(0,10)!==s?void 0:s},e.exactHistoryDate=function(t,o){if(1!==(t.match(/\b(?:\d{4}-\d{2}-\d{2}|\d{1,2}\/\d{1,2}\/\d{4}|\d{1,2}(?:st|nd|rd|th)?\s+[a-z]+\s+\d{4})\b/gi)??[]).length)return;const s=t.match(/\b(\d{4}-\d{2}-\d{2})\b/);let d=s?.[1];if(!d){const o=t.match(/\b(\d{1,2})\/(\d{1,2})\/(\d{4})\b/);o&&(d=`${o[3]}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`)}if(!d){const o=t.toLowerCase().match(/\b(\d{1,2})(?:st|nd|rd|th)?\s+(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|jun|jul|aug|sep|sept|oct|nov|dec)\s+(\d{4})\b/),n=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];o&&(d=`${o[3]}-${String(n.indexOf(o[2].slice(0,3))+1).padStart(2,'0')}-${o[1].padStart(2,'0')}`)}return d&&n(d,o)?d:void 0},Object.defineProperty(e,"historyDateLabel",{enumerable:!0,get:function(){return d}}),e.bookingDayText=function(t){const n=`Booked covers on ${d(t.date)}: ${null===t.booked_covers?'not recorded':t.booked_covers}.`,s=t.bookings.map(t=>`${t.time??'Time not recorded'}: party size ${null===t.covers?'not recorded':`${t.covers} Covers`}; ${t.table?`table ${t.table}`:'table not recorded'}; ${t.status??'status not recorded'}${t.counted?'':', excluded from Booked covers'}.`);return[n,...s,t.historical_records?"Includes previous booking system history (incomplete).":'',o,t.bookings.length?'':'No booking records found; incomplete history does not prove there were no bookings.',t.missing_covers?`${t.missing_covers} booking records have no party size; left blank.`:''].filter(Boolean).join(' ')};const t='Includes previous booking system history (incomplete)',o='Recovered booking records, not confirmed attendance. Cancelled bookings are shown but excluded from Booked covers.';function n(t,o){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return!1;const n=new Date(t+'T12:00:00Z');return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t&&t{const[o,n,s]=t.split('-');return`${s}/${n}/${o}`};const d=t=>new Date(t+'T12:00:00Z').toLocaleDateString('en-GB',{day:'numeric',month:'long',year:'numeric',timeZone:'Europe/London'})},1093,[]); +__d(function(g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.shiftNow=k,e.useShiftReminders=function({rid:c,staffId:u,name:h,kitchen:b,onStartBreak:S}){const D=(0,t.useRef)(S);D.current=S;const v=(0,t.useRef)(h);v.current=h;const I=(0,s.useReminders)(t=>`${t.reminders.length}:${t.done.length}:${JSON.stringify(t.rules[c]??{})}:${t.reminders.map(t=>t.updatedAt??'').join()}`),w=(0,r.useOwner)(t=>`${t.attendance.length}:${t.shifts.length}:${t.leave.length}`);(0,t.useEffect)(()=>{s.useReminders.getState().ensure(c);const t=()=>{const t=f(),{att:h,shift:S,on:I}=k(u,t),w=s.useReminders.getState();if(!I||!u)return w.reminders.forEach(t=>(0,a.dismissNotice)(`rem:${t.id}`)),void(0,a.dismissNotice)('break-reminder');const $=(0,s.rulesOf)(c),R=h?.in?new Date(h.in).getTime():void 0,p=!!h?.breaks?.length,y=`break:${h?.id??S?.id??''}`,M=(0,o.breakDue)({now:t,clockIn:R,shiftStart:S?l(S.date,S.start):void 0,shiftEnd:S?l(S.date,S.end):void 0,rotaBreak:void 0!==S?.breakAt?l(S.date,S.breakAt):void 0,hadBreak:p,rules:$},w.snooze[y]??0);if(M){const r=R??(S?l(S.date,S.start):t);(0,a.notify)({id:'break-reminder',tone:3===M.stage?'warn':'normal',icon:'\ud83e\uded6',kicker:'BREAK REMINDER',testID:'break-reminder',timeoutMs:null,title:M.label,body:`${R?'Clocked in':'Shift started'} at ${m(r)}. ${3===M.stage?'':'Over 6 hours needs a 20-minute break.'}`.trim(),actions:[{label:'Start break',testID:'break-reminder-start',onPress:()=>{if(!h)return D.current?.(),void(0,a.notify)({id:'break-clock-first',title:'Clock in first, then tap Start break.',body:'Your break is started from the clock screen.',timeoutMs:6e3});const t=new Date(f()).toISOString();(0,n.clockAction)('break_start',{rid:c,staffId:u,date:t.slice(0,10),at:t}).then(t=>{t.ok||(0,a.notify)({id:'break-blocked',tone:'warn',title:'Break not started',body:t.message,timeoutMs:1e4}),D.current?.()})}},{label:'Later',kind:'ghost',testID:'break-reminder-later',onPress:()=>{s.useReminders.getState().setSnooze(y,f()+6e4*$.snoozeMins),(0,a.dismissNotice)('break-reminder')}}]})}else(0,a.dismissNotice)('break-reminder');const N=r.useOwner.getState().staff.find(t=>t.id===u),O=b??(0,d.inKitchen)(N);for(const n of w.reminders){if(n.rid!==c)continue;const r=`rem:${n.id}`;if(n.removed||!(0,o.audienceMatch)(n.audience,O)){(0,a.dismissNotice)(r);continue}const{due:d,forDate:m}=(0,o.reminderDue)(n,t),l=w.done.find(t=>t.reminderId===n.id&&t.forDate===m),k=`rem:${n.id}:${m}`;!d||l||(w.snooze[k]??0)>t?(0,a.dismissNotice)(r):(0,a.notify)({id:r,icon:'\ud83e\ude91',kicker:'REMINDER',title:n.text,testID:'venue-reminder',timeoutMs:null,body:`For everyone on shift${'all'===n.audience?'':'kitchen'===n.audience?' in the kitchen':' front of house'}. Tap Done once it\u2019s done.`,actions:[{label:'Done',testID:'venue-reminder-done',onPress:()=>s.useReminders.getState().markDone({rid:c,reminderId:n.id,forDate:m,at:new Date(f()).toISOString(),staffRef:u,staffName:v.current.replace(' (example)','')})},{label:'Later',kind:'ghost',onPress:()=>s.useReminders.getState().setSnooze(k,f()+6e4*$.snoozeMins)}]})}};t();const h=setInterval(t,2e4);return()=>clearInterval(h)},[c,u,I,w,b])};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),a=_r(_d[5]),d=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]);const f=()=>{try{return(0,c.nowFrom)(c.useStore.getState().clock).getTime()}catch{return Date.now()}},m=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=(t,n)=>{const[r,s,o]=t.split('-').map(Number);return new Date(r,s-1,o,Math.floor(n),Math.round(n%1*60)).getTime()};function k(t,n){const s=r.useOwner.getState(),a=(0,r.openShiftOf)(s.attendance,t,new Date(n)),d=(0,o.ukClock)(n).ymd,c=(0,u.workingShifts)(s.shifts,s.leave),f=c.find(r=>r.staffId===t&&r.date===d&&!1!==r.published&&l(r.date,r.start)<=n&&nn.staffId===t&&n.date===d&&!1!==n.published):void 0),m=!a&&!!f&&s.attendance.some(n=>n.staffId===t&&n.date===d&&!!n.out&&new Date(n.out).getTime()>=l(f.date,f.start));return{att:a,shift:f,on:!!a||!!f&&!m}}},1094,[34,1095,891,1009,1010,1001,1047,831,1098]); +__d(function(_g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.clockAction=async function(n,u){if((0,t.privateClockVenue)(u.rid)&&'in'!==n)return c(n,u,{action:n,at:u.at,inside:null,unchecked:!0});const f=(0,a.areaOf)(u.rid),k=f.on&&null!=f.lat&&null!=f.lng,l=k?await(u.fixFn??r.getFix)():'unavailable';if((0,t.privateClockVenue)(u.rid)&&'object'==typeof l&&(!Number.isFinite(l.acc)||l.acc>150))return{ok:!1,message:'Your phone\u2019s location is not accurate enough to confirm you are at the pub. Enable precise location, step near a window and try again, or ask a manager to record your clock-in with a reason.'};const g=k&&'object'!=typeof l?(0,s.locWhere)():'browser',p=(0,o.gate)(f,n,k?l:'unavailable',u.at,g);if(!p.allowed){const a='object'==typeof l?void 0:'app'===g&&'denied'===l?'settings':'app-phone-off'===g?'location':'app-old'===g&&'denied'===l?'update':void 0;return'update'===a&&(0,s.checkAppUpdate)(),{ok:!1,message:(p.message??'You need to be at the venue.')+((0,t.privateClockVenue)(u.rid)?' Ask a manager to record your clock-in with a reason using Record it for someone.':''),fix:a}}const w=c(n,u,p.geo);return w.ok&&p.warn?{...w,warn:p.warn}:w},e.managerClockAction=function(t,a,r,s){const u=(0,o.overrideGeo)(t,a.at,r,s);if(!u)return{ok:!1,message:'Type a short reason (at least 3 letters).'};const f=n.useOwner.getState().staff.find(t=>t.id===a.staffId)?.name??'staff',k=c(t,a,u,{adjusted:{by:r.name,at:a.at,reason:u.override.reason}});if(k.ok){const o={in:'clocked in',out:'clocked out',break_start:'started a break for',break_end:'ended a break for'}[t],s=`${r.name} ${o} ${f} (manager, no location check): ${u.override.reason}`;n.useOwner.setState(t=>({attLog:[{id:`al-${Date.now().toString(36)}`,at:a.at,text:s},...t.attLog]}))}return k};var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),o=_r(d[3]),r=_r(d[4]),s=_r(d[5]);function c(a,o,r,s={}){const c=(0,t.venueClockGeo)(o.rid,r),u=c?!1!==c.inside:void 0,f=n.useOwner.getState(),k=(0,n.openShiftOf)(f.attendance,o.staffId,o.at);if('in'===a){if(k)return{ok:!1,message:'You\u2019re already clocked in.'};f.clock(o.staffId,o.date,'in',o.at,u);const t=(0,n.openShiftOf)(n.useOwner.getState().attendance,o.staffId,o.at);return t&&n.useOwner.getState().patchAttendance(t.id,{...o.offRota?{offRota:!0}:{},...s},c),{ok:!0,att:t&&n.useOwner.getState().attendance.find(a=>a.id===t.id)}}if(!k)return{ok:!1,message:'You\u2019re not clocked in.'};if('out'===a){let t=o.breakMins;if(o.addedBreak&&o.addedBreak>0&&!k.breaks?.length){const a=new Date(o.at).getTime(),r=new Date(Math.max(new Date(k.in).getTime(),a-6e4*o.addedBreak)).toISOString();n.useOwner.getState().patchAttendance(k.id,{breaks:[{start:r,end:o.at}],breakAddedAtClockOut:o.addedBreak}),t=Math.round((a-new Date(r).getTime())/6e4)}return n.useOwner.getState().clock(o.staffId,o.date,'out',o.at,u,t),n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}}return n.useOwner.getState().breakToggle(o.staffId,'break_start'===a?'start':'end',o.at)?(n.useOwner.getState().patchAttendance(k.id,s,c),{ok:!0,att:n.useOwner.getState().attendance.find(t=>t.id===k.id)}):{ok:!1,message:'break_start'===a?'You\u2019re already on a break.':'You\u2019re not on a break.'}}},1095,[997,1042,891,998,1096,1097]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getFix=function(e=1e4){const t='undefined'!=typeof navigator?navigator.geolocation:void 0;return t?new Promise(o=>{let n=!1;const c=e=>{n||(n=!0,o(e))},u=setTimeout(()=>c('timeout'),e+1500);try{t.getCurrentPosition(e=>{clearTimeout(u),c({lat:e.coords.latitude,lng:e.coords.longitude,acc:e.coords.accuracy??999})},e=>{clearTimeout(u),c(1===e.code?'denied':3===e.code?'timeout':'unavailable')},{enableHighAccuracy:!0,timeout:e,maximumAge:0})}catch{clearTimeout(u),c('unsupported')}}):Promise.resolve('unsupported')},_e.locationAllowed=async function(){try{const e=await(navigator.permissions?.query({name:'geolocation'}));return'granted'===e?.state}catch{return!1}}},1096,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"inPhoneApp",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"canOpenAppSettings",{enumerable:!0,get:function(){return c}}),e.openAppSettings=function(){try{t()?.openSettings?.()}catch{}},e.openLocationSettings=function(){try{t()?.openLocationSettings?.()}catch{}},e.appLocationPermission=function(){try{return t()?.locationPermission?.()??null}catch{return null}},e.phoneLocationOn=p,e.checkAppUpdate=function(){try{t()?.checkUpdate?.()}catch{}},e.locWhere=function(){if(!o()){const t=String(n()?.navigator?.userAgent??'');return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&(n()?.navigator?.maxTouchPoints??0)>1?'iphone':'browser'}return c()?p()?'app':'app-phone-off':'app-old'};const n=()=>'undefined'!=typeof window?window:void 0,t=()=>{const t=n()?.CoverChargeNative;return t&&'object'==typeof t?t:null},o=()=>/CoverChargePhone\//.test(String(n()?.navigator?.userAgent??'')),c=()=>'function'==typeof t()?.openSettings;function p(){try{const n=t()?.locationOn?.();return!1!==n}catch{return!0}}},1097,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n,o){if(t&&t.length&&o)return t.find(t=>t.staffId===n&&'approved'===t.status&&t.from<=o&&o<=t.to)}Object.defineProperty(e,'__esModule',{value:!0}),e.leaveCovering=t,Object.defineProperty(e,"coveredByLeave",{enumerable:!0,get:function(){return n}}),e.workingShifts=function(t,o){return o&&o.length?t.filter(t=>!n(o,t)):t},e.leaveLabel=function(t){return/sick|ill/i.test(t?.reason??'')?'Off sick':'On holiday'},e.leaveNote=function(t){return['Approved time off',t.reason&&'Holiday'!==t.reason?t.reason:'',t.decidedBy?`approved by ${t.decidedBy.replace(' (example)','')}`:''].filter(Boolean).join(' \xb7 ')};const n=(n,o)=>!!t(n,o.staffId,o.date)},1098,[]); +__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:p,big:x,sound:$,testID:v="covers-today",day:j,compact:C=!1,snug:w=!1,tight:T=!1,aside:k}){const D=(0,c.useBookings)(e),S=(0,c.useNow)(3e4),I=(0,h.venueYmd)(S),L=j&&j!==I?j:I,_=L!==I,M=(0,u.coversFour)(D,L),R=(0,y.dayWord)(L,I),z=/^(Today|Yesterday|Tomorrow)$/.test(R),O=`COVERS ${R.toUpperCase()}`,P=_?`${z?`${R}\u2019s`:R} bookings \u203a`:'Today\u2019s bookings \u203a',W=_?`${z?`${R}, `:''}${(0,y.dayLong)(L)}`:'today',E=(0,o.useLiveState)();if('ready'!==E)return(0,f.jsx)(o.LiveWait,{state:E,title:"Covers today",testID:`${v}-wait`});const F=x?64:T?28:w?36:44,V=M.total?Math.min(1,M.done/M.total):0,Y=(e,o,t,c)=>(0,f.jsxs)(s.default,{style:{flex:1,alignItems:'center',gap:T?2:w?4:6,minWidth:0},children:[(0,f.jsx)(l.SplitFlap,{value:o,height:F,colour:t,testID:`covers-${c}`,sound:$}),(0,f.jsx)(n.T,{size:T?11:x||C?14:12,weight:"semibold",colour:b.colours.muted,numberOfLines:1,center:C||T,style:{letterSpacing:.4},children:e})]});return(0,f.jsxs)(t.default,{testID:v,dataSet:{centreExempt:'dashboard-card'},accessibilityRole:"button",disabled:!p,onPress:p,accessibilityLabel:`Covers ${W}: ${M.done} done, ${M.seated} seated, ${M.toCome} to come, ${M.total} total.${p?` Opens ${_?'that day\u2019s':'today\u2019s'} bookings.`:''}`,style:({pressed:e})=>({backgroundColor:e?b.colours.tilePressed:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:T?6:16,...w&&!T?{paddingVertical:8,paddingHorizontal:10}:null,gap:T?4:w?8:12}),children:[T?null:(0,f.jsxs)(s.default,{style:{flexDirection:C?'column':'row',justifyContent:'space-between',alignItems:'center',gap:C?w?2:6:void 0},children:[(0,f.jsx)(n.T,{center:C,size:C?16:12,weight:"semibold",colour:b.colours.goldMuted,style:{letterSpacing:1.6},children:O}),p?(0,f.jsx)(n.T,{center:C,size:C?14:12,colour:b.colours.muted,children:P}):null]}),(0,f.jsxs)(s.default,{style:{flexDirection:'row',gap:8},children:[Y('Done',M.done,b.colours.text,'done'),Y('Seated',M.seated,b.colours.text,'seated'),Y('To come',M.toCome,b.colours.text,'tocome'),Y('Total',M.total,b.colours.goldLight,'total')]}),T?null:(0,f.jsx)(s.default,{style:{height:4,borderRadius:2,backgroundColor:'rgba(255,255,255,0.06)',overflow:'hidden'},children:(0,f.jsx)(s.default,{style:{width:`${Math.round(100*V)}%`,height:4,backgroundColor:b.colours.gold,borderRadius:2}})})]})},r(d[0]);var o=r(d[1]),t=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),n=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),y=r(d[9]),b=r(d[10]),f=r(d[11])},1099,[34,986,402,102,1100,794,874,1101,858,1102,821,25]); +__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)'}})]})}},1100,[34,281,283,364,102,1048,821,25]); +__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 r}}),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,n,r){const o={};for(const i of t)if(i.date===n)for(const t of i.holds??[])if(t.served)for(const[n,a]of Object.entries(s({...i,holds:[{...t,served:void 0}]},r)))o[n]=(o[n]??0)+a;return o},e.heldSummary=function(t,n,o){const i={},s={};for(const o of t)if(o.date===n&&r(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,n)=>t+n,0),byItem:i,single:s,stock:a(t,n,o)}},e.holdsText=function(t,n,r){return(t.holds??[]).filter(t=>t.qty>0).map(t=>`${'item'===t.kind?c(n.find(n=>n.id===t.id)?.name??'Reserved item'):r.find(n=>n.key===t.id)?.name??t.id} x${t.qty}${t.served?' (served)':''}`).join(', ')},Object.defineProperty(e,"shortItem",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"needsAllergenSeen",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"needsHoldOk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasAllergens",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"allergenText",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"dogCount",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"hasAccess",{enumerable:!0,get:function(){return y}}),e.accessText=function(t){const n=t.access;return n?[n.wheelchair?`${n.wheelchair} wheelchair user${1===n.wheelchair?'':'s'}`:'',n.stepFree?'step-free access':'',n.toilet?'accessible toilet':'',n.assistDog?'assistance dog':'',n.note?.trim()??''].filter(Boolean).join(', '):''},Object.defineProperty(e,"dietText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"accessibleSetUp",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"dogSetUp",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"isAccessible",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isDogOk",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"dogsAt",{enumerable:!0,get:function(){return k}}),e.tableBlockReason=function(t,r,o,i,s){const a=t.tables.find(t=>t.name===r);return a?a.maxSeats0&&O(t)&&!(0,n.tableDogOk)(t,a)?'No dogs here':s&&h(t)&&!a.accessible?'Not step-free':'':'Not available'},Object.defineProperty(e,"holidayName",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"coverDone",{enumerable:!0,get:function(){return S}}),e.shownStatus=w,Object.defineProperty(e,"isWalkInBooking",{enumerable:!0,get:function(){return $}}),e.partiesLine=function(t){const n=t.filter(r),o=n.filter(t=>!$(t)).length,i=n.length-o;return`${o} ${1===o?'booking':'bookings'} \xb7 ${i} ${1===i?'walk-in':'walk-ins'}`},Object.defineProperty(e,"COVERS_FOUR_LABELS",{enumerable:!0,get:function(){return A}}),e.coversFour=N,e.coversCard=function(t,n,o){const i=t.filter(t=>t.date===n&&r(t)),s=t=>t.reduce((t,n)=>t+(n.partySize||0),0);return{...N(t,n),booked:s(i.filter(t=>!$(t))),walkIns:s(i.filter($))}},e.coversToday=function(t,n){return N(t,n)};var t=_r(_d[0]),n=_r(_d[1]);const r=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,n,r=!1){const o={};for(const i of t.holds??[])if(!i.served||r)if('stock'===i.kind)o[i.id]=(o[i.id]??0)+i.qty;else for(const t of n.find(t=>t.id===i.id)?.uses??[])o[t.key]=(o[t.key]??0)+t.qty*i.qty;return o}function a(t,n,o,i){const a={};for(const c of t)if(c.date===n&&r(c)&&'finished'!==c.status&&c.id!==i)for(const[t,n]of Object.entries(s(c,o)))a[t]=(a[t]??0)+n;return a}const c=t=>/platter/i.test(t)?'Platter':t.replace(/ for \d+$/i,''),l=t=>r(t)&&(t.allergies.length>0||!!t.allergyNote?.trim())&&!t.allergyAck,d=t=>r(t)&&(t.holds??[]).some(t=>t.qty>0&&!t.served)&&!t.holdOk,u=t=>t.allergies.length>0||!!t.allergyNote?.trim(),f=n=>[n.allergies.map(n=>(0,t.allergenLabel)(n.allergen)).join(', '),n.allergyNote?.trim()].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''),b=t=>t.dogs??(t.dog?1:0),y=t=>!(!t.access||!(t.access.wheelchair||t.access.stepFree||t.access.toilet||t.access.assistDog||t.access.note?.trim()));const p=t=>[t.diet?.vegan?`${t.diet.vegan} vegan`:'',t.diet?.vegetarian?`${t.diet.vegetarian} vegetarian`:''].filter(Boolean).join(', '),h=t=>t.tables.some(t=>t.accessible),O=t=>t.tables.some(t=>void 0!==t.dogOk)||t.areas.some(t=>t.dogs),v=(t,n)=>n.split('+').every(n=>!!t.tables.find(t=>t.name===n.trim())?.accessible),j=(t,r)=>r.split('+').every(r=>{const o=t.tables.find(t=>t.name===r.trim());return!!o&&(0,n.tableDogOk)(t,o)}),k=(t,n,o,i)=>t.filter(t=>t.id!==i&&t.date===n&&t.time===o&&r(t)).reduce((t,n)=>t+b(n),0);const P=t=>t.replace(/\s*\(substitute day\)/gi,'').trim(),S=t=>'finished'===t.status;function w(t){if('seated'===t.status&&t.seatedAt){const n=new Date(t.seatedAt);if((isNaN(n.getTime())?t.date:n.toLocaleDateString('en-CA',{timeZone:'Europe/London'}))!!t.walkIn||'walk-in'===t.source;const A=['Done','Seated','To come','Total'];function N(t,n){const o=t.filter(t=>t.date===n&&r(t)),i=t=>t.reduce((t,n)=>t+(n.partySize||0),0),s=i(o.filter(S)),a=i(o.filter(t=>!S(t)&&'seated'===w(t))),c=i(o.filter(t=>!$(t)&&['confirmed','pending'].includes(w(t))));return{done:s,seated:a,toCome:c,total:s+a+c}}},1101,[861,859]); +__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,"DAY_BACK",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"DAY_AHEAD",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"DAY_IDLE_MS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"dayOffset",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"shiftDay",{enumerable:!0,get:function(){return h}}),_e.dayWord=p,Object.defineProperty(_e,"dayLong",{enumerable:!0,get:function(){return x}}),_e.bookingsForDay=function(e,t,o){return e.filter(e=>e.date===t&&(0,s.ACTIVE)(e))},_e.dayCovers=function(e,t,o){return(0,s.coversFour)(e,t)},_e.DaySwitch=function({day:e,today:s,onDay:y,back:$=u,ahead:D=b,idPrefix:j="display-day",stacked:P=!1,header:w=!1}){const C=f(e,s),T=t=>{const o=h(e,t);y(o===s?null:o)},v=h(e,-1),I=h(e,1),Y=0!==C,k=(e,o,s,l,u)=>(0,c.jsx)(t.default,{testID:u,accessibilityRole:"button",accessibilityLabel:o,accessibilityState:{disabled:l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:44,minWidth:w?44:P?140:92,flex:P?1:void 0,paddingHorizontal:w?8:P?6:12,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:d.colours.hairline,opacity:l?.35:1,backgroundColor:e?d.colours.tilePressed:'rgba(255,255,255,0.03)'}),children:(0,c.jsx)(n.T,{center:P,size:P?16:14,weight:"semibold",colour:d.colours.goldLight,numberOfLines:P?void 0:1,children:e})}),L=p(e,s);return P?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1,borderColor:Y?d.colours.gold:d.colours.hairline,backgroundColor:Y?d.colours.goldTint:d.colours.surface},children:[(0,c.jsxs)(o.default,{testID:`${j}-label`,accessible:!0,accessibilityRole:"header",accessibilityLabel:`Showing ${L}, ${x(e)}`,style:{gap:2,alignItems:'center'},children:[(0,c.jsx)(n.T,{center:!0,size:20,weight:"semibold",colour:d.colours.goldLight,children:L}),(0,c.jsx)(n.T,{center:!0,size:16,children:x(e)})]}),(0,c.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),k('Today','Back to today',()=>y(null),!1,'back-to-today'),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})]}):w?(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,flexShrink:1,minWidth:0},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsx)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({minWidth:72,maxWidth:220,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:8,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:(0,c.jsx)(n.T,{size:14,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L})}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]}):(0,c.jsxs)(o.default,{testID:`${j}-switch`,style:{flexDirection:'row',alignItems:'center',gap:8},children:[k('\u2039 Previous',`Previous day, ${x(v)}`,()=>T(-1),C<=-$,`${j}-prev`),(0,c.jsxs)(t.default,{testID:`${j}-label`,accessibilityRole:Y?'button':'text',disabled:!Y,onPress:()=>y(null),accessibilityLabel:Y?`Showing ${L===(0,l.niceDate)((0,l.parseYmd)(e))?'':`${L}, `}${x(e)}. Back to today`:`Showing today, ${x(e)}`,style:({pressed:e})=>({flex:1,minWidth:0,minHeight:44,borderRadius:12,alignItems:'center',justifyContent:'center',paddingHorizontal:6,borderWidth:Y?1:0,borderColor:d.colours.gold,backgroundColor:e?d.colours.tilePressed:Y?d.colours.goldTint:'transparent'}),children:[(0,c.jsx)(n.T,{size:15,weight:"semibold",colour:Y?d.colours.gold:d.colours.text,numberOfLines:1,children:Y&&L!==(0,l.niceDate)((0,l.parseYmd)(e))?`${L} \xb7 ${(0,l.niceDate)((0,l.parseYmd)(e))}`:L}),Y?(0,c.jsx)(n.T,{size:11,colour:d.colours.muted,numberOfLines:1,children:"Tap for today"}):null]}),k('Next \u203a',`Next day, ${x(I)}`,()=>T(1),C>=D,`${j}-next`)]})},r(_d[0]);var t=e(r(_d[1])),o=e(r(_d[2])),n=r(_d[3]),s=r(_d[4]),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]);const u=365,b=365,y=12e4,f=(e,t)=>Math.round(((0,l.parseYmd)(e).getTime()-(0,l.parseYmd)(t).getTime())/864e5),h=(e,t)=>(0,l.ymd)((0,l.addMins)((0,l.parseYmd)(e),1440*t+120));function p(e,t){const o=f(e,t);return 0===o?'Today':-1===o?'Yesterday':1===o?'Tomorrow':(0,l.niceDate)((0,l.parseYmd)(e))}const x=e=>(0,l.parseYmd)(e).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},1102,[34,402,102,794,1101,858,821,25]); +__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 T=new Date(`${h}T${b.time}:00`),p=Math.round((T.getTime()-o.getTime())/6e4),_=$[0],j=_?`${_.title}${_.time?` from ${(0,s.fmt12)(_.time)}`:''}`:'';if(p>90&&!_)return null;if(p<-60)return null;const w=p>=0&&p<=15,x=p<0,D=w?n.colours.redBg:x?n.colours.surface2:n.colours.goldTint,F=w?n.colours.red:x?n.colours.hairline:n.colours.accentBorder,M=w?'#FFD9D4':x?n.colours.muted:n.colours.goldLight,y=c?1.3:1,B=x?`Kitchen closed for food \xb7 last orders were ${(0,s.fmt12)(b.time)}`:w?`Last food orders in ${Math.max(0,p)} min (${(0,s.fmt12)(b.time)})`:`Last food orders ${(0,s.fmt12)(b.time)}`;return(0,d.jsxs)(t.default,{testID:w?'last-food-warning':'last-food-banner',accessibilityRole:"text",style:{borderRadius:14,borderWidth:w?2:1,borderColor:F,backgroundColor:D,paddingVertical:10*y,paddingHorizontal:14,gap:2},children:[(0,d.jsxs)(r.T,{size:17*y,weight:"bold",colour:M,children:[w?'\u23f0 ':'\ud83c\udf7d ',B]}),j||'kitchen closes'!==b.reason?(0,d.jsx)(r.T,{size:13*y,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')}`},1103,[34,102,794,874,877,821,25]); +__d(function(_g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useNextFree=j,_e.NextTableFreeCard=function({rid:e,now:s,big:r,always:d}){const u=(0,n.useRestaurant)(e),c=j(e,s);if(!u||!c||!(0,h.nextTableOn)(u))return null;if(!c.full&&!d)return null;const T=c.list.slice(0,3),w=c.waitFor(2),p=c.waitFor(4),y=(0,h.lastFoodOn)(u,x(s)),M=r?1.25:1,F=(e,r)=>(0,g.jsxs)(l.default,{style:{flex:1,borderRadius:12,borderWidth:1,borderColor:f.colours.hairline,backgroundColor:f.colours.tile,padding:10},testID:`wait-for-${e}`,children:[(0,g.jsxs)(o.Muted,{children:["Wait for ",e]}),(0,g.jsx)(o.T,{size:20*M,weight:"bold",colour:f.colours.goldLight,children:r?`About ${Math.max(5,Math.round((r.at.getTime()-s.getTime())/6e4))} min`:'\u2014'}),(0,g.jsx)(o.Muted,{children:r?`${(0,t.tableNumbers)(r.table)} \xb7 ${r.confidence}`:'nothing due yet'})]});return(0,g.jsxs)(l.default,{testID:"next-table-free",accessibilityRole:"summary",style:{borderRadius:16,borderWidth:1,borderColor:f.colours.accentBorder,backgroundColor:f.colours.surface,padding:14,gap:8},children:[(0,g.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,g.jsx)(o.T,{size:12,weight:"semibold",colour:f.colours.goldMuted,style:{letterSpacing:1.4},children:c.full?'FULL \xb7 NEXT TABLE FREE':'NEXT TABLE FREE'}),(0,g.jsx)(o.Badge,{kind:"amber",label:"ESTIMATE"})]}),T.length?(0,g.jsxs)(o.T,{size:22*M,weight:"bold",children:["About ",(0,b.hhmm)(T[0].at)," ",(0,g.jsxs)(o.T,{size:16*M,colour:f.colours.muted,children:["(",(0,t.tableNumbers)(T[0].table),", ",T[0].seats," seats \xb7 ",T[0].confidence,")"]})]}):(0,g.jsx)(o.T,{size:18*M,weight:"semibold",children:c.freeNow.length?`Free now: ${c.freeNow.map(e=>`${(0,t.tableNumbers)(e)}`).join(', ')}`:'No table due to free up before its next booking'}),T.slice(1).map(e=>(0,g.jsxs)(o.Muted,{children:["Then about ",(0,b.hhmm)(e.at)," \xb7 ",(0,t.tableNumbers)(e.table)," (",e.seats," seats) \xb7 ",e.confidence," \xb7 ",e.why]},e.table)),T[0]?(0,g.jsxs)(o.Muted,{children:[(0,t.tableNumbers)(T[0].table),": ",T[0].why,"."]}):null,(0,g.jsxs)(o.Row,{gap:8,children:[F(2,w),F(4,p)]}),T.some(e=>e.drinksOnly)&&y?(0,g.jsxs)(o.T,{size:13,colour:f.colours.amber,children:["After last food orders (",(0,h.fmt12)(y.time),") a table is for drinks only."]}):null,(0,g.jsx)(o.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=_r(_d[2]),l=(e=r)&&e.__esModule?e:{default:e},o=_r(_d[3]),n=_r(_d[4]),d=_r(_d[5]),u=_r(_d[6]),c=_r(_d[7]),b=_r(_d[8]),h=_r(_d[9]),f=_r(_d[10]),g=_r(_d[11]);const x=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,'0')}-${String(e.getDate()).padStart(2,'0')}`,T=e=>(0,b.hhmm)(e);function j(e,t){const r=(0,n.useRestaurant)(e),l=(0,u.usePlan)(e),o=(0,n.useBookings)(e),h=(0,n.useOrders)(e),f=(0,u.useFloor)(t=>t.live[e]),g=(0,d.useBlocks)(e=>e.blocks),j=t.getTime()/6e4|0;return(0,s.useMemo)(()=>{if(!r)return null;const s=x(t),n=(0,d.closedAreasAt)(g,e,s,T(t)),u=(0,c.floorView)(l,o,h,f??{},t,r.settings.turnMins,n);return(0,b.nextTablesFree)(r,u,o.filter(e=>e.date===s),t,o)},[r,l,o,h,f,g,j])}},1104,[860,34,102,794,874,1026,1029,1105,1106,877,821,25]); +__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 o}}),Object.defineProperty(e,"STAGE_LABEL",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"turnFor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"startOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"durOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"endOf",{enumerable:!0,get:function(){return f}}),e.clashes=function(a,s=90){const n=new Set,l=a.filter(t=>g(t)&&t.table);for(let a=0;a(0,t.tablesOf)(d.table).includes(a))&&(u(i)t.date===n&&!['cancelled','noshow'].includes(t.status)).sort((t,a)=>t.time.localeCompare(a.time));for(const s of a.tables){const a=o.filter(a=>(0,t.tablesOf)(a.table).includes(s.name)),n=a[0],i=(0,t.tablesOf)(n?.table);l[s.name]={table:s,status:n?'soon':'free',next:n,covers:n?.partySize??0,dayBookings:a.length?a:void 0,group:i.length>1?i:void 0,allergy:!(!n?.allergies?.length&&!n?.allergyNote),vip:n?.tags?.find(t=>'VIP'===t)??n?.tags?.find(t=>'Regular'===t),occasion:n?.occasion??h(n?.notes)}}return l},e.floorView=function(a,n,l,o,i,d=90,c){const b={},g=n.filter(t=>t.date===O(i));for(const n of a.tables){const a=o[n.name]??{},y=g.filter(a=>(0,t.tablesOf)(a.table).includes(n.name)),O=y.find(t=>'seated'===(0,s.shownStatus)(t)),v=y.filter(t=>'confirmed'===t.status).sort((t,a)=>t.time.localeCompare(a.time)).find(t=>S(i,t)>=-20),T=v?Math.round(S(i,v)):void 0,F=O?void 0:p(y,i,d),w=l.find(t=>'table'===t.type&&t.tableNo===n.name&&!['closed','cancelled','collected'].includes(t.status));let j='free';a.blocked?j='blocked':O?j=a.stage??'seated':!c?.has(n.areaId)&&!c?.has(`tbl:${n.name}`)||w?a.dirty?j='dirty':w?j=a.stage??'seated':v&&(j='soon'):j='blocked';const A=O,P=A?.tags?.find(t=>'VIP'===t)??A?.tags?.find(t=>'Regular'===t)??(A?void 0:v?.tags?.[0]);b[n.name]={table:n,status:j,booking:A,next:v,due:F,nextIn:T,covers:A?.partySize??0,group:(()=>{const a=(0,t.tablesOf)((A??('soon'===j?v:void 0))?.table);return a.length>1?a:void 0})(),orderOnly:!A&&!!w,note:a.note,seatedMins:A?Math.max(0,Math.round((i.getTime()-u(A).getTime())/6e4)):void 0,freeAt:A?f(A,d):void 0,allergy:!!(A?.allergies?.length||A?.allergyNote||!A&&(v?.allergies?.length||v?.allergyNote)||w?.allergies?.length),vip:P,occasion:A?.occasion??(A?void 0:v?.occasion??h(v?.notes))??h(A?.notes)}}return b},e.dueOnTable=p,Object.defineProperty(e,"OCCASION_ICON",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"tableAllowed",{enumerable:!0,get:function(){return v}}),e.suggestTable=function(s,n,l,o,i,d,c=90,b,p){const h=[...s.tables.map(t=>({name:t.name,seats:t.maxSeats,min:t.minSeats,parts:[t.name]})),...s.joins.map(t=>{const a=s.tables.filter(a=>t.tables.includes(a.name));return{name:t.tables.join('+'),seats:a.reduce((t,a)=>t+a.maxSeats,0),min:a.reduce((t,a)=>t+a.minSeats,0),parts:t.tables}})].filter(t=>t.parts.every(t=>v(s,t,p))),y=i.getTime()+6e4*d,S=new Set((0,a.bestTables)(s));let O=null;for(const a of h){if(a.seats['blocked'].includes(l[t]?.status)))continue;const s=!!l&&a.parts.some(t=>['seated','mains','dessert','bill','dirty'].includes(l[t]?.status)),d=n.filter(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()i.getTime()).length,p=1===a.parts.length&&S.has(a.parts[0])?12:0,h=(s?1e3:0)+100*d+10*(a.seats-o)+(o({name:t.name,seats:t.maxSeats,parts:[t.name]})),...s.joins.map(t=>({name:t.tables.join('+'),seats:s.tables.filter(a=>t.tables.includes(a.name)).reduce((t,a)=>t+a.maxSeats,0),parts:t.tables}))].filter(t=>t.seats>=l&&t.parts.every(t=>v(s,t,c))).filter(a=>!n.some(s=>s.id!==b&&g(s)&&(0,t.tablesOf)(s.table).some(t=>a.parts.includes(t))&&u(s).getTime()o.getTime())),y=new Set((0,a.bestTables)(s)),S=t=>1===t.parts.length&&y.has(t.parts[0])?0:1;return h.sort((t,a)=>t.seats-a.seats||t.parts.length-a.parts.length||S(t)-S(a)).map(t=>({table:t.name,seats:t.seats,area:s.areas.find(a=>a.id===s.tables.find(a=>a.name===t.parts[0])?.areaId)?.name??''}))};var t=r(_d[0]),a=r(_d[1]),s=r(_d[2]);const n={colour:'#3A2F1E',fg:'#F1DDB0'},l={colour:'#CFA45F',fg:'#0B0B0B'},o={free:{label:'Free',...n},soon:{label:'Booked later',colour:'#9A3050',fg:'#FFF6F0'},seated:{label:'Seated',...l},mains:{label:'Seated',...l},dessert:{label:'Seated',...l},bill:{label:'Seated',...l},dirty:{label:'Needs clearing',colour:'#6E6555',fg:'#FFFFFF'},blocked:{label:'Blocked',...n}},i={seated:'Seated',mains:'Mains',dessert:'Dessert',bill:'Bill requested'},d=['seated','mains','dessert','bill'],c=(t,a=90)=>Math.min(a+60,a+15*Math.max(0,Math.ceil((t-2)/2))),u=t=>'seated'===(0,s.shownStatus)(t)&&t.seatedAt?new Date(t.seatedAt):new Date(`${t.date}T${t.time}:00`),b=(t,a=90)=>t.durationMins??c(t.partySize,a),f=(t,a=90)=>new Date(u(t).getTime()+6e4*b(t,a)),g=t=>!['cancelled','noshow','finished'].includes(t.status);function p(t,a,s=90){return t.filter(t=>'confirmed'===t.status&&S(a,t)<=45&&-S(a,t)t.time.localeCompare(a.time))[0]}const h=t=>t?/birthday/i.test(t)?'birthday':/anniversary/i.test(t)?'anniversary':void 0:void 0,y={birthday:'\ud83c\udf82',anniversary:'\ud83d\udc9d',celebration:'\ud83e\udd42'},S=(t,a)=>(new Date(`${a.date}T${a.time}:00`).getTime()-t.getTime())/6e4,O=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,v=(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)&&!s?.closed?.has(`tbl:${n.name}`))}},1105,[1029,859,1101]); +__d(function(_g,_r,i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.nextTablesFree=function(t,r,o,l,u=[]){const m=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,'0')}-${String(l.getDate()).padStart(2,'0')}`,f=(0,a.lastFoodOn)(t,m),d=f?new Date(`${m}T${f.time}:00`):null,b=t=>o.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>=s(l,-20)).sort((t,a)=>t.getTime()-a.getTime())[0],c=[],g=[];for(const o of Object.values(r)){const r=o.table.name,m=b(r);if('free'===o.status){(!m||m>s(l,60))&&c.push(r);continue}if(!n.includes(o.status)||!o.booking)continue;const f=o.booking,h=f.seatedAt?new Date(f.seatedAt):new Date(`${f.date}T${f.time}:00`),$=(0,a.dwellFor)(t,f.partySize,u);let w=s(h,$.mins),T='maybe',p=`seated ${Math.max(0,Math.round((l.getTime()-h.getTime())/6e4))} min, usual ${$.mins} min`;'bill'===o.status?(w=s(l,10),T='likely',p='bill requested'):'dessert'===o.status?(w=new Date(Math.min(w.getTime(),s(l,25).getTime())),T='likely',p='on dessert'):'mains'===o.status&&(w=new Date(Math.min(Math.max(w.getTime(),s(l,35).getTime()),s(l,60).getTime())),p='mains out'),w=d?{drinksOnly:!0}:{}})}g.sort((t,a)=>t.at.getTime()-a.at.getTime());const h=Object.values(r).filter(t=>'blocked'!==t.status).length,$=h>0&&c.length<=Math.max(1,Math.round(.1*h));return{full:$,freeNow:c,list:g,waitFor:t=>g.find(a=>a.seats>=t)??null}},Object.defineProperty(e,"hhmm",{enumerable:!0,get:function(){return r}}),e.nextFreeSentence=function(a,n){if(a.freeNow.length&&!a.full)return`There are ${a.freeNow.length} tables free now: ${a.freeNow.slice(0,4).map(t=>`table ${t}`).join(', ')}.`;const s=a.list[0];if(!s)return a.freeNow.length?`${(0,t.tableNumbers)(a.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((s.at.getTime()-n.getTime())/6e4)),l=a.waitFor(2),u=a.waitFor(4);return`Next table free about ${r(s.at)} (table ${s.table}, ${s.seats} seats), ${s.confidence}, in about ${o} minutes.${l?` A table for 2: about ${r(l.at)}.`:''}${u?` A table for 4: about ${r(u.at)}.`:''}${s.drinksOnly?' That\u2019s after last food orders, so drinks only.':''}`};var t=_r(_d[0]),a=_r(_d[1]);const n=['seated','mains','dessert','bill'],s=(t,a)=>new Date(t.getTime()+6e4*a);const r=t=>`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},1106,[860,877]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenBar=p,_e.NeedsPills=k,_e.BookingNeeds=x,Object.defineProperty(_e,"needsIcons",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"confirmHolds",{enumerable:!0,get:function(){return S}}),_e.serveHolds=y,_e.postNewBookingToKitchen=function(e,t){if(!t||'system'===t)return;const s=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),l=[],r=`${e.name}, ${(0,c.niceDate)((0,c.parseYmd)(e.date)).slice(0,3)} ${e.time}${e.table?`, table ${e.table}`:''}`;if((e.holds??[]).filter(e=>e.qty>0).length){const t=I(e.restaurantId);l.push(`${(0,u.holdsText)(e,(0,u.reservablesOf)(s),t)} reserved: ${r}. Tap Platter OK in the Head Chef app.`)}(0,u.hasAllergens)(e)&&l.push(`\u26a0\ufe0f Allergens: ${(0,u.allergenText)(e)} \u2014 ${r}. Please sign \u2018Allergens seen\u2019.`);if(!l.length)return;a.useOwner.getState().chatSend({ch:'kitchen',from:t,text:l.join('\n'),at:(new Date).toISOString()})},_e.useKitchenTodo=D,_e.KitchenSignoffs=function({rid:t,today:s,by:a,app:f,canConfirm:p=!0,showAll:k}){const j=D(t,s),I=(0,o.useBookings)(t),T=(0,o.useRestaurant)(t),O=(0,n.useStockItems)(t),$=(0,u.reservablesOf)(T),A=I.filter(e=>e.date===s&&!['cancelled','noshow'].includes(e.status)&&(e.holds??[]).some(e=>e.qty>0)),C=k?[...j,...A.filter(e=>!j.includes(e))]:j;return C.length?(0,b.jsxs)(l.default,{testID:"kitchen-signoffs",style:{gap:10,padding:16,borderRadius:16,borderWidth:1.5,borderColor:j.length?h.colours.amber:h.colours.hairline,backgroundColor:h.colours.surface},children:[(0,b.jsx)(r.T,{size:12,weight:"semibold",colour:j.length?h.colours.amber:h.colours.goldMuted,style:{letterSpacing:1.6},children:j.length?`KITCHEN SIGN-OFF NEEDED (${j.length})`:'RESERVED TODAY'}),C.map(t=>(0,b.jsxs)(l.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:h.colours.hairline},testID:`signoff-${t.ref}`,children:[(0,b.jsxs)(r.T,{weight:"semibold",children:[t.name," \xb7 ",t.partySize," Covers \xb7 ",t.date===s?'Today':(0,c.niceDate)((0,c.parseYmd)(t.date))," ",t.time,t.table?` \xb7 ${(0,e.tableNumbers)(t.table)}`:'']}),(0,b.jsx)(x,{b:t}),p?(0,b.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,u.needsAllergenSeen)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"danger",label:"Allergens seen",testID:`allergens-seen-${t.ref}`,onPress:()=>o.useStore.getState().ackBookingAllergy(t.id,a)}):null,(0,u.needsHoldOk)(t)?(0,b.jsx)(r.Button,{small:!0,kind:"success",label:/platter/i.test((0,u.holdsText)(t,$,O))?'Platter OK':'Reservation OK',testID:`platter-ok-${t.ref}`,onPress:()=>S(t.id,a)}):null,t.date===s&&t.holdOk&&(t.holds??[]).some(e=>!e.served)&&['seated','confirmed'].includes(t.status)?(0,b.jsx)(r.Button,{small:!0,kind:"secondary",label:"Served",testID:`served-${t.ref}`,onPress:()=>y(t,a,f)}):null]}):(0,b.jsx)(r.Muted,{children:"The kitchen signs these off."})]},t.id))]}):null},_e.PlattersBooked=function({rid:e,date:t,label:s}){const a=(0,o.useBookings)(e),c=(0,o.useRestaurant)(e),f=(0,n.useStockItems)(e),p=(0,u.heldSummary)(a,t,(0,u.reservablesOf)(c)),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,b.jsx)(l.default,{testID:"platters-booked",children:(0,b.jsxs)(r.T,{weight:"semibold",colour:h.colours.goldLight,children:[s??'Platters booked',": ",p.platters,k.length?` (${k.join(', ')})`:'']})}):null};var e=_r(d[0]);_r(d[1]);var t,s=_r(d[2]),l=(t=s)&&t.__esModule?t:{default:t},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]),b=_r(d[10]);const f=({label:e,bg:t,fg:s,border:o,testID:n})=>(0,b.jsx)(l.default,{testID:n,style:{backgroundColor:t,borderColor:o,borderWidth:1,borderRadius:999,paddingHorizontal:9,paddingVertical:2},children:(0,b.jsx)(r.T,{size:13,weight:"semibold",colour:s,children:e})});function p({b:e,big:t}){return(0,u.hasAllergens)(e)?(0,b.jsxs)(l.default,{testID:`allergen-bar-${e.ref}`,style:{backgroundColor:h.colours.redSolid,borderRadius:10,paddingHorizontal:10,paddingVertical:t?8:5,gap:2},children:[(0,b.jsxs)(r.T,{size:t?16:13,weight:"bold",colour:"#FFFFFF",children:["\u26a0\ufe0f ALLERGENS: ",(0,u.allergenText)(e)]}),e.allergyAck?(0,b.jsxs)(r.T,{size:12,colour:"#FFE3DF",children:["Seen by kitchen: ",e.allergyAck.by]}):(0,b.jsx)(r.T,{size:12,colour:"#FFE3DF",children:"Kitchen hasn\u2019t signed \u2018Allergens seen\u2019 yet"})]}):null}function k({b:t,r:s}){const l=(0,n.useStockItems)(t.restaurantId),o=(0,u.reservablesOf)(s),a=(t.holds??[]).some(e=>e.qty>0),c=[];return t.drinksOnly&&c.push((0,b.jsx)(f,{testID:"pill-drinks",label:"\ud83c\udf77 Drinks only (after last food orders)",bg:h.colours.surface2,fg:h.colours.goldLight,border:h.colours.accentBorder},"x")),(0,u.hasAccess)(t)&&c.push((0,b.jsx)(f,{testID:"pill-access",label:`\u267f ${(0,u.accessText)(t)}`,bg:h.colours.blueBg,fg:"#E2C489",border:h.colours.blue},"a")),(0,u.dogCount)(t)&&c.push((0,b.jsx)(f,{testID:"pill-dog",label:"\ud83d\udc15 "+((0,u.dogCount)(t)>1?`${(0,u.dogCount)(t)} dogs`:'Dog'),bg:h.colours.surface2,fg:h.colours.text,border:h.colours.hairline},"d")),(0,u.dietText)(t)&&c.push((0,b.jsx)(f,{testID:"pill-veg",label:`\u24cb ${(0,u.dietText)(t)}`,bg:"#2A2216",fg:"#E2C489",border:"#CFA45F"},"v")),a&&c.push(t.holdOk?(0,b.jsx)(f,{testID:"pill-platter",label:`\u2713 ${(0,u.holdsText)(t,o,l)} \xb7 confirmed`,bg:h.colours.okBg,fg:"#E2C489",border:h.colours.ok},"h"):(0,b.jsx)(f,{testID:"pill-platter",label:`\ud83e\udd9e ${(0,u.holdsText)(t,o,l)} \xb7 awaiting kitchen`,bg:h.colours.amberBg,fg:"#FFE2A8",border:h.colours.amber},"h")),t.tableReq?.length&&c.push((0,b.jsx)(f,{testID:"pill-request",label:`Requested: ${t.tableReq.map(t=>`${(0,e.tableNumbers)(t)}`).join(' or ')}`,bg:h.colours.goldTint,fg:h.colours.goldLight,border:h.colours.accentBorder},"t")),c.length?(0,b.jsx)(r.Row,{wrap:!0,gap:6,children:c}):null}function x({b:e,big:t}){const s=(0,o.useRestaurant)(e.restaurantId);return(0,b.jsxs)(l.default,{style:{gap:6},children:[(0,b.jsx)(p,{b:e,big:t}),(0,b.jsx)(k,{b:e,r:s})]})}const j=e=>[(0,u.hasAllergens)(e)?'\u26a0\ufe0f':'',(0,u.hasAccess)(e)?'\u267f':'',(0,u.dogCount)(e)?'\ud83d\udc15':'',(0,u.dietText)(e)?'\u24cb':'',(e.holds??[]).some(e=>e.qty>0)?e.holdOk?'\ud83e\udd9e\u2713':'\ud83e\udd9e':''].filter(Boolean).join(' '),S=(e,t)=>o.useStore.getState().updateBooking(e,{holdOk:{by:t,at:(new Date).toISOString()}});function y(e,t,s){const l=o.useStore.getState().restaurants.find(t=>t.id===e.restaurantId),r=(0,u.stockNeed)(e,(0,u.reservablesOf)(l));for(const[l,o]of Object.entries(r))o>0&&n.shellfish.append({rid:e.restaurantId,kind:l,delta:-o,reason:'sold',by:t,app:s});const a=(new Date).toISOString();o.useStore.getState().updateBooking(e.id,{holds:(e.holds??[]).map(e=>e.served?e:{...e,served:{by:t,at:a}})})}const I=e=>n.useShellStore.getState().items[e]??[];function D(e,t){return(0,o.useBookings)(e).filter(e=>e.date>=t&&!e.walkIn&&((0,u.needsAllergenSeen)(e)||(0,u.needsHoldOk)(e))).sort((e,t)=>(e.date+e.time).localeCompare(t.date+t.time))}},1107,[860,34,102,794,874,983,891,1101,858,821,25]); +__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.ListBadge=C,_e.OrderListsScreen=function({rid:e,who:t,editor:s,today:i}){(0,o.useEffect)(()=>{x.useOrderLists.getState().ensure(e)},[e]);const d=(0,x.useOrderLists)(e=>e.lists).filter(t=>t.rid===e&&!t.archived),n=(0,x.useOrderLists)(e=>e.items);(0,x.useOrderLists)(t=>t.settings[e]);const l=(0,x.orderSettingsOf)(e).allowStaff,h=(0,x.useListOpen)(e=>e.seed),[y,j]=(0,o.useState)(null);(0,o.useEffect)(()=>{if(!h)return;const e=d.find(e=>e.seed===h);e&&(j(e.id),x.useListOpen.getState().request(void 0))},[h,d.length]);const f=s||l;if(!s&&!l)return(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{children:"Order lists are for managers and the Head Chef here."}),(0,w.jsx)(c.Muted,{children:"Ask a manager to switch on \u201cLet all staff add items\u201d."})]});const b=d.find(e=>e.id===y);if(b)return(0,w.jsx)($,{rid:e,list:b,editor:s,canAdd:f,who:t,today:i,onBack:()=>j(null)});const I=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:"order-lists",children:[(0,w.jsxs)(c.Muted,{size:13,children:["Tip: add what\u2019s running low as you notice it. ",s?'On the day, tick what you got, then Finish order.':'A manager or the Head Chef places the order.']}),d.map(t=>{const s=(0,p.liveItems)(n.filter(t=>t.rid===e),t.id).filter(e=>'open'===e.status).length;return(0,w.jsx)(c.Card,{onPress:()=>j(t.id),children:(0,w.jsx)(u.default,{testID:`order-list-card-${t.seed??t.id}`,children:(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,i,I)})]}),(0,w.jsx)(c.Badge,{kind:s?'gold':'neutral',label:`${s} to get`})]})})},t.id)}),d.length?null:(0,w.jsx)(c.Muted,{children:"No order lists yet. Add one in Settings \u203a Advanced \u203a Order lists."})]})};var t=r(_d[0]),s=r(_d[1]),i=r(_d[2]),o=r(_d[3]),d=e(r(_d[4])),n=e(r(_d[5]));r(_d[6]);var l=e(r(_d[7])),u=e(r(_d[8])),c=r(_d[9]),h=r(_d[10]),x=r(_d[11]),p=r(_d[12]),y=r(_d[13]),j=r(_d[14]),f=r(_d[15]),b=r(_d[16]),w=r(_d[17]);const I={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},L=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',v=e=>e.replace(' (example)','').split(' ')[0];function C({list:e,size:s=40}){const i=(0,f.useLogoCache)(t=>t.byList[e.id]),[n,l]=(0,o.useState)(null);(0,o.useEffect)(()=>{let t=!0;return!i&&e.logo&&(0,b.orderLogoUrl)(e.logo).then(e=>{t&&l(e)}),()=>{t=!1}},[e.logo,i]);const x=i??n;return x?(0,w.jsx)(d.default,{testID:`list-logo-${e.seed??e.id}`,source:{uri:x},accessibilityLabel:`${e.name} logo`,style:{width:s,height:s,borderRadius:s/2,borderWidth:1,borderColor:h.colours.gold}}):(0,w.jsx)(u.default,{testID:`list-initials-${e.seed??e.id}`,accessibilityLabel:`${e.name}`,style:{width:s,height:s,borderRadius:s/2,backgroundColor:(0,t.soutersSurface)('#1c1a16'),borderWidth:1,borderColor:h.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(c.T,{size:.38*s,weight:"bold",colour:h.colours.gold,children:(0,p.initials)(e.name)})})}function D({phone:e}){const t=(0,p.telHref)(e);if(!e||!t)return null;return'undefined'!=typeof navigator&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?(0,w.jsx)(l.default,{testID:"list-phone",accessibilityRole:"link",onPress:()=>{n.default.openURL(t)},children:(0,w.jsxs)(c.T,{colour:h.colours.gold,children:["\ud83d\udcde Call ",e]})}):(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(u.default,{testID:"list-phone",children:(0,w.jsxs)(c.T,{children:["\ud83d\udcde ",e]})}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"list-phone-copy",label:"Copy",onPress:()=>{navigator.clipboard?.writeText(e).then(()=>(0,y.notify)({id:'copied',title:'Number copied',timeoutMs:3e3}))}})]})}function T({list:e}){const t=x.useOrderLists.getState(),s=(0,f.useLogoCache)(t=>!!t.byList[e.id])||!!e.logo,i=async s=>{try{const i=await(0,j.capturePlatingPhoto)(s);if(!i)return;const o=await(0,f.squareLogo)(i.dataUrl,256);f.useLogoCache.getState().put(e.id,o);const d=await(0,b.uploadOrderLogo)(e.id,o);if(d.ok){const s=e.logo;t.updateList(e.id,{logo:d.path}),s&&(0,b.removeOrderLogo)(s)}else'offline'!==d.message&&(0,y.notify)({id:'logo',tone:'warn',title:'Logo saved on this device only',body:d.message,timeoutMs:7e3})}catch(e){(0,y.notify)({id:'logo',tone:'warn',title:'Couldn\u2019t use that picture',body:String(e.message),timeoutMs:7e3})}};return(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-camera",label:s?'Replace: take photo':'Logo: take photo',onPress:()=>{i('camera')}}),(0,w.jsx)(c.Button,{small:!0,kind:"secondary",testID:"logo-library",label:s?'Replace: choose':'Logo: choose image',onPress:()=>{i('library')}}),s?(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"logo-remove",label:"Remove logo",onPress:()=>{f.useLogoCache.getState().drop(e.id),e.logo&&(0,b.removeOrderLogo)(e.logo),t.updateList(e.id,{logo:void 0})}}):null]})}function S({rid:e,list:t,who:i}){const[d,n]=(0,o.useState)(''),[l,y]=(0,o.useState)('1'),[j,f]=(0,o.useState)(''),[b,L]=(0,o.useState)(''),[C,D]=(0,o.useState)(null),T=x.useOrderLists.getState(),S=Number(l.replace(',','.')),B=d.trim().length>0&&(0,p.validQty)(S),$=()=>{n(''),y('1'),L(''),D(null)};return(0,w.jsxs)(u.default,{testID:"order-add",style:{gap:6},children:[(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Item",testID:"order-add-name",value:d,onChangeText:n,placeholder:"Item, e.g. Tennent\u2019s",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(s.TextInput,{accessibilityLabel:"Quantity",testID:"order-add-qty",value:l,onChangeText:y,keyboardType:"decimal-pad",style:{...I,width:64,borderColor:(0,p.validQty)(S)?h.colours.hairline:h.colours.red}})]}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:p.UNITS.map(e=>(0,w.jsx)(c.Chip,{label:e||'no unit',selected:j===e,onPress:()=>f(e)},e||'none'))}),(0,w.jsxs)(c.Row,{gap:6,children:[(0,w.jsx)(s.TextInput,{accessibilityLabel:"Note",testID:"order-add-note",value:b,onChangeText:L,placeholder:"Note (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}}),(0,w.jsx)(c.Button,{testID:"order-add-save",label:"Add",disabled:!B,onPress:()=>{const s=(0,p.findDuplicate)(T.items.filter(t=>t.rid===e),t.id,d,j);s?D(s):(T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$())}})]}),(0,w.jsxs)(c.Sheet,{visible:!!C,onClose:()=>D(null),title:"Already on the list",testID:"order-dup",children:[(0,w.jsx)(c.T,{children:C?`${C.name}: ${(0,p.qtyText)(C)} (added by ${v(C.addedByName)})`:''}),(0,w.jsxs)(c.Row,{gap:8,children:[(0,w.jsx)(c.Button,{testID:"order-dup-bump",label:`Add ${l} more`,onPress:()=>{C&&T.bump(C.id,S,i),$()}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Add as separate item",onPress:()=>{T.addItem(e,{listId:t.id,name:d.trim(),qty:S,unit:j,note:b.trim()||void 0,addedBy:i.id,addedByName:i.name}),$()}})]})]})]})}function B({item:e,editor:t,who:s}){const i=x.useOrderLists.getState(),o='got'===e.status?h.colours.gold:'missing'===e.status?h.colours.amber:h.colours.text;return(0,w.jsxs)(u.default,{testID:`order-item-${e.id}`,style:{borderTopWidth:1,borderColor:h.colours.hairline,paddingVertical:8,gap:4},children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",colour:o,style:{flex:1,textDecorationLine:'got'===e.status?'line-through':'none'},children:e.name}),(0,w.jsx)(c.T,{weight:"semibold",children:(0,p.qtyText)(e)})]}),e.note?(0,w.jsxs)(c.Muted,{size:12,children:["Note: ",e.note]}):null,(0,w.jsxs)(c.Muted,{size:12,children:["Added by ",v(e.addedByName)," \xb7 ",L(e.addedAt),e.bumps?.length?` \xb7 +${e.bumps.map(e=>`${e.qty} ${v(e.name)}`).join(', ')}`:'',e.carried?' \xb7 carried over':'']}),'open'!==e.status?(0,w.jsxs)(c.Muted,{size:12,children:['got'===e.status?'Got / ordered':'Missing / not in stock'," \xb7 ",e.statusBy," ",L(e.statusAt)]}):null,t?(0,w.jsxs)(c.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(c.Chip,{testID:`order-got-${e.id}`,label:"\u2713 Got / ordered",selected:'got'===e.status,onPress:()=>i.setStatus(e.id,'got'===e.status?'open':'got',s)}),(0,w.jsx)(c.Chip,{testID:`order-missing-${e.id}`,label:"Missing / not in stock",selected:'missing'===e.status,onPress:()=>i.setStatus(e.id,'missing'===e.status?'open':'missing',s)}),(0,w.jsx)(c.Chip,{testID:`order-remove-${e.id}`,label:"Remove",onPress:()=>{i.removeItem(e.id),(0,y.notify)({id:`undo-${e.id}`,title:`Removed ${e.name}`,timeoutMs:8e3,actions:[{label:'Undo',testID:'order-undo',onPress:()=>i.undoRemove(e.id)}]})}})]}):null]})}function $({rid:e,list:t,editor:d,canAdd:n,who:l,today:j,onBack:f}){(0,i.useBackLayer)(!0,f);const b=(0,x.useOrderLists)(e=>e.items),$=(0,x.useOrderLists)(e=>e.history).filter(e=>e.listId===t.id),P=(0,p.liveItems)(b.filter(t=>t.rid===e),t.id),[k,R]=(0,o.useState)(!1),[O,M]=(0,o.useState)(!1),[A,z]=(0,o.useState)(t.phone??''),N=x.useOrderLists.getState(),q=P.filter(e=>'got'!==e.status).length,H=(0,x.orderSettingsOf)(e).defaultTripDay;return(0,w.jsxs)(u.default,{style:{gap:10},testID:`order-list-${t.seed??t.id}`,children:[(0,w.jsx)(i.BackButton,{onPress:f,testID:"order-list-back"}),(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{gap:10,children:[(0,w.jsx)(C,{list:t,size:48}),(0,w.jsxs)(u.default,{style:{flex:1},children:[(0,w.jsx)(c.T,{size:18,weight:"semibold",children:t.name}),(0,w.jsx)(c.Muted,{size:12,children:(0,p.tripText)(t,j,H)})]})]}),(0,w.jsx)(D,{phone:t.phone}),'trip'===t.kind&&d?(0,w.jsxs)(u.default,{style:{gap:4},children:[(0,w.jsx)(c.Muted,{size:12,children:"Trip day for this trip"}),(0,w.jsx)(c.Row,{wrap:!0,gap:4,children:[1,2,3,4,5,6,0].map(e=>(0,w.jsx)(c.Chip,{testID:`trip-day-${e}`,label:p.DAY_FULL[e].slice(0,3),selected:(t.tripDay??H)===e,onPress:()=>N.updateList(t.id,{tripDay:e})},e))})]}):null,d?(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(c.Row,{gap:6,children:(0,w.jsx)(s.TextInput,{accessibilityLabel:"Phone number",testID:"list-phone-edit",value:A,onChangeText:z,onBlur:()=>N.updateList(t.id,{phone:A.trim()||void 0}),placeholder:"Phone (optional)",placeholderTextColor:h.colours.muted,style:{...I,flex:1}})}),(0,w.jsx)(T,{list:t})]}):null]}),n?(0,w.jsxs)(c.Card,{children:[(0,w.jsx)(c.T,{weight:"semibold",children:"Add to this list"}),(0,w.jsx)(S,{rid:e,list:t,who:l})]}):null,(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(c.T,{weight:"semibold",children:"On the list"}),(0,w.jsx)(c.Badge,{kind:"neutral",label:`${P.length}`})]}),P.length?P.map(e=>(0,w.jsx)(B,{item:e,editor:d,who:l},e.id)):(0,w.jsx)(c.Muted,{children:"Nothing on this list yet."}),d&&P.length?(0,w.jsx)(c.Button,{testID:"order-finish",label:"Finish order",onPress:()=>R(!0)}):null]}),(0,w.jsx)(c.Button,{small:!0,kind:"ghost",testID:"order-history",label:O?'Hide history \u25b4':`History (${$.length}) \u25be`,onPress:()=>M(!O)}),O?$.map(e=>(0,w.jsxs)(c.Card,{children:[(0,w.jsxs)(c.T,{weight:"semibold",children:[L(e.finishedAt)," \xb7 ",v(e.finishedByName)]}),(0,w.jsx)(c.Muted,{size:12,children:e.items.map(e=>`${e.name} ${(0,p.qtyText)(e)}${'missing'===e.status?' (missing)':'open'===e.status?' (not got)':''}`).join(' \xb7 ')}),e.carried?(0,w.jsxs)(c.Muted,{size:12,children:[e.carried," carried over"]}):null]},e.id)):null,(0,w.jsxs)(c.Sheet,{visible:k,onClose:()=>R(!1),title:"Finish this order?",testID:"order-finish-sheet",children:[(0,w.jsxs)(c.T,{children:[P.length-q," got or ordered",q?`, ${q} not got (missing or still open)`:'',"."]}),(0,w.jsx)(c.Muted,{children:"It goes into History with today\u2019s date and your name."}),q?(0,w.jsxs)(c.T,{weight:"semibold",children:["Carry over the ",q," not got to the next order?"]}):null,(0,w.jsxs)(c.Row,{wrap:!0,gap:8,children:[q?(0,w.jsx)(c.Button,{testID:"order-finish-carry",label:"Finish and carry over",onPress:()=>{N.finish(e,t.id,!0,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,body:`${q} carried over`,timeoutMs:6e3})}}):null,(0,w.jsx)(c.Button,{testID:"order-finish-clear",kind:q?'secondary':'primary',label:q?'Finish, don\u2019t carry over':'Finish order',onPress:()=>{N.finish(e,t.id,!1,l),R(!1),(0,y.notify)({id:'order-done',title:`${t.name}: order finished`,timeoutMs:6e3})}}),(0,w.jsx)(c.Button,{kind:"ghost",label:"Cancel",onPress:()=>R(!1)})]})]})]})}},1108,[828,827,1056,34,336,379,236,402,102,794,821,1040,1041,1001,1109,1110,987,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"MAX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"TARGET",{enumerable:!0,get:function(){return t}}),_e.compressOnWeb=r,_e.capturePlatingPhoto=async function(e){{const n=await(t='camera'===e,new Promise(e=>{const n=document.createElement('input');n.type='file',n.accept='image/*',t&&n.setAttribute('capture','environment'),n.style.display='none',n.setAttribute('data-testid',t?'photo-input-camera':'photo-input-library'),n.onchange=()=>{const t=n.files?.[0]??null;n.remove(),e(t)},n.oncancel=()=>{n.remove(),e(null)},document.body.appendChild(n),n.click()}));if(!n)return null;return{...await r(n),originalBytes:n.size}}var t},Object.defineProperty(_e,"kb",{enumerable:!0,get:function(){return a}});!(function(e){if(e&&e.__esModule)return e;var t={};e&&Object.keys(e).forEach(function(n){if('default'!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e})(_r(_d[0]));_r(_d[1]);const e=1024,t=225280,n=e=>Math.round(3*(e.length-e.indexOf(',')-1)/4);async function r(r,a=e,o=t){const i='string'==typeof r?r:URL.createObjectURL(r);try{const e=await new Promise((e,t)=>{const n=new window.Image;n.onload=()=>e(n),n.onerror=()=>t(new Error('That file is not a photo we can read.')),n.src=i}),t=Math.min(1,a/Math.max(e.naturalWidth,e.naturalHeight)),r=Math.max(1,Math.round(e.naturalWidth*t)),c=Math.max(1,Math.round(e.naturalHeight*t)),u=document.createElement('canvas');u.width=r,u.height=c;const l=u.getContext('2d');l.fillStyle='#ffffff',l.fillRect(0,0,r,c),l.drawImage(e,0,0,r,c);let f=.8,s=u.toDataURL('image/jpeg',f);for(;n(s)>o&&f>.4;)f-=.1,s=u.toDataURL('image/jpeg',f);return{dataUrl:s,width:r,height:c,bytes:n(s)}}finally{'string'!=typeof r&&URL.revokeObjectURL(i)}}const a=e=>`${Math.max(1,Math.round(e/1024))} KB`},1109,[1076,236]); +__d(function(_g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useLogoCache",{enumerable:!0,get:function(){return s}}),_e.squareLogo=async function(e,t=256){const n=await new Promise((t,n)=>{const o=new window.Image;o.onload=()=>t(o),o.onerror=()=>n(new Error('That file is not a picture we can read.')),o.src=e}),o=Math.min(n.naturalWidth,n.naturalHeight),i=(n.naturalWidth-o)/2,s=(n.naturalHeight-o)/2,c=document.createElement('canvas');c.width=t,c.height=t;const u=c.getContext('2d');return u.fillStyle='#ffffff',u.fillRect(0,0,t,t),u.drawImage(n,i,s,o,o,0,0,t,t),c.toDataURL('image/jpeg',.85)};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),i=r(d[2]);const s=(0,o.create)()((0,i.persist)(e=>({byList:{},put:(t,n)=>e(e=>({byList:{...e.byList,[t]:n}})),drop:t=>e(e=>{const n={...e.byList};return delete n[t],{byList:n}})}),{name:'covercharge-order-logos-v1',storage:(0,i.createJSONStorage)(()=>n.default)}))},1110,[839,846,849]); +__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.NotificationsSettings=function({rid:e}){(0,n.useEffect)(()=>{c.useNotifs.getState().ensure(e),(0,j.readPushLive)()},[e]);const t=(0,c.useNotifs)(e=>e.items).filter(t=>t.rid===e&&!t.removed),s=(0,h.useOwner)(e=>e.staff),o=(0,j.usePushLive)(),[l,p]=(0,n.useState)(null),[f,g]=(0,n.useState)(null),[x,b]=(0,n.useState)(!1),y=c.useNotifs.getState(),T=s.map(e=>({id:e.id,role:e.role,level:e.level,job:e.job,department:e.dept,active:e.active})),v=e=>{const t=(0,u.resolveRecipients)(e,T,[]),n=[...e.recipients.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...(e.recipients.onShiftIn??[]).map(e=>u.SHIFT_FILTER_LABEL[e])];e.recipients.fallback&&n.push(`else ${[...e.recipients.fallback.groups.map(e=>u.NOTIF_GROUP_LABEL[e]),...e.recipients.fallback.staff.map(e=>I(s.find(t=>t.id===e)?.name??e))].join(', ')}`);const o=e.recipients.staff.map(e=>I(s.find(t=>t.id===e)?.name??e));return[...n,...o].join(', ')+(t.length||(e.recipients.onShiftIn??[]).length?'':' (nobody yet)')};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"notif-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: these remind people at a set time, e.g. the Mills milk order. They show in the app as a gold slider with Done and Later. Done is logged with the name and time. Times are UK time."}),(0,k.jsxs)(a.default,{testID:"push-live-status",style:{borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:10,padding:8,gap:4},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Send to phones"}),(0,k.jsx)(r.Badge,{kind:o.live?'gold':'neutral',label:o.live?'ON':'OFF'})]}),(0,k.jsx)(r.Muted,{size:12,children:o.live?'Phone notifications go to people who turned them on.':'Off: nothing goes to anyone\u2019s phone yet. In-app reminders still work.'}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:"push-live-toggle",label:o.live?'Switch phone notifications off':'Switch phone notifications on\u2026',onPress:()=>b(!0)})]}),(0,k.jsx)(R,{}),t.map(e=>l===e.id?(0,k.jsx)(D,{init:e,onCancel:()=>p(null),onSave:t=>{y.update(e.id,t),p(null)}},e.id):(0,k.jsxs)(a.default,{testID:`notif-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:12,padding:10,gap:4,opacity:e.paused?.6:1},children:[(0,k.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(r.T,{weight:"semibold",style:{flex:1},children:e.title}),e.paused?(0,k.jsx)(r.Badge,{kind:"neutral",label:"Off"}):null]}),(0,k.jsx)(r.Muted,{size:13,children:e.message}),(0,k.jsxs)(r.Muted,{size:12,children:[(0,u.scheduleText)(e)," \xb7 ",v(e)," \xb7 ",[e.sendBy.inApp?'In app':'',e.sendBy.push?'Phone':''].filter(Boolean).join(' + ')]}),(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",testID:`notif-edit-${e.seed??e.id}`,label:"Edit",onPress:()=>p(e.id)}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.paused?'Switch on':'Switch off',onPress:()=>y.update(e.id,{paused:!e.paused})}),(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>g(e)})]})]},e.id)),'new'===l?(0,k.jsx)(D,{init:C,onCancel:()=>p(null),onSave:t=>{y.add(e,t),p(null)}}):(0,k.jsx)(r.Button,{small:!0,testID:"notif-add",label:"Add a notification",onPress:()=>p('new')}),(0,k.jsxs)(r.Sheet,{visible:!!f,onClose:()=>g(null),title:"Remove this notification?",children:[(0,k.jsx)(r.T,{children:f?.title}),(0,k.jsx)(r.Muted,{children:"Nobody gets it after this. Reset to default restores the configured rules."}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{label:"Remove",onPress:()=>{f&&y.remove(f.id),g(null)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>g(null)})]})]}),(0,k.jsxs)(r.Sheet,{visible:x,onClose:()=>b(!1),title:o.live?'Switch phone notifications off?':'Switch phone notifications on?',testID:"push-live-confirm",children:[(0,k.jsx)(r.T,{children:o.live?'Nothing more goes to phones. In-app reminders keep working.':'From the next scheduled time, everyone ticked on a notification with \u201cPhone notification\u201d gets it on any phone where they turned phone notifications on.'}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{testID:"push-live-yes",label:o.live?'Switch off':'Yes, switch on',onPress:()=>{(0,j.setPushLive)(!o.live).then(e=>(0,w.notify)({id:'push-live',tone:e.ok?'normal':'warn',title:e.ok?o.live?'Phone notifications are off':'Phone notifications are on':'Not changed',body:e.message??'',timeoutMs:7e3})),b(!1)}}),(0,k.jsx)(r.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]})]})},_e.PushButton=R,_e.OrderListsSettings=function({rid:e}){(0,n.useEffect)(()=>{p.useOrderLists.getState().ensure(e)},[e]);const s=(0,p.useOrderLists)(e=>e.lists).filter(t=>t.rid===e),o=(0,p.orderSettingsOf)(e);(0,p.useOrderLists)(t=>t.settings[e]);const l=p.useOrderLists.getState(),[c,u]=(0,n.useState)(''),[h,g]=(0,n.useState)({});return(0,k.jsxs)(a.default,{style:{gap:10},testID:"order-list-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:"Tip: running lists (like Alsons drinks) collect items until you order; trip lists (like Cash and carry) are for one shopping day. Logos and phone numbers are set on each list."}),(0,k.jsx)(r.Toggle,{testID:"order-allow-staff",label:"Let all staff add items",value:o.allowStaff,onChange:t=>l.setSettings(e,{allowStaff:t})}),(0,k.jsx)(r.Muted,{size:12,children:"Staff can add items and see the lists. Only managers and the Head Chef tick, remove or finish an order."}),(0,k.jsx)(r.T,{weight:"semibold",children:"Default trip day"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:o.defaultTripDay===t,onPress:()=>l.setSettings(e,{defaultTripDay:t})},t))}),s.map(e=>(0,k.jsxs)(a.default,{testID:`order-list-row-${e.seed??e.id}`,style:{borderWidth:1,borderColor:d.colours.hairline,borderRadius:10,padding:8,gap:6,opacity:e.archived?.55:1},children:[(0,k.jsxs)(r.Row,{gap:6,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:`Rename ${e.name}`,value:h[e.id]??e.name,onChangeText:t=>g(s=>({...s,[e.id]:t})),onBlur:()=>{const t=(h[e.id]??'').trim();t&&t!==e.name&&l.updateList(e.id,{name:t})},style:{...T,flex:1,minWidth:0}}),(0,k.jsx)(r.Badge,{kind:"neutral",label:'trip'===e.kind?'Trip':'Running'})]}),'trip'===e.kind?(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(t=>(0,k.jsx)(r.Chip,{label:f.DAY_FULL[t].slice(0,3),selected:(e.tripDay??o.defaultTripDay)===t,onPress:()=>l.updateList(e.id,{tripDay:t})},t))}):null,(0,k.jsx)(r.Row,{gap:6,children:(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:e.archived?'Bring back':'Archive',onPress:()=>l.updateList(e.id,{archived:!e.archived})})})]},e.id)),(0,k.jsxs)(r.Row,{gap:6,wrap:!0,children:[(0,k.jsx)(t.TextInput,{accessibilityLabel:"New list name",testID:"order-new-name",value:c,onChangeText:u,placeholder:"e.g. Butcher",placeholderTextColor:d.colours.muted,style:{...T,flexGrow:1,flexBasis:160,minWidth:0}}),(0,k.jsx)(r.Button,{small:!0,label:"Add running",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'running'}),u('')}}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"Add trip",disabled:c.trim().length<2,onPress:()=>{l.addList(e,{name:c.trim(),kind:'trip',tripDay:o.defaultTripDay}),u('')}})]})]})},Object.defineProperty(_e,"resetOrderLists",{enumerable:!0,get:function(){return B}}),_e.ClockAreaSettings=function({rid:e,me:c}){(0,g.useClockArea)(t=>t.areas[e]);const u=(0,g.areaOf)(e);const h=g.useClockArea.getState(),p=(0,s.privateClockVenue)(e),[f,j]=(0,n.useState)(null==u.lat?'':String(u.lat)),[y,w]=(0,n.useState)(null==u.lng?'':String(u.lng)),[v,S]=(0,n.useState)(!1),[I,C]=(0,n.useState)(''),[L,D]=(0,n.useState)(u.breakOptions.join(', ')),R=(t,s)=>{const n=Number(t),o=Number(s);t.trim()||s.trim()?Number.isFinite(n)&&Number.isFinite(o)&&Math.abs(n)<=90&&Math.abs(o)<=180&&h.set(e,{lat:n,lng:o},c):h.set(e,{lat:null,lng:null},c)},B=async()=>{if(p)return;S(!0),C('');const t=await(0,b.getFix)();if(S(!1),'object'!=typeof t)return void C('denied'===t?'Location is blocked for this app. Allow it in your browser or phone settings.':'Couldn\u2019t get your location. Try again outside or near a window.');const s=t.lat.toFixed(6),n=t.lng.toFixed(6);j(s),w(n),h.set(e,{lat:Number(s),lng:Number(n)},c),C(`Centre set to where you are (accurate to about ${Math.round(t.acc)} m).`)},P=(0,x.areaSet)(u);return(0,k.jsxs)(a.default,{style:{gap:10},testID:"clock-area-settings",children:[(0,k.jsx)(r.Muted,{size:13,children:p?'The address-matched pub centre is configured below. Only clock-in checks location; only pass/fail is saved. No background, clock-out or break checks. Change the radius or centre here; use a manager override for a refused check.':'Tip: stand in the middle of the venue and tap \u201cUse my current location\u201d. Clocking in, out and breaks then only work within the distance below. Rota and pay screens are never blocked.'}),P?null:(0,k.jsx)(r.Banner,{kind:"warn",title:"Clock-in area not set yet",children:"Until you set the centre, staff can clock in from anywhere."}),p?(0,k.jsx)(r.Muted,{children:"Clock-in at the pub is required. A manager can record an exception with a reason."}):(0,k.jsx)(r.Toggle,{testID:"clock-area-on",label:"Check people are at the venue",value:u.on,onChange:t=>h.set(e,{on:t},c)}),p?null:(0,k.jsx)(r.Button,{testID:"clock-area-here",label:v?'Finding you\u2026':'\ud83d\udccd Use my current location',disabled:v,onPress:()=>{B()}}),I?(0,k.jsx)(r.Muted,{size:13,children:I}):null,(0,k.jsxs)(r.Row,{wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Latitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Latitude",testID:"clock-area-lat",value:f,onChangeText:j,onBlur:()=>R(f,y),placeholder:"55.40\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]}),(0,k.jsxs)(a.default,{style:{gap:2},children:[(0,k.jsx)(r.Muted,{size:12,children:"Longitude"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Longitude",testID:"clock-area-lng",value:y,onChangeText:w,onBlur:()=>R(f,y),placeholder:"-4.75\u2026",placeholderTextColor:d.colours.muted,style:{...T,width:130}})]})]}),P?(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"clock-area-map",onPress:()=>{o.default.openURL(`https://www.openstreetmap.org/?mlat=${u.lat}&mlon=${u.lng}#map=18/${u.lat}/${u.lng}`)},children:(0,k.jsx)(r.T,{size:13,colour:d.colours.gold,children:"See the pin on a map \u203a"})}):null,(0,k.jsx)(r.T,{weight:"semibold",children:"How far from the centre"}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"\u2212",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius-10)},c)}),(0,k.jsxs)(r.T,{weight:"semibold",style:{minWidth:70,textAlign:'center'},children:[u.radius," m"]}),(0,k.jsx)(r.Button,{small:!0,kind:"secondary",label:"+",onPress:()=>h.set(e,{radius:(0,x.clampRadius)(u.radius+10)},c)})]}),(0,k.jsxs)(r.Muted,{size:12,children:["At least ",x.MIN_RADIUS," m. Phones aren\u2019t exact, so up to 50 m of the phone\u2019s own accuracy is added on top."]}),(0,k.jsx)(r.T,{weight:"semibold",children:"Forgotten break: lengths to offer at clock-out"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Break lengths in minutes",testID:"clock-break-options",value:L,onChangeText:D,onBlur:()=>{const t=L.split(/[ ,]+/).map(Number).filter(e=>Number.isFinite(e)&&e>0&&e<=180);t.length&&h.set(e,{breakOptions:[...new Set(t)].sort((e,t)=>e-t)},c),D((0,g.areaOf)(e).breakOptions.join(', '))},style:T}),(0,k.jsxs)(r.Muted,{size:12,children:["Minutes, e.g. 5, 10, 15, 20, 30, 45, 60. Shows as ",u.breakOptions.map(x.breakLabel).join(', ')," and \u201cNo break\u201d."]}),p?(0,k.jsx)(r.Muted,{children:"No automatic arrival checks: staff location is used only at clock-in."}):(0,k.jsxs)(k.Fragment,{children:[" ",(0,k.jsx)(r.T,{weight:"semibold",children:"Not on the rota"}),(0,k.jsx)(r.Toggle,{testID:"clock-offrota-on",label:"Ask people at the venue who aren\u2019t on the rota if they want to clock in",value:u.offRotaPrompt,onChange:t=>h.set(e,{offRotaPrompt:t},c)}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota question",testID:"clock-offrota-title",value:u.offRotaTitle,onChangeText:t=>h.set(e,{offRotaTitle:t||x.DEFAULT_CLOCK_AREA.offRotaTitle},c),style:T}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Off-rota second line",testID:"clock-offrota-body",value:u.offRotaBody,onChangeText:t=>h.set(e,{offRotaBody:t||x.DEFAULT_CLOCK_AREA.offRotaBody},c),style:T}),(0,k.jsx)(r.Muted,{size:12,children:"This only checks while the app is open (web apps can\u2019t watch location in the background; that would need a native app)."})]})]})},Object.defineProperty(_e,"resetClockArea",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"COOKSAFE_URL",{enumerable:!0,get:function(){return O}}),_e.FoodSafetyCard=function({children:e}){return(0,k.jsx)(r.Card,{children:(0,k.jsxs)(a.default,{testID:"food-safety",style:{gap:6},children:[(0,k.jsx)(r.T,{size:17,weight:"semibold",children:"Food safety"}),(0,k.jsxs)(r.T,{children:["Based on ",(0,k.jsx)(r.T,{weight:"bold",colour:d.colours.gold,children:"CookSafe"})," (Food Standards Scotland)"]}),(0,k.jsx)(r.Muted,{size:12,children:"CoverCharge is not endorsed by Food Standards Scotland."}),(0,k.jsx)(l.default,{accessibilityRole:"link",testID:"cooksafe-link",onPress:()=>{o.default.openURL(O)},children:(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"Open the CookSafe guidance \u203a"})}),(0,k.jsx)(r.Muted,{size:13,children:"Full logs coming in the next update."}),e]})})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),o=e(_r(_d[3])),l=e(_r(_d[4])),a=e(_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]),f=_r(_d[12]),g=_r(_d[13]),x=_r(_d[14]),b=_r(_d[15]),j=_r(_d[16]),y=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]);const T={minHeight:44,borderRadius:10,borderWidth:1,borderColor:d.colours.hairline,backgroundColor:d.colours.surface2,color:d.colours.text,paddingHorizontal:10,fontSize:15},v=[1,2,3,4,5,6,0],S=['on_shift','everyone','managers','head_chef','kitchen','foh'],I=e=>e.replace(' (example)',''),C={title:'',message:'',days:[3,4,5,6,0],time:'21:00',recipients:{staff:[],groups:[]},sendBy:{inApp:!0,push:!1}};function L({value:e,onChange:t}){const s=(0,h.useOwner)(e=>e.staff).filter(e=>e.active);return(0,k.jsxs)(a.default,{style:{gap:6},testID:"notif-recipients",children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Who gets it"}),(0,k.jsx)(r.Muted,{size:12,children:"Tick people, or pick a group (groups follow the team as it changes)."}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:S.map(s=>(0,k.jsx)(r.Chip,{testID:`notif-group-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:e.groups.includes(s),onPress:()=>t({...e,groups:e.groups.includes(s)?e.groups.filter(e=>e!==s):[...e.groups,s]})},s))}),(0,k.jsx)(r.Muted,{size:12,children:"Only people on shift when it goes, in:"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:Object.keys(u.SHIFT_FILTER_LABEL).map(s=>{const n=(e.onShiftIn??[]).includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-onshift-${s}`,label:u.SHIFT_FILTER_LABEL[s],selected:n,onPress:()=>t({...e,onShiftIn:n?(e.onShiftIn??[]).filter(e=>e!==s):[...e.onShiftIn??[],s]})},s)})}),(0,k.jsx)(a.default,{style:{gap:2},children:s.map(s=>{const n=e.staff.includes(s.id);return(0,k.jsxs)(l.default,{testID:`notif-tick-${s.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},onPress:()=>t({...e,staff:n?e.staff.filter(e=>e!==s.id):[...e.staff,s.id]}),style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:6},children:[(0,k.jsx)(a.default,{style:{width:22,height:22,borderRadius:5,borderWidth:1.5,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:n?'#2a2414':'transparent'},children:n?(0,k.jsx)(r.T,{size:14,colour:d.colours.gold,children:"\u2713"}):null}),(0,k.jsx)(r.T,{style:{flex:1},children:(0,h.staffLabel)({name:I(s.name),nickname:s.nickname})}),(0,k.jsx)(r.Muted,{size:12,children:'Head Chef'===s.level?'Head Chef':s.job})]},s.id)})}),(0,k.jsx)(r.Muted,{size:12,children:"If nobody above matches when it goes, send it to:"}),(0,k.jsxs)(r.Row,{wrap:!0,gap:6,children:[S.filter(e=>'on_shift'!==e).map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.groups.includes(s);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s}`,label:u.NOTIF_GROUP_LABEL[s],selected:o,onPress:()=>{const l=o?n.groups.filter(e=>e!==s):[...n.groups,s];t({...e,fallback:l.length||n.staff.length?{...n,groups:l}:void 0})}},s)}),s.map(s=>{const n=e.fallback??{staff:[],groups:[]},o=n.staff.includes(s.id);return(0,k.jsx)(r.Chip,{testID:`notif-fallback-${s.id}`,label:I(s.name),selected:o,onPress:()=>{const l=o?n.staff.filter(e=>e!==s.id):[...n.staff,s.id];t({...e,fallback:l.length||n.groups.length?{...n,staff:l}:void 0})}},s.id)})]})]})}function D({init:e,onSave:s,onCancel:o}){const[l,c]=(0,n.useState)(e),[h,p]=(0,n.useState)(!!e.dayTimes&&Object.keys(e.dayTimes).length>0),f=(0,u.validateNotif)(l),g=e=>c(t=>({...t,...e}));return(0,k.jsxs)(a.default,{testID:"notif-editor",style:{gap:8,borderWidth:1,borderColor:d.colours.accentBorder,borderRadius:12,padding:10},children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Title"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification title",testID:"notif-title",value:l.title,onChangeText:e=>g({title:e}),maxLength:60,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Message"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Notification message",testID:"notif-message",value:l.message,onChangeText:e=>g({message:e}),maxLength:160,style:T}),(0,k.jsx)(r.T,{weight:"semibold",children:"Days"}),(0,k.jsx)(r.Row,{wrap:!0,gap:6,children:v.map(e=>(0,k.jsx)(r.Chip,{testID:`notif-day-${e}`,label:u.NOTIF_DAY_NAMES[e],selected:l.days.includes(e),onPress:()=>g({days:l.days.includes(e)?l.days.filter(t=>t!==e):[...l.days,e]})},e))}),(0,k.jsxs)(r.Row,{gap:8,children:[(0,k.jsx)(r.T,{weight:"semibold",children:"Time (UK)"}),(0,k.jsx)(t.TextInput,{accessibilityLabel:"Time",testID:"notif-time",value:l.time,onChangeText:e=>g({time:e}),placeholder:"21:00",style:{...T,width:90,borderColor:(0,u.validHm)(l.time)?d.colours.hairline:d.colours.red}})]}),(0,k.jsx)(r.Toggle,{label:"A different time on some days",value:h,onChange:e=>{p(e),e||g({dayTimes:void 0})}}),h?(0,k.jsx)(r.Row,{wrap:!0,gap:8,children:v.filter(e=>l.days.includes(e)).map(e=>(0,k.jsxs)(r.Row,{gap:4,children:[(0,k.jsx)(r.T,{size:13,children:u.NOTIF_DAY_NAMES[e]}),(0,k.jsx)(t.TextInput,{accessibilityLabel:`${u.NOTIF_DAY_NAMES[e]} time`,testID:`notif-daytime-${e}`,value:l.dayTimes?.[String(e)]??'',placeholder:l.time,onChangeText:t=>{const s={...l.dayTimes??{}};t.trim()?s[String(e)]=t.trim():delete s[String(e)],g({dayTimes:s})},style:{...T,width:74}})]},e))}):null,(0,k.jsx)(L,{value:l.recipients,onChange:e=>g({recipients:e})}),(0,k.jsx)(r.T,{weight:"semibold",children:"Send by"}),(0,k.jsx)(r.Toggle,{testID:"notif-inapp",label:"In the app (gold slider, Done / Later)",value:l.sendBy.inApp,onChange:e=>g({sendBy:{...l.sendBy,inApp:e}})}),(0,k.jsx)(r.Toggle,{testID:"notif-push",label:"Phone notification (when phones are switched on)",value:l.sendBy.push,onChange:e=>g({sendBy:{...l.sendBy,push:e}})}),f?(0,k.jsx)(r.Muted,{size:13,children:f}):null,(0,k.jsxs)(r.Row,{gap:8,style:{justifyContent:'flex-end'},children:[(0,k.jsx)(r.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:o}),(0,k.jsx)(r.Button,{small:!0,testID:"notif-save",label:"Save",disabled:!!f,onPress:()=>s({...l,title:l.title.trim(),message:l.message.trim(),days:[...l.days].sort()})})]})]})}function R(){const[e,t]=(0,n.useState)(null),[s,o]=(0,n.useState)('');return(0,n.useEffect)(()=>{(0,y.pushState)().then(t)},[]),e&&'unsupported'!==e?(0,k.jsxs)(a.default,{testID:"push-button",style:{gap:4},children:[(0,k.jsx)(r.Button,{small:!0,kind:'on'===e?'ghost':'secondary',testID:"push-turn-on",label:'on'===e?'Phone notifications are on for this phone \xb7 Turn off':'\ud83d\udd14 Turn on phone notifications',onPress:()=>{('on'===e?(0,y.turnOffPush)():(0,y.turnOnPush)()).then(e=>{o(e.message),(0,y.pushState)().then(t)})}}),(0,k.jsx)(r.Muted,{size:12,children:s||('ios-home-screen'===e?'iPhone: add this app to your Home Screen first (iOS 16.4 or later).':'For this phone only. Each person turns it on on their own phone.')})]}):null}const B=e=>p.useOrderLists.getState().resetSettings(e);const P=(e,t)=>g.useClockArea.getState().reset(e,t),O='https://www.foodstandards.gov.scot/publications-and-research/publications/cooksafe-manual'},1111,[827,997,34,379,402,102,794,821,1036,1037,891,1040,1041,1042,998,1096,987,1059,1001,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SNOOZE_MINS",{enumerable:!0,get:function(){return S}}),e.useScheduledNotices=function({rid:u,staffId:S,name:w,onOpen:D}){const I=(0,t.useRef)(w);I.current=w;const N=(0,t.useRef)(D);N.current=D,(0,t.useEffect)(()=>{if('undefined'==typeof window||!window.location?.search)return;const t=new URLSearchParams(window.location.search);if('orderlists'===t.get('open'))o.useListOpen.getState().request(t.get('list')??void 0),setTimeout(()=>N.current?.('orderlists'),0);else if('chat'===t.get('open'))c.useChatOpen.getState().request(t.get('ch')??void 0),setTimeout(()=>N.current?.('chat'),0);else{const s=t.get('open');s&&v.includes(s)&&setTimeout(()=>N.current?.(s),0)}},[]);const O=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),b=(0,d.useReminders)(t=>t.done.length);(0,t.useEffect)(()=>{s.useNotifs.getState().ensure(u);const t=()=>{const t=h(),c=s.useNotifs.getState(),v=n.useOwner.getState().staff.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),w=v.filter(s=>!1!==s.active&&(0,p.shiftNow)(s.id,t).on).map(t=>t.id);for(const n of c.items){if(n.rid!==u)continue;const p=`sched:${n.id}`;if(!S||n.removed||n.paused||!n.sendBy.inApp||!(0,f.isRecipient)(n,S,v,w)){(0,l.dismissNotice)(p);continue}const{due:D,forDate:O}=(0,f.notifDue)(n,t),b=d.useReminders.getState().done.find(t=>t.reminderId===n.id&&t.forDate===O),R=`sched:${n.id}:${O}`;!D||b||(c.snooze[R]??0)>t?(0,l.dismissNotice)(p):(0,l.notify)({id:p,icon:'\ud83d\udd14',kicker:'NOTICE',title:n.title,body:n.message,testID:'sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'sched-notice-done',onPress:()=>d.useReminders.getState().markDone({rid:u,reminderId:n.id,forDate:O,at:new Date(h()).toISOString(),staffRef:S,staffName:I.current.replace(' (example)','')})},...'orderlists'===n.open?.page&&N.current?[{label:'Open list',testID:'sched-notice-open',onPress:()=>{o.useListOpen.getState().request(n.open?.list),N.current?.('orderlists')}}]:[],{label:'Later',kind:'ghost',testID:'sched-notice-later',onPress:()=>s.useNotifs.getState().setSnooze(R,h()+9e5)}]})}};t();const c=setInterval(t,2e4);return()=>clearInterval(c)},[u,S,O,b])};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),u=r(_d[6]),f=r(_d[7]),l=r(_d[8]),p=r(_d[9]);const h=()=>{try{return(0,u.nowFrom)(u.useStore.getState().clock).getTime()}catch{return Date.now()}},S=15,v=['bookings','rota','notifications','chat']},1112,[34,1036,891,1040,1113,1009,831,1037,1001,1094]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useChatOpen",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)()(t=>({request:n=>t({ch:n})}))},1113,[846]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useOffRotaPrompt=function({rid:r,staffId:k}){const w=(0,o.useRef)(!1),h=(0,n.useClockArea)(o=>{const n=o.areas[r];return!(0,t.privateClockVenue)(r)&&!!n&&!1!==n.offRotaPrompt&&null!=n.lat});(0,o.useEffect)(()=>{if(!h||!k)return;const t=async()=>{if(w.current||'undefined'!=typeof document&&'hidden'===document.visibilityState)return;const t=(0,n.areaOf)(r);if(!(0,a.areaSet)(t)||!t.offRotaPrompt)return;const o=l(),y=(0,f.ukClock)(o).ymd,h=`${y}:${k}`,b=s.useOwner.getState();if(n.useClockArea.getState().visiting[h]||(0,s.openShiftOf)(b.attendance,k,new Date(o)))return void(0,d.dismissNotice)('off-rota');if(!await(0,c.locationAllowed)())return;w.current=!0;const v=await(0,c.getFix)();if(w.current=!1,'object'!=typeof v)return;const S=new Date(o),I=b.shifts.filter(t=>t.staffId===k&&t.date===y&&!1!==t.published);(0,a.offRotaDue)({area:t,inside:(0,a.isInside)(t,v).inside,clockedIn:!1,shifts:I,nowHours:S.getHours()+S.getMinutes()/60,dismissedToday:!1})?(0,d.notify)({id:'off-rota',icon:'\ud83d\udccd',kicker:'AT THE VENUE',title:t.offRotaTitle,body:t.offRotaBody,testID:'off-rota',timeoutMs:null,actions:[{label:'Yes, clock me in',testID:'off-rota-yes',onPress:()=>{(0,u.clockAction)('in',{rid:r,staffId:k,date:y,at:new Date(l()).toISOString(),offRota:!0}).then(t=>{(0,d.notify)(t.ok?{id:'off-rota-done',title:'Clocked in',body:'Your manager will see you weren\u2019t on the rota today.',timeoutMs:6e3}:{id:'off-rota-done',tone:'warn',title:'Not clocked in',body:t.message,timeoutMs:9e3})})}},{label:'No, just visiting',kind:'ghost',testID:'off-rota-no',onPress:()=>n.useClockArea.getState().setVisiting(h)}]}):(0,d.dismissNotice)('off-rota')};t();const o=setInterval(()=>{t()},y),b=()=>{'visible'===document.visibilityState&&t()};return'undefined'!=typeof document&&document.addEventListener('visibilitychange',b),()=>{clearInterval(o),'undefined'!=typeof document&&document.removeEventListener('visibilitychange',b)}},[r,k,h])},e.useOffRotaAlerts=function({enabled:t}){const n=(0,o.useRef)(new Set),r=(0,s.useOwner)(t=>t.attendance);(0,o.useEffect)(()=>{if(!t)return;const o=(0,f.ukClock)(l()).ymd;for(const t of r){if(!t.offRota||t.date!==o||n.current.has(t.id))continue;n.current.add(t.id);const r=s.useOwner.getState().staff.find(o=>o.id===t.staffId)?.name??'Someone',a=t.in?new Date(t.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';(0,d.notify)({id:`off-rota-mgr:${t.id}`,icon:'\ud83d\udccd',kicker:'NOT ON THE ROTA',title:`${r} clocked in at ${a}`,body:'They weren\u2019t on today\u2019s rota. Check Hours if that\u2019s not right.',timeoutMs:null,actions:[{label:'OK',testID:'off-rota-mgr-ok',onPress:()=>{}}]})}},[r,t])};var t=_r(_d[0]),o=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),a=_r(_d[5]),f=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]);const l=()=>{try{return(0,r.nowFrom)(r.useStore.getState().clock).getTime()}catch{return Date.now()}},y=24e4},1114,[997,34,1042,891,831,998,1010,1096,1001,1095]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SeatAllergenReminder=function({rid:c}){const u=(0,n.useRef)(new Set);return(0,n.useEffect)(()=>s.useStore.subscribe((n,s)=>{if(n.bookings===s.bookings)return;const h=new Map(s.bookings.map(t=>[t.id,t.status]));for(const s of n.bookings){if(s.restaurantId!==c||'seated'!==s.status||!(0,l.hasAllergens)(s)||u.current.has(s.id))continue;const n=h.get(s.id);n&&'seated'!==n&&(u.current.add(s.id),(0,o.notify)({id:`seat-allergen:${s.id}`,tone:'urgent',testID:'seat-allergen-reminder',icon:'\u26a0\ufe0f',kicker:'RE-CONFIRM ALLERGENS AT THE TABLE',title:`${s.name} \xb7 ${s.partySize} Covers${s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:''}`,body:`${(0,l.allergenText)(s)}. Before taking the order, check the allergens with the guests again and tell the kitchen about any change.`,actions:[{label:'Done, re-confirmed with the guests',testID:'seat-allergen-ok'}]}))}}),[c]),null},e.useKitchenTodoChime=function(t,u,h){const f=(0,s.useStore)(n=>n.bookings.filter(n=>n.restaurantId===t&&n.date>=u&&!n.walkIn&&((0,l.needsAllergenSeen)(n)||(0,l.needsHoldOk)(n))).map(t=>t.id).sort().join(',')),k=f?f.split(',').length:0,b=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const t=s.useStore.getState().bookings.filter(t=>f.split(',').includes(t.id)),n=b.current;if(b.current=t.map(t=>t.id),null===n)return;const k=t.filter(t=>!n.includes(t.id));if(k.length){(0,c.soundAllowed)()&&(0,c.chime)('bright');for(const t of k){const n=(0,l.needsAllergenSeen)(t);(0,o.notify)({id:`kitchen-todo:${t.id}`,tone:n?'urgent':'warn',testID:'kitchen-todo-notice',icon:n?'\u26a0\ufe0f':'\ud83c\udf7d\ufe0f',kicker:n?'ALLERGENS TO SIGN OFF':'PLATTER TO SIGN OFF',title:`${t.name} \xb7 ${t.partySize} Covers \xb7 ${t.date===u?'today':t.date} ${t.time}`,body:n?`${(0,l.allergenText)(t)}. Tap Allergens seen on the booking once the kitchen has read it.`:'A platter is booked. Tap Platter OK on the booking once the kitchen can do it.',actions:[...h?[{label:'Open bookings',onPress:h}]:[],{label:'Later',kind:'ghost'}]})}}},[f]),k};var t=r(d[0]),n=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5])},1115,[860,34,1001,874,1101,1048]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TodaysBookings=function({rid:s,today:o,by:S,app:j}){const $=(0,n.useBookings)(s).filter(e=>e.date===o&&(0,u.ACTIVE)(e)).sort((e,t)=>e.time.localeCompare(t.time)),w=$.reduce((e,t)=>e+(t.diet?.vegan??0),0),T=$.reduce((e,t)=>e+(t.diet?.vegetarian??0),0);return(0,x.jsxs)(a.default,{style:{gap:12},testID:"todays-bookings",children:[(0,x.jsx)(p.CoversToday,{rid:s}),(0,x.jsx)(b.PlattersBooked,{rid:s,date:o,label:"Platters booked today"}),w||T?(0,x.jsxs)(l.T,{colour:h.colours.ok,children:["\u24cb ",w?`${w} vegan`:'',w&&T?' \xb7 ':'',T?`${T} vegetarian`:''," today"]}):null,(0,x.jsx)(b.KitchenSignoffs,{rid:s,today:o,by:S,app:j,showAll:!0}),$.length?$.map(o=>(0,x.jsxs)(a.default,{testID:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?`kitchen-seated-${o.id}`:`kitchen-booking-${o.id}`,style:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?{gap:6,padding:14,borderRadius:16,...(0,c.seatedHighlightStyle)()}:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface,opacity:'finished'===o.status?.55:1},children:[(0,x.jsxs)(l.T,{weight:"semibold",colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,accessibilityLabel:`${o.time}, ${o.walkIn?`Walk-in ${o.ref}`:o.name}, ${o.partySize} Covers${o.table?`, ${(0,e.tableNumbersA11y)(o.table)}`:''}`,children:[o.time," \xb7 ",o.walkIn?`Walk-in ${o.ref}`:o.name," \xb7 ",o.partySize," Covers",o.table?` \xb7 ${(0,e.tableNumbers)(o.table)}`:'']}),(0,x.jsx)(t.DepositChip,{b:o,money:!0,testID:`kitchen-deposit-${o.id}`}),(0,x.jsx)(k.BookingTableButton,{rid:s,booking:o,readOnly:'chef'===j}),'chef'!==j&&o.walkIn?(0,x.jsx)(y.CancelWalkInButton,{rid:s,b:o,small:!0}):null,o.notes?(0,x.jsxs)(l.T,{size:16,colour:(0,c.isSeatedHighlight)((0,u.shownStatus)(o))?c.SEATED_FG:h.colours.text,testID:`kitchen-notes-${o.id}`,children:["Notes: ",o.notes]}):null,(0,x.jsx)(f.BookingEditButton,{rid:s,booking:o,who:S,inStaffApp:'staff'===j}),(0,x.jsx)(b.BookingNeeds,{b:o}),'seated'===(0,u.shownStatus)(o)?(0,x.jsx)(l.T,{weight:"semibold",colour:c.SEATED_FG,children:"Seated"}):'finished'===o.status?(0,x.jsx)(l.Muted,{children:"Finished"}):null]},o.id)):(0,x.jsx)(l.Muted,{children:"No bookings today yet."})]})};var e=r(d[0]),t=r(d[1]);r(d[2]);var s,o=r(d[3]),a=(s=o)&&s.__esModule?s:{default:s},l=r(d[4]),n=r(d[5]),u=r(d[6]),h=r(d[7]),c=r(d[8]),b=r(d[9]),k=r(d[10]),y=r(d[11]),f=r(d[12]),p=r(d[13]),x=r(d[14])},1116,[860,1117,34,102,794,874,1101,821,1118,1107,1119,1140,1143,1099,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DepositChip=function({b:e,money:o,big:n,testID:b}){const f=(0,s.depositView)(e,o);if(!f)return null;const h={gold:[t.colours.goldTint,t.colours.goldLight,t.colours.gold],amber:[t.colours.amberBg,'#FFE2A8',t.colours.amber],red:[t.colours.redBg,'#FFD9D4',t.colours.red],neutral:[t.colours.surface2,t.colours.muted,t.colours.border]}[f.kind];return(0,u.jsxs)(l.default,{accessible:!0,accessibilityRole:"text",accessibilityLabel:f.a11y,testID:b??'deposit-chip',style:{alignSelf:'flex-start',maxWidth:'100%'},children:[(0,u.jsx)(l.default,{style:{backgroundColor:h[0],borderColor:h[2],borderWidth:n?2:1,borderRadius:8,paddingHorizontal:n?12:8,paddingVertical:n?6:3},children:(0,u.jsx)(c.T,{size:16,weight:"semibold",colour:h[1],children:f.label})}),f.note?(0,u.jsx)(c.Muted,{size:12,children:f.note}):null]})},r(d[0]);var e,o=r(d[1]),l=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),t=r(d[3]),c=r(d[4]),u=r(d[5])},1117,[34,102,14,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SEATED_BG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"SEATED_FG",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SEATED_MUTED",{enumerable:!0,get:function(){return u}}),e.isSeatedHighlight=function(t,o){return'seated'===t&&!o?.otherDay},e.seatedHighlightStyle=function(u){return{backgroundColor:o,borderColor:t.colours.goldLight,borderWidth:1.5,borderLeftWidth:8,borderLeftColor:n,...u}};var t=r(d[0]);const o=t.colours.gold,n=t.colours.onGold,u='#3F3218'},1118,[821]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingTableButton=function({rid:e,booking:l,readOnly:y,turnBase:B=90,testID:f}){const[h,j]=(0,t.useState)(!1),k=(0,s.tableButtonLabel)(l.table),x=f??`table-btn-${l.id}`;if(y)return(0,c.jsx)(n.default,{testID:x,accessible:!0,accessibilityLabel:(0,s.tableButtonA11y)(l.table,!0),style:{minHeight:44,justifyContent:'center'},children:(0,c.jsx)(b.T,{size:16,weight:"semibold",colour:o.colours.goldLight,children:k})});return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(b.Button,{kind:"secondary",label:k,testID:x,accessibilityLabel:(0,s.tableButtonA11y)(l.table),onPress:()=>j(!0),style:{minHeight:44}}),h?(0,c.jsx)(u.TablePicker,{rid:e,booking:l,name:l.walkIn?'Walk-in':(l.name??'').replace(' (example)',''),turnBase:B,onClose:()=>j(!1)}):null]})};var e,t=r(d[0]),l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),b=r(d[5]),c=r(d[6])},1119,[34,102,1120,821,1121,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tableButtonLabel",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"tableButtonA11y",{enumerable:!0,get:function(){return s}}),e.tableOptions=function(t,n,o){const s=t.tables.map(t=>t.name).sort(l),c=new Set;return(t.joins??[]).forEach(t=>{t.tables.length>1&&c.add(t.tables.slice().sort(l).join('+'))}),[...n.map(t=>t.table),o].forEach(t=>{const n=a(t);n.length>1&&c.add(n.slice().sort(l).join('+'))}),[...s,...[...c].sort(l)]},e.tableOverlaps=function(t,l,o,s=90){const c=a(l);if(!c.length)return[];const b={...t,table:l};return o.filter(l=>l.id!==t.id&&l.date===t.date&&!['cancelled','noshow','finished'].includes(l.status)&&a(l.table).some(t=>c.includes(t))&&(0,n.startOf)(b)<(0,n.endOf)(l,s)&&(0,n.startOf)(l)<(0,n.endOf)(b,s))},Object.defineProperty(e,"tablePatch",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],l=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),o=n=>(0,t.tableNumbers)(n)||'No table',s=(n,a)=>`${(0,t.tableNumbersA11y)(n)}${a?'':', change table'}`;const c=t=>({table:t||void 0,tableSetHere:!0})},1120,[860,1105]); +__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.saveBookingTables=async function(e,s,t){const l=(0,p.tableKey)(t),o=(0,g.tablesOf)(s.table);await h.repo.bookings.update(s.id,(0,y.tablePatch)(l||null)),'seated'===s.status&&s.date===(0,f.venueYmd)(new Date)&&(o.filter(e=>!(0,g.tablesOf)(l).includes(e)).forEach(s=>g.useFloor.getState().setLive(e,s,{stage:void 0,dirty:!0})),l&&(0,j.resetTableLive)(e,l))},_e.TablePicker=function({rid:e,booking:y,name:f,turnBase:j=90,onClose:$,onSaved:w,onPickOnPlan:T}){const L=(0,g.usePlan)(e),S=(0,h.useBookings)(e),[P,W]=(0,l.useState)(()=>(0,g.tablesOf)((0,p.tableKey)((0,g.tablesOf)(y.table)))),z=(0,l.useMemo)(()=>(0,p.pickGroups)(L),[L]),D=S.filter(e=>e.date===y.date),I=(0,p.seatsOf)(L,P),B=(0,p.seatLine)(I.total,y.partySize),R=(0,p.pickClashes)(y,P,D,j),O=e=>(0,p.pickClashes)(y,[e],D,j)[0]?.with,M=(0,p.tableKey)(P)!==(0,p.tableKey)((0,g.tablesOf)(y.table)),N=(0,m.useBlocks)(e=>e.blocks),_=(0,m.blockAt)(N,e,y.date,y.time),[A,F]=(0,l.useState)(null),G=e=>{F(null),W(s=>(0,p.toggleTable)(s,e))},[Y]=(0,l.useState)(()=>(0,n.bookingSaveBlocker)());(0,l.useEffect)(()=>{Y&&(0,c.announce)(`Tables can't be saved: ${Y}.`)},[Y]);const[K,E]=(0,l.useState)(!1),H=async s=>{(0,o.guardBookingChange)(w,{b:y,tables:s})?(E(!0),$(),await(0,o.saveTablesReported)(e,y,s,f,(0,p.seatsOf)(L,s).total,e=>w?.(e))):$()},U=(0,v.jsxs)(u.default,{style:{gap:8},children:[(0,v.jsxs)(u.default,{testID:"table-pick-total",accessible:!0,accessibilityLabel:`${(0,p.tablesWords)(P)} picked. ${B.text}.`,children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",center:!0,colour:k.colours.goldLight,children:(0,p.tablesWords)(P)}),(0,v.jsx)(x.T,{size:17,center:!0,colour:k.colours.text,children:B.text})]}),_?(0,v.jsx)(u.default,{testID:"table-pick-pause",accessible:!0,accessibilityLabel:`Note. New bookings are paused ${_.from} to ${_.to}${_.reason?` (${_.reason})`:''}. You can still assign tables to this booking.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.goldMuted},children:(0,v.jsxs)(x.T,{size:16,center:!0,colour:k.colours.goldLight,children:["New bookings paused ",_.from,"\u2013",_.to,_.reason?` \xb7 ${_.reason}`:'',". You can still save tables for this booking."]})}):null,R.length?(0,v.jsx)(u.default,{testID:"table-pick-clash",accessible:!0,accessibilityLabel:`Warning. ${(0,p.clashWords)(R)} You can still save.`,style:{padding:10,borderRadius:10,borderWidth:1,borderColor:k.colours.gold},children:(0,v.jsxs)(x.T,{size:16,weight:"semibold",center:!0,colour:k.colours.goldLight,children:[(0,p.clashWords)(R)," You can still save."]})}):null,A?(0,v.jsxs)(u.default,{testID:"table-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:A,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:k.colours.gold,backgroundColor:k.colours.amberBg,alignItems:'stretch'},children:[(0,v.jsx)(x.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:A}),(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,v.jsx)(x.Button,{testID:"table-pick-overcap-yes",label:"Use it anyway",accessibilityLabel:`Use it anyway, ${(0,p.tablesWords)(P)} for ${f}, ${y.partySize} people`,disabled:K,onPress:()=>{H(P)},style:[C,{flexGrow:1}]}),(0,v.jsx)(x.Button,{testID:"table-pick-overcap-no",kind:"secondary",label:"Pick another table",onPress:()=>F(null),style:C})]})]}):null,(0,v.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[A?null:(0,v.jsx)(x.Button,{testID:"table-pick-save",label:K?'Saving\u2026':R.length?'Save anyway':'Save tables',disabled:!M||!P.length||K,accessibilityLabel:`${R.length?'Save anyway, ':'Save, '}${(0,p.tablesWords)(P)} for ${f}. ${B.text}.${R.length?` ${(0,p.clashWords)(R)}`:''}`,onPress:()=>{if(!(0,o.guardBookingChange)(w,{b:y,tables:P}))return void $();const e=(0,p.overCapacityAsk)(P,I.total,y.partySize);!e||A?H(P):F(e)},style:[C,{flexGrow:1}]}),(0,g.tablesOf)(y.table).length?(0,v.jsx)(x.Button,{testID:"table-pick-clear",kind:"secondary",label:"Clear table",accessibilityLabel:`Clear table, take ${(0,p.tablesWords)((0,g.tablesOf)(y.table)).toLowerCase()} off ${f}`,disabled:K,onPress:()=>H([]),style:C}):null,(0,v.jsx)(x.Button,{testID:"table-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",onPress:$,style:C})]})]});return(0,v.jsxs)(x.Sheet,{visible:!0,onClose:$,title:`Tables \xb7 ${y.time} ${f} \xb7 ${y.partySize} Covers`,maxWidth:760,testID:"table-picker",footer:U,children:[(0,v.jsx)(s.TableNumberWarning,{plan:L}),Y?(0,v.jsx)(u.default,{testID:"table-pick-blocked",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:`Tables can't be saved: ${Y}.`,style:{padding:12,borderRadius:12,borderWidth:2,borderColor:k.colours.red,backgroundColor:'#3a1210'},children:(0,v.jsx)(x.T,{size:16,weight:"semibold",center:!0,colour:"#FFD2CC",children:`Tables can't be saved: ${Y}.`})}):null,(0,v.jsx)(x.T,{size:16,center:!0,colour:k.colours.text,children:"Tap one table, or several to join them. Tap again to take one off. Smaller tables can still be used."}),T?(0,v.jsx)(x.Button,{kind:"secondary",testID:"table-pick-on-plan",label:"Pick on the table plan",accessibilityLabel:`Pick on the table plan instead, for ${f}`,onPress:()=>T(P),style:C}):null,z.map(e=>(0,v.jsxs)(u.default,{style:{gap:6},accessibilityLabel:e.area,children:[(0,v.jsx)(x.T,{size:15,weight:"semibold",center:!0,colour:k.colours.gold,children:e.area}),(0,v.jsx)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:e.tables.map(e=>{const s=P.includes(e.name),l=O(e.name);return(0,v.jsxs)(b.default,{testID:`table-pick-${e.name}`,accessibilityRole:"checkbox",accessibilityState:{checked:s},'aria-checked':s,accessibilityLabel:(0,p.pickA11y)(e.name,e.seats,s,l),onPress:()=>G(e.name),style:({pressed:e})=>({minWidth:92,minHeight:64,paddingHorizontal:10,paddingVertical:6,borderRadius:12,alignItems:'center',justifyContent:'center',borderWidth:s?2:1,borderColor:s?k.colours.gold:l?k.colours.goldMuted:k.colours.hairline,borderStyle:l&&!s?'dashed':'solid',backgroundColor:s?k.colours.gold:e?k.colours.tilePressed:k.colours.tile}),children:[(0,v.jsx)(x.T,{size:18,weight:"semibold",colour:s?k.colours.onGold:k.colours.text,children:(0,t.tableNumbers)(e.name)}),(0,v.jsxs)(x.T,{size:14,colour:s?k.colours.onGold:k.colours.muted,children:[e.seats," seats",l?' \xb7 booked':'']})]},e.name)})})]},e.area)),z.length?null:(0,v.jsx)(x.Muted,{center:!0,children:"No tables on the plan yet. Add them in Setup \u203a Table plan."})]})};var s=r(d[0]),t=r(d[1]),l=r(d[2]),o=r(d[3]),n=r(d[4]),c=r(d[5]),b=e(r(d[6])),u=e(r(d[7])),h=r(d[8]),g=r(d[9]),y=r(d[10]),p=r(d[11]),k=r(d[12]),f=r(d[13]),x=r(d[14]),j=r(d[15]),m=r(d[16]),v=r(d[17]);const C={minHeight:56}},1121,[1122,860,34,1123,987,1125,402,102,874,1029,1120,1124,821,858,794,1126,1026,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.TableNumberWarning=function({plan:u}){const c=(0,n.numberClashes)(u.tables),o=[...new Set([...c.acrossAreas,...u.tables.filter(n=>c.sameArea.has(n.name)).map(n.tableNumber)])];return o.length?(0,l.jsxs)(t.T,{testID:"duplicate-table-numbers",size:16,colour:s.colours.goldLight,children:["Duplicate table numbers: ",o.join(', '),". Kept unchanged. Ask a manager to check the areas before assigning."]}):null},r(d[0]);var n=r(d[1]),s=r(d[2]),t=r(d[3]),l=r(d[4])},1122,[34,859,821,794,25]); +__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.guardBookingChange=w,_e.saveTablesReported=async function(e,t,n,o,s,u){if(!w(u,{b:t,tables:n}))return!1;const v=n.length?(0,h.notSavedWhat)({...t,name:o,table:n.join('+')}):`Taking the table off ${o}`;u(`Saving ${v}\u2026`);try{await(0,b.saveBookingTables)(e,t,n)}catch(e){const t=`${v} did not save: ${String(e?.message??e).slice(0,120)}`;return u(t),(0,l.announce)(t),!1}const y=await(0,c.waitForBookingSave)(t.id);if('saved'===y.state||'local'===y.state){const e=(0,r.savedWords)(o,t.partySize,n,s);return u(e),(0,l.announce)(e),!0}const k='waiting'===y.state?`${v}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${v} did not save. ${f("why"in y?y.why:"the shared system did not take it")}. Tap the red banner to try again.`;return u(k),(0,l.announce)(k),!1},_e.reportBookingSave=async function(e,t,n,o){const s=await(0,c.waitForBookingSave)(e);if('saved'===s.state||'local'===s.state)return o(t),(0,l.announce)(t),!0;const r='waiting'===s.state?`${n}: not saved yet. It saves by itself when the connection is back; a red banner shows if it fails.`:`${n} did not save. ${f('why'in s?s.why:'the shared system did not take it')}. Tap the red banner to try again.`;return o(r),(0,l.announce)(r),!1},_e.BookingSaveBanner=function({rid:e,testID:r="booking-save-banner",margin:c}){const b=(0,h.useBookingSaves)(e=>e.notSaved),w=(0,s.useBookings)(e).filter(e=>b[e.id]).map(e=>void 0!==b[e.id].want?{...e,table:b[e.id].want||void 0}:e),{msg:S,retry:$}=k(),m=(0,t.useRef)(''),p=w.map(e=>(0,h.notSavedLine)(e)),B=w.map(e=>e.id).sort().join(',');if((0,t.useEffect)(()=>{B&&B!==m.current&&(0,l.announce)(1===w.length?p[0]:`${w.length} booking changes did not save. Tap the red banner to try again.`),m.current=B},[B]),!w.length)return null;const j=1===w.length?p[0]:`${w.length} booking changes did not save. Tap to try again.`;return(0,y.jsx)(n.default,{testID:r,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${j}${w.length>1?` ${w.map(e=>(0,h.notSavedWhat)(e)).join('. ')}.`:''} ${f(b[w[0].id].why)}.`,onPress:$,style:{...c??{},alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:(0,y.jsxs)(o.default,{accessibilityRole:"alert",style:{alignItems:'center',gap:4},children:[(0,y.jsx)(v.T,{testID:`${r}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:j}),w.length>1?w.slice(0,6).map(e=>(0,y.jsx)(v.T,{testID:`${r}-line`,size:15,center:!0,colour:"#FFD2CC",children:(0,h.notSavedWhat)(e)},e.id)):null,(0,y.jsx)(v.T,{testID:`${r}-why`,size:14,center:!0,colour:"#FFB3AA",children:w.length>1?`${f(b[w[0].id].why)}${w.length>6?` \xb7 and ${w.length-6} more`:''}`:f(b[w[0].id].why)}),S?(0,y.jsx)(v.T,{testID:`${r}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:S}):null]})})},_e.BookingNotSavedLine=function({b:e}){const t=(0,h.useBookingSaves)(t=>t.notSaved[e.id]),{msg:o,retry:s}=k();if(!t)return null;void 0!==t.want&&(e={...e,table:t.want||void 0});return(0,y.jsxs)(n.default,{testID:`booking-not-saved-${e.id}`,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${(0,h.notSavedLine)(e)} ${f(t.why)}.`,onPress:s,style:{alignSelf:'stretch',padding:8,borderRadius:10,borderWidth:1.5,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,y.jsx)(v.T,{size:15,weight:"semibold",center:!0,colour:"#FFD2CC",children:(0,h.notSavedLine)(e)}),o?(0,y.jsx)(v.T,{size:13,center:!0,colour:u.colours.goldLight,children:o}):null]})};var t=_r(d[0]),n=e(_r(d[1])),o=e(_r(d[2])),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),u=_r(d[8]),b=_r(d[9]),v=_r(d[10]),y=_r(d[11]);const f=e=>e.charAt(0).toUpperCase()+e.slice(1);function w(e,t){const n=(0,c.bookingSaveBlocker)();if(!n)return!0;t&&h.useBookingSaves.getState().mark({id:t.b.id,table:t.b.walkIn?'walk_ins':'bookings',why:n,...t.tables?{want:t.tables.join('+')}:{}});const o=`${t?(0,h.notSavedWhat)({...t.b,...t.tables?{table:t.tables.join('+')||void 0}:{}}):'This change'} did not save: ${n}.`;return e?.(o),(0,l.announce)(o),!1}function k(){const[e,n]=(0,t.useState)('');return{msg:e,retry:async()=>{n('Saving\u2026'),(0,l.announce)('Saving');const e=await(0,c.saveBookingsNow)(!0),t=e?`Not saved: ${e}.`:h.useBookingSaves.getState().count()?'Sent again. The banner clears when the shared system takes it.':'Nothing is left waiting. Check the plan and make the change again if it is not there.';n(t),(0,l.announce)(t)}}}},1123,[34,402,102,874,1124,1125,987,1021,821,1121,794,25]); +__d(function(_g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"byNum",{enumerable:!0,get:function(){return s}}),e.tableKey=o,e.toggleTable=function(t,n){return t.includes(n)?t.filter(t=>t!==n):a(o([...t,n]))},e.seatsOf=function(t,n){const a={};for(const s of n)a[s]=t.tables.find(t=>t.name===s)?.maxSeats??0;return{per:a,total:Object.values(a).reduce((t,n)=>t+n,0)}},e.seatLine=function(t,n){const a=Math.max(0,n-t);return{text:`${t} ${1===t?'seat':'seats'} for ${l(n)}${a?`: ${a} short`:''}`,short:a,fits:0===a&&t>0}},e.pickClashes=u,e.requestedFreeTable=function(t,n,a,s,l=90){const o={id:n.id??'new',status:'confirmed',...n};for(const n of t)if(a.includes(n)&&!u(o,[n],s,l).length)return n;return null},e.overCapacityAsk=function(n,s,l){const u=a(o(n));if(!u.length||s>=l)return null;const c=u.map(n=>(0,t.tableNumbers)(n));return`${1===c.length?`Table ${c[0]} seats`:`Tables ${c.slice(0,-1).join(', ')} and ${c[c.length-1]} seat`} ${s} \u2013 this booking is ${l}. Use it anyway?`},e.clashWords=function(n){return n.map(n=>`${(0,t.tableNumbers)(n.table)} has ${n.with.walkIn?'a walk-in':(n.with.name||'a booking').replace(' (example)','')} at ${n.with.time}`).join('. ')+(n.length?'.':'')},e.tablesWords=c,e.pickA11y=function(n,a,s,l){return`Table ${(0,t.tableNumbers)(n)}, ${a} ${1===a?'seat':'seats'}${s?', selected':''}${l?`, has ${l.walkIn?'a walk-in':l.name} at ${l.time}`:''}`},e.pickGroups=function(t){return t.areas.map(n=>({area:n.name,tables:t.tables.filter(t=>t.areaId===n.id).map(t=>({name:t.name,seats:t.maxSeats})).sort((t,n)=>s(t.name,n.name))})).filter(t=>t.tables.length)},e.savedWords=function(t,n,a,s){return a.length?`${t}, ${l(n)}: ${c(a)} (${s} seats).`:`${t}: table taken off.`},e.tableActions=function(t,n){const s=a(t.table);if(['cancelled','noshow'].includes(t.status))return[];const o=[s.length?{id:'assign',label:'Change table',a11y:`Change table for ${n}, ${l(t.partySize)}, now ${c(s).toLowerCase()}. You can pick several tables to join.`}:{id:'assign',label:'Assign table',a11y:`Assign table for ${n}, ${l(t.partySize)}. You can pick several tables to join.`}];s.length&&o.push({id:'clear',label:'Clear table',a11y:`Clear table for ${n}, take ${c(s).toLowerCase()} off this booking`});return o},e.dragTables=function(t,n,s){if(!s||'__none'===s||s===n)return null;const l=a(t);if(l.includes(s))return null;return o('__none'!==n&&l.includes(n)?l.map(t=>t===n?s:t):[s])};var t=r(d[0]),n=r(d[1]);const a=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=(t,n)=>t.localeCompare(n,'en-GB',{numeric:!0}),l=t=>`${t} ${1===t?'person':'people'}`;function o(t){return[...new Set(t.map(t=>String(t).trim()).filter(Boolean))].sort(s).join('+')}function u(t,l,u,c=90){if(!l.length)return[];const f={...t,table:o(l)},b=[];for(const s of u)if(s.id!==t.id&&s.date===t.date&&!['cancelled','noshow','finished'].includes(s.status)&&(0,n.startOf)(f)<(0,n.endOf)(s,c)&&(0,n.startOf)(s)<(0,n.endOf)(f,c))for(const t of a(s.table))l.includes(t)&&b.push({table:t,with:s});return b.sort((t,n)=>s(t.table,n.table))}function c(n){const s=a(o(n));return s.length?(0,t.tableListNumbers)(s):'No table'}},1124,[860,1105]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.primeAnnouncer=function(){u()},_e.announce=function(t){const e=String(t??'').trim();if(!e)return;{const t=u();if(!t)return;const n=++o;return t.textContent='',void setTimeout(()=>{n===o&&(t.textContent=e)},80)}},Object.defineProperty(_e,"lastAnnounced",{enumerable:!0,get:function(){return c}});var t,e=r(d[0]);(t=e)&&t.__esModule;r(d[1]);let n=null,o=0;function u(){if('undefined'==typeof document||!document.body)return null;if(n&&document.body.contains(n))return n;const t=document.createElement('div');return t.id='cc-announcer',t.setAttribute('aria-live','assertive'),t.setAttribute('aria-atomic','true'),t.setAttribute('role','status'),t.setAttribute('data-testid','cc-announcer'),Object.assign(t.style,{position:'absolute',width:'1px',height:'1px',margin:'-1px',padding:'0',overflow:'hidden',clip:'rect(0 0 0 0)',whiteSpace:'nowrap',border:'0'}),document.body.appendChild(t),n=t,t}const c=()=>n?.textContent??''},1125,[281,236]); +__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,"TABLES",{enumerable:!0,get:function(){return L}}),_e.useTableNames=F,_e.resetTableLive=R,_e.seatBookingNow=W,_e.finishBookingNow=async function(e,t){await f.repo.bookings.setStatus(t.id,'finished'),(0,S.tablesOf)(t.table).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!0}))},_e.useTableUse=A,Object.defineProperty(_e,"walkInLabel",{enumerable:!0,get:function(){return E}}),_e.TablePicker=H,_e.WalkInSheet=Y,_e.WalkInMatchPrompt=q,_e.AssignTableSheet=U,_e.undoNotice=Q,_e.NewBookingSheet=V,_e.useFrontDoor=function(e,t){const[s,o]=(0,d.useState)(!1),[l,a]=(0,d.useState)(!1),[i,n]=(0,d.useState)(null);return{openWalkIn:()=>o({}),openWalkInAt:e=>o({table:e}),openBooking:()=>a(!0),assignTable:e=>n({b:e}),combineTables:e=>n({b:e,combine:!0}),elements:(0,N.jsxs)(N.Fragment,{children:[s?(0,N.jsx)(Y,{wide:t,initialTable:s.table,onClose:()=>o(!1),onSeated:Q}):null,l?(0,N.jsx)(V,{wide:t,date:e,onClose:()=>a(!1),onSaved:e=>(0,r.notify)({id:`booked:${Date.now()}`,testID:'booking-saved-toast',timeoutMs:5e3,icon:'\u2713',title:`Booked: ${e.name} \xb7 ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${e.time}`})}):null,i?(0,N.jsx)(U,{booking:i.b,combine:i.combine,onClose:()=>n(null)}):null]})}};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),a=_r(_d[4]),i=_r(_d[5]),n=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=e(d),c=_r(_d[9]),b=e(_r(_d[10])),h=e(_r(_d[11])),p=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),S=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),D=_r(_d[24]),I=_r(_d[25]),$=_r(_d[26]),P=_r(_d[27]),z=_r(_d[28]),B=_r(_d[29]),O=_r(_d[30]),N=_r(_d[31]);const M=e=>(0,r.notify)({id:'booking-blocked',testID:'booking-blocked-toast',timeoutMs:9e3,icon:'\u26a0',title:e}),L=Array.from({length:12},(e,t)=>String(t+1));function F(e){const t=(0,S.usePlan)(e);return t.areas.flatMap(e=>t.tables.filter(t=>t.areaId===e.id).map(e=>e.name))}function R(e,t){(0,S.tablesOf)(t).forEach(t=>S.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}async function W(e,t){await f.repo.bookings.setStatus(t.id,'seated'),R(e,t.table)}function A(e,t){const s=(0,f.useBookings)(e),o=(0,f.useOrders)(e),l=F(e),a=(0,S.useFloor)(t=>t.live[e])??{},i=(0,S.usePlan)(e),n=(0,C.useBlocks)(e=>e.blocks),r=(0,x.ymd)(t),d=(0,C.closedAreasAt)(n,e,r,(0,x.hm)(t)),u={};for(const e of l)u[e]=a[e]?.blocked||d.has(`tbl:${e}`)?{busy:!0,label:'Blocked'}:d.has(i.tables.find(t=>t.name===e)?.areaId??'')?{busy:!0,label:'Closed'}:a[e]?.dirty?{busy:!0,label:'Needs clearing'}:{busy:!1,label:'Free'};for(const e of s)if(e.date===r&&e.table)for(const s of(0,S.tablesOf)(e.table))if(u[s])if('seated'===e.status)u[s]={busy:!0,label:`${e.walkIn?'Walk-in':`${e.name.slice(0,1)}.`} \xb7 ${e.partySize}`};else if('confirmed'===e.status&&!u[s].busy){const o=(0,x.minsBetween)(t,new Date(`${e.date}T${e.time}:00`));o>=-15&&o<=90&&(u[s]={...u[s],soon:`Booked ${e.time}`})}for(const e of o)'table'===e.type&&e.tableNo&&u[e.tableNo]&&!['closed','cancelled','collected'].includes(e.status)&&!u[e.tableNo].busy&&(u[e.tableNo]={busy:!0,label:'Open order'});return u}const E=e=>e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;function H({use:e,value:t,onPick:s,big:o,best:a,dense:i,bestSet:n,picked:r}){const u=Object.keys(e),[c,p]=(0,d.useState)(0),m=i?6:8,f=i?64:o?92:76,y=c?Math.max(3,Math.floor((c+m)/(f+m))):0,k=y?Math.floor((c-m*(y-1))/y):f,x=new Set(n??[]),w=a?(0,S.tablesOf)(a)[0]:null;return(0,N.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:m},testID:"table-picker",onLayout:e=>p(Math.floor(e.nativeEvent.layout.width)),children:u.map(o=>{const a=e[o],n=t===o||!!r?.includes(o),d=x.has(o),u=w===o&&!n,c=a.busy?['Blocked','Needs clearing','Closed'].includes(a.label)?a.label:'In use':a.soon??'Free';return(0,N.jsxs)(b.default,{accessibilityRole:"button",testID:`pick-table-${o}`,accessibilityLabel:`Table ${(0,l.tableNumbers)(o)}${r?n?', picked':', not picked':''}, ${a.busy?`in use (${a.label})`:a.soon?`free, ${a.soon}`:'free'}${d?', best table':''}${u?', suggested for this party':''}`,accessibilityState:{selected:n,disabled:'Closed'===a.label},disabled:'Closed'===a.label,onPress:()=>s(o),style:{width:k,minHeight:i?58:64,borderRadius:12,borderWidth:n||u?2.5:1.5,paddingVertical:i?3:6,paddingHorizontal:4,alignItems:'center',justifyContent:'center',gap:2,borderColor:n||u?j.colours.gold:a.busy?j.colours.red:j.colours.ok,backgroundColor:n?j.colours.goldTint:a.busy?j.colours.redBg:j.colours.surface2,opacity:'Closed'!==a.label||n?1:.55},children:[(0,N.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:4},children:[(0,N.jsx)(T.T,{weight:"bold",size:22,colour:n?j.colours.goldLight:j.colours.text,children:(0,l.tableNumbers)(o)}),d?(0,N.jsx)(h.default,{testID:"best-table",style:{backgroundColor:j.colours.gold,borderRadius:5,paddingHorizontal:4,paddingVertical:1},children:(0,N.jsx)(T.T,{size:11,weight:"bold",colour:j.colours.onGold,children:"BEST"})}):null]}),(0,N.jsx)(T.T,{size:i?13:14,colour:a.busy?'#FFD9D4':a.soon?'#FFE2A8':'#E2C489',center:!0,numberOfLines:1,children:c})]},o)})})}const _=[1,2,3,4,5,6,7,8];function Y({onClose:e,onSeated:a,wide:i,initialTable:n}){const{rid:y,r:w,now:v}=(0,m.useCtx)(15e3),D=A(y,v),[I,$]=(0,d.useState)(2),[P,B]=(0,d.useState)(!1),[L,F]=(0,d.useState)(n??null),E=(0,S.usePlan)(y),Y=(0,f.useBookings)(y),U=(0,C.useBlocks)(e=>e.blocks),Q=(0,C.closedAreasAt)(U,y,(0,x.ymd)(v),(0,x.hm)(v)),V=u.default.useMemo(()=>{const e=Object.fromEntries(Object.entries(D).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(E,Y.filter(e=>e.date===(0,x.ymd)(v)),e,I,v,(0,k.turnFor)(I,w.settings.turnMins),90,void 0,{closed:Q})?.table??null},[E,Y,D,I,Q.size,v.getTime()]);(0,d.useEffect)(()=>{L&&(0,S.tablesOf)(L).some(e=>'Closed'===D[e]?.label)&&F(null)},[L,Q.size]);const[G,K]=(0,d.useState)(!1),[X,J]=(0,d.useState)(''),Z=(e,t=String(e),s=()=>{B(!1),$(e)})=>{const o='9+'===t?P:!P&&I===e;return(0,N.jsx)(b.default,{accessibilityRole:"button",accessibilityLabel:'9+'===t?'Party of 9 or more':`Party of ${e}`,accessibilityState:{selected:o},onPress:s,style:{width:i?58:60,height:i?58:56,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:o?j.colours.gold:'transparent'},children:(0,N.jsx)(T.T,{weight:"bold",size:22,colour:o?j.colours.onGold:j.colours.gold,children:t})},t)},ee=(0,N.jsx)(s.PartySizeInput,{value:I,onChange:$,min:9,max:o.MAX_PARTY,label:"Walk-in party size",testID:"walkin-party-size"}),te=(0,N.jsxs)(h.default,{style:{gap:8,width:i?256:void 0},children:[(0,N.jsx)(T.T,{weight:"semibold",children:"How many people?"}),(0,N.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"walkin-party",children:[_.map(e=>Z(e)),Z(9,'9+',()=>{B(!0),$(e=>e>=9?e:9)})]}),P?ee:null]}),[se,oe]=(0,d.useState)(!1),[le,ae]=(0,d.useState)(null),ie=async(t=L,s=!1)=>{if(!se&&(0,O.guardBookingChange)(M)){if(!s){const e=(0,z.bookingsNearWalkIn)(Y,v,I);if(e.length)return void ae({at:t,list:e})}oe(!0);try{const s=await f.repo.bookings.seatWalkIn(y,I,t??void 0,X);R(y,t??void 0),a(s),e()}finally{oe(!1)}}},ne=async(t,s)=>{if(!se&&(0,O.guardBookingChange)(M)){oe(!0);try{const o=s??t.table??null;o&&o!==t.table&&await f.repo.bookings.assignTable(t.id,o),await W(y,{...t,table:o??void 0}),(0,r.notify)({id:`seated:${t.id}`,testID:'walkin-match-toast',timeoutMs:5e3,icon:'\u2713',title:`${t.name} seated \xb7 ${t.partySize} \xb7 ${o?(0,l.tableNumbers)(o):'table to assign'} (booking ${t.ref})`}),ae(null),e()}finally{oe(!1)}}},re=(0,N.jsxs)(h.default,{style:{gap:8,flex:i?1:void 0,minWidth:0},children:[(0,N.jsxs)(T.Row,{style:{justifyContent:'space-between'},children:[(0,N.jsxs)(T.T,{weight:"semibold",children:["Table ",(0,N.jsx)(T.T,{colour:j.colours.muted,size:14,children:"(optional)"})]}),L?(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Clear table",onPress:()=>F(null)}):null]}),(0,N.jsx)(H,{use:D,value:L,onPick:e=>{D[e]&&!D[e].busy?ie(e):F(L===e?null:e)},big:i,dense:i,best:V,bestSet:(0,c.bestTables)(E)}),(0,N.jsxs)(T.Muted,{children:["Tap a free table to seat them there",V&&!L?` (suggested for ${I}: ${(0,l.tableNumbers)(V)})`:'',", or Seat for no table yet. BEST marks the venue\u2019s best tables."]})]});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:e,title:`Walk-in \xb7 ${(0,x.hm)(v)}`,maxWidth:i?1100:void 0,testID:"walkin-sheet",children:[(0,N.jsx)(T.Button,{label:`Seat walk-in \xb7 ${I} ${1===I?'person':'people'}${L?` \xb7 ${(0,l.tableNumbers)(L)}`:''}`,disabled:se,onPress:()=>{ie()},testID:"seat-walkin",style:{minHeight:52}}),i?(0,N.jsxs)(T.Row,{gap:16,style:{alignItems:'flex-start'},children:[te,re]}):(0,N.jsxs)(N.Fragment,{children:[te,re]}),(0,N.jsxs)(T.Row,{gap:10,wrap:!0,style:{alignItems:'center'},children:[G?(0,N.jsx)(t.TextInput,{accessibilityLabel:"Walk-in note",placeholder:"Note (optional), e.g. high chair",placeholderTextColor:"#7D776C",value:X,onChangeText:J,style:[T.styles.input,{flex:1,minWidth:220}],autoFocus:!0}):(0,N.jsx)(T.Button,{small:!0,kind:"ghost",label:"Add a note (optional)",onPress:()=>K(!0)}),(0,N.jsx)(h.default,{style:{flex:1,minWidth:220},children:(0,N.jsxs)(T.Muted,{children:["No name needed. Counts in today's covers.",'staff'!==p.APP_VARIANT?' Using website bookings too? Mark the table there as well.':'']})})]}),le?(0,N.jsx)(q,{list:le.list,busy:se,onYes:e=>{ne(e,le.at)},onNo:()=>{const e=le.at;ae(null),ie(e,!0)},onClose:()=>ae(null)}):null]})}function q({list:e,busy:t,onYes:s,onNo:o,onClose:a}){return(0,N.jsx)(T.Sheet,{visible:!0,onClose:a,title:"Booked party?",maxWidth:720,testID:"walkin-match",children:(0,N.jsxs)(h.default,{style:{gap:14},children:[e.map((e,o)=>(0,N.jsxs)(h.default,{testID:`walkin-match-${o}`,style:{gap:12,padding:16,borderRadius:16,borderWidth:2,borderColor:j.colours.gold,backgroundColor:'#15130F'},children:[(0,N.jsx)(h.default,{accessibilityRole:"header",accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:26,weight:"bold",colour:j.colours.goldLight,testID:"walkin-match-question",children:(0,z.walkInMatchQuestion)(e)})}),e.table?(0,N.jsxs)(T.T,{size:17,colour:j.colours.text,children:["Booked table ",(0,l.tableNumbers)(e.table)," \xb7 ",e.ref]}):(0,N.jsx)(T.T,{size:17,colour:j.colours.text,children:e.ref}),(0,N.jsx)(T.Button,{label:"Yes, seat booking",testID:"walkin-match-yes",disabled:t,accessibilityLabel:`Yes, seat ${e.name}'s booking, ${e.partySize} people`,onPress:()=>s(e),style:{minHeight:64}})]},e.id)),(0,N.jsx)(T.Button,{kind:"secondary",label:"No, new walk-in",testID:"walkin-match-no",disabled:t,onPress:o,style:{minHeight:64}})]})})}function U({booking:e,onClose:t,combine:s}){const{rid:o,r:a,now:i}=(0,m.useCtx)(15e3),n=A(o,i),r=(0,S.usePlan)(o),b=(0,f.useBookings)(o),p=(0,S.tablesOf)(e.table),y=u.default.useMemo(()=>Object.fromEntries(Object.entries(n).map(([e,t])=>[e,p.includes(e)?{busy:!1,label:'This party',soon:'This party'}:t])),[n,e.table]),w=u.default.useMemo(()=>{const t=Object.fromEntries(Object.entries(y).map(([e,t])=>[e,{status:t.busy?'seated':'free'}]));return(0,k.suggestTable)(r,b.filter(e=>e.date===(0,x.ymd)(i)),t,e.partySize,i,(0,k.turnFor)(e.partySize,a.settings.turnMins),90,e.id)?.table??null},[r,b,y,e.partySize,i.getTime()]),[C,v]=(0,d.useState)(!!s||p.length>1),[D,I]=(0,d.useState)(p),$=e=>r.tables.find(t=>t.name===e)?.maxSeats??0,P=D.reduce((e,t)=>e+$(t),0),z=D.length>0&&P{if(!(0,O.guardBookingChange)(M))return;const l=(0,S.joinTables)(s);await f.repo.bookings.assignTable(e.id,l);p.filter(e=>!s.includes(e)).forEach(t=>S.useFloor.getState().setLive(o,t,{stage:void 0,dirty:'seated'===e.status})),'seated'===e.status&&R(o,l),t()},L=C?(0,N.jsxs)(h.default,{style:{gap:8},testID:"assign-table-tip",children:[(0,N.jsx)(h.default,{accessibilityLiveRegion:"polite",children:(0,N.jsx)(T.T,{size:17,weight:"semibold",colour:j.colours.text,children:D.length?`${(0,S.tablesLabel)((0,S.joinTables)(D))} \xb7 ${P} seats for ${e.partySize} Covers`:'No tables picked yet'})}),z?(0,N.jsx)(h.default,{testID:"combine-short",children:(0,N.jsxs)(T.T,{size:15,weight:"semibold",colour:"#FFD9D4",children:["Not enough seats yet: ",e.partySize-P," more needed. Add another table."]})}):null,(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Tap each table to add or remove it, then tap Done. All of them show as taken until the party has finished."}),(0,N.jsxs)(T.Row,{gap:8,wrap:!0,children:[(0,N.jsx)(T.Button,{label:"Done",testID:"combine-done",disabled:!D.length,accessibilityLabel:D.length?`Done, save ${(0,S.tableCardLabel)((0,S.joinTables)(D))}`:'Done',onPress:()=>B(D)}),(0,N.jsx)(T.Button,{kind:"ghost",label:"Cancel",onPress:t})]})]}):(0,N.jsx)(h.default,{style:{gap:8},testID:"assign-table-tip",children:(0,N.jsx)(T.T,{size:15,colour:j.colours.text,children:"Red tables are in use right now; you can still pick one (e.g. joining a table). BEST marks the venue\u2019s best tables. Big party? Tap Combine tables."})});return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`${C?'Combine tables':'Assign table'} \xb7 ${E(e)}`,testID:"assign-table-sheet",footer:L,children:[w&&!C?(0,N.jsx)(h.default,{testID:"assign-suggested",children:(0,N.jsxs)(T.T,{size:16,weight:"semibold",colour:j.colours.goldLight,accessibilityLabel:`Suggested for ${e.partySize}: ${(0,S.tableCardLabel)(w)}`,children:["Suggested for ",e.partySize,": ",(0,l.tableNumbers)(w)]})}):null,C?null:(0,N.jsx)(T.Button,{kind:"secondary",label:"Combine tables",testID:"combine-start",accessibilityLabel:"Combine tables: pick several tables for this party",onPress:()=>v(!0)}),(0,N.jsx)(H,{use:y,best:C?null:w,bestSet:(0,c.bestTables)(r),picked:C?D:void 0,onPick:C?e=>I(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]):async e=>{await B([e])}})]})}function Q(e){(0,r.notify)({id:`walkin:${e.id}`,testID:'walkin-toast',timeoutMs:6e3,title:`${E(e)} seated \xb7 ${e.table?`${(0,l.tableNumbers)(e.table)}`:'table to assign'} (${e.ref})`,actions:[{label:'Undo',testID:'undo-walkin',onPress:()=>f.repo.bookings.undoWalkIn(e.id)},{label:'OK',kind:'ghost'}]})}function V({date:e,onClose:t,wide:r,onSaved:u}){const{rid:c,r:b,now:p,role:z,meId:L}=(0,m.useCtx)(6e4),F=(0,x.ymd)(p),[R,W]=(0,d.useState)(ee.blocks),[H,_]=(0,d.useState)(!1),[Y,q]=(0,d.useState)(''),[U,Q]=(0,d.useState)(2),[V,G]=(0,d.useState)(0),K=Math.min(V,Math.max(0,U-1)),[X,J]=(0,d.useState)(null),[Z,ee]=(0,d.useState)(''),[te,se]=(0,d.useState)(''),[oe,le]=(0,d.useState)(''),[ae,ie]=(0,d.useState)('phone'),[ne,re]=(0,d.useState)((0,D.emptyNeeds)()),de=(0,D.needsMissing)(ne),[ue,ce]=(0,d.useState)(null),be=(0,S.usePlan)(c),he=(0,P.dogSetUp)(be),ge=!0===ne.dog&&he,pe=ne.dog?ne.dogs:0,me=(0,x.parseYmd)(R),fe=(0,k.turnFor)(U,b.settings.turnMins),ye=A.filter(e=>e.date===R),ke=e=>(0,k.freeTablesAt)(be,ye,U,new Date(`${R}${(0,l.tableNumbers)(e)}:00`),fe,b.settings.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(E,c,R,e)}),xe=ge&&X?ke(X):[];(0,d.useEffect)(()=>{ce(null)},[ge,X,U]);const je=(0,y.bookingSlots)(b,me,e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).reduce((e,t)=>e+t.partySize,0),U,R===(0,x.ymd)(p)?p:(0,x.addMins)(me,0),e=>A.filter(t=>t.date===R&&t.time===e&&'cancelled'!==t.status&&!t.walkIn).length),we=(0,w.ukPhone)(te),[Te,Se]=(0,d.useState)(!1),Ce=X?je.find(e=>e.time===X):void 0,ve=Ce&&Ce.left=2&&!!X&&(!Ie||Te)&&(0,o.validParty)(U)&&we.ok&&(0,w.emailOk)(oe)&&(!$e||Pe&&H)&&(!ge||xe.length>0)&&!ze,Oe=ne.wheelchair>0||ne.stepFree;return(0,N.jsxs)(T.Sheet,{visible:!0,onClose:t,title:`New booking \xb7 ${(0,x.niceDate)(me)}`,maxWidth:r?760:void 0,testID:"booking-sheet",children:[(0,N.jsx)(D.FirstQuestions,{rid:c,value:ne,onChange:re,party:U,audience:"staff"}),ne.dog&&!he?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Dog-friendly tables aren\u2019t marked yet. Managers \u203a Booking options \u203a Tables. Booking is allowed; check where the dog can sit."}):null,(0,N.jsx)(v.BookingDatePicker,{r:b,today:p,value:R,onChange:e=>{e!==R&&(W(e),J(null),_(!1))}}),(0,N.jsxs)(T.Row,{gap:6,children:[(0,N.jsx)(T.Chip,{label:"Phone",selected:'phone'===ae,onPress:()=>ie('phone')}),(0,N.jsx)(T.Chip,{label:"In person",selected:'in-person'===ae,onPress:()=>ie('in-person')})]}),(0,N.jsx)(T.Field,{label:"Name",value:Y,onChangeText:q,placeholder:"e.g. Reid",testID:"nb-name"}),(0,N.jsx)(T.Field,{label:"Mobile or phone number (needed)",value:te,onChangeText:se,keyboardType:"phone-pad",placeholder:"e.g. 07700 900123",testID:"nb-phone"}),!we.ok&&te?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:we.error}):null,(0,N.jsx)(T.Field,{label:"Email (optional)",value:oe,onChangeText:le,keyboardType:"email-address",autoCapitalize:"none",placeholder:"For an email confirmation too",testID:"nb-email"}),(0,w.emailOk)(oe)?null:(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right."}),(0,N.jsxs)(h.default,{style:{gap:6,alignItems:'center'},children:[(0,N.jsx)(T.T,{center:!0,children:"Covers"}),(0,N.jsx)(s.PartySizeInput,{value:U,onChange:e=>{Q(e),Se(!1)},label:"Covers",testID:"nb-party"})]}),(0,N.jsx)(n.ChildrenCount,{party:U,value:K,onChange:G,depositsOn:(0,i.depositOf)(b.settings).on&&(0,i.depositOf)(b.settings).perPersonPence>0,testID:"nb-children"}),(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:je.map(e=>{const t=ge&&e.available&&!ke(e.time).length||!(0,D.dogTimeOk)(b,A,R,e.time,pe);return(0,N.jsx)(T.Chip,{testID:`nb-slot-${e.time}`,label:e.time,sub:(0,C.blockAt)(E,c,R,e.time)?'Paused':t?'Dogs full':e.drinksOnly?'Drinks only':null!=e.partiesLeft&&e.partiesLeft<1||e.left<=0?'Full':`${e.left} left`,disabled:(e.past??!e.available)||t,selected:X===e.time,onPress:()=>{J(e.time),_(!1),Se(!1)}},e.time)})}),Ie?(0,N.jsxs)(h.default,{testID:"nb-over-capacity",accessible:!0,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[ve?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overCapacityNote)(U,ve.left,ve.time)}):null,De?(0,N.jsx)(T.T,{weight:"semibold",colour:j.colours.amber,children:(0,o.overPartiesNote)(De.time,De.cap)}):null,(0,N.jsx)(T.Chip,{label:Te?'Booking over the limit: on':'Book anyway (over the limit)',selected:Te,onPress:()=>Se(e=>!e),testID:"nb-over-ok"})]}):null,ge&&X?(0,N.jsxs)(h.default,{style:{gap:6},testID:"nb-dog-tables",children:[(0,N.jsxs)(T.T,{size:14,weight:"semibold",children:["Dog-friendly table ",(0,N.jsxs)(T.T,{size:13,colour:j.colours.muted,children:["(",be.areas.filter(e=>e.dogs).map(e=>e.name).join(' or '),")"]})]}),xe.length?(0,N.jsx)(T.Row,{wrap:!0,gap:6,children:xe.slice(0,10).map((e,t)=>(0,N.jsx)(T.Chip,{label:`${(0,l.tableNumbers)(e.table)}`,sub:`${e.area} \xb7 ${e.seats}${0===t?' \xb7 best':''}${Oe&&(0,P.accessibleSetUp)(be)&&!(0,P.isAccessible)(be,e.table)?' \xb7 not step-free':''}`,selected:(ue??xe[0].table)===e.table,onPress:()=>ce(e.table)},e.table))}):(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["No dog-friendly table free for ",U," at ",X,". Try another time."]})]}):null,$e?(0,N.jsxs)(h.default,{testID:"nb-block-warning",style:{borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg,borderRadius:12,padding:10,gap:6},children:[(0,N.jsxs)(T.T,{weight:"semibold",colour:j.colours.amber,children:["Bookings are paused ",$e.from,"\u2013",$e.to,$e.reason?` (${$e.reason})`:'']}),Pe?(0,N.jsx)(T.Chip,{label:H?'Manager override on':'Override and book anyway',selected:H,onPress:()=>_(e=>!e)}):(0,N.jsx)(T.Muted,{children:"Ask a manager to override, or pick another time."})]}):null,je.length?null:(0,N.jsx)(h.default,{testID:"nb-closed",children:(0,N.jsxs)(T.T,{size:14,weight:"semibold",colour:j.colours.amber,children:["Closed on ",(0,x.niceDate)(me)," (per the venue\u2019s opening hours). Pick another date."]})}),(0,N.jsx)(D.MoreQuestions,{rid:c,r:b,value:ne,onChange:re,party:U,date:R,time:X,today:(0,x.ymd)(p),bookings:A,audience:"staff",showTables:!1!==b.settings.tableRequests}),Oe&&!(0,P.accessibleSetUp)(be)?(0,N.jsx)(T.T,{size:13,colour:j.colours.amber,children:"Step-free tables aren\u2019t marked yet (Managers \u203a Booking options \u203a Tables). Check the table works for a wheelchair."}):null,(0,N.jsx)(T.Field,{label:"Notes (optional)",value:Z,onChangeText:ee,placeholder:I.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"nb-notes"}),(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?(0,N.jsxs)(T.Muted,{testID:"nb-deposit",children:["Deposit due: ",(0,a.gbp)((0,i.depositDue)((0,i.depositOf)(b.settings),U,K))," (",(0,a.gbp)((0,i.depositOf)(b.settings).perPersonPence)," per adult for ",(0,i.depositOf)(b.settings).fromParty,"+",K?`; ${K} ${1===K?'child':'children'} free`:'; children free',"). Deposits are paid through website bookings or to you, never in CoverCharge: tick Deposit paid on the booking once the guest has paid."]}):null,(0,N.jsxs)(T.Muted,{children:["The guest gets a confirmation text",oe.trim()?' and email':''," automatically (preview mode: shown in the Outbox, not sent)."]}),ze?(0,N.jsxs)(T.T,{size:14,colour:j.colours.amber,children:["We already have the most dogs we can look after at ",X,". Try another time: dogs are very welcome then."]}):null,(0,N.jsx)(T.Button,{label:de.length?de[0]:'Save booking',testID:"nb-save",disabled:!Be,onPress:()=>{if(R<(0,x.ymd)(p))return;if(!(0,O.guardBookingChange)(M))return;const e=(0,D.needsPatch)(ne),s=ne.tableReq.find(e=>!ge||xe.some(t=>t.table===e)),o=ge?null:(0,B.requestedFreeTable)(ne.tableReq,{date:R,time:X,partySize:U},be.tables.map(e=>e.name),ye,b.settings.turnMins);f.repo.bookings.create({restaurantId:c,customerId:null,name:Y.trim(),partySize:U,date:R,time:X,notes:Z.trim(),security:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?'deposit':'none',depositPaid:0,...K?{children:K}:{},...(0,i.depositDue)((0,i.depositOf)(b.settings),U,K)?{depositDue:(0,i.depositDue)((0,i.depositOf)(b.settings),U,K),depositPolicy:(0,i.depositWords)((0,i.depositOf)(b.settings),U,b.name,K).join(' '),depositRefundable:(0,i.depositOf)(b.settings).refundable,depositCutoffHours:(0,i.depositOf)(b.settings).cutoffHours}:{},phone:we.pretty,email:oe.trim()||void 0,source:ae,...e,...je.find(e=>e.time===X)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??[],...ge?{table:ue??s??xe[0]?.table}:o?{table:o}:{}}).then(e=>(0,$.postNewBookingToKitchen)(e,L)).catch(()=>{}),u?.({date:R,time:X,name:Y.trim()}),t()}})]})}},1126,[827,1127,1128,860,867,14,1129,1130,34,859,402,102,872,1088,874,1131,1105,858,821,864,794,1029,1026,1132,1133,1138,1107,1101,1139,1124,1123,25]); +__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.PartySizeInput=function({value:e,onChange:p,min:b=s.MIN_PARTY,max:y=s.MAX_PARTY,label:f="Party size",testID:h="party-size"}){const[x,$]=(0,t.useState)(String(e));(0,t.useEffect)(()=>{$(String(e))},[e]);const w=e=>p((0,s.clampParty)(e,b,y)),I=(t,n,l)=>{const s=t<0?e<=b:e>=y;return(0,d.jsx)(o.default,{testID:`${h}-${t>0?'up':'down'}${10===Math.abs(t)?'10':''}`,accessibilityRole:"button",accessibilityLabel:l,accessibilityState:{disabled:s},disabled:s,onPress:()=>w(e+t),hitSlop:4,style:{minWidth:44,height:44,paddingHorizontal:8,borderRadius:22,borderWidth:1.5,borderColor:c.colours.gold,alignItems:'center',justifyContent:'center',opacity:s?.4:1},children:(0,d.jsx)(u.T,{size:10===Math.abs(t)?14:20,weight:"semibold",colour:c.colours.gold,center:!0,children:n})},t)};return(0,d.jsxs)(l.default,{testID:h,style:{flexDirection:'row',alignItems:'center',gap:6,flexWrap:'wrap',justifyContent:'center'},children:[y-b>=20?I(-10,'\u221210',"10 fewer people"):null,I(-1,'\u2212','One fewer person'),(0,d.jsx)(n.default,{testID:`${h}-input`,value:x,keyboardType:"number-pad",inputMode:"numeric",maxLength:3,selectTextOnFocus:!0,accessibilityLabel:`${f}, ${b} to ${y} people`,accessibilityValue:{min:b,max:y,now:e,text:`${e} ${1===e?'person':'people'}`},onChangeText:e=>{$(e.replace(/\D/g,'')),e.replace(/\D/g,'')&&w((0,s.partyFromText)(e,b,y))},onBlur:()=>{const e=(0,s.partyFromText)(x,b,y);$(String(e)),w(e)},style:{width:64,height:44,borderRadius:10,borderWidth:1,borderColor:c.colours.border,color:c.colours.text,backgroundColor:c.colours.surface,textAlign:'center',fontSize:20,fontFamily:c.fonts.semibold}}),I(1,'+','One more person'),y-b>=20?I(10,'+10',"10 more people"):null]})};var t=r(_d[0]),o=e(r(_d[1])),n=e(r(_d[2])),l=e(r(_d[3])),s=r(_d[4]),c=r(_d[5]),u=r(_d[6]),d=r(_d[7])},1127,[34,402,412,102,1128,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_PARTY",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MIN_PARTY",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PARTY_RULE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"validParty",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"partyFromText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"clampParty",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"overCapacityNote",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"overPartiesNote",{enumerable:!0,get:function(){return b}});const t=100,n=1,o=`Bookings are for ${n} to ${t} people.`,u=o=>'number'==typeof o&&Number.isInteger(o)&&o>=n&&o<=t,c=(o,u=n,c=t)=>{const s=parseInt(String(o??'').replace(/\D/g,'').slice(0,4),10);return Math.max(u,Math.min(c,Number.isFinite(s)?s:u))},s=(o,u=n,c=t)=>Math.max(u,Math.min(c,Math.round(Number(o)||u))),f=(t,n,o)=>n<=0?`${o} is already full for booked Covers. Booking ${t} more goes over the venue\u2019s limit: check tables and staffing.`:`${t} is more than the ${n} Covers left at ${o}. Booking goes over the venue\u2019s limit by ${t-n}: check tables and staffing.`,b=(t,n)=>`${t} already has the most bookings we take at one start time (${n}). Booking another goes over the venue\u2019s limit: check tables and staffing.`},1128,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"maxChildren",{enumerable:!0,get:function(){return u}}),_e.ChildrenCount=function({party:e,value:t,onChange:o,depositsOn:h,testID:c="children-count",guest:p}){const f=u(e);if(f<1)return null;const x=Math.min(t,f);return(0,s.jsxs)(n.default,{style:{gap:6,alignItems:'center',width:'100%'},testID:c,children:[(0,s.jsx)(l.T,{size:17,weight:"semibold",center:!0,children:p?`How many of the ${e} are children?`:`Children in the ${e}`}),(0,s.jsx)(l.Stepper,{value:x,onChange:e=>o(Math.max(0,Math.min(f,e))),min:0,max:f,label:"children",testID:`${c}-stepper`,format:e=>e?String(e):'None'}),h?(0,s.jsx)(l.Muted,{center:!0,children:"Children never pay a deposit."}):null]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]);const u=e=>Math.max(0,Math.round(Number(e)||0)-1)},1129,[34,102,794,25]); +__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,"dismissNotice",{enumerable:!0,get:function(){return u.dismissNotice}}),Object.defineProperty(_e,"notify",{enumerable:!0,get:function(){return u.notify}}),Object.defineProperty(_e,"useSliders",{enumerable:!0,get:function(){return u.useSliders}}),Object.defineProperty(_e,"SLIDER",{enumerable:!0,get:function(){return j}}),_e.SliderButton=k,_e.SliderCard=C,_e.SliderHost=function(){y();const e=(0,u.useSliders)(e=>e.queue),n=e[0],o=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(p)return window.ccSlider=e=>(0,u.notify)(e),()=>{delete window.ccSlider}},[]),(0,t.useEffect)(()=>{if(o.current&&clearTimeout(o.current),!n)return;const e=void 0!==n.timeoutMs?n.timeoutMs:n.actions?.length||n.content?null:6e3;return e&&(o.current=setTimeout(()=>u.useSliders.getState().dismiss(n.id),e)),()=>{o.current&&clearTimeout(o.current)}},[n?.id,n?.timeoutMs]);const[l,c]=(0,t.useState)(0);if((0,t.useEffect)(()=>{if(!p||!n)return;const e=()=>{const e=document.querySelector('[data-testid="app-bottom-tabs"]');c(e?Math.max(0,Math.round(window.innerHeight-e.getBoundingClientRect().top)):0)};e();const t=setTimeout(e,300);return window.addEventListener('resize',e),()=>{clearTimeout(t),window.removeEventListener('resize',e)}},[n?.id]),!n)return null;const a=p?'fixed':'absolute';return(0,f.jsxs)(f.Fragment,{children:[n.modal?(0,f.jsx)(s.default,{...x('dim'),style:{position:a,left:0,right:0,top:0,bottom:0,zIndex:2147482990,backgroundColor:'rgba(0,0,0,0.72)'}}):null,(0,f.jsx)(s.default,{testID:"cc-slider-host",pointerEvents:"box-none",style:{position:a,left:12,right:12,bottom:12,zIndex:2147483e3,alignItems:'center',...p?{bottom:l?`${12+l}px`:'calc(12px + env(safe-area-inset-bottom))'}:{}},children:(0,f.jsx)(C,{n:n,waiting:e.length-1,onClose:()=>u.useSliders.getState().dismiss(n.id)},n.id+':'+(n.seq??0))})]})};var t=r(d[0]);r(d[1]);var n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),l=e(r(d[5])),c=r(d[6]),a=r(d[7]),u=r(d[8]),b=r(d[9]),f=r(d[10]);const p='undefined'!=typeof document,h="\n[data-ccsl=\"in\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccsl-in{from{opacity:0;transform:translate3d(0,110%,0)}to{opacity:1;transform:none}}\n[data-ccsl=\"urgent\"]{animation:ccsl-in .45s cubic-bezier(.2,1,.3,1) both,ccsl-red 1.6s ease-in-out .45s infinite}\n@keyframes ccsl-red{0%,100%{box-shadow:0 10px 30px rgba(0,0,0,.6),0 0 0 1px rgba(255,107,94,.55)}50%{box-shadow:0 10px 40px rgba(0,0,0,.6),0 0 0 2px #FF6B5E,0 0 34px rgba(255,107,94,.45)}}\n[data-ccsl=\"dim\"]{animation:ccsl-dim .3s ease both}\n@keyframes ccsl-dim{from{opacity:0}to{opacity:1}}\n@media (prefers-reduced-motion: reduce){[data-ccsl]{animation:none !important}}\n",x=e=>p?{dataSet:{ccsl:e}}:{};function y(){(0,t.useEffect)(()=>{if(!p||document.getElementById('cc-slider-css'))return;const e=document.createElement('style');e.id='cc-slider-css',e.textContent=h,document.head.appendChild(e)},[])}const j={bg:'#17140F',border:'rgba(207,164,95,.55)',text:'#F5F1E8',quiet:'#A89A80',gold:c.colours.gold,ink:'#17130D'},w=(e="normal")=>'urgent'===e?c.colours.red:'warn'===e?c.colours.amber:c.colours.gold,S=(e="normal")=>'urgent'===e?'rgba(255,107,94,.75)':'warn'===e?'rgba(255,181,71,.65)':j.border;function k({a:e,onDone:t,big:o}){const s=e.kind??'primary';return(0,f.jsx)(n.default,{testID:e.testID,accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{try{e.onPress?.()}finally{e.keepOpen||t()}},style:({pressed:e})=>({minHeight:o?56:44,minWidth:44,paddingHorizontal:'ghost'===s?10:o?24:18,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:'primary'===s?j.gold:'transparent',borderWidth:'danger'===s?1:0,borderColor:c.colours.red,opacity:e?.8:1}),children:(0,f.jsx)(a.T,{size:o?18:'ghost'===s?14:15,weight:'primary'===s?'bold':'medium',colour:'primary'===s?j.ink:'danger'===s?c.colours.red:j.quiet,children:e.label})})}function C({n:e,onClose:t,waiting:n=0,maxWidth:c=520}){y();const u=e.tone??'normal',h=w(u),C=e.content,z=!!e.big,{height:I}=(0,l.default)(),D=e.actions??[];return(0,f.jsxs)(s.default,{testID:e.testID??'cc-slider',accessibilityRole:"summary",accessibilityLabel:`${e.kicker?e.kicker+': ':''}${e.title}`,...x('urgent'===u?'urgent':'in'),style:{width:'100%',maxWidth:z?Math.max(c,900):c,alignSelf:'center',borderRadius:14,backgroundColor:j.bg,borderWidth:1,borderColor:S(u),overflow:'hidden',...p?{boxShadow:'0 10px 30px rgba(0,0,0,.6)'}:{elevation:12}},children:['normal'!==u?(0,f.jsx)(s.default,{style:{position:'absolute',left:0,top:0,bottom:0,width:5,backgroundColor:h}}):null,(0,f.jsxs)(o.default,{style:{maxHeight:Math.max(220,I-40)},contentContainerStyle:{paddingVertical:z?18:12,paddingLeft:'normal'!==u?z?24:18:z?20:14,paddingRight:z?20:14,gap:z?10:6},children:[(0,f.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:12},children:[e.icon?(0,f.jsx)(a.T,{size:z?34:22,children:e.icon}):null,(0,f.jsxs)(s.default,{style:{flex:1,gap:2},children:[e.kicker?(0,f.jsx)(a.T,{size:z?15:11,weight:"bold",colour:h,style:{letterSpacing:1.4},children:e.kicker}):null,(0,f.jsx)(a.T,{size:z?24:15,weight:"medium",colour:j.text,children:e.title}),e.body?(0,f.jsx)(a.T,{size:z?18:13,colour:j.quiet,children:e.body}):null]}),D.length||C?null:(0,f.jsx)(b.ToastClose,{testID:"cc-slider-ok",label:`Close: ${e.title}`,onPress:t,size:z?'lg':'md',colour:j.quiet})]}),C?(0,f.jsx)(C,{close:t}):null,D.length?(0,f.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:8,justifyContent:'flex-end'},children:D.map(e=>(0,f.jsx)(k,{a:e,onDone:t,big:z},e.label))}):null,n>0?(0,f.jsxs)(a.T,{size:z?14:11,colour:j.quiet,center:!0,style:{alignSelf:'stretch'},children:[n," more waiting"]}):null]})]})}},1130,[34,236,402,295,102,426,821,794,1001,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSlotMinutesOf=s,e.bookingNoticeMinsOf=r,e.bookingCoversPerStartOf=u,e.bookingPartiesPerStartOf=l,e.onlinePartyBounds=c,Object.defineProperty(e,"COVERS_WINDOW_MINS",{enumerable:!0,get:function(){return f}}),e.coversInHalfHour=m,e.countInStartSlot=p,e.bookingLimitsHint=function(t){const n=s(t),o=u(t),f=l(t),m=r(t),p=c(t);if(null!=o||null!=f){const t=[];return null!=o&&null!=f?t.push(`up to ${o} people and ${f} bookings at each start time`):null!=o?t.push(`up to ${o} people at each start time`):t.push(`up to ${f} bookings at each start time`),(p.max<100||p.min>1)&&t.push(`parties of ${p.min} to ${p.max}`),t.push(`from ${m} minutes ahead`),t.push('table rules still apply'),`Times are every ${n} minutes: ${t.join(', ')}.`}return`Times are every ${n} minutes. Covers per slot (${t.settings.bookingCoversPerSlot} per half hour) and table rules still apply.`},e.takeawaySlots=function(o,s,r){const u=(0,t.hoursFor)(o,r);if(!u)return[];const l=o.settings.slotMinutes,c=(0,n.addMins)(r,o.settings.leadMins),f=[];for(let t=new Date(u.open);t<=u.close;t=(0,n.addMins)(t,l)){if(tn.restaurantId===o.id&&'takeaway'===n.type&&'cancelled'!==n.status&&n.slotTime&&new Date(n.slotTime).getTime()===t.getTime()).length;f.push({time:new Date(t),label:(0,n.hm)(t),taken:r,cap:o.settings.slotCap,full:r>=o.settings.slotCap})}return f},e.bookingSlots=function(c,f,d,h,k,M=()=>0){const y=(0,t.hoursFor)(c,f);if(!y)return[];const S=[],$=y.close,P=(0,o.lastFoodOn)(c,b(f)),v=P?(0,n.atTime)(f,P.time):$,I='drinks'===(0,o.afterLastFood)(c),O=s(c),C=r(c),N=u(c),T=l(c);for(let t=new Date(y.open);t<=$;t=(0,n.addMins)(t,O)){const o=(0,n.hm)(t),s=t>v;if(s&&!I)continue;const r=null!=N?p(d,o,O):m(d,o),u=(N??c.settings.bookingCoversPerSlot)-r,l=null!=T?p(M,o,O):0,f=null!=T?T-l:void 0,b=t.getTime()=1;S.push({time:o,left:u,available:!b&&u>=h&&y,past:b,...s?{drinksOnly:!0}:{},...null!=f?{partiesLeft:f,partiesCap:T}:{}})}return S};var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]);function s(t){const n=t.settings.bookingSlotMinutes;return 5===n||10===n||15===n||20===n||30===n?n:15}function r(t){const n=t.settings.bookingNoticeMins;return'number'==typeof n&&Number.isInteger(n)&&n>=0&&n<=1440?n:30}function u(t){const n=t.settings.bookingCoversPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=200?n:null}function l(t){const n=t.settings.bookingPartiesPerStart;return'number'==typeof n&&Number.isInteger(n)&&n>0&&n<=50?n:null}function c(t){const n=t.settings.onlinePartyMin,o=t.settings.onlinePartyMax,s='number'==typeof n&&Number.isInteger(n)&&n>=1&&n<=100?n:1;return{min:s,max:'number'==typeof o&&Number.isInteger(o)&&o>=s&&o<=100?o:100}}const f=30;function m(t,o){const s=Math.floor((0,n.toMins)(o)/f)*f;let r=0;for(let o=0;o`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1131,[878,858,877]); +__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.nextDays=c,Object.defineProperty(_e,"openOn",{enumerable:!0,get:function(){return u}}),_e.BookingDatePicker=function({r:e,today:l,value:b,onChange:m}){const[f,x]=(0,t.useState)(!1),p=(0,r.ymd)(l),j=c(l,9),D=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,r.dayShort)(e)} ${e.getDate()}`,w=j.some(e=>(0,r.ymd)(e)===b),C=(0,r.parseYmd)(b),[P,T]=(0,t.useState)(()=>({y:C.getFullYear(),m:C.getMonth()})),v=(new Date(P.y,P.m,1,12).getDay()+6)%7,M=new Date(P.y,P.m+1,0).getDate(),R=[...Array.from({length:v},()=>null),...Array.from({length:M},(e,t)=>new Date(P.y,P.m,t+1,12))];for(;R.length%7;)R.push(null);const k=12*(P.y-l.getFullYear())+P.m-l.getMonth(),F=e=>T(({y:t,m:o})=>{const s=new Date(t,o+e,1);return{y:s.getFullYear(),m:s.getMonth()}});return(0,i.jsxs)(s.default,{testID:"nb-date",style:{gap:6},children:[(0,i.jsxs)(d.Row,{wrap:!0,gap:6,children:[j.map((t,o)=>(0,i.jsx)(d.Chip,{label:D(t,o),sub:u(e,t)?void 0:'Closed',selected:b===(0,r.ymd)(t),onPress:()=>{m((0,r.ymd)(t)),x(!1)}},(0,r.ymd)(t))),w?null:(0,i.jsx)(d.Chip,{label:(0,r.niceDate)(C),sub:u(e,C)?void 0:'Closed',selected:!0,onPress:()=>x(!0)}),(0,i.jsx)(d.Chip,{label:f?'Close calendar':'\ud83d\udcc5 Pick date',selected:f,onPress:()=>{f||T({y:C.getFullYear(),m:C.getMonth()}),x(!f)}})]}),f?(0,i.jsxs)(s.default,{testID:"nb-calendar",style:{borderWidth:1,borderColor:n.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:n.colours.surface2,maxWidth:420},children:[(0,i.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",disabled:k<=0,onPress:()=>F(-1),style:{padding:8,opacity:k<=0?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u2039"})}),(0,i.jsxs)(d.T,{weight:"semibold",children:[(0,r.monthLong)(P.m)," ",P.y]}),(0,i.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:"Next month",disabled:k>=h,onPress:()=>F(1),style:{padding:8,opacity:k>=h?.3:1},children:(0,i.jsx)(d.T,{size:20,colour:n.colours.gold,children:"\u203a"})})]}),(0,i.jsx)(s.default,{style:{flexDirection:'row'},children:y.map(e=>(0,i.jsx)(d.T,{size:12,colour:n.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:R.length/7},(t,l)=>(0,i.jsx)(s.default,{style:{flexDirection:'row',gap:4},children:R.slice(7*l,7*l+7).map((t,l)=>{if(!t)return(0,i.jsx)(s.default,{style:{flex:1,height:40}},l);const c=(0,r.ymd)(t),y=c{m(c),x(!1)},style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:c===p?1.5:0,borderColor:n.colours.gold,backgroundColor:h?n.colours.gold:'transparent',opacity:y?.3:1},children:(0,i.jsx)(d.T,{size:15,weight:h?'bold':'regular',colour:h?n.colours.onGold:f?n.colours.muted:n.colours.text,style:f&&!y?{textDecorationLine:'line-through'}:void 0,children:t.getDate()})},l)})},l)),(0,i.jsx)(d.Muted,{children:"Past dates can\u2019t be booked. Crossed-out days: closed (per the venue\u2019s hours)."})]}):null]})};var t=_r(_d[0]),o=e(_r(_d[1])),s=e(_r(_d[2])),l=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),d=_r(_d[6]),i=_r(_d[7]);function c(e,t){const o=new Date(e);return o.setHours(12,0,0,0),Array.from({length:t},(e,t)=>{const s=new Date(o);return s.setDate(o.getDate()+t),s})}const u=(e,t)=>!!(0,l.hoursFor)(e,t),y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],h=12},1132,[34,402,102,878,858,821,794,25]); +__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 w}}),_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:l,onChange:a,party:r,audience:i,profile:o=[]}){const y=e=>a({...l,...e}),b=(0,p.usePlan)(e),[x,j]=(0,t.useState)(!1),k=(0,s.dogQuestionOn)((0,u.useRestaurant)(e));(0,t.useEffect)(()=>{k||null!==l.dog||a({...l,dog:!1})},[k,l.dog]);const w=x?m.ALLERGENS:m.ALLERGENS.filter(e=>['gluten','milk','peanuts','treenuts','crustaceans','molluscs','fish','eggs','sesame'].includes(e.id)||l.allergens.includes(e.id)),q=[...o.map(e=>e.allergen),...l.allergens],M=(0,f.dogSetUp)(b);return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(R,{tone:"red",testID:"q-allergens",children:[(0,v.jsx)(C,{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?"}),o.length?(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(e=>(0,v.jsx)(h.Badge,{kind:"red",label:`${m.ALLERGENS.find(l=>l.id===e.allergen)?.short} (from your profile)`},e.allergen))}):null,(0,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No allergies",selected:'none'===l.allergy,onPress:()=>y({allergy:'none',allergens:[]})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes, allergies",selected:'yes'===l.allergy,onPress:()=>y({allergy:'yes'})})})]}),'none'===l.allergy&&o.length?(0,v.jsx)(h.Muted,{children:"Your profile allergies above are still shared with the kitchen."}):null,'yes'===l.allergy?(0,v.jsxs)(n.default,{style:{gap:10},testID:"allergen-picker",children:[(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"Which allergens? (the 14 UK allergens)"}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,v.jsx)(h.Chip,{label:e.short,selected:l.allergens.includes(e.id)||o.some(l=>l.allergen===e.id),disabled:o.some(l=>l.allergen===e.id),onPress:()=>y({allergens:l.allergens.includes(e.id)?l.allergens.filter(l=>l!==e.id):[...l.allergens,e.id]})},e.id)),x?null:(0,v.jsx)(h.Chip,{label:"All 14\u2026",onPress:()=>j(!0)})]}),(0,v.jsx)(h.T,{size:14,weight:"semibold",children:"How serious?"}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:m.SEVERITIES.map(e=>(0,v.jsx)(h.Chip,{label:e.label,selected:l.severity===e.id,onPress:()=>y({severity:e.id})},e.id))}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many people with allergies?"}),(0,v.jsx)(h.Stepper,{value:Math.min(l.allergyPeople,r),onChange:e=>y({allergyPeople:e}),min:1,max:Math.max(1,r),label:"people with allergies"})]}),(0,v.jsx)(h.Field,{label:"Anything else the kitchen should know? (optional)",value:l.allergyNote,onChangeText:e=>y({allergyNote:e}),placeholder:"e.g. traces of sesame, one child with coeliac disease",testID:"allergy-note"}),q.length?(0,v.jsx)(c.MenuAllergyCheck,{rid:e,allergens:q,audience:i}):null]}):null]}),k?(0,v.jsxs)(R,{tone:"gold",testID:"q-dogs",children:[(0,v.jsx)(C,{sub:M?'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,v.jsxs)(h.Row,{gap:8,children:[(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"No",selected:!1===l.dog,onPress:()=>y({dog:!1})})}),(0,v.jsx)(n.default,{style:{flex:1},children:(0,v.jsx)(h.Chip,{label:"Yes",selected:!0===l.dog,onPress:()=>y({dog:!0,dogs:Math.max(1,l.dogs)})})})]}),l.dog?(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"How many dogs?"}),(0,v.jsx)(h.Stepper,{value:l.dogs,onChange:e=>y({dogs:e}),min:1,max:4,label:"dogs"})]}):null]}):null]})},_e.useReserveAvailability=q,_e.MoreQuestions=function({rid:e,r:l,value:a,onChange:r,party:i,date:o,time:c,today:y,bookings:m,audience:b,showTables:x}){const j=e=>r({...a,...e}),w=l.settings,S=(0,u.useMenu)(e),P=(0,t.useMemo)(()=>S.filter(e=>/\((V|VG|Ve)\)|vegan|vegetarian/i.test(`${e.name} ${e.tags?.join(' ')??''}`)).slice(0,4),[S.length]),N=q(e,l,o,y,m,b),T=e=>a.holds[e]??0,D=(0,f.stockNeed)({holds:Object.entries(a.holds).map(([e,l])=>({kind:e.startsWith('item:')?'item':'stock',id:e.slice(5),qty:l}))},N.items),$=(e,l)=>Math.min(10,...e.map(e=>{const s=(D[e.key]??0)-T(l)*e.qty;return Math.floor(((N.free[e.key]??0)-s)/e.qty)})),I=(e,l,s,t)=>{const r=T(e),i=t<=0&&0===r;return(0,v.jsxs)(n.default,{style:{flexDirection:'row',alignItems:'center',gap:10,opacity:i?.55:1},testID:`reserve-${e.replace(':','-')}`,children:[(0,v.jsxs)(n.default,{style:{flex:1,minWidth:0},children:[(0,v.jsx)(h.T,{weight:"semibold",children:l}),(0,v.jsx)(h.Muted,{children:i?'Unavailable \u2014 none left for this day':s})]}),i?(0,v.jsx)(h.Badge,{kind:"neutral",label:"Unavailable"}):(0,v.jsx)(h.Stepper,{value:r,onChange:l=>j({holds:{...a.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)},A=N.items.length>0||!1!==w.reserveStock&&N.stock.length>0,O=(0,p.usePlan)(e);return(0,v.jsxs)(v.Fragment,{children:[(0,s.accessQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-access",children:[(0,v.jsx)(C,{sub:"Optional. Tell us and we\u2019ll have the right table ready.",children:"\u267f Access needs"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Wheelchair users"}),(0,v.jsx)(h.Stepper,{value:a.wheelchair,onChange:e=>j({wheelchair:e}),min:0,max:Math.max(1,i),label:"wheelchair users"})]}),(0,v.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(h.Chip,{label:"Step-free access",selected:a.stepFree,onPress:()=>j({stepFree:!a.stepFree})}),(0,v.jsx)(h.Chip,{label:"Accessible toilet",selected:a.toilet,onPress:()=>j({toilet:!a.toilet})}),(0,v.jsx)(h.Chip,{label:"Assistance dog",selected:a.assistDog,onPress:()=>j({assistDog:!a.assistDog})})]}),(0,v.jsx)(h.Field,{label:"Anything else? (optional)",value:a.accessNote,onChangeText:e=>j({accessNote:e}),placeholder:"e.g. needs a chair with arms"}),w.accessStatement?.trim()?(0,v.jsx)(h.Muted,{children:w.accessStatement.trim()}):null]}):null,(0,s.dietQuestionOn)(l)?(0,v.jsxs)(R,{tone:"plain",testID:"q-veg",children:[(0,v.jsx)(C,{sub:"We\u2019d love to look after you. Optional.",children:"\u24cb Any vegans or vegetarians?"}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegan"}),(0,v.jsx)(h.Stepper,{value:a.vegan,onChange:e=>j({vegan:e}),min:0,max:Math.max(1,i),label:"vegans"})]}),(0,v.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsx)(h.T,{size:14,children:"Vegetarian"}),(0,v.jsx)(h.Stepper,{value:a.vegetarian,onChange:e=>j({vegetarian:e}),min:0,max:Math.max(1,i),label:"vegetarians"})]}),!1!==w.vegTeaser&&P.length&&(a.vegan||a.vegetarian)?(0,v.jsxs)(h.Muted,{children:["On the menu: ",P.map(e=>e.name).join(' \xb7 ')]}):null]}):null,A?(0,v.jsxs)(R,{tone:"gold",testID:"q-reserve",children:[(0,v.jsx)(C,{sub:N.known?'Held for you from today\u2019s count.':o>y||'guest'===b?'Held for you; the kitchen confirms and orders in.':void 0,children:"\ud83e\udd9e Reserve with your table"}),N.items.map(e=>I(`item:${e.id}`,`${e.name}${k(e.price)}`,e.description||e.uses.map(e=>`${e.qty} ${N.stock.find(l=>l.key===e.key)?.name.toLowerCase()??e.key}`).join(' + '),$(e.uses,`item:${e.id}`))),!1!==w.reserveStock?N.stock.map(e=>I(`stock:${e.key}`,`Reserve ${e.name.toLowerCase()}`,N.known?`${N.free[e.key]} available today`:'Held for the kitchen to order',$([{key:e.key,qty:1}],`stock:${e.key}`))):null,'staff'===b&&N.known?(0,v.jsxs)(h.Muted,{children:["Today: ",N.stock.map(e=>`${N.free[e.key]} ${e.plural.toLowerCase()} free (${N.reserved[e.key]??0} reserved)`).join(' \xb7 ')]}):null]}):null,x&&!1!==w.tableRequests&&O.tables.length?(0,v.jsx)(M,{rid:e,value:a,onChange:r,party:i,hide:w.tableRequestHide??[]}):null]})},_e.dogTimeOk=function(e,l,s,t,a){if(!a)return!0;const n=e.settings.maxDogsPerSlot;return!n||(0,f.dogsAt)(l,s,t)+a<=n},Object.defineProperty(_e,"accessibleSetUp",{enumerable:!0,get:function(){return f.accessibleSetUp}});var e,l=_r(d[0]),s=_r(d[1]),t=_r(d[2]),a=_r(d[3]),n=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),i=_r(d[5]),o=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),p=_r(d[10]),y=_r(d[11]),m=_r(d[12]),b=_r(d[13]),x=_r(d[14]),f=_r(d[15]),j=_r(d[16]),v=_r(d[17]);const k=e=>'display'===x.APP_VARIANT?'':` \xb7 ${(0,b.gbp)(e)}`,w=()=>({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 R=({children:e,tone:l,testID:s})=>(0,v.jsx)(n.default,{testID:s,style:{gap:10,padding:16,borderRadius:16,borderWidth:'plain'===l?1:1.5,borderColor:'red'===l?j.colours.red:'gold'===l?j.colours.accentBorder:j.colours.hairline,backgroundColor:'red'===l?'#1E1110':j.colours.surface},children:e}),C=({children:e,sub:l})=>(0,v.jsxs)(n.default,{style:{gap:2},children:[(0,v.jsx)(h.T,{weight:"semibold",size:17,children:e}),l?(0,v.jsx)(h.Muted,{children:l}):null]});function q(e,l,s,t,a,n,i){const o=(0,f.reservablesOf)(l),c=(0,y.useStockItems)(e),h=(0,y.useShellStore)((0,r.useShallow)(l=>(0,y.venueCounts)(l,e))),u=(0,y.useShellStore)(l=>!!l.server[e]),p=(0,f.reservedOn)(a,s,o,i),m=s===t&&('staff'===n||u),b={};for(const e of c)b[e.key]=m?Math.max(0,Math.floor((h[e.key]??0)-(p[e.key]??0))):1/0;return{items:o,stock:c,free:b,reserved:p,known:m}}function M({rid:e,value:s,onChange:a,party:r,hide:c}){const u=(0,p.usePlan)(e),y=u.areas.filter(e=>u.tables.some(l=>l.areaId===e.id&&!c.includes(l.name))),[m,b]=(0,t.useState)(y[0]?.id??''),x=s.dog?s.dogs:0,k=e=>c.includes(e)?'Not bookable':(0,f.tableBlockReason)(u,e,r,x,s.wheelchair>0||s.stepFree),w=Object.fromEntries(u.tables.map(e=>[e.name,{table:e,status:k(e.name)?'blocked':'free',covers:0,allergy:!1}])),q=e=>{if(k(e))return;const l=s.tableReq.includes(e)?s.tableReq.filter(l=>l!==e):[...s.tableReq,e].slice(-2);a({...s,tableReq:l})},M=u.tables.filter(e=>e.areaId===m&&!c.includes(e.name));return(0,v.jsxs)(R,{tone:"plain",testID:"q-table",children:[(0,v.jsx)(C,{sub:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best.",children:"\ud83e\ude91 Request a table (optional)"}),y.length>1?(0,v.jsx)(i.AreaTabs,{plan:u,area:m,onPick:b}):null,(0,v.jsx)(n.default,{testID:"q-table-plan",style:{height:240,borderRadius:12,overflow:'hidden',borderWidth:1,borderColor:j.colours.hairline},children:(0,v.jsx)(o.FloorCanvas,{plan:u,areaId:m,mode:"live",view:w,privacy:!0,fit:"contain",crop:!0,maxH:260,highlight:s.tableReq,onTap:e=>q(e.name)})}),(0,v.jsx)(h.Row,{wrap:!0,gap:6,children:M.map(e=>{const t=k(e.name),a=s.tableReq.indexOf(e.name);return(0,v.jsx)(h.Chip,{label:`${(0,l.tableNumbers)(e.name)}`,sub:t||(0===a?'1st choice':1===a?'2nd choice':`${e.maxSeats} seats`),selected:a>=0,disabled:!!t,onPress:()=>q(e.name)},e.name)})}),s.tableReq.length?(0,v.jsxs)(h.T,{size:14,colour:j.colours.goldLight,children:["Requested: ",s.tableReq.map((e,s)=>`${(0,l.tableNumbers)(e)}${s?' (2nd choice)':''}`).join(', ')]}):(0,v.jsx)(h.Muted,{children:"Tap a table; tap another for a second choice."})]})}},1133,[860,877,34,102,879,1134,1135,1137,794,874,1029,983,861,867,872,1101,821,25]); +__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 n}}),_e.AreaTabs=function({plan:o,area:e,onPick:u,counts:a,closed:b}){return(0,c.jsx)(t.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:o.areas.map(o=>{const h=o.id===e,f=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':''}${f?', closed for weather':''}`,accessibilityState:{selected:h},onPress:()=>u(o.id),style:{maxWidth:'100%',minWidth:0,flexShrink:1,minHeight:48,paddingHorizontal:16,borderRadius:24,borderWidth:1.5,borderColor:h?s.colours.gold:f?s.colours.blue:s.colours.border,backgroundColor:h?s.colours.gold:s.colours.surface,justifyContent:'center'},children:(0,c.jsxs)(t.T,{weight:"semibold",size:15,colour:h?s.colours.onGold:s.colours.text,children:[o.name,n(o),f?(0,c.jsx)(t.T,{size:12,colour:h?s.colours.onGold:s.colours.blue,children:" closed"}):null,a?.[o.id]?(0,c.jsxs)(t.T,{size:12,colour:h?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 n=o=>`${o.dogs?' \ud83d\udc3e':''}${o.outdoor?' \ud83c\udf26':''}`},1134,[34,402,821,794,25]); +__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 v}}),Object.defineProperty(_e,"fitLabel",{enumerable:!0,get:function(){return M}}),Object.defineProperty(_e,"BIG_LABEL_MIN",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"OCC_LABEL_MIN",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"occupiedLabel",{enumerable:!0,get:function(){return S}}),_e.areaBounds=I,_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,g.tableNumber)(e).length)+6)/(e.w*t),n=22/Math.min(e.w,e.h);return Math.max(o,n)}))},_e.seatSpots=R,_e.FixtureShape=T,_e.FloorCanvas=function(e){const[$,L]=(0,r.useState)({w:0,h:0}),z=e.plan.tables.filter(t=>t.areaId===e.areaId),E=e.crop&&z.length?I(e.plan,e.areaId):{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H},F='live'===e.mode?[...new Map(z.flatMap(t=>{const o=e.view?.[t.name];if(!o?.group||o.group.length<2)return[];const n=[...o.group].sort().join('+');return[[n,{key:n,members:o.group,view:o}]]})).values()]:[],O=28*F.length,D={x:E.x,y:E.y,r:E.x+E.w,b:E.y+E.h},_=$.w?'width'===e.fit?Math.min($.w/l.PLAN_W,e.maxH?e.maxH/l.PLAN_H:9):Math.min($.w/E.w,Math.max(1,$.h-O)/E.h):0,B=e.fill&&'contain'===e.fit&&_>0&&$.h>0,N=B?($.w/_-E.w)/2:0,P=B?(($.h-O)/_-E.h)/2:0,W={x:D.x-N,y:D.y-P,r:D.r+N,b:D.b+P},H=W.r-W.x,G=W.b-W.y,[Y,X]=(0,r.useState)(null),U=(0,r.useRef)(null),[q,J]=(0,r.useState)(null),K=(0,r.useRef)(null);K.current=q,i.default.useEffect(()=>{if(!q)return;const e=setTimeout(()=>J(null),n.ARM_MS);return()=>clearTimeout(e)},[q]);const V='live'===e.mode&&!!e.onDrop,Q=e=>!V||(0,n.isArmed)(K.current,e.id,Date.now()),Z=t=>e.plan.sections.find(e=>e.id===t.sectionId),ee=t=>e.plan.joins.find(e=>e.tables.includes(t.name)),te=i.default.useMemo(()=>(0,g.numberClashes)(e.plan.tables).sameArea,[e.plan.tables]),oe=(t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>Q(t),onResponderTerminationRequest:()=>!Q(t),onResponderGrant:e=>{U.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,id:t.id,kind:o}},onResponderMove:n=>{const r=U.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,a=n.nativeEvent.pageY-r.y;Math.abs(i)+Math.abs(a)<6&&!Y||Q(t)&&('live'!==e.mode||e.onDrop&&e.view&&['seated','mains','dessert','bill'].includes(e.view[t.name]?.status)&&e.view[t.name]?.booking)&&X({id:t.id,dx:i,dy:a,kind:o})},onResponderRelease:r=>{const i=U.current;U.current=null;const s=r.nativeEvent.pageX-(i?.x??0),u=r.nativeEvent.pageY-(i?.y??0);if(X(null),Math.abs(s)+Math.abs(u)<6||!_){if('move'===o){if(V){const e=(0,n.releaseOn)(K.current,t.id,!1,Date.now());if(J(e.arm),'select'===e.action)try{a.default.announceForAccessibility(n.SELECTED_A11Y)}catch{}}e.onTap?.(t)}return}if(V){const e=(0,n.releaseOn)(K.current,t.id,!0,Date.now());if(J(e.arm),'move'!==e.action)return}const h=s/_,c=u/_;if('edit'===e.mode&&'move'===o)e.onMove?.(t,w(v(t.x+h,e.snapOn),0,l.PLAN_W-t.w),w(v(t.y+c,e.snapOn),0,l.PLAN_H-t.h));else if('edit'===e.mode&&'resize'===o)e.onResize?.(t,w(v(t.w+h,e.snapOn),50,400),w(v(t.h+c,e.snapOn),50,300));else if('live'===e.mode&&e.onDrop){const o=t.x+t.w/2+h,n=t.y+t.h/2+c,r=z.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)}}}),ne=e=>e*_,re=e=>ne(e-W.x),ie=e=>ne(e-W.y),ae='width'===e.fit?l.PLAN_H*_+O||200:void 0;return(0,x.jsxs)(s.default,{testID:"floor-canvas",onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),style:[{width:'100%',borderRadius:16,overflow:'hidden'},'contain'===e.fit?{flex:1}:{height:ae}],children:[F.map(e=>{const o=z.filter(t=>e.members.includes(t.name)),n=o.length?(Math.min(...o.map(e=>e.x))+Math.max(...o.map(e=>e.x+e.w)))/2:W.x+H/2,r=e.view.booking?.time??e.view.next?.time,i=`${A(e.members)}${r?` \xb7 ${'seated'===e.view.status?'Seated':'Booked'} ${r}`:''}`,a=Math.min(Math.max(0,$.w-8),260);return(0,x.jsx)(s.default,{testID:`joined-label-${e.key}`,accessible:!0,accessibilityLabel:`Joined tables ${i}`,pointerEvents:"none",style:{height:28,width:a,marginLeft:w(ne(n-W.x)-a/2,4,Math.max(4,$.w-a-4)),alignItems:'center',justifyContent:'center',overflow:'hidden',borderRadius:8,borderWidth:1,borderColor:h.colours.gold,backgroundColor:(0,t.soutersSurface)('#0B0B0B')},children:(0,x.jsx)(c.T,{size:16,weight:"bold",colour:h.colours.goldLight,center:!0,numberOfLines:1,children:i})},e.key)}),_?(0,x.jsx)(s.default,{style:{width:ne(H),height:ne(G),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0F0E0C'),borderRadius:16,borderWidth:1,borderColor:h.colours.border,overflow:'hidden'},children:(0,x.jsxs)(s.default,{style:{position:'absolute',left:0,top:0,width:ne(H),height:ne(G)},children:['edit'===e.mode?Array.from({length:l.PLAN_W/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',left:re(o*l.GRID*2),top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`v${o}`)):null,'edit'===e.mode?Array.from({length:l.PLAN_H/(2*l.GRID)},(e,o)=>(0,x.jsx)(s.default,{style:{position:'absolute',top:ie(o*l.GRID*2),left:0,right:0,height:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},`h${o}`)):null,(e.plan.fixtures??[]).filter(t=>t.areaId===e.areaId).map(t=>(0,x.jsx)(T,{f:{...t,x:t.x-W.x,y:t.y-W.y},S:ne,live:'live'===e.mode},t.id)),e.plan.joins.map(e=>{const t=z.filter(t=>e.tables.includes(t.name));if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,a=n.x+n.w/2,l=n.y+n.h/2,u=Math.hypot(a-r,l-i),h=Math.atan2(l-i,a-r);return(0,x.jsx)(s.default,{testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:re((r+a)/2-u/2),top:ie((i+l)/2)-3,width:ne(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.55)',transform:[{rotate:`${h}rad`}]}},e.id)}),z.map(n=>{const r=e.view?.[n.name],a=r?u.STATUS[r.status]:u.STATUS.free,v=Y?.id===n.id,w=v&&'resize'===Y.kind?Math.max(50,n.w+Y.dx/_):n.w,$=v&&'resize'===Y.kind?Math.max(50,n.h+Y.dy/_):n.h,I=v&&'move'===Y.kind?n.x+Y.dx/_:n.x,T=v&&'move'===Y.kind?n.y+Y.dy/_:n.y,A=e.selected===n.id||e.highlight?.includes(n.name)||q?.id===n.id,L=Z(n),z='edit'===e.mode?'#2A2419':a.colour,E='edit'===e.mode?h.colours.text:a.fg,F='round'===n.shape?ne(Math.min(w,$))/2:ne(10),O='live'===e.mode?(0,g.liveTableLabel)(n,te):(0,l.tableLabel)(n),D=ne(Math.min(w,$))<64,B=r?r.covers>0?r.covers:'soon'===r.status?(r.next??r.dayBookings?.[0])?.partySize??0:0:0,N=e.big&&'live'===e.mode&&r&&!(r.group&&r.group.length>1)&&k.has(r.status)&&B>0,P=N?S(O,B):O,W=M(e.big?Math.max(13,Math.min(34,ne(Math.min(w,$))/3)):Math.max(11,Math.min(22,ne(Math.min(w,$))/4)),P,ne(w)*('round'===n.shape?.85:1),N?C:e.big?j:9),H=ne(w)*('round'===n.shape?.85:1),G=e=>e.length*W*.62+6,X=N&&G(P)>H,U=X&&Math.max(G(O),G(`(${B})`))<=H&&1.2*W*2<=ne($)-4,J=X&&!U,K=Math.max(e.big?11:12,Math.round(.62*W)),V=(ne($)-6-1.4*W)/(1.4*K),Q=V>=2&&ne(w)>=5*K?2:V>=1?1:0,ae=r?.booking&&void 0!==r.seatedMins?r.booking.time:void 0,se='soon'===r?.status?r.next?.time??r.dayBookings?.[0]?.time:void 0,le='edit'===e.mode?`Table ${(0,o.tableNumbers)(O)}, ${(0,l.shapeLabel)(n.shape).toLowerCase()}, ${n.minSeats}\u2013${n.maxSeats} seats${n.online?', bookable online':''}`:'soon'===r?.status?`Table ${(0,o.tableNumbers)(O)}, booked later${se?`, ${se}`:''}${r.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`:`Table ${(0,o.tableNumbers)(O)}, ${a.label}${void 0!==r?.seatedMins?`, seated ${r.seatedMins} min`:''}${r?.covers?`, ${r.covers} Covers`:''}${r?.dayBookings?.length?`, booked: ${r.dayBookings.map(e=>`${e.time}, ${e.partySize} Covers`).join('; ')}`:''}${r?.group?`, combined with ${r.group.filter(e=>e!==n.name).map(e=>`table ${e}`).join(', ')}`:''}`,de=void 0!==r?.seatedMins&&r.booking?Math.min(1.2,r.seatedMins/(r.booking.durationMins??(0,u.turnFor)(r.booking.partySize,e.turnBase))):null;return(0,x.jsxs)(i.default.Fragment,{children:[R({...n,w:w,h:$}).map((t,o)=>(0,x.jsx)(s.default,{pointerEvents:"none",style:[{position:'absolute',left:re(I+t.x)-Math.max(4,ne(8)),top:ie(T+t.y)-Math.max(4,ne(8)),width:Math.max(8,ne(16)),height:Math.max(8,ne(16)),borderRadius:99,backgroundColor:'edit'===e.mode?'#5A4C33':'rgba(255,255,255,0.16)',borderWidth:1,borderColor:'edit'===e.mode?h.colours.gold:'rgba(255,255,255,0.25)'},y()]},o)),'live'===e.mode&&(ne(w)<44||ne($)<44)?(0,x.jsx)(s.default,{accessible:!1,importantForAccessibility:"no-hide-descendants",'aria-hidden':!0,...oe(n,'move'),style:{position:'absolute',left:re(I+w/2)-Math.max(44,ne(w))/2,top:ie(T+$/2)-Math.max(44,ne($))/2,width:Math.max(44,ne(w)),height:Math.max(44,ne($)),zIndex:2}}):null,(0,x.jsxs)(s.default,{testID:`table-${n.name}`,accessibilityRole:"button",accessibilityLabel:le,onAccessibilityTap:()=>e.onTap?.(n),onKeyDown:t=>{'Enter'!==t?.key&&' '!==t?.key||e.onTap?.(n)},tabIndex:0,...oe(n,'move'),style:[{position:'absolute',left:re(I),top:ie(T),width:ne(w),height:ne($),borderRadius:F,backgroundColor:z,alignItems:'center',justifyContent:'center',padding:2,overflow:J?'visible':'hidden',borderWidth:A?3:e.sectionColours&&L?2.5:1.5,borderColor:A?'#FFFFFF':e.sectionColours&&L?(0,h.brandColour)(L.colour):'edit'===e.mode?h.colours.gold:'rgba(0,0,0,0.35)',transform:[{scale:v?1.06:1}],zIndex:v?50:J?4:3,opacity:v&&'live'===e.mode?.85:1,shadowColor:'#000',shadowOpacity:v?.6:.3,shadowRadius:v?14:6,cursor:'edit'===e.mode?'grab':'pointer',touchAction:'none'},v?null:y()],children:[(0,x.jsxs)(s.default,{style:J?{alignItems:'center',justifyContent:'center',overflow:'visible'}:{alignItems:'center',justifyContent:'center',maxWidth:'100%',maxHeight:'100%',overflow:'hidden'},pointerEvents:"none",children:[N?(0,x.jsx)(c.T,{testID:`table-label-${n.name}`,style:U?{flexShrink:0,lineHeight:Math.round(1.2*W),maxWidth:Math.max(20,H-4)}:J?{...p,whiteSpace:'nowrap',textShadowColor:'rgba(0,0,0,0.9)',textShadowRadius:3,textShadowOffset:{width:0,height:0}}:p,weight:"bold",size:W,colour:J?'#FFFFFF':E,center:!0,numberOfLines:U?2:1,children:P}):(0,x.jsx)(c.T,{style:p,weight:"bold",size:W,colour:E,center:!0,numberOfLines:1,children:O}),'live'===e.mode&&'blocked'===r?.status?(0,x.jsx)(c.T,{style:f,size:Math.max(10,Math.round(.5*W)),weight:"semibold",colour:E,center:!0,numberOfLines:1,children:"Blocked"}):null,N||'live'===e.mode&&r?.group&&r.group.length>1?null:e.big&&'live'===e.mode&&r&&1===Q?'free'!==r.status&&'soon'!==r.status&&(r.covers||ae)?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,numberOfLines:1,children:[r.covers?`${r.covers}`:'',ae??''].filter(Boolean).join(' \xb7 ')}):null:e.big&&'live'===e.mode&&r&&2===Q?(0,x.jsxs)(x.Fragment,{children:['soon'!==r.status&&r.covers?(0,x.jsxs)(c.T,{style:f,size:K,weight:"semibold",colour:E,center:!0,children:[r.covers," ",1===r.covers?'Cover':'Covers']}):'free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:K,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats]}),'free'!==r.status&&'soon'!==r.status&&ae?(0,x.jsx)(c.T,{style:f,size:K,weight:"bold",colour:E,center:!0,children:ae}):'dirty'===r.status?(0,x.jsx)(c.T,{style:f,size:K,colour:E,center:!0,children:"Clear"}):null]}):e.big&&'live'===e.mode?null:'edit'===e.mode?D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:h.colours.muted,center:!0,children:[n.minSeats,"\u2013",n.maxSeats,n.online?' \xb7 online':'']}):r?(0,x.jsxs)(x.Fragment,{children:['free'!==r.status||D?null:(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[n.minSeats,"\u2013",n.maxSeats," seats"]}),void 0!==r.seatedMins?(0,x.jsxs)(c.T,{style:f,size:12,weight:"semibold",colour:E,center:!0,children:[r.seatedMins,"m \xb7 ",r.covers,"\ud83d\udc65"]}):r.orderOnly?(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Open order"}):null,'dirty'!==r.status||D?null:(0,x.jsx)(c.T,{style:f,size:11,colour:E,center:!0,children:"Clear"}),!D||r.allergy||r.vip?(0,x.jsxs)(c.T,{style:f,size:11,colour:E,center:!0,children:[r.allergy?'\u26a0':'',r.vip?'VIP'===r.vip?'\u2605':'\u2665':'',r.occasion?u.OCCASION_ICON[r.occasion]:'',r.note?'\u270e':'']}):null]}):null]}),null,'live'===e.mode&&r&&!D&&(r.booking??r.next)&&(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()?(0,x.jsx)(s.default,{pointerEvents:"none",testID:`needs-${n.name}`,style:{position:'absolute',bottom:e.big?-Math.max(9,.55*K):2,right:e.big?-6:4,backgroundColor:(0,t.soutersSurface)('rgba(11,11,11,0.85)'),borderRadius:8,paddingHorizontal:4,borderWidth:1,borderColor:'rgba(255,255,255,0.15)'},children:(0,x.jsx)(c.T,{size:e.big?Math.max(11,.75*K):10,children:(0,b.needsIcons)(r.booking??r.next).replace('\u26a0\ufe0f','').trim()})}):null,L&&'live'===e.mode&&e.sectionColours&&!D&&!e.big?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:3,right:6,backgroundColor:(0,h.brandColour)(L.colour),borderRadius:6,paddingHorizontal:3},children:(0,x.jsx)(c.T,{size:9,weight:"bold",colour:"#0B0B0B",children:L.server})}):null,null===de||D?null:(0,x.jsx)(s.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,x.jsx)(s.default,{style:{width:`${Math.min(100,100*de)}%`,height:4,borderRadius:2,backgroundColor:de>=1?'#B3261E':'rgba(0,0,0,0.6)'}})}),ee(n)&&'edit'===e.mode?(0,x.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',bottom:2,left:4},children:(0,x.jsx)(c.T,{size:10,colour:h.colours.gold,children:"\u26d3"})}):null]}),'edit'===e.mode&&e.selected===n.id?(0,x.jsx)(s.default,{testID:"resize-handle",accessibilityLabel:"Resize table",...oe(n,'resize'),style:{position:'absolute',left:re(I+w)-14,top:ie(T+$)-14,width:28,height:28,borderRadius:14,backgroundColor:h.colours.gold,borderWidth:2,borderColor:'#fff',zIndex:60,cursor:'nwse-resize',touchAction:'none'}}):null]},n.id)}),0===z.length?(0,x.jsx)(s.default,{style:{position:'absolute',left:0,right:0,top:'45%'},children:(0,x.jsxs)(c.T,{center:!0,colour:h.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=_r(d[1]),n=_r(d[2]),r=_r(d[3]),i=e(r),a=e(_r(d[4]));_r(d[5]);var s=e(_r(d[6])),l=_r(d[7]),u=_r(d[8]),h=_r(d[9]),c=_r(d[10]),b=_r(d[11]),g=_r(d[12]),x=_r(d[13]);const f={flexShrink:0},p={flexShrink:0,maxWidth:'none'},y=(e=250)=>({transitionProperty:'background-color, border-color, transform, left, top, width, height',transitionDuration:`${e}ms`}),v=(e,t=!0)=>t?Math.round(e/l.GRID)*l.GRID:Math.round(e),w=(e,t,o)=>Math.max(t,Math.min(o,e)),M=(e,t,o,n=9)=>Math.max(n,Math.min(e,(o-6)/(.62*Math.max(1,t.length)))),j=12,C=11,k=new Set(['soon','seated','mains','dessert','bill']),S=(e,t)=>`${e} (${t})`,$=46;function I(e,t){const o=e.tables.filter(e=>e.areaId===t);if(!o.length)return{x:0,y:0,w:l.PLAN_W,h:l.PLAN_H};const n=Math.max(0,Math.min(...o.map(e=>e.x))-$),r=Math.max(0,Math.min(...o.map(e=>e.y))-$);return{x:n,y:r,w:Math.min(l.PLAN_W,Math.max(...o.map(e=>e.x+e.w))+$)-n,h:Math.min(l.PLAN_H,Math.max(...o.map(e=>e.y+e.h))+$)-r}}function R(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,a=n?{borderColor:'#FFFFFF',borderWidth:2}:null;return'bar'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#2A2216':'#3A2E1C',borderRadius:8,borderWidth:1.5,borderColor:o?'#5A4A30':h.colours.gold},a],children:(0,x.jsx)(c.T,{size:Math.max(9,Math.min(14,t(e.h)/2.4)),weight:"semibold",colour:h.colours.goldLight,children:"BAR"})}):'wall'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:o?'#3A3631':'#5C574F',borderRadius:2},a]}):'window'===e.kind?(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{backgroundColor:'rgba(226,196,137,0.16)',borderColor:'rgba(226,196,137,0.6)',borderWidth:1,borderRadius:2},a],children:!o&&t(i?e.h:e.w)>60?(0,x.jsx)(c.T,{size:9,colour:"#BFDDFF",style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"WINDOW"}):null}):(0,x.jsx)(s.default,{pointerEvents:"none",style:[r,{borderColor:o?'#7A6440':h.colours.gold,borderWidth:1.5,borderStyle:'dashed',borderRadius:3,backgroundColor:'rgba(207,164,95,0.08)'},a],children:t(i?e.h:e.w)>40?(0,x.jsx)(c.T,{size:9,colour:h.colours.goldLight,style:i?{transform:[{rotate:'90deg'}]}:void 0,children:"DOOR"}):null})}function A(e){return(0,l.tablesLabel)(e.join('+')).replace(/^Tables? /,'').replace(/ \+ /g,'+')}},1135,[828,860,1136,34,281,236,102,1029,1105,821,794,1107,859,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ARM_MS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SELECT_HINT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SELECTED_A11Y",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TABLE_SELECT_HINT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"isArmed",{enumerable:!0,get:function(){return l}}),e.releaseOn=function(n,o,c,u){const b=l(n,o,u);return c?b?{arm:null,action:'move'}:{arm:n&&u-n.at!!n&&n.id===o&&c-n.at!e.signOff),S=k.filter(e=>e.signOff),_=j.map(o.allergenLabel).join(', '),C=e=>e.map(e=>e.name).join(', ')||'none';return(0,f.jsxs)(l.default,{testID:"menu-allergy-check",style:{gap:6,borderWidth:1,borderColor:p.length?h.colours.red:h.colours.border,borderRadius:12,padding:10,backgroundColor:h.colours.surface2},children:[(0,f.jsxs)(u.T,{weight:"semibold",children:["Allergy check against the menu (",_,")"]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.red,children:["Contains: ",p.length," dish",1===p.length?'':'es']}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.amber,children:["May contain: ",M.length]}),(0,f.jsxs)(u.T,{size:14,colour:h.colours.ok,children:["Free from ",1===j.length?'it':'them'," (signed off): ",S.length]}),w.length?(0,f.jsxs)(u.Muted,{children:[w.length," more awaiting the head chef's sign-off, so not shown as safe."]}):null,(0,f.jsx)(n.default,{testID:"menu-allergy-details",accessibilityRole:"button",onPress:()=>y(!x),hitSlop:6,children:(0,f.jsx)(u.T,{size:14,colour:h.colours.gold,children:x?'Hide dishes':'Show dishes'})}),x?(0,f.jsxs)(l.default,{style:{gap:4},children:[(0,f.jsxs)(u.Muted,{children:["Contains: ",C(p)]}),(0,f.jsxs)(u.Muted,{children:["May contain: ",C(M)]}),(0,f.jsxs)(u.Muted,{children:["Free from: ",C(S)]})]}):null,(0,f.jsx)(u.Muted,{children:'guest'===m?'From the kitchen\u2019s signed-off recipe cards. Specials on the board are checked by staff on the day.':'From the signed-off recipe cards. Specials on the board have their own allergens. Still check with the guest and the kitchen.'})]})};var s=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),t=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8])},1137,[34,402,102,874,861,863,821,794,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"NOTES_PLACEHOLDER",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"WIX_EDIT_NOTE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"guestMessageFields",{enumerable:!0,get:function(){return d}}),_e.canEditBooking=function(e){return'customer'!==e.variant&&('staff'===e.variant||e.inStaffApp?!!e.shiftManager:'display'===e.variant||'chef'===e.variant||'staff'!==e.role)},Object.defineProperty(_e,"isWixBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"EDIT_FIELDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"DEPOSIT_METHODS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"EDIT_STATUSES",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"SOURCES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"OCCASIONS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"TAGS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"FIELD_WORDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"draftOf",{enumerable:!0,get:function(){return y}}),_e.changedFields=$,_e.historyText=k,_e.editPatch=function(t,a,s,o=(new Date).toISOString()){const d=$(t,a);if(!d.length)return{};const n={};for(const c of d)switch(c){case'partySize':n.partySize=(0,e.clampParty)(Number(a.partySize));break;case'children':n.children=Math.max(0,Math.min((0,e.clampParty)(Number(a.partySize)),Math.round(Number(a.children??0))))||void 0;break;case'phone':case'email':case'table':n[c]=String(a[c]??'').trim()||void 0;break;case'date':case'time':case'name':case'notes':n[c]=String(a[c]??'').trim();break;case'area':n.area=(a.area??'').trim()||void 0;break;case'dogs':n.dogs=Math.max(0,Number(a.dogs??0)),n.dog=Number(a.dogs??0)>0;break;case'highChairs':n.highChairs=Math.max(0,Number(a.highChairs??0))||void 0;break;case'wheelchair':n.access={...t.access??{},wheelchair:Math.max(0,Number(a.wheelchair??0))||void 0};break;case'occasion':n.occasion=a.occasion||void 0;break;case'allergies':n.allergies=[...a.allergies??[]],n.allergyNone=!!a.allergyNone&&!(a.allergies??[]).length,n.allergyNote=(a.allergyNote??'').trim()||void 0,(a.allergies??[]).length||(n.allergyAck=void 0);break;case'diet':n.diet={vegan:Number(a.vegan??0)||void 0,vegetarian:Number(a.vegetarian??0)||void 0};break;case'deposit':if(!a.depositOn){Object.assign(n,{security:'none',depositDue:0,depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0,depositWaived:void 0});break}if(n.security='deposit',n.depositDue=Math.max(0,Math.round(Number(a.depositDue??0))),!a.depositPaid&&a.depositWaived?n.depositWaived=t.depositWaived?.by&&(t.depositWaived.note??'')===(a.depositWaiveNote??'').trim()?t.depositWaived:{by:s.by.slice(0,80),at:o,...(a.depositWaiveNote??'').trim()?{note:(a.depositWaiveNote??'').trim().slice(0,120)}:{}}:n.depositWaived=void 0,a.depositPaid){const e=/^\d{4}-\d{2}-\d{2}$/.test(a.depositDate??'')?a.depositDate:o.slice(0,10);Object.assign(n,{depositPaid:Math.max(0,Math.round(Number(a.depositAmount??0))),depositPaidBy:s.by.slice(0,80),depositPaidAt:e===o.slice(0,10)?o:`${e}T12:00:00.000Z`,depositMethod:a.depositMethod||void 0})}else Object.assign(n,{depositPaid:0,depositPaidBy:void 0,depositPaidAt:void 0,depositMethod:void 0});break;case'status':n.status=a.status,'seated'!==a.status||t.seatedAt||(n.seatedAt=o),'finished'!==a.status||t.finishedAt||(n.finishedAt=o),'confirmed'!==a.status&&'pending'!==a.status||(n.seatedAt=void 0,n.finishedAt=void 0);break;case'source':n.source=a.source||void 0;break;case'tags':n.tags=[...(t.tags??[]).filter(e=>!b.includes(e)),...a.tags??[]];break;case'duration':n.durationMins=Number(a.duration??0)>=15?Number(a.duration):void 0}d.includes('table')&&(n.tableSetHere=!0);const c=t;return n.locallyEdited=!0,n.editedFields=[...new Set([...c.editedFields??[],...d])],n.editLog=[...c.editLog??[],{at:o,by:s.by.slice(0,80),app:s.app,fields:d,text:k(t,a,d,s.by.slice(0,80),o)}].slice(-50),n},_e.historyLines=function(e){return(e.editLog??[]).slice().reverse().map(e=>e.text??`${e.fields.map(e=>f[e]??e).join(', ')} changed by ${e.by} ${w(e.at)}`.replace(/^./,e=>e.toUpperCase()))},_e.editWarnings=function(e,s,o,d,n=90,c){const l=[];if(!$(e,s).some(e=>['date','time','partySize','table','duration','dogs','status'].includes(e)))return l;const h={...e,date:s.date,time:s.time,partySize:s.partySize,...Number(s.duration??0)>=15?{durationMins:Number(s.duration)}:{}};if(s.table){const e=(0,t.tableOverlaps)(h,s.table,o.filter(e=>e.date===s.date),n);if(e.length&&l.push(`The table already has a booking at about the same time: ${e.map(e=>`${e.time} ${e.walkIn?'walk-in':e.name}`).join(', ')}.`),c){const e=s.table.split('+').map(e=>e.trim()).filter(Boolean).map(e=>c.tables.find(t=>t.name===e)).filter(Boolean),t=e.reduce((e,t)=>e+t.maxSeats,0),o=e.length?(0,a.overCapacityAsk)(e.map(e=>e.name),t,s.partySize):null;o&&l.push(o);const d=e.map(e=>c.areas.find(t=>t.id===e.areaId)).filter(e=>e&&!e.dogs);Number(s.dogs??0)>0&&d.length&&l.push(`Dogs aren\u2019t allowed in ${d[0].name}. Pick a dog-friendly table.`)}}d&&l.push(`Bookings are paused ${d.from} to ${d.to}${d.reason?` (${d.reason})`:''}.`);return l},Object.defineProperty(_e,"editedWords",{enumerable:!0,get:function(){return M}}),_e.bookingExtras=function(e){const t=e,a=e.dogs??(e.dog?1:0),s=[];e.children&&s.push(O(e.children,'child','children'));a&&s.push(O(a,'dog','dogs'));t.highChairs&&s.push(O(t.highChairs,'high chair','high chairs'));e.access?.wheelchair&&s.push(O(e.access.wheelchair,'wheelchair','wheelchairs'));e.diet?.vegan&&s.push(`${e.diet.vegan} vegan`);e.diet?.vegetarian&&s.push(`${e.diet.vegetarian} vegetarian`);e.occasion&&s.push(e.occasion.charAt(0).toUpperCase()+e.occasion.slice(1));t.area&&s.push(t.area);t.depositMethod&&(e.depositPaid??0)>0&&s.push(`Deposit by ${t.depositMethod}`);return s.join(' \xb7 ')};var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]);const s='For example: birthday, high chair, dog, window seat',o='This booking is on the website too. Saving here updates the website booking. The website may email the guest about a new date, time or status.',d=e=>e.filter(e=>'date'===e||'time'===e||'status'===e);const n=e=>{const t=e;return'Wix'===t.importedFrom||!!t.wix||(e.tags??[]).includes('Wix')},c=['date','time','partySize','children','name','phone','email','notes','table','area','dogs','highChairs','wheelchair','occasion','allergies','diet','deposit','status','source','tags','duration'],l=['card','cash','bank transfer','website','other'],h=[{id:'pending',label:'Needs confirming'},{id:'confirmed',label:'Confirmed'},{id:'seated',label:'Seated'},{id:'finished',label:'Finished'},{id:'noshow',label:'No-show'}],p=[{id:'phone',label:'Phone'},{id:'in-person',label:'In person'},{id:'online',label:'Online'}],u=[{id:'',label:'None'},{id:'birthday',label:'Birthday'},{id:'anniversary',label:'Anniversary'},{id:'celebration',label:'Celebration'}],b=['VIP','Regular'],f={date:'date',time:'time',partySize:'covers',children:'children',name:'name',phone:'phone',email:'email',notes:'notes',table:'table',area:'area',dogs:'dogs',highChairs:'high chairs',wheelchair:'wheelchairs',occasion:'occasion',allergies:'allergies',diet:'dietary',deposit:'deposit',status:'status',source:'source',tags:'tags',duration:'table time'},y=e=>{const t=e;return{date:e.date,time:e.time,partySize:e.partySize,name:e.name,phone:e.phone??'',email:e.email??'',notes:e.notes??'',table:e.table??'',area:t.area??'',dogs:e.dogs??(e.dog?1:0),highChairs:t.highChairs??0,wheelchair:e.access?.wheelchair??0,occasion:e.occasion??'',allergies:e.allergies??[],allergyNone:!!e.allergyNone,allergyNote:e.allergyNote??'',vegan:e.diet?.vegan??0,vegetarian:e.diet?.vegetarian??0,depositOn:'deposit'===e.security||(e.depositDue??0)>0||(e.depositPaid??0)>0,depositPaid:(e.depositPaid??0)>0&&!!e.depositPaidBy,depositAmount:(e.depositPaid??0)>0?e.depositPaid:e.depositDue??0,depositMethod:t.depositMethod??'',depositDate:(a=e.depositPaidAt,a?a.slice(0,10):''),depositDue:e.depositDue??0,children:e.children??0,depositWaived:!!e.depositWaived?.by,depositWaiveNote:e.depositWaived?.note??'',status:e.status,source:e.source??'',tags:[...e.tags??[]].filter(e=>b.includes(e)).sort(),duration:e.durationMins??0};var a},v=e=>JSON.stringify([[...e.allergies??[]].map(e=>`${e.allergen}:${e.severity}`).sort(),!!e.allergyNone,(e.allergyNote??'').trim()]),N=e=>JSON.stringify(e.depositOn?[!0,!!e.depositPaid,Number(e.depositAmount??0),Number(e.depositDue??0),e.depositPaid?e.depositMethod??'':'',e.depositPaid?e.depositDate??'':'',!e.depositPaid&&!!e.depositWaived,!e.depositPaid&&e.depositWaived?(e.depositWaiveNote??'').trim():'']:[!1]);function P(e,t){switch(e){case'partySize':return Number(t.partySize);case'allergies':return v(t);case'diet':return`${Number(t.vegan??0)}/${Number(t.vegetarian??0)}`;case'deposit':return N(t);case'tags':return[...t.tags??[]].sort().join(',');case'dogs':case'highChairs':case'wheelchair':case'duration':case'children':return Number(t[e]??0);default:return String(t[e]??'').trim()}}function $(e,t){const a=y(e);return c.filter(e=>P(e,a)!==P(e,t))}const S=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`,w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},O=(e,t,a)=>`${e} ${1===e?t:a}`;function k(e,t,a,s,o){const d=y(e),n=[];for(const e of[...a].sort((e,t)=>Number('deposit'===t)-Number('deposit'===e)))'deposit'===e?t.depositOn?t.depositPaid||!t.depositWaived||d.depositWaived?t.depositPaid||t.depositWaived||!d.depositWaived||d.depositPaid?t.depositPaid&&!d.depositPaid?n.push(`deposit marked paid (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`):!t.depositPaid&&d.depositPaid?n.push('deposit marked not paid'):n.push(t.depositPaid?`deposit changed (${S(Number(t.depositAmount??0))}${t.depositMethod?`, ${t.depositMethod}`:''})`:`deposit due ${S(Number(t.depositDue??0))}`):n.push('deposit waiver taken off'):n.push("deposit waived"+((t.depositWaiveNote??'').trim()?` (${(t.depositWaiveNote??'').trim().slice(0,120)})`:'')):n.push('deposit taken off'):'dogs'===e?n.push(!d.dogs&&t.dogs?1===t.dogs?'dog added':`${t.dogs} dogs added`:t.dogs?O(Number(t.dogs),'dog','dogs'):'no dog now'):'highChairs'===e?n.push(t.highChairs?O(Number(t.highChairs),'high chair','high chairs'):'no high chair now'):'wheelchair'===e?n.push(t.wheelchair?O(Number(t.wheelchair),'wheelchair user','wheelchair users'):'no wheelchair now'):'partySize'===e?n.push(`covers ${d.partySize} to ${t.partySize}`):'children'===e?n.push(t.children?`${O(Number(t.children),'child','children')} (no deposit for children)`:'no children now'):'time'===e?n.push(`time ${d.time} to ${t.time}`):'date'===e?n.push(`date ${d.date} to ${t.date}`):'table'===e?n.push(t.table?`table ${t.table}`:'table taken off'):'status'===e?n.push(`status ${h.find(e=>e.id===t.status)?.label.toLowerCase()??t.status}`):'occasion'===e?n.push(t.occasion?`occasion ${t.occasion}`:'occasion taken off'):'area'===e?n.push(t.area?`area ${t.area}`:'any area'):'duration'===e?n.push(t.duration?`table time ${t.duration} min`:'table time as usual'):n.push(`${f[e]} changed`);const c=n.join(', ');return`${c.charAt(0).toUpperCase()}${c.slice(1)} by ${s} ${w(o)}`}const M=e=>e.map(e=>f[e]).join(', ')},1138,[1128,1120,1124]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WALKIN_MATCH_MINS",{enumerable:!0,get:function(){return t}}),e.bookingsNearWalkIn=function(s,o,u,d=3){const c=n(o);return s.filter(t=>t.date===c&&!t.walkIn&&('confirmed'===t.status||'pending'===t.status)&&/^\d{2}:\d{2}/.test(t.time||'')).map(t=>({b:t,d:Math.abs((new Date(`${t.date}T${t.time.slice(0,5)}:00`).getTime()-o.getTime())/6e4)})).filter(n=>n.d<=t).sort((t,n)=>(u?Number(n.b.partySize===u)-Number(t.b.partySize===u):0)||t.d-n.d).slice(0,d).map(t=>t.b)},e.walkInMatchQuestion=function(t){return`Is this ${t.name}, ${t.time.slice(0,5)}, ${t.partySize} ${1===t.partySize?'person':'people'}?`};const t=45,n=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1139,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canCancelWalkIn",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"canReinstateWalkIn",{enumerable:!0,get:function(){return h}}),_e.cancelWalkInWords=x,_e.reinstateWalkInWords=p,_e.cancelWalkInNow=$,_e.reinstateWalkInNow=I,_e.CancelWalkInButton=function({rid:e,b:t,onDone:l,small:s,big:o}){const[c,u]=(0,n.useState)(!1);return y(t)?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.Button,{kind:"secondary",small:s,label:"Cancel walk-in",testID:`cancel-walkin-${t.id}`,accessibilityLabel:`Cancel walk-in ${t.ref}, ${t.partySize} Covers`,onPress:()=>u(!0),style:o?{minHeight:64}:s?{minHeight:44}:w}),c?(0,k.jsx)(j,{rid:e,b:t,onClose:()=>u(!1),onDone:l}):null]}):null},_e.CancelWalkInConfirm=j,_e.ReinstateWalkInButton=function({rid:e,b:t,today:l,onDone:o,small:c}){const[u,y]=(0,n.useState)(!1);if(!h(t,l))return null;const x=p(t);if(!u)return(0,k.jsx)(f.Button,{kind:"ghost",small:c,label:"Undo cancel",testID:`reinstate-walkin-${t.id}`,accessibilityLabel:`Undo cancel for walk-in ${t.ref}`,onPress:()=>y(!0),style:c?{minHeight:44}:w});return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:()=>y(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:x,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:x})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, put back to seated",testID:"reinstate-walkin-yes",accessibilityLabel:`Yes, put walk-in ${t.ref} back to seated`,style:[w,{flexGrow:1}],onPress:async()=>{await I(e,t),y(!1),o?.(`Walk-in ${t.ref} put back to seated.`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-walkin-no",onPress:()=>y(!1),style:w})]})]})};var e,t=r(d[0]),n=r(d[1]),l=r(d[2]),s=(e=l)&&e.__esModule?e:{default:e},o=r(d[3]),c=r(d[4]),u=r(d[5]),b=r(d[6]),f=r(d[7]),k=r(d[8]);const w={minHeight:56},y=e=>!!e.walkIn&&('seated'===e.status||'confirmed'===e.status),h=(e,t)=>!!e.walkIn&&'cancelled'===e.status&&e.date>=t;function x(e){const t=(0,c.tablesOf)(e.table),n=(0,u.tablesWords)(t);return`Cancel walk-in ${e.ref}, ${e.partySize} Covers${t.length?` at ${n}`:''}, arrived ${e.time}? It comes off the Covers${t.length?` and ${n} ${t.length>1?'go':'goes'} back to Free`:''}.`}function p(e){return`Put walk-in ${e.ref} back to seated? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`}async function $(e,n){await o.repo.bookings.setStatus(n.id,'cancelled'),await o.repo.bookings.update(n.id,{cancelled:(0,t.cancelStamp)(n)}),(0,c.tablesOf)(n.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function I(e,t){await o.repo.bookings.setStatus(t.id,'seated'),(0,c.tablesOf)(t.table).forEach(t=>c.useFloor.getState().setLive(e,t,{stage:'seated',dirty:!1}))}function j({rid:e,b:t,onClose:n,onDone:l}){const o=x(t);return(0,k.jsxs)(f.Sheet,{visible:!0,onClose:n,title:"Cancel walk-in?",maxWidth:560,testID:"cancel-walkin-confirm",children:[(0,k.jsx)(s.default,{accessible:!0,accessibilityLabel:o,children:(0,k.jsx)(f.T,{size:18,colour:b.colours.text,children:o})}),(0,k.jsxs)(f.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(f.Button,{label:"Yes, cancel walk-in",testID:"cancel-walkin-yes",accessibilityLabel:`Yes, cancel walk-in ${t.ref}`,style:[w,{flexGrow:1}],onPress:async()=>{await $(e,t),n(),l?.(`Walk-in ${t.ref} cancelled.${(0,c.tablesOf)(t.table).length?` ${(0,u.tablesWords)((0,c.tablesOf)(t.table))} free.`:''}`)}}),(0,k.jsx)(f.Button,{kind:"secondary",label:"Keep walk-in",testID:"cancel-walkin-no",accessibilityLabel:`Keep walk-in ${t.ref}`,onPress:n,style:w})]})]})}},1140,[1141,34,102,874,1029,1124,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.cancelStamp=C,_e.cancelBookingNow=w,_e.reinstateBookingNow=$,_e.CancelBookingButton=function({rid:e,b:n,name:o,onDone:s,big:l,small:c}){const[u,f]=(0,t.useState)(!1);return(0,b.canCancelBooking)(n)?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(x.Button,{kind:"secondary",small:c,label:"Cancel booking",testID:`cancel-booking-${n.id}`,accessibilityLabel:`Cancel booking for ${o}, ${n.time}, ${n.partySize} Covers`,onPress:()=>f(!0),style:l?{minHeight:64}:c?{minHeight:44}:j}),u?(0,h.jsx)(D,{rid:e,b:n,name:o,onClose:()=>f(!1),onDone:s}):null]}):null},_e.CancelBookingConfirm=D,_e.ReinstateBookingButton=function({b:e,name:n,today:s,onDone:l}){const[c,u]=(0,t.useState)(!1);if(!(0,b.canReinstateBooking)(e,s))return null;const y=(0,b.reinstateBookingWords)(e,n);if(!c)return(0,h.jsx)(x.Button,{kind:"ghost",label:"Undo cancel",testID:`reinstate-booking-${e.id}`,accessibilityLabel:`Undo cancel for ${n}`,onPress:()=>u(!0),style:j});return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:()=>u(!1),title:"Undo cancel?",maxWidth:560,testID:"reinstate-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center'},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, put back to booked",testID:"reinstate-booking-yes",accessibilityLabel:`Yes, put ${n} back to booked`,style:[j,{flexGrow:1}],onPress:async()=>{await $(e),u(!1),l?.(`${n} put back to booked.`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep cancelled",testID:"reinstate-booking-no",onPress:()=>u(!1),style:j})]})]})};var e,t=r(d[0]),n=r(d[1]),o=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),c=r(d[4]),b=r(d[5]),u=r(d[6]),f=r(d[7]),y=r(d[8]),k=r(d[9]),p=r(d[10]),x=r(d[11]),h=r(d[12]);const j={minHeight:56},B={display:'Display',owner:'Managers app',staff:'Staff app',chef:'Kitchen app',customer:'Customer page'};function C(e){const t=y.useSession.getState().meId,n=t?k.useOwner.getState().staff.find(e=>e.id===t):void 0,o=B[p.APP_VARIANT]??'CoverCharge';return{by:n?`${n.name.replace(' (example)','')} (${o})`:o,at:(new Date).toISOString(),app:o,...e.table?{table:e.table}:{}}}async function w(e,t){const n=(0,l.tablesOf)(t.table);await s.repo.bookings.update(t.id,{status:'cancelled',cancelled:C(t),...(0,c.tablePatch)(null)}),n.forEach(t=>l.useFloor.getState().setLive(e,t,{stage:void 0,dirty:!1}))}async function $(e){await s.repo.bookings.setStatus(e.id,'confirmed')}function D({rid:e,b:t,name:n,onClose:s,onDone:c}){const y=(0,b.cancelBookingWords)(t,n),k=(0,l.tablesOf)(t.table);return(0,h.jsxs)(x.Sheet,{visible:!0,onClose:s,title:"Cancel booking?",maxWidth:560,testID:"cancel-booking-confirm",children:[(0,h.jsx)(o.default,{accessible:!0,accessibilityLabel:y,style:{alignItems:'center',gap:8},children:(0,h.jsx)(x.T,{size:18,colour:f.colours.text,style:{textAlign:'center'},children:y})}),(0,h.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,h.jsx)(x.Button,{label:"Yes, cancel booking",testID:"cancel-booking-yes",accessibilityLabel:`Yes, cancel booking for ${n}`,style:[j,{flexGrow:1}],onPress:async()=>{await w(e,t),s(),c?.(`${n} cancelled.${k.length?` ${(0,u.tablesWords)(k)} free.`:''}`)}}),(0,h.jsx)(x.Button,{kind:"secondary",label:"Keep booking",testID:"cancel-booking-no",accessibilityLabel:`Keep booking for ${n}`,onPress:s,style:j})]})]})}},1141,[34,102,874,1029,1120,1142,1124,821,1004,891,872,794,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"canCancelBooking",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"canReinstateBooking",{enumerable:!0,get:function(){return t}}),e.cancelBookingWords=function(n,t){const o=`${n.partySize} Cover${1===n.partySize?'':'s'}`;return`Cancel booking for ${t}, ${n.time}, ${o}? The table is freed. Website bookings will cancel it on the website and may email the guest.`},e.reinstateBookingWords=function(n,t){return`Put ${t} back to booked for ${n.time}? CoverCharge only \u2014 if it was cancelled on the website, put it back there too if needed.`},e.cancelledOnDay=o,e.cancelledDayTally=function(n,t){const a=o(n,t),l=a.filter(n=>!!n.walkIn),c=a.filter(n=>!n.walkIn);return{count:a.length,covers:a.reduce((n,t)=>n+t.partySize,0),bookings:c.length,bookingCovers:c.reduce((n,t)=>n+t.partySize,0),walkIns:l.length,walkInCovers:l.reduce((n,t)=>n+t.partySize,0),list:a}},e.cancelledTallyWords=function(n,t="today"){if(!n.count)return`No cancellations ${t}`;const o=[],a=n.bookings??0,l=n.walkIns??0;a&&o.push(`${a} booking${1===a?'':'s'} (${n.bookingCovers??0} Cover${1===(n.bookingCovers??0)?'':'s'})`);l&&o.push(`${l} walk-in${1===l?'':'s'} (${n.walkInCovers??0} Cover${1===(n.walkInCovers??0)?'':'s'})`);if(!o.length)return`Cancelled ${t}: ${n.count} \xb7 ${n.covers} Cover${1===n.covers?'':'s'}`;return`Cancelled ${t}: ${o.join(' \xb7 ')}`};const n=n=>!n.walkIn&&('confirmed'===n.status||'pending'===n.status||'seated'===n.status),t=(n,t)=>!n.walkIn&&'cancelled'===n.status&&n.date>=t;function o(n,t){return n.filter(n=>n.date===t&&'cancelled'===n.status).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name))}},1142,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingEditButton=function({rid:e,booking:i,who:s,role:a,inStaffApp:n,shiftManager:l,big:o,testID:d}){const[r,u]=(0,t.useState)(!1),x=(0,p.useSession)(e=>e.meId),j=(0,b.useOwner)(e=>e.staff.find(e=>e.id===x&&e.active));return i.walkIn||!(0,h.canEditBooking)({variant:c.APP_VARIANT,inStaffApp:n,role:a,shiftManager:l})||x&&!(0,m.canChangeBookings)(j)?null:(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Button,{kind:"secondary",small:!o,label:"Edit booking",sub:o?void 0:"Deposit, dog, table, anything",testID:d??`edit-booking-${i.id}`,accessibilityLabel:`Edit booking, ${i.name}, ${i.time}`,onPress:()=>u(!0),style:{minHeight:o?64:44}}),r?(0,k.jsx)(R,{rid:e,id:i.id,who:s,onClose:()=>u(!1)}):null]})},_e.EditBookingPicker=function({rid:e,today:i,who:s,onClose:a,hidePrivate:n}){const[o,d]=(0,t.useState)(null),r=(0,l.useBookings)(e).filter(e=>!e.walkIn&&e.date>=i&&!['cancelled','noshow','finished'].includes(e.status)).sort((e,t)=>e.date.localeCompare(t.date)||e.time.localeCompare(t.time)).slice(0,200);return o?(0,k.jsx)(R,{rid:e,id:o,who:s,hidePrivate:n,onClose:a}):(0,k.jsxs)(w.Sheet,{visible:!0,onClose:a,title:"Edit booking \xb7 pick a booking",maxWidth:640,testID:"edit-booking-picker",children:[(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: tap the booking you want to change. Any upcoming day."}),r.length?r.map(e=>(0,k.jsx)(w.Button,{kind:"secondary",testID:`edit-pick-${e.id}`,label:`${$(e.date,i)} ${e.time} \xb7 ${e.name} \xb7 ${e.partySize} ${1===e.partySize?'Cover':'Covers'}`,sub:e.notes?`Notes: ${e.notes}`:void 0,accessibilityLabel:`Edit booking, ${e.name}, ${$(e.date,i).toLowerCase()}, ${e.time}, ${e.partySize} Covers`,onPress:()=>d(e.id),style:{minHeight:56}},e.id)):(0,k.jsx)(w.Muted,{center:!0,children:"No bookings to edit from today on."}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:a,style:{minHeight:44}})]})},_e.EditBookingSheet=R;var e,t=_r(_d[0]),i=_r(_d[1]),s=_r(_d[2]),a=_r(_d[3]),n=(e=a)&&e.__esModule?e:{default:e},l=_r(_d[4]),o=_r(_d[5]),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),m=_r(_d[13]),x=_r(_d[14]),j=_r(_d[15]),y=_r(_d[16]),D=_r(_d[17]),C=_r(_d[18]),I=_r(_d[19]),v=_r(_d[20]),f=_r(_d[21]),T=_r(_d[22]),w=_r(_d[23]),k=_r(_d[24]);const S=/^([01]\d|2[0-3]):[0-5]\d$/,P=e=>{const t=e.trim().replace('.',':').match(/^(\d{1,2}):?(\d{2})$/);return t?`${t[1].padStart(2,'0')}:${t[2]}`:e.trim()};const $=(e,t)=>{if(e===t)return'Today';const i=new Date(`${t}T12:00:00`);return i.setDate(i.getDate()+1),e===(0,y.ymd)(i)?'Tomorrow':O(e)};const N=e=>e?(e/100).toFixed(e%100?2:0):'',z=e=>{const t=Number(e.replace(/[\xa3,\s]/g,''));return Number.isFinite(t)&&t>=0?Math.round(100*t):NaN},O=e=>e&&/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`:'',E=e=>{const t=e.trim().match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);return t?`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`:''},W=e=>e.charAt(0).toUpperCase()+e.slice(1);function B({title:e,children:t,testID:i}){return(0,k.jsxs)(n.default,{testID:i,style:{gap:8,paddingTop:10,borderTopWidth:1,borderTopColor:j.colours.hairline,alignItems:'stretch'},children:[(0,k.jsx)(w.T,{size:17,weight:"semibold",center:!0,colour:j.colours.goldLight,children:e}),t]})}const A=({label:e,value:t,onChange:i,max:s=20,testID:a})=>(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:e}),(0,k.jsx)(w.Stepper,{testID:a,value:t,min:0,max:s,onChange:i,label:e})]});function R({rid:e,id:a,who:p,onClose:b,hidePrivate:m='display'===c.APP_VARIANT}){const $=(0,l.useBookings)(e),R=$.find(e=>e.id===a),L=(0,r.useRestaurant)(e),F=(0,o.usePlan)(e),M=(0,d.useBlocks)(e=>e.blocks),[_,H]=(0,t.useState)(R?(0,h.draftOf)(R):null),[V,Y]=(0,t.useState)(null),[G,U]=(0,t.useState)(null),[X,q]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositDue:0)),[J,K]=(0,t.useState)(N(R?(0,h.draftOf)(R).depositAmount:0)),[Q,Z]=(0,t.useState)(O(R?(0,h.draftOf)(R).depositDate:''));if(!R||!_||!L)return null;const ee=e=>{Y(null),U(null),H({..._,...e})},te=(0,f.depositOf)(L.settings),ie=e=>{const t=e.partySize??_.partySize,i=Math.min(e.children??_.children??0,Math.max(0,t-1));if(!(0,h.isWixBooking)(R)&&_.depositOn&&!_.depositPaid&&z(X||'0')===(0,f.depositDue)(te,_.partySize,_.children??0)){const e=(0,f.depositDue)(te,t,i);e>0&&q(N(e))}ee({...e,children:i})},se=P(_.time),ae=S.test(se),ne=_.area?F.areas.filter(e=>e.name===_.area).map(e=>e.id):null,le=e=>!ne||e.split('+').every(e=>ne.includes(F.tables.find(t=>t.name===e)?.areaId??'')),oe=(0,x.tableOptions)(F,$.filter(e=>e.date===_.date),_.table).filter(e=>le(e)||e===_.table),de=!(_.depositOn&&(Number.isNaN(z(X||'0'))||_.depositPaid&&(Number.isNaN(z(J||'0'))||Q.trim()&&!E(Q)))),re={..._,time:se,depositDue:z(X||'0')||0,depositAmount:z(J||'0')||0,depositDate:E(Q)},ce=(0,h.changedFields)(R,re),he=L.settings.turnMins??90,ue=async()=>{const t=(0,h.editPatch)(R,re,{by:p||'Team member',app:c.APP_VARIANT});if(Object.keys(t).length&&await l.repo.bookings.update(R.id,t),'seated'===R.status&&'table'in t&&t.table!==R.table){const i=e=>e?e.split('+').map(e=>e.trim()).filter(Boolean):[],s=i(R.table),a=i(t.table),n=o.useFloor.getState(),l=s.map(t=>n.live[e]?.[t]?.stage).find(Boolean)??'seated';s.filter(e=>!a.includes(e)).forEach(t=>n.setLive(e,t,{stage:void 0,dirty:!0})),a.forEach(t=>n.setLive(e,t,{stage:l,dirty:!1}))}U(`Saved. Changed: ${(0,h.editedWords)(ce)}.`),Y(null),b()},pe=_.allergies??[],ge=e=>ee({allergyNone:!1,allergies:pe.some(t=>t.allergen===e)?pe.filter(t=>t.allergen!==e):[...pe,{allergen:e,severity:'allergy'}]}),be=(0,h.historyLines)(R);return(0,k.jsxs)(w.Sheet,{visible:!0,onClose:b,title:`Edit booking \xb7 ${R.name} \xb7 ${R.ref}`,maxWidth:760,testID:"edit-booking-sheet",children:[(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(C.DepositChip,{b:R,money:!0,big:!0,testID:"edit-deposit"})}),(0,h.isWixBooking)(R)?(0,k.jsx)(n.default,{testID:"edit-wix-note",accessible:!0,accessibilityLabel:h.WIX_EDIT_NOTE,style:{padding:12,borderRadius:12,borderWidth:1,borderColor:j.colours.gold},children:(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:h.WIX_EDIT_NOTE})}):null,(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.text,children:"Tip: change what you need, then press Save changes. Website bookings are updated too."}),(0,k.jsxs)(B,{title:"Deposit",testID:"edit-section-deposit",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No deposit",selected:!_.depositOn,testID:"edit-deposit-none",onPress:()=>ee({depositOn:!1,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit due",selected:!!_.depositOn&&!_.depositPaid&&!_.depositWaived,testID:"edit-deposit-due",onPress:()=>ee({depositOn:!0,depositPaid:!1,depositWaived:!1})}),(0,k.jsx)(w.Chip,{label:"Deposit paid",selected:!!_.depositOn&&!!_.depositPaid,testID:"edit-deposit-paid",onPress:()=>{J||K(X),Q||Z(O((0,y.ymd)(new Date))),ee({depositOn:!0,depositPaid:!0,depositWaived:!1})}}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsx)(w.Chip,{label:"Deposit waived",selected:!0,testID:"edit-deposit-waived",onPress:()=>{}}):null]}),_.depositOn&&!_.depositPaid&&_.depositWaived?(0,k.jsxs)(w.T,{size:15,center:!0,colour:j.colours.goldLight,testID:"edit-deposit-waived-by",children:[R.depositWaived?.by?(0,f.waiverText)(R.depositWaived):'Waived',". Tap Deposit due to ask for it again."]}):null,_.depositWaived||ce.includes('deposit')?null:(0,k.jsx)(n.default,{style:{alignItems:'center'},children:(0,k.jsx)(v.WaiveDepositButton,{b:R,who:p,onDone:e=>H({..._,depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:e})})}),_.depositOn?(0,k.jsx)(w.Field,{label:"Deposit due (\xa3)",value:X,onChangeText:e=>{q(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-due-amount"}):null,_.depositOn&&_.depositPaid?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Amount paid (\xa3)",value:J,onChangeText:e=>{K(e),ee({})},keyboardType:"decimal-pad",testID:"edit-deposit-amount"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"How was it paid?"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.DEPOSIT_METHODS.map(e=>(0,k.jsx)(w.Chip,{label:W(e),selected:_.depositMethod===e,testID:`edit-deposit-method-${e.replace(' ','-')}`,onPress:()=>ee({depositMethod:e})},e))}),(0,k.jsx)(w.Field,{label:"Date paid (DD/MM/YYYY)",value:Q,onChangeText:e=>{Z((0,i.slashDate)(e,Q)),ee({})},placeholder:"11/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,testID:"edit-deposit-date"}),Q.trim()&&!E(Q)?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write the date like 11/11/2026."}):null]}):null,de?null:(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"Write amounts in pounds, for example 60 or 12.50."}),(0,k.jsx)(w.Muted,{center:!0,children:"No payment is taken in CoverCharge: this records what the guest paid."})]}),(0,k.jsxs)(B,{title:"When",testID:"edit-section-when",children:[(0,k.jsx)(D.BookingDatePicker,{r:L,today:new Date,value:_.date,onChange:e=>ee({date:e})}),(0,k.jsx)(w.Field,{label:"Time (24-hour, for example 19:15)",value:_.time,onChangeText:e=>ee({time:e}),testID:"edit-time"}),ae?null:(0,k.jsx)(w.T,{size:15,colour:j.colours.amber,children:"Write the time like 19:15."}),(0,k.jsxs)(n.default,{style:{gap:6,alignItems:'center'},children:[(0,k.jsx)(w.T,{size:18,center:!0,children:"Covers"}),(0,k.jsx)(s.PartySizeInput,{value:_.partySize,onChange:e=>ie({partySize:e}),label:"Covers",testID:"edit-covers"})]}),(0,k.jsx)(I.ChildrenCount,{party:_.partySize,value:_.children??0,onChange:e=>ie({children:e}),depositsOn:te.on&&te.perPersonPence>0,testID:"edit-children"}),(0,k.jsxs)(w.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,k.jsx)(w.T,{size:16,children:"Table time"}),(0,k.jsx)(w.Stepper,{testID:"edit-duration",value:_.duration||0,min:0,max:360,step:15,onChange:e=>ee({duration:e}),format:e=>e?`${Math.floor(e/60)}h ${String(e%60).padStart(2,'0')}m`:'As usual',label:"Table time"})]})]}),(0,k.jsxs)(B,{title:"Where",testID:"edit-section-where",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"Any area",selected:!_.area,testID:"edit-area-any",onPress:()=>ee({area:''})}),F.areas.map(e=>(0,k.jsx)(w.Chip,{label:`${e.name}${e.dogs?' \xb7 dogs ok':''}`,selected:_.area===e.name,testID:`edit-area-${e.id}`,onPress:()=>ee({area:e.name})},e.id))]}),(0,k.jsx)(w.T,{size:18,weight:"semibold",center:!0,children:(0,x.tableButtonLabel)(_.table)}),(0,k.jsxs)(w.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Button,{kind:_.table?'secondary':'primary',label:"No table",accessibilityLabel:"No table"+(_.table?'':', chosen'),onPress:()=>ee({table:''}),style:{minHeight:44,minWidth:96},testID:"edit-table-none"}),oe.map(e=>(0,k.jsx)(w.Button,{kind:e===_.table?'primary':'secondary',label:(0,x.tableButtonLabel)(e),accessibilityLabel:`Table ${(0,x.tableButtonLabel)(e)}${e===_.table?', chosen':''}`,onPress:()=>ee({table:e}),style:{minHeight:44,minWidth:64},testID:`edit-table-${e}`},e))]})]}),(0,k.jsxs)(B,{title:"Guest",testID:"edit-section-guest",children:[(0,k.jsx)(w.Field,{label:"Name",value:_.name,onChangeText:e=>ee({name:e}),testID:"edit-name"}),m?(0,k.jsx)(w.Muted,{center:!0,children:"Phone and email can be changed in the Managers app. Use Show number on the booking to see the number."}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(w.Field,{label:"Phone",value:_.phone,onChangeText:e=>ee({phone:e}),keyboardType:"phone-pad",testID:"edit-phone"}),(0,k.jsx)(w.Field,{label:"Email",value:_.email,onChangeText:e=>ee({email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"edit-email"})]}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Booked by"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.SOURCES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.source===e.id,testID:`edit-source-${e.id}`,onPress:()=>ee({source:e.id})},e.id))}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.TAGS.map(e=>{const t=(_.tags??[]).includes(e);return(0,k.jsx)(w.Chip,{label:e,selected:t,testID:`edit-tag-${e}`,onPress:()=>ee({tags:t?(_.tags??[]).filter(t=>t!==e):[..._.tags??[],e].sort()})},e)})})]}),(0,k.jsxs)(B,{title:"Dogs, high chairs and access",testID:"edit-section-needs",children:[(0,k.jsx)(A,{label:"Dogs",value:_.dogs??0,max:6,onChange:e=>ee({dogs:e}),testID:"edit-dogs"}),(0,k.jsx)(A,{label:"High chairs",value:_.highChairs??0,max:10,onChange:e=>ee({highChairs:e}),testID:"edit-high-chairs"}),(0,k.jsx)(A,{label:"Wheelchair users",value:_.wheelchair??0,max:10,onChange:e=>ee({wheelchair:e}),testID:"edit-wheelchair"}),(0,k.jsx)(w.T,{size:16,center:!0,children:"Occasion"}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.OCCASIONS.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:(_.occasion??'')===e.id,testID:`edit-occasion-${e.id||'none'}`,onPress:()=>ee({occasion:e.id})},e.id||'none'))})]}),(0,k.jsxs)(B,{title:"Allergies and dietary",testID:"edit-section-allergies",children:[(0,k.jsxs)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,k.jsx)(w.Chip,{label:"No allergies",selected:!!_.allergyNone&&!pe.length,testID:"edit-allergy-none",onPress:()=>ee({allergyNone:!0,allergies:[]})}),u.ALLERGENS.map(e=>(0,k.jsx)(w.Chip,{label:e.short,selected:pe.some(t=>t.allergen===e.id),testID:`edit-allergen-${e.id}`,onPress:()=>ge(e.id)},e.id))]}),pe.map(e=>(0,k.jsxs)(n.default,{style:{gap:4,alignItems:'center'},children:[(0,k.jsxs)(w.T,{size:15,center:!0,children:[u.ALLERGENS.find(t=>t.id===e.allergen)?.short,": how serious?"]}),(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:u.SEVERITIES.map(t=>(0,k.jsx)(w.Chip,{label:t.label,selected:e.severity===t.id,testID:`edit-severity-${e.allergen}-${t.id}`,onPress:()=>ee({allergies:pe.map(i=>i.allergen===e.allergen?{...i,severity:t.id}:i)})},t.id))})]},e.allergen)),(0,k.jsx)(w.Field,{label:"Anything else about allergies",value:_.allergyNote,onChangeText:e=>ee({allergyNote:e}),testID:"edit-allergy-note"}),ce.includes('allergies')&&pe.length?(0,k.jsx)(w.T,{size:15,center:!0,colour:j.colours.amber,children:"The kitchen signs off allergies again after this change."}):null,(0,k.jsx)(A,{label:"Vegan",value:_.vegan??0,max:_.partySize,onChange:e=>ee({vegan:e}),testID:"edit-vegan"}),(0,k.jsx)(A,{label:"Vegetarian",value:_.vegetarian??0,max:_.partySize,onChange:e=>ee({vegetarian:e}),testID:"edit-vegetarian"})]}),'cancelled'!==R.status?(0,k.jsxs)(B,{title:"Status",testID:"edit-section-status",children:[(0,k.jsx)(w.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:h.EDIT_STATUSES.map(e=>(0,k.jsx)(w.Chip,{label:e.label,selected:_.status===e.id,testID:`edit-status-${e.id}`,onPress:()=>ee({status:e.id})},e.id))}),(0,k.jsx)(w.Muted,{center:!0,children:"To cancel, use Cancel booking below. Nothing is ever deleted."})]}):null,(0,k.jsx)(B,{title:"Notes",testID:"edit-section-notes",children:(0,k.jsx)(w.Field,{label:"Notes",value:_.notes,onChangeText:e=>ee({notes:e}),placeholder:h.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"edit-notes"})}),V?(0,k.jsxs)(n.default,{testID:"edit-warn",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:j.colours.amber,backgroundColor:j.colours.amberBg},children:[V.map(e=>(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:e},e)),(0,k.jsx)(w.T,{size:16,center:!0,colour:"#FFE2A8",children:"You can still save."})]}):null,G?(0,k.jsx)(w.T,{size:16,center:!0,colour:j.colours.goldLight,children:G}):null,(0,k.jsxs)(w.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(w.Button,{label:V?'Save anyway':'Save changes',testID:"edit-save",disabled:!ae||!de||_.name.trim().length<1||!ce.length,onPress:()=>{const t=ae?(0,d.blockAt)(M,e,_.date,se):void 0,i=(0,h.editWarnings)(R,re,$,t,he,F);!i.length||V?ue():Y(i)},style:{minHeight:56,flex:1}}),(0,k.jsx)(w.Button,{kind:"ghost",label:"Close",onPress:b,style:{minHeight:56}})]}),be.length?(0,k.jsx)(B,{title:"Changes",testID:"edit-history",children:be.slice(0,12).map((e,t)=>(0,k.jsx)(w.T,{size:14,center:!0,colour:j.colours.muted,children:e},t))}):null,(0,k.jsx)(T.CancelBookingButton,{rid:e,b:R,name:R.name,big:!0,onDone:()=>b()}),(0,k.jsx)(T.ReinstateBookingButton,{b:R,name:R.name,today:(0,y.ymd)(new Date),onDone:()=>b()})]})}},1143,[34,1063,1127,102,874,1029,1026,876,872,1138,861,1004,891,1027,1120,821,858,1132,1117,1129,1144,14,1141,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WaiveDepositButton=function({b:e,who:s,onDone:f,small:w}){const[x,W]=(0,t.useState)(!1),[j,k]=(0,t.useState)(''),[D,$]=(0,t.useState)(!1);if(!(0,u.canWaiveDeposit)(e))return null;const P=(e.depositDue??0)>0?y(e.depositDue):'the',I=e.walkIn?`walk-in ${e.ref}`:e.name,_=!!(0,u.wixPayStatus)(e);return x?(0,v.jsxs)(o.default,{testID:`waive-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:b.colours.surface,alignItems:'center',width:'100%'},children:[(0,v.jsxs)(h.T,{size:17,weight:"semibold",center:!0,children:["Waive ",P," deposit for ",I,"?"]}),(0,v.jsxs)(h.Muted,{center:!0,children:["The guest won\u2019t be asked for it. Your name (",(s||'Team member').slice(0,40),") is saved on the booking.",_?' Website bookings may still ask for it on the website.':'']}),(0,v.jsx)(h.Field,{label:"Why? (optional)",value:j,onChangeText:e=>k(e.slice(0,120)),placeholder:"For example: regular",testID:`waive-note-${e.id}`}),(0,v.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,v.jsx)(h.Button,{label:"Yes, waive it",testID:`waive-yes-${e.id}`,accessibilityLabel:`Yes, waive the deposit for ${I}`,onPress:async()=>{if(D)return;$(!0);const t=(s||'Team member').slice(0,80),o=(0,c.editPatch)(e,{...(0,c.draftOf)(e),depositOn:!0,depositPaid:!1,depositWaived:!0,depositWaiveNote:j.trim()},{by:t,app:l.APP_VARIANT});try{Object.keys(o).length&&await n.repo.bookings.update(e.id,o),(0,p.announce)(`Deposit waived for ${I}. Saved with your name.`),f?.(j.trim()),W(!1)}finally{$(!1)}},disabled:D,style:{minHeight:48,minWidth:140}}),(0,v.jsx)(h.Button,{kind:"ghost",label:"Keep the deposit",testID:`waive-no-${e.id}`,onPress:()=>{W(!1),k('')},style:{minHeight:48,minWidth:140}})]})]}):(0,v.jsx)(h.Button,{small:w,kind:"secondary",label:"Waive deposit",testID:`waive-deposit-${e.id}`,accessibilityLabel:`Waive the deposit for ${I}`,onPress:()=>W(!0),style:{minHeight:44}})};var e,t=r(d[0]),s=r(d[1]),o=(e=s)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),c=r(d[4]),u=r(d[5]),p=r(d[6]),b=r(d[7]),h=r(d[8]),v=r(d[9]);const y=e=>`\xa3${(e/100).toFixed(e%100?2:0)}`},1144,[34,102,874,872,1138,14,1125,821,794,25]); +__d(function(g,r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.BookingHistory=function({rid:e,today:t}){const[b,k]=(0,s.useState)((0,n.addDaysIso)(t,-1)),[w,v]=(0,s.useState)('day'),[p,f]=(0,s.useState)((0,n.ddmmyyyy)((0,n.addDaysIso)(t,-1))),[D,$]=(0,s.useState)(!1),[_,I]=(0,s.useState)(0),T=(0,n.historyRange)(w,b,t),C=(0,c.useKitchenHistory)(e,T.from,T.to,t,_),P=(0,d.parseHistoryInput)(p),B=!!P&&(0,d.validPastDate)(P,t),L=e=>{(0,d.validPastDate)(e,t)&&(k(e),f((0,n.ddmmyyyy)(e)))};if(!C.allowed)return(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:20,center:!0,children:"Booking history is for the Head Chef and managers. Sign in to the Head Chef app to see it."})});const z='day'===w?1:7,S=(0,n.addDaysIso)('day'===w?b:(0,n.mondayOf)(b),-z),R='day'===w?(0,n.addDaysIso)(b,1):(0,n.addDaysIso)((0,n.mondayOf)(b),7),W='day'===w?'day':'week';return(0,h.jsxs)(o.default,{style:{gap:14},testID:"booking-history",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},children:[(0,h.jsx)(l.T,{size:18,center:!0,children:"Bookings, covers and walk-ins on past days. Read-only; nothing is changed."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:'day'===w?'primary':'secondary',testID:"bh-mode-day",label:"One day",accessibilityLabel:"Show one day"+('day'===w?', selected':''),onPress:()=>v('day')}),(0,h.jsx)(l.Button,{kind:'week'===w?'primary':'secondary',testID:"bh-mode-week",label:"Whole week",accessibilityLabel:"Show the whole week, Monday to Sunday"+('week'===w?', selected':''),onPress:()=>v('week')})]}),(0,h.jsx)(l.Field,{label:"Past date (DD/MM/YYYY)",value:p,onChangeText:e=>f((0,i.slashDate)(e,p)),placeholder:"09/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Past date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"bh-date",style:{textAlign:'center'}}),B?null:(0,h.jsx)(l.T,{size:16,center:!0,testID:"bh-date-hint",children:"Enter a past date as DD/MM/YYYY, for example 09/11/2026."}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",label:"Pick a date",testID:"bh-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${u(b)}`,onPress:()=>$(!0)}),(0,h.jsx)(l.Button,{label:"Show",testID:"bh-show",accessibilityLabel:`Show booking history for ${B&&P?u(P):'a valid past date'}`,disabled:!B,onPress:()=>{P&&L(P),I(_+1)}})]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-prev",label:`Previous ${W}`,accessibilityLabel:`Previous ${W}, ${u(S)}`,onPress:()=>L(S)}),(0,h.jsx)(l.Button,{kind:"secondary",testID:"bh-next",label:`Next ${W}`,accessibilityLabel:(0,d.validPastDate)(R,t)?`Next ${W}, ${u(R)}`:`Next ${W}, not available. Booking history is for past days only`,disabled:!(0,d.validPastDate)(R,t),onPress:()=>L(R)})]}),'day'===w?(0,h.jsx)(l.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:(0,h.jsx)(l.Button,{small:!0,kind:"secondary",testID:"bh-prev-week",label:"Same day last week",accessibilityLabel:`Same day last week, ${u((0,n.addDaysIso)(b,-7))}`,onPress:()=>L((0,n.addDaysIso)(b,-7))})}):null]})}),(0,h.jsx)(y.LookBackCalendar,{visible:D,today:t,selected:b,purpose:"Booking history",idPrefix:"bh",onClose:()=>$(!1),onPick:e=>{L(e),$(!1)}}),C.data?'day'===w?C.data.days[0]?(0,h.jsx)(x,{d:C.data.days[0]}):null:(0,h.jsx)(j,{days:C.data.days,onDay:e=>{L(e),v('day')}}):(0,h.jsx)(l.Card,{children:(0,h.jsx)(o.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(l.T,{size:20,center:!0,testID:"bh-status",children:C.error||'Loading booking history\u2026'})})})]})};var e,s=r(_d[0]),t=r(_d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(_d[2]),i=r(_d[3]),d=r(_d[4]),n=r(_d[5]),c=r(_d[6]),y=r(_d[7]),b=r(_d[8]),h=r(_d[9]);const u=e=>`${(0,n.dayName)(e)} ${(0,n.ddmmyyyy)(e)}`,k=({label:e,value:s,id:t})=>(0,h.jsxs)(o.default,{testID:`bh-stat-${t}`,accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',minWidth:96,padding:8,borderRadius:12,borderWidth:1,borderColor:b.colours.border},children:[(0,h.jsx)(l.T,{size:28,weight:"bold",colour:b.colours.gold,center:!0,children:String(s)}),(0,h.jsx)(l.T,{size:16,center:!0,children:e})]});function x({d:e}){return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-day",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:(0,n.dayText)(e)+`. Done: ${e.done_covers+e.walk_in_covers} covers.`,children:[(0,h.jsx)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:u(e.date)}),(0,h.jsx)(o.default,{testID:"bh-stats",style:{alignSelf:'stretch'},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"bookings",label:"Bookings",value:e.bookings}),(0,h.jsx)(k,{id:"booked",label:"Booked covers",value:e.booked_covers}),(0,h.jsx)(k,{id:"walkins",label:"Walk-ins",value:e.walk_ins}),(0,h.jsx)(k,{id:"walkin-covers",label:"Walk-in covers",value:e.walk_in_covers}),(0,h.jsx)(k,{id:"done",label:"Done",value:e.done_covers+e.walk_in_covers}),(0,h.jsx)(k,{id:"total",label:"Total",value:e.total_covers})]})}),e.not_counted?(0,h.jsxs)(l.T,{size:16,center:!0,children:[e.not_counted," cancelled or no-show ",1===e.not_counted?'booking is':'bookings are'," listed but not counted."]}):null,e.old_records?(0,h.jsx)(l.T,{size:16,center:!0,colour:b.colours.muted,children:"Includes records from the previous booking system, which may be incomplete."}):null]})}),(e.lines??[]).length||e.walk_ins?null:(0,h.jsx)(l.Card,{children:(0,h.jsx)(l.T,{size:18,center:!0,children:"No bookings or walk-ins recorded for this day."})}),(e.lines??[]).map((e,s)=>(0,h.jsx)(o.default,{testID:"bh-line",accessible:!0,accessibilityLabel:(0,n.lineText)(e),style:{padding:10,borderRadius:12,borderWidth:1,borderColor:b.colours.border,alignItems:'center',opacity:e.counted?1:.7},children:(0,h.jsxs)(l.Row,{wrap:!0,gap:14,style:{justifyContent:'center'},children:[(0,h.jsx)(l.T,{size:20,weight:"bold",colour:b.colours.gold,children:e.time??'No time'}),(0,h.jsx)(l.T,{size:18,children:null==e.covers?'Covers not recorded':`${e.covers} ${1===e.covers?'cover':'covers'}`}),(0,h.jsx)(l.T,{size:18,children:e.table?`Table ${e.table}`:'No table'}),(0,h.jsx)(l.T,{size:18,children:(0,n.statusWord)(e.status)})]})},s))]})}function j({days:e,onDay:s}){const t=(0,n.sumDays)(e);return(0,h.jsxs)(o.default,{style:{gap:12},testID:"bh-week",children:[(0,h.jsx)(l.Card,{children:(0,h.jsxs)(o.default,{style:{gap:10,alignItems:'center'},accessible:!0,accessibilityLabel:`Week ${(0,n.ddmmyyyy)(e[0].date)} to ${(0,n.ddmmyyyy)(e[e.length-1].date)}: ${t.bookings} bookings, ${t.booked_covers} booked covers, ${t.walk_ins} walk-ins with ${t.walk_in_covers} covers, ${t.total_covers} covers in total`,children:[(0,h.jsxs)(l.T,{size:22,weight:"bold",center:!0,accessibilityRole:"header",children:["Week ",(0,n.ddmmyyyy)(e[0].date)," to ",(0,n.ddmmyyyy)(e[e.length-1].date)]}),(0,h.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(k,{id:"week-bookings",label:"Bookings",value:t.bookings}),(0,h.jsx)(k,{id:"week-walkins",label:"Walk-ins",value:t.walk_ins}),(0,h.jsx)(k,{id:"week-total",label:"Total",value:t.total_covers})]})]})}),e.map(e=>(0,h.jsx)(l.Button,{kind:"secondary",testID:`bh-week-day-${e.date}`,label:`${(0,n.day3)(e.date)} ${(0,n.ddmmyyyy)(e.date)} \xb7 ${e.bookings} booked (${e.booked_covers}) \xb7 ${e.walk_ins} walk-in (${e.walk_in_covers}) \xb7 Total ${e.total_covers}`,accessibilityLabel:`${(0,n.dayText)(e)}. Double tap to see this day's bookings.`,onPress:()=>s(e.date)},e.date))]})}},1145,[34,102,794,1063,1093,1146,1092,1086,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"addDaysIso",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ddmmyyyy",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"day3",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dayName",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mondayOf",{enumerable:!0,get:function(){return l}}),e.historyRange=function(o,t,s){if('day'===o)return{from:t,to:t};const a=l(t),c=n(a,6),d=n(s,-1);return{from:a,to:c({bookings:o.bookings+t.bookings,booked_covers:o.booked_covers+t.booked_covers,walk_ins:o.walk_ins+t.walk_ins,walk_in_covers:o.walk_in_covers+t.walk_in_covers,total_covers:o.total_covers+t.total_covers}),{bookings:0,booked_covers:0,walk_ins:0,walk_in_covers:0,total_covers:0})};const o=o=>o.toISOString().slice(0,10),t=o=>new Date(o+'T12:00:00Z'),n=(n,s)=>{const a=t(n);return a.setUTCDate(a.getUTCDate()+s),o(a)},s=o=>`${o.slice(8,10)}/${o.slice(5,7)}/${o.slice(0,4)}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],c=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d=o=>a[t(o).getUTCDay()],u=o=>c[t(o).getUTCDay()],l=o=>n(o,-(t(o).getUTCDay()+6)%7);function b(o){switch((o??'').toLowerCase()){case'finished':case'seated':return'Done';case'confirmed':case'booked':case'amended':return'Booked';case'cancelled':return'Cancelled';case'noshow':return'No-show';default:return o||'Not recorded'}}const y=(o,t,n)=>`${o} ${1===o?t:n}`},1146,[]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TempUnitsSetup=function(){const e=(0,f.useSync)(e=>e.mode),s='live'===e||'offline'===e||'connecting'===e,o=(0,c.useSafety)(e=>e.points),b=(0,d.useOwner)(e=>e.site),[k,j]=(0,t.useState)(()=>(0,u.draftsFrom)(c.useSafety.getState().points)),[$,S]=(0,t.useState)(null),[I,w]=(0,t.useState)(!1),[T,D]=(0,t.useState)(''),[C,L]=(0,t.useState)(1),B=(0,t.useMemo)(()=>(0,u.changesOf)(k,o),[k,o]),z=e=>(0,h.chefCanSee)(b,e),A=Object.fromEntries(k.map(e=>[e.key,(0,u.problemOf)(e,k,z)])),P=Object.values(A).some(Boolean),R=e=>{j(t=>t.map(t=>t.key===e.key?e:t)),D(''),w(!1)},_=k.filter(e=>!e.archived),O=k.filter(e=>e.archived&&e.id),F=_.filter(e=>'fridge'===e.kind).length,H=_.length-F,M=e=>{const t=`new${C}`;L(C+1),D(''),w(!1),j(s=>[...s,{key:t,name:'',kind:e,location:'',max:String(u.DEFAULT_MAX[e]),due:'09:00, 16:00',archived:!1}])},W=P?'Fix the unit marked in red first.':B.length?`${B.length} change${1===B.length?'':'s'} not saved yet.`:'No changes yet.';return(0,x.jsxs)(n.default,{testID:"tu-setup",style:{gap:12,alignSelf:'center',width:'100%',maxWidth:560,alignItems:'stretch'},children:[(0,x.jsx)(l.T,{weight:"semibold",size:18,center:!0,accessibilityRole:"header",children:"Temperature units"}),(0,x.jsx)(l.T,{testID:"tu-count",size:15,center:!0,children:`${F} fridge${1===F?'':'s'} and ${H} freezer${1===H?'':'s'} checked`}),(0,x.jsx)(p.TempSaveBanner,{testID:"tu-save-banner"}),(0,x.jsx)(l.Banner,{kind:"info",title:s?'Shared with every device':'Not connected yet',children:s?'These units and their readings are on the shared food safety log, so every phone, tablet and screen at the venue shows the same units.':'These units are saved on this device until it connects. Then they are shared with every device at the venue.'}),_.map(e=>(0,x.jsxs)(n.default,{style:{gap:8},children:[(0,x.jsx)(v,{d:e,problem:A[e.key],onChange:R,onArchive:()=>e.id?S(e.key):j(t=>t.filter(t=>t.key!==e.key))}),$===e.key?(0,x.jsxs)(n.default,{testID:"tu-archive-ask",style:{gap:8,padding:12,borderRadius:12,backgroundColor:y.colours.amberBg,alignItems:'center'},children:[(0,x.jsx)(l.T,{size:15,center:!0,children:`Archive ${e.name.trim()||'this unit'}? It will no longer be checked. Its past readings stay in History and the EHO report. Nothing is deleted.`}),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-archive-confirm",label:"Archive",accessibilityLabel:`Yes, archive ${e.name}`,onPress:()=>{R({...e,archived:!0}),S(null)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-archive-cancel",label:"Keep it",accessibilityLabel:`No, keep ${e.name}`,onPress:()=>S(null)})]})]}):null]},e.key)),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-fridge",label:"Add a fridge",onPress:()=>M('fridge')}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-add-freezer",label:"Add a freezer",onPress:()=>M('freezer')})]}),O.length?(0,x.jsxs)(n.default,{testID:"tu-archived",style:{gap:6,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:"Archived (not checked, history kept)"}),O.map(e=>(0,x.jsxs)(l.Row,{gap:8,style:{justifyContent:'center'},children:[(0,x.jsx)(l.T,{size:14,center:!0,children:e.name}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-restore-${e.key}`,label:"Bring back",accessibilityLabel:`Bring back ${e.name}`,onPress:()=>R({...e,archived:!1,due:e.due||'09:00, 16:00'})})]},e.key))]}):null,I?(0,x.jsxs)(n.default,{testID:"tu-save-ask",style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:y.colours.gold,alignItems:'center'},children:[(0,x.jsx)(l.T,{weight:"medium",center:!0,children:`Save ${B.length} change${1===B.length?'':'s'}?`}),B.map(e=>(0,x.jsx)(l.T,{size:14,center:!0,children:e.text},e.key)),(0,x.jsxs)(l.Row,{gap:8,children:[(0,x.jsx)(l.Button,{small:!0,testID:"tu-save-confirm",label:"Save",accessibilityLabel:"Yes, save the changes",onPress:()=>{const e=c.useSafety.getState(),t=new Set(e.points.map(e=>e.id));for(const t of B)t.add?e.addPoint(t.add):t.id&&t.patch&&e.setPoint(t.id,t.patch);j((0,u.draftsFrom)(c.useSafety.getState().points)),w(!1);const n=[...B.filter(e=>e.id).map(e=>e.id),...c.useSafety.getState().points.filter(e=>!t.has(e.id)).map(e=>e.id)],l=`Saved ${B.length} change${1===B.length?'':'s'}.`;D(s?`${l} Sending to every device\u2026`:`${l} (on this device until it connects).`),s&&(0,p.reportTempSave)('temp_units',n,l,D)}}),(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:"tu-save-cancel",label:"Back",accessibilityLabel:"Go back without saving",onPress:()=>w(!1)})]})]}):null,(0,x.jsx)(l.Button,{testID:"tu-save",label:"Save changes",disabled:!B.length||P,accessibilityHint:W,onPress:()=>w(!0),style:{alignSelf:'center',minWidth:200}}),T?(0,x.jsx)(l.T,{testID:"tu-saved",size:15,colour:y.colours.ok,center:!0,accessibilityRole:"text",children:T}):(0,x.jsx)(l.Muted,{style:{textAlign:'center'},children:W})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},l=r(_d[2]),o=r(_d[3]),c=r(_d[4]),d=r(_d[5]),h=r(_d[6]),u=r(_d[7]),y=r(_d[8]),p=r(_d[9]),f=r(_d[10]),x=r(_d[11]);const b=['Downstairs','Upstairs'],k={fridge:'Fridge',freezer:'Freezer'};function v({d:e,problem:t,onChange:s,onArchive:c}){const d=e.name.trim()||'new unit';return(0,x.jsxs)(n.default,{testID:`tu-unit-${e.key}`,style:{gap:8,padding:12,borderRadius:12,borderWidth:1,borderColor:t?y.colours.red:y.colours.border,alignSelf:'stretch'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-name-${e.key}`,accessibilityLabel:`Name of ${d}`,value:e.name,onChangeText:t=>s({...e,name:t}),placeholder:"e.g. Upstairs fridge 5",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:6,children:[['fridge','freezer'].map(t=>(0,x.jsx)(l.Chip,{testID:`tu-kind-${e.key}-${t}`,label:k[t],selected:e.kind===t,accessibilityLabel:`${d}: ${k[t]}${e.kind===t?', selected':''}`,onPress:()=>s((0,u.withKind)(e,t))},t)),b.map(t=>(0,x.jsx)(l.Chip,{testID:`tu-loc-${e.key}-${t.toLowerCase()}`,label:t,selected:e.location.trim().toLowerCase()===t.toLowerCase(),accessibilityLabel:`${d}: location ${t}`,onPress:()=>s({...e,location:t})},t))]}),(0,x.jsxs)(l.Row,{wrap:!0,gap:8,children:[(0,x.jsx)(o.TextInput,{testID:`tu-loc-${e.key}`,accessibilityLabel:`Location of ${d}`,value:e.location,onChangeText:t=>s({...e,location:t}),placeholder:"Location",placeholderTextColor:"#7D776C",style:[l.styles.input,{flexGrow:1,flexBasis:120,minWidth:0,width:40}]}),(0,x.jsxs)(l.Row,{gap:6,style:{flexWrap:'nowrap'},children:[(0,x.jsx)(o.TextInput,{testID:`tu-max-${e.key}`,accessibilityLabel:`Safe limit for ${d}, degrees or colder`,value:e.max,onChangeText:t=>s({...e,max:t}),placeholder:String(u.DEFAULT_MAX[e.kind]),placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[l.styles.input,{width:72,textAlign:'center'}]}),(0,x.jsx)(l.T,{size:14,children:"\xb0C or colder"})]})]}),(0,x.jsx)(o.TextInput,{testID:`tu-due-${e.key}`,accessibilityLabel:`Check times for ${d}, 24 hour, comma separated`,value:e.due,onChangeText:t=>s({...e,due:t}),placeholder:"Check times, e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[l.styles.input,{alignSelf:'stretch',width:'100%'}]}),t?(0,x.jsx)(l.T,{testID:`tu-problem-${e.key}`,size:14,colour:y.colours.red,center:!0,accessibilityRole:"text",children:t}):null,(0,x.jsx)(l.Button,{small:!0,kind:"secondary",testID:`tu-archive-${e.key}`,label:"Archive",accessibilityLabel:`Archive ${d}`,accessibilityHint:"Stops the checks. Its past readings stay in History and the EHO report",onPress:c,style:{alignSelf:'center'}})]})}},1147,[34,102,794,827,1034,891,835,1148,821,1149,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MAX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isUnit",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"dueList",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"dueOk",{enumerable:!0,get:function(){return c}}),e.draftsFrom=function(n){return n.filter(o).map(n=>({key:n.id,id:n.id,name:n.name,kind:n.kind,location:n.location??'',max:null==n.max?'':String(n.max),due:n.due.join(', '),archived:!!n.archived}))},e.withKind=function(n,o){const u=d(n.max),c='fridge'===o?'freezer':'fridge';return{...n,kind:o,max:''===n.max||u===t[c]?String(t[o]):n.max}},e.problemOf=function(n,t,o=()=>!0){if(n.archived)return'';const u=n.name.trim();if(!u)return'Give it a name.';if(!o(u))return'Choose another name.';if(t.some(t=>t.key!==n.key&&!t.archived&&t.name.trim().toLowerCase()===u.toLowerCase()))return'Another unit has this name.';const s=d(n.max);return null==s?'Type the safe limit in \xb0C, for example 5 or -18.':s<-40||s>15?'The safe limit must be between -40 \xb0C and 15 \xb0C.':c(n.due)?'':'Use 24-hour times like 09:00, 16:00.'},e.changesOf=function(t,o){const c=[];for(const s of t){const t=s.name.trim(),f=s.location.trim(),h=d(s.max)??void 0,l=u(s.due),p={name:t,kind:s.kind,location:f||void 0,max:h,due:l,aliases:(0,n.unitAliases)(t,f)},k=s.id?o.find(n=>n.id===s.id):void 0;if(!k){!s.archived&&t&&c.push({key:s.key,text:`Add ${t}`,add:{...p,archived:!1}});continue}if(s.archived!==!!k.archived){c.push(s.archived?{key:s.key,id:k.id,text:`Archive ${k.name} (its readings stay in History and the EHO report)`,patch:{archived:!0,due:[]}}:{key:s.key,id:k.id,text:`Bring back ${t}`,patch:{...p,archived:!1}});continue}if(s.archived)continue;const y=[];t!==k.name&&y.push(`rename to ${t}`),s.kind!==k.kind&&y.push(`make it a ${s.kind}`),(f||'')!==(k.location??'')&&y.push(f?`location ${f}`:'no location'),h!==k.max&&y.push(`${h} \xb0C or colder`),l.join(',')!==[...k.due].sort().join(',')&&y.push(l.length?`due ${l.join(', ')}`:'no due times'),y.length&&c.push({key:s.key,id:k.id,text:`${k.name}: ${y.join(', ')}`,patch:p})}return c};var n=r(_d[0]);const t={fridge:5,freezer:-18},o=n=>'fridge'===n.kind||'freezer'===n.kind,d=n=>{const t=n.trim().replace(',','.').replace(/^[\u2212\u2013]/,'-');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},u=n=>n.split(',').map(n=>n.trim()).filter(Boolean).sort(),c=n=>u(n).every(n=>/^([01]\d|2[0-3]):[0-5]\d$/.test(n))},1148,[1035]); +__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.TempSaveBanner=function({testID:e="temp-save-banner"}){const c=v(),[w,p]=(0,t.useState)(''),y=(0,t.useRef)(''),m=c.refused||c.refusedUnits.length?(0,l.tempNotSavedLine)(c.refused,c.refusedUnits):'';(0,t.useEffect)(()=>{m&&m!==y.current&&(0,r.announce)(`${m} ${b(c.why??'')}.`),y.current=m},[m]);const S=async()=>{p('Saving\u2026'),(0,r.announce)('Saving');const e=await(0,o.saveTempNow)(!0),t=(0,o.tempLogState)(),n=e?`Not saved: ${e}.`:t.refused||t.refusedUnits.length?'Sent again. This clears when the shared log takes it.':'Saved to the shared log.';p(n),(0,r.announce)(n)};if(m)return(0,f.jsxs)(n.default,{testID:e,accessibilityRole:"button",accessibilityLiveRegion:"assertive",accessibilityLabel:`${m} ${b(c.why??'')}.`,onPress:S,style:{alignSelf:'stretch',gap:4,padding:12,borderRadius:12,borderWidth:2,borderColor:u.colours.red,backgroundColor:'#3a1210',alignItems:'center'},children:[(0,f.jsx)(h.T,{testID:`${e}-title`,size:17,weight:"semibold",center:!0,colour:"#FFD2CC",children:m}),c.why?(0,f.jsx)(h.T,{testID:`${e}-why`,size:14,center:!0,colour:"#FFB3AA",children:b(c.why)}):null,w?(0,f.jsx)(h.T,{testID:`${e}-msg`,size:14,center:!0,colour:u.colours.goldLight,children:w}):null]});if(c.waiting>0)return(0,f.jsx)(s.default,{testID:`${e}-waiting`,accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:(0,l.tempWaitingLine)(c.waiting),style:{alignSelf:'stretch',padding:10,borderRadius:12,borderWidth:1,borderColor:u.colours.goldMuted,alignItems:'center'},children:(0,f.jsx)(h.T,{size:15,center:!0,colour:u.colours.goldLight,children:(0,l.tempWaitingLine)(c.waiting)})});return null},_e.reportTempSave=async function(e,t,n,s){const c=await(0,o.waitForTempSave)(e,t),l='saved'===c.state?`${n} Every device shows it now.`:'local'===c.state?`${n} (on this device until it connects).`:'waiting'===c.state?`${n} Not on the shared log yet: it sends by itself when the connection is back.`:`Not saved to the shared log: ${'why'in c?c.why:'it was refused'}. Tap the red banner to try again.`;s(l),(0,r.announce)(l)};var t=_r(d[0]),n=e(_r(d[1])),s=e(_r(d[2])),r=_r(d[3]),o=_r(d[4]),c=_r(d[5]),l=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const b=e=>e?e.charAt(0).toUpperCase()+e.slice(1):e;function v(){const e=(0,l.useTempSaves)(e=>e.notSaved),[n,s]=(0,t.useState)(()=>(0,o.tempLogState)());return(0,t.useEffect)(()=>{const e=()=>s((0,o.tempLogState)()),t=c.mutationQueue.subscribe(e),n=setInterval(e,2e3);return e(),()=>{t(),clearInterval(n)}},[e]),n}},1149,[34,402,102,1125,987,1150,1022,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getSupabase",{enumerable:!0,get:function(){return t.getSupabase}}),Object.defineProperty(e,"setSupabaseClient",{enumerable:!0,get:function(){return t.setSupabaseClient}}),Object.defineProperty(e,"isSupabaseConfigured",{enumerable:!0,get:function(){return n.isSupabaseConfigured}}),Object.defineProperty(e,"REALTIME_TABLES",{enumerable:!0,get:function(){return n.REALTIME_TABLES}}),Object.defineProperty(e,"isOnline",{enumerable:!0,get:function(){return u.isOnline}}),Object.defineProperty(e,"onConnectivity",{enumerable:!0,get:function(){return u.onConnectivity}}),Object.defineProperty(e,"setOnline",{enumerable:!0,get:function(){return u.setOnline}}),Object.defineProperty(e,"cache",{enumerable:!0,get:function(){return c.cache}}),Object.defineProperty(e,"mutationQueue",{enumerable:!0,get:function(){return o.mutationQueue}}),Object.defineProperty(e,"TableRepository",{enumerable:!0,get:function(){return f.TableRepository}}),Object.defineProperty(e,"executeMutation",{enumerable:!0,get:function(){return f.executeMutation}}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return p.VenueRealtime}}),Object.defineProperty(e,"startVenueSync",{enumerable:!0,get:function(){return l.startVenueSync}}),Object.defineProperty(e,"pairDevice",{enumerable:!0,get:function(){return y.pairDevice}}),Object.defineProperty(e,"unpairDevice",{enumerable:!0,get:function(){return y.unpairDevice}}),Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return y.currentDevice}}),Object.defineProperty(e,"signInStaff",{enumerable:!0,get:function(){return y.signInStaff}}),Object.defineProperty(e,"whoami",{enumerable:!0,get:function(){return y.whoami}}),Object.defineProperty(e,"createDeviceToken",{enumerable:!0,get:function(){return y.createDeviceToken}}),Object.defineProperty(e,"useSyncedRows",{enumerable:!0,get:function(){return s.useSyncedRows}}),Object.defineProperty(e,"usePendingWrites",{enumerable:!0,get:function(){return s.usePendingWrites}}),Object.defineProperty(e,"uuid",{enumerable:!0,get:function(){return j.uuid}});var t=r(d[0]),n=r(d[1]),u=r(d[2]),c=r(d[3]),o=r(d[4]),f=r(d[5]),b=r(d[6]);Object.keys(b).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return b[t]}})});var p=r(d[7]),l=r(d[8]),y=r(d[9]),s=r(d[10]),O=r(d[11]);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 j=r(d[12])},1150,[933,976,1011,1019,1014,1017,1151,1152,1153,1154,1155,1156,977]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"venuesRepo",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"rolesRepo",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"staffRepo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"staffPrivateRepo",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"bookingsRepo",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"walkInsRepo",{enumerable:!0,get:function(){return l}}),Object.defineProperty(_e,"blocksRepo",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"tablePlansRepo",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"takeawayOrdersRepo",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"stockCountsRepo",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"stockEventsRepo",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"suppliersRepo",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"supplierOrdersRepo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"recipeCardsRepo",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"rotaShiftsRepo",{enumerable:!0,get:function(){return R}}),Object.defineProperty(_e,"outboxRepo",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"bookings",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"takeawayOrders",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"stock",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"tablePlans",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"recipeCards",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"outbox",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"allRepositories",{enumerable:!0,get:function(){return B}});var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]);const n=new r.TableRepository('venues',{venueColumn:'id'}),o=new r.TableRepository('roles',{orderBy:{column:'name'}}),s=new r.TableRepository('staff',{orderBy:{column:'display_name'}}),u=new r.TableRepository('staff_private',{keyOf:e=>String(e.staff_id),keyColumns:['staff_id'],conflictKey:'staff_id'}),c=new r.TableRepository('bookings',{orderBy:{column:'booking_date'},limit:2e3}),l=new r.TableRepository('walk_ins',{orderBy:{column:'arrived_at'}}),p=new r.TableRepository('blocks',{orderBy:{column:'block_date'}}),b=new r.TableRepository('table_plans'),f=new r.TableRepository('takeaway_orders',{orderBy:{column:'created_at',ascending:!1}}),y=new r.TableRepository('stock_counts',{keyOf:e=>String(e.item),keyColumns:['item'],conflictKey:'venue_id,item'}),m=new r.TableRepository('stock_events',{writeMode:'insert',orderBy:{column:'at',ascending:!1},limit:500}),_=new r.TableRepository('suppliers',{orderBy:{column:'name'}}),w=new r.TableRepository('supplier_orders',{orderBy:{column:'order_date',ascending:!1}}),O=new r.TableRepository('recipe_cards',{orderBy:{column:'dish'}}),R=new r.TableRepository('rota_shifts',{orderBy:{column:'shift_date'}}),k=new r.TableRepository('outbox',{writeMode:'insert',orderBy:{column:'created_at',ascending:!1},limit:200}),P={repo:c,create:(e,t)=>c.create(e,t),setStatus:(e,t,r)=>{const n=(new Date).toISOString();return c.update(e,t,{status:r,...'seated'===r?{seated_at:n}:{},...'finished'===r?{finished_at:n}:{}})},assignTables:(e,t,r)=>c.update(e,t,{table_ids:r}),acknowledgeAllergy:(e,t,r)=>c.update(e,t,{allergy_ack_by:r,allergy_ack_at:(new Date).toISOString()}),decide:(e,t,r,n)=>c.update(e,t,{status:r,decided_by:n,decided_at:(new Date).toISOString()}),refreshFrom:(e,t)=>c.refresh(e,{filter:e=>e.gte('booking_date',t)})},j={repo:f,create:(e,t)=>f.create(e,t),confirm:(e,t,r)=>f.update(e,t,{status:'acknowledged',confirmed_by:r,confirmed_at:(new Date).toISOString()}),setStatus:(e,t,r)=>f.update(e,t,{status:r})},h={counts:y,events:m,async record(t,r){if('crab'===r.item&&!Number.isInteger(r.delta))throw new Error('Crabs are counted in whole units');if(Math.round(2*r.delta)!==2*r.delta)throw new Error('Stock moves in halves at most');const n=await m.create(t,{item:r.item,delta:r.delta,reason:r.reason,by_name:r.by??null,app:r.app??null,undoes:r.undoes??null}),o=e.cache.get('stock_counts',t,r.item);return o&&e.cache.put('stock_counts',t,r.item,{...o,quantity:Number(o.quantity)+r.delta}),n}},v={repo:b,active:e=>b.rows(e).find(e=>e.is_active),save:(e,t,r)=>b.update(e,t.id,r,{version:t.version})},S={repo:O,signOff:(e,t,r)=>O.update(e,t,{signed_off_by:r,signed_off_at:(new Date).toISOString()}),async uploadPhoto(e,r,n,o="image/jpeg"){const s=o.split('/')[1]??'jpg',u=`${e}/${r}-${Date.now()}.${s}`,{error:c}=await(0,t.getSupabase)().storage.from('recipe-photos').upload(u,n,{contentType:o,upsert:!1});if(c)throw c;return await O.update(e,r,{photo_url:u}),u},async photoUrl(e,r=3600){const{data:n}=await(0,t.getSupabase)().storage.from('recipe-photos').createSignedUrl(e,r);return n?.signedUrl??null}},T={repo:k,preview:(e,t)=>k.create(e,{...t,status:'preview'})},B=[n,o,s,u,c,l,p,b,f,y,m,_,w,O,R,k]},1151,[1019,933,1017]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"VenueRealtime",{enumerable:!0,get:function(){return c}});var t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const h=(t,n)=>'stock_counts'===t?`${n.item}`:String(n.id);class c{channel=null;listeners=new Set;status='idle';onReconnect=null;onStatus=null;constructor(t,n=s.REALTIME_TABLES){this.venueId=t,this.tables=n}start(){if(this.channel)return;let t=(0,n.getSupabase)().channel(`venue:${this.venueId}`);for(const n of this.tables)t=t.on('postgres_changes',{event:'*',schema:'public',table:n,filter:`venue_id=eq.${this.venueId}`},t=>this.apply(n,t));this.set('connecting');let s=!1;this.channel=t.subscribe(t=>{'SUBSCRIBED'===t?(s&&this.onReconnect?.(),s=!0,this.set('live')):'CHANNEL_ERROR'===t||'TIMED_OUT'===t?this.set('error'):'CLOSED'===t&&this.set('closed')})}async stop(){this.channel&&(await(0,n.getSupabase)().removeChannel(this.channel),this.channel=null,this.set('closed'))}on(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}set(t){this.status=t,this.onStatus?.(t)}apply(n,s){const c='DELETE'===s.eventType?s.old:s.new,u=h(n,c);'DELETE'===s.eventType?t.cache.remove(n,this.venueId,u):l.mutationQueue.hasPending(n,this.venueId,u)||t.cache.put(n,this.venueId,u,c),this.listeners.forEach(t=>t({table:n,type:s.eventType,row:c}))}}},1152,[1019,933,976,1014]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.startVenueSync=async function(r,l={}){const c=l.tables??o.REALTIME_TABLES,k=[...c.map(t=>u[t]),...l.extra??[]];await Promise.all([s.mutationQueue.load(),...k.map(t=>t.hydrate(r))]);const b=l.bookingsFrom??new Date(Date.now()-48384e5).toISOString().slice(0,10),p=async()=>{await s.mutationQueue.flush(),await Promise.allSettled(k.map(t=>'bookings'===t.table?t.refresh(r,{filter:t=>t.gte('booking_date',b)}):'walk_ins'===t.table?t.refresh(r,{filter:t=>t.gte('walk_date',b)}):t.refresh(r)))},w=new n.VenueRealtime(r,c);w.onReconnect=()=>{p()},w.onStatus=l.onStatus??null,w.start();const _=(0,t.onConnectivity)(t=>{t&&p()});return p().catch(()=>{}),{venueId:r,realtime:w,refresh:p,async stop(){_(),await w.stop()}}};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]);s.mutationQueue.setExecutor(r.executeMutation);const u={bookings:l.bookingsRepo,walk_ins:l.walkInsRepo,blocks:l.blocksRepo,table_plans:l.tablePlansRepo,takeaway_orders:l.takeawayOrdersRepo,stock_counts:l.stockCountsRepo}},1153,[1011,976,1152,1014,1017,1151]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pairDevice=async function(c){const s=(0,t.getSupabase)(),{data:u}=await s.auth.getSession();if(!u.session){const{error:t}=await s.auth.signInAnonymously();if(t)throw t}const{data:w,error:v}=await s.rpc('claim_device',{p_token:c});if(v)throw v;const p=w?.[0];if(!p)throw new Error('Device token was not accepted');const f={venueId:p.venue_id,venueSlug:p.venue_slug,venueName:p.venue_name,canWrite:p.can_write,pairedAt:(new Date).toISOString()};return await n.kv.set(o,f),f},Object.defineProperty(e,"currentDevice",{enumerable:!0,get:function(){return c}}),e.unpairDevice=async function(){await n.kv.remove(o),await(0,t.getSupabase)().auth.signOut()},e.signInStaff=async function(n,o){const{data:c,error:s}=await(0,t.getSupabase)().auth.signInWithPassword({email:n,password:o});if(s)throw s;return c.session},e.whoami=async function(){const{data:n,error:o}=await(0,t.getSupabase)().rpc('whoami');if(o)throw o;return n??[]},e.createDeviceToken=async function(n,o,c=!0){const{data:s,error:u}=await(0,t.getSupabase)().rpc('create_device_token',{p_venue:n,p_label:o,p_can_write:c});if(u)throw u;return s};var t=r(d[0]),n=r(d[1]);const o='device:binding:v1';const c=()=>n.kv.get(o,null)},1154,[933,977]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSyncedRows=function(n,u){const s=(0,t.useState)([])[0];return(0,t.useSyncExternalStore)(t=>u?n.subscribe(u,t):()=>{},()=>u?n.rows(u):s,()=>u?n.rows(u):s)},e.usePendingWrites=function(){const[u,s]=(0,t.useState)(n.mutationQueue.pending.length);return(0,t.useEffect)(()=>(n.mutationQueue.load().then(()=>s(n.mutationQueue.pending.length)),n.mutationQueue.subscribe(()=>s(n.mutationQueue.pending.length))),[]),u};var t=r(d[0]),n=r(d[1])},1155,[34,1014]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueIdForSlug=async function(n){if(o.has(n))return o.get(n);const{data:s}=await(0,t.getSupabase)().from('venues').select('id').eq('slug',n).maybeSingle();s?.id&&o.set(n,s.id);return s?.id??null},e.bookingToRow=function(t){return{id:t.id,ref:t.ref,guest_name:t.name,phone:t.phone??null,email:t.email??null,booking_date:t.date,booking_time:t.time,duration_mins:t.durationMins??null,covers:t.partySize,table_ids:n(t.table),dog:!!t.dog,allergies:t.allergies,notes:t.notes??'',tags:t.tags??[],occasion:t.occasion??null,status:t.status,source:t.source??(t.walkIn?'walk-in':'phone'),security:t.security,deposit_paid:t.depositPaid,seated_at:t.seatedAt??null,finished_at:t.finishedAt??null,allergy_ack_by:t.allergyAck?.by??null,allergy_ack_at:t.allergyAck?.at??null,decided_by:t.decided?.by??null,decided_at:t.decided?.at??null}},e.rowToBooking=function(t,o){const n='declined'===t.status?'cancelled':t.status;return{id:t.id,ref:t.ref??'',restaurantId:o,customerId:t.customer_id,name:t.guest_name,partySize:t.covers,date:t.booking_date,time:s(t.booking_time),table:t.table_ids.join('+')||void 0,allergies:t.allergies??[],notes:t.notes,status:n,security:'deposit'===t.security?'deposit':'none',depositPaid:t.deposit_paid,createdAt:t.created_at,allergyAck:t.allergy_ack_by&&t.allergy_ack_at?{by:t.allergy_ack_by,at:t.allergy_ack_at}:void 0,walkIn:'walk-in'===t.source||void 0,tags:t.tags.length?t.tags:void 0,occasion:t.occasion??void 0,durationMins:t.duration_mins??void 0,dog:t.dog,seatedAt:t.seated_at??void 0,finishedAt:t.finished_at??void 0,phone:t.phone??void 0,email:t.email??void 0,source:['online','phone','in-person','walk-in'].includes(t.source)?t.source:'phone',decided:t.decided_by&&t.decided_at&&('confirmed'===t.status||'declined'===t.status)?{by:t.decided_by,at:t.decided_at,outcome:t.status}:void 0}},e.blockToRow=function(t){return{id:t.id,block_date:t.date,from_time:t.from,to_time:t.to,reason:t.reason??null,note:t.note??null,area_id:t.areaId??null,area_name:t.areaName??null,created_by:t.by}},e.rowToBlock=function(t,o){return{id:t.id,rid:o,date:t.block_date,from:s(t.from_time),to:s(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}},e.rowToShellEvent=function(t,o){return{id:t.id,rid:o,kind:t.item,delta:Number(t.delta),reason:t.reason,by:t.by_name??'',app:t.app??'',at:t.at,undoes:t.undoes??void 0}},e.rowToPlan=function(t){return{planId:t.id,version:t.version,areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures}},e.planToPatch=function(t){return{areas:t.areas,tables:t.tables,joins:t.joins,sections:t.sections,fixtures:t.fixtures??[]}},e.outboxToRow=function(t){const o=/^[0-9a-f-]{36}$/i.test(t.refId);return{channel:t.channel,kind:t.kind,to_address:t.to,to_name:t.toName,subject:t.subject??null,body:t.body,html:t.html??null,ref_type:t.refType,ref_id:o?t.refId:null,ref:t.ref,provider:t.provider}};var t=_r(d[0]);const o=new Map;const n=t=>t?t.split('+').map(t=>t.trim()).filter(Boolean):[],s=t=>t.slice(0,5)},1156,[933]); +__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=h,_e.useVoiceTarget=p,_e.VoiceSlot=function({size:e=56,layer:t=0}){const u=p(),c=(0,n.useRef)(null),l=(0,n.useRef)(y++).current,{width:f,height:h,fontScale:v}=(0,o.default)(),A=()=>{if(t{if(c.current!==e||!s||tu+.5?w.getState().owner===l&&w.setState({rect:null,owner:0}):w.setState({rect:{x:n,y:o,size:s},owner:l})})},W=(0,n.useRef)(A);return W.current=A,(0,n.useLayoutEffect)(()=>{if(u?.on)return S.set(l,{layer:t,measure:()=>W.current()}),()=>{S.delete(l),w.getState().owner===l&&w.setState({rect:null,owner:0}),requestAnimationFrame(b)}},[u?.on,t]),(0,n.useLayoutEffect)(()=>{A();const e=requestAnimationFrame(A);return()=>cancelAnimationFrame(e)},[f,h,v,u?.on]),(0,n.useEffect)(()=>{const e=c.current;if(!u?.on||'undefined'==typeof ResizeObserver||!e?.parentElement)return;const t=new ResizeObserver(A);return t.observe(e.parentElement),e.parentElement.parentElement&&t.observe(e.parentElement.parentElement),()=>t.disconnect()},[u?.on]),(0,n.useEffect)(()=>()=>{w.getState().owner===l&&w.setState({rect:null,owner:0})},[]),(0,n.useEffect)(()=>{u?.on||w.getState().owner!==l||w.setState({rect:null,owner:0})},[u?.on]),u?.on?(0,m.jsx)(s.default,{ref:c,testID:"voice-slot",onLayout:A,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]),m=r(d[8]);const w=(0,u.create)(()=>({rect:null,owner:0}));function h(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=h(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;const S=new Map,E=()=>{let e=-1;return S.forEach(t=>{t.layer>e&&(e=t.layer)}),e};function b(){const e=E();S.forEach(t=>{t.layer===e&&t.measure()})}},1157,[30,34,426,102,846,872,1088,1158,25]); +__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 o}}),Object.defineProperty(_e,"VOICE_ROLE_LABEL",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"useVoiceSettings",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"voiceOn",{enumerable:!0,get:function(){return f}}),_e.micExplainedFor=function(e){try{if('1'===b()?.getItem(s(e)))return!0}catch{}return u.getState().micExplained},_e.setMicExplainedFor=function(e){try{b()?.setItem(s(e),'1')}catch{}u.getState().setMicExplained(!0)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},c=r(d[1]),l=r(d[2]);const o=['owner','manager','staff','chef','display'],p={owner:'Owner (Managers app)',manager:'Managers (Managers app)',staff:'Staff app (full voice assistant, no money or HR)',chef:'Head Chef app',display:'Main Display'},u=(0,c.create)()((0,l.persist)(e=>({enabled:{},micExplained:!1,setEnabled:(n,t,c)=>e(e=>({enabled:{...e.enabled,[n]:{...e.enabled[n]??{},[t]:c}}})),setMicExplained:n=>e({micExplained:n})}),{name:'covercharge-voice-v1',version:4,storage:(0,l.createJSONStorage)(()=>t.default),migrate:(e,n)=>({enabled:n<2?{}:e?.enabled??{},micExplained:!!e?.micExplained}),merge:(e,n)=>({...n,enabled:e?.enabled??n.enabled,micExplained:e?.micExplained??n.micExplained}),partialize:e=>({enabled:e.enabled,micExplained:e.micExplained})})),f=(e,n,t)=>!1!==e[n]?.[t],s=e=>`cc-voice-mic-explained-${e}`,b=()=>{try{return'undefined'!=typeof window?window.localStorage:void 0}catch{return}}},1158,[839,846,849]); +__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()},1159,[1160]); +__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 a}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return n}}),_e.revenueHistory=function(e,n,r=28){const s=[];if(!(0,o.examplesAllowed)())return s;for(let o=r;o>=1;o--){const r=(0,t.addMins)(n,1440*-o),i=!!e.kitchenHours[r.getDay()],d=[1.05,0,0,.6,.7,1,1.2][r.getDay()]*('anchorage'===e.id?1:.6),l=o=>.85+.3*a((0,t.ymd)(r)+o+e.id),u=i?Math.round(24e4*d*l('d')):0,c=i?Math.round(95e3*d*l('t')):0,p=i?Math.round(52e3*d*l('q')):0;s.push({date:r,label:(0,t.niceDate)(r).slice(0,6),byChannel:{'Dine-in':u,Takeaway:c,'Table QR':p},total:u+c+p,covers:i?Math.round(150*d*l('c')):0})}return s},_e.dishStats=function(e){return(0,o.examplesAllowed)()?e.filter(e=>null!=e.price).map(e=>{const t=Math.round(20+260*a(e.id+'s')),o=.24+.22*a(e.id+'c'),n=e.price??0,r=Math.round(n*(1-o));return{item:e,sold:t,revenue:t*n,costPct:o,margin:r,gp:r*t}}):[]},_e.quadrant=function(e,t,o,a){return e>=o?t>=a?'Star':'Plough horse':t>=a?'Puzzle':'Dog'},Object.defineProperty(_e,"QUADRANT_TIP",{enumerable:!0,get:function(){return r}}),_e.crmCustomers=function(){return(0,o.examplesAllowed)()?s.map((e,t)=>{const o=a(e+t);return{id:0===t?'cust-demo':`cr-${t}`,name:`${e} ${i[t]}${0===t?'':' (example)'}`,phone:`07700 900${String(100+7*t).slice(-3)}`,visits:1+Math.round(18*o),lastVisit:`${1+Math.round(27*o)} days ago`,spend:Math.round(3e3+6e4*o),allergies:0===t?['Crustaceans (anaphylaxis)','Mustard']:o>.8?['Gluten (coeliac)']:o<.1?['Peanuts']:[],stamps:0===t?5:Math.round(7*o),optIn:o>.25,channel:n[Math.floor(3*o)%3],birthday:o>.6?`${1+Math.round(27*o)} Nov`:void 0}}):[]},Object.defineProperty(_e,"STOCK",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"stockList",{enumerable:!0,get:function(){return l}}),_e.insights=function(a,n,r,s,i,l,c){const p=[];if(!(0,o.examplesAllowed)())return u(a,n,r,s,i,l,c);const h=new Date(l);h.setDate(h.getDate()+((6-h.getDay()+7)%7||7)),h.setHours(0,0,0,0);const b=(0,e.forecastToday)(a,n,r,s,h),m=Math.round(b.restOfDay.covers/Math.max(1,b.multiplier)),y=Math.max(35,Math.round(100*(b.multiplier-1))+35);p.push({id:'sat',icon:'\ud83d\udcc8',tone:'gold',title:`${(0,t.niceDate)(h)} forecast +${y}%: add 1 server 6\u20139pm`,body:`Example: about ${Math.round(m*(1+y/100))} covers expected vs about ${m} on a usual Saturday (bookings pace + Halloween weekend flag).`,action:{label:'Open rota',tab:'more',sub:'rota'}});const f=(0,e.forecastToday)(a,n,r,s,l),v=d[0],w=Math.ceil((f.restOfDay.covers+2*f.restOfDay.takeaway)*v.perCover);p.push({id:'haddock',icon:'\ud83d\udc1f',tone:'red',title:`Haddock low: ${v.onHand} portions left`,body:`Tonight\u2019s forecast needs about ${w}. Call the supplier before 18:00 or mark the fish supper sold out at ${v.onHand} sold.`,action:{label:'Prep list',tab:'more',sub:'prep'}});const k=s.find(e=>/Burns/.test(e.title));if(k){const e=Math.max(1,Math.round((new Date(k.date).getTime()-l.getTime())/6048e5));p.push({id:'burns',icon:'\ud83e\udd43',tone:'blue',title:`Burns Night in ${e} weeks: open bookings?`,body:'Last year\u2019s equivalent nights sold out about 3 weeks ahead (example). Publish the set menu and push to opted-in regulars.',action:{label:'Plan campaign',tab:'more',sub:'marketing'}})}const M=n.filter(e=>e.date===(0,t.venueYmd)(l)&&'noshow'===e.status).length;p.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:M?`${M} no-show today: deposits for 6+?`:'Deposits for bigger tables (example)',body:'Deposits are set per venue in Settings \u203a Advanced \u203a Deposits. Consider them on Fri/Sat after 19:00.',action:{label:'Bookings',tab:'bookings'}});const C=i.filter(e=>e.stars<=2).length;C&&p.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${C} 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 p.push({id:'commission',icon:'\ud83d\udcb7',tone:'ok',title:'You kept about \xa31,240 in commission this month',body:'Example: \xa34,140 of direct takeaway orders that would have cost about 30% on delivery apps.',action:{label:'Analytics',tab:'more',sub:'analytics'}}),p.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${c} covers so far today`,body:'Lobster special is the top add-on tonight. Suggest it with the scallops (example).'}),p};var e=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]);const a=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.'},s=['Alex','Fiona','Iain','Morag','Callum','Eilidh','Ross','Kirsty','Euan','Shona','Hamish','Isla','Craig','Ailsa','Neil','Catriona'],i=['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}],l=()=>(0,o.examplesAllowed)()?d:[];function u(o,a,n,r,s,i,d){const l=[],u=(0,e.forecastToday)(o,a,n,r,i);u.enough||l.push({id:'history',icon:'\ud83d\udcc5',tone:'gold',title:'Not enough history yet',body:u.suggestions[0]?.replace(/^Not enough history yet\. /,'')??'',action:{label:'Settings \u203a Advanced',tab:'more',sub:'advanced'}});const c=(0,t.ymd)(i),p=a.filter(e=>e.date===c&&'noshow'===e.status).length;p&&l.push({id:'noshow',icon:'\ud83e\ude91',tone:'amber',title:`${p} no-show${1===p?'':'s'} today`,body:'Think about a deposit for larger parties (Settings \u203a Advanced \u203a Deposits).',action:{label:'Bookings',tab:'bookings'}});const h=s.filter(e=>e.stars<=2).length;h&&l.push({id:'reviews',icon:'\ud83d\udcac',tone:'red',title:`${h} low rating${1===h?'':'s'} to read`,body:'Read what they said, reply to say thanks and invite them back.',action:{label:'Reviews',tab:'more',sub:'reviews'}});const b=r.filter(e=>e.date>=c).sort((e,t)=>e.date.localeCompare(t.date))[0];return b&&l.push({id:'event',icon:'\ud83d\udcc5',tone:'blue',title:`Coming up: ${b.title}`,body:`${(0,t.niceDate)(new Date(b.date+'T12:00:00'))}. Check your rota and think about a promo.`,action:{label:'Forecast',tab:'forecast'}}),l.push({id:'covers',icon:'\ud83c\udf7d\ufe0f',tone:'gold',title:`${d} covers so far today`,body:'Seated bookings and walk-ins recorded in CoverCharge today.'}),l}},1160,[1161,858,884]); +__d(function(g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.forecastToday=function(u,c,h,f,p,v){const k=(0,e.venueBusy)(u,c,p),M=(0,a.examplesAllowed)(),b=(0,n.clampWeeks)(u.settings.forecastMinWeeks),w=M?null:v??(0,n.buildHistory)(u.id,c,h,[],p,b),H=M||!!w?.enough,O=(0,r.hoursFor)(u,p),S=[],C=(0,s.ymd)(p);let I=1;for(const e of f.filter(e=>e.date===C&&(null===e.restaurantId||e.restaurantId===u.id)))S.push(e.title.replace(/\s*\(substitute day\)/gi,'')),!1!==e.busier&&(I*='bank-holiday'===e.kind?1.25:'event'===e.kind?1.15:1.1);if(!O)return{busy:k,open:!1,hours:[],restOfDay:{covers:0,low:0,high:0,takeaway:0,booked:0},flags:S,suggestions:['Kitchen closed today (per listed hours).'],multiplier:I,example:M,enough:H,minWeeks:b};const x=M?o.EXAMPLE_HISTORY[u.id]??o.EXAMPLE_HISTORY.default:H&&w?w:{covers:{},takeaway:{}},E=p.getDay(),N=l(u,p),$=(0,t.lastFoodOn)(u,C);let _=O.close.getMinutes()>0?O.close.getHours():O.close.getHours()-1;if($){const[e,t]=$.time.split(':').map(Number);_=Math.min(_,t>0?e:e-1),'kitchen closes'!==$.reason&&S.push(`Last food orders ${$.time} (${$.reason})`)}const P=c.filter(e=>e.restaurantId===u.id&&e.date===C&&['confirmed','seated','finished'].includes(e.status)),T=P.filter(e=>!e.walkIn&&'finished'!==e.status).map(e=>Number(e.time.slice(0,2))),A=Math.min(N[0],O.open.getHours(),...T),L=Math.max(N[1],_,...T),R=[];for(let e=A;e<=L;e++){const t=e>=O.open.getHours()&&e<=_,o=x.covers[E]?.[e]??0,r=x.takeaway[E]?.[e]??0,a=P.filter(t=>!t.walkIn&&'finished'!==t.status&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),n=P.filter(t=>t.walkIn&&['seated','finished'].includes(t.status)&&Number(t.time.slice(0,2))===e).reduce((e,t)=>e+t.partySize,0),i=t?Math.round(o*u.settings.walkInShare*I):0,c=H&&t?Math.max(0,Math.round(o*I*(1-u.settings.walkInShare))-a):0,l=Math.max(n,i)+c,f=a+l,p=h.filter(t=>t.restaurantId===u.id&&'takeaway'===t.type&&'cancelled'!==t.status&&t.slotTime&&new Date(t.slotTime).getHours()===e&&(0,s.ymd)(new Date(t.slotTime))===C).length,y=t?Math.max(p,Math.round(r*I)):p;R.push({hour:e,booked:a,walkIns:l,covers:f,coversLow:H?Math.round(.8*f):f,coversHigh:H?Math.round(1.2*f):f,takeawayPlaced:p,takeaway:y,historicalCovers:o})}const D=y(u,E);if(H&&D){const e=D-R.reduce((e,t)=>e+t.covers,0),t=R.filter(e=>e.hour>=O.open.getHours()&&e.hour<=_);if(e>0&&t.length){const o=t.map(e=>e.historicalCovers),r=i(e,o.reduce((e,t)=>e+t,0)>0?o:t.map(()=>1));t.forEach((e,t)=>{const o=r[t];o&&(e.floorAdded=o,e.walkIns+=o,e.covers+=o,e.coversHigh=Math.max(e.coversHigh,Math.round(1.2*e.covers)))})}const o=R.reduce((e,t)=>e+t.coversLow,0);if(oMath.max(1,e.covers)));t.forEach((t,o)=>{t.coversLow=Math.min(t.covers,t.coversLow+e[o])})}}const j=p.getHours()+(p.getMinutes()>=30?1:0),W=R.filter(e=>e.hour>=j),F=W[0],B=e=>W.reduce((t,o)=>t+e(o),0),G={covers:B(e=>e.covers),low:B(e=>e.coversLow),high:B(e=>e.coversHigh),takeaway:B(e=>e.takeaway),booked:B(e=>e.booked)},z=[],V=u.settings.capacityPerHour,X=W.reduce((e,t)=>!e||t.covers>e.covers?t:e,void 0);X&&X.covers>=.85*V&&z.push(`Dining room near capacity around ${String(X.hour).padStart(2,'0')}:00 (about ${X.covers} of ${V} covers) \u2014 consider pausing or capping takeaway slots then.`);const Y=W.find(e=>e.historicalCovers>0&&e.covers>1.1*e.historicalCovers);Y&&z.push(`Busier than a usual ${['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][E]} from ${String(Y.hour).padStart(2,'0')}:00 \u2014 consider one more on the floor.`);G.takeaway>=10&&z.push(`About ${G.takeaway} takeaway orders expected \u2014 prep extra haddock and chips.`);H||z.unshift(`Not enough history yet. ${(0,a.notEnoughTip)(b)}`);z.length||z.push('Looks like a normal service \u2014 no action suggested.');return{busy:k,open:!0,nextHour:F,hours:R,restOfDay:G,flags:S,suggestions:z,multiplier:I,example:M,enough:H,minWeeks:b,minCovers:D??void 0}},_e.spread=i,Object.defineProperty(_e,"ANCHORAGE_FORECAST_HOURS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"forecastHoursOf",{enumerable:!0,get:function(){return c}}),_e.forecastWindow=l,Object.defineProperty(_e,"ANCHORAGE_MIN_COVERS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"MIN_COVERS_NOTE",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"minCoversOf",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"minCoversOn",{enumerable:!0,get:function(){return y}}),_e.coversRange=function(e,t,o=!0){const r=Math.min(e,t),s=Math.max(e,t),a=r===s?String(r):`${r} to ${s}`;return o?`${a} ${1===s?'Cover':'Covers'}`:a};var e=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=_r(d[4]),a=_r(d[5]),n=_r(d[6]);function i(e,t){const o=t.reduce((e,t)=>e+t,0)||1,r=t.map(t=>e*t/o),s=r.map(Math.floor);let a=e-s.reduce((e,t)=>e+t,0);return r.map((e,t)=>[e-Math.floor(e),t]).sort((e,t)=>t[0]-e[0]).forEach(([,e])=>{a>0&&(s[e]++,a--)}),s}const u={0:['12:00','22:00'],1:null,2:null,3:['12:00','22:00'],4:['12:00','22:00'],5:['12:00','22:00'],6:['12:00','22:00']},c=e=>e.settings.forecastHours??('anchorage'===e.id?u:{});function l(e,t){const o=(0,r.hoursFor)(e,t),s=o.close.getMinutes()>0?o.close.getHours():o.close.getHours()-1,a=c(e)[t.getDay()];if(!a)return[o.open.getHours(),s];const[n]=a[0].split(':').map(Number),[i,u]=a[1].split(':').map(Number);return[Math.min(n,o.open.getHours()),Math.max(u>0?i:i-1,s)]}const h={0:50,6:50},f='Gordon, 4 Nov 2026',p=e=>e.settings.minCoversByDay??('anchorage'===e.id?h:{}),y=(e,t)=>{const o=p(e)[t];return o&&o>0?Math.round(o):null}},1161,[1162,877,1163,878,858,884,1164]); +__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.venueBusy=function(n,s,a){const d=(0,t.ymd)(new Date(a.getTime()-48384e5)),r=(0,t.ymd)(a),u=n.settings.busyLearningSince,o=u&&/^\d{4}-\d{2}-\d{2}$/.test(u)&&u>d?u:d,l=new Map,y=new Set,c=new Set,h=new Set;for(const a of s){if(h.has(a.id)||a.restaurantId!==n.id||a.date=r||!['confirmed','seated','finished'].includes(a.status)||!Number.isFinite(a.partySize)||a.partySize<=0)continue;h.add(a.id),y.add(a.date);const s=new Date(a.date+'T12:00:00');s.setDate(s.getDate()-(s.getDay()+6)%7),c.add((0,t.ymd)(s));const d=a.date+'T'+a.time.slice(0,2);l.set(d,(l.get(d)??0)+a.partySize)}const w=[...l.values()].sort((t,n)=>t-n),f=[...y].sort(),M=(f.length?Math.round((new Date(r+'T12:00:00').getTime()-new Date(f[0]+'T12:00:00').getTime())/864e5):0)>=28&&c.size>=4&&y.size>=16&&w.length>=40,b=n.settings.busyCoversPerHour,v=Number.isFinite(b)&&b>=1?Math.round(b):30,S=M&&!1!==n.settings.busyLearning,z=S?Math.max(1,Math.ceil(w[Math.ceil(.85*w.length)-1])):v,D=Math.max(1,Math.ceil(z/2));return{busy:z,steady:D,learned:S,weeks:c.size,enough:M,words:`Busy level: ${z} Covers an hour (${S?`learned from your last ${c.size} weeks`:null!=b?'set by you':'starting level'})`}},e.hourlyBand=function(t,n){return t>=n?'Busy':t>=Math.ceil(n/2)?'Steady':'Quiet'};var t=_r(_d[0])},1162,[858]); +__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'},1163,[]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEFAULT_MIN_WEEKS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"clampWeeks",{enumerable:!0,get:function(){return o}}),e.buildHistory=function(o,a,c,u,d,f=n){const l=(0,t.ymd)(d),y=(0,t.ymd)(new Date(d.getTime()-48384e5)),h=t=>t>=y&&tt.rid===o&&h(t.date));for(const t of k)D.add(t.date);const T=[...D].sort(),w=T.length?s(T[0],l):0,j=w>=7*f&&T.length>=2*f,O=t=>{const n={},o={};for(const t of T){const n=new Date(t+'T12:00:00').getDay();o[n]=(o[n]??0)+1}for(const[o,s]of Object.entries(t)){const t=new Date(o+'T12:00:00').getDay();n[t]??={};for(const[o,a]of Object.entries(s))n[t][Number(o)]=(n[t][Number(o)]??0)+a}for(const t of Object.keys(n))for(const s of Object.keys(n[+t]))n[+t][+s]=n[+t][+s]/(o[+t]||1);return n},M=Array.from({length:7},()=>[]);for(const t of k)'number'==typeof t.takings&&t.takings>0&&M[new Date(t.date+'T12:00:00').getDay()].push(Math.round(100*t.takings));const N=M.map(t=>t.length?Math.round(t.reduce((t,n)=>t+n,0)/t.length):null),_=k.filter(t=>'number'==typeof t.takings&&t.takings>0),E=(_.length?s(_.map(t=>t.date).sort()[0],l):0)>=7*f&&_.length>=2*f;return{covers:O(b),takeaway:O(p),days:T.length,spanDays:w,enough:j,minWeeks:f,takingsByDay:N,cashUps:_.length,salesEnough:E}};var t=r(_d[0]);const n=2,o=t=>{const o=Math.round(Number(t));return Number.isFinite(o)&&o>=1&&o<=8?o:n},s=(t,n)=>Math.round((new Date(n+'T12:00:00').getTime()-new Date(t+'T12:00:00').getTime())/864e5)},1164,[858]); +__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 x}}),_e.useChef=C,Object.defineProperty(_e,"isLow",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"stockValue",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"within7",{enumerable:!0,get:function(){return v}}),_e.useWeek=function(){const{k:e,c:r,now:t}=C(6e4),o=e.waste.filter(e=>v(e.at,t)).reduce((e,r)=>e+r.cost,0),n=e.stockTakes[0],s=n?n.lines.reduce((e,r)=>e+(r.expected-r.counted)*r.cost,0):0;return{...(0,b.weekGp)(r,o,s),wasteWeek:o,variance:Math.round(s)}},_e.useForecast=function(){const{r:e,rid:r,now:t}=C(6e4),o=(0,i.useBookings)(r),n=(0,i.useOrders)(r),s=(0,i.useEvents)(r),d=(0,u.useRealHistory)(r,t),c=(0,l.forecastToday)(e,o,n,s,t,d??void 0),f=c.hours.reduce((e,r)=>e+r.covers,0),b=c.hours.reduce((e,r)=>e+r.booked,0),p=c.hours.reduce((e,r)=>e+r.historicalCovers,0),y=c.enough&&p?Math.round((f-p)/p*100):0,w=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'][(0,h.weekday)(t)],x=c.enough?`${w} ${y>=0?'+':''}${y}%${c.example?' (example figures)':''}`:'Not enough history yet';return{f:c,covers:f,booked:b,typical:p,pct:y,day:w,label:x,enough:c.enough,example:c.example}},_e.Tile=function({label:e,value:r,sub:t,tone:o,onPress:s,testID:i}){const d='red'===o?f.colours.red:'amber'===o?f.colours.amber:'ok'===o?f.colours.ok:f.colours.text;return(0,w.jsxs)(n.default,{testID:i,accessibilityRole:s?'button':void 0,accessibilityLabel:`${e}: ${r}`,onPress:s,style:({pressed:e})=>({flexGrow:1,flexBasis:200,minWidth:200,maxWidth:'100%',padding:12,borderRadius:14,borderWidth:1,borderColor:'red'===o?f.colours.red:f.colours.border,backgroundColor:e?'#1d1a14':f.colours.surface,gap:2}),children:[(0,w.jsx)(c.Muted,{children:e}),(0,w.jsx)(c.T,{size:22,weight:"bold",colour:d,children:r}),t?(0,w.jsx)(c.T,{size:12,colour:f.colours.muted,children:t}):null]})},_e.Seg=function({value:e,options:r,onChange:t}){return(0,w.jsx)(c.Row,{wrap:!0,gap:6,children:r.map(r=>(0,w.jsx)(n.default,{accessibilityRole:"tab",accessibilityState:{selected:e===r.id},accessibilityLabel:r.label,onPress:()=>t(r.id),style:{paddingHorizontal:12,paddingVertical:7,minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center',borderRadius:999,borderWidth:1,borderColor:e===r.id?f.colours.gold:f.colours.border,backgroundColor:e===r.id?f.colours.goldTint:'transparent'},children:(0,w.jsx)(c.T,{size:13,weight:e===r.id?'semibold':'regular',colour:e===r.id?f.colours.goldLight:f.colours.text,children:r.label})},r.id))})},_e.Bar=function({pct:e,colour:r=f.colours.gold}){return(0,w.jsx)(s.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.surface2,overflow:'hidden'},children:(0,w.jsx)(s.default,{style:{width:`${Math.max(0,Math.min(100,e))}%`,height:6,backgroundColor:r}})})},Object.defineProperty(_e,"pct1",{enumerable:!0,get:function(){return S}});var r=_r(_d[0]),t=e(_r(_d[1])),o=_r(_d[2]),n=e(_r(_d[3])),s=e(_r(_d[4])),i=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),f=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),w=_r(_d[15]);const x=y.ROSTER.find(e=>'chef'===e.app)?.id??'';function C(e=3e4){const n=(0,d.useOwner)(e=>e.site),s=(0,i.useRestaurant)(n),u=(0,d.useOwner)(e=>e.staff),l=u.find(e=>e.id===x)?.name??'Head Chef',c=(0,i.useNow)(e),f=(0,i.useAllMenu)(n),h=(0,p.useKitchen)(),y=t.default.useMemo(()=>{const e=r.LIVE_HEAD_CHEF?{...h,...(0,p.stripKitchenExamples)(h)}:h,t=e.ingredients.filter(e=>(0,o.chefCanSee)(n,e)),s=new Set(e.ingredients.filter(e=>!(0,o.chefCanSee)(n,e)).map(e=>e.id));return{...e,ingredients:t,temps:e.temps.filter(e=>(0,o.chefCanSee)(n,e)),waste:e.waste.filter(e=>(0,o.chefCanSee)(n,e)&&!s.has(e.ing||'')),deliveries:e.deliveries.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))})),orders:e.orders.filter(e=>(0,o.chefCanSee)(n,e)).map(e=>({...e,lines:e.lines.filter(e=>!s.has(e.ing))}))}},[h,n]),w=(0,b.costings)(f,y.recipes,y.ingredients,y.targetGp);return{rid:n,r:s,me:l,now:c,menu:f,k:y,c:w}}const k=(e,r)=>e>0&&e<.5*r,j=e=>Math.round(e.reduce((e,r)=>e+r.onHand*r.cost,0)),v=(e,r)=>r.getTime()-new Date(e).getTime()<6048e5;const S=e=>`${e.toFixed(1)}%`},1165,[978,34,835,402,102,874,891,1166,1161,794,821,1088,1159,1033,15,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useRealHistory=function(e,t){const o=(0,c.useExamples)(),n=(0,r.useBookings)(e),l=(0,r.useOrders)(e),f=(0,u.useCashUp)(e=>e.cashUps),y=(0,k.clampWeeks)((0,h.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings.forecastMinWeeks)),b=t.toDateString();return(0,s.useMemo)(()=>o?null:(0,k.buildHistory)(e,n,l,f.map(e=>({rid:e.rid,date:e.date,takings:(0,p.takings)(e.vals)})),t,y),[o,e,n,l,f,y,b])},Object.defineProperty(_e,"ExampleBadge",{enumerable:!0,get:function(){return b}}),_e.NotEnoughHistory=function({weeks:e,booked:s,what:t="Forecasts",testID:r="not-enough-history"}){return(0,y.jsx)(n.Card,{children:(0,y.jsxs)(o.default,{testID:r,style:{gap:6},children:[(0,y.jsx)(n.T,{weight:"semibold",colour:f.colours.gold,children:"Not enough history yet"}),(0,y.jsx)(n.Muted,{children:'Forecasts'===t?(0,l.notEnoughTip)(e):`${t} start once CoverCharge has ${1===e?'1 week':`${e} weeks`} of your bookings and cash-ups.`}),s?(0,y.jsx)(o.default,{testID:`${r}-booked`,children:(0,y.jsxs)(n.T,{children:["Booked so far: ",s," Covers"]})}):null,(0,y.jsx)(n.Muted,{children:"Tip: upload or add your bookings and do the cash up each night. Managers can change how much history is needed in Settings \u203a Advanced."})]})})};var e,s=_r(d[0]),t=_r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=_r(d[2]),r=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),p=_r(d[8]),k=_r(d[9]),f=_r(d[10]),y=_r(d[11]);const b=()=>(0,y.jsx)(n.Badge,{kind:"amber",label:l.EXAMPLE_LABEL.toUpperCase()})},1166,[34,102,794,874,1039,884,1167,831,13,1164,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useExamples",{enumerable:!0,get:function(){return l}});var t=r(d[0]),n=r(d[1]);const l=()=>(0,t.useSyncExternalStore)(n.onDataModeChange,n.examplesAllowed,n.examplesAllowed)},1167,[34,884]); +__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:o}=(0,c.useChef)(),d=(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:()=>d(o.targetGp-1)}),(0,h.jsxs)(n.T,{size:22,weight:"bold",colour:r.colours.gold,children:[o.targetGp,"%"]}),(0,h.jsx)(n.Button,{small:!0,kind:"secondary",label:"+",accessibilityLabel:"Raise target",onPress:()=>d(o.targetGp+1)})]})}),(0,h.jsx)(c.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)(w,{})]})};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]),o=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),h=_r(_d[10]);function u(){const{c:e,k:t}=(0,c.useChef)(),[l,r]=(0,s.useState)(null),o=e.filter(e=>e.below),d=[...e].sort((e,s)=>e.gp-s.gp),a=e.find(e=>e.item.id===l);return e.length?(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."}),o.length?(0,h.jsxs)(n.Banner,{kind:"danger",title:`${o.length} of ${e.length} dishes below ${t.targetGp}%`,children:[o.slice(0,6).map(e=>e.item.name).join(', '),o.length>6?'\u2026':'']}):(0,h.jsx)(n.Banner,{kind:"success",title:"All costed dishes on target"}),d.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})]}):(0,h.jsx)(n.Muted,{children:"No costed dishes yet. Add your real recipes and ingredient costs to see GP."})}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.ok,children:(0,c.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,d.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 o='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-o))/1e3))}),(0,h.jsx)(n.T,{size:13,style:{width:64,textAlign:'center'},children:(0,d.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+o))/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.ok,children:(0,c.pct1)(e.gp)})]}),(0,h.jsxs)(n.Banner,{kind:e.below?'warn':'info',title:`Price that hits ${e.target}%: ${(0,l.gbp)((0,d.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 CoverCharge for Managers (Menu & allergens)."]})]})]})}function j(){const{menu:e,k:s}=(0,c.useChef)(),t=(0,d.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,c.pct1)(e.before)," \u2192 "]}),(0,h.jsx)(n.T,{size:13,weight:"semibold",colour:e.below?r.colours.red:r.colours.ok,children:(0,c.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,c.useChef)(),s=(0,c.useWeek)();return s.sales?(0,h.jsxs)(i.default,{style:{gap:10},children:[(0,h.jsxs)(n.Row,{wrap:!0,gap:10,children:[(0,h.jsx)(c.Tile,{label:"Theoretical GP (recipes \xd7 sales)",value:(0,c.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),d={Star:[],'Plough horse':[],Puzzle:[],Dog:[]};return s.forEach(e=>d[(0,o.quadrant)(e.soldWeek,e.cashGp,t,r)].push(e)),(0,h.jsxs)(i.default,{style:{gap:10},children:[s.length?(0,h.jsx)(n.Muted,{children:"Popularity (sold per week) against cash GP per dish, using the live menu from CoverCharge for Managers. Example sales figures."}):(0,h.jsx)(n.Muted,{children:"Needs dish sales figures, which CoverCharge doesn't have on a real venue yet (no till link). Nothing is guessed."}),Object.keys(d).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?'\u2754 Puzzles':'\ud83d\udc15 Dogs'}),(0,h.jsx)(n.Badge,{kind:"gold",label:`${d[e].length}`})]}),(0,h.jsx)(n.Muted,{children:o.QUADRANT_TIP[e]}),d[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,c.pct1)(e.gp)]})]},e.item.id))]},e))]})}},1168,[34,402,102,794,867,821,1160,1159,1165,1033,25]); +__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.ChefForecast=function({openPrep:e}){const{r:f,rid:y,now:b}=(0,u.useChef)(6e4),x=(0,l.useBookings)(y),p=(0,l.useOrders)(y),j=(0,l.useEvents)(y),k=(0,a.useRealHistory)(y,b),w=(0,d.ymd)(b),[T,$]=(0,o.useState)(7),{covers:v,enough:C,booked:D,pct:I,day:A,example:L}=(0,u.useForecast)(),M=0===I?`about a usual ${A}`:`${Math.abs(I)}% ${I>0?'busier':'quieter'} than a usual ${A}`,z=(0,o.useMemo)(()=>Array.from({length:T},(e,o)=>{const s=0===o?b:(0,d.addMins)((0,d.parseYmd)(w),1440*o),t=(0,i.forecastToday)(f,x,p,j,s,k??void 0);return{d:s,f:t,booked:t.hours.reduce((e,o)=>e+o.booked,0),covers:t.hours.reduce((e,o)=>e+o.covers,0)}}),[f,x,p,j,w,T,k,b.getTime()/6e5|0]),B=z[0].f,R=z.map(e=>({key:(0,d.ymd)(e.d),label:(0,d.dayShort)(e.d),spoken:(0,d.dayLong)(e.d),value:e.f.open?C?e.covers:e.booked:0,open:!!e.f.open}));return(0,h.jsxs)(t.default,{style:{gap:12},testID:"chef-forecast",children:[(0,h.jsx)(r.Muted,{center:!0,testID:"chef-forecast-busy",children:B.busy.words}),C?null:(0,h.jsx)(a.NotEnoughHistory,{weeks:B.minWeeks,booked:D}),(0,h.jsxs)(r.Card,{children:[(0,h.jsxs)(t.default,{testID:"forecast-week",style:{flexDirection:'row',justifyContent:'center',alignItems:'center',gap:8,flexWrap:'wrap'},children:[(0,h.jsxs)(r.T,{center:!0,weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:[7===T?'This week':`Next ${T} days`," \xb7 ",C?'forecast covers':'booked covers']}),C?B.example?(0,h.jsx)(a.ExampleBadge,{}):(0,h.jsx)(r.Badge,{kind:"amber",label:"ESTIMATE"}):null]}),(0,h.jsx)(r.Row,{gap:4,style:{justifyContent:'center'},children:[7,14].map(e=>(0,h.jsx)(r.Chip,{label:`${e}d`,accessibilityLabel:`Next ${e} days`,selected:T===e,onPress:()=>$(e),testID:`chef-forecast-range-${e}`},e))}),(0,h.jsx)(c.DaysLineGraph,{days:R,titleSpoken:`${C?'Forecast':'Booked'} covers for the next ${T} days`})]}),(0,h.jsxs)(r.Card,{children:[(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,accessibilityRole:"header",children:"Covers per day"}),(0,h.jsxs)(t.default,{testID:"chef-forecast-days",children:[(0,h.jsxs)(t.default,{style:{flexDirection:'row',paddingVertical:6,borderBottomWidth:1,borderColor:n.colours.hairline},children:[(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{flex:1,textAlign:'left'},children:"Day"}),(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:72,textAlign:'right'},children:"Booked"}),C?(0,h.jsx)(r.T,{size:12,weight:"semibold",colour:n.colours.muted,style:{width:84,textAlign:'right'},children:"Forecast"}):null]}),z.map((e,o)=>{const s=0===o;return(0,h.jsxs)(t.default,{testID:`chef-forecast-day-${(0,d.ymd)(e.d)}`,accessible:!0,accessibilityLabel:e.f.open?`${(0,d.dayLong)(e.d)}: ${e.booked} booked${C?`, about ${e.covers} forecast`:''}`:`${(0,d.dayLong)(e.d)}: closed`,style:{flexDirection:'row',alignItems:'center',minHeight:40,borderBottomWidth:o({minHeight:48,borderRadius:12,borderWidth:1.5,borderColor:n.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:e?n.colours.goldTint:'transparent'}),children:(0,h.jsx)(r.T,{weight:"semibold",colour:n.colours.gold,children:"Open prep list \u203a"})})]})]})};var o=_r(_d[0]),s=e(_r(_d[1])),t=e(_r(_d[2])),r=_r(_d[3]),l=_r(_d[4]),i=_r(_d[5]),d=_r(_d[6]),n=_r(_d[7]),c=_r(_d[8]),a=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11])},1169,[34,402,102,794,874,1161,858,821,1170,1166,1165,25]); +__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.CountUp=function({value:e,format:t=e=>String(Math.round(e)),size:i=26,colour:r=d.colours.text}){const n=(0,l.useRef)(new o.default.Value(0)).current,[a,c]=(0,l.useState)(0);return(0,l.useEffect)(()=>{const t=n.addListener(({value:e})=>c(e));return o.default.timing(n,{toValue:e,duration:900,easing:s.default.out(s.default.cubic),useNativeDriver:!1}).start(),()=>n.removeListener(t)},[e]),(0,x.jsx)(u.T,{size:i,weight:"bold",colour:r,children:t(a)})},_e.FadeIn=function({children:e,delay:t=0,style:i}){const r=(0,l.useRef)(new o.default.Value(0)).current;return(0,l.useEffect)(()=>{o.default.timing(r,{toValue:1,duration:450,delay:t,easing:s.default.out(s.default.quad),useNativeDriver:!0}).start()},[]),(0,x.jsx)(o.default.View,{style:[{opacity:r,transform:[{translateY:r.interpolate({inputRange:[0,1],outputRange:[12,0]})}]},i],children:e})},_e.Gauge=function({pct:e,label:t,sub:r,size:c=220}){const h=(0,l.useRef)(new o.default.Value(0)).current,[f,y]=(0,l.useState)(0);(0,l.useEffect)(()=>{const t=h.addListener(({value:e})=>y(e));return o.default.timing(h,{toValue:Math.min(1.2,Math.max(0,e)),duration:1200,easing:s.default.out(s.default.back(1.2)),useNativeDriver:!1}).start(),()=>h.removeListener(t)},[e]);const p=c,v=.62*c,j=p/2,b=v-8,k=p/2-16,M=e=>Math.PI*(1-Math.min(1.2,Math.max(0,e))/1.2),S=(e,t=k)=>[j+t*Math.cos(M(e)),b-t*Math.sin(M(e))],w=(e,t)=>{const[l,o]=S(e),[s,i]=S(t);return`M ${l} ${o} A ${k} ${k} 0 0 1 ${s} ${i}`},$=[[0,.5,d.colours.muted],[.5,1,d.colours.gold],[1,1.2,d.colours.amber]],[A,L]=S(f,k-18);return(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${t}. ${r??''}`,style:{alignItems:'center'},children:[(0,x.jsxs)(a.default,{accessible:!1,width:p,height:v,children:[(0,x.jsx)(n.Path,{d:w(0,1.2),stroke:d.colours.surface2,strokeWidth:18,fill:"none"}),$.map(([e,t,l])=>(0,x.jsx)(n.Path,{d:w(e+.005,t-.005),stroke:l,strokeOpacity:.85,strokeWidth:14,fill:"none"},l)),(0,x.jsx)(n.Line,{x1:j,y1:b,x2:A,y2:L,stroke:d.colours.text,strokeWidth:4,strokeLinecap:"round"}),(0,x.jsx)(n.Circle,{cx:j,cy:b,r:8,fill:d.colours.gold})]}),(0,x.jsx)(u.T,{size:22,weight:"bold",colour:d.colours.gold,style:{marginTop:-4},children:t}),r?(0,x.jsx)(u.T,{size:13,colour:d.colours.muted,center:!0,children:r}):null]})},_e.LineChart=function({series:e,labels:l,width:o,height:s=140,colours:i=[d.colours.gold,d.colours.blue]}){const r=Math.max(1,...e.flat()),u=Math.max(1,l.length-1),c=e=>8+e/u*(o-16),h=e=>s-18-e/r*(s-30);return(0,x.jsxs)(a.default,{width:o,height:s,children:[[.25,.5,.75,1].map(e=>(0,x.jsx)(n.Line,{x1:8,x2:o-8,y1:h(r*e),y2:h(r*e),stroke:d.colours.border,strokeWidth:1},e)),e.map((e,t)=>(0,x.jsx)(n.Polyline,{points:e.map((e,t)=>`${c(t)},${h(e)}`).join(' '),fill:"none",stroke:i[t],strokeWidth:2.5},t)),l.map((e,o)=>o%Math.ceil(l.length/7)===0?(0,x.jsx)(n.Text,{x:c(o),y:s-8,fill:d.colours.muted,fontSize:(0,t.soutersFont)(10),textAnchor:"middle",children:e},o):null)]})},_e.Donut=function({parts:e,size:l=130,centre:o}){const s=Math.max(1,e.reduce((e,t)=>e+t.value,0)),i=l/2-12,r=2*Math.PI*i;let u=0;return(0,x.jsxs)(a.default,{width:l,height:l,children:[(0,x.jsx)(n.G,{rotation:-90,origin:`${l/2}, ${l/2}`,children:e.map((e,t)=>{const o=e.value/s*r,a=(0,x.jsx)(n.Circle,{cx:l/2,cy:l/2,r:i,stroke:e.colour,strokeWidth:18,fill:"none",strokeDasharray:`${o} ${r-o}`,strokeDashoffset:-u},t);return u+=o,a})}),o?(0,x.jsx)(n.Text,{x:l/2,y:l/2+5,fill:d.colours.text,fontSize:(0,t.soutersFont)(15),fontWeight:"bold",textAnchor:"middle",children:o}):null]})},_e.Scatter=function({points:e,width:l,height:o=240,xMid:s,yMid:i}){const r=1.08*Math.max(1,...e.map(e=>e.x)),u=1.08*Math.max(1,...e.map(e=>e.y)),c=e=>10+e/r*(l-20),h=e=>o-10-e/u*(o-20);return(0,x.jsxs)(a.default,{width:l,height:o,children:[(0,x.jsx)(n.Rect,{x:0,y:0,width:l,height:o,fill:d.colours.surface2,rx:10}),(0,x.jsx)(n.Line,{x1:c(s),x2:c(s),y1:6,y2:o-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Line,{y1:h(i),y2:h(i),x1:6,x2:l-6,stroke:d.colours.border,strokeDasharray:"4 4"}),(0,x.jsx)(n.Text,{x:l-12,y:18,fill:d.colours.ok,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"STARS"}),(0,x.jsx)(n.Text,{x:14,y:18,fill:d.colours.blue,fontSize:(0,t.soutersFont)(11),children:"PUZZLES"}),(0,x.jsx)(n.Text,{x:l-12,y:o-14,fill:d.colours.amber,fontSize:(0,t.soutersFont)(11),textAnchor:"end",children:"PLOUGH HORSES"}),(0,x.jsx)(n.Text,{x:14,y:o-14,fill:d.colours.red,fontSize:(0,t.soutersFont)(11),children:"DOGS"}),e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:c(e.x),cy:h(e.y),r:6,fill:e.colour,fillOpacity:.9},t))]})},_e.DaysLineGraph=function({days:e,height:o=150,titleSpoken:s}){const[f,y]=(0,l.useState)(0),p=Math.max(48,o-h.AXIS_BAND),v=Math.max(10,f-28-8),j=Math.max(10,p-16-6),b=Math.max(1,...e.map(e=>e.value)),k=t=>28+(e.length<=1?v/2:t/Math.max(1,e.length-1)*v),M=e=>16+j-e/(1.15*b)*j,S=e.map((e,t)=>`${t?'L':'M'}${k(t).toFixed(1)},${M(e.value).toFixed(1)}`).join(' '),{fontScale:w}=(0,r.default)(),[$,A]=(0,l.useState)(0),L=$>0?$/Math.max(1,(0,h.dayLabelWidth)('Wed')-4):0,D=Math.max((w||1)*((0,t.soutersFont)(h.AXIS_FONT)/h.AXIS_FONT),L,1),T=f?(0,h.daysAxis)(f,e.map(e=>e.label),D):[],F=`${s}. ${e.map(e=>e.open?`${e.spoken} ${e.value}`:`${e.spoken} closed`).join('. ')}.`,z=e.reduce((e,t,l)=>!t.open||t.value<=0?e:!e||t.value>e.value?{i:l,value:t.value,spoken:t.spoken}:e,null);let I=null;if(f&&z){const e=`Busiest ${z.spoken}, ${z.value} ${1===z.value?'Cover':'Covers'}`,t=(0,h.labelWidth)(e,13);if(t<=f){const l=k(z.i)-t/2,o={x:Math.max(0,Math.min(f-t,l)),y:1,w:t,h:16,text:e};l>=-2&&l+t<=f+2&&M(z.value)>=o.y+o.h+6&&(I=o)}}return(0,x.jsxs)(i.default,{testID:"forecast-days-graph",style:{overflow:'visible'},children:[(0,x.jsxs)(i.default,{accessible:!0,accessibilityLabel:F,onLayout:e=>y(e.nativeEvent.layout.width),style:{height:p,minHeight:p,overflow:'visible'},children:[f?(0,x.jsxs)(a.default,{width:f,height:p,children:[S?(0,x.jsx)(n.Path,{d:S,stroke:d.colours.gold,strokeWidth:2.5,fill:"none"}):null,e.map((e,t)=>(0,x.jsx)(n.Circle,{cx:k(t),cy:M(e.value),r:3,fill:d.colours.gold},e.key))]}):null,I?(0,x.jsx)(u.T,{size:13,colour:d.colours.gold,numberOfLines:1,style:{position:'absolute',left:I.x,width:I.w,top:I.y,lineHeight:I.h,textAlign:'center'},children:I.text}):null]}),(0,x.jsxs)(i.default,{testID:"forecast-days-axis",style:{height:h.AXIS_BAND,minHeight:h.AXIS_BAND,position:'relative',overflow:'visible'},children:[(0,x.jsx)(i.default,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{position:'absolute',left:0,top:0,opacity:0,flexDirection:'row'},children:(0,x.jsx)(c.Text,{onLayout:e=>A(Math.round(10*e.nativeEvent.layout.width)/10),style:[{fontFamily:d.fonts.regular,fontSize:h.AXIS_FONT},{whiteSpace:'nowrap'}],children:"Wed"})}),T.map((e,t)=>(0,x.jsx)(u.T,{testID:"forecast-day-label",size:h.AXIS_FONT,colour:d.colours.muted,style:[{position:'absolute',left:e.x,width:e.w,top:0,lineHeight:h.AXIS_BAND,textAlign:e.align??'center'},{whiteSpace:'nowrap'}],children:e.text},`${e.text}-${t}-${e.x}`))]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=e(_r(_d[2])),s=e(_r(_d[3]));_r(_d[4]);var i=e(_r(_d[5])),r=e(_r(_d[6])),n=_r(_d[7]),a=e(n),u=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12])},1170,[828,34,283,364,236,102,426,797,794,827,821,1171,25]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AXIS_BAND",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AXIS_FONT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"labelWidth",{enumerable:!0,get:function(){return a}}),e.overlaps=i,e.anyOverlap=u,e.busiestText=s,e.hourAxis=h,e.dayLabelWidth=c,e.daysAxis=function(n,a,i=1){if(!a.length||n<=0)return[];const u=Math.max(10,n-28-8),s=Math.max(1,a.length-1),h=t=>a.length<=1?28+u/2:28+t/s*u,o=t=>t.every((a,i)=>a.x>=0&&a.x+a.w<=n&&(0===i||t[i-1].x+t[i-1].w+2<=a.x)),x=(u,s)=>{const x=a.map((t,n)=>({t:t,i:n})).filter(({i:t})=>t%u===0).map(({t:a,i:u})=>{const o=a.length>s?a.slice(0,s):a,x=Math.min(n,c(o,i));return{x:Math.max(0,Math.min(n-x,h(u)-x/2)),y:0,w:x,h:t,text:o}});return o(x)?x.map((t,a)=>{const i=0===a?0:(x[a-1].x+x[a-1].w+t.x)/2+1,u=a===x.length-1?n:(t.x+t.w+x[a+1].x)/2-1,s=Math.max(0,t.x-i),h=Math.max(0,u-(t.x+t.w));if(t.x<=.5)return{...t,x:0,w:t.w+h,align:'left'};if(t.x+t.w>=n-.5)return{...t,x:t.x-s,w:t.w+s,align:'right'};const o=Math.min(s,h);return{...t,x:t.x-o,w:t.w+2*o,align:'center'}}):null};for(let t=1;t<=a.length;t++){const n=x(t,3);if(n)return n;if(t>1){const n=x(t,2);if(n)return n}}return[]},e.layoutChart=function(n){const i=Math.max(1,n.width),u=Math.max(10,i-28-8),o=Math.max(1,n.t1-n.t0),x=h(i,n.t0,n.t1,n.hours).map(a=>({...a,y:Math.max(0,n.height-t)}));let c=null;if(n.busiest&&n.busiest.covers>0){const t=s(n.busiest.t,n.busiest.covers),h=Math.min(i,a(t,13)),x=28+(n.busiest.t-n.t0)/o*u-h/2;c={x:Math.max(0,Math.min(i-h,x)),y:1,w:h,h:16,text:t}}return{hours:x,busiest:c}},e.chartLabels=function(t){return t.busiest?[...t.hours,t.busiest]:t.hours};const t=22,n=12,a=(t,n)=>Math.max(1,Math.ceil(t.length*n*.62));function i(t,n){return t.x28+(t-s)/c*x,f=o.map(i=>{const u=String(new Date(i).getHours()).padStart(2,'0'),s=a(u,n);return{x:l(i)-s/2,y:0,w:s,h:t,text:u}});for(let t=1;t<=Math.max(1,f.length);t++){const n=f.filter((n,a)=>a%t===0).map(t=>({...t,x:Math.max(0,Math.min(i-t.w,t.x))}));if(!u(n))return n}return[]}const o='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ',x=[674,613,772,707,513,504,778,692,246,530,599,432,861,703,786,579,788,608,587,541,675,676,976,621,584,541,676,676,607,676,620,329,676,640,246,248,515,246,1030,640,640,676,676,373,522,364,640,561,820,479,563,455,628,320,575,589,629,628,635,546,631,630,267];function c(t,a=1,i=n){const u=[...t].reduce((t,n)=>{const a=o.indexOf(n);return t+(a<0?1e3:x[a])},0)/1e3;return Math.ceil(u*i*Math.max(1,a))+4}},1171,[]); +__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:s,now:i}=(0,I.useChef)(),{covers:n,label:r,typical:l,enough:a,booked:o,f:c}=(0,I.useForecast)(),f=(0,k.ymd)(i),p=(0,R.dishStats)(t).filter(t=>e.recipes.some(e=>e.dishId===t.item.id)&&!['Sides','Desserts'].includes(t.item.section)),m=p.reduce((e,t)=>e+t.sold,0)||1,x=p.map(e=>({id:e.item.id,name:e.item.name,qty:Math.ceil(.85*n*(e.sold/m)*1.1)})).filter(e=>e.qty>0).sort((e,t)=>t.qty-e.qty),b={};x.forEach(t=>e.recipes.find(e=>e.dishId===t.id)?.lines.forEach(e=>{b[e.ing]=(b[e.ing]??0)+e.qty*t.qty}));const y=[{id:'haddock',text:`Portion ${x.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,$.fmtQty)(Math.ceil(2*(b.potatoes??0))/2,'kg')} chipping potatoes`},{id:'batter',text:`Make up ${(0,$.fmtQty)(Math.ceil(10*(b.batter??0))/10+.5,'kg')} beer batter`},{id:'leaves',text:`Wash and spin ${(0,$.fmtQty)(Math.ceil(10*(b.leaves??0))/10,'kg')} salad leaves`},{id:'mussels',text:`Clean and debeard ${(0,$.fmtQty)(Math.ceil(2*(b.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'}],j=(0,D.useKitchen)(e=>e.tickPrep),w=[...y.map(e=>({key:`${f}:task:${e.id}`,text:e.text})),...x.map(e=>({key:`${f}:dish:${e.id}`,text:`${e.qty} \xd7 ${e.name}`}))],S=w.filter(t=>e.prepTicks[t.key]).length;return e.recipes.length&&e.ingredients.length?(0,q.jsxs)(h.default,{style:{gap:10},children:[a?null:(0,q.jsx)(u.Banner,{kind:"info",title:`Booked so far: ${o} Covers`,children:`Not enough history yet. Forecasts start once CoverCharge has ${c.minWeeks} weeks of your bookings and cash-ups. Prep from what is booked and your own judgement.`}),a?(0,q.jsxs)(u.Banner,{kind:"info",title:`${r}: ${n} Covers forecast`,children:["A typical ",r.split(' ')[0]," is about ",l," Covers. Portions below are scaled from the forecast, bookings and the usual dish mix, plus 10% cover."]}):null,(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Prep list for today"}),(0,q.jsx)(u.Badge,{kind:S===w.length?'ok':'gold',label:`${S}/${w.length} done`})]}),w.map((t,i)=>{const n=e.prepTicks[t.key];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t.text,onPress:()=>j(t.key,n?null:s),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:n?C.colours.ok:C.colours.border,backgroundColor:C.colours.surface,marginTop:i===y.length?8:0},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,style:n?{textDecorationLine:'line-through',color:C.colours.muted}:void 0,children:t.text}),n?(0,q.jsxs)(u.Muted,{children:[n.by," \xb7 ",new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]}):null]})]},t.key)})]}):(0,q.jsx)(u.Muted,{children:"No prep list yet. Add your real recipe costs and ingredients to build it."})},_e.WasteScreen=function(){const{k:e,me:n,now:r,rid:l}=(0,I.useChef)(),a=(0,I.useWeek)(),d=(0,D.useKitchen)(e=>e.addWaste),[f,p]=(0,o.useState)(e.ingredients[0]?.id),[m,x]=(0,o.useState)(''),[b,y]=(0,o.useState)('Over-production'),w=e.ingredients.find(e=>e.id===f),k=Number(m.replace(',','.'))||0,S=k>=0&&(!w||!(0,s.fishInStone)(l,w)||Number.isInteger(2*k)),T=w&&S?(0,s.inputQuantity)(l,w,k):0,v=e.waste.filter(e=>(0,I.within7)(e.at,r));return w?(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Row,{wrap:!0,gap:10,children:[(0,q.jsx)(I.Tile,{label:"Waste this week",value:(0,j.gbp)(a.wasteWeek),sub:`${v.length} entries`,tone:a.sales&&a.wasteWeek/a.sales>.02?'amber':'ok'}),(0,q.jsx)(I.Tile,{label:"Waste as % of food sales",value:a.sales?(0,I.pct1)(a.wasteWeek/a.sales*100):'\u2014',sub:a.sales?'Food sales ex VAT, this week':'Needs dish sales (no till link yet)'})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Log waste"}),(0,q.jsx)(c.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,children:(0,q.jsx)(u.Row,{gap:6,children:e.ingredients.map(e=>(0,q.jsx)(u.Chip,{label:e.name,selected:e.id===f,onPress:()=>p(e.id)},e.id))})}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:`Waste quantity in ${(0,s.quantityUnit)(l,w)}`,accessibilityValue:{text:(0,i.ingredientSpeech)(l,w,T)},keyboardType:"decimal-pad",value:m,onChangeText:x,placeholder:`qty (${(0,s.quantityUnit)(l,w)})`,placeholderTextColor:C.colours.muted,style:{flex:1,minHeight:44,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),(0,q.jsx)(u.T,{children:(0,s.quantityUnit)(l,w)}),(0,q.jsx)(u.T,{weight:"semibold",colour:C.colours.gold,children:(0,j.gbp)(Math.round(T*w.cost))})]}),(0,s.fishInStone)(l,w)?(0,q.jsxs)(u.Row,{children:[(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Waste half a stone less ${w.name}`,onPress:()=>x(String(Math.max(0,(0,s.halfStone)(k)-.5)))}),(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Waste half a stone more ${w.name}`,onPress:()=>x(String((0,s.halfStone)(k)+.5))}),(0,q.jsx)(u.Muted,{children:"Half-stone amounts"})]}):null,(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:D.WASTE_REASONS.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===b,onPress:()=>y(e)},e))}),(0,q.jsx)(u.Button,{label:"Add to waste log",disabled:T<=0,onPress:()=>{d({by:n,item:w.name,ing:w.id,qty:T,unit:w.unit,reason:b,cost:Math.round(T*w.cost)}),x('')}}),(0,q.jsx)(u.Muted,{children:"Logged waste also comes off stock."})]}),e.waste.slice(0,20).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between',paddingVertical:2},children:[(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsxs)(u.T,{size:14,children:[e.item," \xb7 ",(0,i.ingredientQty)(l,{name:e.item,unit:e.unit},e.qty)]}),(0,q.jsxs)(u.Muted,{children:[e.reason," \xb7 ",new Date(e.at).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})," \xb7 ",e.by]})]}),(0,q.jsx)(u.T,{size:14,children:(0,j.gbp)(e.cost)})]},e.id))]}):(0,q.jsx)(u.Muted,{children:"No stock items yet. Add your real ingredients before logging waste."})},_e.AllergenScreen=function({openCards:e}={}){const{k:t,me:s,rid:i}=(0,I.useChef)(),n=(0,f.useRecipeCards)(i),r=(0,b.auditView)('chef',(0,f.useAudit)(i)).filter(e=>/allergen|recipe card|sign/i.test(e.text)).slice(0,12),l=n.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}}),a={name:s,role:'head-chef'},c=(0,m.useUnsignedDishes)(i),[x,j]=(0,o.useState)(!1);return x?(0,q.jsx)(m.UnsignedDishList,{rid:i,actor:a,onClose:()=>j(!1),onOpenCards:e}):(0,q.jsxs)(h.default,{style:{gap:10},testID:"allergen-matrix",children:[(0,q.jsx)(d.default,{testID:"tile-not-signed-off",accessibilityRole:"button",accessibilityLabel:`Dishes not signed off, ${c.length}. Opens the list.`,onPress:()=>j(!0),style:({pressed:e})=>({minHeight:48,opacity:e?.85:1}),children:(0,q.jsxs)(u.Card,{style:{alignItems:'center'},highlight:c.length?C.colours.amber:void 0,children:[(0,q.jsx)(u.Muted,{center:!0,children:"Dishes not signed off"}),(0,q.jsx)(u.T,{center:!0,size:20,weight:"bold",children:c.length})]})}),(0,q.jsx)(u.Muted,{children:"The 14 allergens from each recipe card. These are what guests see on the menu, takeaway and the booking allergy check. A red warning means the costing recipe uses an ingredient with that allergen but the card doesn't list it."}),e?(0,q.jsx)(u.Button,{testID:"open-recipe-cards",small:!0,kind:"secondary",label:"Open recipe cards \u203a",onPress:e}):null,l.map(({card:e,fromCosting:t})=>(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",center:!0,children:e.dish}),(0,q.jsx)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center'},children:y.ALLERGENS.map(s=>{const i=e.allergens[s.id],n=t.has(s.id)&&!i,r='contains'===i?'Contains':'may'===i?'May contain':n?'In costing recipe, not on card':'Not listed';return(0,q.jsxs)(h.default,{accessible:!0,accessibilityLabel:`${e.dish}, ${s.label}: ${r}`,style:{flexGrow:1,flexBasis:220,minWidth:180,maxWidth:'100%',padding:8,borderRadius:8,backgroundColor:n?C.colours.redBg:C.colours.surface2},children:[(0,q.jsx)(u.T,{center:!0,size:14,weight:"semibold",children:s.label}),(0,q.jsx)(u.T,{center:!0,size:14,colour:n?C.colours.red:'contains'===i?C.colours.gold:C.colours.muted,children:r})]},s.id)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Not listed means the allergen is not recorded on this recipe card. Check any costing warnings before sign-off."}),l.filter(e=>e.missing.length||!e.card.signOff).map(({card:t,missing:s})=>(0,q.jsxs)(u.Card,{highlight:s.length?C.colours.red:C.colours.amber,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{weight:"semibold",style:{flex:1},children:t.dish}),t.signOff?(0,q.jsx)(u.Badge,{kind:"ok",label:"Signed off"}):(0,q.jsx)(u.Badge,{kind:"amber",label:"Awaiting sign-off"})]}),s.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["Costing recipe has ",s.map(e=>y.ALLERGENS.find(t=>t.id===e)?.short).join(', '),", not on the card"]}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:[s.length?(0,q.jsx)(u.Button,{small:!0,label:"Add to the card",onPress:()=>{const e={...t.allergens};s.forEach(t=>{e[t]='contains'}),(0,p.recipeCards)().update(t.id,{allergens:e},a).catch(()=>{})}}):null,e?(0,q.jsx)(u.Button,{small:!0,kind:"secondary",label:"Check and sign off on the card",onPress:e}):null]})]},t.id)),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Audit log"}),r.length?r.map(e=>(0,q.jsxs)(u.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,q.jsx)(u.Muted,{children:"No allergen changes yet."})]})]})},_e.ComplianceScreen=function(){const{k:e,me:s,now:i,rid:r}=(0,I.useChef)(),l=(0,k.ymd)(i),a=(0,D.useKitchen)(e=>e.addTemp),c=(0,x.useOwner)(e=>e.checks),{tick:f,untick:p}=x.useOwner.getState(),[m,b]=(0,o.useState)('fridge'),y=E.find(e=>e.id===m),j={...y,units:y.units.filter(e=>(0,n.chefCanSee)(r,e))},[w,S]=(0,o.useState)(j.units[0]),[T,v]=(0,o.useState)(''),R=Number(T.replace(',','.')),$=T.trim()&&!Number.isNaN(R)?j.ok(R):null,M=e.temps.filter(e=>e.at.slice(0,10)===l),B=(e,t,i)=>{const n=c[e];return(0,q.jsxs)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!!n},accessibilityLabel:t,onPress:()=>n?p(e):f(e,s,(new Date).toISOString()),style:{flexDirection:'row',gap:10,alignItems:'center',paddingVertical:6},children:[(0,q.jsx)(u.T,{size:18,colour:n?C.colours.ok:C.colours.muted,children:n?'\u2611':'\u2610'}),(0,q.jsxs)(h.default,{style:{flex:1},children:[(0,q.jsx)(u.T,{size:14,children:t}),(0,q.jsx)(u.Muted,{children:n?`${n.by} \xb7 ${new Date(n.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:i??''})]})]},e)};return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Record a temperature"}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:E.map(e=>(0,q.jsx)(u.Chip,{label:e.label,selected:e.id===m,onPress:()=>{b(e.id),S(e.units.filter(e=>(0,n.chefCanSee)(r,e))[0])}},e.id))}),(0,q.jsx)(u.Row,{wrap:!0,gap:6,children:j.units.map(e=>(0,q.jsx)(u.Chip,{label:e,selected:e===w,onPress:()=>S(e)},e))}),(0,q.jsx)(u.Muted,{children:j.rule}),(0,q.jsxs)(u.Row,{gap:8,children:[(0,q.jsx)(t.TextInput,{accessibilityLabel:"Temperature in degrees C",keyboardType:"numbers-and-punctuation",value:T,onChangeText:v,placeholder:"\xb0C",placeholderTextColor:C.colours.muted,style:{width:90,borderWidth:1,borderColor:C.colours.border,borderRadius:8,padding:8,color:C.colours.text}}),null===$?null:(0,q.jsx)(u.Badge,{kind:!0===$?'ok':'warn'===$?'amber':'red',label:!0===$?'OK':'warn'===$?'CHECK':'OUT OF RANGE'}),(0,q.jsx)(u.Button,{small:!0,label:"Save",disabled:null===$,onPress:()=>{a({by:s,kind:m,unit:w,temp:R,note:!0===$?void 0:'Action needed'}),v('')}})]}),!1===$?(0,q.jsx)(u.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,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today's readings (",M.length,")"]}),M.length?M.map(e=>{const t=E.find(t=>t.id===e.kind)?.ok(e.temp);return(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsx)(u.T,{size:14,style:{flex:1},children:e.unit}),(0,q.jsx)(u.Muted,{children:new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}),(0,q.jsxs)(u.T,{size:14,weight:"semibold",colour:!0===t?C.colours.ok:'warn'===t?C.colours.amber:C.colours.red,children:[e.temp,"\xb0C"]})]},e.id)}):(0,q.jsx)(u.Muted,{children:"None yet today."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Opening and closing checks"}),(0,q.jsx)(u.Muted,{children:"Day-to-day checks in the style of a CookSafe diary. Your own CookSafe manual is the record that counts."}),G.map(e=>B(`${l}:kc-${e.id}`,e.text))]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Cleaning schedule"}),F.map(e=>B('Daily'===e.freq?`${l}:kcl-${e.id}`:`wk${Math.floor(i.getTime()/6048e5)}:kcl-${e.id}`,e.text,e.freq))]})]})},_e.TeamScreen=function(){const{rid:e,r:t,me:s,now:i,menu:n}=(0,I.useChef)(15e3),[r,a]=(0,o.useState)('live'),d=(0,v.useSignedIn)(),c=(0,o.useMemo)(()=>({meId:d?.id??I.CHEF_ID,role:'staff'}),[d?.id]),u=(0,T.useChatOpen)(e=>e.ch);return(0,o.useEffect)(()=>{u&&a('chat')},[u]),(0,q.jsx)(S.ChatAsCtx.Provider,{value:c,children:(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(H,{sub:r,setSub:a}),'live'===r?(0,q.jsx)(_,{}):'soldout'===r?(0,q.jsx)(l.SoldOutList,{rid:e,by:s}):'team'===r?(0,q.jsx)(V,{}):(0,q.jsx)(U,{}),void 0,void 0,void 0,void 0,void 0]})})};var t=_r(_d[0]),s=_r(_d[1]),i=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),a=_r(_d[6]),o=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),h=e(_r(_d[10])),u=_r(_d[11]),f=_r(_d[12]),p=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),T=_r(_d[23]),v=_r(_d[24]),R=_r(_d[25]),$=_r(_d[26]),M=_r(_d[27]),B=_r(_d[28]),I=_r(_d[29]),D=_r(_d[30]),O=_r(_d[31]),L=_r(_d[32]),z=_r(_d[33]),P=_r(_d[34]),A=_r(_d[35]),N=_r(_d[36]),W=_r(_d[37]),q=_r(_d[38]);const E=[{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'}],F=[{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'}],G=[{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 H({sub:e,setSub:t}){const{total:s}=(0,S.useChatUnread)();return(0,q.jsx)(I.Seg,{value:e,onChange:t,options:[{id:'live',label:'Live tickets'},{id:'soldout',label:'Sold out'},{id:'team',label:"Who's on & rota"},{id:'chat',label:s?`Chat (${s})`:'Chat'}]})}function U(){return(0,q.jsx)(S.Chat,{go:()=>{}})}function _(){const{rid:e,r:t,me:s,now:i}=(0,I.useChef)(15e3),n=(0,f.useStore)(e=>e.bookings),l=(0,f.useOrders)(e),o=l.filter(e=>(0,a.waitingForStaff)(e)).length,d=l.filter(a.kitchenCanSee).filter(e=>['new','acknowledged','preparing'].includes(e.status)||'ready'===e.status&&'pass'===(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))),c=(e,t)=>!!(0,B.statusBlock)(e,t,(0,B.linkedBooking)(e,n)),p=(0,b.ticketView)('chef',d),m=(0,f.useStore)(e=>e.setOrderStatus),x=(0,f.useStore)(e=>e.ackReadiness),j=d.flatMap(e=>(0,w.readinessFor)(e,t,i)).filter(e=>'due'===e.state||'overdue'===e.state);return(0,q.jsxs)(h.default,{style:{gap:8},children:[j.length?(0,q.jsx)(u.Banner,{kind:"warn",title:`${j.length} readiness alert${j.length>1?'s':''}`,children:j.map(e=>e.detail).join(' \xb7 ')}):(0,q.jsx)(u.Muted,{children:"No readiness alerts right now."}),o?(0,q.jsxs)(u.Muted,{children:[o," table order",o>1?'s':''," waiting for front of house to accept (the first order from a new phone). It shows here once accepted."]}):null,p.length?p.map(e=>(0,q.jsxs)(u.Card,{highlight:e.allergies.length&&(0,B.nextStep)(e,(0,B.linkedBooking)(e,n))&&'ready'!==e.status?C.colours.red:void 0,children:[(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.T,{weight:"semibold",children:['table'===e.type?`Table ${(0,r.tableNumbers)(e.tableNo)}`:`Takeaway ${e.slotTime?new Date(e.slotTime).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`," \xb7 ",e.ref]}),(0,q.jsx)(u.Badge,{kind:'new'===e.status?'amber':'gold',label:e.status.toUpperCase()})]}),e.lines.map((e,t)=>(0,q.jsxs)(u.T,{size:14,children:[e.qty," \xd7 ",e.name]},t)),e.allergies.length?(0,q.jsxs)(u.T,{size:13,colour:C.colours.red,children:["\u26a0 Allergy: ",e.allergies.map(e=>`${y.ALLERGENS.find(t=>t.id===e.allergen)?.label} (${e.severity})`).join(', ')]}):null,'takeaway'===e.type&&e.accepted?(0,q.jsxs)(u.T,{size:13,colour:C.colours.ok,children:["\u2713 Confirmed by ",e.accepted.by,Object.keys(e.allergyTicks??{}).length?` \xb7 kitchen checked: ${Object.keys(e.allergyTicks).map(e=>y.ALLERGENS.find(t=>t.id===e)?.label??e).join(', ')}`:'']}):null,e.allergies.length?(0,q.jsx)(M.AllergyChain,{o:e,me:s}):null,(0,q.jsxs)(u.Row,{wrap:!0,gap:8,children:['preparing'!==e.status&&'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,label:"Start",testID:`start-${e.ref}`,disabled:c(e,'preparing'),onPress:()=>{m(e.id,'preparing',s),'takeaway'===e.type&&x(e.id,'cook',s)}}):null,'ready'!==e.status?(0,q.jsx)(u.Button,{small:!0,kind:"success",label:"Ready",testID:`ready-${e.ref}`,disabled:c(e,'ready'),onPress:()=>m(e.id,'ready',s)}):null]})]},e.id)):(0,q.jsx)(u.Muted,{children:"No live tickets. New orders from the customer app and the Staff app show here."})]})}const K=(e,t)=>{const[s,i,n]=e.split('-').map(Number);return(0,k.ymd)(new Date(s,i-1,n+t))};function V(){const{now:e,today:t}={...(0,I.useChef)(6e4),today:(0,k.ymd)(new Date)},{staff:s,shifts:i}=(0,b.rotaView)('chef',(0,x.useOwner)(e=>e.staff),(0,x.useOwner)(e=>e.shifts)),n=(0,x.useOwner)(e=>e.leave),r=(0,N.canEditKitchenRota)((0,P.useSync)(e=>e.perms)),l=(0,x.useOwner)(e=>e.attendance).filter(e=>e.date===t&&e.in&&!e.out),a=(0,v.weekday)(e),o=s.filter(e=>/kitchen|chef|kp/i.test(e.job+e.name)),d=(0,z.useSession)(e=>e.meId),c=(0,P.useSync)(e=>e.staffRef),f=d??c??I.CHEF_ID,p=(0,x.useOwner)(e=>e.staff.find(e=>e.id===f)?.name??'Chef').replace(/\s*\(.*\)$/,'');return(0,q.jsxs)(h.default,{style:{gap:10},children:[(0,q.jsx)(L.BreakRoomCard,{staffId:f,name:p,now:e}),(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"On now"}),l.length?l.map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name??e.staffId})]}),(0,q.jsxs)(u.Muted,{children:["since ",new Date(e.in).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]},e.id)):(0,q.jsx)(u.Muted,{children:"Nobody clocked in yet."})]}),(0,q.jsxs)(u.Card,{children:[(0,q.jsxs)(u.T,{weight:"semibold",children:["Today on the rota (",v.DAY3[a],")"]}),i.filter(e=>e.date===t).map(e=>(0,q.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,q.jsxs)(u.Row,{gap:8,style:{flex:1},children:[(0,q.jsx)(O.StaffAvatar,{id:e.staffId,size:28}),(0,q.jsx)(u.T,{size:14,children:s.find(t=>t.id===e.staffId)?.name})]}),(0,W.leaveCovering)(n,e.staffId,e.date)?(0,q.jsx)(u.T,{size:13,colour:C.colours.blue,children:(0,W.leaveLabel)((0,W.leaveCovering)(n,e.staffId,e.date))}):(0,q.jsxs)(u.Muted,{children:[(0,v.fmtH)(e.start),"\u2013",(0,v.fmtH)(e.end)]})]},e.id))]}),r?(0,q.jsx)(u.Card,{children:(0,q.jsx)(A.KitchenRotaEditor,{today:t})}):(0,q.jsxs)(u.Card,{children:[(0,q.jsx)(u.T,{weight:"semibold",children:"Kitchen rota this week"}),o.map(e=>(0,q.jsxs)(h.default,{style:{gap:4},children:[(0,q.jsx)(u.T,{size:14,children:e.name}),(0,q.jsx)(u.Row,{wrap:!0,gap:4,children:v.DAY3.map((s,n)=>{const r=i.find(s=>s.staffId===e.id&&s.date===K(t,n-a));return(0,q.jsxs)(h.default,{style:{width:44,padding:4,borderRadius:6,backgroundColor:r?C.colours.goldTint:C.colours.surface2,alignItems:'center'},children:[(0,q.jsx)(u.T,{size:10,colour:C.colours.muted,children:s}),(0,q.jsx)(u.T,{size:10,children:r?`${(0,v.fmtH)(r.start).slice(0,2)}\u2013${(0,v.fmtH)(r.end).slice(0,2)}`:'off'})]},s)})})]},e.id)),(0,q.jsx)(u.Muted,{children:"Rota changes, swaps and leave are made in CoverCharge for Managers. This view shows shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})]})}},1172,[827,984,1173,835,860,1174,1175,34,402,295,102,794,874,882,1176,891,994,861,867,1179,858,821,1180,1113,1088,1160,1159,1181,869,1165,1033,925,1182,1004,987,1185,989,1098,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ingredientQty",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingredientSpeech",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const i=(i,f,u)=>(0,n.fishInStone)(i,f)?(0,n.fishQtyText)(i,f,u):(0,t.fmtQty)(u,f.unit||''),f=(t,f,u)=>(0,n.fishInStone)(t,f)?(0,n.fishQtySpeech)(t,f,u):i(t,f,u)},1173,[1159,984]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.SoldOutList=f,_e.SoldOutSheet=function({visible:e,onClose:t,rid:s,by:o,hideLinks:n=!0,testID:i="soldout-sheet"}){return(0,k.jsx)(l.Sheet,{visible:e,onClose:t,title:"Add sold out",maxWidth:520,testID:i,children:(0,k.jsx)(f,{rid:s,by:o,hideLinks:n})})};var e,t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=(e=o)&&e.__esModule?e:{default:e},l=_r(_d[3]),i=_r(_d[4]),d=_r(_d[5]),r=_r(_d[6]),a=_r(_d[7]),u=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),m=_r(_d[11]),k=_r(_d[12]);const y=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},x=e=>{const t=new Date(globalThis.__ccNow??Date.now()).toISOString();for(const s of['kitchen','foh'])r.useOwner.getState().sys(s,e,t)};function f({rid:e,by:o,canMark:r=!0,hideLinks:f=!1}){const b=(0,d.useSoldOut)(e=>e.entries),p=(0,i.useStore)(e=>e.clock),w=(0,i.useStore)(e=>e.menu),S=(0,i.useStore)(t=>t.restaurants.find(t=>t.id===e)),[I,$]=(0,s.useState)(''),C=(0,h.nowFrom)(p),D=(0,a.activeSoldOut)(b,e,C),M=new Set(D.map(e=>e.itemId)),L=(0,a.soldOutSettingsOf)(S?.settings?.soldOut),T=(0,u.useAutoSoldOutView)(e),v=b.filter(t=>t.rid===e&&!t.on&&t.kept&&T.reason(t.itemId)),O=(0,s.useMemo)(()=>w.filter(t=>t.restaurantId===e&&!t.hidden&&!M.has(t.id)&&(!I.trim()||t.name.toLowerCase().includes(I.trim().toLowerCase()))).sort((e,t)=>e.name.localeCompare(t.name)),[w,e,I,D.length]),B=t=>d.useSoldOut.getState().entries.some(s=>s.rid===e&&s.itemId===t&&s.on),A=(t,s)=>{const n=b.some(s=>s.rid===e&&s.itemId===t&&s.auto&&T.reason(t));w.some(e=>e.id===t)&&(0,d.setSoldOut)(t,!1,o),B(t)&&d.useSoldOut.getState().back(e,t,o),x(`Back on: ${s}${n?' (kept on until the count changes)':''}`)};return(0,k.jsxs)(n.default,{testID:"soldout-list",style:{gap:10},children:[(0,k.jsx)(l.Muted,{children:"A reminder for staff. Dishes you mark sold out show on the Display and in the Sold out list in every staff app, within seconds. It doesn't change your till."}),(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Sold out now"}),(0,k.jsx)(l.T,{size:13,colour:D.length?m.colours.amber:m.colours.muted,children:D.length?(0,a.soldOutCount)(D.length):'Nothing sold out'})]}),D.length?D.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-row-${e.itemId}`,style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'space-between',alignItems:'center',paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border},children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160,gap:2},children:[(0,k.jsx)(l.T,{weight:"semibold",children:(0,c.withReason)(e.name,T.reason(e.itemId))}),(0,k.jsxs)(l.Muted,{children:["Since ",y(e.at),e.auto?' \xb7 Auto, from the counts \xb7 clears when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 clears at ${y(e.clearAfter)}`:''}`]})]}),r?(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back on",testID:`soldout-back-${e.itemId}`,accessibilityLabel:`Cancel sold out: ${e.name}, put ${e.name} back on`,onPress:()=>A(e.itemId,e.name)}):null]},e.itemId)):(0,k.jsx)(l.Muted,{children:"When a dish runs out, mark it here so everyone knows."}),v.length?(0,k.jsx)(n.default,{testID:"soldout-kept",children:(0,k.jsxs)(l.Muted,{children:["Kept on by hand while the count is short: ",v.map(e=>e.name).join(', '),". They stay on until the count changes."]})}):null,(0,k.jsxs)(l.Muted,{children:["Clears by itself: ",a.SOLD_OUT_CLEAR_LABEL[L.clear].toLowerCase(),". ",L.auto?'Dishes marked from the counts clear when the count is back up. ':'',"Managers can change this in Settings \u203a Advanced."]})]}),!f&&T.items.length?(0,k.jsx)(j,{rid:e,by:o,canEdit:r,auto:L.auto,view:T}):null,r?(0,k.jsxs)(l.Card,{children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Mark a dish sold out"}),(0,k.jsx)(t.TextInput,{testID:"soldout-search",value:I,onChangeText:$,placeholder:"Find a dish",placeholderTextColor:m.colours.muted,accessibilityLabel:"Find a dish",style:{minHeight:46,borderRadius:12,borderWidth:1,borderColor:m.colours.accentBorder,backgroundColor:m.colours.surface2,color:m.colours.text,paddingHorizontal:12,fontSize:16}}),O.slice(0,60).map(t=>(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingVertical:4},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{children:t.name}),(0,k.jsx)(l.Muted,{children:t.section})]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Mark sold out",testID:`soldout-mark-${t.id}`,accessibilityLabel:`Mark sold out: ${t.name}`,onPress:()=>{return s=t.id,n=t.name,(0,d.setSoldOut)(s,!0,o),B(s)||d.useSoldOut.getState().mark(e,s,n,o),void x(`Sold out: ${n}`);var s,n}})]},t.id)),O.length?null:(0,k.jsx)(l.Muted,{children:I?'No dish matches that.':'Every dish is marked sold out.'})]}):null]})}const b={link:'set by staff',card:'from its recipe card',description:'from its description',name:'from its name',none:''},p=e=>.5===e?'\xbd':Number.isInteger(e)?String(e):`${Math.floor(e)}\xbd`;function j({rid:e,by:t,canEdit:o,auto:i,view:d}){const[r,a]=(0,s.useState)(!1),[h,y]=(0,s.useState)(null),[x,f]=(0,s.useState)([]),j=d.dishes.filter(t=>t.uses.length||'none'===t.source&&d.links.some(s=>s.rid===e&&s.itemId===t.id&&!s.auto)),w=(r?d.dishes:j).slice().sort((e,t)=>e.name.localeCompare(t.name)),S=d.items.map(e=>`${e.name.toLowerCase()} ${p(d.counts[e.key]??0)}`).join(', '),I=(e,t,s)=>f(o=>o.map(o=>o.key===e?{...o,qty:Math.max(0,Math.min(20,o.qty+s*('half'===t.unit?.5:1)))}:o)),$=(s,o)=>{u.useSoldOutLinks.getState().setLink(e,s,o,t),y(null)};return(0,k.jsx)(n.default,{testID:"soldout-links",children:(0,k.jsxs)(l.Card,{children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsx)(l.T,{weight:"semibold",size:17,children:"Dishes linked to the counts"}),(0,k.jsx)(n.default,{testID:"soldout-links-counts",children:(0,k.jsxs)(l.T,{size:13,colour:m.colours.muted,children:["Counts now: ",S]})})]}),(0,k.jsx)(l.Muted,{children:i?'When a count runs out, or drops below what a dish needs, the dish is marked sold out by itself, and put back on when the count is back up. Dishes you mark by hand are left alone.':'Marking dishes from the counts is off for this venue (Settings \u203a Advanced \u203a Sold out reminders).'}),w.map(e=>(0,k.jsxs)(n.default,{testID:`soldout-link-${e.id}`,style:{paddingVertical:6,borderTopWidth:1,borderTopColor:m.colours.border,gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'center'},wrap:!0,children:[(0,k.jsxs)(n.default,{style:{flexShrink:1,flexGrow:1,flexBasis:160},children:[(0,k.jsx)(l.T,{weight:"semibold",children:e.name}),(0,k.jsxs)(l.Muted,{children:[e.uses.length?`Uses ${(0,c.usesText)(e.uses,d.items)}`:'Not linked to the counts',b[e.source]?` \xb7 ${b[e.source]}`:'']})]}),o&&h!==e.id?(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Change",testID:`soldout-link-edit-${e.id}`,accessibilityLabel:`Change what ${e.name} uses`,onPress:()=>{return t=e.id,s=e.uses,y(t),void f(d.items.map(e=>({key:e.key,qty:s.find(t=>t.key===e.key)?.qty??0})));var t,s}}):null]}),h===e.id?(0,k.jsxs)(n.default,{style:{gap:6},children:[d.items.map(t=>{const s=x.find(e=>e.key===t.key)?.qty??0;return(0,k.jsxs)(l.Row,{style:{alignItems:'center',gap:8},children:[(0,k.jsx)(l.T,{style:{flexGrow:1},children:t.name}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"\u2013",testID:`soldout-link-${e.id}-${t.key}-minus`,accessibilityLabel:`Fewer ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,-1)}),(0,k.jsx)(n.default,{testID:`soldout-link-${e.id}-${t.key}-qty`,style:{minWidth:28},children:(0,k.jsx)(l.T,{weight:"semibold",style:{textAlign:'center'},children:p(s)})}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"+",testID:`soldout-link-${e.id}-${t.key}-plus`,accessibilityLabel:`More ${t.plural.toLowerCase()}`,onPress:()=>I(t.key,t,1)})]},t.key)}),(0,k.jsxs)(l.Muted,{children:["Per portion. ",x.some(e=>e.qty>0)?`Uses ${(0,c.usesText)(x.filter(e=>e.qty>0),d.items)}.`:'Not linked: never marked from the counts.']}),(0,k.jsxs)(l.Row,{style:{gap:8},wrap:!0,children:[(0,k.jsx)(l.Button,{small:!0,label:"Save",testID:`soldout-link-save-${e.id}`,onPress:()=>$(e.id,x.filter(e=>e.qty>0))}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Back to automatic",testID:`soldout-link-reset-${e.id}`,accessibilityLabel:`Back to automatic: ${e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'}`,onPress:()=>$(e.id,null)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y(null)})]}),(0,k.jsxs)(l.Muted,{children:["Automatic: ",e.guess.length?(0,c.usesText)(e.guess,d.items):'not linked'," (from the recipe card, description or name)."]})]}):null]},e.id)),w.length?null:(0,k.jsx)(l.Muted,{children:"No dish is linked yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:r?'Show linked dishes only':'Link another dish',testID:"soldout-links-all",onPress:()=>a(!r)})]})})}},1174,[827,34,102,794,874,979,891,980,981,982,831,821,25]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"TABLE_ORDER_DEFAULT",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"cleanToken",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"isTableNo",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"fromRow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"toRow",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"hm",{enumerable:!0,get:function(){return l}}),_e.openAt=function(e,t){const r=a(t),n=e.openFrom?a(e.openFrom):null,o=e.lastOrders?a(e.lastOrders):null;return null!==n&&null!==o?n<=o?r>=n&&r=n||r=n:null===o||r{const t=(e??'').trim().toUpperCase();return/^[A-Z2-9]{16}$/.test(t)?t:null},r=e=>/^[0-9]{1,4}$/.test(e),n=t=>t?{on:!!t.is_on,tables:Array.isArray(t.tables)?t.tables.map(String):null,staffAccept:!1!==t.staff_accept,openFrom:t.open_from?String(t.open_from).slice(0,5):null,lastOrders:t.last_orders?String(t.last_orders).slice(0,5):null,guestTip:t.guest_tip??''}:{...e},o=e=>({is_on:e.on,tables:e.tables&&e.tables.length?e.tables.filter(r):null,staff_accept:e.staffAccept,open_from:e.openFrom,last_orders:e.lastOrders,guest_tip:e.guestTip.slice(0,300)}),a=e=>{const[t,r]=e.split(':').map(Number);return 60*t+r},l=e=>`${String(Math.floor(e/60)%24).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`;const s=(e,t)=>e.reduce((e,r)=>e+r.qty*(t.find(e=>e.id===r.id)?.pricePence??0),0),u=(e,t,r)=>e.map(e=>t.find(t=>t.id===e.id)).filter(e=>!!e&&(e.allergens.some(e=>r.includes(e))||e.mayContain.some(e=>r.includes(e)))),c=(e,t)=>`${e.replace(/\/$/,'')}/t?k=${t}`,f=(e,t)=>`${e.replace(/\/$/,'')}/customer-app/index.html?table=${t}`,p=e=>{const t=e.trim();return t.length>=2&&t.length<=40&&/\p{L}/u.test(t)},b=e=>{const t=e.trim();return!t||/^\+?[0-9][0-9 ()-]{6,19}$/.test(t)},m=e=>'table'===e.type&&'table-qr'===e.channel,y=e=>m(e)&&!!e.held&&!e.accepted&&'cancelled'!==e.status,h=e=>!y(e),O=e=>'cancelled'===e.status?e.cancelReason?`Cancelled: ${e.cancelReason}`:'Cancelled by the staff.':e.held&&!e.accepted?'Sent. Waiting for a member of staff to accept it.':'served'===e.status||'collected'===e.status||'closed'===e.status?'Served. Enjoy!':'ready'===e.status?'Ready: on its way to your table.':'Accepted: the kitchen has your order.',P=['Sold out','Wrong table','Sent twice','Kitchen closed','Guest asked to cancel'],j='Pay at the bar or with your server. Paying by card from your phone is coming later.'},1175,[]); +__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 j}}),_e.SignOffLine=$,_e.CardView=P,_e.CardEditor=R,_e.RecipeCards=function({rid:e,actor:s,mode:l}){const h=(0,a.useRecipeCards)(e),u=(0,n.useMemo)(()=>h.filter(e=>!c.OFF_CARD_LIST.has(e.menuItemId)),[h]),[p,x]=(0,n.useState)(''),[b,j]=(0,n.useState)([]),[C,w]=(0,n.useState)('free-from'),[I,$]=(0,n.useState)('all'),[D,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(null),v='edit'===l&&(0,m.canEditCards)(s.role),B=v?u:u.filter(e=>!!e.signOff),L=(0,n.useMemo)(()=>{const e='all'===I?B:B.filter(e=>(0,m.cardState)(e)===I);return(0,m.filterCards)(e,p,b,C).slice().sort((e,t)=>e.section.localeCompare(t.section)||M(e.dish).localeCompare(M(t.dish)))},[B,p,b,C,I]),O=u.filter(e=>!e.signOff).length,A=D?u.find(e=>e.id===D):void 0,N=k&&'new'!==k?u.find(e=>e.id===k)??null:null,z=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return(0,y.jsxs)(r.default,{testID:"recipe-cards",style:{gap:12},children:['read'===l?(0,y.jsx)(d.Banner,{kind:"info",title:"Read-only",children:"Signed-off recipe cards only. The head chef keeps these up to date."}):(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(s,{createdBy:s.name,createdByRole:s.role})?'You can add, edit and sign off cards. A card goes live once it is signed off. Editing a card clears the sign-off.':'You can add and edit cards. The Head Chef, an owner or a manager signs it off before it goes live. Editing a card clears the sign-off.'}),u.some(e=>'example'===e.origin)?(0,y.jsx)(d.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,v?(0,y.jsx)(d.Button,{testID:"new-card",label:"New recipe card",onPress:()=>S('new')}):null,(0,y.jsx)(t.TextInput,{testID:"card-search",accessibilityLabel:"Search recipe cards",value:p,onChangeText:x,placeholder:"Search dishes or ingredients",placeholderTextColor:"#7D776C",style:d.styles.input}),(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,children:"Allergens:"}),(0,y.jsx)(d.Chip,{label:"Free from",selected:'free-from'===C,onPress:()=>w('free-from')}),(0,y.jsx)(d.Chip,{label:"Contains",selected:'contains'===C,onPress:()=>w('contains')}),b.length?(0,y.jsx)(d.Chip,{label:"Clear",onPress:()=>j([])}):null]}),(0,y.jsx)(d.Row,{gap:6,wrap:!0,children:f.ALLERGENS.map(e=>(0,y.jsx)(i.default,{testID:`filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:b.includes(e.id)},onPress:()=>z(e.id),style:{paddingVertical:5,paddingHorizontal:10,minHeight:44,minWidth:44,justifyContent:'center',borderRadius:14,borderWidth:1,borderColor:b.includes(e.id)?o.colours.gold:o.colours.border,backgroundColor:b.includes(e.id)?o.colours.gold:'transparent'},children:(0,y.jsx)(d.T,{size:13,colour:b.includes(e.id)?o.colours.onGold:o.colours.text,children:e.short})},e.id))}),v?(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.Chip,{label:`All (${u.length})`,selected:'all'===I,onPress:()=>$('all')}),(0,y.jsx)(d.Chip,{label:`Awaiting sign-off (${O})`,selected:'awaiting'===I,onPress:()=>$('awaiting')}),(0,y.jsx)(d.Chip,{label:`Signed off (${u.length-O})`,selected:'signed-off'===I,onPress:()=>$('signed-off')})]}):null,(0,y.jsx)(r.default,{testID:"card-count",children:(0,y.jsxs)(d.Muted,{center:!0,children:[L.length," ",1===L.length?'card':'cards',b.length?` ${'free-from'===C?'free from':'containing'} ${b.map(f.allergenLabel).join('free-from'===C?' and ':' or ')}`:'']})}),L.map(e=>(0,y.jsx)(E,{c:e,actor:s,mode:l,editable:v,onPress:()=>T(e.id)},e.id)),L.length?null:(0,y.jsx)(r.default,{testID:"cards-empty",style:{alignItems:'center',paddingVertical:16},children:(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:u.length?'No cards match.':'No recipe cards yet.'})}),(0,y.jsx)(d.Sheet,{visible:!!A&&!k,onClose:()=>T(null),title:A?.dish??'',maxWidth:640,testID:"card-sheet",children:A?(0,y.jsx)(P,{card:A,mode:l,actor:'read'===l?{...s,role:'staff'}:s,onEdit:v?()=>S(A.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!k,onClose:()=>S(null),title:'new'===k?'New recipe card':`Edit: ${N?.dish??''}`,maxWidth:680,testID:"editor-sheet",children:k?(0,y.jsx)(R,{rid:e,card:N,actor:s,onDone:e=>{S(null),T(e)}},k):null})]})},Object.defineProperty(_e,"addedLabel",{enumerable:!0,get:function(){return m.addedLabel}}),Object.defineProperty(_e,"allergenSentence",{enumerable:!0,get:function(){return m.allergenSentence}}),Object.defineProperty(_e,"unsignedOldestFirst",{enumerable:!0,get:function(){return m.unsignedOldestFirst}}),_e.useUnsignedDishes=O,_e.UnsignedDishList=function({rid:e,actor:t,onClose:s,onOpenCards:l}){const i=O(e),c=(0,a.useRecipeCards)(e),[f,p]=(0,n.useState)(null),[x,b]=(0,n.useState)(null),[j,C]=(0,n.useState)(null);(0,h.useBackLayer)(!0,s);const w=x?c.find(e=>e.id===x):void 0,I=j?c.find(e=>e.id===j)??null:null,$=async e=>{try{await(0,u.recipeCards)().signOff(e.id,t),p(null)}catch(t){p({id:e.id,text:t?.message??'Could not sign off.'})}};return(0,y.jsxs)(r.default,{testID:"unsigned-list",style:{gap:12,alignItems:'stretch'},children:[(0,y.jsx)(h.BackButton,{onPress:s,testID:"unsigned-back"}),(0,y.jsx)(d.T,{center:!0,size:22,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",style:{alignSelf:'stretch'},children:"Dishes not signed off"}),(0,y.jsx)(d.Muted,{center:!0,testID:"unsigned-status",children:i.length?`${i.length} ${1===i.length?'dish':'dishes'} waiting, oldest first.`:'Every dish is signed off.'}),i.map(({item:e,card:s,at:n})=>{const i=(0,m.allergenSentence)(s?s.allergens:e.allergens),a=!!s&&(0,m.maySignOff)(t,s),c=s?(0,m.signOffBlock)(s):null;return(0,y.jsxs)(d.Card,{highlight:o.colours.amber,style:{alignItems:'center',gap:8},children:[(0,y.jsxs)(r.default,{testID:`unsigned-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}, ${(0,m.addedLabel)(n)}, ${i}`,style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,children:e.name}),(0,y.jsx)(d.T,{center:!0,children:(0,m.addedLabel)(n)}),(0,y.jsx)(d.Muted,{center:!0,children:i})]}),s&&a&&!c?(0,y.jsx)(d.Button,{testID:`unsigned-sign-${e.id}`,kind:"success",label:"Sign off",accessibilityLabel:`Sign off ${e.name} as ${t.name}`,onPress:()=>$(s),style:{alignSelf:'stretch'}}):null,s&&a&&c?(0,y.jsx)(d.Muted,{center:!0,children:c}):null,s&&!a?(0,y.jsx)(d.Muted,{center:!0,children:"Only the Head Chef, an owner or a manager can sign it off."}):null,s?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",testID:`unsigned-open-${e.id}`,label:a&&c?'Check the recipe card':'Open recipe card',accessibilityLabel:`Open the recipe card for ${e.name}`,onPress:()=>b(s.id),style:{alignSelf:'stretch'}}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(d.Muted,{center:!0,children:"No recipe card yet."}),l?(0,y.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open recipe cards",onPress:l,style:{alignSelf:'stretch'}}):null]}),f&&s&&f.id===s.id?(0,y.jsx)(d.Banner,{kind:"danger",children:f.text}):null]},e.id)}),(0,y.jsx)(d.Sheet,{visible:!!w&&!j,onClose:()=>b(null),title:w?.dish??'',maxWidth:640,testID:"unsigned-card-sheet",children:w?(0,y.jsx)(P,{card:w,actor:t,onEdit:(0,m.canEditCards)(t.role)?()=>C(w.id):void 0}):null}),(0,y.jsx)(d.Sheet,{visible:!!j,onClose:()=>C(null),title:`Edit: ${I?.dish??''}`,maxWidth:680,testID:"unsigned-editor-sheet",children:j&&I?(0,y.jsx)(R,{rid:e,card:I,actor:t,onDone:e=>{C(null),b(e)}},j):null})]})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),l=e(_r(_d[3])),i=e(_r(_d[4])),r=e(_r(_d[5])),o=_r(_d[6]),d=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),u=_r(_d[11]),f=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),y=_r(_d[17]);const j=e=>{const t=new Date(e.length<=10?`${e}T12:00:00`:e);return isNaN(+t)?e:t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})},C=e=>`\xa3${(Math.round(e)/100).toFixed(2)}`,w=e=>null==e?'Price on the board':C(e),I={example:p.EXAMPLE_TAG,imported:'Imported from the menu',new:null};function $({card:e,testID:t}){return e.signOff?(0,y.jsx)(r.default,{testID:t??'card-signed-off',accessibilityLabel:`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`,style:{alignItems:'center',gap:4,width:'100%'},children:(0,y.jsxs)(d.T,{center:!0,weight:"bold",colour:o.colours.gold,children:["Signed off by ",e.signOff.by,", ",j(e.signOff.at)]})}):(0,y.jsxs)(r.default,{testID:t??'card-signed-off',accessibilityLabel:"Not signed off yet",style:{alignItems:'center',gap:4,width:'100%'},children:[(0,y.jsx)(d.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:m.STATE_LABEL.awaiting}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:c.portionCardItemIds.includes(e.menuItemId)?'A portion card for the kitchen. The dish on the menu is not changed by this card.':e.wasLive?'Edited since the last sign-off. Guests see it as awaiting sign-off until a chef signs it again.':'This dish stays off the menu until a chef signs it off.'})]})}function D({dish:e,photo:t,height:s=180,pending:n,index:i,total:a,radius:c=12}){const h=n?{uri:n}:t?(0,u.recipeCards)().photoSource(t):null,f=i&&a?`Photo ${i} of ${a}`:'Plating photo';return h?(0,y.jsx)(l.default,{testID:i?`card-photo-${i}`:'card-photo',accessibilityLabel:`${f}${e?`: ${e}`:''}`,source:h,style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.surface2},resizeMode:"cover"}):(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:"No plating photo yet"+(e?`, ${e}`:''),style:{width:'100%',height:s,borderRadius:c,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:o.colours.gold,gap:2},children:[(0,y.jsx)(d.T,{center:!0,size:Math.min(64,Math.max(30,Math.round(.38*s))),weight:"bold",colour:o.colours.gold,children:(e.trim()[0]??'?').toUpperCase()}),s>=120?(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:o.colours.goldLight,children:"No plating photo yet"}):null]})}function T({map:e}){const t=f.ALLERGENS.filter(t=>e[t.id]).map(e=>e.id);return t.length?(0,y.jsx)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:t.map(t=>{const s='may'===e[t],n=s?`May contain ${(0,f.allergenLabel)(t).toLowerCase()}`:(0,f.allergenLabel)(t);return(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:s?n:`Contains ${(0,f.allergenLabel)(t).toLowerCase()}`,style:{paddingHorizontal:12,paddingVertical:6,borderRadius:999,borderWidth:1.5,borderColor:s?o.colours.amber:o.colours.gold,backgroundColor:s?'transparent':o.colours.gold,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"semibold",center:!0,colour:s?o.colours.amber:o.colours.onGold,children:n})},t)})}):(0,y.jsx)(d.Muted,{center:!0,children:"None of the UK 14 allergens."})}const k=({label:e,gold:t,testID:s})=>(0,y.jsx)(r.default,{testID:s,style:{paddingHorizontal:12,paddingVertical:5,borderRadius:999,borderWidth:1,borderColor:t?o.colours.gold:o.colours.accentBorder,backgroundColor:t?o.colours.goldTint:o.colours.surface,maxWidth:'100%'},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",center:!0,colour:t?o.colours.goldLight:o.colours.text,children:e})}),S=({title:e})=>(0,y.jsxs)(r.default,{style:{width:'100%',alignItems:'center',gap:4,paddingTop:4},children:[(0,y.jsx)(d.T,{size:13,weight:"semibold",center:!0,colour:o.colours.goldMuted,accessibilityRole:"header",children:e.toUpperCase()}),(0,y.jsx)(r.default,{style:{width:36,height:2,borderRadius:1,backgroundColor:o.colours.gold}})]});function P({card:e,actor:t,onEdit:s,mode:l="edit"}){const[i,a]=(0,n.useState)(null),c=(0,m.signOffBlock)(e),h=I[e.origin],f=(0,m.cardPhotos)(e),p=(0,m.maySignOff)(t,e),x=(0,b.useCardCosting)(e,t.role,l);return(0,y.jsxs)(r.default,{testID:"card-view",style:{gap:12,alignItems:'center',width:'100%'},children:[f.length?(0,y.jsx)(D,{dish:e.dish,photo:f[0],height:220,index:1,total:f.length,radius:18}):(0,y.jsx)(D,{dish:e.dish,height:180,radius:18}),f.length>1?(0,y.jsx)(d.Row,{gap:8,style:{width:'100%'},children:f.slice(1).map((t,s)=>(0,y.jsx)(r.default,{style:{flex:1,minWidth:0},children:(0,y.jsx)(D,{dish:e.dish,photo:t,height:72,index:s+2,total:f.length})},t))}):null,(0,y.jsx)(d.T,{center:!0,size:26,weight:"bold",colour:o.colours.gold,accessibilityRole:"header",children:e.dish}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[h?(0,y.jsx)(d.Badge,{label:h,kind:'example'===e.origin?'blue':'neutral'}):null,(0,y.jsx)(k,{label:e.section,gold:!0}),(0,y.jsx)(k,{label:w(e.price)}),x&&x.summary.lines.length?(0,y.jsx)(k,{testID:"card-yield",label:x.summary.batch/Math.max(1,x.summary.perPortion||1)>1.5?`Makes ${Math.round(x.summary.batch/x.summary.perPortion)} portions`:'1 portion'}):null]}),(0,y.jsx)(r.default,{accessible:!0,accessibilityLabel:`Created by ${e.createdBy||'not recorded'}`,style:{width:'100%',alignItems:'center'},children:(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,testID:"card-created-by",children:["Created by ",e.createdBy||'Not recorded']})}),(0,y.jsx)(r.default,{style:{width:'100%',paddingVertical:8,paddingHorizontal:10,borderRadius:14,borderWidth:1,borderColor:e.signOff?o.colours.accentBorder:o.colours.amber,backgroundColor:e.signOff?o.colours.accentBg:o.colours.amberBg},children:(0,y.jsx)($,{card:e,testID:"card-status"})}),(0,y.jsx)(S,{title:"Allergens"}),(0,y.jsx)(r.default,{testID:"card-allergens",style:{width:'100%'},children:(0,y.jsx)(T,{map:e.allergens})}),e.allergenNotes?(0,y.jsx)(d.Muted,{center:!0,children:e.allergenNotes}):null,e.allergensConfirmed?(0,y.jsxs)(d.Muted,{center:!0,children:["Allergen list confirmed by ",e.allergensConfirmed.by," on ",j(e.allergensConfirmed.at),"."]}):null,(0,y.jsx)(S,{title:"Ingredients"}),e.ingredients.length?(0,y.jsx)(r.default,{testID:"card-ingredients",style:{width:'100%',borderRadius:14,borderWidth:1,borderColor:o.colours.border,backgroundColor:o.colours.surface,overflow:'hidden'},children:e.ingredients.map((e,t)=>{const s=[e.qty,e.unit].filter(Boolean).join(' '),n=x?.byRecipeIng[e.id];return(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}${s?`, ${s}`:''}${n?`, ${C(n.cost)}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,paddingVertical:10,paddingHorizontal:12,borderTopWidth:t?1:0,borderColor:o.colours.border,minHeight:48},children:[(0,y.jsx)(d.T,{style:{flex:1,minWidth:0},children:e.name}),(0,y.jsxs)(r.default,{style:{alignItems:'flex-end',flexShrink:0,maxWidth:'40%'},children:[(0,y.jsx)(d.T,{weight:"semibold",colour:o.colours.goldLight,style:{textAlign:'right'},children:s||'\u2013'}),n?(0,y.jsx)(d.T,{size:o.font.small,colour:o.colours.muted,style:{textAlign:'right'},children:C(n.cost)}):null]})]},e.id)})}):(0,y.jsx)(d.Muted,{center:!0,children:"No ingredients on this card yet."}),(0,y.jsx)(S,{title:"Method"}),e.steps.length?(0,y.jsx)(r.default,{testID:"card-method",style:{width:'100%',gap:10},children:e.steps.map((e,t)=>(0,y.jsxs)(r.default,{accessible:!0,accessibilityLabel:`Step ${t+1}. ${e}`,style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,y.jsx)(r.default,{style:{width:32,height:32,borderRadius:16,borderWidth:1.5,borderColor:o.colours.gold,backgroundColor:o.colours.goldTint,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,y.jsx)(d.T,{size:o.font.small,weight:"bold",colour:o.colours.gold,children:t+1})}),(0,y.jsx)(d.T,{style:{flex:1,minWidth:0,paddingTop:4},children:e})]},t))}):(0,y.jsxs)(d.Muted,{center:!0,children:["No method yet.",(0,m.canEditCards)(t.role)?' Tap Edit to add the steps.':'']}),(0,y.jsx)(b.CardGpPanel,{card:e,actor:t,mode:l}),(0,y.jsxs)(d.Muted,{center:!0,children:["Version ",e.version," \xb7 last changed ",j(e.updatedAt)," by ",e.updatedBy]}),(0,m.canEditCards)(t.role)&&s?(0,y.jsx)(d.Button,{testID:"edit-card",kind:"secondary",label:"Edit card",accessibilityLabel:`Edit ${e.dish}`,onPress:s,style:{alignSelf:'stretch'}}):null,p&&!e.signOff?(0,y.jsxs)(r.default,{style:{gap:6,width:'100%'},children:[c?(0,y.jsx)(d.Banner,{kind:"warn",title:"Not ready to sign off",children:c}):null,(0,y.jsx)(d.Button,{testID:"sign-off",kind:"success",label:`Sign off as ${t.name}`,accessibilityLabel:`Sign off ${e.dish} as ${t.name}`,disabled:!!c,onPress:async()=>{try{await(0,u.recipeCards)().signOff(e.id,t),a(null)}catch(e){a(e?.message??'Could not sign off.')}}})]}):null,!(0,m.canEditCards)(t.role)||p||e.signOff?null:(0,y.jsx)(d.Banner,{kind:"info",title:"Sign-off",children:"Only the Head Chef, an owner or a manager can sign it off."}),i?(0,y.jsx)(d.Banner,{kind:"danger",children:i}):null]})}const v=()=>`i-${Math.random().toString(36).slice(2,9)}`,B=(e,t,s)=>e?{id:e.id,dish:e.dish,section:e.section,price:null==e.price?'':(e.price/100).toFixed(2),description:'',createdBy:e.createdBy??'',ingredients:e.ingredients.map(e=>({...e})),steps:[...e.steps],allergens:{...e.allergens},dismissed:[...e.dismissed],allergenNotes:e.allergenNotes??'',photos:(0,m.cardPhotos)(e),pending:[],confirm:!!e.allergensConfirmed}:{id:(0,m.uuid)(),dish:'',section:t,price:'',description:'',createdBy:s,ingredients:[{id:v(),name:'',qty:'',unit:''}],steps:[''],allergens:{},dismissed:[],allergenNotes:'',photos:[],pending:[],confirm:!1},L=e=>{const t=e.replace(/[\xa3\s]/g,'');if(!t)return null;const s=Number(t);return isFinite(s)&&s>=0?Math.round(100*s):'bad'};function R({rid:e,card:l,actor:c,onDone:h}){const p=(0,a.useRestaurant)(e),b=p?.sections??['Mains'],[j,C]=(0,n.useState)(()=>B(l,b[0]??'Mains',c.name)),[w,I]=(0,n.useState)(null),[$,T]=(0,n.useState)(null),[k,S]=(0,n.useState)(!1),P=e=>C(t=>({...t,...e})),R=j.ingredients.filter(e=>e.name.trim()),M={ingredients:R,allergens:j.allergens,dismissed:j.dismissed},O=(0,m.suggestAllergens)(R),E=(0,m.unresolved)(M),A=e=>{const t=j.allergens[e],s={...j.allergens};t?'contains'===t?s[e]='may':delete s[e]:s[e]='contains',P({allergens:s,dismissed:j.dismissed.filter(t=>t!==e),confirm:!1})},N=e=>{const t={...j.allergens};delete t[e],P({allergens:t,dismissed:[...new Set([...j.dismissed,e])],confirm:!1})},z=(e,t)=>P({ingredients:j.ingredients.map((s,n)=>n===e?{...s,...t}:s),confirm:!1}),W=(e,t)=>P({steps:j.steps.map((s,n)=>n===e?t:s)}),H=(e,t)=>{const s=[...j.steps],n=e+t;n<0||n>=s.length||([s[e],s[n]]=[s[n],s[e]],P({steps:s}))},_=j.photos.length+j.pending.length,F=async e=>{if(T(null),_>=m.MAX_RECIPE_PHOTOS)T('A card can hold 5 photos.');else try{const t=await(0,x.capturePlatingPhoto)(e);t&&(P({pending:[...j.pending,t]}),T(`Photo ${_+1} of ${m.MAX_RECIPE_PHOTOS}. Compressed on this device: ${t.width}\xd7${t.height}, ${(0,x.kb)(t.bytes)}${t.originalBytes?` (was ${(0,x.kb)(t.originalBytes)})`:''}.`))}catch(e){T(e?.message??'Could not read that photo.')}},[G,V]=(0,n.useState)(!1),U=j.dish||l?.dish||'this dish';return(0,y.jsxs)(r.default,{testID:"card-editor",style:{gap:12},children:[l?.signOff?(0,y.jsx)(d.Banner,{kind:"warn",title:"Saving a change clears the sign-off",children:"This card is signed off. Any change you save clears it until the Head Chef, an owner or a manager signs it off again."}):null,(0,y.jsx)(d.Field,{testID:"dish-name",label:"Dish name",value:j.dish,onChangeText:e=>P({dish:e}),placeholder:"e.g. Cullen skink"}),(0,y.jsx)(d.Field,{testID:"card-created-by-field",label:"Created by",value:j.createdBy,onChangeText:e=>P({createdBy:e}),placeholder:"Chef's name"}),l?null:(0,y.jsx)(d.Field,{testID:"dish-description",label:"Menu description (optional)",value:j.description,onChangeText:e=>P({description:e}),placeholder:"What guests read on the menu"}),(0,y.jsx)(d.T,{size:o.font.small,weight:"medium",colour:o.colours.muted,children:"Menu section"}),(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:b.map(e=>(0,y.jsx)(d.Chip,{label:e,selected:j.section===e,onPress:()=>P({section:e})},e))}),(0,y.jsx)(d.Field,{testID:"dish-price",label:"Price (\xa3)",value:j.price,onChangeText:e=>P({price:e}),placeholder:"Blank = price on the board",keyboardType:"decimal-pad"}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Photos"}),(0,y.jsx)(d.T,{center:!0,colour:o.colours.muted,children:"Up to 5 photos."}),(0,y.jsxs)(r.default,{testID:"card-photos",style:{gap:10,width:'100%',alignItems:'center'},children:[j.photos.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,photo:e,height:160,index:t+1,total:_||j.photos.length}),(0,y.jsx)(d.Button,{testID:`photo-remove-${t+1}`,kind:"ghost",label:`Remove photo ${t+1}`,accessibilityLabel:`Remove photo ${t+1} of ${U}`,onPress:()=>P({photos:j.photos.filter((e,s)=>s!==t)})})]},e)),j.pending.map((e,t)=>(0,y.jsxs)(r.default,{style:{width:'100%',gap:6,alignItems:'center'},children:[(0,y.jsx)(D,{dish:U,pending:e.dataUrl,height:160,index:j.photos.length+t+1,total:_}),(0,y.jsx)(d.Button,{testID:`photo-remove-new-${t+1}`,kind:"ghost",label:`Remove photo ${j.photos.length+t+1}`,accessibilityLabel:`Remove new photo ${j.photos.length+t+1}`,onPress:()=>P({pending:j.pending.filter((e,s)=>s!==t)})})]},`new-${t}`)),_?null:(0,y.jsx)(D,{dish:U,height:160})]}),(0,y.jsx)(d.Button,{testID:"photo-camera",kind:"secondary",label:"Take photo",accessibilityLabel:"Take a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('camera')}),(0,y.jsx)(d.Button,{testID:"photo-library",kind:"secondary",label:"Choose photo",accessibilityLabel:"Choose a photo for this recipe card",disabled:_>=m.MAX_RECIPE_PHOTOS,onPress:()=>F('library')}),$?(0,y.jsx)(r.default,{testID:"photo-info",children:(0,y.jsx)(d.Muted,{center:!0,children:$})}):(0,y.jsx)(d.Muted,{center:!0,children:'shared'===(0,u.recipeCards)().mode?'Photos are shrunk on this device, then shared with the team. Staff and guests only see them once the card is signed off.':'Photos are shrunk on this device before they are saved.'}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Ingredients"}),(0,y.jsx)(d.Muted,{children:"Quantity, unit and ingredient. We suggest allergens from the ingredient names."}),j.ingredients.map((e,n)=>{const l=e.name.trim()?(0,m.suggestAllergens)([e]):[];return(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsxs)(d.Row,{gap:6,children:[(0,y.jsx)(t.TextInput,{testID:`ing-qty-${n}`,accessibilityLabel:`Quantity ${n+1}`,value:e.qty,onChangeText:e=>z(n,{qty:e}),placeholder:"Qty",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:64}]}),(0,y.jsx)(t.TextInput,{testID:`ing-unit-${n}`,accessibilityLabel:`Unit ${n+1}`,value:e.unit,onChangeText:e=>z(n,{unit:e}),placeholder:"g / ml / each",placeholderTextColor:"#7D776C",style:[d.styles.input,{width:92}]}),(0,y.jsx)(t.TextInput,{testID:`ing-name-${n}`,accessibilityLabel:`Ingredient ${n+1}`,value:e.name,onChangeText:e=>z(n,{name:e}),placeholder:"Ingredient",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1}]}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove ingredient ${n+1}`,onPress:()=>P({ingredients:j.ingredients.filter((e,t)=>t!==n)})})]}),l.length?(0,y.jsxs)(d.Muted,{children:["Suggests: ",l.map(f.allergenLabel).join(', ')]}):null]},e.id)}),(0,y.jsx)(d.Button,{testID:"ing-add",small:!0,kind:"ghost",label:"Add ingredient",onPress:()=>P({ingredients:[...j.ingredients,{id:v(),name:'',qty:'',unit:''}]})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Method"}),j.steps.map((e,n)=>(0,y.jsxs)(d.Row,{gap:6,style:{alignItems:'flex-start'},children:[(0,y.jsx)(d.T,{colour:o.colours.gold,style:{width:20,paddingTop:10},children:n+1}),(0,y.jsx)(t.TextInput,{testID:`step-${n}`,accessibilityLabel:`Step ${n+1}`,value:e,onChangeText:e=>W(n,e),multiline:!0,placeholder:"Describe this step",placeholderTextColor:"#7D776C",style:[d.styles.input,{flex:1,minHeight:56,textAlignVertical:'top'}]}),(0,y.jsxs)(r.default,{style:{gap:4},children:[(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} up`,onPress:()=>H(n,-1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25b2"})}),(0,y.jsx)(i.default,{accessibilityLabel:`Move step ${n+1} down`,onPress:()=>H(n,1),hitSlop:6,children:(0,y.jsx)(d.T,{colour:o.colours.muted,children:"\u25bc"})}),(0,y.jsx)(s.GoldClose,{size:"sm",label:`Remove step ${n+1}`,onPress:()=>P({steps:j.steps.filter((e,t)=>t!==n)})})]})]},n)),(0,y.jsx)(d.Button,{testID:"step-add",small:!0,kind:"ghost",label:"Add step",onPress:()=>P({steps:[...j.steps,'']})}),(0,y.jsx)(d.Divider,{}),(0,y.jsx)(d.H2,{children:"Allergens (UK 14)"}),(0,y.jsx)(d.Muted,{children:"Tap to cycle: contains \u2192 may contain \u2192 none. Suggested allergens are marked \u201c?\u201d until you add or rule them out."}),E.length?(0,y.jsxs)(r.default,{testID:"allergen-suggestions",style:{gap:6},children:[(0,y.jsx)(d.Banner,{kind:"warn",title:`Check ${E.length} suggested allergen${1===E.length?'':'s'}`,children:E.map(e=>`${(0,f.allergenLabel)(e)} (from ${(0,m.suggestedBy)(R,e).join(', ')})`).join('; ')}),E.map(e=>(0,y.jsxs)(d.Row,{gap:6,wrap:!0,children:[(0,y.jsx)(d.T,{style:{flex:1},children:(0,f.allergenLabel)(e)}),(0,y.jsx)(d.Button,{testID:`suggest-add-${e}`,small:!0,label:"Contains",onPress:()=>P({allergens:{...j.allergens,[e]:'contains'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-may-${e}`,small:!0,kind:"secondary",label:"May contain",onPress:()=>P({allergens:{...j.allergens,[e]:'may'},confirm:!1})}),(0,y.jsx)(d.Button,{testID:`suggest-dismiss-${e}`,small:!0,kind:"ghost",label:"Not in this dish",onPress:()=>N(e)})]},e)),(0,y.jsx)(d.Button,{testID:"apply-suggestions",small:!0,kind:"secondary",label:"Add all suggestions as \u2018contains\u2019",onPress:()=>{const e={...j.allergens};E.forEach(t=>{e[t]='contains'}),P({allergens:e,confirm:!1})}})]}):null,(0,y.jsx)(d.Row,{wrap:!0,gap:6,children:f.ALLERGENS.map(e=>{const t=j.allergens[e.id],s=O.includes(e.id)&&!t&&!j.dismissed.includes(e.id),n='contains'===t?o.colours.redBg:'may'===t?o.colours.amberBg:o.colours.surface2,l='contains'===t?o.colours.red:'may'===t?o.colours.amber:s?o.colours.gold:o.colours.border;return(0,y.jsx)(i.default,{testID:`allergen-${e.id}`,accessibilityRole:"button",accessibilityLabel:`${e.short}: ${'contains'===t?'contains':'may'===t?'may contain':'not marked'}`,onPress:()=>A(e.id),style:{paddingVertical:6,paddingHorizontal:10,borderRadius:16,borderWidth:s?2:1,borderStyle:s?'dashed':'solid',borderColor:l,backgroundColor:n},children:(0,y.jsxs)(d.T,{size:o.font.small,colour:'contains'===t?'#FFD9D4':'may'===t?'#FFE2A8':o.colours.text,children:[e.short,'may'===t?' (may)':'',s?' ?':'']})},e.id)})}),j.dismissed.length?(0,y.jsxs)(d.Muted,{children:["Ruled out: ",j.dismissed.map(f.allergenLabel).join(', ')]}):null,(0,y.jsx)(d.Field,{testID:"allergen-notes",label:"Allergen notes (optional)",value:j.allergenNotes,onChangeText:e=>P({allergenNotes:e}),placeholder:"e.g. Cooked in the shared fryer"}),(0,y.jsxs)(i.default,{testID:"confirm-allergens",accessibilityRole:"checkbox",accessibilityState:{checked:j.confirm,disabled:E.length>0},disabled:E.length>0,onPress:()=>P({confirm:!j.confirm}),style:{flexDirection:'row',gap:10,alignItems:'center',padding:10,borderRadius:10,borderWidth:1,borderColor:j.confirm?o.colours.ok:o.colours.border,opacity:E.length?.5:1},children:[(0,y.jsx)(r.default,{style:{width:22,height:22,borderRadius:4,borderWidth:2,borderColor:j.confirm?o.colours.ok:o.colours.muted,alignItems:'center',justifyContent:'center',backgroundColor:j.confirm?o.colours.okBg:'transparent'},children:j.confirm?(0,y.jsx)(d.T,{colour:o.colours.ok,children:"\u2713"}):null}),(0,y.jsx)(d.T,{style:{flex:1},children:E.length?'Check the suggested allergens above first':`I have checked the allergen list against the ingredients (${c.name})`})]}),w?(0,y.jsx)(d.Banner,{kind:"danger",children:w}):null,(0,y.jsx)(d.Button,{testID:"card-save",label:G?'Saving\u2026':l?'Save changes':'Save card',disabled:G,onPress:async()=>{I(null);const t=L(j.price);if(!j.dish.trim())return I('Give the dish a name.');if('bad'===t)return I('Price should be in pounds, e.g. 14.50 (or leave it blank for "price on the board").');const s=(0,u.recipeCards)();V(!0);try{const n=[...j.photos];for(const t of j.pending){if(n.length>=m.MAX_RECIPE_PHOTOS)break;n.push(await s.savePhoto(e,j.id,t))}const i=j.steps.map(e=>e.trim()).filter(Boolean),r=j.createdBy.trim(),o={dish:j.dish.trim(),section:j.section,price:t,ingredients:R.map(e=>({...e,name:e.name.trim(),qty:e.qty.trim(),unit:e.unit.trim()})),steps:i,allergens:j.allergens,dismissed:j.dismissed,allergenNotes:j.allergenNotes.trim()||void 0,photo:n[0],photos:n,createdBy:r||void 0};if(l)await s.update(l.id,{...o,confirmAllergens:j.confirm},c),h(l.id);else{const t=await s.create(e,{...o,id:j.id,description:j.description.trim()||void 0},c);j.confirm&&await s.update(t.id,{confirmAllergens:!0},c),h(t.id)}}catch(e){I(e?.message??'Could not save the card.')}finally{V(!1)}}}),(0,y.jsx)(d.Muted,{center:!0,children:(0,m.maySignOff)(c,{createdBy:j.createdBy||c.name,createdByRole:c.role})?'After saving, sign the card off so it goes live.':'After saving, the Head Chef, an owner or a manager signs it off before it goes live.'}),l?k?(0,y.jsxs)(d.Row,{gap:8,children:[(0,y.jsx)(d.Button,{testID:"card-delete-yes",small:!0,kind:"danger",label:"Yes, remove this dish",onPress:async()=>{if(l)try{await(0,u.recipeCards)().remove(l.id,c),h(null)}catch(e){I(e?.message??'Could not remove the card.')}}}),(0,y.jsx)(d.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>S(!1)})]}):(0,y.jsx)(d.Button,{testID:"card-delete",small:!0,kind:"ghost",label:"Remove card and dish from the menu",onPress:()=>S(!0)}):null]})}const M=e=>e.replace(/ \xb7 Starter$/,' \xb7 1').replace(/ \xb7 Main$/,' \xb7 2');function O(e){const t=(0,a.useAllMenu)(e),s=(0,a.useRecipeCards)(e);return(0,n.useMemo)(()=>{const e=new Map(s.map(e=>[e.menuItemId,e]));return(0,m.unsignedOldestFirst)(t,t=>e.get(t.id)??(t.recipeCardId?s.find(e=>e.id===t.recipeCardId):void 0))},[t,s])}function E({c:e,actor:t,mode:s,editable:n,onPress:l}){const a=(0,m.cardPhotos)(e),c=(0,b.useCardCosting)(e,'read'===s?'staff':t.role,s),h=f.ALLERGENS.filter(t=>e.allergens[t.id]).length,u=c?.summary.gp,x=c?.summary.tone,C='ok'===x?o.colours.ok:'amber'===x?o.colours.amber:'red'===x?o.colours.red:o.colours.muted,I=`${e.dish}, ${e.section}, ${w(e.price)}, ${h?`${h} allergen${1===h?'':'s'}`:'no allergens marked'}${null!=u?`, GP ${u.toFixed(1)} percent`:''}, created by ${e.createdBy||'not recorded'}, ${e.signOff?`signed off by ${e.signOff.by}`:'awaiting sign-off'}`;return(0,y.jsxs)(i.default,{testID:`card-${e.menuItemId}`,accessibilityRole:"button",accessibilityLabel:I,onPress:l,style:({pressed:t})=>({width:'100%',minHeight:48,flexDirection:'row',gap:12,alignItems:'center',padding:10,borderRadius:18,borderWidth:1,borderColor:!e.signOff&&n?o.colours.amber:o.colours.accentBorder,backgroundColor:t?o.colours.tilePressed:o.colours.tile}),children:[(0,y.jsx)(r.default,{style:{width:84,flexShrink:0},children:(0,y.jsx)(D,{dish:e.dish,photo:a[0],height:84,radius:14})}),(0,y.jsxs)(r.default,{style:{flex:1,minWidth:0,gap:4,alignItems:'center'},children:[(0,y.jsx)(d.T,{center:!0,weight:"bold",size:18,colour:o.colours.gold,children:e.dish}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,colour:o.colours.muted,children:[e.section," \xb7 ",w(e.price),'example'===e.origin?` \xb7 ${p.EXAMPLE_TAG}`:'']}),(0,y.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,y.jsx)(k,{label:h?`${h} allergen${1===h?'':'s'}`:'No allergens marked'}),null!=u?(0,y.jsx)(r.default,{testID:`card-gp-${e.menuItemId}`,style:{paddingHorizontal:10,paddingVertical:4,borderRadius:999,borderWidth:1.5,borderColor:C},children:(0,y.jsxs)(d.T,{size:o.font.small,weight:"bold",colour:C,children:["GP ",u.toFixed(1),"%"]})}):null]}),(0,y.jsxs)(d.T,{center:!0,size:o.font.small,testID:`card-created-${e.menuItemId}`,children:["Created by ",e.createdBy||'Not recorded']}),(0,y.jsx)(d.T,{center:!0,size:o.font.small,colour:e.signOff?o.colours.goldLight:o.colours.amber,children:e.signOff?`Signed off by ${e.signOff.by}, ${j(e.signOff.at)}`:m.STATE_LABEL.awaiting})]})]})}},1176,[827,796,34,336,402,102,821,794,874,1177,1056,882,861,863,885,1109,1178,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"portionCardItemIds",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"OFF_CARD_LIST",{enumerable:!0,get:function(){return n}});const t=['a-langoustines-starter','a-langoustines-main','a-moules-starter','a-moules-main'],n=new Set(['a-scallops'])},1177,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CREATOR_TITLE",{enumerable:!0,get:function(){return n}}),e.DishCreator=function(n){return null},e.useCardCosting=function(...n){return null},e.CardGpPanel=function(n){return null};const n='New dish creator'},1178,[]); +__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])},1179,[858]); +__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 R}}),Object.defineProperty(_e,"CHANNELS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"dmId",{enumerable:!0,get:function(){return w.dmId}}),Object.defineProperty(_e,"inChannel",{enumerable:!0,get:function(){return w.inChannel}}),_e.autoPost=function(e,t){const n=new Date(globalThis.__ccNow??Date.now()).toISOString();(Array.isArray(e)?e:[e]).forEach(e=>f.useOwner.getState().sys(e,t,n))},_e.ensureChat=D,_e.useChatUnread=A,Object.defineProperty(_e,"DISPLAY_DEVICE_ID",{enumerable:!0,get:function(){return B}}),_e.chatSender=L,_e.Chat=function({go:e}){return(0,O.jsx)(z,{children:(0,O.jsx)(K,{go:e})})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),a=r(d[3]),o=r(d[4]),i=r(d[5]),l=r(d[6]),c=e(r(d[7])),h=e(r(d[8])),u=e(r(d[9])),m=r(d[10]),f=r(d[11]),p=r(d[12]),b=r(d[13]),x=r(d[14]),j=r(d[15]),y=r(d[16]),w=r(d[17]),C=r(d[18]),v=r(d[19]),S=r(d[20]),k=r(d[21]),O=r(d[22]);const R=(0,i.createContext)(null);function I(e){const t=(0,x.useCtx)(e),n=(0,i.useContext)(R);return n?{...t,meId:n.meId,role:n.role}:t}const T=[{id:'all',name:'Team',icon:'\ud83d\udce2'},{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\udd11'}],M=[],P=e=>(e??'').replace(' (example)','');function D(e){if(a.LIVE_VENUE_BUILD)return;if(o.IS_WILDINGS)return;const t=f.useOwner.getState();if(t.chat.some(e=>'m-seed-all'===e.id&&/this phone only/.test(e.text??''))&&f.useOwner.getState().chatPatch('m-seed-all',{text:'Welcome to the team chat on CoverCharge.'}),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};f.useOwner.setState({chat:[n('all',5,'Welcome to the team chat on CoverCharge.',{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 A(){const{meId:e}=I(3e4),{role:t}=I(3e4),n=(0,f.useOwner)(e=>e.chat),s=(0,f.useOwner)(e=>e.staff),a=(0,f.useOwner)(t=>t.chatMuted[e]??M),o=(0,i.useMemo)(()=>E(s,e,t),[s,e,t]);return(0,i.useMemo)(()=>{const t={};return n.forEach(n=>{n.removed||n.from===e||n.seenBy.includes(e)||!(0,w.inChannel)(n.ch,o)||(t[n.ch]=(t[n.ch]??0)+1)}),{by:t,total:Object.entries(t).filter(([e])=>!a.includes(e)).reduce((e,[,t])=>e+t,0)}},[n,e,a,o])}function E(e,t,n){if(t===j.CAR_DEVICE_ID)return{id:t,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''};if('display-device'===t)return{id:t,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''};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:''}}const B='display-device';function L(e,t){return e===j.CAR_DEVICE_ID?{id:e,name:j.CAR_ACTOR,role:'owner',job:'',active:!0,level:'Owner',dept:''}:e===B?{id:e,name:'Display',role:'owner',job:'',active:!0,level:'Owner',dept:''}:t.find(t=>t.id===e)}class z extends i.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,O.jsxs)(u.default,{style:{gap:10},testID:"chat-error",children:[(0,O.jsx)(m.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,O.jsx)(m.Button,{kind:"secondary",label:"Back to chats",onPress:()=>{this.setState({err:null}),this.props.onBack?.()}})]}):this.props.children}}const $={owner:b.colours.gold,manager:b.colours.blue,staff:'#7a6f5c'};function _({s:e,size:t=34}){return e?(0,O.jsx)(y.StaffAvatar,{id:e.id,size:t}):(0,O.jsx)(u.default,{style:{width:t,height:t,borderRadius:t/2,backgroundColor:(0,n.soutersSurface)('#333'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:.38*t,weight:"bold",colour:"#111",children:"CC"})})}const N=[{caption:'Specials board',tone:'#4A3A22'},{caption:'Plating: Cullen skink',tone:'#3E2A2A'},{caption:'Delivery arrived',tone:'#40362A'},{caption:'Spillage by the bar',tone:'#2E2E40'}],W=['\ud83d\udc4d','\u2764\ufe0f','\ud83d\ude04','\ud83d\udc4f','\ud83d\udd25'];function H({ch:e,go:a,back:o}){const{now:j,meId:S,role:R,today:M}=I(1e4),D=(0,f.useOwner)(e=>e.staff),A=(0,f.useOwner)(e=>e.chat),E=(0,f.useOwner)(e=>e.shifts),B=(0,f.useOwner)(e=>e.leave),z=A.filter(t=>t.ch===e).sort((e,t)=>e.at.localeCompare(t.at)),[H,K]=(D.find(e=>e.id===S),(0,i.useState)('')),[V,U]=(0,i.useState)(null),[Y,q]=(0,i.useState)(!1),[F,G]=(0,i.useState)(!1),J=e.startsWith('dm:')?e.split(':').slice(1).length:D.filter(t=>t.active&&(0,w.inChannel)(e,t)).length;(0,i.useEffect)(()=>{const t=f.useOwner.getState().chat.some(t=>t.ch===e&&t.from!==S&&!t.seenBy.includes(S));f.useOwner.getState().chatSeen(e,S),t&&(0,v.markChatRead)(S,e)},[e,S,z.length]);const Q=t=>f.useOwner.getState().chatSend({ch:e,from:S,at:j.toISOString(),...t});(0,l.useBackLayer)(!0,o);const X=z.filter(e=>e.pinned&&!e.removed),Z=e.startsWith('dm:')?D.find(t=>t.id===e.split(':').slice(1).find(e=>e!==S)):void 0,ee=Z?.name.replace(' (example)','')??T.find(t=>t.id===e)?.name??'Private message',te=t.AVATAR_OPTIONS.find(t=>t.id===('kitchen'===e?'spatula':'bar'===e?'espresso-martini':'waves')),ne=(0,C.useChatSync)(e=>e.synced),se=(0,k.workingShifts)(E,B).filter(e=>e.staffId===S&&e.published&&e.date>=M).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,10);return(0,O.jsxs)(u.default,{style:{gap:8},children:[(0,O.jsxs)(u.default,{testID:"chat-thread-header",style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(u.default,{style:{alignSelf:'flex-start'},children:(0,O.jsx)(l.BackButton,{onPress:o,testID:"chat-thread-back"})}),Z?(0,O.jsx)(y.StaffAvatar,{id:Z.id,size:88}):(0,O.jsx)(c.default,{testID:"chat-group-avatar",source:{uri:te.dataUrl},style:{width:88,height:88},accessibilityLabel:`${ee} group avatar`}),(0,O.jsx)(m.T,{center:!0,weight:"semibold",size:22,children:ee}),(0,O.jsxs)(m.Muted,{center:!0,children:[J," ",1===J?'member':'members']})]}),X.map(e=>(0,O.jsxs)(m.Card,{highlight:b.colours.gold,children:[(0,O.jsxs)(m.T,{size:12,colour:b.colours.gold,children:["\ud83d\udccc ",'system'===e.from?'Pinned note':`Pinned by ${P(D.find(t=>t.id===e.from)?.name)}`]}),(0,O.jsx)(m.T,{size:14,children:e.text})]},e.id)),z.map((t,s)=>{const o=L(t.from,D),i=t.from===S,l=t.seenBy.filter(e=>e!==t.from).length,c=0===s||t.at.slice(0,10)!==z[s-1].at.slice(0,10);return'system'===t.from?(0,O.jsxs)(u.default,{style:{alignItems:'center',gap:2},children:[c?(0,O.jsx)(m.Muted,{children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsx)(u.default,{style:{backgroundColor:(0,n.soutersSurface)('#1c1a14'),borderRadius:10,paddingHorizontal:10,paddingVertical:5,borderWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.T,{size:13,colour:/Allergy|86|Sold out/.test(t.text??'')?b.colours.amber:b.colours.muted,children:["CoverCharge \xb7 ",t.text," \xb7 ",(0,p.hm)(new Date(t.at))]})})]},t.id):(0,O.jsxs)(u.default,{style:{gap:2},children:[c?(0,O.jsx)(m.Muted,{center:!0,children:(0,p.niceDate)(new Date(t.at))}):null,(0,O.jsxs)(m.Row,{style:{alignItems:'flex-start',flexDirection:i?'row-reverse':'row'},children:[(0,O.jsx)(_,{s:o}),(0,O.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message from ${o?.name}`,onPress:()=>U(V===t.id?null:t.id),style:{maxWidth:'78%',backgroundColor:i?'#3a2f12':b.colours.surface,borderRadius:14,padding:9,borderWidth:1,borderColor:t.pinned?b.colours.gold:b.colours.border,gap:3},children:[(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:o?$[o.role]:b.colours.muted,children:P(o?.name)}),(0,O.jsxs)(m.T,{size:11,colour:b.colours.muted,children:[o?f.ROLE_LABEL[o.role]:''," \xb7 ",(0,p.hm)(new Date(t.at))]})]}),t.removed?(0,O.jsx)(m.T,{size:14,colour:b.colours.muted,children:"Message removed by the owner"}):(0,O.jsxs)(O.Fragment,{children:[t.photo?(0,O.jsx)(u.default,{style:{width:200,height:120,borderRadius:10,backgroundColor:t.photo.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsxs)(m.T,{size:12,children:[t.photo.caption," (example image)"]})}):null,t.text?(0,O.jsx)(m.T,{size:15,children:t.text}):null,'cover'===t.action?(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Open cover requests on the rota",onPress:()=>a('more','rota')}):null]}),Object.entries(t.reactions).filter(([,e])=>e.length).length?(0,O.jsx)(m.Row,{wrap:!0,gap:4,children:Object.entries(t.reactions).filter(([,e])=>e.length).map(([e,t])=>(0,O.jsx)(u.default,{style:{borderRadius:10,paddingHorizontal:6,backgroundColor:t.includes(S)?'#4a3c16':'#222'},children:(0,O.jsxs)(m.T,{size:12,children:[e," ",t.length]})},e))}):null,i?(0,O.jsx)(m.T,{size:11,colour:b.colours.muted,children:l?`Seen by ${l}`:'Sent'}):null]})]}),V!==t.id||t.removed?null:(0,O.jsxs)(m.Row,{wrap:!0,gap:6,style:{justifyContent:i?'flex-end':'flex-start',paddingLeft:i?0:40},children:[W.map(e=>(0,O.jsx)(h.default,{accessibilityLabel:`React ${e}`,onPress:()=>{f.useOwner.getState().chatReact(t.id,e,S),U(null)},style:{padding:4},children:(0,O.jsx)(m.T,{size:20,children:e})},e)),'staff'===R||e.startsWith('dm:')?null:(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:t.pinned?'Unpin':'Pin',onPress:()=>{f.useOwner.getState().chatPatch(t.id,{pinned:!t.pinned}),U(null)}}),'owner'!==R||i?null:(0,O.jsx)(m.Button,{small:!0,kind:"danger",label:"Remove",onPress:()=>{f.useOwner.getState().chatPatch(t.id,{removed:!0,pinned:!1}),U(null)}})]})]},t.id)}),(0,O.jsxs)(m.Row,{gap:6,children:[(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Send a photo",onPress:()=>q(!0),style:{padding:8},children:(0,O.jsx)(m.T,{size:20,children:"\ud83c\udf9e\ufe0f"})}),(0,O.jsx)(s.TextInput,{accessibilityLabel:"Message",placeholder:`Message ${ee}`,placeholderTextColor:"#7D776C",value:H,onChangeText:K,style:[m.styles.input,{flex:1,minWidth:0,width:0}]}),(0,O.jsx)(m.Button,{small:!0,label:"Send",disabled:!H.trim(),onPress:()=>{Q({text:H.trim()}),K('')}})]}),(0,O.jsx)(m.Row,{wrap:!0,gap:6,children:(0,O.jsx)(m.Button,{small:!0,kind:"secondary",label:"Ask for shift cover",onPress:()=>G(!0)})}),ne?null:(0,O.jsx)(m.Muted,{center:!0,children:"Not shared yet: this message stays on this phone only. Nobody else will see it."}),(0,O.jsx)(m.Sheet,{visible:Y,onClose:()=>q(!1),title:"Send a photo",children:(0,O.jsx)(m.Row,{wrap:!0,gap:8,children:N.map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.caption,onPress:()=>{Q({photo:e}),q(!1)},style:{width:'47%',height:100,borderRadius:10,backgroundColor:e.tone,justifyContent:'flex-end',padding:6},children:(0,O.jsx)(m.T,{size:12,children:e.caption})},e.caption))})}),(0,O.jsxs)(m.Sheet,{visible:F,onClose:()=>G(!1),title:"Ask for shift cover",children:[se.length?null:(0,O.jsx)(m.Muted,{children:"You have no shifts on the rota this week."}),se.map(e=>(0,O.jsx)(m.Button,{kind:"secondary",label:`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`,onPress:()=>{const t=`${x.DAY3[e.day]} ${Number(e.date.slice(8))} ${(0,x.fmtH)(e.start)}\u2013${(0,x.fmtH)(e.end)}`;f.useOwner.getState().addSwap({shiftId:e.id,fromId:S,kind:'cover',note:`Cover asked in chat for ${t}`}),Q({text:`Can anyone cover my ${t} shift? I\u2019ve added a cover request on the rota.`,action:'cover'}),G(!1)}},e.id)),(0,O.jsx)(m.Muted,{children:"Creates a cover request in Rota \u203a Swaps & leave for a manager to approve."})]})]})}function K({go:e}){const{now:t,meId:s,role:a}=I(3e4),o=(0,f.useOwner)(e=>e.staff),l=(0,f.useOwner)(e=>e.chat),c=(0,f.useOwner)(e=>e.chatMuted[s]??M),{by:x,total:j}=A(),y=(0,C.useChatSync)(e=>e.synced),k=(0,C.useChatSync)(e=>e.error),R=(0,w.useKitchenExtra)(e=>e.extra),[B,$]=(0,i.useState)(null),[N,W]=(0,i.useState)(!1),[K,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{D(t)},[]),(0,i.useEffect)(()=>{$(null)},[s]);const U=(0,S.useChatOpen)(e=>e.ch);(0,i.useEffect)(()=>{if(!U)return;const e=U.startsWith('dm:')||T.some(e=>e.id===U)?U:null;e&&(0,w.inChannel)(e,E(o,s,a))&&$(e),S.useChatOpen.getState().request(void 0)},[U,s,a,o]);const Y=E(o,s,a);if(B)return(0,O.jsx)(z,{resetKey:B,onBack:()=>$(null),children:(0,O.jsx)(H,{ch:B,go:e,back:()=>$(null)})});const q=e=>l.filter(t=>t.ch===e).sort((e,t)=>t.at.localeCompare(e.at))[0],F=o.filter(e=>e.active&&e.id!==s).map(e=>{const t=(0,w.dmId)(s,e.id);return{x:e,id:t,u:x[t]??0,l:q(t)?.at??''}}).sort((e,t)=>t.u-e.u||t.l.localeCompare(e.l)||P(e.x.name).localeCompare(P(t.x.name))),G='owner'===a||'manager'===a,J=({id:e,name:t,icon:s,avatar:a})=>{const i=q(e),l=x[e]??0,f=c.includes(e);return(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Open ${t}`,onPress:()=>$(e),style:{padding:12,borderTopWidth:1,borderColor:b.colours.border},children:(0,O.jsxs)(m.Row,{children:[a?(0,O.jsx)(_,{s:a}):(0,O.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,backgroundColor:(0,n.soutersSurface)('#222'),alignItems:'center',justifyContent:'center'},children:(0,O.jsx)(m.T,{size:16,children:s})}),(0,O.jsxs)(u.default,{style:{flex:1},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{weight:l?'bold':'medium',children:[t,f?' \ud83d\udd15':'']}),i?(0,O.jsx)(m.Muted,{children:(0,p.hm)(new Date(i.at))}):null]}),(0,O.jsx)(m.Muted,{numberOfLines:1,children:i?i.removed?'Message removed':`${'system'===i.from?'CoverCharge':P(L(i.from,o)?.name)}: ${i.text??'Photo'}`:'No messages yet'})]}),l?(0,O.jsx)(u.default,{style:{backgroundColor:f?'#555':b.colours.red,borderRadius:10,minWidth:20,height:20,alignItems:'center',justifyContent:'center',paddingHorizontal:5},children:(0,O.jsx)(m.T,{size:11,weight:"bold",children:l})}):null]})})};return(0,O.jsxs)(u.default,{style:{gap:10},children:[y?(0,O.jsx)(u.default,{testID:"chat-synced",children:(0,O.jsx)(m.Muted,{children:"\u2713 Shared with the team: messages reach everyone in the chat on their own phone."})}):(0,O.jsx)(m.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."}),y&&k?(0,O.jsx)(u.default,{testID:"chat-sync-error",children:(0,O.jsx)(m.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,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.Muted,{children:["Signed in as ",P(Y?.name)," (",'Head Chef'===Y?.level?'Head Chef':f.ROLE_LABEL[a],")"]}),(0,O.jsxs)(m.Row,{gap:6,children:[j||Object.keys(x).length?(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"chat-mark-all",accessibilityLabel:"Mark all chats as read",onPress:()=>(0,v.markChatRead)(s,'*')}):null,(0,O.jsx)(m.Button,{small:!0,kind:"ghost",label:"Chat settings",onPress:()=>V(!0)})]})]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{padding:10},children:"TEAM CHATS"}),T.filter(e=>'all'===e.id||(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsx)(J,{id:e.id,name:e.pinned?`${e.name} \ud83d\udccc`:e.name,icon:e.icon},e.id))]}),(0,O.jsxs)(u.default,{style:{borderRadius:14,borderWidth:1,borderColor:b.colours.border,backgroundColor:b.colours.surface,overflow:'hidden'},children:[(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between',padding:10},children:[(0,O.jsx)(m.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"PRIVATE MESSAGES"}),(0,O.jsx)(m.Button,{small:!0,kind:"success",label:"New message",testID:"chat-new-pm",onPress:()=>W(!0)})]}),F.map(e=>(0,O.jsx)(J,{id:e.id,name:P(e.x.name),avatar:e.x},e.id)),F.length?null:(0,O.jsx)(m.Muted,{style:{padding:10},children:"Nobody else on the team yet."})]}),(0,O.jsx)(m.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,O.jsx)(m.Sheet,{visible:N,onClose:()=>W(!1),title:"New private message",children:o.filter(e=>e.active&&e.id!==s).map(e=>(0,O.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:`Message ${e.name}`,onPress:()=>{W(!1),$((0,w.dmId)(s,e.id))},style:{paddingVertical:8},children:(0,O.jsxs)(m.Row,{children:[(0,O.jsx)(_,{s:e}),(0,O.jsxs)(u.default,{children:[(0,O.jsx)(m.T,{children:P(e.name)}),(0,O.jsxs)(m.Muted,{children:[f.ROLE_LABEL[e.role]," \xb7 ",e.job]})]})]})},e.id))}),(0,O.jsxs)(m.Sheet,{visible:K,onClose:()=>V(!1),title:"Chat settings",children:[(0,O.jsx)(m.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,O.jsx)(m.T,{weight:"semibold",children:"Mute channels"}),T.filter(e=>(0,w.inChannel)(e.id,Y)).map(e=>(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[e.icon," ",e.name]}),(0,O.jsx)(m.Toggle,{label:`Mute ${e.name}`,value:c.includes(e.id),onChange:()=>f.useOwner.getState().chatMute(s,e.id)})]},e.id)),(0,O.jsx)(m.Muted,{children:"Muted channels don\u2019t count towards the tab badge. The Kitchen chat can be muted but not left."}),G?(0,O.jsxs)(u.default,{style:{gap:6},testID:"kitchen-members",children:[(0,O.jsx)(m.T,{weight:"semibold",children:"Kitchen chat members"}),(0,O.jsxs)(m.Muted,{children:["Automatic: owners, managers, head chefs and kitchen staff (chefs, kitchen porters). Change who else is in it here",y?'':'; saved on this device for now',"."]}),o.filter(e=>e.active).map(e=>{const t=R[e.id]??(0,w.kitchenByRule)(e);return(0,O.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,O.jsxs)(m.T,{children:[P(e.name),null!=R[e.id]?' (changed)':'']}),(0,O.jsx)(m.Toggle,{label:`Kitchen chat: ${P(e.name)}`,value:t,onChange:t=>w.useKitchenExtra.getState().set(e.id,t===(0,w.kitchenByRule)(e)?null:t)})]},e.id)})]}):null]})]})}},1180,[928,828,827,837,5,34,1056,336,402,102,794,891,858,821,1088,1025,925,1047,1046,987,1113,1098,25]); +__d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergyChain=j,_e.BookingAllergyChain=function({b:l,me:t,readOnly:k}){const p=(0,i.useOrders)(l.restaurantId),S=(0,o.useStore)(e=>e.ackBookingAllergy);if(!l.allergies.length)return null;const A=p.find(e=>e.allergies.length&&!['cancelled','closed'].includes(e.status)&&(e.bookingId===l.id||!e.bookingId&&(0,c.linkedBooking)(e,[l])?.id===l.id));if(A)return(0,h.jsx)(j,{o:A,me:t,readOnly:k,compact:!0});const I={booked:l.allergyAck,ordered:void 0,kitchen:void 0,pass:void 0,table:void 0};return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:l.allergyAck?u.colours.border:u.colours.red,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:"#FFD9D4",children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:l.allergyAck?'amber':'red',label:(l.allergyAck?1:0)+" of 5"})]}),(0,h.jsx)(y,{chain:I,next:l.allergyAck?null:'booked',testID:`allergy-steps-${l.ref}`}),l.allergyAck?(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:l.allergyAck.by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:["1. Booked: ",b(l.allergyAck.by)," at ",x(l.allergyAck.at),". Steps 2 to 5 are signed on the table's order."]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(n.T,{size:13,children:"Next: 1. Booked. Allergy recorded (who took it)."}),k?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off Booked on ${l.ref}`,disabled:!t.trim(),onPress:()=>S(l.id,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]})]})]})};var e=r(d[0]);r(d[1]);var l,t=r(d[2]),s=(l=t)&&l.__esModule?l:{default:l},n=r(d[3]),i=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),f=r(d[8]),h=r(d[9]);const x=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),b=e=>e.replace(' (example)','');function y({chain:e,next:l,testID:t}){return(0,h.jsx)(s.default,{testID:t,accessibilityLabel:`Allergen sign-off ${c.CHAIN_STEPS.filter(l=>e[l.id]).length} of 5`,style:{flexDirection:'row',alignItems:'flex-start'},children:c.CHAIN_STEPS.map((t,i)=>{const o=!!e[t.id],f=l===t.id,y=o?u.colours.ok:f?u.colours.gold:u.colours.border,j=0===i?'flex-start':i===c.CHAIN_STEPS.length-1?'flex-end':'center',k=(0,h.jsxs)(s.default,{style:{width:'200%',alignSelf:j,alignItems:j},children:[(0,h.jsx)(n.T,{size:11,weight:f?'semibold':'regular',colour:o?u.colours.text:f?u.colours.gold:u.colours.muted,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:t.label}),e[t.id]?(0,h.jsxs)(n.T,{size:10,colour:u.colours.muted,numberOfLines:1,style:{textAlign:0===i?'left':i===c.CHAIN_STEPS.length-1?'right':'center'},children:[b(e[t.id].by).split(' ')[0]," ",x(e[t.id].at)]}):null]}),p=i%2==1;return(0,h.jsxs)(s.default,{style:{flex:1,alignItems:'center'},children:[(0,h.jsx)(s.default,{style:{minHeight:30,justifyContent:'flex-end',alignSelf:'stretch',alignItems:j},children:p?k:null}),(0,h.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',width:'100%',marginVertical:2},children:[(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i?o||f?y:u.colours.border:'transparent'}}),(0,h.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,borderWidth:2,borderColor:y,backgroundColor:o?u.colours.ok:'transparent',alignItems:'center',justifyContent:'center'},children:(0,h.jsx)(n.T,{size:12,weight:"bold",colour:o?'#0B0B0B':f?u.colours.gold:u.colours.muted,children:o?'\u2713':String(t.n)})}),(0,h.jsx)(s.default,{style:{flex:1,height:2,backgroundColor:i<4?o?u.colours.ok:u.colours.border:'transparent'}})]}),(0,h.jsx)(s.default,{style:{minHeight:30,alignSelf:'stretch',alignItems:j},children:p?null:k})]},t.id)})})}function j({o:l,me:t,readOnly:j,compact:k}){const p=(0,i.useBookings)(l.restaurantId),S=(0,o.useStore)(e=>e.signAllergyStep);if(!l.allergies.length)return null;const A=(0,c.linkedBooking)(l,p),I=(0,c.orderChain)(l,A),C=(0,c.nextStep)(l,A),w=c.CHAIN_STEPS.filter(e=>I[e.id]).length,T=C?(0,c.stepInfo)(C):null,B='table'===C&&!['ready','served','collected'].includes(l.status);return(0,h.jsxs)(s.default,{testID:`allergy-chain-${l.ref}`,style:{gap:6,padding:8,borderRadius:10,borderWidth:1,borderColor:C?u.colours.red:u.colours.ok,backgroundColor:(0,e.soutersSurface)('#140f0e')},children:[(0,h.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(n.T,{size:13,weight:"semibold",colour:C?'#FFD9D4':'#E2C489',children:["Allergen sign-off \xb7 ",l.ref]}),(0,h.jsx)(n.Badge,{kind:C?'red':'ok',label:C?`${w} of 5`:'Complete'})]}),(0,h.jsx)(y,{chain:I,next:C,testID:`allergy-steps-${l.ref}`}),k?null:c.CHAIN_STEPS.filter(e=>I[e.id]).map(e=>(0,h.jsxs)(n.Row,{gap:6,children:[(0,h.jsx)(f.StaffAvatar,{name:I[e.id].by,size:20,ring:!1}),(0,h.jsxs)(n.Muted,{style:{flex:1},children:[e.n,". ",e.label,": ",b(I[e.id].by)," at ",x(I[e.id].at)]})]},e.id)),T?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(n.T,{size:13,children:["Next: ",T.n,". ",T.label,". ",T.what,"."]}),j?null:(0,h.jsxs)(n.Row,{wrap:!0,gap:8,children:[(0,h.jsx)(n.Button,{small:!0,kind:"danger",label:"Sign off",testID:`sign-off-${l.ref}`,accessibilityLabel:`Sign off ${T.label} on ${l.ref}`,disabled:!t.trim()||B,onPress:()=>S(l.id,C,t)}),(0,h.jsxs)(n.Muted,{children:["as ",b(t)]})]}),B?(0,h.jsx)(n.Muted,{children:"Signed off at the pass. The table step is signed when the dish is served."}):(0,h.jsx)(n.Muted,{children:"The ticket can't move on until this step is signed off."})]}):(0,h.jsx)(n.Muted,{children:"All five steps signed off. The full chain is in the allergen audit log."})]})}},1181,[828,34,102,794,876,831,869,821,925,25]); +__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=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return!1!==e?.settings?.games},_e.useGameClock=I,_e.usePlayable=function(e,t){return(0,y.gamePlayable)(I(e,t))},Object.defineProperty(_e,"LENNY_GAME_URL",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"validGameUrl",{enumerable:!0,get:function(){return C}}),_e.gameBase=function(){const e=b.useStore.getState().restaurants.find(e=>e.id===p.VENUE_RID);return C(e?.settings?.gameUrl)??v},_e.BreakRoomCard=function({staffId:e,name:t,now:s}){const n=(0,b.useStore)(e=>!1!==e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.games),[o,l]=(0,r.useState)(!1),c=I(e,s),u=(0,y.gamePlayable)(c);return n?(0,w.jsxs)(d.Card,{children:[(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(d.T,{size:13,colour:u?x.colours.ok:x.colours.muted,children:u?'Open':'Locked'})]}),(0,w.jsx)(d.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."}),u?null:(0,w.jsx)(d.Muted,{testID:"break-room-locked-text",children:y.GAME_LOCKED_TEXT}),(0,w.jsx)(d.Button,{testID:"break-room-open",kind:"secondary",label:"Open the Break room",onPress:()=>l(!0)}),o?(0,w.jsx)(R,{staffId:e,name:t,playable:u,clock:c,onClose:()=>l(!1)}):null]}):null},Object.defineProperty(_e,"displayName",{enumerable:!0,get:function(){return T}}),_e.BreakRoom=R;var t=_r(_d[0]),s=_r(_d[1]),r=_r(_d[2]),n=e(r),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),c=e(_r(_d[6])),u=_r(_d[7]),d=_r(_d[8]),f=_r(_d[9]),m=_r(_d[10]),y=_r(_d[11]),h=_r(_d[12]),b=_r(_d[13]),p=_r(_d[14]),k=_r(_d[15]),j=_r(_d[16]),x=_r(_d[17]),w=_r(_d[18]);function I(e,t){const s=(0,m.useOwner)(e=>e.attendance);return(0,y.gameClock)(s,e,t)}const v='https://lennys-kitchen-chaos-13e285.deed.page/',C=e=>{try{const t=new URL(String(e??'').trim());return'https:'!==t.protocol||t.username||t.password?null:t.toString()}catch{return null}};function S(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 T=e=>String(e??'').replace(/\s*\(.*\)$/,'').replace(/\s+/g,' ').trim().slice(0,24).trim();function R({staffId:e,name:I,playable:R,clock:P,onClose:L,car:M}){const D=(0,m.useOwner)(e=>e.staff),O=(0,f.useAvatars)(e=>e.photos),_=(0,h.useSetup)(e=>e.looks),z=(0,r.useRef)(null),[N,U]=(0,r.useState)({}),[A,B]=(0,r.useState)(!1),[G,q]=(0,r.useState)(null),H=(0,b.useStore)(e=>C(e.restaurants.find(e=>e.id===p.VENUE_RID)?.settings?.gameUrl)??v),V=(0,r.useMemo)(()=>S(H),[H]),W=V?.origin??'',$=(0,j.useSync)(e=>'staff'===e.kind?e.staffRef??null:null),K=!(!$||!e||$===e),X=K?null:$??e??null,Y=T(I),[F,J]=(0,r.useState)(''),[Q,Z]=(0,r.useState)(null),ee=(0,r.useRef)(null),te=(0,r.useRef)(0),se=(0,r.useRef)(null),re=(0,r.useRef)(R);re.current=R;const ne=(0,r.useMemo)(()=>D.filter(e=>e.active&&!e.name.includes('(example)')),[D]);(0,r.useEffect)(()=>{const e=setTimeout(()=>{const e={};for(const s of ne){const r=null!=_[s.id]&&_[s.id]>=1e3?t.AVATAR_OPTIONS.find(e=>e.look===_[s.id]):void 0;if(r){e[s.id]=r.dataUrl;continue}const n=document.getElementById(`cc-av-${s.id}`)?.querySelector('svg');n&&(e[s.id]=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n.outerHTML.includes('xmlns')?n.outerHTML:n.outerHTML.replace('clearTimeout(e)},[ne,_]);const oe=(0,r.useMemo)(()=>ne.map(e=>{const t=O[e.id]?.dataUrl??N[e.id],s={id:e.id,name:T(e.name),role:e.job||e.level||e.role};return t&&(s.avatarUrl=t),s}),[ne,O,N]),le=(0,r.useCallback)(e=>{try{W&&z.current?.contentWindow?.postMessage(e,W)}catch{}},[W]);return(0,r.useEffect)(()=>{const e=async e=>{if(!W||e.origin!==W||e.source!==z.current?.contentWindow)return;const t=e.data;if('string'!=typeof t?.type||!t.type.startsWith('lenny:'))return;if('lenny:ready'===t.type)return q('string'==typeof t.version?String(t.version).slice(0,12):null),void B(!0);const s=String(t.levelId??'').slice(0,40);if('lenny:scores:list'===t.type&&le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.listScores)(s,Math.min(50,Number(t.limit)||10))}),'lenny:scores:submit'===t.type){const e=t.entry??{};if(!X||'string'==typeof e.staffId&&e.staffId!==X)return void le({type:'lenny:scores:result',reqId:t.reqId,result:{rank:null,entries:await(0,k.listScores)(s,10),id:null}});const r='string'==typeof e.characterId?e.characterId.slice(0,80):void 0;le({type:'lenny:scores:result',reqId:t.reqId,result:await(0,k.submitScore)(s,{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:r,character:'string'==typeof e.character?e.character.slice(0,60):void 0,staffId:X,name:Y})})}'lenny:roundAbandoned'===t.type&&J('The last round was stopped because the player changed. No score was saved.'),'lenny:roundStart'===t.type&&J(''),'lenny:progress'===t.type&&X&&t.staffId===X&&(0,k.saveProgress)(X,t.progress),'lenny:gameComplete'===t.type&&X&&t.staffId===X&&J(!0===t.firstTime?'Game complete! Character select is now unlocked.':'Game complete again. Nice work!')};return window.addEventListener('message',e),()=>window.removeEventListener('message',e)},[le,X,Y,W]),(0,r.useEffect)(()=>{B(!1),ee.current=null,se.current=null},[V?.src]),(0,r.useEffect)(()=>{if(!A)return;const e=e=>{se.current!==e&&(se.current=e,le({type:'lenny:setPlayable',playable:e}))},t=K?null:`${X??''}|${Y}`;if(t&&ee.current===t)return void e(R);const s=++te.current;ee.current=null,se.current&&e(!1),t&&(0,k.loadProgress)(X).catch(()=>null).then(r=>{s===te.current&&(le({type:'lenny:setPlayer',name:Y,staffId:X,...r?{progress:r}:{}}),ee.current=t,e(re.current))})},[A,K,X,Y,R,le]),(0,r.useEffect)(()=>{A&&le({type:'lenny:setRoster',staff:oe})},[A,oe,le]),(0,r.useEffect)(()=>{A&&null!==Q&&le({type:'lenny:setMuted',muted:Q})},[A,Q,le]),(0,w.jsx)(o.default,{visible:!0,animationType:"slide",onRequestClose:L,children:(0,w.jsxs)(c.default,{testID:"break-room",style:{flex:1,backgroundColor:(0,s.soutersSurface)('#000')},children:[M?(0,w.jsx)(E,{status:K?'Switching player\u2026':R?'Parked only \xb7 enjoy!':'Game locked',muted:!!Q,onPause:()=>le({type:'lenny:pause'}),onMute:()=>Z(!Q),onClose:L}):(0,w.jsxs)(d.Row,{style:{justifyContent:'space-between',padding:10,backgroundColor:x.colours.bg},children:[(0,w.jsx)(d.T,{weight:"semibold",children:"\ud83e\uded6 Break room"}),(0,w.jsx)(c.default,{testID:R&&!K?'break-playable':'break-locked',accessibilityLabel:G?`Game version ${G}`:void 0,children:(0,w.jsx)(d.T,{size:13,colour:R?x.colours.ok:x.colours.gold,children:K?'Switching player\u2026':R?'off'===P?'Off shift: enjoy!':'On your break: enjoy!':'Game locked'})}),(0,w.jsxs)(d.Row,{gap:4,children:[(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:Q?'Turn sound and voice on':'Mute sound and voice',onPress:()=>Z(!Q),style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:Q?'Sound on':'Mute'})}),(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",onPress:L,style:{padding:6},children:(0,w.jsx)(d.T,{weight:"semibold",colour:x.colours.gold,children:"Close"})})]})]}),R||K?null:(0,w.jsx)(c.default,{testID:"break-locked-text",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.text,children:y.GAME_LOCKED_TEXT})}),F?(0,w.jsx)(c.default,{testID:"break-notice",style:{paddingHorizontal:10,paddingVertical:6,backgroundColor:x.colours.surface},children:(0,w.jsx)(d.T,{size:13,colour:x.colours.muted,children:F})}):null,V?n.default.createElement('iframe',{ref:z,src:V.src,key:V.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)(c.default,{style:{flex:1,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(d.Muted,{children:"The Break room opens in the web app."})}),(0,w.jsx)(c.default,{style:{position:'absolute',left:-9999,top:0,width:64,height:64,opacity:0},pointerEvents:"none",children:ne.map(e=>(0,w.jsx)(c.default,{nativeID:`cc-av-${e.id}`,children:(0,w.jsx)(u.AvatarLook,{look:_[e.id],id:e.id,name:e.name,size:96})},e.id))})]})})}function E({status:e,muted:t,onPause:s,onMute:r,onClose:n}){const o={minHeight:72,minWidth:150,paddingHorizontal:22,borderRadius:18,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center'};return(0,w.jsxs)(c.default,{testID:"car-game-bar",style:{flexDirection:'row',alignItems:'center',gap:14,paddingHorizontal:16,paddingVertical:10,backgroundColor:x.colours.bg,borderBottomWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(l.default,{testID:"break-room-close",accessibilityRole:"button",accessibilityLabel:"Close the game",onPress:n,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Close"})}),(0,w.jsx)(l.default,{testID:"car-game-pause",accessibilityRole:"button",accessibilityLabel:"Pause the game",onPress:s,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:"Pause"})}),(0,w.jsxs)(c.default,{style:{flex:1,alignItems:'center',minWidth:0},children:[(0,w.jsx)(d.T,{size:22,weight:"semibold",center:!0,numberOfLines:1,children:"Lenny\u2019s Kitchen Chaos"}),(0,w.jsx)(d.T,{size:15,colour:x.colours.goldLight,center:!0,numberOfLines:1,children:`${e} \xb7 touch the big buttons on the game`})]}),(0,w.jsx)(l.default,{testID:"break-room-mute",accessibilityRole:"button",accessibilityLabel:t?'Turn sound and voice on':'Mute sound and voice',onPress:r,style:o,children:(0,w.jsx)(d.T,{size:20,weight:"semibold",colour:x.colours.gold,children:t?'Sound on':'Mute'})}),(0,w.jsx)(c.default,{testID:"car-game-parked",style:{...o,minWidth:0,borderColor:x.colours.goldMuted,backgroundColor:'rgba(201,162,74,0.12)'},children:(0,w.jsx)(d.T,{size:16,weight:"semibold",colour:x.colours.goldLight,children:"PARKED ONLY"})})]})}},1182,[928,828,34,395,236,402,102,925,794,926,891,1183,927,831,5,1184,987,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GAME_LOCKED_TEXT",{enumerable:!0,get:function(){return t}}),e.gameClock=function(t,n,o){if(!n)return'off';const a=new Date(o).getTime(),c=t.filter(t=>t.staffId===n&&t.in&&!t.out&&a-new Date(t.in).getTime()<72e6).sort((t,n)=>String(n.in).localeCompare(String(t.in)))[0];return c?c.breaks?.some(t=>!t.end)?'break':'working':'off'},Object.defineProperty(e,"gamePlayable",{enumerable:!0,get:function(){return n}});const t='You\u2019re clocked in, so the game is locked. Start your break or clock out in CoverCharge to play.';const n=t=>'working'!==t},1183,[]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listScores=o,_e.submitScore=async function(e,t){const f=r.useSync.getState(),l=Math.max(0,Math.round(Number(t.score)||0));if(c()&&f.staffRef&&t.staffId===f.staffRef)try{const{data:r,error:s}=await a().from('game_scores').insert({venue_id:f.venueId,game:'lenny',level_id:e,staff_ref:f.staffRef??null,name:String(t.name||'Crew').replace(/\s+/g,' ').trim().slice(0,24),character_id:t.characterId??null,score:l,stars:Math.max(0,Math.min(3,Number(t.stars)||0)),stats:{...t.stats??{},badges:t.badges??[],character:t.character??null}}).select('id').single();if(s)throw s;const{count:n}=await a().from('game_scores').select('id',{count:'exact',head:!0}).eq('venue_id',f.venueId).eq('game','lenny').eq('level_id',e).gt('score',l);return{rank:(n??0)+1,entries:await o(e,10),id:r.id}}catch{}const u=await s.kv.get(n,{}),y=[...u[e]??[],{...t,score:l,date:(new Date).toISOString()}].sort((e,t)=>t.score-e.score).slice(0,50);return await s.kv.set(n,{...u,[e]:y}),{rank:y.findIndex(e=>e.score===l)+1,entries:y.slice(0,10),id:null}},_e.loadProgress=async function(e){if(!e)return null;const t=r.useSync.getState();if(l(e))try{const{data:r,error:s}=await a().from('game_progress').select('progress').eq('venue_id',t.venueId).eq('game','lenny').eq('staff_ref',e).maybeSingle();if(s)throw s;if(r)return v(r.progress)}catch{}return v((await s.kv.get(f,{}))[e])},Object.defineProperty(_e,"LENNY_LAST_WORLD",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"LENNY_LEVELS",{enumerable:!0,get:function(){return y}}),_e.cleanProgress=v,_e.saveProgress=async function(e,t){const n=v(t);if(!e||!n||JSON.stringify(n).length>16e3)return;const c=await s.kv.get(f,{});await s.kv.set(f,{...c,[e]:n});const o=r.useSync.getState();if(l(e))try{await a().from('game_progress').upsert({venue_id:o.venueId,game:'lenny',staff_ref:e,progress:n,updated_at:(new Date).toISOString()},{onConflict:'venue_id,game,staff_ref'})}catch{}};var e=_r(d[0]),t=_r(d[1]),r=_r(d[2]),s=_r(d[3]);const a=()=>(0,e.getSupabase)(),n='lenny:scores:v1',c=()=>(0,t.isSupabaseConfigured)()&&!!r.useSync.getState().venueId&&'staff'===r.useSync.getState().kind;async function o(e,t=10){if(c())try{const{data:s,error:n}=await a().from('game_scores').select('*').eq('venue_id',r.useSync.getState().venueId).eq('game','lenny').eq('level_id',e).order('score',{ascending:!1}).limit(t);if(n)throw n;return(s??[]).map(e=>({name:e.name,staffId:e.staff_ref,characterId:e.character_id??void 0,character:e.stats?.character,score:e.score,stars:e.stars,badges:e.stats?.badges??[],stats:e.stats,date:e.created_at}))}catch{}return((await s.kv.get(n,{}))[e]??[]).sort((e,t)=>t.score-e.score).slice(0,t)}const f='lenny:progress:v1',l=e=>{const t=r.useSync.getState();return c()&&!!t.staffRef&&e===t.staffRef};const u='festival',y=['mop','dsoap','dish','dtower','dscrub','mussels','ppeel','pfifo','bin1','bin2','bin3','mothersday','bin4','creel1','creel2','dsundae','dplate','pass','rush','delivery','death','line','steak','festival'];function v(e){if(!e||'object'!=typeof e||Array.isArray(e))return null;const t=e,r=e=>('string'==typeof e||'number'==typeof e)&&String(e).length>0&&String(e).length<=60?String(e):null,s={};if(t.stars&&'object'==typeof t.stars&&!Array.isArray(t.stars))for(const[e,a]of Object.entries(t.stars).slice(0,300)){const t=r(e),n=Math.max(0,Math.min(3,Math.floor(Number(a)||0)));t&&(s[t]=n)}const a={},n=t.badges;if(Array.isArray(n))for(const e of n.slice(0,100)){const t=r(e);t&&(a[t]=!0)}else if(n&&'object'==typeof n)for(const[e,t]of Object.entries(n).slice(0,100)){const s=r(e);s&&t&&(a[s]=!0)}const c={stars:s,badges:a,charactersUnlocked:!0===t.charactersUnlocked};return'number'==typeof t.v&&Number.isInteger(t.v)&&t.v>=0&&t.v<=9999&&(c.v=t.v),Array.isArray(t.legacyWorlds)&&t.legacyWorlds.length<=50&&t.legacyWorlds.every(e=>null!==r(e)&&'string'==typeof e)&&(c.legacyWorlds=[...t.legacyWorlds]),c}},1184,[933,976,987,977]); +__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.KitchenRotaEditor=p,_e.KitchenRotaTab=function({today:e=(0,h.ymd)(new Date)}){const t=(0,r.canEditKitchenRota)((0,d.useSync)(e=>e.perms));return(0,m.jsx)(i.default,{testID:"chef-rota-tab",style:{alignSelf:'stretch',alignItems:'center'},children:t?(0,m.jsx)(p,{today:e}):(0,m.jsx)(w,{today:e})})},_e.KitchenRotaRead=w;var t=_r(_d[0]),s=e(_r(_d[1])),i=e(_r(_d[2])),n=_r(_d[3]),a=_r(_d[4]),r=_r(_d[5]),l=_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]),m=_r(_d[13]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],x=e=>`${e.slice(8,10)}/${e.slice(5,7)}`,j=e=>`${e.slice(8,10)}/${e.slice(5,7)}/${e.slice(0,4)}`,$=e=>e.replace(/\s*\(.*\)$/,''),k=[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5]];function p({today:e=(0,h.ymd)(new Date)}){const l=(0,a.useOwner)(e=>e.staff),o=(0,a.useOwner)(e=>e.shifts),d=(0,t.useMemo)(()=>(0,r.kitchenTeam)(l),[l]),k=(0,t.useMemo)(()=>new Set(d.map(e=>e.id)),[d]),[p,w]=(0,t.useState)(0),[I,D]=(0,t.useState)(null),[T,v]=(0,t.useState)(''),H=(0,a.addDays)((0,a.mondayOfDate)(e),7*p),C=(0,a.addDays)(H,6),L=y.map((e,t)=>(0,a.addDays)(H,t)),P=(0,r.kitchenPending)(o,k,H,C).length,R=e=>{v(e),(0,u.announce)(e)},M=0===p?'This week':1===p?'Next week':-1===p?'Last week':`Week of ${j(H)}`;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-editor",style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{w(p-1),v('')},style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${M}, ${b[0]} ${j(H)} to ${b[6]} ${j(C)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:M}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(H)," \u2013 ",x(C)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{w(p+1),v('')},style:{minWidth:84,minHeight:48}})]}),d.map(t=>(0,m.jsxs)(i.default,{testID:"krota-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{size:14,weight:"semibold",center:!0,children:[$(t.nickname||t.name),t.job?(0,m.jsx)(n.T,{size:12,colour:f.colours.muted,children:` ${t.job}`}):null]}),(0,m.jsx)(n.Row,{gap:4,style:{justifyContent:'center',flexWrap:'nowrap'},children:L.map((i,a)=>{const r=o.find(e=>e.staffId===t.id&&e.date===i),l=!(!r||r.published&&!r.changed),d=`${$(t.nickname||t.name)}, ${b[a]} ${j(i)}, ${r?`${(0,c.fmtH)(r.start)} to ${(0,c.fmtH)(r.end)}${l?', draft, not published yet':''}. Change shift`:'off. Add a shift'}`;return(0,m.jsxs)(s.default,{testID:`krota-cell-${t.id}-${a}`,accessibilityRole:"button",accessibilityLabel:d,onPress:()=>D({staffId:t.id,date:i,shift:r}),style:({pressed:e})=>({width:44,minHeight:52,borderRadius:8,paddingVertical:4,alignItems:'center',justifyContent:'center',borderWidth:1,borderStyle:l?'dashed':'solid',borderColor:r?l?f.colours.amber:f.colours.gold:f.colours.border,backgroundColor:e||r?f.colours.goldTint:f.colours.surface2}),children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:i===e?f.colours.gold:f.colours.muted,children:y[a]}),(0,m.jsx)(n.T,{size:10,center:!0,children:r?`${(0,c.fmtH)(r.start).slice(0,5)}`:'off'}),r?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(r.end).slice(0,5)}):(0,m.jsx)(n.T,{size:10,center:!0,colour:f.colours.muted,children:"+"})]},i)})})]},t.id)),d.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen team on the staff list yet."}),(0,m.jsx)(n.Button,{testID:"krota-publish",kind:P?'primary':'secondary',disabled:!P,label:P?`Publish kitchen rota (${P} ${1===P?'change':'changes'})`:'Kitchen rota published',accessibilityLabel:P?`Publish the kitchen rota for ${M.toLowerCase()}, ${P} ${1===P?'change':'changes'}`:'Kitchen rota published for this week',onPress:()=>{const e=(0,r.publishKitchen)(a.useOwner.getState().shifts,k,H,C);a.useOwner.getState().setShifts(e.shifts),R(e.n?`Published ${e.n} kitchen ${1===e.n?'shift':'shifts'}. The kitchen team see them in their app now.`:'Nothing new to publish this week.')},style:{minHeight:56,alignSelf:'stretch'}}),T?(0,m.jsx)(i.default,{testID:"krota-msg",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.goldLight,children:T})}):null,(0,m.jsx)(n.Muted,{center:!0,children:"Tap a day to add or change a shift. Dashed amber = draft, only you see it until you publish. Front of house shifts are made in CoverCharge for Managers."}),I?(0,m.jsx)(S,{init:I,onClose:()=>D(null),onSaid:R}):null]})}function w({today:e=(0,h.ymd)(new Date)}){const{staff:s,shifts:r}=(0,o.rotaView)('chef',(0,a.useOwner)(e=>e.staff),(0,a.useOwner)(e=>e.shifts)),d=(0,a.useOwner)(e=>e.leave),[u,k]=(0,t.useState)(0),p=(0,a.addDays)((0,a.mondayOfDate)(e),7*u),w=(0,a.addDays)(p,6),S=y.map((e,t)=>(0,a.addDays)(p,t)),I=s.filter(e=>/kitchen|chef|kp/i.test(`${e.job??''} ${e.name}`)),D=0===u?'This week':1===u?'Next week':-1===u?'Last week':`Week of ${j(p)}`,[T,v]=(0,t.useState)(0),H=T?Math.max(30,Math.min(44,Math.floor((T-12)/7))):40;return(0,m.jsxs)(i.default,{testID:"kitchen-rota-read",onLayout:e=>v(e.nativeEvent.layout.width),style:{gap:10,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Kitchen rota"}),(0,m.jsxs)(n.Row,{gap:8,style:{justifyContent:'center',alignItems:'center'},children:[(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>k(u-1),style:{minWidth:84,minHeight:48}}),(0,m.jsxs)(i.default,{accessible:!0,accessibilityLabel:`${D}, ${b[0]} ${j(p)} to ${b[6]} ${j(w)}`,style:{alignItems:'center',minWidth:120},children:[(0,m.jsx)(n.T,{weight:"semibold",center:!0,children:D}),(0,m.jsxs)(n.Muted,{center:!0,children:[x(p)," \u2013 ",x(w)]})]}),(0,m.jsx)(n.Button,{small:!0,kind:"ghost",testID:"krota-read-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>k(u+1),style:{minWidth:84,minHeight:48}})]}),I.map(t=>(0,m.jsxs)(i.default,{testID:"krota-read-row",style:{gap:4,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsx)(n.T,{size:14,weight:"semibold",center:!0,children:$(t.nickname||t.name)}),(0,m.jsx)(n.Row,{gap:2,style:{justifyContent:'center',flexWrap:'nowrap'},children:S.map((s,a)=>{const o=r.find(e=>e.staffId===t.id&&e.date===s),h=o?(0,l.leaveCovering)(d,t.id,s):void 0,u=o?h?(0,l.leaveLabel)(h):`${(0,c.fmtH)(o.start)} to ${(0,c.fmtH)(o.end)}`:'off';return(0,m.jsxs)(i.default,{testID:`krota-read-cell-${t.id}-${a}`,accessible:!0,accessibilityLabel:`${$(t.nickname||t.name)}, ${b[a]} ${j(s)}, ${u}`,style:{width:H,minHeight:52,borderRadius:8,paddingVertical:4,paddingHorizontal:0,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?f.colours.gold:f.colours.border,backgroundColor:o?f.colours.goldTint:f.colours.surface2},children:[(0,m.jsx)(n.T,{size:10,center:!0,colour:s===e?f.colours.gold:f.colours.muted,children:y[a]}),o&&h?(0,m.jsx)(n.T,{size:9,center:!0,colour:f.colours.blue,children:(0,l.leaveLabel)(h).toLowerCase()}):(0,m.jsx)(n.T,{size:10,center:!0,children:o?(0,c.fmtH)(o.start).slice(0,5):'off'}),o&&!h?(0,m.jsx)(n.T,{size:10,center:!0,children:(0,c.fmtH)(o.end).slice(0,5)}):null]},s)})})]},t.id)),I.length?null:(0,m.jsx)(n.Muted,{center:!0,children:"No kitchen shifts on the rota yet."}),(0,m.jsx)(n.Muted,{center:!0,children:"This shows published shifts only. To change the kitchen rota here, an owner can tick \u201cMake the kitchen rota\u201d for you on the Permissions screen."})]})}function S({init:e,onClose:s,onSaid:l}){const o=(0,a.useOwner)(t=>t.staff.find(t=>t.id===e.staffId)),d=$(o?.nickname||o?.name||''),[u,y]=(0,t.useState)(e.shift?.start??11),[b,x]=(0,t.useState)(e.shift?.end??21),[p,w]=(0,t.useState)(!1),[S,I]=(0,t.useState)(''),D=`${(0,h.niceDate)((0,h.parseYmd)(e.date))} (${j(e.date)})`;return(0,m.jsx)(n.Sheet,{visible:!0,onClose:s,title:`${d} \xb7 ${D}`,testID:"krota-sheet",children:(0,m.jsxs)(i.default,{style:{gap:10,alignItems:'center'},children:[(0,m.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(([e,t,s])=>(0,m.jsx)(n.Chip,{testID:`krota-preset-${e.toLowerCase()}`,label:`${e} ${(0,c.fmtH)(t)}\u2013${(0,c.fmtH)(s)}`,selected:u===t&&b===s,onPress:()=>{y(t),x(s)}},e))}),(0,m.jsx)(n.T,{center:!0,children:"Start"}),(0,m.jsx)(n.Stepper,{testID:"krota-start",value:u,step:.5,min:c.SHIFT_MIN_START,max:b-1,onChange:y,format:c.fmtH,label:"Start time"}),(0,m.jsxs)(n.T,{center:!0,children:["End",b>=24?' (next day)':'']}),(0,m.jsx)(n.Stepper,{testID:"krota-end",value:b,step:.5,min:u+1,max:c.SHIFT_MAX_END,onChange:x,format:c.fmtH,label:"End time"}),(0,m.jsxs)(n.Muted,{center:!0,children:[(b-u).toFixed(1)," hours"]}),S?(0,m.jsx)(i.default,{accessibilityLiveRegion:"assertive",children:(0,m.jsx)(n.T,{center:!0,colour:f.colours.amber,children:S})}):null,(0,m.jsx)(n.Button,{testID:"krota-save",label:e.shift?'Save shift':'Add shift',accessibilityLabel:`${e.shift?'Save':'Add'} ${d}'s shift, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}`,onPress:()=>{const t=a.useOwner.getState();(0,r.clashes)(t.shifts,e.staffId,e.date,u,b,e.shift?.id)?I(`${d} already has a shift that overlaps on ${D}.`):(e.shift?t.setShifts(t.shifts.map(t=>t.id===e.shift.id?{...t,start:u,end:b,changed:!!t.published||t.changed}:t)):t.addShift({staffId:e.staffId,date:e.date,start:u,end:b}),l(`${e.shift?'Changed':'Added'}: ${d}, ${D}, ${(0,c.fmtH)(u)} to ${(0,c.fmtH)(b)}. Draft until you publish the kitchen rota.`),s())},style:{minHeight:56,alignSelf:'stretch'}}),e.shift&&!p?(0,m.jsx)(n.Button,{testID:"krota-remove",kind:"danger",label:"Remove shift",onPress:()=>w(!0),style:{minHeight:52,alignSelf:'stretch'}}):null,e.shift&&p?(0,m.jsxs)(i.default,{testID:"krota-remove-ask",accessibilityLiveRegion:"assertive",style:{gap:8,alignItems:'center',alignSelf:'stretch'},children:[(0,m.jsxs)(n.T,{center:!0,weight:"semibold",children:["Remove ",d,"\u2019s shift on ",D,"?"]}),(0,m.jsx)(n.Button,{testID:"krota-remove-yes",kind:"danger",label:"Yes, remove it",onPress:()=>{a.useOwner.getState().removeShift(e.shift.id),l(`Removed ${d}'s shift on ${D}.`),s()},style:{minHeight:52,alignSelf:'stretch'}}),(0,m.jsx)(n.Button,{testID:"krota-remove-no",kind:"secondary",label:"No, keep it",onPress:()=>w(!1),style:{minHeight:52,alignSelf:'stretch'}})]}):null]})})}},1185,[34,402,102,794,891,989,1098,994,987,1091,858,1125,821,25]); +__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.useSuggestions=j,_e.OrdersScreen=function({focus:e}={}){const[s,t]=(0,n.useState)('sheets');return(0,x.jsxs)(l.default,{style:{gap:12},children:[(0,x.jsx)(y.Seg,{value:s,onChange:t,options:[{id:'sheets',label:'Order sheets'},{id:'suggested',label:'Suggested orders'},{id:'history',label:'Order history'}]}),'sheets'===s?(0,x.jsx)(m.OrderSheets,{focus:e}):'suggested'===s?(0,x.jsx)(w,{}):(0,x.jsx)($,{})]})};var s=r(_d[0]),t=r(_d[1]),n=r(_d[2]),i=e(r(_d[3])),l=e(r(_d[4])),d=r(_d[5]),o=r(_d[6]),u=r(_d[7]),c=r(_d[8]),h=r(_d[9]),p=r(_d[10]),y=r(_d[11]),f=r(_d[12]),m=r(_d[13]),x=r(_d[14]);const b=(e,s)=>'kg'===s?Math.ceil(2*e)/2:Math.ceil(e);function j(){const{k:e,now:s,rid:n}=(0,y.useChef)(6e4),{pct:i}=(0,y.useForecast)(),l=(0,u.supplierView)('chef',(0,o.useOwner)(e=>e.suppliers)).filter(e=>!e.archived),d=1+Math.max(0,i)/100;return l.map(i=>{const l=e.ingredients.filter(e=>e.supplierId===i.id).map(e=>({i:e,qty:(0,t.fishInStone)(n,e)?(0,t.fromStone)(Math.ceil(2*(0,t.toStone)(Math.max(0,e.par*d-e.onHand),e.unit))/2,e.unit):b(Math.max(0,e.par*d-e.onHand),e.unit)})).filter(e=>e.qty>0),o=(0,p.weekday)(s),u=i.orderDays.includes(o),[c,h]=(i.cutoff||'23:59').split(':').map(Number),y=new Date(s);y.setHours(c,h,0,0);const f=e.orders.some(e=>e.supplierId===i.id&&new Date(e.at).toDateString()===s.toDateString()),m=[1,2,3,4,5,6,7].map(e=>(o+e)%7).find(e=>i.orderDays.includes(e));return{s:i,lines:l,ordersToday:u,cutPassed:s>y,placedToday:f,nextDay:m,total:Math.round(l.reduce((e,s)=>e+s.qty*s.i.cost,0))}}).filter(e=>e.lines.length||e.ordersToday)}function w(){const{me:e,rid:o}=(0,y.useChef)(),{label:u,covers:m,enough:b,booked:w}=(0,y.useForecast)(),$=(0,f.useKitchen)(e=>e.addOrder),S=j(),[C,M]=(0,n.useState)({}),[O,k]=(0,n.useState)('');return(0,x.jsxs)(l.default,{style:{gap:10},children:[(0,x.jsxs)(d.Muted,{children:[b?`Built from par levels and today's forecast (${m} Covers, ${u} vs a typical day).`:`Built from par levels (no forecast yet: not enough history; ${w} Covers booked so far).`," Adjust, then call the supplier or use their ordering website. Nothing is sent by CoverCharge."]}),O?(0,x.jsx)(d.Banner,{kind:"success",title:"Saved to order history",children:O}):null,S.map(({s:n,lines:u,ordersToday:y,cutPassed:f,placedToday:m,nextDay:b,total:j})=>{const w=u.map(e=>({...e,q:C[`${n.id}:${e.i.id}`]??e.qty})),S=Math.round(w.reduce((e,s)=>e+s.q*s.i.cost,0)),O=s=>{$({supplierId:n.id,by:e,status:s,lines:w.filter(e=>e.q>0).map(e=>({ing:e.i.id,qty:e.q,cost:e.i.cost})),total:S}),k(`${n.name}: ${(0,c.gbp)(S)} (${s}).`)};return(0,x.jsxs)(d.Card,{highlight:!y||m||f?void 0:h.colours.gold,children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{weight:"semibold",children:n.name}),(0,x.jsxs)(d.Muted,{children:[n.category," \xb7 min order ",(0,c.gbp)(n.minOrder)]})]}),m?(0,x.jsx)(d.Badge,{kind:"ok",label:"ORDERED TODAY"}):y?(0,x.jsx)(d.Badge,{kind:f?'red':'amber',label:f?`CUT-OFF ${n.cutoff} PASSED`:`ORDER BY ${n.cutoff}`}):(0,x.jsx)(d.Badge,{label:`NEXT ${null!=b?p.DAY3[b].toUpperCase():'\u2014'}`})]}),w.length?w.map(e=>(0,x.jsxs)(d.Row,{wrap:!0,style:{justifyContent:'space-between'},children:[(0,x.jsxs)(l.default,{style:{flex:1},children:[(0,x.jsx)(d.T,{size:14,children:e.i.name}),(0,x.jsxs)(d.Muted,{children:["On hand ",(0,s.ingredientQty)(o,e.i,e.i.onHand)," \xb7 par ",(0,s.ingredientQty)(o,e.i,e.i.par)]})]}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"Less",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone less':'Less'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,-1)}))}),(0,x.jsx)(l.default,{accessible:!0,accessibilityLabel:(0,s.ingredientSpeech)(o,e.i,e.q),children:(0,x.jsx)(d.T,{size:16,style:{minWidth:76,textAlign:'center'},children:(0,s.ingredientQty)(o,e.i,e.q)})}),(0,x.jsx)(d.Button,{small:!0,kind:"ghost",label:"More",accessibilityLabel:`${(0,t.fishInStone)(o,e.i)?'Half a stone more':'More'} ${e.i.name}`,onPress:()=>M(s=>({...s,[`${n.id}:${e.i.id}`]:(0,t.stepQuantity)(o,e.i,e.q,1)}))})]},e.i.id)):(0,x.jsx)(d.Muted,{children:"Everything is at par."}),w.length?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(d.T,{weight:"semibold",children:["Estimated ",(0,c.gbp)(S)]}),S{i.default.openURL(`tel:${n.phones[0].replace(/\s/g,'')}`).catch(()=>{}),O('placed (by phone)')}}):null,n.website?(0,x.jsx)(d.Button,{small:!0,kind:"secondary",label:"Open website",onPress:()=>{i.default.openURL(n.website).catch(()=>{}),O('placed (on website)')}}):null]})]}):null,void 0]},n.id)})]})}function $(){const{k:e,rid:t}=(0,y.useChef)(),n=(0,o.useOwner)(e=>e.suppliers);return(0,x.jsx)(l.default,{style:{gap:8},children:e.orders.map(i=>(0,x.jsxs)(d.Card,{children:[(0,x.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(d.T,{weight:"semibold",style:{flex:1},children:n.find(e=>e.id===i.supplierId)?.name}),(0,x.jsx)(d.Badge,{kind:"neutral",label:i.status.toUpperCase()})]}),(0,x.jsxs)(d.Muted,{children:[new Date(i.at).toLocaleString('en-GB',{weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'})," \xb7 ",i.by,i.total?` \xb7 ${(0,c.gbp)(i.total)}`:'']}),i.lines.length?(0,x.jsx)(d.Muted,{children:i.lines.map(n=>{const i=e.ingredients.find(e=>e.id===n.ing);return`${(0,s.ingredientQty)(t,i??{name:n.ing,unit:''},n.qty)} ${i?.name??n.ing}`}).join(', ')}):null]},i.id))})}},1186,[1173,984,34,379,102,794,891,994,867,821,1088,1165,1033,1187,25]); +__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.openLink=j,_e.useSheetReminders=T,_e.OrderSheets=function({focus:e}){const{rid:t,now:l}=(0,x.useChef)(3e4),o=(0,u.useSheets)(t).filter(e=>(0,n.chefCanSee)(t,e)&&!e.placeholder),[h,c]=(0,s.useState)(e??null),p=T(),f=(0,b.wd)(l);return(0,y.jsxs)(d.default,{style:{gap:10},testID:"order-sheets",children:[(0,y.jsx)(i.Banner,{kind:"info",title:"Nothing is sent for you",children:"Text, WhatsApp and phone orders open your phone\u2019s own app with the order already written. Check it, then press Send yourself."}),p.map(e=>(0,y.jsx)(r.default,{accessibilityRole:"button",onPress:()=>c(e.supplierId),children:(0,y.jsxs)(i.Banner,{kind:'red'===e.tone?'danger':'warn',title:`\u23f0 ${e.text}`,children:["Tap to open the ",e.name," order sheet."]})},e.supplierId)),(0,y.jsxs)(i.Muted,{children:["Today is ",b.DAYS[f],". Edit suppliers in Managers \u203a Settings \u203a Supplier order sheets."]}),o.map(e=>(0,y.jsx)(C,{s:e,open:h===e.id,onToggle:()=>c(h===e.id?null:e.id)},e.id)),o.length?null:(0,y.jsx)(i.Muted,{children:"No order sheets yet. Add suppliers in Managers \u203a Settings \u203a Supplier order sheets."})]})};var t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=e(_r(_d[4]));_r(_d[5]);var r=e(_r(_d[6])),d=e(_r(_d[7])),i=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]);function j(e){if('undefined'!=typeof window){const t=window;return'function'==typeof t.__ccOpenLink?void t.__ccOpenLink(e):void(/^https?:/.test(e)?window.open(e,'_blank','noopener'):window.location.href=e)}o.default.openURL(e).catch(()=>{})}async function w(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0}catch{}return!1}const k={online:'\ud83c\udf10',phone:'\ud83d\udcde',text:'\ud83d\udcac',whatsapp:'\u2706',tbc:'\ud83d\udd8a\ufe0f'},S={borderWidth:1,borderColor:f.colours.border,borderRadius:10,paddingHorizontal:12,paddingVertical:10,color:f.colours.text,backgroundColor:f.colours.surface2,fontSize:f.font.body};function T(){const{rid:e,now:t}=(0,x.useChef)(6e4),l=(0,u.useSheets)(e).filter(t=>(0,n.chefCanSee)(e,t)&&!t.placeholder),s=(0,u.useOrderSheets)(e=>e.opened),o=(0,h.useShellfish)(e,'','chef'),r=(0,b.remindersFor)(l,t,s);for(const n of l){const l=o.items.filter(e=>(e.supplierId===n.id||!e.supplierId&&n.shellfish)&&o.isLow(e.key));!l.length||s[n.id]&&new Date(s[n.id]).toDateString()===t.toDateString()||r.push({supplierId:n.id,name:n.name,text:`${'text'===n.method||'whatsapp'===n.method?'Text':'Order from'} ${n.contact||n.name}: ${l.map(t=>`${(0,c.fmtStockCount)(e,t,o.counts[t.key]??0)} ${t.plural.toLowerCase()}`).join(' and ')} left`,tone:'amber',cutoffPassed:!1})}return r}function C({s:e,open:n,onToggle:o}){const{rid:T,r:C,me:$,now:D}=(0,x.useChef)(3e4),v=(0,u.useOrderSheets)(e=>e.patch),I=(0,u.useOrderSheets)(e=>e.markOpened),M=(0,u.useOrderSheets)(t=>t.opened[e.id]),[B,L]=(0,s.useState)({}),[P,O]=(0,s.useState)(''),[R,A]=(0,s.useState)(''),[z,_]=(0,s.useState)(!1),W=(0,h.useShellfish)(T,$,'chef'),H=(0,b.nextDelivery)(e,D),K=(0,b.orderLines)(e,B,P,T),E=(C.address??C.location??'').split(',').map(e=>e.trim()).filter(Boolean),q=E.length>=3?E[1]:E[0]??'',N=(0,b.orderMessage)(e,C.name,q,K,$.split(' ')[0],D),U=e.orderDays.includes((0,b.wd)(D)),Q=(e,t)=>L(n=>({...n,[e.id]:(0,l.stepQuantity)(T,e,n[e.id]||0,t)})),Y=t=>{I(e.id,D.toISOString()),j(t)},F='text'===e.method||'whatsapp'===e.method||'phone'===e.method,G=Math.round(100*parseFloat(R.replace(/[\xa3,]/g,''))),V=W.items.filter(t=>t.supplierId===e.id||!t.supplierId&&e.shellfish),J=V.filter(e=>W.isLow(e.key));return(0,y.jsxs)(d.default,{testID:`sheet-${e.id}`,style:{borderRadius:14,borderWidth:1.5,borderColor:U||J.length?f.colours.amber:n?f.colours.gold:f.colours.border,backgroundColor:f.colours.surface,overflow:'hidden'},children:[(0,y.jsxs)(r.default,{accessibilityRole:"button",accessibilityLabel:`${e.name} order sheet`,onPress:o,style:{padding:12,gap:4},children:[(0,y.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,y.jsxs)(i.T,{weight:"semibold",size:f.font.large,style:{flex:1},children:[k[e.method]," ",e.name]}),(0,y.jsx)(i.Badge,{kind:e.placeholder?'amber':'gold',label:e.placeholder?'To fill in':b.METHOD_LABEL[e.method]})]}),(0,y.jsx)(i.Muted,{children:e.goods}),(0,y.jsxs)(i.Row,{wrap:!0,gap:6,children:[e.deliveryDays.length?(0,y.jsx)(i.Badge,{kind:"neutral",label:`Delivers ${(0,b.dayRange)(e.deliveryDays)}`}):null,e.orderDays.length?(0,y.jsx)(i.Badge,{kind:U?'amber':'neutral',label:`Order ${(0,b.dayRange)(e.orderDays)}${e.cutoff?` by ${e.cutoff}`:''}`}):null,e.frequency?(0,y.jsx)(i.Badge,{kind:"neutral",label:e.frequency}):null,e.priceCapPerKg?(0,y.jsx)(i.Badge,{kind:"blue",label:`Cap ${(0,p.gbp)(e.priceCapPerKg)}/kg`}):null,V.length?(0,y.jsx)(i.Badge,{kind:J.length?'amber':'ok',label:V.map(e=>`${e.icon} ${(0,c.fmtStockCount)(T,e,W.counts[e.key]??0)}`).join(' \xb7 ')}):null,M&&new Date(M).toDateString()===D.toDateString()?(0,y.jsx)(i.Badge,{kind:"ok",label:"Opened today \u2713"}):null]})]}),n?(0,y.jsxs)(d.default,{style:{padding:12,paddingTop:0,gap:10},children:[H?(0,y.jsxs)(i.Muted,{children:["Next delivery if you order now: ",(0,b.niceDay)(H),"."]}):null,e.reminder?(0,y.jsxs)(i.Muted,{children:["Reminder on ",e.orderDays.map(e=>b.DAYS[e]).join(', '),": ",e.reminder]}):null,e.notes?(0,y.jsx)(i.T,{size:f.font.small,colour:f.colours.muted,children:e.notes}):null,e.placeholder?(0,y.jsx)(i.Banner,{kind:"warn",title:"Still to be set up",children:"Add the supplier, how to order and delivery days in Managers \u203a Settings \u203a Supplier order sheets."}):null,e.items.map(e=>(0,y.jsxs)(d.default,{style:{gap:6},children:[(0,y.jsxs)(i.T,{children:[e.name,e.unit?(0,y.jsxs)(i.T,{size:f.font.small,colour:f.colours.muted,children:[" (",(0,l.quantityUnit)(T,e),")"]}):null]}),(0,y.jsxs)(i.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone less':'Less'} ${e.name}`,onPress:()=>Q(e,-1),style:{minWidth:44,minHeight:44}}),(0,y.jsx)(d.default,{accessible:!0,accessibilityLabel:(0,l.fishQtySpeech)(T,e,B[e.id]||0),children:(0,y.jsx)(i.T,{weight:"bold",size:20,style:{minWidth:76,textAlign:'center'},children:(0,l.fishInStone)(T,e)?(0,l.fishQtyText)(T,e,B[e.id]||0):B[e.id]||0})}),(0,y.jsx)(i.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`${(0,l.fishInStone)(T,e)?'Half a stone more':'More'} ${e.name}`,testID:`qty-${e.id}`,onPress:()=>Q(e,1),style:{minWidth:44,minHeight:44}})]})]},e.id)),(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsx)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:"Anything else (one line each)"}),(0,y.jsx)(t.TextInput,{value:P,onChangeText:O,multiline:!0,placeholder:"e.g. 2 boxes lemons",placeholderTextColor:f.colours.muted,style:[S,{minHeight:60}]})]}),F?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['whatsapp'===e.method?'WhatsApp number':'phone'===e.method?'Phone number':'Mobile number',e.number?'':' (blank: fill in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`number-${e.id}`,value:e.number,onChangeText:t=>v(T,e.id,{number:t}),keyboardType:"phone-pad",placeholder:"07\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,'online'===e.method?(0,y.jsxs)(d.default,{style:{gap:4},children:[(0,y.jsxs)(i.T,{size:f.font.small,weight:"medium",colour:f.colours.muted,children:['Open Coldweb'===e.urlLabel?'Coldweb ordering link':'Website link',e.url?'':' (blank: paste it in once, it is saved)']}),(0,y.jsx)(t.TextInput,{testID:`url-${e.id}`,value:e.url,onChangeText:t=>v(T,e.id,{url:t.trim()}),autoCapitalize:"none",keyboardType:"url",placeholder:"https://\u2026",placeholderTextColor:f.colours.muted,style:S})]}):null,e.priceCapPerKg?(0,y.jsxs)(d.default,{style:{gap:6,padding:10,borderRadius:12,backgroundColor:f.colours.blueBg},children:[(0,y.jsxs)(i.T,{weight:"semibold",colour:"#E2C489",children:["Price cap ",(0,p.gbp)(e.priceCapPerKg),"/kg \xb7 buy from the cheapest UK seller under it"]}),(0,y.jsxs)(i.Muted,{children:["Seller: ",e.seller||'to be chosen']}),(0,y.jsxs)(i.Row,{gap:8,children:[(0,y.jsx)(i.T,{size:f.font.small,style:{flex:1},children:"Price you found (\xa3/kg)"}),(0,y.jsx)(t.TextInput,{testID:"price-found",value:R,onChangeText:A,keyboardType:"decimal-pad",placeholder:"e.g. 22.50",placeholderTextColor:f.colours.muted,style:[S,{width:120}]})]}),G>0?(0,y.jsx)(i.Badge,{kind:G<=e.priceCapPerKg?'ok':'red',label:G<=e.priceCapPerKg?`${(0,p.gbp)(G)}/kg is under the cap \u2713`:`${(0,p.gbp)(G)}/kg is over the ${(0,p.gbp)(e.priceCapPerKg)} cap: look for a cheaper seller`}):null]}):null,'online'!==e.method&&'tbc'!==e.method?(0,y.jsxs)(d.default,{testID:`preview-${e.id}`,style:{padding:10,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:f.colours.surface2},children:[(0,y.jsx)(i.T,{size:12,weight:"semibold",colour:f.colours.gold,children:'phone'===e.method?'READ THIS OUT':'YOUR MESSAGE'}),(0,y.jsx)(i.T,{size:f.font.small,children:K.length?N:'Add quantities above to write the order.'})]}):null,(0,y.jsxs)(i.Row,{wrap:!0,gap:8,children:['text'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"\ud83d\udcac Open in Messages",disabled:!K.length,onPress:()=>Y((0,b.smsLink)(e.number,N))}):null,'whatsapp'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:"Open in WhatsApp",disabled:!K.length,onPress:()=>Y((0,b.waLink)(e.number,N))}):null,'phone'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83d\udcde Call ${e.name}`,disabled:!e.number,onPress:()=>Y((0,b.telLink)(e.number))}):null,'online'===e.method?(0,y.jsx)(i.Button,{testID:`send-${e.id}`,kind:"success",label:`\ud83c\udf10 ${e.urlLabel??'Open website'}`,disabled:!e.url,onPress:()=>Y(e.url)}):null,'online'!==e.method&&'tbc'!==e.method&&K.length?(0,y.jsx)(i.Button,{kind:"ghost",label:z?'Copied \u2713':'Copy order',onPress:async()=>{const e=await w(N);_(e),e&&setTimeout(()=>_(!1),2e3)}}):null]}),'text'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: Messages opens with the order written and asks who to send it to."}):null,'whatsapp'===e.method&&!e.number&&K.length?(0,y.jsx)(i.Muted,{children:"No number saved: WhatsApp opens with the order written and asks who to send it to."}):null,'phone'!==e.method||e.number?null:(0,y.jsx)(i.Muted,{children:"Add the phone number above to call from here."}),'online'!==e.method||e.url?null:(0,y.jsx)(i.Muted,{children:"Add the link above and the button opens it."})]}):null]})}},1187,[827,835,984,34,379,236,402,102,794,1031,983,985,867,1032,821,1165,25]); +__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,"isTextIcon",{enumerable:!0,get:function(){return v}}),_e.StockIcon=w,_e.useReservedToday=L,_e.ShellfishTile=function({rid:e,by:t,app:s,big:r,onOrder:l,style:c}){const y=(0,h.useShellfish)(e,t,s),f=L(e),[p,k]=(0,o.useState)(!1),x=I(e,y.items.find(e=>e.supplierId)?.supplierId),j=(0,n.useLiveState)();if('ready'!==j)return(0,S.jsx)(n.LiveWait,{state:j,title:"Lobsters & crabs",testID:"shellfish-wait"});if(!y.items.length)return null;const v=y.items.filter(e=>y.isLow(e.key)),w=y.items.length<=3?y.items.map(e=>e.plural.toUpperCase()).join(' & '):'LIVE STOCK';return(0,S.jsxs)(a.default,{testID:"shellfish-tile",style:[{borderRadius:16,borderWidth:1.5,borderColor:v.length?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface,padding:r?10:12,gap:6},c],children:[(0,S.jsxs)(i.default,{accessibilityRole:"button",accessibilityLabel:`${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>k(!0),style:{gap:4,flex:r?1:void 0},children:[(0,S.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:["LIVE \xb7 ",w]}),(0,S.jsx)(d.T,{size:12,colour:b.colours.muted,children:"Tap to update \u203a"})]}),(0,S.jsx)(d.Row,{gap:r?14:18,style:{flex:r?1:void 0,alignItems:'center'},children:y.items.map(t=>{const s=y.counts[t.key]??0,o=y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,s)}`,style:{flex:1,alignItems:'center'},children:[(0,S.jsx)(d.T,{size:r?42:34,weight:"bold",colour:s<=0?b.colours.red:o?b.colours.amber:b.colours.text,style:{lineHeight:r?50:42},children:(0,u.fmtStockCount)(e,t,s)}),(0,S.jsxs)(d.T,{size:13,colour:o?b.colours.amber:b.colours.muted,children:[C(t),s<=0?' \xb7 out':o?' \xb7 low':'']}),f[t.key]?(0,S.jsxs)(d.T,{size:12,weight:"semibold",colour:b.colours.goldLight,children:["Reserved: ",(0,u.fmtStockCount)(e,t,f[t.key])," \xb7 free ",(0,u.fmtStockCount)(e,t,Math.max(0,s-f[t.key]))]}):null]},t.key)})})]}),!r&&v.length?(0,S.jsxs)(a.default,{testID:"shellfish-low",style:{backgroundColor:b.colours.amberBg,borderRadius:10,padding:8,gap:6},children:[(0,S.jsxs)(d.T,{size:13,weight:"semibold",colour:"#FFE2A8",children:["Low stock: ",v.map(t=>`${(0,u.fmtStockCount)(e,t,y.counts[t.key]??0)} ${t.plural.toLowerCase()} (warns at ${(0,u.fmtStockCount)(e,t,t.lowAt)})`).join(', ')]}),l?(0,S.jsx)(d.Button,{small:!0,label:x?`Order from ${x} \u203a`:'Order sheets \u203a',testID:"shellfish-order",onPress:l}):null]}):null,r||v.length||!l?null:(0,S.jsx)(i.default,{accessibilityRole:"button",onPress:l,style:{minHeight:44,justifyContent:'center'},children:(0,S.jsx)(d.T,{size:13,colour:b.colours.gold,children:x?`${x} order sheet \u203a`:'Order sheets \u203a'})}),p?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>k(!1),onOrder:l?()=>{k(!1),l()}:void 0}):null]})},_e.ShellfishStrip=function({rid:e,by:t,app:s,height:n=76}){const l=(0,h.useShellfish)(e,t,s),c=L(e),[y,f]=(0,o.useState)(!1);if(!l.items.length)return null;const p=n>=80,k=Math.max(28,Math.min(52,Math.round(.6*n))),x=Math.max(22,Math.min(34,Math.round(.42*n)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:"shellfish-tile",accessibilityRole:"button",accessibilityLabel:`${l.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,l.counts[t.key]??0)}`).join(', ')}. Tap to update`,onPress:()=>f(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'stretch',height:n,backgroundColor:e?'#181612':'#100F0D',borderBottomWidth:1,borderBottomColor:'rgba(207,164,95,0.12)',borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.04)',...r.look.web({backgroundImage:'linear-gradient(180deg, rgba(207,164,95,0.07) 0%, rgba(207,164,95,0.015) 100%)',cursor:'pointer'})}),children:l.items.map((t,s)=>{const o=l.counts[t.key]??0,i=c[t.key]??0,h=Math.max(0,o-i),y=h<=0,f=y||l.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,h)}`,style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'center',gap:p?16:12,borderLeftWidth:s?1:0,borderLeftColor:'rgba(207,164,95,0.16)',backgroundColor:f?'rgba(255,107,94,0.07)':'transparent',...r.look.web(f?{backgroundImage:'linear-gradient(180deg, rgba(255,107,94,0.11) 0%, rgba(255,107,94,0.035) 100%)'}:{})},children:[v(t.icon)?null:(0,S.jsx)(w,{icon:t.icon,size:x}),(0,S.jsx)(d.T,{size:k,weight:"bold",colour:f?'#FF8E82':b.colours.text,style:{lineHeight:Math.round(1.15*k),letterSpacing:-.5,minWidth:Math.round(.85*k),textAlign:'center'},children:(0,u.fmtStockCount)(e,t,h)}),(0,S.jsxs)(a.default,{style:{gap:0},children:[(0,S.jsx)(d.T,{size:p?15:13,weight:"semibold",colour:f?'#FFB3AA':b.colours.goldLight,style:{letterSpacing:2},children:t.plural.toUpperCase()}),f&&n>=60?(0,S.jsx)(d.T,{size:11,weight:"semibold",colour:"#FF8E82",style:{letterSpacing:1.5},children:y?'NONE LEFT':`LOW \xb7 WARNS AT ${(0,u.fmtStockCount)(e,t,t.lowAt)}`}):null,(0,S.jsxs)(d.T,{size:p?14:12,weight:"semibold",colour:i?b.colours.goldLight:'#857D6E',style:{letterSpacing:.5},children:["Reserved: ",(0,u.fmtStockCount)(e,t,i)]})]})]},t.key)})}),y?(0,S.jsx)(T,{rid:e,by:t,app:s,onClose:()=>f(!1)}):null]})},_e.ShellfishPanel=T,_e.ShellfishChip=M,_e.SundayRoastChip=function(e){return(0,S.jsx)(M,{...e,group:"roast"})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]),l=e(_r(_d[5])),i=e(_r(_d[6])),a=e(_r(_d[7])),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),y=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),p=_r(_d[15]),k=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),S=_r(_d[19]);const v=e=>!!e&&/[A-Za-z]{2,}/.test(e);function w({icon:e,size:t}){const s=e?c.STOCK_ICON_IMAGES[e.trim()]:void 0;if(!s)return(0,S.jsx)(d.T,{size:t,children:e});const o=Math.round(1.25*t),n=o/Math.max(s.w,s.h);return(0,S.jsx)(a.default,{testID:"stock-icon-img",style:{width:o,height:o,alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,S.jsx)(l.default,{source:{uri:s.uri},accessible:!1,style:{width:Math.round(s.w*n),height:Math.round(s.h*n)},resizeMode:"contain"})})}const C=e=>v(e.icon)&&e.icon.trim().toLowerCase()===e.plural.trim().toLowerCase()?e.plural:`${e.icon??''} ${e.plural}`.trim(),$=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'});function L(e){const t=(0,f.useBookings)(e),s=(0,f.useRestaurant)(e),o=(0,k.ymd)((0,f.useNow)(6e4));return(0,p.reservedOn)(t,o,(0,p.reservablesOf)(s))}function I(e,t){const s=(0,y.useSheets)(e);return t?s.find(e=>e.id===t)?.name:void 0}function T({rid:e,by:s,app:n,onClose:r,onOrder:l,group:i}){const c=(0,h.useShellfish)(e,s,n,i),y='roast'===i,[f,p]=(0,o.useState)({}),k=y?Object.fromEntries(c.items.map(e=>[e.key,f[e.key]??Math.max(0,Math.round(c.counts[e.key]??0))])):f,[v,w]=(0,o.useState)(null),L=I(e,c.items.find(e=>e.supplierId)?.supplierId),T=(s,o)=>{const n=c.itemOf(s);n&&p(r=>{const l=r[s]??(y?Math.max(0,Math.round(c.counts[s]??0)):0);return{...r,[s]:(0,t.fishInStone)(e,n)?(0,t.stepQuantity)(e,n,l,o):Math.max(0,Math.min(99,l+o))}})},M=(e,t=!1)=>{const s=c.itemOf(e);c.sell(e,t)&&w(('kg'===s?.unit?`Half a stone ${s.name.toLowerCase()}`:t?`Half ${s?.name.toLowerCase()}`:`1 ${s?.name.toLowerCase()}`)+" sold.")},D=Object.values(k).reduce((e,t)=>e+t,0),z=y&&c.items.some(e=>null!=f[e.key]&&f[e.key]!==Math.round(c.counts[e.key]??0)),O=(0,o.useRef)(null);O.current||(O.current=new Set(c.events.map(e=>e.id)));const R=c.events.filter(e=>!O.current.has(e.id)),[E,B]=(0,o.useState)({state:'idle'}),[A,F]=(0,o.useState)(0),H=R.filter(e=>'saved'!==(0,j.stockEventStatus)(e.id).state),P=y?z:D>0,W=(e,t)=>{B({state:e,text:t}),(0,x.announce)(t)};(0,o.useEffect)(()=>{if('saving'!==E.state&&!H.length)return;const e=setInterval(()=>F(e=>e+1),600);return()=>clearInterval(e)},[E.state,H.length]);const N=(0,o.useRef)(0);(0,o.useEffect)(()=>{if('saving'!==E.state)return;const e=R.map(e=>e.id).map(e=>(0,j.stockEventStatus)(e)),t=e.find(e=>'refused'===e.state);if(t)return void W('error',`Not saved. ${t.why.charAt(0).toUpperCase()}${t.why.slice(1)}.`);const s=(0,j.stockSaveBlocker)();s&&e.some(e=>'saved'!==e.state)?W('error',`Not saved yet: ${s}.`):e.every(e=>'saved'===e.state)?W('saved',y?'Saved. Every screen now shows this roast count.':'Saved. Every screen now shows this count.'):Date.now()-N.current>2e4&&W('error','Not saved yet: the shared system has not answered. Check the connection, then press Save changes again.')},[E.state,A,R.length]);const _='saving'!==E.state&&(P||H.length>0),U='saving'===E.state?'Saving\u2026':'saved'!==E.state||P||H.length?'error'===E.state?E.text:_?P?'You have changes to save.':`${H.length} ${1===H.length?'change':'changes'} not confirmed yet.`:'Nothing to save: no changes since you opened this.':E.text,G=(0,S.jsxs)(a.default,{testID:y?'roast-save-box':'shellfish-save-box',style:{gap:6,alignItems:'center',alignSelf:'stretch'},children:[(0,S.jsx)(d.Button,{testID:y?'roast-save':'shellfish-save',kind:"primary",label:'saving'===E.state?'Saving\u2026':'Save changes',disabled:!_,accessibilityLabel:'saving'===E.state?'Saving':_?'Save changes':'Save changes, nothing to save',onPress:()=>{y&&z&&(c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({})),!y&&D&&(c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),p({})),N.current=Date.now(),B({state:'saving',text:'Saving\u2026'}),(0,x.announce)('Saving'),setTimeout(()=>{(0,j.saveStockEventsNow)()},50)},style:{minHeight:56,alignSelf:'stretch'}}),(0,S.jsx)(a.default,{testID:y?'roast-save-status':'shellfish-save-status',accessibilityLiveRegion:"polite",style:{alignSelf:'stretch'},children:(0,S.jsx)(d.T,{center:!0,size:14,colour:'error'===E.state?'#FFB3AA':'saved'===E.state?b.colours.goldLight:b.colours.muted,children:U})})]});return(0,S.jsxs)(d.Sheet,{visible:!0,onClose:r,title:y?`Sunday roast: ${c.items.map(e=>e.plural).join(' & ')}`:c.items.map(e=>e.plural).join(' & ')||'Tracked stock',maxWidth:620,testID:y?'roast-panel':'shellfish-panel',footer:G,children:[(0,S.jsx)(d.Row,{gap:10,wrap:!0,style:{alignItems:'stretch'},children:c.items.map(s=>{const o=c.counts[s.key]??0;return(0,S.jsxs)(a.default,{style:{flex:1,minWidth:160,gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:c.isLow(s.key)?b.colours.amber:b.colours.border,backgroundColor:b.colours.surface2},children:[(0,S.jsx)(d.T,{center:!0,size:13,colour:b.colours.muted,children:C(s)}),(0,S.jsx)(d.T,{center:!0,size:48,weight:"bold",colour:c.isLow(s.key)?b.colours.amber:b.colours.text,style:{lineHeight:56},children:(0,u.fmtStockCount)(e,s,o)}),(0,S.jsx)(d.Button,{label:(0,t.fishInStone)(e,s)?`Sold half a stone ${s.name.toLowerCase()}`:`Sold 1 ${s.name.toLowerCase()} \u22121`,testID:`sell-${s.key}`,disabled:o<((0,t.fishInStone)(e,s)?t.HALF_STONE_KG:1),onPress:()=>M(s.key),style:{minHeight:56}}),'half'===s.unit?(0,S.jsx)(d.Button,{kind:"secondary",label:"Sold a half \u2212\xbd",testID:`sell-${s.key}-half`,disabled:o<.5,onPress:()=>M(s.key,!0),style:{minHeight:52}}):(0,S.jsx)(a.default,{style:{minHeight:52}})]},s.key)})}),(0,S.jsx)(d.Button,{kind:"ghost",label:c.undoable?`\u21b6 Undo: ${(0,u.describe)(c.undoable,c.itemOf(c.undoable.kind))}`:'\u21b6 Nothing to undo',testID:y?'roast-undo':'shellfish-undo',disabled:!c.undoable,onPress:()=>{const e=c.undoable;c.undoLast(),e&&w(`Undone: ${(0,u.describe)(e,c.itemOf(e.kind))}.`)}}),v?(0,S.jsx)(d.Banner,{kind:"success",title:v}):null,(0,S.jsxs)(a.default,{testID:y?'roast-load':'delivery-in',style:{gap:8,padding:10,borderRadius:14,borderWidth:1,borderColor:b.colours.gold,backgroundColor:b.colours.goldTint},children:[(0,S.jsx)(d.T,{weight:"semibold",colour:b.colours.goldLight,children:y?'Count before service':'Delivery in'}),c.items.map(s=>(0,S.jsxs)(d.Row,{gap:10,children:[(0,S.jsx)(d.T,{style:{flex:1},children:C(s)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:y?`One less ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone less':'Fewer'} ${s.plural.toLowerCase()} in`,testID:`in-minus-${s.key}`,onPress:()=>T(s.key,-1),style:{minWidth:48,minHeight:48}}),(0,S.jsx)(d.T,{size:24,weight:"bold",style:{minWidth:76,textAlign:'center'},children:(0,u.fmtStockCount)(e,s,k[s.key]||0)}),(0,S.jsx)(d.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:y?`One more ${s.name.toLowerCase()}, now ${k[s.key]||0}`:`${(0,t.fishInStone)(e,s)?'Half a stone more':'More'} ${s.plural.toLowerCase()} in`,testID:`in-plus-${s.key}`,onPress:()=>T(s.key,1),style:{minWidth:48,minHeight:48}}),(0,t.fishInStone)(e,s)?null:(0,S.jsx)(d.Button,{small:!0,kind:"ghost",label:"Add five",onPress:()=>T(s.key,5)})]},s.key)),y?(0,S.jsx)(d.Button,{kind:"success",label:`Set today\u2019s count: ${c.items.map(e=>`${k[e.key]||0} ${e.name.toLowerCase()}`).join(' and ')}`,testID:"roast-set",disabled:!z,onPress:()=>{c.items.forEach(e=>{null!=f[e.key]&&c.recount(e.key,Math.max(0,Math.round(f[e.key])))}),p({}),w('Today\u2019s roast count is set.')},style:{minHeight:54}}):(0,S.jsx)(d.Button,{kind:"success",label:D?`Add to stock: ${c.items.filter(e=>k[e.key]).map(t=>`${(0,u.fmtStockCount)(e,t,k[t.key])} ${(1===k[t.key]?t.name:t.plural).toLowerCase()}`).join(' and ')}`:'Add to stock',testID:"delivery-add",disabled:!D,onPress:()=>{c.items.forEach(e=>c.deliver(e.key,k[e.key]??0)),w('Delivery added to the count.'),p({})},style:{minHeight:54}})]}),l?(0,S.jsx)(d.Button,{kind:"secondary",label:L?`${L} order sheet \u203a`:'Order sheets \u203a',onPress:l}):null,(0,S.jsxs)(a.default,{style:{gap:2},children:[(0,S.jsx)(d.T,{size:12,weight:"semibold",colour:b.colours.gold,children:"RECENT"}),c.events.slice(0,6).map(e=>(0,S.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(d.T,{size:13,style:{flex:1},children:(0,u.describe)(e,c.itemOf(e.kind))}),(0,S.jsxs)(d.Muted,{children:[$(e.at)," \xb7 ",e.by.replace(' (example)','')]})]},e.id))]}),(0,S.jsx)(d.Row,{wrap:!0,gap:6,children:c.synced?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"ok",label:"Shared live"}),(0,S.jsx)(d.Muted,{children:"Every paired device sees the same count."})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.Badge,{kind:"neutral",label:"Saved on this device"}),(0,S.jsx)(d.Muted,{children:"Not connected to the shared venue yet."})]})})]})}function M({rid:e,by:t,app:n,size:l="m",group:c}){const y=(0,h.useShellfish)(e,t,n,c),p=L(e),[k,x]=(0,o.useState)(!1),j=(0,f.useNow)(3e4);if(!y.items.length)return null;if('roast'===c&&!(0,u.isSundayIn)(j))return null;const C='m'===l?20:17,$='xs'!==l;return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(i.default,{testID:'roast'===c?'roast-tile':'shellfish-tile',accessibilityRole:"button",accessibilityLabel:`${'roast'===c?'Sunday roast: ':''}${y.items.map(t=>`${t.plural} ${(0,u.fmtStockCount)(e,t,Math.max(0,(y.counts[t.key]??0)-(p[t.key]??0)))} available`).join(', ')}. Tap to update`,onPress:()=>x(!0),style:({pressed:e})=>({flexDirection:'row',alignItems:'center',minHeight:44,borderRadius:14,borderWidth:1,borderColor:'rgba(207,164,95,0.30)',overflow:'hidden',backgroundColor:e?'#1C1913':'rgba(207,164,95,0.06)',...r.look.web({cursor:'pointer'})}),children:y.items.map((t,o)=>{const n=y.counts[t.key]??0,r=p[t.key]??0,l=Math.max(0,n-r),i=l<=0,c=i||y.isLow(t.key);return(0,S.jsxs)(a.default,{testID:`count-${t.key}`,accessible:!0,accessibilityLabel:`${t.plural} ${(0,u.speakStockCount)(e,t,l)}`,style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:9,paddingVertical:3,borderLeftWidth:o?1:0,borderLeftColor:'rgba(207,164,95,0.18)',backgroundColor:c?'rgba(255,107,94,0.10)':'transparent'},children:[v(t.icon)?(0,S.jsx)(d.T,{size:Math.max(11,C-7),weight:"semibold",colour:b.colours.goldLight,numberOfLines:1,center:!0,style:{flexShrink:0},children:t.icon}):(0,S.jsx)(w,{icon:t.icon,size:C-2}),(0,S.jsx)(d.T,{size:C,weight:"bold",colour:i?b.colours.red:c?b.colours.amber:b.colours.text,style:{lineHeight:C+4},children:(0,u.fmtStockCount)(e,t,l)}),!$||!(r||i||c)||i&&s.IS_CAR?null:(0,S.jsx)(d.T,{size:10,weight:"semibold",colour:i||c?'#FFB3AA':b.colours.goldLight,children:i?'none left':r?`${(0,u.fmtStockCount)(e,t,r)} res`:'low'})]},t.key)})}),k?(0,S.jsx)(T,{rid:e,by:t,app:n,group:c,onClose:()=>x(!1)}):null]})}},1188,[984,872,34,986,1189,336,402,102,1190,794,985,983,1031,821,874,1101,858,1125,987,25]); +__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 D}});var E=r(d[0]),I=r(d[1]),S=r(d[2]),o=r(d[3]);r(d[4]);var _=r(d[5]);const b=E=>E,D={panel:{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.ink:E.IS_ABBOTSFORD?'#2A2F34':E.IS_KIRKTON?'#141414':E.IS_GREENSIDE?'#222222':E.IS_WILDINGS?'#30343B':(0,o.soutersSurface)('#121110'),borderRadius:_.radii.xl,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:_.control.tall,borderRadius:_.radii.button,borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'rgba(229,208,141,0.65)':E.IS_KIRKTON?'rgba(180,108,84,0.55)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietBorder:E.IS_WILDINGS?'rgba(255,227,165,0.55)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.55)':E.IS_ISOLATED_VENUE?'rgba(164,98,46,0.55)':'blue'===b?'rgba(226,196,137,0.55)':'rgba(207,164,95,0.38)',backgroundColor:E.IS_ISOLATED_VENUE?o?E.IS_ABBOTSFORD?'rgba(184,147,98,0.16)':E.IS_KIRKTON?'rgba(180,108,84,0.16)':E.IS_GREENSIDE?S.GREENSIDE_DISPLAY.quietPressed:E.IS_WILDINGS?'rgba(255,227,165,0.16)':E.IS_KIRKMICHAEL?'rgba(184,119,84,0.16)':'rgba(164,98,46,0.16)':'rgba(255,255,255,0.035)':o?'rgba(207,164,95,0.16)':'blue'===b?'rgba(226,196,137,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'}),primary:o=>E.IS_ISOLATED_VENUE?{backgroundColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.accent:E.IS_ABBOTSFORD?'#B89362':E.IS_KIRKTON?'#B46C54':E.IS_GREENSIDE?o?S.GREENSIDE_DISPLAY.primaryPressed:S.GREENSIDE_PALETTE.gold:E.IS_WILDINGS?o?'#E6CC94':'#FFE3A5':E.IS_KIRKMICHAEL?o?'#A66949':'#B87754':o?'#8C5226':'#A4622E',borderWidth:1,borderColor:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.smallTextAccent:E.IS_ABBOTSFORD?'#E5D08D':E.IS_KIRKTON?'#D6A28E':E.IS_GREENSIDE?S.GREENSIDE_PALETTE.goldLight:E.IS_WILDINGS?'#FFF0CF':E.IS_KIRKMICHAEL?'#C2937A':'#C18F67',backgroundImage:'none',boxShadow:'0 4px 12px rgba(0,0,0,0.35)'}:{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:E.IS_QUEUED_VENUE?I.QUEUED_BRAND.onAccent:E.IS_ABBOTSFORD||E.IS_KIRKTON?'#0B0B0B':E.IS_GREENSIDE?'#1A1A1A':E.IS_WILDINGS?'#272A2F':E.IS_KIRKMICHAEL?'#0B0B0B':E.IS_ISOLATED_VENUE?'#FFFFFF':'#17130D',web:b}},1189,[5,822,823,828,236,826]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"STOCK_ICON_IMAGES",{enumerable:!0,get:function(){return A}});const A={'\ud83e\udd9e':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAABACAYAAACKhS4jAAAZTUlEQVR42rV6eXxcxZXud6ruvb2r1ZJarW6ttpGxZeMlZjWLbTBbgIQQZIckjxAYYHgEQjIJPDKZkc2E/DIhCZM3GSCQeQSSEAaxOazBBmwcbGyQF+IN28KLrM3ae1N331t15o/uNrItOWbycn+/+2vLt27VV+d+56tzThXwV1zPAJLzt2BAtgDiBM2p0JYKt2BAFh8yQADwy1Co7s9V0cc3RaI/uwehYOGZOGlQYzoXJ2oz3v9PNAGa4M9iP28DBgCsKQ9/h+samGsbuCsSe/2HgUD5RP0a41mTAJXvd0ILggB+uaJiXgTG5QlwdYCw/eVk/Pnlo6NdLYBYDuhi+xaAlgP0UlnF1xpM4yof4BtmdPRp5wnq738HAPUVxhti1Z5VyhGAjlrmpdfB91+bE8GrluFQdhlANBGu4uz+saRkyoGq6t92RKK/bgL8Y61V/BprKyvvGqmpTXDdJOa6Bua6Bu6sim17vLx8Go1pV/xdHw4v59p65tp6TsZqmOsaOB6rTb8cLF9UaCcB4I4ylPTFqj/WNXWcjdVkubaet4Yjj4xpQ+PyFwDu94VmdkWrP+K6Bk7GavhmT8kZxYkxIAjAy6GKK9LVtcw19by3MvrS2nDk/uForJ3rJ/HOyuhzCwCDAVE0xu8rKqbGq2tSo7G6dFtF5bf/3Rc6bXck9iTXNXB7VfTxIrDiBNrCkfu4po6zsVrbrq51cjV1vDkc+fpYeh1lcQJwg9tduz8S28G19czVtU4iVnPgSkS9Y/0AAPVEY6u5toG3lEf+pUi9p4LBuSPR6s5MrDb7pLd0duEdEwB+H6q4hWsb+EA0+svimHdY/qZkdW1yqLpu4wLAXaCjyYB4saysaShW06er6zhTXeNwTZ3uj1Z3/UswOInBdIT/BVDyDsC1NxJdwbX1nInVZLiugbdWRp8stDGaC1a5ze+fnohVp/tj1W0AXBLAvvp6NwDsicQe5LoGfjUU/k7hPQsAuiOxR+zaOn4jHL6mMJ4BgHLVtR8djFZ3zwdixzJhdyTyBNfWc7a61snFamyuqecPw1WPjqWYQN7q6vNl4ZsnmebnHK0cQSRZawit13DeSZxnClz7fiAw1SsNz66s8woBWQcw3j9wwGZA7HCyq3Na43yPaxYAoKkJAFBlmmVJzc5rqVR7weGYADYBxYBMAbS2LhjaXFn1zN5I1WMA8LGt/5DTGhIQIBIazNWmsfTRUGiGKLwnCFB3+P3hWS7zOwIEzSCTyBhQamilSr5HAD8cCDQ2FOgRgfQJIgRN2sMArQbQnAejX8rldmY0RnNANQBgxwwFAP3slEogU+/SQwDQWpCyEa21JMJWYEhn3XPnuF3NUyzX371fEb3pssG+V1JadUkiYoAUsy6TsuR8y7qzIDcsAOAmr/eLFdKoz7HWRFSgE3307aHUnl2V0R8vDZavfjlc9XUA6NO2SzMjTNQDgBcWLAkAP/P7B0uEGBphXQkgALRqALA1mwDBHnUfpRTrnNFlCVbfB5Ae1bompbQNZl1r0M0AnC7Nq0ACAGsAAsxcLYzmB4PBBgK0aAGMkJBX5CdYAEIChxz7zR8EAp9pNI3vhgixMikXAUAf86t/SCWufUDrdQX9LOo52tJpx4EeFQwXCs5a4OZR2ry98Pdn+wafnd7d/SgAKAVIgqGYOSDknMeCFbMrhHxRg0H5L0s2sw4YRuhCy70EAER9IDCp1DBmQ2sigMBMAKPOEG03+nxXCSEYrPWI1mEArlmHD/d+YXDwuZ/29qaKiyQVnGfRyMhon+P0uwCPHxDGGNAMCIeZjpXnbQWnNoXs1wzNzMorhetyj7Hw/w3G/zzoOFmDhKGLfTGjxjCv+VEoFBSmlNOV0lWaCAyQIBJZrfBSJnPYQ3JyYVEQLkLoPMDL+RXTOHax4E9WXzaBirsDgdCRJRaCLUL6glJ3GgCWFZovAdSO/GoON0ELQDNAIIJN8szNlMuRED1UWNEZEApgizB7qsR8caU7MCUopam0VgAgiSjNnFqRydjDmo9ImIfIf4HH4yWAl50gfChOwiiEEQBMm+F1E2Xmu1z2se2bC6+cZtBhi5DTgMHMcDRPnupySQmMgrlIP9Jaa78Q7jmm91yRgKoTeasfuRymzA5HZASxCwAcgEulKPlKWZm3YDmaMHQs9vHJP4M2uAxgjjvOccHVssLv8+n0cL+jMxYJIs2IkpjkSguvDyIFoiN2YQKYCCOaZ4oBrfOyRgWdYYYL7LvYizIH5DAAh1mbRCWnELnHDjgBfE3Hf4yJgjwsL/jMTSMjAyOsD4EImw3F73tVWaBGPL3eyjU5+dCzMHESlMc4WSjm0NiRHYA9Qri/nPXmgowDxAQ3Q+eYrd+m05GCTh9redb5zjPdSnWUGIbrK75gyfjR8PFM0/k2I0EhOkYFY6tl6/2GokmWNbOEyVPgxVH9lAoKGx4SJWDOO2ve8HAkoasS9/QL1VgnbMRsIKwkBSCnA1jVfAIkDqAMIRAtUO6kruZmgdZWFRSi19KEq0ZNOCzgAasSkFBjgIv8goUKkpXCR6KqOC0GYBBoBBraIz+XtDB9vWljn9SCBOEit9VYGGxCHLLweR0QMyB8gCBoaAaPJMX49GltBQB8mM12EAPlLDhiavhZSOcTxz+Kh1KQMBJadYGMOjAzAaQAhLXARSlD28QkQeTTeREkiGhhsHFANBPQCgjuBQhusCgsYDmLyDWoVN8/xDtH6QQ82q3UnrmKQackBOqTwAcVQNzKB8s8BjiAUa3TIkccP17uGOVMokoJCiuCCSIQYVA71QDcMg+KJlCbJMA4JHR8RVnZ1y4zPNM0I+Vo6NaCph9n+MLvGYbY4RhOVkZSJH0OU00SUOIof2eABRG6lXNIBA3ZUVgCjrKmDcCm/K3zKy8MoOYrXm9In0g+mEyHGSnbvvFSt+/RR8tLn/QTxZjgYIL8thnQBODBdLprEHo/iAgKmiwFSF3Qo09GYCKkmTqFcnhjRisWRMfpdfHOOzKjQsiSezye4Phaf5gAoJZEvwChyXLfKQlmrWk2Bg0jlGF2Lh5TLThmLNbNkI+kUocHcliFnFEkwDjGYSYQSki0iTdTmXWjzH1Gnll6gs7JYYZHCHmay+8ZX+uTxACFpEwIMBzmHAPIMds678BiJZDTn2jD0YtVaz4C2zRkPZ4alhouGCyOZgMDLImQUk7uY5V9W/xnauijuHI2Ix9V6hPpsQJEO7N3vIdtBQs6di6UBSCYhcgnMobQihslZneGQhcWYhQ5zmKl+Z8hbrAPtu0bMB/I9VmMETeDCUxgDWhmtqUQchj6lYv6+98QbYC9x7F/o/IDjf+l8jOmDLPMaT1yrOUZEKejzd4QCEx902t84wshPz/kt4RghsGglZbBPyh1+dsD/kdfDgYnFzIhMc5ySwAw0GF8mFsXtnlfQDA5bDKRRSQsKa0ux974Qjb7DQE4BgNEAwOteyrNpae43VfllLLzcn9UYYgFCeqwc0/P6O3eXkgN9Vj3aAKsqMf74O/9wdgbhqXJpcXfp21oVvi5zyNWWl7VKey6uzP2/70AI1cf+5U5P6azJhy+/TOW9QuPozW7mIXpoXgqnRgF+hPgt3+UiH/vP1Op3hZAGMvyK2vuhWT8lhuk8VzYkPN1PqpzSEASiEgzA4xuZe8ZI7WqaHUC1MqKyptiLuuz52RHna1CG19K27A0Q4Fwvq2wTyrZlM2oetO84p5QxbU01P80FwpcHwAmAfZDvkjlTNP4Rz9JONMnwYiUaZgemezrX/2//7jq9hVAR7HasbygUChYkm+Bv+K7lYEfl5tySUhIH2wHjnbApsGGkJR01MirdvbCpf39m7cD5oy89fQNXm/lj0tDG8LarCNWOmlq4dcCDuVnmSWgQwg0KEeZwpBddu7td3u6L2vGPAbaFAH6X2vLY9dpz89qtV6qJtUqOWOa1NmcI1yWGEylnyt/qnUJNzVZ2LHDLlbNBMYE+o8i2d94uPvGjY594dpM+vbhmuh2MWcm5BmzQbObnIDLDFaxvJoAngnkCHAI0Hf5/ddVklGnqtPKrrSFR0nkCqRTyFegGh0FQEiltS4Rcr6rvPw8QptNgLG2vPLLfzdqrKl19FJbSk3RKkLOtgUgoFm829f1JgOidcYMNbbcZ4yRw3wW09ws6NlnN4J5455FCxtKS/1NyOYcGELi4EGeMZT42lC0unxn1u7MGMaGJ3h4e1nWuhhTs0zX90EeMqGeCEPYMl9jKwyVI4LIE137pXRNt6wl71VXp2tse3nU471EVJTDKfEr6fNAlAQkpBTDjpPsGRh47KF9vb++mkjr1tYTFW/HOFBzs3z8QPuCr0+f9iakhHYcjZ4+EgNDhNE0kEghnbOzI6T3WVkrWn5+Jqg/P8ximyTnmYpCyjx+piUAZICUth0jEC51oekUrf1BFoI0LJfZOzi0JeXYT7b1DLy/5N13//RJQHm0kxtjS80E8P1z5oR9LnkqtbauB/DWzMrK754SLLktaFmTRU0UOhaxoRUjnSFXT48R7eiZBlJgJw2xi0i3eYCsBNx6XN0l5DMhr1I+rijTas5MW5oGCa0NkJCd/X2t169Zf8dbhw/3Fl6xPvjsZXeWel03diRTNy56fdV7RYc9orWrWxZIAFhcWXHx/5o5Y23X0i8++/CcObPPfPn1nzy8fdPZu4aG707ncrYwTVNYLkuUBk05a6ZE06lQpAC3DfTmwANmnuQTJloEKAXl8UDMO03IgN+EIY1hrdNth/tbalpXXL+6r68XAH4ya9bc7iXXvDqvvuYBtzQOVcNoZ2YqJvDHFfl/MmtWeOmpU35dW1l+eWIkMbJnaPjn9/1p14MrRg4M/+6COY3nVNR+UxrG+W4gCMNQPJywQ1u2TTbP6DOpLAe1vgo8XJgAjw+etIbyuPTwrOkH06bVy05u/av7Ov/tG5s3Hyjm+xsuvfjmpkjFj2AI2j8wcO9pK17/eSFXOlKjP7Z8QQRwGPCvvOLS+6aFy7/lcrvRNxzfuS858pQWcm93Iq3jyp5UJq2QbRiZUDzuO7ej5zZzbp+PqjJQmyrAXT7AHJ82DLABUJLV6Nra6l/ud7s+rresnnK35ZJSWtlczpxSErw+GiyZ3x2Pv7Hq4MG7r39349Z8PEYYqzY03naNyM8Qqy684PJpFeX3VZeFTocs1PUFAVoDjgMQMTIZ0m+9D0zphGhMQ20PgveWTggeAKA1yOOBvOAswO8f4wz5F4ZG4iP7h4fv/cxLrz8MAG8vWGAsWrPmuHKLMV54ekQyW1tf+1p9/frbZ56yRGsx2dY6k7RtV9rRpW5BpSUuy/BLjtc7zjWlCXcpjDSTxyHWdKL9LjaEoCGt+nd2dDw35HB/1nGSlhBDAbeRnRoqH25tP7Dprra2g4IIT197rVzU2uqcxD7X0Vdhxs79MydF/N6y2QvDFdOrykrr+0Yz9YZGXZlp1JX7vSHxwTZTDXRDnD4M7vJCHygBTDUh59m2YUarkJh5arpnNNWeZT5Y4Q/sGU2lO984eHDzrXPPeAeLF+tlS5bw8hNEuhOCf6a5WS5tbVW/Pe+8BVdMqn4q6PXGII18ocJ28pVRzYMH7dxH1tad1ZGe4TrHK5gU04lMoiXYzDD1B717c2fNOVRtuuaCEITLBQgBKBvdA0Mvndn64tIO5syxPD8Z8MTMaCSy3lnyhXeiodCZB/r7V0Y87j+39fTvefHQga1rO3o+vmtqQ1mksuniUyObbq3amZzu7PVA+BWNW2oqpGSckNqckqGBM6ztyZ75j61o/3D3mr6hxI1TpsQW1EZnOIRrS0sCMzZ2HHrwrFfe+DY3N0tqbVUnDb74wrqLL7z1nMkNj+zvH1g56bkVlxSfv7V48aVTQv5rQl7XVQGrNKp9+5WqfovEyoDgLb582d8s7OQeSYoJsAHRmAV/vp9l8lSgbyHF7SFYmjf1ZJIrt/WPPL96f+f+e+efsarc7z9t9d7dNy9atfZXRfr+RfAMkCTif5o+veyOWU3rQ1533SMf7rqgOmDFG/zBr9b4PM3lPt+p8HqRjo8c3tk3vA4i6Ztz4XsLpVubue0ejTYPyW6LOG0cSYSpPAealwafnmI2CatWVT2Z6m5ad0Vj6YVDo8750WBJDNDY0tlz47q+wVXXTZ/ynt8wgu8c6Lh88VvvrOWWFkHLl+sTqg0WLJB6zRpnQXXll8rLS6fu7Tz846fa23tfuHTRB+Gy8jCyWfSn0zuHhwYfWtfdO3JOrPqWxlDFeTq1Cyz7YTZlhT4lw2JIgvtcQJqAcgWqzAJBAKMECYMWls9bMgR37pvvrVr26O6Bnr1XXDHFF/T++7RI5WP7U5m5T2zbtviGWXM2TA1XPPP3kchsLF/ex8dsIh+filVWMgB4TJHe19P7dOOLf/g/v1o4/6ZwqCzc2Xd408pDHV+e+ftnz4in7fQXpzb+R2O04rz9vc5LIzl+lbwSWkFJDxMmOaCzE6BFcdBpaaBMgxWzcDONZnVqNMsHomW+mx8+//KdHV+8+v43e3o+3HKg62YBnT03Fv7dtzZvb9/U1XVtfDT73pRIZFyn/UtFUDw+e3bp1TOmrrNMs/6VPXvOXbLu/S17r77qZ1NikW/F44mR7UO9P5z/yuoH1txuXTNvCj/ji0tW3ZYQ/Zp0wgRBAD4bVMrQZaRkbFTuGdTrp96vPrfukgWnR0pCd02uKL90V3fvL6avePmODZcv/ocz6+t/sqXj4H1zX1nZcsJ69EQPPrhlnjkveqVa/afVlyyc3PDart7DD03/w2u3L54cqvuvsy/aKpi6frNzz5fv3LJlqyDgiel1TdcEU+94M1Tu1DOLEpswZACDdj7ZA6BHpTJcJJPMvwm8O3R9kbrDX126gcHV33/rtRn/0ZUY7l56zYaAx33app4dNee/trl/Irmc8FTHvOiVipYv58ZI5U2jOVuv7u3+Nwbo/qnzGi3LFWyPj/zizi1btvKCBW7FoMZc8pBdFu/j8xLAZ0e0WJwALU5AzEhCTItDTIvDmDUENA5jtDTd1QIIvnKelwDno4GBp0rcnshXP3PeQgLUnsHENw8lU+/GPJOKuwbjXsaEgWves2lHIn44AOPu2zZs2XMbgE6ff7LfMKjG7dndAghUVtpg4GwaSGyaJdvnZtU02m2AXQIYApAeEwoDpA3GRie7bzmgr4rBZgAdfcMvzKyK/KDcZV7GwHMXrFz5LoCLMF70eBKWL34ivuSlP955zkuv/JSfeUYCQEcmPW0oHs8s/dPq9uWARmurxhIIQHDMoj/D0JADOabOHCidA1wMuAB2MeBmshV4a49vNwB8PNSmuaVFXPvBBwe6E4k19cGSK/mWW0xuaRF8EmV94y8eHGLWWLZMYPt2BoCQaTWZhuxc0ztysChdhT1GHE7znkjOBT1iEo+aQLZgG8EgjwKV2GQGM9lFdakObAWam45YVu0dTP6rMl3fXL17p/fWtrYRPgkx+YvgC5zTxc72jqSeP5hOpgv5ZL7+3JoHsWar5+OGgDcTcMGl3DkWZTZBaEATdMLS6PCLgXZv1yFyDwKHgOVgwnIGgMveeuttABtagEwxuv2rwY/hHQPAFW+//djYikNxj4oBejiW2qFnpOIwUEmjxOSIfH3dUJA1KcAPZA/J0bVrgg4XJ37kC4OkoPRyPhnCnDz4o2fS0iKwYwcVg6XCF9EE8GudwQVGVpaqlMWM/L4OlAAsBS2YDDfD5U/7SuoHQzSIeOHoiirk5FwoxJ80esJfcRVKfboJ8P8uUnXvVJjf8UhhqanDLEMZIsv5pKBtG1CDbsbuEh6wse1DZ/R7Fw/1v1KkI30K0H81+CLw35aW1i8wPb+q8RmLUZ9k+6AX5tm9BL+T314pgjcBJA3Y70TZjGYoMSLtnYfxwFkjPS0CcCaq25/oEv9D4CQA/ZuysprLvZ7nagz3YieYttE4DGFq0j3eQhXz6Ju7vRBMpKYN6EBlRpzp9nxvcyTy5EzAVzxv+TcFXxzg5lAoeJFlPV1mWvOytnZE0DFhMVEoC+7xHJ+MMKB7vKCKDKRfC0Va2KydOS73dY+FI/fTCTbp/r+BX52PVPhL0lwaNVzn2ko7gsjIn3UCqCoNHnYBg678sTdF+UMpg27wsAtUkyxYgIgBqZnVDNO89Y/h8LmFeqn8m4FfiBbNAM02zcUAazCDhAanDSBHoFAGVJKDs7UcHDcBD4OTJpzNZaDyDKhyFMgBnLQgiMlhzT4p3SGIyz4tFuPTM345AIgyw/TlT0+BIAH0u4CUwfDZipoGBLdVCr02CoSywLALMDSoqU9pg4kGLcEDLqBwrkUTdIq57JjQ5G9CGwFAt+dyXRBCAHC0YHYyBuv2EoIgQ1TYwpjfqziWUmwLxdUJZZzTo0WZLYUthfqoVGlbsILWBNICEGGiDz4tJuPT0ya/qm5IZX8akHRepTSngTVgAalOr7PXSr9QNTkzI+JzmowzBvJ2JGA0AySS2JjbEvTUDPlOy9d1BIHI2pfLrbqnL/NiQQzUyWKR/wPSMABxZ260bxbRHy2iQELr4GGlDrSz889n7Rr5np21Xq23eEdC8b59Q9iWc+jtPYfNh776of6n5O7S5ysCjm/EUSU9Sn/Yo9SvfjiavPfZXHzwhAedx7n+G1W4GfQ2sVDSAAAAAElFTkSuQmCC',w:47,h:64},'\ud83e\udd80':{uri:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAtCAYAAAAeA21aAAAWJklEQVR42r2aeZhV1ZX2f3ufc+58ax6hikGgmAVBEI1CoaCACEZTOEQ73YlN9HNI8kU7dqfTRWnyGWM6MZ3BBLWj0dZOVUyiokFFoRyQURAQKeYaqKKGW/Mdzzl7f3/cW1hGbY1K3+e5T/1zz6611l7vu9Z61xF8Dp9qkGuqEKIOF2BBIaHvzGBaiY+5JWEquhJMkAofBlp66D96wvzh8teczRrkGqAG1BuLKcrK5yfZLhcIUBqIuhwKWew50s0bTzTy2tqDdAHoKgxRhwL0Z7VdfNYDaqswVmUc/9Fsxl0+hmsLvCyzPEwKQo6wAAVIQAoSjQH15j7Psotael5QYABaCNTmwqLpM2bGtgbGDvqxM64Z6f8xaOMmbd5pT/KnRw/y0I/20qI1AgHiMwbhMwVAVyNFDerusym/YhTfKvPzj1l+QgA4gE4HxjVQRp/XGjwSTuxt8F17XrzlTxpk5qYFIJYy3nqgIFU7ZnJ0hTsuYguNiUIj0RIEJhIJkSht+7u5e/561gJudTWypgb1vx6ATBq6Gy/k8qnF/LQwxBhsQOEiAI3EQGALzfE80X080HWkU1wzN9m04Z7p5P7zXnqGQ6gG1DcpKP2XosCOwvLkCKZ1KISWmfvVgEIDJoYScLyXJ9bu4v/ce5Q+DeLTZsKnCsDQ7b2xiGtmlPF40Iskho3ATCdm+uS+XksdOJwrQ+3eLZs69fUsa7GX+Lgr4OHCdzr55uKXeWoIQrsu45+Uh51NfynoXRIKP5Ma01fsndotver9NiqNlgIXL2akl9cea2DFN3fT92nhID8N5tHoR87izMll4pfBqYagQjqEhYXOGKvTAQgczdVu1MOfswZa5ixvmXtdLtvH5fN3pSHK4i4mQFVtmiFyffz91Gyem3F5V9nvA/21b0Z8RuJwlsIEPcwtKRAaTJXAyc/lgmVn8BshkFSnoXTaA1BVixICFozhrtxxItf1obCEifme4wBaglU+aIxwBWeYni9N8Fn/le2jEBfn5AB71zbwrABYgwDUgMurXh/ebEc+pb36hpKkQXbca+hMfv912kowVAJnXB6rdn+RL4salK4+zQGoqsIQAv3f53JBaZ5YQUBoAwx6NPToDKdnLHSAwhgF4RSelKQ/JRQKO+oi26J8Z10bMVWNrNuf9q+nnyfjCZLxpEV20huanGXDlAjCzVSRD4JXSIU0QI/28/3VFRSImlOkenoCUNuRPvy8IlZ6cxCYKBTQqd93+wAiTVgE8pOEHZOoKxV+rOZuHpi1jr/oKgxRg15Vh1LVyPkbqG8Z4AdKC8PvSsczcgDGA6Ot9wL7QeslNjrHT/lNFVwJsGnBUPH8/AMg2IQCjIRisrZADd10LHOS/iBbEkqhUG5xQJmRfrav3cUdWiOGNTJa1KBrqzAq6vj+7k4eKA1qk5Bj45WaUhMKDHA/HOEqXW90np8lgKhM2yg+9wDoNAGpm6aTlWVQLlS6FHzcQ9pnu2PzbUMYTu+Bblb/pJlk3aoPhEu/U4fWqzFXvJn4RirlPoHQFj3KxQWKTPB+OBRkOgoiaDDpZzMpkCLdRZ4WCAgBb3SQSmhipDL9akyD8yHIS2eHa+Q4xhkTI9HnD6ql5z/PbiFQVXUfdOUugRJrsQF77tH2Lze57n8xoEwVdW3CArIlH3G3AgX52QRum0JYpxuLT5wB5t/QMGg9H1PUE5UedhHVc+W7SpP6kLTUaKlx8GP1xXTr87363nmXcd7hJXzpQKexXjzobhhOFQI4ZyS+f7vMunbpNGfesXZ98Nkd7o+vjjAj37Kn0S9tPagt8SEwU+nMpD9OdEucwdPaCNWCcRW4D81jwXUVvOwRSK0QwwxTCrQ0MPBAb4zNuweNn85apO+QCf9ccAiEnWTLCbl6dI39O12LQVV6FtjxHXHX7El8ry/iJeDROKQ2vrDOvOO8AvvHRQEqsXEzRGv8FcxcPBgn2s29lz47cv4e0dir9CfvDP+2MpjuScS8hrKVnoMFBlJo4ckMLSbgQUovRo9D94Fu7s99jIvOXqBmvXGocO6MByoSFz9WkTzcHvQKy7kyc6ASAnXrErKml3Ljpn05euHDFalFj05IHYsEF46bZecWP8HSI/08PAgSb6YeaJw0fWZ8UKi8ltxJawP6fA1s4pNXAvm33L4A9WB2wayRAfl1tzFMakuxUE1hVJ9HM+BxuvrElu0d3LGjkfMn1/Et/Rvctg7Ppf+xpUAHPa7n5KBpPbarQEvn/QaOMBgbTxk5928pIYmwmvoto/5olioPMAZEYnwtN9Sf4LLWfrYkQOPFxERhARbCOZql/J1hqzDbrURDJZ98ODL/htsXAKO9nBWUMqClckSvz7R7fa7XEEafq5p/0cbSGhp7hyZFWvHmh1W+JbVQCATaFQjTb3JyGAR1foj4oCtVJG4KU2ptCmTQcmwtOAhK6NXCFGt5Dnjp9UtZUiiNayu07yoctNsREE5bQJiWxlUidNo6wU2ZvwlXtyfQCg3K1FpKhOPgNsWSv6ihsU/Pxhoak8+umZ1Uwun8yswuDI3O9bpcMrGbvAJ9KHOoBIgX0RgSTusVk3qJpgxVOXpQXDyut61nkOMg9JpSXF2NlILU+c/xzMRn3avf3Vj4a3dnqbCbw8o00S5ax121FYApmFojdDVSV//PPn5cBoiNCzAqb0bzS9gxiLXtsPN61HV3hyxrlmtr1wzbxuDI3lSXFTV/dgSP2InNTrTWSCF22t0xY/OVs7tmTsyLKsvSYmJRnC0NshsUbAKtEUKQ/OI9+qVvLWxd/YVR3c6sUSmjO+K8Ne5eWrRGrhGwBvjeAsyaepwX5zMhld0oHOnXRmtAmW1hs13Zzz6Wk/yDaAexn9SwsQytEWsEouZDoGH+T2KHrEEtrMehfvg01teTY5pfn4/4eaGU56hJER0uTpgLNfcWeegQh3lk+2qsNZXpGf7ESfePI3ONr00riXsA1R+TurObTl2NZD/y0G0Yuho7bhkNuJq5I2NgCHwWe3U1cBtWDSQBqEfVncfZs0bxx3y/LkfGtCMdaM/CcFXjfQ2RgXtGkXvJLK6uCHDtoGJgX4QHhOBZQA9l5scGINOnu0Dg1Uu4cnoRS5XG3XmSuos38Oy1kciO50v01y6QoTdCps52k0IZlhamhy9p+N3cB7FFOojmzhG8Go/orX6/nE8KJS0tOiWDGUNOdRFP36Kbl00CUxoCR7O9g2OLfqIVkFzkCU+Ykidy2mWib8EZqZ/nZ1GuBklhYZonQ2YypZ31Pc6fty1n6ZgQ/68wxEyAoIY8H0sPXcl/17dyp6ihceMCzIX1OB/VBwhdjRA1qBcWc/G0PO7O9zPXa6R/GXNw2wd5fssJqq99U+zqLCp/rWBm3/lqVJ8jwUykaP5hI1N+tR86O0lVgXsUvE9+W9RMKJO3q0FtSyGsfYfV4y3Nek/IR6jIw0jHRXuDlI0qEZdY6aleNLXpzdFB9rpKBA81ZVUOxDzZg7aOTyhQRRWlMT2qOCFESxhnT2H0dTv66+DCdjEtwDf8fgxiwsaWluNzMTO2d0fZv6WDr1y6gR3DZTQxrG0/NXa/dRn/OiGX74Y8eIclTBIXDxaiP0HfScXd2/9QevjK0eJR3zkd4cZ+Q7R1e53DXYH6AYes4mBqYOmMnt5+pcs9mtG5FsW4GVR6PoR+35cPpHv/IYkjKelLGMSSBvuaA7ppwOKSbJuclqwj9aHeV+ae3zul0MP5uLh0+HWqMdvsSjqPOtO6Nvo9rC7wcZ4IQDxKz7tdXDr7Od7U/5aGgxiOeWrQB1byg0kl/DM6PekN2Ox+qymQKvXKuWNLoq5laAADA04kqI/tzC9qlubkoza6KGiLcdk2RWGHwqwU+N33nHOGOaQ+ok7LYWEZ/huBSKvKaDTy1YYs3d0UFlON1J6CBZ15uQHKGBT2YFOWtf9EgGNRddfVbe3VQ4+vv5iFZ+Xwf0M+Ko/38pupz3D7kKYphouS1WdSsWY2DTa4vUme60uy7oZ3ebJtf6nv5jH2yzMLOXNKab9bkJeSroE2YpZ8+Z0cTrpwUUUfJeEU5OJSiKALTRdaCSQCIcVnVKB1+itNiCckf96by/y+ICOn9JDKjzvHDuaY2zus4y/EY7c/3tn31J1nUnHrRGY3DzJGmKS2tfLihhYGZpYxWLMzvV/4AAfccz6504Ms7+glGndpvnkH+2rLYFULccB3T3nR2skhef3U7KQeP3aA9sNZel2nTy6eEWFUfhIVkoixAjwg+jUcUJyWj4BXGrIxW0J6glfrt6Qr9gyIjbK484Gl49xgsRRf9Rp6athPvmGk4dYXJ3q0h2/OWsdDw4nwPQjUYohVuE/O54KLRvMjSzEn7nIyy09jez/NSZdtnYodL76dXzXKsL46y8TvU5J3/CmxYlo3vmwNE2WaSCTQpOCk5pRW+Dl9NCBM2HU0xJ7GECFDk50Tt8ef0b+t2M8Zfj+lGREdXFJoZAZMpivhlSZWX7yBB3U1pqjBEcM1/ucu5PIvjKQu24eJi4uV6dkzDtgJUnGHQyd6fKP3NIdD8aRBUTjF4kk9WGOAETKt3HRpaFSfw97pw6EgLNjbHODYgVwu9GpCF7RqfAiiEvrNFINeg6Rl0OchoVVST4y4/rAbwMXp07g7O1hx0Xpe1FUY5sYFmKIO58VKFpxbziMhA4EDJCyDkz7wOOC1bXyOY5n4LT9Ts7ITlOY4vLorn37bwEFgBXT6dmIamk9T6g9XmoQmS0EIAa0h4XR7dSLqEcmU4WlPQJ5tvNQaT22WfeH6HtGfmjXdXZvtY0q2i55XxKPblrNC1LHdXFiP88BMJswZweMhgywEoiPOrld3WA/M6co/1x9wzg16qAgGleVaLsJrI4MOOUGHOUqyIaWJpyR+Moxv8wGB9HRwgOsI4oamwRac2JOjBwwdbdXu0ZhMbn4unnpoY1ffzlMs9zasz2HlWSP5fVGAWQGDkvFhHv3pDJYZ1xUTvHEWjxdnMRMQrQO88vBbrLrpkL3p/kTv0xt1/++/EMv7yx8Tbtu+JMHWASs/FgkY3Sf9HPM4dGlBgdehoMyBsEQkMhL56fI9U0pbIz6O9VkkwykCowa0zBt8O1Tc/9KSydH9145Pjq0aS+HaBg7pauTUTqyVO+gs0zydE2BUlsHUUA6FIS+WOPwl7htXzO3JKDRHefiGOm6ph8SO2VizAbET++aLyP/hZM5q6WL8u62euT0DnvlFeMZ6BjyiGyFKCqNUnt2PHmcgujQcVWCdxgyQsPFgGO/RXM6t6EdM7gUbG4mVVm8hlUId7+XX/76VOx5sI/bKMOZ/dhHL5hZyzYkoL4nXl7F+VD6e1g5+O+8FHgOoXoB5Vz2OBt5cxt9PyuOunADlQ82R7dJnIELySI7R0BTi7fwYV07uxijRkGdAj0oToTh9HPDMvlwmdYSpmB7RlEUVKcBIL2aVAxJMvMimXtbdtpXrn26ktxaMqwTu8FWbmAf+LWnuTunMpubqP+BeORL/D+Zx37gsbpYCsEliYpzaTMl0hzawuYTnkoLzJkcYdbaNLpQIB9inIK4/xfLt4/GfTAme2VXA1JiH8rwUIuwgtEAbGjc7RnZBEpVCaXANP1ZrL3/5l61c8chxkoi0arxpE7KyMtMKCwHq9xisSq+gV5VScN98fjc6lyXEUQg0FgatQdxuH07ABaFJmArZFKQ+bpBb1s8XzhtAjTCRUQWH1UcuMz5TCTThZI+HjfuyddAQIuG6kZNRY6t0zWafFJ0eObircl7f5aPyuB4bFxeFH6spwsOjn+LrWqOGb5JNDUJoEKtwa6swVgk4dAX3js5jCTESGPiSGvVus/jxO/XBXTHDzCVbTOrCKS+XzMrzivKIxyHZ7yHeLPH1OumhRp2mSiCgPWYQinnEhSMSMC0SjMQpPpFia9DgTzPq2MtT/HH/FbRPzud2QJEkWZbD1zYuY5MUPK6qMMi81XLKxKH28JVFLDi3jBc9GqSBJ+YQPdDNrbPX8VuAdSs4Z3qQRe0J5o3R8uxAylcycCRb19uIqRP6mDYihnZAyNODfUx4+UAW4WM5zJ0RgbJoOtgm9CfQHQP855tH+Mbf7SG6ZyXfm5zHXaaLwoNojfLmyCffewfpfZpgZWW6YSzP5kafiUcKrEiC7m3tXD57Hb+970yCjVfy4OIctowK8f05+SwvzFMlwfKYW3JGP1Nsg91tAeJJiTBPTweIAT0xQ3d3+N2KnKRLaSztiAbi2FkSd3wRX5s4mhuFgDOf5u53O7jVNbBxUfkGc391DmfpzAB4KgDVGano/nOZNsLPChQqoel/rZVVC19gg65Gzh/LNaPyuMEjUCQzw6prQNwwKIyJ6dm2ndfjVVubQjA8xJ9f5oNAH2oNiIA2DccURmp/ntT78kj2eDUWFi4SBzUuxK3/kEdYa+SZz/GLg738GInh9WJUjuAqgDW16SNNgDWb0uPw4mKuC/jwa404HOEHX9zEy7oaE1AjfVyPRiNQCU2su9WzXh3LdvtcUZrwcE4Iwz/SD7s7/RzNSrlnlCakthFCfG7k5wwMWObhk36nS8fXNcdkn7/Zs0v2Gg3Hc63mK+a3XzMpnzsNB5HvZfTl07lYCJ7StRgrb+LetYtYWVzANL/kvDOLCRpXEQWEqUFQj/va+eSWBFiMH9F6kj9NX8f9QxPTfWcx+papzNEOwhaYB7v59oz1qYegE8DzldLcOZPD7jKvYH4W8uxdjdm+sFdRmJdSykZK8Zlwr4XARUhz+/FAbM8A37i3rfuh96VGD1gR/r0kzKp8k/GY6MWjmAs8deg1zGciDNzQzi0X+VnvNyjMTWDpzCsNsq4KKUAnfJQpD+M7u3nz1Qg3CYG9dl06TQqDzBHgExa6c5BXZqzjEV2NqRdgarAfbet5486Dke9+qyGycF80Of3AoPPzVxqy4r29XimtNFiUft+rPh/rttIopXExEHgx3zlhbH7iqHnpvW0dD2kwdRVGLRhaI/VqrDtfp7c/zgZMhAYRSZADMOEkTm0VxopN1O84wcp9PdxZ38ep/aG5Kr2qFnsGOdzVxPKj3Rz47m46q6uRq0F/fScsG0mF14PGRu7u4ZcCnLoajFWZSl8FRhWwCpyftvQfBm67tSTnqe7d4e9WjjMXTy6Lp4dyF6V0Bkjv1SCBHqYYCLQUCGmlm62BBP2NffzsH/fZ92yJROK16dHdoW5YtNam63pdLw+W+viqLwvLdt8j+FV1uBqEeIkXh80UeogDNMC3txAHXjslkNag1mS2Kl6DMsLIlhM8vXwDz1aDzDgPoOvArRsmrgJSnOytB169pbfoy1Vxdc2scfGZBozwe4cJJHqY5qffe8sk6uAmEhzsirL+9Q5+dcNmGmSGuYfeSv0rglSZBcuuHctZMzObe3xmRmKdMsSf6b0AwPDdwHB0itoqZFUdaqhLGhJKdl7Gj7IDjN66nxuv20fPJ1k/V4HxlMAdqgYvLmKyXzLnzGKmtMSo0C75UiKlxOe6DGgwDYPOfJODDRG2betg27ff5sSQHQyz6yNaBDE0LO5ezuq4Yte5z7N1SO/8qOf+P3szMKsEIBYrAAAAAElFTkSuQmCC',w:64,h:45}}},1190,[]); +__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.StockScreen=function({initial:e="levels"}){const[t,i]=(0,l.useState)(e);return(0,x.jsxs)(r.default,{style:{gap:12},children:[(0,x.jsx)(p.Seg,{value:t,onChange:i,options:[{id:'levels',label:'Stock levels'},{id:'take',label:'Stock take'},{id:'deliveries',label:'Deliveries in'}]}),'levels'===t?(0,x.jsx)(y,{}):'take'===t?(0,x.jsx)(j,{}):(0,x.jsx)(f,{})]})};var t=_r(_d[0]),i=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),l=_r(_d[4]),d=e(_r(_d[5])),r=e(_r(_d[6])),o=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),b=_r(_d[12]),x=_r(_d[13]);function y(){const{k:e,rid:t}=(0,p.useChef)(),d=(0,c.useOwner)(e=>e.suppliers),b=(0,i.useSheets)(t),[y,j]=(0,l.useState)('all'),f=e.ingredients.filter(e=>e.onHand<=0),v=e.ingredients.filter(e=>(0,p.isLow)(e.onHand,e.par)),k='alerts'===y?[...f,...v]:e.ingredients,S=[...new Set(k.map(e=>e.supplierId))].map(e=>{const t=d.find(t=>t.id===e),i=b.find(t=>t.id===e);return{id:e,name:t?.name||i?.name||'Supplier not linked',category:t?.category||i?.goods||'Stock'}});return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsxs)(o.Row,{wrap:!0,gap:10,children:[(0,x.jsx)(p.Tile,{label:"Stock value (at cost)",value:(0,u.gbp)((0,p.stockValue)(e.ingredients)),sub:`${e.ingredients.length} ingredients`}),(0,x.jsx)(p.Tile,{label:"Low or out",value:`${v.length+f.length}`,sub:`${f.length} out \xb7 ${v.length} below half par`,tone:f.length?'red':v.length?'amber':'ok',onPress:()=>j('alerts')})]}),f.length?(0,x.jsxs)(o.Banner,{kind:"danger",title:"Out of stock",children:[f.map(e=>e.name).join(', '),". Mark the dishes that need it as sold out (Kitchen \u203a Live tickets \u203a Sold out), or order now."]}):null,(0,x.jsx)(p.Seg,{value:y,onChange:j,options:[{id:'all',label:'All'},{id:'alerts',label:'Alerts only'}]}),e.ingredients.length?null:(0,x.jsx)(o.Muted,{children:"No stock items yet. Add your real ingredients to start counting."}),S.map(e=>(0,x.jsxs)(o.Card,{children:[(0,x.jsxs)(o.T,{weight:"semibold",children:[e.category," \xb7 ",e.name]}),k.filter(t=>t.supplierId===e.id).map(e=>{const i=e.onHand<=0?'out':(0,p.isLow)(e.onHand,e.par)?'low':'ok';return(0,x.jsxs)(r.default,{style:{gap:4,paddingVertical:4},accessible:!0,accessibilityLabel:`${e.name} ${(0,n.ingredientSpeech)(t,e,e.onHand)} of par ${(0,n.ingredientSpeech)(t,e,e.par)}`,children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},children:e.name}),'out'===i?(0,x.jsx)(o.Badge,{kind:"red",label:"OUT"}):'low'===i?(0,x.jsx)(o.Badge,{kind:"amber",label:"LOW"}):null,(0,x.jsxs)(o.T,{size:13,colour:h.colours.muted,children:[(0,n.ingredientQty)(t,e,e.onHand)," / par ",(0,n.ingredientQty)(t,e,e.par)]})]}),(0,x.jsx)(p.Bar,{pct:e.onHand/e.par*100,colour:'out'===i?h.colours.red:'low'===i?h.colours.amber:h.colours.gold}),(0,x.jsxs)(o.Muted,{children:[(0,u.gbp)(Math.round((0,s.displayedCost)(t,e,e.cost)))," per ",(0,s.quantityUnit)(t,e)," \xb7 value ",(0,u.gbp)(Math.round(e.onHand*e.cost))]})]},e.id)})]},e.id))]})}function j(){const{k:e,me:i,rid:d}=(0,p.useChef)(),c=(0,b.useKitchen)(e=>e.saveStockTake),[y,j]=(0,l.useState)({}),[f,v]=(0,l.useState)(''),k=e.ingredients.map(e=>{const t=y[e.id],i=void 0===t||''===t?void 0:Number(t.replace(',','.')),n=void 0!==i&&Number.isFinite(i)&&i>=0&&(!(0,s.fishInStone)(d,e)||2*i===Math.round(2*i))?(0,s.inputQuantity)(d,e,i):void 0,l=void 0===n||Number.isNaN(n)?void 0:n-e.onHand;return{i:e,counted:n,variance:l,cost:void 0===l?0:Math.round(l*e.cost)}}),S=k.filter(e=>void 0!==e.variance),w=S.reduce((e,t)=>e+t.cost,0);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Count what's on the shelves. Expected = last count + deliveries \u2212 waste. Fish is entered in stone, in half-stone steps. Variance shows what's unexplained (portioning, theft, missed waste)."}),e.stockTakes[0]?(0,x.jsxs)(o.Muted,{children:["Last stock take ",new Date(e.stockTakes[0].at).toLocaleDateString('en-GB')," by ",e.stockTakes[0].by,": variance ",(0,u.gbp)(Math.round(e.stockTakes[0].lines.reduce((e,t)=>e+(t.counted-t.expected)*t.cost,0))),"."]}):null,(0,x.jsx)(o.Card,{children:k.map(({i:e,variance:i,cost:l})=>(0,x.jsxs)(r.default,{style:{gap:6,paddingVertical:8},children:[(0,x.jsxs)(r.default,{accessible:!0,accessibilityLabel:`${e.name}, expected ${(0,n.ingredientSpeech)(d,e,e.onHand)}`,children:[(0,x.jsx)(o.T,{size:16,children:e.name}),(0,x.jsxs)(o.Muted,{children:["Expected ",(0,n.ingredientQty)(d,e,e.onHand)]})]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'space-between'},children:[(0,x.jsx)(t.TextInput,{accessibilityLabel:`Count ${e.name} in ${(0,s.quantityUnit)(d,e)}`,accessibilityValue:{text:y[e.id]?(0,n.ingredientSpeech)(d,e,(0,s.inputQuantity)(d,e,Number(y[e.id]))):'Not counted'},keyboardType:"decimal-pad",placeholder:(0,s.quantityUnit)(d,e),placeholderTextColor:h.colours.muted,value:y[e.id]??'',onChangeText:t=>j(i=>({...i,[e.id]:t})),style:{minHeight:44,width:80,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:8,paddingVertical:6,color:h.colours.text,textAlign:'right'}}),(0,s.fishInStone)(d,e)?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Half a stone less ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String(Math.max(0,(0,s.halfStone)(Number(t[e.id])||0)-.5))}))}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Half a stone more ${e.name}`,onPress:()=>j(t=>({...t,[e.id]:String((0,s.halfStone)(Number(t[e.id])||0)+.5)}))})]}):null,(0,x.jsx)(r.default,{style:{minWidth:86,alignItems:'flex-end'},accessible:!0,accessibilityLabel:void 0===i?'No variance yet':`${(0,n.ingredientSpeech)(d,e,i)} variance, ${(0,u.gbp)(l)}`,children:void 0===i?(0,x.jsx)(o.Muted,{children:"\u2014"}):(0,x.jsxs)(o.T,{size:14,colour:Math.abs(i)<.001?h.colours.ok:i<0?h.colours.red:h.colours.amber,children:[i>0?'+':'',(0,n.ingredientQty)(d,e,i),'\n',(0,u.gbp)(l)]})})]})]},e.id))}),(0,x.jsxs)(o.Banner,{kind:w<0?'warn':'info',title:`Variance so far: ${(0,u.gbp)(w)}`,children:[S.length," of ",e.ingredients.length," counted."]}),(0,x.jsx)(o.Button,{label:"Save stock take",disabled:!S.length,onPress:()=>{const e={};S.forEach(t=>{e[t.i.id]=t.counted}),c(e,i),j({}),v(`Saved: ${S.length} items, variance ${(0,u.gbp)(w)}. Stock levels updated.`)}}),f?(0,x.jsx)(o.Banner,{kind:"success",title:"Stock take saved",children:f}):null]})}function f(){const{k:e,me:t}=(0,p.useChef)(),i=(0,c.useOwner)(e=>e.suppliers),[n,s]=(0,l.useState)(e.deliveries.find(e=>'expected'===e.status)?.id??null);return(0,x.jsxs)(r.default,{style:{gap:10},children:[(0,x.jsx)(o.Muted,{children:"Check each delivery against the order: count it in, check the invoice price, flag shorts and price changes. Accepting adds it to stock and updates costs (and GP)."}),e.deliveries.map(e=>{const l=i.find(t=>t.id===e.supplierId);return(0,x.jsxs)(o.Card,{highlight:n===e.id?h.colours.gold:void 0,children:[(0,x.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`Delivery from ${l?.name}`,onPress:()=>s(n===e.id?null:e.id),children:(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsxs)(r.default,{style:{flex:1},children:[(0,x.jsx)(o.T,{weight:"semibold",children:l?.name??'Supplier'}),(0,x.jsx)(o.Muted,{children:'expected'===e.status?`Due ${e.due} \xb7 ${e.lines.length} lines`:`Accepted by ${e.checkedBy} ${e.at?new Date(e.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):''}`})]}),(0,x.jsx)(o.Badge,{kind:'expected'===e.status?'amber':'ok',label:'expected'===e.status?'TO CHECK':'ACCEPTED'})]})}),n===e.id?(0,x.jsx)(v,{id:e.id,me:t}):null]},e.id)})]})}function v({id:e,me:i}){const{k:d,rid:c}=(0,p.useChef)(),b=d.deliveries.find(t=>t.id===e),[y,j]=(0,l.useState)(b.lines.map(e=>({...e}))),f=(e,t)=>j(i=>i.map(i=>i.ing===e?{...i,...t}:i)),v='expected'!==b.status,k=(0,l.useMemo)(()=>y.map(e=>{const t=d.ingredients.find(t=>t.id===e.ing),i=e.receivede.short>0),w=k.filter(e=>Math.abs(e.pct)>=.5),$=y.reduce((e,t)=>e+t.received*t.price,0);return(0,x.jsxs)(r.default,{style:{gap:8,marginTop:8},children:[k.map(({l:e,i:i,short:l,pct:d})=>(0,x.jsxs)(r.default,{style:{gap:4,borderTopWidth:1,borderColor:h.colours.border,paddingTop:6},children:[(0,x.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(o.T,{style:{flex:1},weight:"medium",children:i.name}),l?(0,x.jsx)(o.Badge,{kind:"red",label:`SHORT ${(0,n.ingredientQty)(c,i,l)}`}):null,Math.abs(d)>=.5?(0,x.jsx)(o.Badge,{kind:"amber",label:`PRICE ${d>0?'+':''}${d.toFixed(0)}%`}):null]}),(0,x.jsxs)(o.Row,{wrap:!0,gap:8,children:[(0,x.jsxs)(o.Muted,{children:["Ordered ",(0,n.ingredientQty)(c,i,e.ordered)]}),(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Received (",(0,s.quantityUnit)(c,i),")"]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Received ${i.name} in ${(0,s.quantityUnit)(c,i)}`,accessibilityValue:{text:(0,n.ingredientSpeech)(c,i,e.received)},keyboardType:"decimal-pad",value:String((0,s.fishInStone)(c,i)?(0,s.halfStone)((0,s.toStone)(e.received,i.unit)):e.received),onChangeText:t=>f(e.ing,{received:(0,s.inputQuantity)(c,i,Number(t.replace(',','.'))||0)}),style:{minHeight:44,width:60,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]}),(0,s.fishInStone)(c,i)&&!v?(0,x.jsxs)(o.Row,{children:[(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"Less",accessibilityLabel:`Receive half a stone less ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,-1)})}),(0,x.jsx)(o.Button,{small:!0,kind:"secondary",label:"More",accessibilityLabel:`Receive half a stone more ${i.name}`,onPress:()=>f(e.ing,{received:(0,s.stepQuantity)(c,i,e.received,1)})})]}):null,(0,x.jsxs)(o.Row,{gap:4,children:[(0,x.jsxs)(o.Muted,{children:["Invoice \xa3/",(0,s.quantityUnit)(c,i)]}),(0,x.jsx)(t.TextInput,{editable:!v,accessibilityLabel:`Invoice price ${i.name}`,keyboardType:"decimal-pad",value:((0,s.displayedCost)(c,i,e.price)/100).toFixed(2),onChangeText:t=>f(e.ing,{price:100*(Number(t.replace(',','.'))||0)/((0,s.fishInStone)(c,i)?(0,s.fromStone)(1,i.unit):1)}),style:{minHeight:44,width:70,borderWidth:1,borderColor:h.colours.border,borderRadius:8,paddingHorizontal:6,paddingVertical:4,color:h.colours.text,textAlign:'right'}})]})]}),(0,x.jsxs)(o.Muted,{children:["Last cost ",(0,u.gbp)(Math.round((0,s.displayedCost)(c,i,i.cost)))," per ",(0,s.quantityUnit)(c,i)]})]},e.ing)),(0,x.jsxs)(o.T,{weight:"semibold",children:["Invoice total ",(0,u.gbp)(Math.round($))]}),S.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Shorts to chase",children:[S.map(e=>`${e.i.name}: ${(0,n.ingredientQty)(c,e.i,e.short)} short`).join(' \xb7 '),". Ask the supplier for a credit note."]}):null,w.length?(0,x.jsxs)(o.Banner,{kind:"warn",title:"Price changes",children:[w.map(e=>`${e.i.name} ${e.pct>0?'+':''}${e.pct.toFixed(0)}%`).join(' \xb7 '),". Check GP \u203a Price changes once accepted."]}):null,v?(0,x.jsx)(o.Muted,{children:b.note?`Noted: ${b.note}.`:'No issues noted.'}):(0,x.jsx)(o.Button,{label:"Accept delivery into stock",testID:"accept-delivery",onPress:()=>d.acceptDelivery(e,y,i,[S.length?`${S.length} short`:'',w.length?`${w.length} price changes`:''].filter(Boolean).join(', '))})]})}},1191,[827,1031,1173,984,34,402,102,794,891,867,821,1165,1033,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dayKey",{enumerable:!0,get:function(){return t}}),e.parseDay=function(t){return null},e.KitchenCosts=function(t){return null},e.useKitchenSummary=function(t){return{stockValue:null,lastCount:null,costed:0,below:0,target:70,avgGp:null,prices:0}};const t=(t=new Date)=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1192,[]); +__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=C,_e.Payroll=function(){const{role:e}=(0,y.useCtx)(6e4),r='owner'===e,c=!!(0,y.useSignedIn)(),p=c&&('owner'===e||'manager'===e),j=(0,a.useOwner)(e=>e.staff),k=(0,i.useMemo)(()=>j.filter(e=>e.active),[j]),D=(0,y.useHourly)(),R=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),z=(0,a.useOwner)(e=>e.troncHistory),{now:M,rid:v}=(0,y.useCtx)(6e4),N=(0,b.useVenuePay)(v).pay,[B,O]=(0,i.useState)(-1),[L,$]=(0,i.useState)(null),[S,H]=(0,i.useState)(''),[I,W]=(0,i.useState)(null),E=(0,i.useMemo)(()=>k.map(e=>({...T(e.id,B,M,R,D[e.id]??0,N,z),person:e})),[k,B,R,D,N,z]),_=E.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=E[0]?.label??'',F=k.find(e=>e.id===L),G=Math.round(100*Number(S));return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:["Pay period (venue setting",r?'':', owner only',"). Used for staff pay, the tip splitter and payroll."]}),(0,f.jsx)(P,{label:V,offset:B,setOffset:O,badge:0===B?'Current period':void 0}),(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!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)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[120,96,64,72,64,76][s]},children:e},e))}),E.map(e=>(0,f.jsxs)(t.TRow,{heads:['Staff','Rate/h','Paid hrs','Gross','Tips','Total'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay for ${e.person.name}`,onPress:()=>W(e.person.id),style:{width:120,minHeight:44,justifyContent:'center'},children:[(0,f.jsx)(l.T,{size:13,colour:h.colours.gold,numberOfLines:1,children:x(e.person.name)}),c&&e.person.noTax?(0,f.jsx)(l.T,{size:10,colour:h.colours.amber,children:"No tax deducted"}):null]}),(0,f.jsx)(o.default,{accessibilityRole:"button",accessibilityLabel:`Edit rate for ${e.person.name}`,disabled:!p,onPress:()=>{$(e.person.id),H(null==D[e.person.id]?'':(D[e.person.id]/100).toFixed(2))},style:{width:96,minHeight:44,justifyContent:'center'},children:(0,f.jsxs)(l.T,{size:13,colour:null==D[e.person.id]?h.colours.muted:'owner'!==e.person.role&&D[e.person.id]$(null),title:`Hourly rate: ${x(F?.name)}`,children:[(0,f.jsx)(l.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,D[F.id],u.gbp)}`:''}),(0,f.jsx)(s.TextInput,{accessibilityLabel:"Hourly rate \xa3",keyboardType:"decimal-pad",value:S,onChangeText:H,style:l.styles.input}),Number.isFinite(G)&&G>0&&G{a.useOwner.getState().setRate(L,G),$(null)}}),L&&null!=D[L]?(0,f.jsx)(l.Button,{kind:"secondary",label:"Clear (Not set)",onPress:()=>{a.useOwner.getState().clearRate(L),$(null)}}):null]}),(0,f.jsx)(l.Sheet,{visible:!!I,onClose:()=>W(null),title:`What ${x(k.find(e=>e.id===I)?.name)} sees`,children:I?(0,f.jsx)(C,{staffId:I}):null})]})};var s=_r(d[0]),t=_r(d[1]),i=_r(d[2]),o=e(_r(d[3])),n=e(_r(d[4])),r=e(_r(d[5])),l=_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,s){const{now:t,rid:o}=(0,y.useCtx)(6e4),n=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),r=(0,y.useHourly)()[e]??0,l=(0,b.useVenuePay)(o).pay,u=(0,a.useOwner)(e=>e.troncHistory);return(0,i.useMemo)(()=>T(e,s,t,n,r,l,u),[e,s,n,r,l,u,Math.floor(t.getTime()/6e4)])}function T(e,s,t,i,o,n,r){const{s:l,e:u,key:h}=(0,b.venueRange)(n,'wage',s,t),p=(0,c.ymd)(l),f=(0,c.ymd)(u),x=i.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*o),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),P=x.filter(e=>!e.open&&!e.confirmed).reduce((e,s)=>e+s.paid,0),C=r.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),k=C.reduce((e,s)=>e+s.amount,0);return{s:l,e:u,key:h,label:`${(0,c.niceDate)(l)} \u2013 ${(0,c.niceDate)(u)} ${u.getFullYear()}`,shifts:x,paid:j,pending:P,gross:T,tips:k,tipItems:C,total:T+k,rate:o}}function P({label:e,offset:s,setOffset:t,badge:i}){return(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:s<=-12,onPress:()=>t(s-1)}),(0,f.jsxs)(n.default,{style:{alignItems:'center',flex:1},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e}),i?(0,f.jsx)(l.Badge,{kind:0===s?'amber':'neutral',label:i}):null]}),(0,f.jsx)(l.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:s>=0,onPress:()=>t(s+1)})]})}function C({staffId:e}){const{meId:s,now:C,rid:k}=(0,y.useCtx)(6e4),D=e??s,R=(0,b.useVenuePay)(k).pay,z=(0,a.useOwner)(e=>e.staff).find(e=>e.id===D),M=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),v=(0,a.useOwner)(e=>e.troncHistory),N=(0,y.useHourly)(),B=N[D]??0,O=null!=N[D],[L,$]=(0,i.useState)(0),S=j(D,L),H=(0,r.default)().width<520,I=(0,i.useMemo)(()=>[-1,-2,-3,-4,-5,-6].map(e=>({o:e,...T(D,e,C,M,B,R,v)})),[D,M,B,R,v]);return(0,f.jsxs)(n.default,{style:{gap:10},children:[(0,f.jsx)(l.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)(l.Muted,{children:[x(z?.name)," \xb7 ",z?.job," \xb7 ",O?`${(0,u.gbp)(B)}/hour`:'Hourly rate not set yet'," \xb7 Paid on the ",R.wagePayDay,[1,21,31].includes(R.wagePayDay)?'st':[2,22].includes(R.wagePayDay)?'nd':[3,23].includes(R.wagePayDay)?'rd':'th',", cut-off the ",R.wageCutoffDay,[1,21].includes(R.wageCutoffDay)?'st':[2,22].includes(R.wageCutoffDay)?'nd':[3,23].includes(R.wageCutoffDay)?'rd':'th',e?'':' (set by your manager)']}),(0,f.jsx)(P,{label:S.label,offset:L,setOffset:$,badge:0===L?'Current period':void 0}),(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Confirmed paid hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,y.hmDur)(S.paid)})]}),S.pending?(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{colour:h.colours.amber,children:"Pending sign-off"}),(0,f.jsx)(l.T,{colour:h.colours.amber,children:(0,y.hmDur)(S.pending)})]}):null,(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Gross pay from hours"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.gross)})]}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{children:"Tips allocated"}),(0,f.jsx)(l.T,{weight:"semibold",children:(0,u.gbp)(S.tips)})]}),S.tipItems.map(e=>(0,f.jsxs)(l.Muted,{children:[" Tips for ",e.label,": ",(0,u.gbp)(e.amount)]},e.label)),(0,f.jsx)(n.default,{style:{height:1,backgroundColor:h.colours.border}}),(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"bold",children:"Total gross"}),(0,f.jsx)(l.T,{size:20,weight:"bold",colour:h.colours.gold,children:(0,u.gbp)(S.total)})]}),(0,f.jsxs)(l.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)(n.default,{testID:"pay-shifts-list",children:[S.shifts.map(e=>(0,f.jsxs)(n.default,{style:{paddingVertical:8,borderBottomWidth:1,borderColor:'#222',gap:2},children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{size:14,weight:"semibold",children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.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)(l.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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."}),S.shifts.length?(0,f.jsxs)(l.Muted,{children:["At ",(0,u.gbp)(S.rate),"/hour."]}):null]}):(0,f.jsx)(t.WideTable,{children:(0,f.jsxs)(n.default,{children:[(0,f.jsx)(t.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:h.colours.border,paddingBottom:4},children:['Date','In','Out','Break','Paid','Rate','Gross'].map((e,s)=>(0,f.jsx)(l.T,{size:12,weight:"semibold",colour:h.colours.gold,style:{width:[86,50,50,50,62,56,100][s]},children:e},e))}),S.shifts.map(e=>(0,f.jsxs)(t.TRow,{heads:['Date','In','Out','Break','Paid','Rate','Gross'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,f.jsx)(l.T,{size:13,style:{width:86},children:(0,c.niceDate)(new Date(e.a.date+'T12:00:00'))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:(0,c.hm)(new Date(e.a.in))}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.a.out?(0,c.hm)(new Date(e.a.out)):'on now'}),(0,f.jsx)(l.T,{size:13,style:{width:50},children:e.open?'\u2013':`${e.brk}m`}),(0,f.jsx)(l.T,{size:13,style:{width:62},children:e.open?'\u2013':(0,y.hmDur)(e.paid)}),(0,f.jsx)(l.T,{size:13,style:{width:56},children:(0,u.gbp)(S.rate)}),(0,f.jsx)(l.T,{size:13,weight:"semibold",style:{width:100},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)(l.Muted,{style:{paddingVertical:8},children:"No clocked shifts in this period."})]})}),S.shifts.some(e=>e.open)?(0,f.jsx)(l.Muted,{children:"The shift you\u2019re on now is added once you clock out."}):null,S.pending?(0,f.jsx)(l.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)(o.default,{accessibilityRole:"button",accessibilityLabel:`Pay period ${e.label}`,onPress:()=>$(e.o),children:(0,f.jsxs)(l.Card,{children:[(0,f.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(l.T,{weight:"semibold",children:e.label}),(0,f.jsx)(l.T,{weight:"bold",children:(0,u.gbp)(e.total)})]}),(0,f.jsxs)(l.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))]})}},1193,[827,1194,34,402,102,426,794,891,867,858,821,1195,1088,1065,25]); +__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,"NARROW_W",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"useNarrow",{enumerable:!0,get:function(){return f}}),_e.WideTable=function({children:e}){return f()?(0,o.jsx)(l.default,{children:e}):(0,o.jsx)(n.default,{horizontal:!0,children:e})},_e.TRow=function({heads:e,head:n,style:i,children:s}){if(!f())return(0,o.jsx)(u.Row,{gap:0,style:i,children:s});if(n)return null;const h=t.default.Children.toArray(s);return(0,o.jsx)(l.default,{style:[i,{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',rowGap:6,columnGap:8,paddingVertical:8}],children:h.map((n,i)=>{const s=e?.[i],f=t.default.isValidElement(n)?t.default.cloneElement(n,{style:[n.props.style,{width:'100%',minWidth:0,maxWidth:'100%',alignItems:'center',textAlign:'center'}]}):n;return(0,o.jsxs)(l.default,{style:{flexGrow:1,flexBasis:'46%',minWidth:130,maxWidth:'100%',alignItems:'center'},children:[s?(0,o.jsx)(u.T,{size:11,colour:c.colours.muted,center:!0,children:s}):null,f]},i)})})};var t=e(r(d[0])),n=e(r(d[1])),l=e(r(d[2])),i=e(r(d[3])),u=r(d[4]),c=r(d[5]),o=r(d[6]);const s=600,f=()=>(0,i.default)().width!e.nextHour||t.hour>=e.nextHour.hour).reduce((e,t)=>!e||t.coversHigh>e.coversHigh?t:e,void 0);return{level:b(r?.coversHigh??0,e.busy.busy),peak:r}},_e.Tile=function({label:e,value:n,sub:c,onPress:a,accent:d,children:u,accessibilityLabel:b,testID:h}){const f=(0,s.jsxs)(r.default,{testID:a?void 0:h,style:{flexGrow:1,flexBasis:150,minHeight:48,alignItems:'center',justifyContent:'center',backgroundColor:o.colours.surface,borderRadius:14,padding:12,borderWidth:1,borderColor:d??o.colours.border,gap:2},children:[(0,s.jsx)(l.T,{center:!0,size:13,weight:"medium",colour:o.colours.muted,children:e}),n?(0,s.jsx)(l.T,{size:24,weight:"bold",colour:d??o.colours.text,children:n}):null,c?(0,s.jsx)(l.T,{center:!0,size:13,colour:o.colours.muted,children:c}):null,u]});return a?(0,s.jsx)(t.default,{testID:h,accessibilityRole:"button",accessibilityLabel:b??e,onPress:a,style:{flexGrow:1,flexBasis:150,minHeight:48},children:f}):f},_e.SectionHead=function({title:e,right:t,sub:n}){return(0,s.jsxs)(r.default,{dataSet:{centre:'heading'},style:{gap:4,marginTop:6,alignItems:'center',alignSelf:'stretch',width:'100%'},children:[(0,s.jsx)(l.T,{weight:"semibold",size:o.font.large,colour:o.colours.gold,center:!0,accessibilityRole:"header",children:e}),n?(0,s.jsx)(l.Muted,{center:!0,children:n}):null,t?(0,s.jsx)(r.default,{style:{alignItems:'center'},children:t}):null]})},_e.AlertBox=function({colour:e,title:t,children:n}){return(0,s.jsxs)(r.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:t}),n]})},_e.Bars=function({data:e,max:t,highlight:n,height:c=110}){return(0,s.jsx)(l.Row,{gap:4,style:{alignItems:'flex-end'},children:e.map(e=>{const a=e.key===n,d=e.a+(e.b??0);return(0,s.jsxs)(r.default,{style:{alignItems:'center',flex:1,minWidth:26},children:[(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.note??String(d)}),(0,s.jsxs)(r.default,{style:{height:c,width:'70%',justifyContent:'flex-end',borderBottomWidth:1,borderColor:o.colours.border},children:[e.b?(0,s.jsx)(r.default,{style:{height:Math.max(0,e.b/t*c),backgroundColor:a?o.colours.goldLight:'#6B5A3A'}}):null,(0,s.jsx)(r.default,{style:{height:Math.max(d?2:0,e.a/t*c),backgroundColor:a?o.colours.gold:'#9C7C45'}})]}),(0,s.jsx)(l.T,{size:11,colour:a?o.colours.gold:o.colours.muted,children:e.label})]},e.key)})})},Object.defineProperty(_e,"DemoTag",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var t=e(_r(_d[1])),r=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,a=e=>'new'===e?'red':'ready'===e?'ok':'preparing'===e||'acknowledged'===e?'amber':'served'===e||'collected'===e?'blue':'neutral',d=e=>({awaiting_payment:'Waiting for card payment',new:'New',acknowledged:'Accepted',preparing:'Preparing',ready:'Ready',collected:'Collected',served:'Served',closed:'Closed',cancelled:'Cancelled'}[e.status]);const u=e=>!['awaiting_payment','collected','served','closed','cancelled'].includes(e.status);function b(e,t){const r=t?e/t:0;return r<.5?{label:'Quiet',colour:o.colours.muted,pct:r}:r<1?{label:'Steady',colour:o.colours.goldLight,pct:r}:{label:'Busy',colour:o.colours.amber,pct:r}}const h=({label:e="DEMO"})=>(0,s.jsx)(l.Badge,{kind:"amber",label:e})},1195,[34,402,102,794,821,5,25]); +__d(function(g,_r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useTravelDay=C,_e.DayBar=function({app:e,today:t}){const a=C(e,t),o=x(e=>e.set),d=a??t,[n,u]=j[e];return(0,r.useEffect)(()=>{if('display'!==e||!a)return;const t=setTimeout(()=>o(e,null),12e4);return()=>clearTimeout(t)},[e,a,o]),(0,D.jsxs)(l.default,{testID:"day-bar",style:{gap:8},children:[(0,D.jsx)(s.DaySwitch,{day:d,today:t,onDay:t=>o(e,t),back:-n,ahead:u,idPrefix:"day"}),a?(0,D.jsx)(c.Button,{testID:"day-today",kind:"secondary",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>o(e,null),style:{minHeight:48}}):null]})},_e.DayView=function({rid:e,day:s,today:r,app:d}){const n=(0,u.useRestaurant)(e),x=(0,u.useBookings)(e),j=(0,u.useEvents)(e),C=(0,p.parseYmd)(s),_=se.date===s),O=(0,f.regularEventsOf)(n).filter(e=>(0,f.occursOn)(e,s)),T=x.filter(e=>e.date===s).sort((e,t)=>e.time.localeCompare(t.time)).filter(y.ACTIVE),E='display'===d;return(0,D.jsxs)(l.default,{testID:"day-view",style:{gap:12},children:[(0,D.jsxs)(c.Card,{children:[(0,D.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,D.jsxs)(c.T,{weight:"semibold",colour:b.colours.gold,children:[(0,p.niceDate)(C),$?` \xb7 ${$.name} hours`:'']}),(0,D.jsx)(c.Badge,{kind:"gold",label:_?'LOOKING BACK':'LOOKING AHEAD'})]}),(0,D.jsxs)(c.T,{size:E?18:15,children:[B?`Kitchen ${k(B[0])}\u2013${k(B[1])}`:'Kitchen closed',B&&v&&'kitchen closes'!==v.reason?` \xb7 last food orders ${k(v.time)} (${v.reason})`:'']}),O.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u266a ",e.name,e.time?` from ${k(e.time)}`:'',e.busier?' \xb7 expect busier':'']},e.id)),w.map(e=>(0,D.jsxs)(c.T,{size:14,colour:b.colours.goldLight,children:["\u2605 ",(0,y.holidayName)(e.title)]},e.id)),(0,D.jsx)(c.Muted,{children:"Read-only. Nothing here changes today\u2019s service."})]}),(0,D.jsx)(a.CoversToday,{rid:e,day:s}),(0,D.jsx)(m.PlattersBooked,{rid:e,date:s,label:_?'Platters that day':'Platters booked'}),T.length?T.map(s=>(0,D.jsxs)(l.default,{style:{gap:6,padding:14,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface},children:[(0,D.jsxs)(c.T,{weight:"semibold",children:[s.time," \xb7 ",s.walkIn?`Walk-in ${s.ref}`:s.name," \xb7 ",s.partySize," Covers",s.table?` \xb7 ${(0,t.tableNumbers)(s.table)}`:'']}),(0,D.jsx)(o.DepositChip,{b:s,money:!0,testID:`day-deposit-${s.id}`}),(0,D.jsx)(m.BookingNeeds,{b:s}),'display'!==d&&!_&&['confirmed','pending'].includes(s.status)?(0,D.jsx)(l.default,{style:{flexDirection:'row'},children:(0,D.jsx)(A.WhatsAppGuest,{b:s,rid:e,kind:"auto"})}):null]},s.id)):(0,D.jsx)(c.Muted,{children:_?'No bookings that day.':'No bookings yet for this day.'})]})};var e,t=_r(_d[0]),s=_r(_d[1]),a=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),d=_r(_d[5]),l=(e=d)&&e.__esModule?e:{default:e},n=_r(_d[6]),c=_r(_d[7]),u=_r(_d[8]),y=_r(_d[9]),h=_r(_d[10]),f=_r(_d[11]),p=_r(_d[12]),b=_r(_d[13]),m=_r(_d[14]),A=_r(_d[15]),D=_r(_d[16]);const x=(0,n.create)(e=>({day:{},set:(t,s)=>e(e=>({day:{...e.day,[t]:s??void 0}}))})),j={owner:[-s.DAY_BACK,s.DAY_AHEAD],chef:[-s.DAY_BACK,s.DAY_AHEAD],display:[-s.DAY_BACK,s.DAY_AHEAD],staff:[-s.DAY_BACK,s.DAY_AHEAD]},k=e=>{const[t,s]=e.split(':').map(Number);return`${t%12||12}${s?`:${String(s).padStart(2,'0')}`:''}${t<12?'am':'pm'}`};function C(e,t){const s=x(t=>t.day[e]);return s&&s!==t?s:null}},1196,[860,1102,1099,1117,34,102,846,794,874,1101,878,877,858,821,1107,1197,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.WhatsAppGuest=function({b:p,rid:o,kind:u="change"}){const c=(0,n.useRestaurant)(o);if(!c?.settings?.whatsapp||!(0,s.waNumber)(c.settings.whatsapp)||p.walkIn||!(0,s.waNumber)(p.phone))return null;const l=c.location?.split(',')[1]?.trim(),f=(0,s.staffWhatsAppTexts)({name:p.name,ref:p.ref,date:p.date,time:p.time,partySize:p.partySize},c.name,l&&!/fictional/i.test(l)?l:void 0),h='auto'===u?['confirmed','pending'].includes(p.status)?'confirm':'change':u,b=(0,s.waMeLink)(p.phone,'confirm'===h?f.confirm:f.change);return b?(0,r.jsx)(t.Button,{small:!0,kind:"secondary",label:"\ud83d\udcac WhatsApp guest",testID:`wa-guest-${p.ref}`,accessibilityLabel:`WhatsApp ${p.name}`,onPress:()=>{(0,s.openWhatsApp)(b)}}):null},_r(d[0]);var t=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4])},1197,[34,794,874,1198,25]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.waNumber=o,_e.waMeLink=function(e,t){const n=o(e);return n?t?`https://wa.me/${n}?text=${encodeURIComponent(t)}`:`https://wa.me/${n}`:null},Object.defineProperty(_e,"guestWhatsAppText",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"staffWhatsAppTexts",{enumerable:!0,get:function(){return p}}),_e.openWhatsApp=async function(e){try{return await n.default.openURL(e),!0}catch{return!1}};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e};function o(e,t="44"){if(!e)return null;let n=String(e).trim().replace(/[\s().\-]/g,'');return n.startsWith('+')?n=n.slice(1):n.startsWith('00')?n=n.slice(2):n.startsWith('0')&&(n=t+n.slice(1)),n=n.replace(/^440/,'44'),/^[1-9][0-9]{6,14}$/.test(n)?n:null}const s=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'})},u=e=>{const[t,n,o]=e.split('-').map(Number);return new Date(t,n-1,o).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},c=e=>e.slice(0,5),l=e=>e.replace(' (example)','').trim().split(/\s+/)[0]||'there',m=(e,t)=>`Hi ${t}, it's ${e.name.trim()} about my booking${e.ref?` ${e.ref}`:''}: ${s(e.date)} at ${c(e.time)}, table for ${e.partySize}. `,p=(e,t,n)=>({confirm:`Hi ${l(e.name)}, it's ${t}${n?` in ${n}`:''}. Just confirming your table for ${e.partySize} on ${u(e.date)} at ${c(e.time)}${e.ref?` (ref ${e.ref})`:''}. Any questions, just reply here.`,change:`Hi ${l(e.name)}, it's ${t} about your booking on ${u(e.date)} at ${c(e.time)}. `})},1198,[379]); +__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 k.payFor}}),Object.defineProperty(_e,"useVenuePay",{enumerable:!0,get:function(){return k.useVenuePay}}),_e.PayTipsSettings=function({go:e}){const{rid:s,today:o}=(0,P.useCtx)(6e4),{pay:r,source:d}=(0,k.useVenuePay)(s),[a,l]=(0,n.useState)(r),[u,c]=(0,n.useState)((0,f.ukDate)(r.tipsAnchorPayday)),[y,x]=(0,n.useState)(null),j=(0,f.parseUk)(u),w=(0,f.cleanPay)({...a,tipsAnchorPayday:j??a.tipsAnchorPayday}),C=JSON.stringify(w)!==JSON.stringify(r)||'settings'!==d,S=(0,f.nextToPay)(w,'tips',o).period,D=(0,f.nextToPay)(w,'wage',o).period,v=(0,f.tipsPeriod)(w,S.start,1),z=(0,f.wagePeriod)(w,D.start,1),H=e=>{l({...a,...e}),x(null)};return(0,M.jsxs)(i.default,{style:{gap:12},testID:"pay-settings",children:['none'===d?(0,M.jsx)(h.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'===d?(0,M.jsx)(h.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,M.jsx)(T.SectionHead,{title:"Tips",sub:"How often tips are paid out, and which days each payout covers."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsx)(h.T,{weight:"semibold",children:"How often"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['weekly','fortnightly','monthly'].map(e=>(0,M.jsx)(h.Chip,{label:$[e],selected:a.tipsFrequency===e,onPress:()=>H({tipsFrequency:e})},e))}),(0,M.jsx)(h.Field,{label:"Next tips payday (DD/MM/YYYY)",value:u,onChangeText:e=>{c((0,t.slashDate)(e,u)),x(null)},maxLength:10,placeholder:"02/11/2026",keyboardType:"numbers-and-punctuation"}),j?(0,M.jsxs)(h.Muted,{children:[(0,f.dayMonth)(j)," ",j.slice(0,4)]}):(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter a date like 02/11/2026"}),(0,M.jsx)(h.T,{weight:"semibold",children:"Each tips period ends"}),(0,M.jsxs)(h.Row,{children:[(0,M.jsx)(h.Stepper,{label:"days before payday",value:a.tipsEndsDaysBefore,min:0,max:13,onChange:e=>H({tipsEndsDaysBefore:e})}),(0,M.jsx)(h.Muted,{style:{flex:1},children:0===a.tipsEndsDaysBefore?'on payday':1===a.tipsEndsDaysBefore?'day before payday (a Monday payday covers up to the Sunday)':'days before payday'})]})]}),(0,M.jsx)(T.SectionHead,{title:"Wages",sub:"Monthly pay: the cut-off starts each pay period."}),(0,M.jsxs)(h.Card,{children:[(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Pay day of the month"}),(0,M.jsx)(h.Stepper,{label:"pay day",value:a.wagePayDay,min:1,max:31,onChange:e=>H({wagePayDay:e})})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.T,{weight:"semibold",style:{flex:1},children:"Cut-off (first day of each period)"}),(0,M.jsx)(h.Stepper,{label:"cut-off day",value:a.wageCutoffDay,min:1,max:28,onChange:e=>H({wageCutoffDay:e})})]}),(0,M.jsxs)(h.Muted,{children:["Period runs the ",R(a.wageCutoffDay)," to the ",R(1===a.wageCutoffDay?31:a.wageCutoffDay-1),1===a.wageCutoffDay?' (end of the month)':' of the next month',". A pay day past the month end uses the last day."]}),(0,M.jsx)(h.T,{weight:"semibold",children:"A pay day on a weekend"}),(0,M.jsx)(h.Row,{wrap:!0,gap:6,children:['none','before','after'].map(e=>(0,M.jsx)(h.Chip,{label:B[e],selected:(a.weekendRule??'none')===e,onPress:()=>H({weekendRule:e})},e))})]}),(0,M.jsx)(T.SectionHead,{title:"Preview"}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(I,{label:"Next tips payday",day:S.payday,period:S}),(0,M.jsx)(I,{label:"Then",day:v.payday,period:v}),(0,M.jsx)(i.default,{style:{height:1,backgroundColor:b.colours.border}}),(0,M.jsx)(I,{label:"Next payday",day:D.payday,period:D}),(0,M.jsx)(I,{label:"Then",day:z.payday,period:z})]}),(0,M.jsx)(h.Button,{kind:"success",label:'settings'===d?'Save pay dates':'Save as our pay dates',disabled:!j||!C,testID:"save-pay",onPress:()=>{p.useStore.getState().updateSettings(s,{pay:w}),x('Saved. Everyone in the venue sees these dates.')}}),y?(0,M.jsx)(h.Banner,{kind:"success",title:y}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Payroll hours",onPress:()=>e('more','hours')}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tips day",onPress:()=>e('more','tipsday')})]})]})},_e.hoursIn=H,Object.defineProperty(_e,"toTsv",{enumerable:!0,get:function(){return F}}),Object.defineProperty(_e,"toCsv",{enumerable:!0,get:function(){return V}}),_e.summaryTable=E,_e.detailTable=Y,_e.copyText=G,_e.periodOptions=U,_e.PayrollHours=function({go:e}){const{rid:s,today:t,now:r,r:p,me:w,meId:T,role:$}=(0,P.useCtx)(6e4),B=(0,C.canSeeHoursEdit)({role:$,isCar:S.IS_CAR}),[R,I]=(0,n.useState)(!1),{pay:z,source:W}=(0,k.useVenuePay)(s),L=(0,y.useOwner)(e=>e.staff),N=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),J=(0,P.useHourly)(),K=(0,a.default)().width<700,[Q,X]=(0,n.useState)(null),[Z,ee]=(0,n.useState)(null),se=e=>{const s=y.useOwner.getState().confirmEntries([e.id],w,T,(new Date).toISOString());Te(s?'Approved. It now counts in the hours and pay.':'Nothing to approve.')},te=e=>(0,M.jsxs)(i.default,{style:{gap:8,marginBottom:8},testID:`daily-${e.person.id}`,children:[e.days.map(e=>(0,M.jsx)(u.ShiftCard,{d:e,manager:!0,onApprove:()=>se(e.a),onEdit:()=>X(e.a),onRemove:()=>ee(e.a)},e.a.id)),e.days.length?null:(0,M.jsx)(h.Muted,{center:!0,children:"No clocked shifts in this period."})]}),oe=(0,n.useMemo)(()=>U(z,t),[z,t]),[ne,re]=(0,n.useState)('wage'),[de,ae]=(0,n.useState)(null),[ie,le]=(0,n.useState)(!1),[ue,ce]=(0,n.useState)({}),[he,pe]=(0,n.useState)(null),ye='custom'===ne&&de?de:(oe.find(e=>e.id===ne)??oe[0]).period,ge=(0,n.useMemo)(()=>H(ye,L,N,r,J),[ye.key,L,N,J,Math.floor(r.getTime()/6e4)]),xe=ge.some(e=>null!=e.rate),fe='tips'===ye.kind,me=ge.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}),be=ge.filter(e=>e.pending>0).length,je=`${p.name}: hours ${(0,f.rangeText)(ye.start,ye.end)}`,we=`hours-${ye.start}-to-${ye.end}`,Te=e=>{pe(e),setTimeout(()=>pe(null),6e3)};return y.CAN.manage($)?(0,M.jsxs)(i.default,{style:{gap:10},testID:"payroll-hours",children:['none'===W?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Pay dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using calendar months for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[oe.map(e=>(0,M.jsx)(h.Chip,{label:e.label,sub:e.sub,selected:ne===e.id,onPress:()=>{re(e.id),le(!1)}},e.id)),(0,M.jsx)(h.Chip,{label:"Custom dates",sub:de&&'custom'===ne?(0,f.rangeText)(de.start,de.end):'Pick any range',selected:'custom'===ne,onPress:()=>le(!ie)})]}),ie?(0,M.jsx)(_,{onSet:e=>{ae(e),re('custom'),le(!1)}}):null,(0,M.jsx)(h.Card,{highlight:b.colours.gold,children:(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(i.default,{style:{flexShrink:1,minWidth:0},children:[(0,M.jsxs)(h.T,{weight:"bold",size:18,children:[(0,f.rangeText)(ye.start,ye.end)," ",ye.end.slice(0,4)]}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)(ye.start)," to ",(0,f.ukDate)(ye.end),ye.payday?` \xb7 ${ye.payday>=t?'pays':'paid'} ${(0,f.dayMonth)(ye.payday)}`:'',fe?' \xb7 tips period':'wage'===ye.kind?' \xb7 wage period':'']})]}),(0,M.jsxs)(i.default,{style:{alignItems:'flex-end'},children:[(0,M.jsx)(h.T,{size:22,weight:"bold",colour:b.colours.gold,children:(0,l.durText)(me.c)}),(0,M.jsxs)(h.Muted,{children:["approved",me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]})]})}),(0,M.jsx)(v.HoursExport,{}),B?(0,M.jsx)(i.default,{style:{alignItems:'center'},children:(0,M.jsx)(h.Button,{testID:"add-past-shift",label:"Add past shift",accessibilityLabel:"Add past shift",onPress:()=>I(!0),style:{minHeight:48,minWidth:180}})}):null,be?(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:"Sign off pending hours",onPress:()=>e('more','signoff'),testID:"pending-banner",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.amberBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.amber,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.amber,children:["\u26a0 ",(0,l.durText)(me.p)," still waiting for approval (",be," ",1===be?'person':'people',")"]}),(0,M.jsx)(h.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,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this period are signed off"}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"copy-tsv",onPress:async()=>{const e=await G(F(E(ge,ye,xe,fe)));Te(e?`Copied ${ge.length} rows. Paste into the first cell of your spreadsheet.`:'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",onPress:()=>{(0,j.downloadText)(`${we}.csv`,V(E(ge,ye,xe,fe))),Te('CSV downloaded (summary).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV (daily detail)",onPress:()=>{(0,j.downloadText)(`${we}-daily.csv`,V(Y(ge))),Te('CSV downloaded (one line per shift).')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",onPress:()=>{const e=E(ge,ye,xe,fe);(0,j.printTable)(je,`${(0,f.ukDate)(ye.start)} to ${(0,f.ukDate)(ye.end)} \xb7 confirmed hours only in the totals \xb7 printed ${(0,f.ukDate)(t)}`,e[0],e.slice(1))}})]}),he?(0,M.jsx)(h.Banner,{kind:"success",title:he}):null,K?(0,M.jsxs)(i.default,{testID:"hours-table",style:{gap:10},children:[ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderRadius:16,borderWidth:1,borderColor:'rgba(212,175,106,0.45)',backgroundColor:b.colours.surface,padding:12,gap:10},children:[(0,M.jsx)(u.HoursSummaryCard,{name:A(e.person),role:O(e.person),approved:e.confirmed,pending:e.pending,rate:e.rate}),(0,M.jsx)(h.Button,{kind:"secondary",testID:`hours-open-${e.person.id}`,label:s?'Hide shifts':`Show ${e.days.length} ${1===e.days.length?'shift':'shifts'}`,accessibilityLabel:`${s?'Hide':'Show'} ${A(e.person)}'s shifts`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{minHeight:48}}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(h.Muted,{center:!0,children:["Total: ",(0,l.durText)(me.c)," approved",xe?` \xb7 ${(0,x.gbp)(me.g)} gross`:'',me.p?` \xb7 ${(0,l.durText)(me.p)} pending`:'']})]}):(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"hours-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:q[s]},children:e},s))}),ge.map(e=>{const s=!!ue[e.person.id];return(0,M.jsxs)(i.default,{style:{borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:`${A(e.person)} daily hours`,onPress:()=>ce({...ue,[e.person.id]:!s}),style:{paddingVertical:7},children:(0,M.jsxs)(o.TRow,{heads:['Name','Shifts','Approved','Pending',fe?'Tips h':'Hours',xe?'Rate':'',xe?'Gross':''],children:[(0,M.jsxs)(i.default,{style:{width:q[0]},children:[(0,M.jsxs)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:[s?'\u25be':'\u25b8'," ",A(e.person)]}),(0,M.jsx)(h.Muted,{children:O(e.person)})]}),(0,M.jsx)(h.T,{size:14,style:{width:q[1]},children:e.shifts}),(0,M.jsx)(h.T,{size:14,weight:"semibold",style:{width:q[2]},children:(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,weight:e.pending?'bold':'regular',colour:e.pending?b.colours.amber:b.colours.muted,style:{width:q[3]},children:e.pending?`\u26a0 ${(0,l.durText)(e.pending)}`:'0m'}),(0,M.jsx)(h.T,{size:14,style:{width:q[4]},children:fe?(0,f.decH)(e.confirmed):(0,l.durText)(e.confirmed)}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:q[5]},children:xe?null!=e.rate?(0,x.gbp)(e.rate):'\u2013':''}),(0,M.jsxs)(h.T,{size:14,weight:"semibold",style:{width:q[6]},children:[xe?null!=e.gross?(0,x.gbp)(e.gross):'\u2013':'',xe&&null!=e.rate&&e.pending?(0,M.jsx)(h.T,{size:12,colour:b.colours.amber,children:`\n+ ${(0,x.gbp)(Math.round(e.pending/60*e.rate))} pending`}):null]})]})}),s?te(e):null]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','Shifts','Approved','Pending',fe?'Tips h':'Hours','',xe?'Gross':''],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:q[0]},children:["Total (",ge.length,")"]}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[1]},children:me.s}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:b.colours.gold,style:{width:q[2]},children:(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,weight:"bold",colour:me.p?b.colours.amber:b.colours.muted,style:{width:q[3]},children:(0,l.durText)(me.p)}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[4]},children:fe?(0,f.decH)(me.c):(0,l.durText)(me.c)}),(0,M.jsx)(h.T,{size:14,style:{width:q[5]},children:" "}),(0,M.jsx)(h.T,{size:14,weight:"bold",style:{width:q[6]},children:xe?(0,x.gbp)(me.g):''})]})]})}),Q?(0,M.jsx)(c.OverrideSheet,{a:Q,staffId:Q.staffId,date:Q.date,onClose:()=>X(null)}):null,Z?(0,M.jsx)(u.RemoveShiftSheet,{a:Z,who:{name:w,id:T},onClose:()=>{ee(null),Te('Removed from hours. It is kept in the history.')}}):null,R?(0,M.jsx)(D.AddPastShiftSheet,{onClose:()=>I(!1),onSaved:()=>{I(!1),Te('Saved. It counts in the hours and pay.')}}):null,(0,M.jsxs)(h.Muted,{children:["Tap a name for each day. Hours read 37h 30m. The export also has decimal hours (37.50) and h:mm for your spreadsheet. Paid hours = clock out \u2212 clock in \u2212 break. ",xe?'Gross is before tax, from confirmed hours only.':'Rates and gross show once you sign in with your personal link.']}),fe?(0,M.jsx)(h.Button,{kind:"success",label:"Tips day: split tips for this period \u203a",onPress:()=>e('more','tipsday')}):null]}):(0,M.jsx)(h.Muted,{center:!0,testID:"hours-managers-only",children:"Payroll hours are for managers and owners."})},_e.TipsDay=function({go:e}){const{rid:t,today:r,now:a}=(0,P.useCtx)(6e4),{pay:u,source:c}=(0,k.useVenuePay)(t),p=(0,y.useOwner)(e=>e.staff),T=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),C=(0,y.useOwner)(e=>e.tronc),S=(0,f.nextToPay)(u,'tips',r),[D,v]=(0,n.useState)(0),$=(0,f.tipsPeriod)(u,S.period.start,D),[B,R]=(0,n.useState)(''),[I,z]=(0,n.useState)({}),[L,N]=(0,n.useState)(null),E=(0,n.useMemo)(()=>H($,p,T,a,{}),[$.key,p,T]),Y=e=>'owner'===e.role&&!C.includeOwner||'manager'===e.role&&!C.includeManagers,U=e=>I[e.id]??Y(e),_=E.filter(e=>e.confirmed>0||e.pending>0),q=Math.round(100*Number(B.replace(/[\xa3,\s]/g,''))),J=Number.isFinite(q)&&q>0&&q<=1e8&&/^\s*\xa3?\s*[\d,]+(\.\d{0,2})?\s*$/.test(B),K=_.filter(e=>!U(e.person)&&e.confirmed>0),{amounts:Q}=(0,w.allocate)(J?q:0,K.map(e=>e.confirmed)),X={};K.forEach((e,s)=>{X[e.person.id]=Q[s]});const Z=K.reduce((e,s)=>e+s.confirmed,0),ee=Object.values(X).reduce((e,s)=>e+s,0),se=_.filter(e=>e.pending>0&&!U(e.person)),te=se.reduce((e,s)=>e+s.pending,0),oe=()=>[['Name','Role','Period start','Period end','Payday','Confirmed hours','Confirmed h:mm','Share %','Tips \xa3'],..._.map(e=>{const s=!U(e.person)&&e.confirmed>0;return[A(e.person),O(e.person),(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),s&&Z?(e.confirmed/Z*100).toFixed(2):'0.00',s?W(X[e.person.id]??0):U(e.person)?'excluded':'0.00']}),['TOTAL','',(0,f.ukDate)($.start),(0,f.ukDate)($.end),$.payday?(0,f.ukDate)($.payday):'',(0,f.decH)(Z),(0,f.hMm)(Z),Z?'100.00':'0.00',W(ee)]],ne=e=>{N(e),setTimeout(()=>N(null),6e3)};return(0,M.jsxs)(i.default,{style:{gap:10},testID:"tips-day",children:[(0,M.jsx)(h.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'===c?(0,M.jsxs)(h.Banner,{kind:"warn",title:"Tips dates not set up",children:[(0,M.jsx)(h.Muted,{children:"Using weekly tips for now."}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Set your pay dates \u203a",onPress:()=>e('more','paysettings')})]}):null,(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",disabled:D<=-6,onPress:()=>v(D-1)}),(0,M.jsxs)(i.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(h.T,{weight:"bold",size:18,children:(0,f.rangeText)($.start,$.end)}),(0,M.jsxs)(h.Muted,{children:[(0,f.ukDate)($.start)," to ",(0,f.ukDate)($.end)," \xb7 ",$.payday>=r?'paid':'was paid'," ",(0,f.dayMonth)($.payday)]}),0===D?(0,M.jsx)(h.Badge,{kind:"gold",label:"Paid next"}):null]}),(0,M.jsx)(h.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:D>=1,onPress:()=>v(D+1)})]}),(0,M.jsxs)(h.Card,{highlight:b.colours.gold,children:[(0,M.jsx)(h.T,{weight:"semibold",children:"Total tips to share"}),(0,M.jsxs)(h.Row,{style:{alignItems:'center'},children:[(0,M.jsx)(h.T,{size:28,weight:"bold",colour:b.colours.gold,children:"\xa3"}),(0,M.jsx)(s.TextInput,{testID:"tips-total",accessibilityLabel:"Total tips in pounds",value:B,onChangeText:R,placeholder:"0.00",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",style:[h.styles.input,{flex:1,fontSize:26,fontWeight:'700'}]})]}),B&&!J?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Enter an amount like 1250.00"}):(0,M.jsx)(h.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."})]}),se.length?(0,M.jsx)(d.default,{accessibilityRole:"button",onPress:()=>e('more','signoff'),testID:"tips-pending",children:(0,M.jsxs)(i.default,{style:{backgroundColor:b.colours.redBg,borderRadius:12,padding:12,borderLeftWidth:6,borderLeftColor:b.colours.red,gap:4},children:[(0,M.jsxs)(h.T,{weight:"bold",colour:b.colours.red,children:["\u26a0 Don't pay out yet: ",(0,l.durText)(te)," not approved yet"]}),(0,M.jsxs)(h.T,{size:14,children:[se.map(e=>`${A(e.person)} (${(0,l.durText)(e.pending)})`).join(', '),". Pending hours are left out of the split, so these people would get less than they should."]}),(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.gold,children:"Sign off hours \u203a"})]})}):_.length?(0,M.jsx)(h.Banner,{kind:"success",title:"All hours in this fortnight are signed off"}):null,(0,M.jsx)(o.WideTable,{children:(0,M.jsxs)(i.default,{testID:"tips-table",children:[(0,M.jsx)(o.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:b.colours.border,paddingBottom:4},children:['Include','Name','Confirmed','Share','Tips'].map((e,s)=>(0,M.jsx)(h.T,{size:12,weight:"semibold",colour:b.colours.gold,style:{width:[64,150,100,64,84][s]},children:e},e))}),_.map(e=>{const s=U(e.person),t=X[e.person.id]??0;return(0,M.jsxs)(o.TRow,{heads:['Include','Name','Confirmed','Share','Tips'],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222',opacity:s?.5:1},children:[(0,M.jsx)(d.default,{accessibilityRole:"checkbox",accessibilityState:{checked:!s},accessibilityLabel:`Include ${A(e.person)}`,onPress:()=>z({...I,[e.person.id]:!s}),style:{width:64,minHeight:44,justifyContent:'center'},children:(0,M.jsx)(i.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:s?b.colours.muted:b.colours.ok,backgroundColor:s?'transparent':b.colours.okBg,alignItems:'center',justifyContent:'center'},children:(0,M.jsx)(h.T,{size:14,colour:b.colours.ok,children:s?'':'\u2713'})})}),(0,M.jsxs)(i.default,{style:{width:150},children:[(0,M.jsx)(h.T,{size:14,weight:"semibold",numberOfLines:1,children:A(e.person)}),(0,M.jsxs)(h.Muted,{numberOfLines:1,children:[s?'Excluded':O(e.person),e.pending?` \xb7 \u26a0 ${(0,f.decH)(e.pending)} h pending`:'']})]}),(0,M.jsxs)(h.T,{size:14,style:{width:80},children:[(0,f.decH)(e.confirmed)," h"]}),(0,M.jsx)(h.T,{size:14,colour:b.colours.muted,style:{width:64},children:!s&&Z?`${(e.confirmed/Z*100).toFixed(1)}%`:'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:s?b.colours.muted:b.colours.gold,style:{width:84},children:s?'\u2013':(0,x.gbp)(t)})]},e.person.id)}),(0,M.jsxs)(o.TRow,{heads:['','','Confirmed','Share','Tips'],style:{paddingVertical:8,borderTopWidth:2,borderColor:b.colours.gold},children:[(0,M.jsx)(h.T,{size:14,style:{width:64},children:" "}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:150},children:["Total (",K.length," people)"]}),(0,M.jsxs)(h.T,{size:14,weight:"bold",style:{width:80},children:[(0,f.decH)(Z)," h"]}),(0,M.jsx)(h.T,{size:14,style:{width:64},children:Z?'100%':'\u2013'}),(0,M.jsx)(h.T,{size:15,weight:"bold",colour:J&&ee===q?b.colours.ok:b.colours.text,style:{width:84},children:(0,x.gbp)(ee)})]})]})}),_.length?null:(0,M.jsx)(h.Muted,{children:"No clocked hours in this fortnight yet."}),J&&Z?(0,M.jsxs)(h.Muted,{children:["Check: ",K.length," shares add up to ",(0,x.gbp)(ee)," of ",(0,x.gbp)(q)," ",ee===q?'\u2713':'',". \xa3",(q/100/(Z/60)).toFixed(4)," per confirmed hour."]}):null,(0,M.jsxs)(h.Muted,{children:["Owner ",C.includeOwner?'included':'left out'," and managers ",C.includeManagers?'included':'left out'," by default (your tipping policy in Tips). Tick or untick anyone for this split."]}),(0,M.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Copy for spreadsheet",testID:"tips-copy",disabled:!J,onPress:async()=>{const e=await G(F(oe()));ne(e?'Copied. Paste into the first cell of your spreadsheet.':'Copy is not available here. Use Download CSV.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Download CSV",disabled:!J,onPress:()=>{(0,j.downloadText)(`tips-${$.start}-to-${$.end}.csv`,V(oe())),ne('CSV downloaded.')}}),(0,M.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print / PDF",disabled:!J,onPress:()=>{const e=oe();(0,j.printTable)(`Tips ${(0,f.rangeText)($.start,$.end)} (paid ${(0,f.dayMonth)($.payday)})`,`Total ${(0,x.gbp)(q)} shared by confirmed hours${se.length?` \xb7 WARNING ${(0,f.decH)(te)} h not signed off`:''}`,e[0],e.slice(1))}})]}),L?(0,M.jsx)(h.Banner,{kind:"success",title:L}):null]})},_e.PaydaysCard=function({go:e}){const{rid:s,today:t}=(0,P.useCtx)(6e4),{pay:o,source:n}=(0,k.useVenuePay)(s),d=(0,f.nextToPay)(o,'tips',t).period,a=(0,f.nextToPay)(o,'wage',t).period;return(0,M.jsxs)(i.default,{testID:"paydays-card",style:{backgroundColor:b.colours.surface,borderRadius:16,borderWidth:1,borderColor:b.colours.hairline,padding:16,gap:8},children:[(0,M.jsx)(r.CardHeading,{right:'none'===n?(0,M.jsx)(h.Badge,{kind:"amber",label:"Not set up"}):null,children:"Paydays"}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next tips payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:d.payday===t?'today':(0,f.dayMonth)(d.payday)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(d.start,d.end)})]}),(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:["Next payday: ",(0,M.jsx)(h.T,{weight:"semibold",colour:b.colours.goldLight,children:a.payday===t?'today':(0,f.dayMonth)(a.payday)})]}),(0,M.jsxs)(h.Muted,{children:["period ",(0,f.rangeText)(a.start,a.end)]})]}),(0,M.jsxs)(r.ActionGrid,{testID:"paydays-actions",children:[(0,M.jsx)(r.ActionTile,{primary:!0,icon:"payroll",label:"Payroll hours",sub:"Copy or export",onPress:()=>e('more','hours'),testID:"paydays-hours"}),(0,M.jsx)(r.ActionTile,{icon:"tips",label:"Tips day",sub:"Share out tips",onPress:()=>e('more','tipsday'),testID:"paydays-tips"})]}),'settings'!==n?(0,M.jsx)(h.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,P.useCtx)(6e4),r=e??n,{pay:d}=(0,k.useVenuePay)(s),a=(0,y.useOwner)(e=>(0,y.liveAttendance)(e.attendance)),u=(0,y.useOwner)(e=>e.staff.find(e=>e.id===r)),c=(0,f.wagePeriod)(d,t,0),p=(0,f.tipsPeriod)(d,t,0),x=e=>u?H(e,[u],a,o,{})[0]??null:null,j=(e,s,o)=>(0,M.jsxs)(i.default,{style:{flexGrow:1,flexBasis:160,backgroundColor:b.colours.surface,borderRadius:14,borderWidth:1,borderColor:b.colours.border,padding:12,gap:2},children:[(0,M.jsx)(h.T,{size:13,weight:"semibold",colour:b.colours.gold,children:e.toUpperCase()}),(0,M.jsxs)(h.Muted,{children:[(0,f.rangeText)(s.start,s.end)," \xb7 ",s.payday>=t?'paid':'was paid'," ",(0,f.dayMonth)(s.payday)]}),(0,M.jsx)(h.T,{size:24,weight:"bold",children:(0,l.durText)(o?.confirmed??0)}),(0,M.jsxs)(h.Muted,{children:["approved \xb7 ",o?.shifts??0," shifts"]}),o?.pending?(0,M.jsxs)(h.T,{size:13,colour:b.colours.amber,children:["+ ",(0,l.durText)(o.pending)," waiting for approval"]}):null]},e);return(0,M.jsx)(h.Row,{wrap:!0,gap:8,style:{alignItems:'stretch'},children:[j('This pay period',c,x(c)),j('This tips fortnight',p,x(p))]})};var s=_r(_d[0]),t=_r(_d[1]),o=_r(_d[2]),n=_r(_d[3]),r=_r(_d[4]);_r(_d[5]);var d=e(_r(_d[6])),a=e(_r(_d[7])),i=e(_r(_d[8])),l=_r(_d[9]),u=_r(_d[10]),c=_r(_d[11]),h=_r(_d[12]),p=_r(_d[13]),y=_r(_d[14]),x=_r(_d[15]),f=_r(_d[16]),b=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),P=_r(_d[21]),k=_r(_d[22]),C=_r(_d[23]),S=_r(_d[24]),D=_r(_d[25]),v=_r(_d[26]),M=_r(_d[27]);const $={weekly:'Weekly',fortnightly:'Fortnightly',monthly:'Monthly'},B={none:'Keep the date',before:'Friday before',after:'Monday after'};const R=e=>`${e}${e%10==1&&11!==e?'st':e%10==2&&12!==e?'nd':e%10==3&&13!==e?'rd':'th'}`;function I({label:e,day:s,period:t}){return(0,M.jsxs)(h.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,M.jsxs)(h.T,{children:[e,": ",(0,M.jsx)(h.T,{weight:"bold",colour:b.colours.gold,children:(0,f.dayMonth)(s)})]}),(0,M.jsx)(h.Muted,{children:(0,f.rangeText)(t.start,t.end)})]})}const z=e=>{if(!e)return'';const s=new Date(e);return`${String(s.getHours()).padStart(2,'0')}:${String(s.getMinutes()).padStart(2,'0')}`};function H(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,P.paidMins)(e,o),t=(0,y.attStatus)(e);return{a:e,date:e.date,inT:z(e.in),outT:z(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'),a=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:a,gross:null!=a?Math.round(d/60*a):void 0}}).filter(e=>e.days.length>0||e.person.active&&'owner'!==e.person.role)}const O=e=>`${y.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`,A=e=>e.name.replace(' (example)',''),W=e=>null==e?'':(e/100).toFixed(2),L=e=>e.replace(/[\t\r\n]+/g,' '),N=e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e,F=e=>e.map(e=>e.map(L).join('\t')).join('\n'),V=e=>e.map(e=>e.map(N).join(',')).join('\r\n');function E(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=>[A(e.person),O(e.person),(0,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(e.confirmed),(0,f.hMm)(e.confirmed),(0,f.decH)(e.pending),(0,f.hMm)(e.pending),String(e.shifts),...o?[(0,f.decH)(e.confirmed)]:[],...t?[W(e.rate),W(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,f.ukDate)(s.start),(0,f.ukDate)(s.end),(0,f.decH)(d.c),(0,f.hMm)(d.c),(0,f.decH)(d.p),(0,f.hMm)(d.p),String(d.s),...o?[(0,f.decH)(d.c)]:[],...t?['',W(d.g)]:[]]]}function Y(e){return[['Name','Role','Date','In','Out','Break mins','Paid hours','Paid h:mm','Status'],...e.flatMap(e=>e.days.map(s=>[A(e.person),O(e.person),(0,f.ukDate)(s.date),s.inT,s.outT,'On now'===s.status?'':String(s.brk),'On now'===s.status?'':(0,f.decH)(s.paid),'On now'===s.status?'':(0,f.hMm)(s.paid),s.status]))]}async function G(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 U(e,s){const t=(0,f.nextToPay)(e,'wage',s),o=(0,f.nextToPay)(e,'tips',s),n=(0,f.wagePeriod)(e,t.period.start,-1),r=(0,f.tipsPeriod)(e,o.period.start,-1),d=e=>e.payday>=s?e.payday===s?'Pays today':`Pays ${(0,f.dayMonth)(e.payday)}`:`Paid ${(0,f.dayMonth)(e.payday)}`;return[{id:'wage',label:`Wages ${(0,f.rangeText)(t.period.start,t.period.end)}`,sub:d(t.period),period:t.period},{id:'wagePrev',label:`Wages ${(0,f.rangeText)(n.start,n.end)}`,sub:d(n),period:n},{id:'tips',label:`Tips ${(0,f.rangeText)(o.period.start,o.period.end)}`,sub:d(o.period),period:o.period},{id:'tipsPrev',label:`Tips ${(0,f.rangeText)(r.start,r.end)}`,sub:d(r),period:r}]}function _({onSet:e}){const[s,o]=(0,n.useState)(''),[r,d]=(0,n.useState)(''),a=(0,f.parseUk)(s),l=(0,f.parseUk)(r),u=!!a&&!!l&&l>=a&&(0,f.plusDays)(a,92)>=l;return(0,M.jsxs)(h.Row,{wrap:!0,gap:6,style:{alignItems:'flex-end'},children:[(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"From (DD/MM/YYYY)",value:s,onChangeText:e=>o((0,t.slashDate)(e,s)),placeholder:"23/10/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(i.default,{style:{flexBasis:130,flexGrow:1},children:(0,M.jsx)(h.Field,{label:"To (DD/MM/YYYY)",value:r,onChangeText:e=>d((0,t.slashDate)(e,r)),placeholder:"22/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10})}),(0,M.jsx)(h.Button,{small:!0,kind:"success",label:"Show",disabled:!u,onPress:()=>u&&e((0,f.customPeriod)(a,l))}),s&&r&&!u?(0,M.jsx)(h.T,{size:13,colour:b.colours.red,children:"Use two dates, the second on or after the first, up to 3 months apart."}):null]})}const q=[150,54,100,90,48,62,70]},1199,[827,1063,1194,34,1200,236,402,426,102,1202,1203,1204,794,831,891,867,1064,821,930,1212,1195,1088,1065,1205,872,1206,1210,25]); +__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)(t.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',justifyContent:'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)(l.Icon,{name:c,size:21,colour:j})}),(0,s.jsxs)(o.default,{style:{flexShrink: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:t="action-grid"}){const l=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])),t=e(_r(d[1])),o=e(_r(d[2])),l=_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]})},1200,[34,402,102,1201,821,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Icon=function({name:l,size:x=22,colour:t}){const n={stroke:t,strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,e.jsxs)(h.default,{width:x,height:x,viewBox:"0 0 24 24",children:['home'===l?(0,e.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,'signoff'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"8",...n}),(0,e.jsx)(s.Path,{d:"M11 6.5V11l3 2",...n}),(0,e.jsx)(s.Path,{d:"M15.5 19.5l2 2 4-4.2",...n})]}):null,'orders'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"5",y:"3",width:"14",height:"18",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M9 8h6M9 12h6M9 16h4",...n})]}):null,'rota'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M7 14h4M13 14h4M7 18h6",...n})]}):null,'bookings'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4",...n})]}):null,'forecast'===l?(0,e.jsx)(s.Path,{d:"M4 20V10M10 20V4M16 20v-7M22 20H2",...n}):null,'more'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"5",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"1.6",fill:t}),(0,e.jsx)(s.Circle,{cx:"19",cy:"12",r:"1.6",fill:t})]}):null,'search'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"11",r:"7",...n}),(0,e.jsx)(s.Path,{d:"M20 20l-4-4",...n})]}):null,'bell'===l?(0,e.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,e.jsx)(s.Path,{d:"M4 5h16v11H9l-5 4z",...n}):null,'clock'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M12 7v5l3 2",...n})]}):null,'user'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M4 21a8 8 0 0 1 16 0",...n})]}):null,'walkin'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"13",cy:"4.5",r:"1.8",...n}),(0,e.jsx)(s.Path,{d:"M10 21l2-6 3 3v3M9 12l2-4 4 1 2 3M11 8l-1 5",...n})]}):null,'calendarPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M3 10h18M8 3v4M16 3v4M12 13v5M9.5 15.5h5",...n})]}):null,'pause'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.jsx)(s.Path,{d:"M10 9v6M14 9v6",...n})]}):null,'rain'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M9 18l-1 2.5M13 18l-1 2.5M17 18l-1 2.5",...n})]}):null,'sun'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"4",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3",y:"4",width:"18",height:"16",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M7 9h6M7 13h4M15 12.5a2 2 0 1 0 0 .01M7 17h10",...n})]}):null,'tips'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"12",cy:"12",r:"9",...n}),(0,e.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,e.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,e.jsx)(e.Fragment,{children:(0,e.jsx)(s.Path,{d:"M3 15h18M5 15a7 7 0 0 1 14 0M12 6v2M2 18h20",...n})}):null,'check'===l?(0,e.jsx)(s.Path,{d:"M5 12.5l4.5 4.5L19 7.5",...n}):null,'alert'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M12 3l9.5 17h-19z",...n}),(0,e.jsx)(s.Path,{d:"M12 10v4M12 17.2v.1",...n})]}):null,'access'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"11",cy:"4.5",r:"1.8",...n}),(0,e.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,e.jsxs)(e.Fragment,{children:[(0,e.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,e.jsx)(s.Path,{d:"M10 13v.1M14 13v.1M11 16h2",...n})]}):null,'leaf'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 19c0-8 5-14 15-14 0 10-6 15-14 15",...n}),(0,e.jsx)(s.Path,{d:"M5 19l8-8",...n})]}):null,'table'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"4",y:"8",width:"16",height:"8",rx:"2",...n}),(0,e.jsx)(s.Path,{d:"M8 16v4M16 16v4M8 4v4M16 4v4",...n})]}):null,'bag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M5 8h14l-1 12H6z",...n}),(0,e.jsx)(s.Path,{d:"M9 10V7a3 3 0 0 1 6 0v3",...n})]}):null,'phone'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"7",y:"2.5",width:"10",height:"19",rx:"2.5",...n}),(0,e.jsx)(s.Path,{d:"M11 18.5h2",...n})]}):null,'swap'===l?(0,e.jsx)(s.Path,{d:"M7 4L3 8l4 4M3 8h14M17 20l4-4-4-4M21 16H7",...n}):null,'box'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 8L12 4l8.5 4v8L12 20l-8.5-4z",...n}),(0,e.jsx)(s.Path,{d:"M3.5 8L12 12l8.5-4M12 12v8",...n})]}):null,'star'===l?(0,e.jsx)(s.Path,{d:"M12 3.5l2.6 5.4 5.9.8-4.3 4.1 1 5.8L12 16.8l-5.2 2.8 1-5.8L3.5 9.7l5.9-.8z",...n}):null,'userPlus'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Circle,{cx:"10",cy:"8",r:"4",...n}),(0,e.jsx)(s.Path,{d:"M3 21a7 7 0 0 1 14 0M19 8v6M16 11h6",...n})]}):null,'gift'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Rect,{x:"3.5",y:"8.5",width:"17",height:"4",rx:"1",...n}),(0,e.jsx)(s.Path,{d:"M5 12.5V20h14v-7.5M12 8.5V20M12 8.5C10 8.5 7.5 7.8 7.5 5.8S10.5 4 12 8.5c1.5-4.5 4.5-4.7 4.5-2.7S14 8.5 12 8.5z",...n})]}):null,'tag'===l?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(s.Path,{d:"M3.5 12.5V4h8.5l8.5 8.5-8.5 8.5z",...n}),(0,e.jsx)(s.Circle,{cx:"8",cy:"8.5",r:"1.4",...n})]}):null,'hanger'===l?(0,e.jsx)(s.Path,{d:"M12 7.5a2 2 0 1 1 2-2M12 7.5v2L3 16.5h18L12 9.5",...n}):null]})},r(d[0]);var l,s=r(d[1]),h=(l=s)&&l.__esModule?l:{default:l},e=r(d[2])},1201,[34,797,25]); +__d(function(_g,_r,i,_a,_m,e,d){"use strict";function t(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return o?`${o}h ${String(r).padStart(2,'0')}m`:`${r}m`}function n(t){const n=Math.max(0,Math.round(t||0)),o=Math.floor(n/60),r=n%60;return[o?`${o} ${1===o?'hour':'hours'}`:'',r||!o?`${r} ${1===r?'minute':'minutes'}`:''].filter(Boolean).join(' ')}Object.defineProperty(e,'__esModule',{value:!0}),e.durText=t,e.durWords=n,e.isZeroShift=function(t){return!(!t.in||!t.out)&&Date.parse(t.out)-Date.parse(t.in)<6e4},Object.defineProperty(e,"isVoided",{enumerable:!0,get:function(){return o}}),e.shiftSentence=function(t,o){if('On now'===t.status)return`${o}, clocked in at ${t.inT}, still on shift.`;const r=t.zero?' Check: 0 minutes, clocked in and out at the same moment.':'';return`${o}, ${t.inT} to ${t.outT}, break ${n(t.brk)}, paid ${n(t.paid)}, ${'Approved'===t.status?'approved':'pending approval'}.${r}`},e.hoursSummary=function(n,o,r){const u=t=>null!=r?Math.round(t/60*r):null;return{approved:{mins:n,text:t(n),gross:u(n)},pending:{mins:o,text:t(o),gross:u(o)}}};const o=t=>!!t.voided},1202,[]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ShiftCard=function({d:e,manager:t,onApprove:s,onEdit:d,onRemove:l}){const a='Confirmed'===e.status?'Approved':e.status,y=(0,u.isZeroShift)(e.a),x={date:e.date,dateText:b(e.date),inT:e.inT,outT:e.outT,brk:e.brk,paid:e.paid,status:a,zero:y};return(0,h.jsxs)(n.default,{testID:`shift-${e.a.id}`,style:{borderRadius:14,borderWidth:1,borderColor:y?c.colours.amber:'rgba(212,175,106,0.35)',backgroundColor:'#15130F',padding:12,gap:8,alignItems:'center'},children:[(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:(0,u.shiftSentence)(x,p(e.date)),style:{alignItems:'center',gap:4,width:'100%'},children:[(0,h.jsx)(o.T,{size:16,weight:"bold",colour:c.colours.goldLight,center:!0,children:b(e.date)}),(0,h.jsx)(o.T,{size:17,weight:"semibold",center:!0,children:'On now'===e.status?`${e.inT} to now`:`${e.inT} to ${e.outT}`}),'On now'!==e.status?(0,h.jsxs)(o.T,{size:15,colour:c.colours.text,center:!0,children:["Break ",(0,u.durText)(e.brk)," \xb7 Paid ",(0,h.jsx)(o.T,{size:15,weight:"bold",colour:c.colours.gold,children:(0,u.durText)(e.paid)})]}):null,(0,h.jsx)(o.Badge,{kind:'Approved'===a?'ok':'Pending'===a?'amber':'neutral',label:'Pending'===a?'Pending approval':a}),y?(0,h.jsx)(n.default,{testID:`shift-zero-${e.a.id}`,style:{borderRadius:8,borderWidth:1,borderColor:c.colours.amber,paddingHorizontal:10,paddingVertical:4},children:(0,h.jsx)(o.T,{size:14,weight:"bold",colour:c.colours.amber,center:!0,children:"Check: 0 minutes"})}):null,e.a.added&&e.a.signOff?(0,h.jsxs)(o.Muted,{center:!0,testID:`shift-entered-${e.a.id}`,children:["Entered by ",e.a.signOff.by]}):null]}),t?(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:['Pending'===e.status&&!y&&s?(0,h.jsx)(o.Button,{label:"Approve",testID:`shift-approve-${e.a.id}`,accessibilityLabel:`Approve ${p(e.date)}, paid ${(0,u.durWords)(e.paid)}`,onPress:s,style:{minHeight:48,minWidth:120}}):null,(y||'Pending'===e.status)&&d?(0,h.jsx)(o.Button,{kind:"secondary",label:"Edit",testID:`shift-edit-${e.a.id}`,accessibilityLabel:`Edit the shift on ${p(e.date)}`,onPress:d,style:{minHeight:48,minWidth:96}}):null,y&&'Confirmed'!==e.status&&l?(0,h.jsx)(o.Button,{kind:"secondary",label:"Remove",testID:`shift-remove-${e.a.id}`,accessibilityLabel:`Remove the 0-minute shift on ${p(e.date)}. It is kept in the history.`,onPress:l,style:{minHeight:48,minWidth:96}}):null]}):null]})},_e.HoursSummaryCard=function({name:e,role:t,approved:s,pending:d,rate:l}){const p=(0,u.hoursSummary)(s,d,l),b=`${e}. Approved ${(0,u.durWords)(s)}${null!=p.approved.gross?`, ${(0,a.gbp)(p.approved.gross)}`:''}. Pending approval ${(0,u.durWords)(d)}${null!=p.pending.gross?`, ${(0,a.gbp)(p.pending.gross)} once approved`:''}.${null!=l?` Rate ${(0,a.gbp)(l)} an hour.`:''}`;return(0,h.jsxs)(n.default,{accessible:!0,accessibilityLabel:b,testID:"hours-summary-card",style:{alignItems:'center',gap:6,width:'100%'},children:[(0,h.jsx)(o.T,{size:18,weight:"bold",center:!0,children:e}),t?(0,h.jsx)(o.Muted,{center:!0,children:t}):null,(0,h.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center'},children:[(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.ok,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.ok,children:"APPROVED"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-approved",children:p.approved.text}),(0,h.jsx)(o.Muted,{children:null!=p.approved.gross?`${(0,a.gbp)(p.approved.gross)} gross`:'no rate'})]}),(0,h.jsxs)(n.default,{style:{minWidth:150,borderRadius:12,borderWidth:1,borderColor:c.colours.amber,padding:10,alignItems:'center'},children:[(0,h.jsx)(o.T,{size:13,weight:"semibold",colour:c.colours.amber,children:"PENDING"}),(0,h.jsx)(o.T,{size:20,weight:"bold",testID:"sum-pending",children:p.pending.text}),(0,h.jsx)(o.Muted,{children:null!=p.pending.gross?`${(0,a.gbp)(p.pending.gross)} once approved`:'no rate'})]})]}),null!=l?(0,h.jsxs)(o.Muted,{center:!0,children:["Rate ",(0,a.gbp)(l)," an hour",(y=null,null==y?'':` \xb7 ${(0,a.gbp)(y)}`)]}):null]});var y},_e.RemoveShiftSheet=function({a:e,who:s,onClose:n}){const[a,u]=(0,t.useState)('Clocked in and out by mistake (0 minutes)'),p=a.trim().length>=3;return(0,h.jsxs)(o.Sheet,{visible:!0,onClose:n,title:`Remove the shift on ${b(e.date)}?`,maxWidth:520,testID:"remove-shift",children:[(0,h.jsx)(o.T,{size:16,center:!0,children:"It comes out of hours, pay and exports. It isn\u2019t deleted: it stays in the history with your name and the reason."}),(0,h.jsx)(d.TextInput,{accessibilityLabel:"Reason for removing the shift",value:a,onChangeText:u,style:{minHeight:48,borderRadius:10,borderWidth:1,borderColor:c.colours.gold,color:c.colours.text,paddingHorizontal:12}}),(0,h.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,h.jsx)(o.Button,{label:"Remove shift",testID:"remove-shift-yes",disabled:!p,onPress:()=>{l.useOwner.getState().voidEntry(e.id,s.name,s.id,a.trim(),(new Date).toISOString()),n()},style:{minHeight:56}}),(0,h.jsx)(o.Button,{kind:"secondary",label:"Keep it",onPress:n,style:{minHeight:56}})]})]})};var e,t=r(_d[0]),s=r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},o=r(_d[2]),d=r(_d[3]),l=r(_d[4]),a=r(_d[5]),u=r(_d[6]),c=r(_d[7]),h=r(_d[8]);const p=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'UTC'}),b=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'UTC'})},1203,[34,102,794,827,891,867,1202,821,25]); +__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,"REASONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"isoAt",{enumerable:!0,get:function(){return D}}),_e.flagsFor=M,_e.notesFor=O,Object.defineProperty(_e,"statusLabel",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"statusKind",{enumerable:!0,get:function(){return B}}),_e.AuditTrail=A,_e.TimeEdit=P,_e.OverrideSheet=q,_e.outstandingDays=H,_e.useOutstanding=function(){const e=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),t=(0,r.useOwner)(e=>e.timeRequests),n=(0,u.ymd)(new Date);return(0,s.useMemo)(()=>({days:H(e,n),requests:t.filter(e=>'open'===e.status).length}),[e,t,n])},_e.SignOff=function(){const{role:e}=(0,h.useCtx)(3e4);return r.CAN.manage(e)?(0,k.jsx)(N,{}):(0,k.jsx)(l.Muted,{center:!0,testID:"signoff-managers-only",children:"Sign off hours is for managers and owners."})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3])),a=e(_r(_d[4])),l=_r(_d[5]),i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),p=_r(_d[14]),x=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),k=_r(_d[18]);const y=['Forgot to clock in','Forgot to clock out','Wrong time'],w=[0,15,20,30,45,60],I=e=>(e??'').replace(' (example)',''),S=e=>{const t=new Date(e);return 60*t.getHours()+t.getMinutes()},D=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setMinutes(t),n.toISOString()},v=e=>{const t=(e%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},C=(e,t)=>{const n=(0,u.parseYmd)(e);return n.setDate(n.getDate()+t),(0,u.ymd)(n)},$=(e,t)=>e===t?'Today':e===C(t,-1)?'Yesterday':(0,u.niceDate)((0,u.parseYmd)(e));function M(e,t,s,o,a=[]){const l=[],i=(0,h.paidMins)(e,s),r=60*s.getHours()+s.getMinutes();if(!e.out&&(e.date60*t.end+60||i.worked>840)&&l.push({key:'noout',label:'No clock-out'}),t&&e.in){const n=S(e.in)-Math.round(60*t.start),s=e.out?S(e.out)+(e.out.slice(0,10)!==e.in.slice(0,10)&&S(e.out)=30&&l.push({key:'diff',label:`${a>=60?(0,h.hmDur)(a):`${a}m`} off the rota`})}return(0,n.isZeroShift)(e)&&l.push({key:'zero',label:'Check: 0 minutes'}),t||l.push({key:'unrostered',label:'Not on the rota'}),i.worked>720&&l.push({key:'long',label:`Very long shift (${(0,h.hmDur)(i.worked)})`}),e.out&&i.worked>360&&0===i.brk&&l.push({key:'nobreak',label:'No break (over 6h)'}),!1!==e.inSite&&!1!==e.outSite||l.push({key:'offsite',label:'Clocked off-site'}),a.some(t=>'open'===t.status&&t.staffId===e.staffId&&t.date===e.date)&&l.push({key:'request',label:'Correction requested'}),e.breakAddedAtClockOut&&l.push({key:'breakadded',label:`Break added at clock-out (${e.breakAddedAtClockOut}m)`}),e.offRota&&t&&l.push({key:'offrota',label:'Signed in off rota'}),l}function O(e,t){const n=[];return(t||e?.temp)&&n.push('Temp'),'display'!==e?.via&&'display'!==e?.outVia||n.push('via Display'),'rota'===e?.auto&&n.push(e.autoNote?`Auto from rota \xb7 ${e.autoNote}`:'Auto from rota'),n}const T=e=>{const t=(0,r.attStatus)(e);return'open'===t?'Open':'awaiting'===t?e.adjusted?'Adjusted \xb7 awaiting sign-off':'Awaiting sign-off':e.adjusted?'Confirmed \xb7 adjusted':'Confirmed'},B=e=>{const t=(0,r.attStatus)(e);return'confirmed'===t?'ok':'open'===t?'blue':'amber'},R={added:'Added entry',clock_in:'Clock-in',clock_out:'Clock-out',break:'Break',confirmed:'Confirmed',reopened:'Reopened',request_applied:'Correction request applied',request_declined:'Correction request declined',voided:'Removed (kept in history)'};function A({a:e,limit:t}){const n=[...e.audit??[]].reverse().slice(0,t??50);return n.length?(0,k.jsx)(a.default,{style:{gap:6},testID:"audit-trail",children:n.map((e,t)=>(0,k.jsxs)(a.default,{style:{flexDirection:'row',gap:8},children:[(0,k.jsx)(a.default,{style:{width:3,borderRadius:2,backgroundColor:'confirmed'===e.action?c.colours.ok:'reopened'===e.action?c.colours.amber:c.colours.gold}}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:13,weight:"semibold",children:[R[e.action],e.from||e.to?`: ${e.from??'\u2013'} \u2192 ${e.to??'\u2013'}`:'']}),(0,k.jsxs)(l.Muted,{children:[I(e.by)," \xb7 ",(0,u.niceDate)(new Date(e.at))," ",(0,u.hm)(new Date(e.at)),e.reason?` \xb7 \u201c${e.reason}\u201d`:'']})]})]},t))}):(0,k.jsx)(l.Muted,{children:"No changes yet. Times are as clocked."})}function P({label:e,mins:n,onChange:o,testID:i}){const[r,d]=(0,s.useState)(null),u=e=>{const t=/^(\d{1,2})[:.]?(\d{2})$/.exec(e.trim());t&&+t[1]<24&&+t[2]<60&&o(60*+t[1]+ +t[2]+(n>=1440&&60*+t[1]+ +t[2]<360?1440:0)),d(null)};return(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:e}),n>=1440?(0,k.jsx)(l.Muted,{children:"next day"}):null]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u221215",onPress:()=>o(n-15)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"\u22125",onPress:()=>o(n-5)}),(0,k.jsx)(t.TextInput,{testID:i,accessibilityLabel:e,value:r??v(n),onChangeText:d,onBlur:()=>null!=r&&u(r),onSubmitEditing:()=>null!=r&&u(r),style:[l.styles.input,{flex:1,textAlign:'center',fontSize:22,fontWeight:'700',paddingVertical:6,color:c.colours.text}]}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+5",onPress:()=>o(n+5)}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"+15",onPress:()=>o(n+15)})]})]})}function q({a:e,staffId:t,date:n,request:o,onClose:i}){const{me:d,meId:b,now:j,role:v}=(0,h.useCtx)(3e4),[C,$]=(0,s.useState)(!1),M=!!e&&(0,m.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),O=(0,r.useOwner)(e=>e.staff.find(e=>e.id===t)?.name),R=(0,r.useOwner)(e=>e.shifts),q=(0,r.shiftOf)(R,t,n),H=o?.suggestedIn?S(o.suggestedIn):e?.in?Math.round((new Date(e.in).getTime()-(0,u.parseYmd)(n).getTime())/6e4):q?Math.round(60*q.start):720,N=o?.suggestedOut??e?.out,z=N?(F=N,Math.round((new Date(F).getTime()-(0,u.parseYmd)(n).getTime())/6e4)):e&&e.in&&!e.out?null:q?Math.round(60*q.end):H+480;var F;const[E,_]=(0,s.useState)(H),[L,Y]=(0,s.useState)(z),[W,V]=(0,s.useState)(e?.breakMins??(q&&q.end-q.start>6?30:0)),[G,K]=(0,s.useState)(o?'out'===o.kind?y[1]:y[0]:e?e.in&&!e.out?y[1]:null:y[0]),[U,Z]=(0,s.useState)(''),[J,Q]=(0,s.useState)(null),X=[G,U.trim()].filter(Boolean).join(': ')+(o&&o.note?` (request: ${o.note})`:''),ee=null!=L?L-E:0,te=e?(0,h.paidMins)(e,j):null,ne=null!=L?Math.max(0,ee-W):null,se=e&&'confirmed'===(0,r.attStatus)(e),oe=null!=L&&L<=E?'Clock-out must be after clock-in.':ee>1200?'A shift can\u2019t be longer than 20 hours.':null!=L&&W>=ee?'The break is longer than the shift.':null,ae=e?.in&&!o&&E===H?e.in:D(n,E),le=null==L?void 0:e?.out&&!o&&L===z?e.out:D(n,L),ie=!e||ae!==e.in||(le??'')!==(e.out??'')||(e.breakMins??0)!==W;return(0,k.jsxs)(l.Sheet,{visible:!0,onClose:i,title:`${e?'Edit hours':'Add missing entry'} \xb7 ${I(O)} \xb7 ${(0,u.niceDate)((0,u.parseYmd)(n))}`,testID:"override-sheet",children:[(0,k.jsxs)(l.Row,{gap:8,style:{flexWrap:'wrap'},children:[e?(0,k.jsx)(l.Badge,{kind:B(e),label:T(e)}):(0,k.jsx)(l.Badge,{kind:"red",label:"No clock record"}),q?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Rota ${(0,h.fmtH)(q.start)}\u2013${(0,h.fmtH)(q.end)}`}):(0,k.jsx)(l.Badge,{kind:"neutral",label:"Not on the rota"}),e?.in?(0,k.jsx)(l.Badge,{kind:"neutral",label:`Clocked ${(0,u.hm)(new Date(e.in))}\u2013${e.out?(0,u.hm)(new Date(e.out)):'still on'}`}):null]}),o?(0,k.jsxs)(l.Banner,{kind:"info",title:`${I(O)} asked for a correction`,children:['in'===o.kind?'Forgot to clock in':'out'===o.kind?'Forgot to clock out':'Forgot to clock in and out',o.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(o.suggestedIn))}`:'',o.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(o.suggestedOut))}`:'',o.note?` \xb7 \u201c${o.note}\u201d`:'',". The suggested times are filled in below."]}):null,(0,k.jsx)(P,{label:"Clock in",mins:E,onChange:_,testID:"ov-in"}),null!=L?(0,k.jsx)(P,{label:"Clock out",mins:L,onChange:Y,testID:"ov-out"}):(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.Muted,{children:"No clock-out yet."}),(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:"Add clock-out",onPress:()=>Y(q?Math.round(60*q.end):Math.min(E+480,60*j.getHours()+j.getMinutes()>E?60*j.getHours()+j.getMinutes():E+480))})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Break"}),(0,k.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.map(e=>(0,k.jsx)(l.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>V(e)},e)),(0,k.jsx)(l.Stepper,{value:W,min:0,max:240,onChange:V,label:"break minutes"})]}),(0,k.jsx)(l.T,{size:13,colour:c.colours.muted,children:"Reason (required, kept in the audit trail)"}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:y.map(e=>(0,k.jsx)(l.Chip,{label:e,selected:G===e,onPress:()=>K(G===e?null:e)},e))}),(0,k.jsx)(l.Field,{label:G?'Add detail (optional)':'Or type a reason',value:U,onChangeText:Z,placeholder:"e.g. stayed late for a function",maxLength:150}),(0,k.jsxs)(l.Card,{style:{backgroundColor:c.colours.surface2},children:[(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(l.T,{children:"Paid hours"}),(0,k.jsx)(l.T,{weight:"bold",colour:c.colours.gold,children:null!=ne?(0,h.hmDur)(ne):'still on shift'})]}),te&&e?.out?(0,k.jsxs)(l.Muted,{children:["Was ",(0,h.hmDur)(te.paid)," (",(0,u.hm)(new Date(e.in)),"\u2013",(0,u.hm)(new Date(e.out)),", ",te.brk,"m break)"]}):null,se?(0,k.jsx)(l.T,{size:13,colour:c.colours.amber,children:"This entry was confirmed. Saving puts it back to Awaiting sign-off (logged)."}):null]}),oe?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:oe}):null,J?(0,k.jsx)(l.T,{size:13,colour:c.colours.red,children:J}):null,(0,k.jsx)(l.Button,{testID:"ov-save",kind:"success",label:e?'Save change':'Add entry',disabled:!!oe||!ie||X.trim().length<3,onPress:()=>{r.useOwner.getState().overrideEntry({id:e?.id,staffId:t,date:n,in:ae,out:le,breakMins:W,reason:X.slice(0,200),by:d,byId:b,now:j.toISOString(),request:o?.id})?(o&&r.useOwner.getState().resolveTimeRequest(o.id,'applied',d,j.toISOString()),i()):Q('Couldn\u2019t save: check the times and the reason.')}}),M?(0,k.jsx)(a.default,{style:{alignItems:'center',width:'100%'},children:(0,k.jsx)(l.Button,{testID:"ov-delete-entry",kind:"ghost",label:"Delete entry",accessibilityLabel:"Delete entry",onPress:()=>$(!0),style:{minHeight:48,minWidth:160}})}):null,e&&C?(0,k.jsx)(x.DeleteShiftSheet,{a:e,onClose:()=>$(!1),onDeleted:i}):null,e?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(f.SectionHead,{title:"Audit trail",sub:"Every change: what, from, to, who, when and why"}),(0,k.jsx)(A,{a:e})]}):null]})}function H(e,t){const n=new Map;return e.forEach(e=>{e.date({date:e,n:t})).sort((e,t)=>t.date.localeCompare(e.date))}function N(){const{now:e,today:t,me:n,meId:m}=(0,h.useCtx)(3e4),p=(0,r.useOwner)(e=>e.staff),x=(0,r.useOwner)(e=>(0,r.liveAttendance)(e.attendance)),y=(0,r.useOwner)(e=>e.shifts),w=(0,r.useOwner)(e=>e.timeRequests),S=(0,r.useOwner)(e=>e.leave),D=(0,s.useMemo)(()=>H(x,t),[x,t]),[v,R]=(0,s.useState)(t),[A,P]=(0,s.useState)(!1),[N,z]=(0,s.useState)(null),[F,E]=(0,s.useState)(null),_=(0,s.useMemo)(()=>{const n=x.filter(e=>e.date===v&&e.in),s=n.map(n=>{const s=(0,r.shiftOf)(y,n.staffId,v);return{key:n.id,staffId:n.staffId,a:n,sh:s,flags:M(n,s,e,t,w)}});y.filter(e=>e.date===v&&!1!==e.published&&!n.some(t=>t.staffId===e.staffId)).forEach(n=>{const o=(0,d.leaveCovering)(S,n.staffId,v);if(o)return void(s.some(e=>e.leave&&e.staffId===n.staffId)||s.push({key:`leave-${n.id}`,staffId:n.staffId,sh:n,flags:[],leave:o}));(v60*n.start+15)&&s.push({key:`miss-${n.id}`,staffId:n.staffId,sh:n,flags:[{key:'noin',label:'No clock-in'}]})});const o=e=>e.leave?4:e.a?'confirmed'===(0,r.attStatus)(e.a)?3:e.flags.length?0:2:1;return s.sort((e,t)=>o(e)-o(t)||(p.find(t=>t.id===e.staffId)?.name??'').localeCompare(p.find(e=>e.id===t.staffId)?.name??''))},[x,y,w,S,v,e.getMinutes(),p]),L=w.filter(e=>'open'===e.status&&e.date===v),Y=w.filter(e=>'open'===e.status&&e.date!==v),W=_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)&&!e.flags.length),V=_.reduce((t,n)=>{if(!n.a)return t;const s=(0,h.paidMins)(n.a,e).paid;return'confirmed'===(0,r.attStatus)(n.a)?t.conf+=s:t.pend+=s,t},{conf:0,pend:0}),G={confirmed:_.filter(e=>e.a&&'confirmed'===(0,r.attStatus)(e.a)).length,awaiting:_.filter(e=>e.a&&'awaiting'===(0,r.attStatus)(e.a)).length,open:_.filter(e=>e.a&&'open'===(0,r.attStatus)(e.a)).length,flagged:_.filter(e=>e.flags.length&&!(e.a&&'confirmed'===(0,r.attStatus)(e.a))).length,off:_.filter(e=>e.leave).length},K=[t,...D.map(e=>e.date).filter(e=>e!==t)];for(let e=1;K.length<8&&e<=7;e++){const n=C(t,-e);K.includes(n)||K.push(n)}const U=A?(0,b.pastWeekDays)(v,t).slice().reverse():K.slice(0,10).sort((e,t)=>t.localeCompare(e)),Z=t=>{const s=r.useOwner.getState().confirmEntries(t,n,m,e.toISOString());E(s?`${s} ${1===s?'entry':'entries'} confirmed`:null)};return(0,k.jsxs)(a.default,{style:{gap:10},testID:"signoff",children:[D.filter(e=>e.date!==v).length?(0,k.jsx)(o.default,{accessibilityRole:"button",onPress:()=>R(D.filter(e=>e.date!==v)[D.filter(e=>e.date!==v).length-1].date),children:(0,k.jsx)(l.Banner,{kind:"warn",title:`${D.filter(e=>e.date!==v).length} earlier ${1===D.filter(e=>e.date!==v).length?'day':'days'} still to sign off`,children:"Hours only count for pay once they\u2019re confirmed. Tap to open the oldest."})}):null,(0,k.jsx)(j.HoursDayPicker,{testID:"so-pick",date:v,today:t,custom:A,onDate:e=>{R(e),P(!0),E(null)},resetLabel:"Back to this week",onReset:()=>{R(t),P(!1),E(null)}}),(0,k.jsx)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:U.map(e=>{const n=D.find(t=>t.date===e);return(0,k.jsx)(l.Chip,{testID:`so-day-${e}`,accessibilityLabel:`${(0,b.longDay)(e)}${n?`, ${n.n} to sign off`:''}`,label:$(e,t),sub:n?`${n.n} to sign off`:void 0,selected:v===e,onPress:()=>{R(e),E(null)}},e)})}),(0,k.jsx)(l.Card,{children:(0,k.jsxs)(l.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{size:18,weight:"bold",testID:"so-day-title",children:[$(v,t),v===t||v===C(t,-1)?` \xb7 ${(0,u.niceDate)((0,u.parseYmd)(v))}`:'']}),(0,k.jsxs)(l.Muted,{children:[G.confirmed," confirmed \xb7 ",G.awaiting," awaiting \xb7 ",G.open," still clocked in",G.flagged?` \xb7 ${G.flagged} flagged`:'',G.off?` \xb7 ${G.off} on time off`:'']})]}),(0,k.jsxs)(a.default,{style:{alignItems:'flex-end'},children:[(0,k.jsx)(l.T,{size:18,weight:"bold",colour:c.colours.ok,children:(0,h.hmDur)(V.conf)}),(0,k.jsx)(l.Muted,{children:"confirmed"}),V.pend?(0,k.jsxs)(l.T,{size:13,colour:c.colours.amber,children:[(0,h.hmDur)(V.pend)," pending"]}):null]})]})}),F?(0,k.jsx)(l.Banner,{kind:"success",title:F}):null,L.length||Y.length?(0,k.jsx)(f.SectionHead,{title:"Correction requests",sub:"From the Staff app. Apply opens the times to check; declining keeps the times as clocked."}):null,[...L,...Y].map(t=>{const s=p.find(e=>e.id===t.staffId),o=t.attendanceId&&x.find(e=>e.id===t.attendanceId)||x.find(e=>e.staffId===t.staffId&&e.date===t.date&&e.in);return(0,k.jsxs)(l.Card,{highlight:c.colours.blue,children:[(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:30}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsxs)(l.T,{weight:"semibold",children:[I(s?.name)," \xb7 ",(0,u.niceDate)((0,u.parseYmd)(t.date))]}),(0,k.jsxs)(l.Muted,{children:['in'===t.kind?'Forgot to clock in':'out'===t.kind?'Forgot to clock out':'Forgot to clock in and out',t.suggestedIn?` \xb7 in ${(0,u.hm)(new Date(t.suggestedIn))}`:'',t.suggestedOut?` \xb7 out ${(0,u.hm)(new Date(t.suggestedOut))}`:'',t.note?` \xb7 \u201c${t.note}\u201d`:'']})]}),(0,k.jsx)(l.Badge,{kind:"blue",label:"Request"})]}),(0,k.jsxs)(l.Row,{gap:6,children:[(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Review & apply",onPress:()=>z({staffId:t.staffId,a:o,request:t})}),(0,k.jsx)(l.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>r.useOwner.getState().resolveTimeRequest(t.id,'declined',n,e.toISOString())})]})]},t.id)}),(0,k.jsx)(f.SectionHead,{title:"Hours",sub:"Rostered vs actual. Flagged rows need a look and are confirmed one by one."}),_.map(t=>{const n=p.find(e=>e.id===t.staffId),s=t.a,o=s?(0,h.paidMins)(s,e):null,f=s?(0,r.attStatus)(s):null,m=s?.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,k.jsx)(l.Card,{highlight:t.leave?c.colours.blue:'confirmed'===f?c.colours.ok:t.flags.length?c.colours.amber:void 0,children:(0,k.jsxs)(a.default,{testID:`so-row-${t.staffId}`,style:{gap:8},children:[(0,k.jsxs)(l.Row,{gap:10,children:[(0,k.jsx)(i.StaffAvatar,{id:t.staffId,size:36}),(0,k.jsxs)(a.default,{style:{flex:1},children:[(0,k.jsx)(l.T,{weight:"semibold",children:I(n?.name)}),(0,k.jsx)(l.Muted,{children:[n?.job,...O(s,n?.temp)].filter(Boolean).join(' \xb7 ')})]}),n?.temp||s?.temp?(0,k.jsx)(l.Badge,{kind:"gold",label:"Temp"}):null,s?(0,k.jsx)(l.Badge,{kind:B(s),label:T(s)}):t.leave?(0,k.jsx)(l.Badge,{kind:"blue",label:(0,d.leaveLabel)(t.leave)}):(0,k.jsx)(l.Badge,{kind:"red",label:"Missing"})]}),(0,k.jsx)(l.Row,{gap:0,style:{flexWrap:'wrap',rowGap:6},children:[['Rota',t.sh?`${(0,h.fmtH)(t.sh.start)}\u2013${(0,h.fmtH)(t.sh.end)}`:'\u2014'],['Actual',s?.in?`${(0,u.hm)(new Date(s.in))}\u2013${s.out?(0,u.hm)(new Date(s.out)):'on'}`:t.leave?(0,d.leaveLabel)(t.leave):'no clock-in'],['Break',s?.out?`${o.brk}m`:s?`${s.breakMins??0}m so far`:'\u2014'],['Paid',s?s.out?(0,h.hmDur)(o.paid):`${(0,h.hmDur)(o.worked)}\u2026`:'\u2014']].map(([e,t])=>(0,k.jsxs)(a.default,{style:{minWidth:92,flexGrow:1},children:[(0,k.jsx)(l.T,{size:11,colour:c.colours.muted,children:e.toUpperCase()}),(0,k.jsx)(l.T,{size:15,weight:"semibold",colour:'Paid'===e&&'confirmed'===f?c.colours.ok:c.colours.text,children:t})]},e))}),t.flags.length&&'confirmed'!==f?(0,k.jsx)(l.Row,{wrap:!0,gap:6,children:t.flags.map(e=>(0,k.jsx)(l.Badge,{kind:'noin'===e.key||'noout'===e.key?'red':'amber',label:e.label},e.key))}):null,t.leave?(0,k.jsxs)(l.Muted,{testID:`so-leave-${t.staffId}`,children:[(0,d.leaveNote)(t.leave),". Rota shift covered by leave: no hours counted."]}):null,m?(0,k.jsxs)(l.Muted,{children:["Adjusted by ",I(m.by),m.reason?`: ${m.reason}`:'']}):null,s?.signOff?(0,k.jsxs)(l.Muted,{children:["Confirmed by ",I(s.signOff.by)," \xb7 ",(0,u.niceDate)(new Date(s.signOff.at))," ",(0,u.hm)(new Date(s.signOff.at))]}):null,(0,k.jsxs)(l.Row,{gap:8,children:[(0,k.jsx)(l.Button,{small:!0,kind:"secondary",label:s?'Edit':'Add entry',accessibilityLabel:`${s?'Edit':'Add entry for'} ${I(n?.name)}`,onPress:()=>z({staffId:t.staffId,a:s})}),s&&'awaiting'===f?(0,k.jsx)(l.Button,{small:!0,kind:"success",label:"Confirm",accessibilityLabel:`Confirm ${I(n?.name)}`,onPress:()=>Z([s.id])}):null,s&&'open'===f?(0,k.jsx)(l.Muted,{style:{alignSelf:'center'},children:"Needs a clock-out before it can be confirmed"}):null]})]})},t.key)}),_.length?null:(0,k.jsx)(l.Card,{children:(0,k.jsx)(l.Muted,{children:"No clock records or rostered shifts for this day."})}),_.length?(0,k.jsx)(l.Button,{testID:"confirm-unflagged",kind:"success",label:W.length?`Confirm all unflagged (${W.length})`:'Nothing unflagged to confirm',disabled:!W.length,onPress:()=>Z(W.map(e=>e.a.id))}):null,(0,k.jsx)(l.Muted,{children:"Flags: no clock-out, 30 min or more off the rota, over 12 hours, no break on a shift over 6 hours, not on the rota, off-site, or a correction request. Editing a confirmed entry puts it back to Awaiting sign-off. Only confirmed hours count for pay, tips and exports."}),N?(0,k.jsx)(q,{a:N.a,staffId:N.staffId,date:N.request?.date??N.a?.date??v,request:N.request,onClose:()=>z(null)}):null]})}},1204,[827,1202,34,402,102,794,925,891,1098,858,821,1195,1088,1205,872,1206,1207,1209,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DELETE_SHIFT_TITLE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"DELETE_SHIFT_BODY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PAPER_HOURS_FROM",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"PAPER_HOURS_FROM_UK",{enumerable:!0,get:function(){return f}}),e.canSeeHoursEdit=function(t){return!!t.isCar||'owner'===t.role||'manager'===t.role},e.deleteBlockedReason=function(a,s,o){if(a.signOff)return"This shift has been signed off and can't be deleted.";const u=(0,n.paidOutFor)(a.date,s,o);return u?.throughDate?`Tips for this day have already been paid (through ${(0,t.slashDay)(u.throughDate)}), so this shift can't be deleted.`:null},e.spansOverlap=d,e.overlappingShifts=function(t,n,a,s,o){return t.filter(t=>t.staffId===n&&!t.voided&&t.in&&t.out&&t.id!==o&&d(t.in,t.out,a,s))},e.overlapWarning=function(n,a){if(!a.length)return null;const s=a.map(n=>`${(0,t.slashDay)(n.date)}, ${l(n.in)} to ${l(n.out)}`);return 1===a.length?`This overlaps ${n}'s existing shift on ${s[0]}.`:`This overlaps ${n}'s existing shifts on ${s.join('; ')}.`},e.pastShiftProblem=function(t){if(!t.staffId)return'Pick a staff member.';if(!t.date||!(0,a.validPastDate)(t.date,t.today))return`Enter a past date as DD/MM/YYYY, for example ${f}.`;if(t.outMins<=t.inMins)return'Finish must be after start.';const n=t.outMins-t.inMins;return n>1200?"A shift can't be longer than 20 hours.":t.breakMins<0?'Break minutes cannot be negative.':t.breakMins>=n?'The break is longer than the shift.':null};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);const s='Delete this shift?',o="This can't be used for pay.",u='2026-10-31',f='31/10/2026';function d(t,n,a,s){return t{if(!t)return'';const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1205,[1063,1085,1093]); +__d(function(g,r,i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DeleteShiftSheet=function({a:e,onClose:s,onDeleted:o}){const{rid:c,me:h,meId:p,now:m}=(0,x.useCtx)(3e4),y=(0,d.useCashUp)(e=>e.pot),S=(0,u.deleteBlockedReason)(e,y,c),[j,C]=(0,t.useState)(null);return(0,b.jsx)(n.Sheet,{visible:!0,onClose:s,title:S?"This shift can't be deleted":u.DELETE_SHIFT_TITLE,maxWidth:520,testID:"delete-shift-confirm",children:(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[S?(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-blocked",children:S}):(0,b.jsx)(n.T,{size:16,center:!0,testID:"delete-shift-body",children:u.DELETE_SHIFT_BODY}),j?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:j}):null,(0,b.jsx)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:S?(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",testID:"delete-shift-close",onPress:s,style:{minHeight:56,minWidth:120}}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"delete-shift-cancel",onPress:s,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{kind:"danger",label:"Delete",accessibilityLabel:"Delete",testID:"delete-shift-yes",onPress:()=>{const t=l.useOwner.getState().deleteEntry(e.id,h,p,m.toISOString());t&&!1!==t.ok?o():C(t?.message??"This shift can't be deleted.")},style:{minHeight:56,minWidth:120}})]})})]})})},_e.AddPastShiftSheet=function({onClose:e,onSaved:s}){const{today:d,me:C,meId:D,now:I,role:v}=(0,x.useCtx)(3e4),P=(0,u.canSeeHoursEdit)({role:v,isCar:p.IS_CAR}),w=(0,l.useOwner)(e=>e.staff),k=(0,t.useMemo)(()=>w.filter(e=>e.active).slice().sort((e,t)=>j(e.name).localeCompare(j(t.name))),[w]),T=(0,l.useOwner)(e=>e.attendance),_=(0,t.useMemo)(()=>(0,l.liveAttendance)(T),[T]),[E,M]=(0,t.useState)(void 0),[O,R]=(0,t.useState)((0,h.addDays)(d,-1)),[A,L]=(0,t.useState)((0,o.slashDay)((0,h.addDays)(d,-1))),[H,$]=(0,t.useState)(!1),[B,Y]=(0,t.useState)(720),[z,F]=(0,t.useState)(1200),[W,U]=(0,t.useState)(0),[K,N]=(0,t.useState)(''),[q,G]=(0,t.useState)(null),J=k.find(e=>e.id===E),Q=(()=>{const e=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(A);if(!e)return!1;const t=`${e[3]}-${e[2].padStart(2,'0')}-${e[1].padStart(2,'0')}`;return!!(0,c.validPastDate)(t,d)&&t})(),V=Q||O,X=(0,u.pastShiftProblem)({staffId:E,date:'string'==typeof Q?Q:(0,c.validPastDate)(O,d)?O:void 0,today:d,inMins:B,outMins:z,breakMins:W}),Z=(0,m.isoAt)(V,B),ee=(0,m.isoAt)(V,z),te=E&&!X?(0,u.overlappingShifts)(_,E,Z,ee):[],se=J?(0,u.overlapWarning)(j(J.name),te):null,ae=e=>{L(e);const t=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(t){const e=`${t[3]}-${t[2].padStart(2,'0')}-${t[1].padStart(2,'0')}`;((0,c.validPastDate)(e,d)||/^\d{4}-\d{2}-\d{2}$/.test(e))&&R(e)}},ie=e=>{R(e),L((0,o.slashDay)(e))};return P?(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsxs)(a.default,{style:{alignItems:'center',gap:12,width:'100%'},children:[(0,b.jsxs)(n.Muted,{center:!0,children:["Enter a closed shift from a paper printout, from ",u.PAPER_HOURS_FROM_UK," onwards. It is signed off and counts in the hours and pay."]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Staff member"}),(0,b.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:k.map(e=>(0,b.jsx)(n.Chip,{testID:`past-shift-staff-${e.id}`,label:j(e.name),selected:E===e.id,onPress:()=>M(e.id)},e.id))}),(0,b.jsx)(n.Field,{label:"Date (DD/MM/YYYY)",value:A,onChangeText:e=>ae((0,o.slashDate)(e,A)),placeholder:u.PAPER_HOURS_FROM_UK,keyboardType:"numbers-and-punctuation",maxLength:10,accessibilityLabel:"Shift date, day, month and four-digit year",autoCapitalize:"none",autoCorrect:!1,testID:"past-shift-date",style:{textAlign:'center'}}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Pick a date",testID:"past-shift-pick",accessibilityLabel:`Pick a date from a calendar. Now showing ${(0,o.slashDay)(V)}`,onPress:()=>$(!0),style:{alignSelf:'center'}}),(0,b.jsxs)(a.default,{style:{width:'100%',gap:12},children:[(0,b.jsx)(m.TimeEdit,{label:"Start",mins:B,onChange:Y,testID:"past-shift-start"}),(0,b.jsx)(m.TimeEdit,{label:"Finish",mins:z,onChange:F,testID:"past-shift-finish"})]}),(0,b.jsx)(n.T,{size:13,colour:f.colours.muted,center:!0,children:"Break minutes"}),(0,b.jsxs)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[S.map(e=>(0,b.jsx)(n.Chip,{label:0===e?'None':`${e} min`,selected:W===e,onPress:()=>U(e)},e)),(0,b.jsx)(n.Stepper,{value:W,min:0,max:240,onChange:U,label:"break minutes"})]}),(0,b.jsx)(n.Field,{label:"Note (optional)",value:K,onChangeText:N,placeholder:"e.g. from the paper hours",maxLength:200,accessibilityLabel:"Optional note",testID:"past-shift-note",style:{textAlign:'center'}}),se?(0,b.jsxs)(n.Banner,{kind:"warn",title:"This overlaps another shift",children:[se," You can still save if the paper hours are right."]}):null,X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:X}):null,q&&q!==X?(0,b.jsx)(n.T,{size:15,colour:f.colours.red,center:!0,children:q}):null,(0,b.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,b.jsx)(n.Button,{kind:"secondary",label:"Cancel",accessibilityLabel:"Cancel",testID:"past-shift-cancel",onPress:e,style:{minHeight:56,minWidth:120}}),(0,b.jsx)(n.Button,{label:"Save past shift",accessibilityLabel:"Save past shift",testID:"past-shift-save",disabled:!!X,onPress:()=>{if(!P)return void G('Ask a manager or owner.');if(X||!E||!Q)return void G(X??`Enter a past date as DD/MM/YYYY, for example ${u.PAPER_HOURS_FROM_UK}.`);if(!l.useOwner.getState().addPastShift({staffId:E,date:Q,in:Z,out:ee,breakMins:W,note:K.trim()||void 0,by:C,byId:D,now:I.toISOString()}))return void G("Couldn\u2019t save. Check the times and the date.");s()},style:{minHeight:56,minWidth:160}})]})]}),(0,b.jsx)(y.LookBackCalendar,{visible:H,today:d,selected:(0,c.validPastDate)(V,d)?V:(0,h.addDays)(d,-1),onClose:()=>$(!1),onPick:e=>{ie(e),$(!1)},purpose:"Add past shift",idPrefix:"past-shift"})]}):(0,b.jsxs)(n.Sheet,{visible:!0,onClose:e,title:"Add past shift",maxWidth:520,testID:"add-past-shift",children:[(0,b.jsx)(n.T,{size:16,center:!0,children:"Only a manager, an owner, or the Car can add a past shift."}),(0,b.jsx)(n.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close",onPress:e})]})},_e.useCanSeeHoursEdit=function(){const{role:e}=(0,x.useCtx)(3e4);return(0,t.useMemo)(()=>(0,u.canSeeHoursEdit)({role:e,isCar:p.IS_CAR}),[e])};var e,t=r(_d[0]),s=r(_d[1]),a=(e=s)&&e.__esModule?e:{default:e},n=r(_d[2]),l=r(_d[3]),d=r(_d[4]),o=r(_d[5]),c=r(_d[6]),h=r(_d[7]),u=r(_d[8]),f=r(_d[9]),p=r(_d[10]),m=r(_d[11]),y=r(_d[12]),x=r(_d[13]),b=r(_d[14]);const S=[0,15,20,30,45,60],j=e=>(e??'').replace(' (example)','')},1206,[34,102,794,891,1039,1063,1093,1087,1205,821,872,1204,1086,1088,25]); +__d(function(g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"longDay",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chipDay",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"weekHolding",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"weekDays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"pastWeekDays",{enumerable:!0,get:function(){return d}}),e.stepWeek=function(n,u,o){const s=(0,t.plusDays)(n,7*u);return s>o?o:s},Object.defineProperty(e,"canNextWeek",{enumerable:!0,get:function(){return f}}),e.pickDay=function(t,u){if(!t.trim())return{day:null,problem:null};const o=(0,n.parseDmy)(t);return o?o>u?{day:null,problem:'That date is in the future. Pick today or an earlier day.'}:{day:o,problem:null}:{day:null,problem:t.replace(/\D/g,'').length>=8?'That date does not exist. Use DD/MM/YYYY, for example 04/11/2026.':null}},e.rangeSpeech=function(t,u){const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Showing ${c(t)}${t===u?', today':''}. Week ${c(o.start)} to ${c(s)}.`},Object.defineProperty(e,"weekTitle",{enumerable:!0,get:function(){return p}}),e.setHoursPreset=function(t,n){b={start:t,end:n,from:'rota'}},e.takeHoursPreset=function(){const t=b;return b=null,t},Object.defineProperty(e,"timeSheetLabel",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"presetNote",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=r(_d[1]);const u=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],o=['January','February','March','April','May','June','July','August','September','October','November','December'],s=t=>{const[n,u,o]=t.split('-').map(Number);return new Date(n,u-1,o,12)},c=t=>{const n=s(t);return`${u[n.getDay()]} ${n.getDate()} ${o[n.getMonth()]} ${n.getFullYear()}`},l=t=>{const n=s(t);return`${u[n.getDay()].slice(0,3)} ${n.getDate()} ${o[n.getMonth()].slice(0,3)}`},i=t=>(0,n.weekOf)(t),y=u=>{const o=(0,n.weekOf)(u);return Array.from({length:7},(n,u)=>(0,t.plusDays)(o.start,u))},d=(t,n)=>y(t).filter(t=>t<=n);const f=(t,u)=>(0,n.weekOf)(t).start<(0,n.weekOf)(u).start;const p=(t,u)=>{const o=(0,n.weekOf)(t),s=o.end>u?u:o.end;return`Week ${l(o.start)} to ${l(s)}`};let b=null;const m=(t,n)=>`Time sheet: export hours as text or a spreadsheet for the rota week ${c(t)} to ${c(n)}`,k=(n,u)=>`Set to the rota week ${(0,t.ukDate)(n)} to ${(0,t.ukDate)(u)}. You can change the dates.`},1207,[1064,1208]); +__d(function(_g,r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ymd",{enumerable:!0,get:function(){return u}}),e.weekOf=function(s,n=0){const o=(i(s).getDay()+6)%7,u=(0,t.plusDays)(s,7*n-o);return{start:u,end:(0,t.plusDays)(u,6)}},e.parseDmy=function(t){const s=t.trim().match(/^(\d{1,2})\D+(\d{1,2})\D+(\d{4})$/)??t.trim().match(/^(\d{2})(\d{2})(\d{4})$/);if(!s)return null;const n=Number(s[1]),o=Number(s[2]),i=Number(s[3]),d=new Date(i,o-1,n);return d.getFullYear()===i&&d.getMonth()===o-1&&d.getDate()===n&&i>=2020&&i<=2100?u(d):null},Object.defineProperty(e,"MAX_DAYS",{enumerable:!0,get:function(){return d}}),e.rangeProblem=function(s,n){return s?n?nt.shifts),y=h($,g),D=[`${n}: staff hours ${o[i(u).getDay()]} ${(0,t.ukDate)(u)} to ${o[i(d).getDay()]} ${(0,t.ukDate)(d)}`,''];let b=0,P=0;for(const n of p){if(!n.shifts.length)continue;D.push(`${n.name}${n.role?` (${n.role})`:''}`);let o=0;for(const i of n.shifts){const n=m(i)?`paid ${(0,s.durText)(i.paid)} (${(0,t.decH)(i.paid)} hours)`:'still on shift, not counted yet';D.push(` ${c(i.date)}: in ${i.inT||'not clocked'}, out ${i.outT||'not yet'}, ${l(i.brk)}, ${n}${'Pending'===i.status?', waiting for sign-off':''}${y.has(i.id)?', POSSIBLE DUPLICATE: overlaps another shift':''}`),m(i)&&(o+=i.paid,P++)}b+=o,D.push(` Total for ${n.name}: ${(0,s.durText)(o)} (${(0,t.decH)(o)} hours, ${f(o)}), ${n.shifts.filter(m).length} ${1===n.shifts.filter(m).length?'shift':'shifts'}`,'')}P||$.length||D.push('No shifts in these dates.','');D.push(`Grand total: ${(0,s.durText)(b)} (${(0,t.decH)(b)} hours), ${P} ${1===P?'shift':'shifts'}`),y.size&&D.push(`${y.size} shifts overlap another shift for the same person: check them before paying.`);return D.push('Removed shifts are not included. Pending shifts are waiting for sign-off.'),D.join('\n')},e.hoursSheets=function(s,o,u,d,f=new Date){const l=h(d.flatMap(t=>t.shifts),f),c=['Person','Role','Date','Day','In','Out','Break (minutes)','Paid hours (decimal)','Paid hours (h:mm)','Status','Check'],p=[c],g=[c.map(()=>1)];for(const s of d)for(const o of s.shifts){const u=l.has(o.id),d=m(o);p.push([s.name,s.role,(0,t.ukDate)(o.date),n[i(o.date).getDay()],o.inT,o.outT||'',d?o.brk:'',d?Number((0,t.decH)(o.paid)):'',d?(0,t.hMm)(o.paid):'',o.status,u?'Possible duplicate':'']),g.push(u?c.map(()=>2):c.map(()=>{}))}const $=['Person','Role','Shifts','Paid hours (decimal)','Paid hours (h:mm)','Pending hours (decimal)','Possible duplicates'],y=[[`${s}: staff hours ${(0,t.ukDate)(o)} to ${(0,t.ukDate)(u)}`],$],D=[[3],$.map(()=>1)];let b=0,P=0,T=0,w=0;for(const s of d){if(!s.shifts.length)continue;const n=s.shifts.filter(m),o=n.reduce((t,s)=>t+s.paid,0),i=n.filter(t=>'Pending'===t.status).reduce((t,s)=>t+s.paid,0),u=s.shifts.filter(t=>l.has(t.id)).length;y.push([s.name,s.role,n.length,Number((0,t.decH)(o)),(0,t.hMm)(o),Number((0,t.decH)(i)),u||'']),D.push(u?$.map(()=>2):$.map(()=>{})),b+=o,P+=i,T+=n.length,w+=u}return y.push(['Grand total','',T,Number((0,t.decH)(b)),(0,t.hMm)(b),Number((0,t.decH)(P)),w||'']),D.push($.map(()=>3)),y.push([]),y.push(['Removed shifts are not included. Paid hours include pending shifts (waiting for sign-off), shown separately.']),[{name:'Shifts',rows:p,styles:g,widths:[18,22,12,6,8,8,14,18,16,12,18]},{name:'Totals',rows:y,styles:D,widths:[22,22,8,18,16,20,18]}]};var t=r(_d[0]),s=r(_d[1]);const n=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],o=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],i=t=>{const[s,n,o]=t.split('-').map(Number);return new Date(s,n-1,o)},u=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`;const d=366;function h(t,s=new Date){const n=new Set,o=t=>t?new Date(t).getTime():NaN,i=new Map;for(const s of t){if(!s.inIso)continue;const t=s.name;i.set(t,[...i.get(t)??[],s])}for(const t of i.values()){const i=t.map(t=>({id:t.id,a:o(t.inIso),b:t.outIso?o(t.outIso):s.getTime()})).filter(t=>Number.isFinite(t.a)).sort((t,s)=>t.a-s.a);for(let t=0;t`${Math.floor(t/60)} hours ${String(Math.round(t)%60).padStart(2,'0')} minutes`,l=t=>t?`${t} minute break`:'no break',c=s=>`${n[i(s).getDay()]} ${(0,t.ukDate)(s)}`,m=t=>'On now'!==t.status},1208,[1064,1202]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HoursDayPicker=function({date:e,today:l,onDate:x,testID:p,resetLabel:k,onReset:D,custom:j}){const[f,I]=(0,t.useState)(''),[w,v]=(0,t.useState)(!1),[C,P]=(0,t.useState)(null),W=e=>{P(null),x(e),(0,u.announce)((0,d.rangeSpeech)(e,l))},L=(0,d.canNextWeek)(e,l);return(0,y.jsxs)(s.default,{testID:p,style:{alignSelf:'center',width:'100%',maxWidth:560,gap:8,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.border,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,y.jsx)(n.T,{weight:"bold",size:17,center:!0,accessibilityRole:"header",children:"Pick a day"}),(0,y.jsxs)(n.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-prev`,label:"\u2039 Previous week",accessibilityLabel:"Previous week",onPress:()=>W((0,d.stepWeek)(e,-1,l)),style:{minHeight:48,minWidth:140}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-next`,label:"Next week \u203a",accessibilityLabel:L?'Next week':'Next week, not available: this is the current week',disabled:!L,onPress:()=>W((0,d.stepWeek)(e,1,l)),style:{minHeight:48,minWidth:140}})]}),(0,y.jsx)(n.T,{size:15,weight:"semibold",center:!0,children:"Go to date (DD/MM/YYYY)"}),(0,y.jsx)(o.TextInput,{testID:`${p}-date`,accessibilityLabel:"Go to date, day month year",value:f,onChangeText:e=>{const t=(0,r.slashDate)(e,f);I(t);const s=(0,d.pickDay)(t,l);P(s.problem),s.problem&&(0,u.announce)(s.problem),s.day&&W(s.day)},placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,width:'100%',maxWidth:200,borderWidth:1,borderColor:C?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,y.jsx)(n.Button,{small:!0,kind:"secondary",testID:`${p}-cal`,label:w?'Close calendar':'Calendar',accessibilityLabel:(w?'Close':'Open')+" the calendar to pick a day",onPress:()=>v(!w),style:{minHeight:44,minWidth:160,alignSelf:'center'}}),w?(0,y.jsx)(b.MonthCalendar,{testID:`${p}-calendar`,label:"Go to",value:e,onPick:e=>{if(v(!1),e>l){const e='That date is in the future. Pick today or an earlier day.';return P(e),void(0,u.announce)(e)}I((0,c.ukDate)(e)),W(e)}}):null,C?(0,y.jsx)(s.default,{accessibilityLiveRegion:"polite",children:(0,y.jsx)(n.T,{testID:`${p}-problem`,size:15,center:!0,colour:h.colours.red,children:C})}):null,(0,y.jsx)(s.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:`${p}-range`,style:{alignItems:'center'},children:(0,y.jsx)(n.T,{size:15,center:!0,colour:h.colours.goldLight,children:(0,d.rangeSpeech)(e,l)})}),j?(0,y.jsx)(n.Button,{small:!0,kind:"ghost",testID:`${p}-reset`,label:k,onPress:()=>{I(''),P(null),D(),(0,u.announce)(k)},style:{minHeight:44}}):null]})};var e,t=_r(_d[0]),l=_r(_d[1]),s=(e=l)&&e.__esModule?e:{default:e},n=_r(_d[2]),o=_r(_d[3]),r=_r(_d[4]),c=_r(_d[5]),d=_r(_d[6]),u=_r(_d[7]),h=_r(_d[8]),b=_r(_d[9]),y=_r(_d[10])},1209,[34,102,794,827,1063,1064,1207,1125,821,1210,25]); +__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.MonthCalendar=$,_e.HoursExport=function(){const{role:e}=(0,b.useCtx)(6e4);return a.CAN.manage(e)?(0,p.jsx)(k,{}):null};var t=_r(_d[0]),s=_r(_d[1]),l=e(_r(_d[2])),r=e(_r(_d[3])),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),i=_r(_d[7]),c=_r(_d[8]),d=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),x=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),p=_r(_d[17]);const j=e=>(0,c.ukDate)(e),D=['January','February','March','April','May','June','July','August','September','October','November','December'],w=['Mo','Tu','We','Th','Fr','Sa','Su'];function $({value:e,onPick:t,testID:n,label:a}){const c=e??(0,i.ymd)(new Date),[d,u]=(0,s.useState)({y:Number(c.slice(0,4)),m:Number(c.slice(5,7))-1}),x=(new Date(d.y,d.m,1).getDay()+6)%7,b=new Date(d.y,d.m+1,0).getDate(),f=[...Array(x).fill(null),...Array.from({length:b},(e,t)=>t+1)];for(;f.length%7;)f.push(null);const m=e=>u(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}});return(0,p.jsxs)(r.default,{testID:n,style:{alignSelf:'center',width:'100%',maxWidth:360,borderWidth:1,borderColor:h.colours.border,borderRadius:14,padding:8,gap:4,backgroundColor:h.colours.surface2},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",onPress:()=>m(-1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u2039"})}),(0,p.jsx)(o.T,{weight:"semibold",center:!0,children:`${D[d.m]} ${d.y}`}),(0,p.jsx)(l.default,{accessibilityRole:"button",accessibilityLabel:"Next month",onPress:()=>m(1),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,p.jsx)(o.T,{size:22,colour:h.colours.gold,children:"\u203a"})})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row'},children:w.map(e=>(0,p.jsx)(o.T,{size:12,colour:h.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:f.length/7},(s,c)=>(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:2},children:f.slice(7*c,7*c+7).map((s,c)=>{if(!s)return(0,p.jsx)(r.default,{style:{flex:1,height:40}},c);const u=(0,i.ymd)(new Date(d.y,d.m,s)),x=u===e;return(0,p.jsx)(l.default,{testID:`${n}-${u}`,accessibilityRole:"button",accessibilityLabel:`${a} ${s} ${D[d.m]} ${d.y}`,accessibilityState:{selected:x},onPress:()=>t(u),style:{flex:1,height:40,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:x?h.colours.gold:'transparent'},children:(0,p.jsx)(o.T,{size:15,weight:x?'bold':'regular',colour:x?h.colours.onGold:h.colours.text,children:s})},c)})},c))]})}function T({label:e,text:l,setText:a,testID:d}){const[x,b]=(0,s.useState)(!1),f=(0,i.parseDmy)(l);return(0,p.jsxs)(r.default,{style:{gap:6,alignItems:'center',flexBasis:150,flexGrow:1,minWidth:0},children:[(0,p.jsxs)(o.T,{size:15,weight:"semibold",center:!0,children:[e," (DD/MM/YYYY)"]}),(0,p.jsx)(n.TextInput,{testID:d,accessibilityLabel:`${e} date, day month year`,value:l,onChangeText:e=>a((0,t.slashDate)(e,l)),placeholder:"DD/MM/YYYY",placeholderTextColor:"#7D776C",keyboardType:"number-pad",maxLength:10,style:{minHeight:48,minWidth:0,width:'100%',maxWidth:200,borderWidth:1,borderColor:l&&!f?h.colours.red:h.colours.border,borderRadius:12,color:h.colours.text,fontSize:18,textAlign:'center',paddingHorizontal:8}}),(0,p.jsx)(o.Button,{small:!0,kind:"secondary",testID:`${d}-cal`,label:x?'Close calendar':'Calendar',accessibilityLabel:`${x?'Close':'Open'} the calendar for the ${e} date`,onPress:()=>b(!x)}),x?(0,p.jsx)($,{testID:`${d}-calendar`,label:e,value:f,onPick:t=>{a(j(t)),b(!1),(0,u.announce)(`${e} ${(0,c.ukDate)(t)}`)}}):null]})}function k(){const{rid:e,today:t,now:l,r:n}=(0,b.useCtx)(6e4),{pay:D}=(0,y.useVenuePay)(e),w=(0,a.useOwner)(e=>e.staff),$=(0,a.useOwner)(e=>(0,a.liveAttendance)(e.attendance)),k=(0,b.useHourly)(),I=(0,i.weekOf)(t),[C]=(0,s.useState)(()=>(0,m.takeHoursPreset)()),[L,P]=(0,s.useState)(j(C?.start??I.start)),[R,M]=(0,s.useState)(j(C?.end??I.end));(0,s.useEffect)(()=>{if(!C)return;(0,u.announce)((0,m.presetNote)(C.start,C.end));const e=setTimeout(()=>{try{globalThis.document?.querySelector?.('[data-testid="hours-export"]')?.scrollIntoView?.({block:'start'})}catch{}},300);return()=>clearTimeout(e)},[C]);const[S,v]=(0,s.useState)(null),z=(0,i.parseDmy)(L),E=(0,i.parseDmy)(R),W=(0,i.rangeProblem)(z,E),O=(0,c.wagePeriod)(D,t),H=[{id:'this',label:'This week',...I},{id:'last',label:'Last week',...(0,i.weekOf)(t,-1)},{id:'pay',label:'This pay period',start:O.start,end:O.end}],A=(0,s.useMemo)(()=>{if(W||!z||!E)return[];const e=e=>e.name.replace(' (example)',''),t=e=>`${a.ROLE_LABEL[e.role]}${e.job?` \xb7 ${e.job}`:''}`;return(0,x.hoursIn)({start:z,end:E},w,$,l,k).filter(e=>e.days.length).map(s=>({name:e(s.person),role:t(s.person),shifts:s.days.map(l=>({id:l.a.id,name:e(s.person),role:t(s.person),date:l.date,inIso:l.a.in,outIso:l.a.out,inT:l.inT,outT:l.outT,brk:l.brk,paid:l.paid,status:l.status}))}))},[z,E,W,w,$,k,Math.floor(l.getTime()/6e4)]),Y=A.flatMap(e=>e.shifts),_=(0,i.overlapIds)(Y,l).size,N=Y.filter(e=>'On now'!==e.status).reduce((e,t)=>e+t.paid,0),B=(e,t=!1)=>{v({t:e,bad:t}),(0,u.announce)(e)};return(0,p.jsxs)(r.default,{testID:"hours-export",style:{alignSelf:'center',width:'100%',maxWidth:560,gap:10,padding:12,borderRadius:16,borderWidth:1,borderColor:h.colours.gold,backgroundColor:h.colours.surface,alignItems:'center'},children:[(0,p.jsx)(o.T,{weight:"bold",size:18,center:!0,accessibilityRole:"header",children:"Export hours"}),(0,p.jsx)(o.Muted,{center:!0,children:"Pick the dates, then copy the hours as text or download an Excel file."}),C?(0,p.jsx)(r.default,{accessible:!0,accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-from-rota",size:15,center:!0,colour:h.colours.goldLight,children:(0,m.presetNote)(C.start,C.end)})}):null,(0,p.jsx)(o.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:H.map(e=>(0,p.jsx)(o.Chip,{testID:`hx-preset-${e.id}`,label:e.label,selected:z===e.start&&E===e.end,onPress:()=>{P(j(e.start)),M(j(e.end)),v(null),(0,u.announce)(`${e.label}: ${(0,c.ukDate)(e.start)} to ${(0,c.ukDate)(e.end)}`)}},e.id))}),(0,p.jsxs)(o.Row,{wrap:!0,gap:10,style:{justifyContent:'center',alignSelf:'stretch'},children:[(0,p.jsx)(T,{label:"From",text:L,setText:e=>{P(e),v(null)},testID:"hx-from"}),(0,p.jsx)(T,{label:"To",text:R,setText:e=>{M(e),v(null)},testID:"hx-to"})]}),W?(0,p.jsx)(o.T,{testID:"hx-problem",size:15,center:!0,colour:h.colours.red,children:W}):(0,p.jsxs)(r.default,{accessible:!0,testID:"hx-summary",style:{alignItems:'center',gap:2},children:[(0,p.jsx)(o.T,{size:16,center:!0,weight:"semibold",children:`${A.length} ${1===A.length?'person':'people'} \xb7 ${Y.length} ${1===Y.length?'shift':'shifts'} \xb7 ${(0,f.durText)(N)} paid (${(0,c.decH)(N)} hours)`}),_?(0,p.jsx)(o.T,{testID:"hx-dups",size:15,center:!0,weight:"semibold",colour:h.colours.red,children:`${_} shifts overlap another shift for the same person: marked Possible duplicate. Check them before paying.`}):null]}),(0,p.jsxs)(o.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Button,{testID:"hx-copy",label:"Copy as text",accessibilityLabel:"Copy the hours as text",disabled:!!W,onPress:async()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);const e=await(0,x.copyText)((0,i.hoursText)(n.name,z,E,A,l));B(e?`Copied hours for ${A.length} ${1===A.length?'person':'people'}, ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}. Paste it into a message, email or document.`:'Copy is not available here. Use Download Excel.',!e)},style:{minHeight:48,minWidth:150}}),(0,p.jsx)(o.Button,{testID:"hx-excel",kind:"secondary",label:"Download Excel",accessibilityLabel:"Download the hours as an Excel file",disabled:!!W,onPress:()=>{if(W||!z||!E)return B(W??'Pick the dates first.',!0);try{const e=(0,d.buildXlsx)((0,i.hoursSheets)(n.name,z,E,A,l));if('undefined'==typeof document)return B('Download is not available here.',!0);const t=new Blob([e],{type:d.XLSX_MIME}),s=document.createElement('a');s.href=URL.createObjectURL(t),s.download=`staff-hours-${z}-to-${E}.xlsx`,document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(s.href),s.remove()},1500),B(`Excel file downloaded: ${Y.length} ${1===Y.length?'shift':'shifts'}, ${(0,c.ukDate)(z)} to ${(0,c.ukDate)(E)}.`)}catch{B('The Excel file could not be made. Try Copy as text.',!0)}},style:{minHeight:48,minWidth:150}})]}),S?(0,p.jsx)(r.default,{accessibilityLiveRegion:"polite",children:(0,p.jsx)(o.T,{testID:"hx-msg",size:15,center:!0,colour:S.bad?h.colours.red:h.colours.goldLight,children:S.t})}):null,(0,p.jsx)(o.Muted,{center:!0,size:13,children:"Removed shifts are not included. Shifts waiting for sign-off are included and marked Pending."})]})}},1210,[1063,34,402,102,794,827,891,1208,1064,1211,1125,821,1199,1088,1202,1207,1065,25]); +__d(function(g,_r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.crc32=n,e.xlsxParts=m,e.zipStored=p,e.buildXlsx=function(t){return p(m(t).map(([t,n])=>[t,o(n)]))},Object.defineProperty(e,"XLSX_MIME",{enumerable:!0,get:function(){return c}});const t=(()=>{const t=new Uint32Array(256);for(let n=0;n<256;n++){let o=n;for(let t=0;t<8;t++)o=1&o?3988292384^o>>>1:o>>>1;t[n]=o>>>0}return t})();function n(n){let o=4294967295;for(let l=0;l>>8;return(4294967295^o)>>>0}const o=t=>(new TextEncoder).encode(t),l=t=>t.replace(/[&<>"]/g,t=>({'&':'&','<':'<','>':'>','"':'"'}[t])).replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,''),s=t=>{let n='';for(t+=1;t>0;){const o=(t-1)%26;n=String.fromCharCode(65+o)+n,t=Math.floor((t-1)/26)}return n},r=t=>(t.replace(/[\\/?*[\]:]/g,' ').trim()||'Sheet').slice(0,31);const i="";function m(t){const n=t.length;return[['[Content_Types].xml',`${t.map((t,n)=>``).join('')}`],['_rels/.rels',""],['xl/workbook.xml',`${t.map((t,n)=>``).join('')}`],['xl/_rels/workbook.xml.rels',`${t.map((t,n)=>``).join('')}`],['xl/styles.xml',i],...t.map((t,n)=>{return[`xl/worksheets/sheet${n+1}.xml`,(o=t,`${o.widths?.length?`${o.widths.map((t,n)=>``).join('')}`:''}${o.rows.map((t,n)=>`${t.map((t,r)=>{if(null==t||''===t)return'';const i=`${s(r)}${n+1}`,m=o.styles?.[n]?.[r],p=m?` s="${m}"`:'';return'number'==typeof t&&Number.isFinite(t)?`${t}`:`${l(String(t))}`}).join('')}`).join('')}`)];var o})]}function p(t){const l=[],s=[];let r=0;const i=t=>[255&t,t>>>8&255],m=t=>[255&t,t>>>8&255,t>>>16&255,t>>>24&255];for(const[p,c]of t){const t=o(p),f=n(c),h=new Uint8Array([...m(67324752),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0)]);l.push(h,t,c),s.push(new Uint8Array([...m(33639248),...i(20),...i(20),...i(2048),...i(0),...i(0),...i(33),...m(f),...m(c.length),...m(c.length),...i(t.length),...i(0),...i(0),...i(0),...i(0),...m(0),...m(r)]),t),r+=h.length+t.length+c.length}const p=s.reduce((t,n)=>t+n.length,0),c=new Uint8Array([...m(101010256),...i(0),...i(0),...i(t.length),...i(t.length),...m(p),...m(r),...i(0)]),f=[...l,...s,c],h=new Uint8Array(f.reduce((t,n)=>t+n.length,0));let x=0;for(const t of f)h.set(t,x),x+=t.length;return h}const c='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'},1211,[]); +__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 O}}),_e.allocate=D,_e.Tips=function({go:e}={}){const n=(0,a.default)().width<600,{rid:C,now:S,today:v,role:P,meId:B,me:F}=(0,x.useCtx)(6e4),R=(0,u.useOwner)(e=>e.staff),N=(0,u.useOwner)(e=>(0,u.liveAttendance)(e.attendance)),A=(0,u.useOwner)(e=>e.shifts),L=(0,u.useOwner)(e=>e.tronc),z=(0,u.useOwner)(e=>e.troncCash),_=(0,u.useOwner)(e=>e.troncHistory),V=(0,u.useOwner)(e=>e.troncLog),U=(0,c.useOrders)(C),q=(0,j.useVenuePay)(C).pay,[H,W]=(0,i.useState)(-1),[Y,K]=(0,i.useState)(''),[G,Q]=(0,i.useState)(!1),[J,X]=(0,i.useState)(!1),[Z,ee]=(0,i.useState)(L.text),[te,se]=(0,i.useState)(null),oe='staff'!==P,ie='owner'===P,{s:ne,e:re,key:le}=(0,j.venueRange)(q,'tips',H,S),ae=`${(0,h.niceDate)(ne)} \u2013 ${(0,h.niceDate)(re)} ${re.getFullYear()}`,de=_.find(e=>e.key===le),ce=e=>u.useOwner.getState().setOwner({tronc:{...L,...e}}),ue=(0,w.useSync)(e=>!!e.venueId&&'guest'!==e.kind),pe=Math.round((re.getTime()-ne.getTime())/864e5)+1,he=(0,i.useMemo)(()=>{let e=U.filter(e=>e.createdAt.slice(0,10)>=(0,h.ymd)(ne)&&e.createdAt.slice(0,10)<=(0,h.ymd)(re)).reduce((e,t)=>e+(t.tip??0),0);if(!o.LIVE_VENUE_BUILD&&!ue)for(let t=0;tS)break;const o=(0,x.weekday)(s);0!==o&&1!==o&&(e+=Math.round(6e3+9e3*(0,b.hash)((0,h.ymd)(s)+'tip')))}return e},[le,U.length,ue]),me=(0,T.useCashUp)(e=>e.cashUps),fe=Math.round(100*(0,k.cashUpTipsBetween)(me,C,(0,h.ymd)(ne),(0,h.ymd)(re))),ye=z[le]??0,ge=de?de.pot:he+fe+ye,xe=(0,i.useMemo)(()=>{const e={};for(let t=0;tv)break;const o=(0,h.ymd)(s);R.forEach(t=>{const s=N.filter(e=>e.staffId===t.id&&e.date===o&&e.out),i=s.filter(u.isConfirmed).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0),n=s.filter(e=>!(0,u.isConfirmed)(e)).reduce((e,t)=>e+(0,x.paidMins)(t,S).paid,0);(i||n)&&(e[t.id]={paid:(e[t.id]?.paid??0)+i,est:(e[t.id]?.est??!1)||n>0})})}return e},[le,N.length,A.length,R.length]),je=R.filter(e=>e.active&&('staff'===e.role||'manager'===e.role&&L.includeManagers||'owner'===e.role&&L.includeOwner)),be=(0,i.useMemo)(()=>{if(de)return de.rows;const e=je.map(e=>{const t=(xe[e.id]?.paid??0)/60,s=L.points[O(e)]??1;return'hours'===L.method?t:'points'===L.method?t*s:'equal'===L.method?t>0?1:0:L.custom[e.id]??0}),{amounts:t}=D(ge,e),s=e.reduce((e,t)=>e+t,0);return je.map((o,i)=>({staffId:o.id,hours:(xe[o.id]?.paid??0)/60,points:L.points[O(o)]??1,pct:s?e[i]/s*100:0,amount:t[i]}))},[de,je.map(e=>e.id).join(),xe,L,ge]),we=be.reduce((e,t)=>e+t.amount,0),Te=de?0:(()=>{const e=be.map(e=>e.pct);return D(ge,e).remainder})(),Ce=Object.entries(L.custom).filter(([e])=>je.some(t=>t.id===e)).reduce((e,[,t])=>e+t,0),Se='custom'===L.method&&Math.abs(Ce-100)>.01,ke=new Date(re.getFullYear(),re.getMonth()+2,0),ve=[..._].sort((e,t)=>t.end.localeCompare(e.end))[0],Pe=0!==_.length&&(0,h.parseYmd)(ve.end)<(0,h.addMins)(S,-89280),Me=['Staff,Category,Paid hours,Points,Share %,Amount \xa3'].concat(be.map(e=>{const t=R.find(t=>t.id===e.staffId);return`${I(t.name)},${O(t)},${e.hours.toFixed(2)},${e.points},${e.pct.toFixed(2)},${(e.amount/100).toFixed(2)}`}),[`TOTAL,,,,100.00,${(we/100).toFixed(2)}`]);return oe?(0,M.jsxs)(l.default,{style:{gap:10},children:[(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Quick split: Tips day"}),(0,M.jsx)(d.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,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"success",label:"Open Tips day",onPress:()=>e?.('more','tipsday')}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Pay & tips settings",onPress:()=>e?.('more','paysettings')})]})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"\u2039 Earlier",onPress:()=>W(H-1)}),(0,M.jsxs)(l.default,{style:{alignItems:'center',flex:1},children:[(0,M.jsx)(d.T,{weight:"semibold",children:ae}),de?(0,M.jsx)(d.Badge,{kind:"ok",label:`Approved & locked ${de.lockedAt}`}):H>=0?(0,M.jsx)(d.Badge,{kind:"amber",label:"Period in progress"}):(0,M.jsx)(d.Badge,{kind:"neutral",label:"Not yet approved"})]}),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"Later \u203a",disabled:H>=0,onPress:()=>W(H+1)})]}),(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Tip pot"}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Card tips on orders"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.card:he)})]}),(0,M.jsx)(l.default,{testID:"tronc-cashup-tips",children:(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Tips from cash ups (cash + card)"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cashUps??0:fe)})]})}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:"Other cash tips"}),(0,M.jsx)(d.T,{children:(0,p.gbp)(de?de.cash:ye)})]}),de?null:(0,M.jsxs)(d.Row,{gap:6,children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Other cash tips not in a cash up, pounds",placeholder:"Other cash tips \xa3",placeholderTextColor:"#7D776C",keyboardType:"decimal-pad",value:Y,onChangeText:K,style:[d.styles.input,{flex:1}]}),(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Set cash",disabled:!(Number(Y)>=0)||''===Y.trim(),onPress:()=>{u.useOwner.getState().setOwner({troncCash:{...z,[le]:Math.round(100*Number(Y))}}),K('')}})]}),(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"bold",children:"Total pot"}),(0,M.jsx)(d.T,{size:20,weight:"bold",colour:m.colours.gold,children:(0,p.gbp)(ge)})]}),(0,M.jsx)(d.Muted,{children:ue?'Card tips on orders are taken in CoverCharge. Tips from cash ups come from each day\u2019s cash up, including days added later. Only add other cash tips that are not in a cash up.':'Card tips are the tips on orders saved on this device (not connected to your venue yet).'})]}),de?(0,M.jsxs)(d.Muted,{children:["Locked with method: ",$[de.method],"."]}):(0,M.jsxs)(d.Card,{children:[(0,M.jsx)(d.T,{weight:"semibold",children:"Split method (venue policy)"}),(0,M.jsx)(d.Row,{wrap:!0,gap:6,children:Object.keys($).map(e=>(0,M.jsx)(d.Chip,{label:$[e],selected:L.method===e,onPress:()=>ie&&ce({method:e})},e))}),ie?null:(0,M.jsx)(d.Muted,{children:"Only the owner can change the policy."}),'points'===L.method?Object.entries(L.points).map(([e,t])=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{children:e}),(0,M.jsx)(d.Row,{gap:6,children:(0,M.jsx)(d.Stepper,{value:t,step:.1,min:0,max:2,onChange:t=>ie&&ce({points:{...L.points,[e]:Math.round(10*t)/10}}),format:e=>e.toFixed(1),label:`${e} points`})})]},e)):null,'custom'===L.method?(0,M.jsxs)(M.Fragment,{children:[je.map(e=>(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{style:{flex:1},children:I(e.name)}),(0,M.jsx)(s.TextInput,{accessibilityLabel:`${e.name} percent`,keyboardType:"decimal-pad",defaultValue:String(L.custom[e.id]??''),placeholder:"%",placeholderTextColor:"#7D776C",onEndEditing:t=>ce({custom:{...L.custom,[e.id]:Number(t.nativeEvent.text)||0}}),onBlur:t=>{const s=Number(t?.target?.value??t?.nativeEvent?.text);Number.isFinite(s)&&ce({custom:{...u.useOwner.getState().tronc.custom,[e.id]:s}})},style:[d.styles.input,{width:80,paddingVertical:4}]})]},e.id)),(0,M.jsxs)(d.T,{size:13,colour:Se?m.colours.red:m.colours.ok,children:["Total ",Ce.toFixed(1),"%",Se?' (must be 100%)':' \u2713']})]}):null,(0,M.jsx)(d.Toggle,{label:"Include managers",value:L.includeManagers,onChange:e=>ie&&ce({includeManagers:e})}),(0,M.jsx)(d.Toggle,{label:"Include owner",value:L.includeOwner,onChange:e=>ie&&ce({includeOwner:e})}),L.includeOwner?(0,M.jsx)(d.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]}),n?(0,M.jsxs)(l.default,{testID:"tips-responsive-list",style:{gap:10,width:'100%',minWidth:0},children:[be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.T,{center:!0,weight:"semibold",children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsxs)(d.T,{center:!0,children:["Paid hours: ",e.hours.toFixed(2)]}),(0,M.jsxs)(d.T,{center:!0,children:["Points: ",'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013']}),(0,M.jsxs)(d.T,{center:!0,children:["Share: ",e.pct.toFixed(1),"%"]}),(0,M.jsxs)(d.T,{center:!0,weight:"semibold",colour:m.colours.gold,children:["Amount: ",(0,p.gbp)(e.amount)]})]},e.staffId)}),(0,M.jsxs)(d.T,{center:!0,weight:"bold",children:["Total: ",(0,p.gbp)(we)]})]}):(0,M.jsx)(r.default,{horizontal:!0,children:(0,M.jsxs)(l.default,{children:[(0,M.jsx)(d.Row,{gap:0,style:{borderBottomWidth:1,borderColor:m.colours.border,paddingBottom:4},children:['Staff','Paid hrs','Points','Share','Amount'].map((e,t)=>(0,M.jsx)(d.T,{size:12,weight:"semibold",colour:m.colours.gold,style:{width:[130,70,54,64,80][t]},children:e},e))}),be.map(e=>{const t=R.find(t=>t.id===e.staffId);return(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,M.jsxs)(d.T,{size:13,style:{width:130},numberOfLines:1,children:[I(t?.name),xe[e.staffId]?.est&&!de?'*':'']}),(0,M.jsx)(d.T,{size:13,style:{width:70},children:e.hours.toFixed(2)}),(0,M.jsx)(d.T,{size:13,style:{width:54},children:'points'===L.method||'points'===de?.method?e.points.toFixed(1):'\u2013'}),(0,M.jsxs)(d.T,{size:13,style:{width:64},children:[e.pct.toFixed(1),"%"]}),(0,M.jsx)(d.T,{size:13,weight:"semibold",style:{width:80},children:(0,p.gbp)(e.amount)})]},e.staffId)}),(0,M.jsxs)(d.Row,{gap:0,style:{paddingVertical:6},children:[(0,M.jsx)(d.T,{size:13,weight:"bold",style:{width:318},children:"Total"}),(0,M.jsx)(d.T,{size:13,weight:"bold",colour:we===ge?m.colours.ok:m.colours.red,style:{width:80},children:(0,p.gbp)(we)})]})]})}),(0,M.jsxs)(d.Muted,{children:[we===ge?`\u2713 Total equals the pot (${(0,p.gbp)(ge)}).`:'\u2717 Total does not equal the pot.',Te?` Rounding: ${Te}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."]}),de?null:(0,M.jsx)(d.Button,{label:"Approve & lock period",disabled:!ie||H>=0||Se||we!==ge||ge<=0,onPress:()=>{const e=`${(0,h.niceDate)(S)} ${S.toTimeString().slice(0,5)}`,t={id:`tp-${le}`,key:le,label:ae,end:(0,h.ymd)(re),pot:ge,card:he,cash:ye,cashUps:fe,method:L.method,rows:be,lockedAt:e,by:F};u.useOwner.getState().setOwner({troncHistory:[t,..._],troncLog:[{id:`tl-${Date.now()}`,at:S.toISOString(),text:`${F} approved & locked tips for ${ae}: ${(0,p.gbp)(ge)} split ${$[L.method].toLowerCase()} between ${be.filter(e=>e.amount>0).length} staff`},...V]})}}),!de&&H>=0?(0,M.jsx)(d.Muted,{center:!0,children:"The current period can be approved once it has ended."}):null,ie||de?null:(0,M.jsx)(d.Muted,{center:!0,children:"Only the owner can approve tips."}),(0,M.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:"Export CSV / PDF summary",onPress:()=>Q(!0)}),de?(0,M.jsx)(d.Button,{small:!0,kind:"secondary",label:de.shared?'Shared \u2713':'Share with staff (chat)',disabled:!!de.shared,onPress:()=>{(0,f.autoPost)('all',`Tips for ${ae} approved: ${(0,p.gbp)(de.pot)} is in the tip pot.`),u.useOwner.getState().setOwner({troncHistory:_.map(e=>e.id===de.id?{...e,shared:(0,h.niceDate)(S)}:e)}),se('Posted to All staff chat.')}}):null]}),te?(0,M.jsx)(d.Banner,{kind:"info",title:te}):null,(0,M.jsx)(y.SectionHead,{title:"Compliance checklist",sub:"Employment (Allocation of Tips) Act 2023, in force since 1 Oct 2024. Summary only, not legal advice."}),(0,M.jsxs)(d.Card,{children:[[[!0,'100% of qualifying tips passed to workers, no deductions',`Pot ${(0,p.gbp)(ge)} = allocated ${(0,p.gbp)(we)}`],[L.text.trim().length>40,'Written tipping policy, available to staff','Stored in the app (template below)'],[!Pe,'Tips allocated by the end of the following month',`This period: by ${(0,h.niceDate)(ke)} ${ke.getFullYear()}`],[!0,'Tip records kept for 3 years',`${_.length} approved period(s) in the history`],[!0,'Staff can request their tip records',`${V.filter(e=>/requested/.test(e.text)).length} request(s) logged`]].map(([e,t,s])=>(0,M.jsxs)(d.Row,{style:{alignItems:'flex-start'},children:[(0,M.jsx)(d.T,{colour:e?m.colours.ok:m.colours.red,children:e?'\u2713':'\u2717'}),(0,M.jsxs)(l.default,{style:{flex:1},children:[(0,M.jsx)(d.T,{size:14,children:t}),(0,M.jsx)(d.Muted,{children:s})]})]},String(t))),(0,M.jsx)(d.Button,{small:!0,kind:"ghost",label:"View / edit tipping policy",onPress:()=>{ee(L.text),X(!0)}})]}),(0,M.jsx)(y.SectionHead,{title:"Tip history & audit log"}),_.map(e=>(0,M.jsxs)(d.Card,{children:[(0,M.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,M.jsx)(d.T,{weight:"semibold",children:e.label}),(0,M.jsx)(d.T,{weight:"bold",children:(0,p.gbp)(e.pot)})]}),(0,M.jsxs)(d.Muted,{children:[$[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)),V.map(e=>(0,M.jsxs)(d.Muted,{children:[(0,h.niceDate)(new Date(e.at))," \xb7 ",e.text]},e.id)),_.length||V.length?null:(0,M.jsx)(d.Muted,{children:"No approved periods yet."}),(0,M.jsxs)(d.Sheet,{visible:G,onClose:()=>Q(!1),title:"Tips summary export",children:[(0,M.jsx)(d.Banner,{kind:"demo",title:"Payroll export: not set up yet",children:"Nothing is sent. This will download a CSV or PDF payslip summary for payroll."}),(0,M.jsx)(l.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:Me.map((e,t)=>(0,M.jsx)(d.T,{size:11,colour:t?m.colours.text:m.colours.gold,children:e},t))}),(0,M.jsxs)(d.Muted,{children:[ae," \xb7 ",$[de?.method??L.method]]})]}),(0,M.jsxs)(d.Sheet,{visible:J,onClose:()=>X(!1),title:"Tipping policy",children:[(0,M.jsx)(s.TextInput,{accessibilityLabel:"Tipping policy",multiline:!0,editable:ie,value:Z,onChangeText:ee,style:[d.styles.input,{minHeight:220,textAlignVertical:'top'}]}),ie?(0,M.jsx)(d.Button,{label:"Save policy",onPress:()=>{ce({text:Z}),X(!1)}}):null,(0,M.jsx)(d.Muted,{children:"Template only. Adapt it to your business."})]})]}):(0,M.jsx)(E,{})},_e.useStaffTips=N,_e.useStaffTipsNotice=function(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useTipsShow)(e),{today:n}=N(e,t);(0,i.useEffect)(()=>{if(!o.showToday||F()||P.PITCH)return;const i=(0,C.latestDayTips)(s,e,t);i?(0,C.postTipsNotice)(e,i.date,i.total,t):null!=n&&(0,C.postTipsNotice)(e,t,n,t)},[e,t,s,n,o.showToday])},_e.StaffTipsTile=function({rid:e,today:t,onPress:s}){const{pot:o,today:i}=N(e,t),r=`Tip pot this period, ${B(o)}`,l=null==i?'No tips confirmed for today yet.':`Today's tips, ${B(i)}`;return(0,M.jsx)(n.default,{testID:"staff-tips-tile",accessibilityRole:"button",accessibilityLabel:`${r}. ${l}`,onPress:s,children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,children:[(0,M.jsx)(A,{testID:"staff-tips-pot",label:"Tip pot this period",amount:o,empty:"No tip pot for this period yet."}),(0,M.jsx)(A,{testID:"staff-tips-today",label:"Today's tips",amount:i,empty:"No tips confirmed for today yet."})]})})},_e.MyTips=E;var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),l=e(_r(_d[6])),a=e(_r(_d[7])),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]),y=_r(_d[15]),x=_r(_d[16]),j=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),T=_r(_d[20]),C=_r(_d[21]),S=_r(_d[22]),k=_r(_d[23]),v=_r(_d[24]),P=_r(_d[25]),M=_r(_d[26]);const $={hours:'By paid hours',points:'Hours \xd7 role points',equal:'Equal share',custom:'Custom %'},O=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',I=e=>(e??'').replace(' (example)','');function D(e,t){const s=t.reduce((e,t)=>e+t,0);if(!s||e<=0)return{amounts:t.map(()=>0),remainder:0};const o=t.map(t=>e*t/s),i=o.map(Math.floor);let n=e-i.reduce((e,t)=>e+t,0);const r=n;return o.map((e,t)=>({i:t,f:e-Math.floor(e)})).sort((e,t)=>t.f-e.f).forEach(({i:e})=>{n>0&&(i[e]+=1,n-=1)}),{amounts:i,remainder:r}}const B=e=>`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`;function F(){if('undefined'==typeof window)return!1;const e=window.location.hostname;return('localhost'===e||'127.0.0.1'===e)&&'tips'===new URLSearchParams(window.location.search).get('demo')}const R={pot:186.4,today:48.5};function N(e,t){const s=(0,T.useCashUp)(e=>e.tips),o=(0,T.useCashUp)(e=>e.pot),n=(0,j.useVenuePay)(e).pay,r=(0,w.useSync)(e=>e.venueId),l=(0,v.tipsPeriod)(n,t),a=(0,i.useMemo)(()=>(0,S.tipsPot)(s.filter(t=>t.rid===e),o.filter(t=>t.rid===e),l.start,t),[s,o,e,l.start,t]),d=s.find(s=>s.rid===e&&s.date===t),[c,u]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!r||P.PITCH)return;let e=!1;const s=async()=>{try{const s=await(0,w.rpc)('staff_tip_summary',{p_venue:r,p_today:t,p_from:l.start}),o=Number(s?.pot);if(e||!s||Array.isArray(s)||s.error||!Number.isFinite(o))return;const i=null==s.today||''===s.today?null:Number(s.today);u({pot:o,today:null!=i&&Number.isFinite(i)?i:null})}catch{}};s();const o=setInterval(()=>{s()},3e4);return()=>{e=!0,clearInterval(o)}},[r,t,l.start]),F()?{pot:R.pot,today:R.today}:{pot:c?c.pot:a.total,today:c?c.today:d?d.total:null}}function A({testID:e,label:t,amount:s,empty:o}){const i=null==s?o:`${t}, ${B(s)}`;return(0,M.jsxs)(l.default,{testID:e,accessible:!0,accessibilityLabel:i,style:{alignItems:'center',gap:2,width:'100%'},children:[(0,M.jsx)(d.T,{center:!0,size:14,weight:"semibold",colour:m.colours.gold,children:t}),null==s?(0,M.jsx)(d.Muted,{center:!0,children:o}):(0,M.jsx)(d.T,{center:!0,size:36,weight:"bold",colour:m.colours.goldLight,children:B(s)})]})}function E(e={}){const t=(0,x.useCtx)(6e4),s=N(t.rid,t.today);return(0,M.jsx)(l.default,{testID:"staff-tips",style:{gap:12,alignItems:'center'},children:(0,M.jsxs)(d.Card,{highlight:m.colours.gold,style:{alignSelf:'stretch'},children:[(0,M.jsx)(A,{testID:"staff-tips-page-pot",label:"Tip pot this period",amount:s.pot,empty:"No tip pot for this period yet."}),(0,M.jsx)(d.Muted,{center:!0,children:"The venue total so far. Confirmed cash ups only."}),(0,M.jsx)(A,{testID:"staff-tips-page-today",label:"Today's tips",amount:s.today,empty:"No tips confirmed for today yet."})]})})}},1212,[828,827,837,34,402,295,102,426,794,874,891,867,858,821,1180,1195,1088,1065,1160,987,1039,1062,13,1085,1064,2,25]); +__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.useWeekSales=G,Object.defineProperty(_e,"ROTA_GAP",{enumerable:!0,get:function(){return X}}),_e.rotaGrid=J,_e.Rota=function({go:e}={}){const{now:t,role:n,meId:o}=(0,T.useCtx)(6e4),i=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),r=(0,s.useOwner)(e=>e.shifts),d=(0,T.useHourly)(),u=(0,s.useOwner)(e=>e.availability),m=(0,s.useOwner)(e=>e.leave),g=(0,s.useOwner)(e=>e.swaps),[x,k]=(0,l.useState)(0),[O,M]=(0,l.useState)(null),[P,R]=(0,l.useState)(null),[B,z]=(0,l.useState)('week'),[H,N]=(0,l.useState)(!1),Y=(0,T.useSignedIn)()?.name??'',_='staff'!==n,q=(0,S.addMins)(U(t),7*x*1440);q.setHours(0,0,0,0);const te=G(q),se=te.sales,ne='none'===te.mode,ae=Array.from({length:7},(e,t)=>{const s=new Date(q);return s.setDate(q.getDate()+t),(0,S.ymd)(s)}),oe=(0,s.visibleShifts)(r,_).filter(e=>e.date>=ae[0]&&e.date<=ae[6]),ie=(()=>{const e=new Date(q);return e.setDate(e.getDate()-7),(0,S.ymd)(e)})(),le=oe.filter(e=>!e.published||e.changed).length,re=r.filter(e=>e.date>=ie&&e.date!!(0,s.leaveOn)(m,e,t),ce=ae.map(e=>(0,p.workingShifts)(oe,m).filter(t=>t.date===e).reduce((e,t)=>{return e+(V(s=t)-K(V(s)))*(d[s.staffId]??0);var s},0)),ue=ce.reduce((e,t)=>e+t,0),he=se.reduce((e,t)=>e+t,0),fe=(e,t)=>t?Math.round(e/t*100):0,me=_?i:i.filter(e=>e.id===o),pe=(0,a.useNarrow)(),ge=Math.max(0,ae.indexOf((0,S.ymd)(t))),[xe,be]=(0,l.useState)(null),je=xe??ge,we=(e,t)=>!pe||t===je,[ye,ke]=(0,l.useState)(0),Ie=J(ye,pe?1:7),Se=Ie.cell,Ce=Ie.name;return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Week",selected:'week'===B,onPress:()=>z('week')}),(0,F.jsx)(f.Chip,{label:`Swaps & time off (${g.filter(e=>'open'===e.status).length+m.filter(e=>'pending'===e.status).length})`,selected:'requests'===B,onPress:()=>z('requests')}),(0,F.jsx)(f.Chip,{label:"Availability",selected:'availability'===B,onPress:()=>z('availability')})]}),'week'===B?(0,F.jsxs)(F.Fragment,{children:[!_&&o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-time-off"}):null,e&&s.CAN.manage(n)?(0,F.jsx)(h.default,{testID:"rota-timesheet-row",style:{alignItems:'center',alignSelf:'stretch'},children:(0,F.jsx)(f.Button,{testID:"rota-timesheet",label:"Time sheet",accessibilityLabel:(0,L.timeSheetLabel)(ae[0],ae[6]),onPress:()=>{(0,L.setHoursPreset)(ae[0],ae[6]),e('more','hours')},style:{minWidth:220,maxWidth:"100%",minHeight:48}})}):null,(0,F.jsxs)(h.default,{testID:"rota-week-nav",style:{flexDirection:'row',alignItems:'center',alignSelf:'center',width:ye?Math.min(ye,Ie.width):'100%',gap:8},children:[(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-prev",label:"\u2039 Prev",accessibilityLabel:"Previous week",onPress:()=>{k(x-1),M(null)},style:{minWidth:96}}),(0,F.jsxs)(h.default,{style:{alignItems:'center',flex:1,minWidth:0},children:[(0,F.jsxs)(f.T,{weight:"semibold",center:!0,children:["Week of ",(0,S.niceDate)(q)]}),(0,F.jsxs)(f.Muted,{center:!0,children:[0===x?'This week':1===x?'Next week':-1===x?'Last week':x>0?`In ${x} weeks`:-x+" weeks ago",_?' \xb7 tap a cell to add or edit':' \xb7 your shifts']})]}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",testID:"rota-next",label:"Next \u203a",accessibilityLabel:"Next week",onPress:()=>{k(x+1),M(null)},style:{minWidth:96}})]}),_?(0,F.jsxs)(f.Row,{wrap:!0,gap:8,style:{alignItems:'center'},children:[(0,F.jsx)(f.Button,{small:!0,kind:"secondary",label:"Copy last week"+(re?` (${re})`:''),disabled:!re,testID:"rota-copy",onPress:()=>{const e=s.useOwner.getState().copyWeek(ie,ae[0]);M(e?`Copied ${e} ${1===e?'shift':'shifts'} from last week as drafts. Check them, then publish.`:'Nothing to copy: those days are already filled.')}}),(0,F.jsx)(f.Button,{small:!0,kind:"success",label:le?`Publish ${le} ${1===le?'change':'changes'}`:'Week published',disabled:!le,testID:"rota-publish",onPress:()=>{const e=s.useOwner.getState().publishWeek(ae[0]);M(`Published ${e} ${1===e?'shift':'shifts'}. Staff see them in their app.`)}}),le?(0,F.jsx)(f.Badge,{kind:"amber",label:`${le} unpublished`}):oe.length?(0,F.jsx)(f.Badge,{kind:"ok",label:"Visible to staff"}):null]}):null,O?(0,F.jsx)(f.Banner,{kind:"success",title:O}):null,pe?(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:T.DAY3.map((e,t)=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,S.parseYmd)(ae[t]).getDate()}`,selected:t===je,onPress:()=>be(t)},e))}):null,(0,F.jsx)(h.default,{testID:"rota-grid-wrap",onLayout:e=>{const t=Math.round(e.nativeEvent.layout.width);Math.abs(t-ye)>1&&ke(t)},style:{alignSelf:'stretch'},children:(0,F.jsx)(ee,{fits:pe||Ie.fits,children:(0,F.jsxs)(h.default,{testID:"rota-grid",style:{gap:X,width:Ie.width,alignSelf:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-dates",style:[{flexDirection:'row',gap:X,backgroundColor:C.colours.bg,paddingVertical:8,borderBottomWidth:1,borderColor:C.colours.hairline,zIndex:5},pe||Ie.fits?Z:null],children:[(0,F.jsx)(h.default,{style:{width:Ce,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:11,weight:"semibold",colour:C.colours.goldMuted,style:{letterSpacing:1.2},children:"TEAM"})}),T.DAY3.map((e,s)=>(0,F.jsx)(h.default,{testID:"rota-date",style:{width:Se,alignItems:'center'},children:(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,colour:ae[s]===(0,S.ymd)(t)?C.colours.gold:C.colours.text,children:[e," ",(0,S.parseYmd)(ae[s]).getDate()]})},e)).filter(we)]}),me.map(e=>(0,F.jsxs)(h.default,{testID:"rota-row",style:{flexDirection:'row',gap:X,alignItems:'center'},children:[(0,F.jsxs)(h.default,{testID:"rota-name",style:{width:Ce,flexDirection:'row',alignItems:'center',gap:8,overflow:'hidden'},children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:28}),(0,F.jsxs)(h.default,{style:{flex:1,minWidth:0},children:[(0,F.jsx)(f.T,{size:13,weight:"semibold",numberOfLines:1,style:{textAlign:'left'},children:e.name.replace(' (example)','')}),e.job?(0,F.jsx)(f.T,{size:11,colour:C.colours.muted,numberOfLines:1,style:{textAlign:'left'},children:e.job}):null]})]}),T.DAY3.map((t,n)=>{const a=(0,s.shiftOf)(oe,e.id,ae[n]),o=(u[e.id]??[]).includes(n),i=de(e.id,ae[n]);return(0,F.jsxs)(c.default,{testID:"rota-cell",accessibilityRole:"button",accessibilityLabel:`${e.name} ${T.DAY3[n]} ${a?`${(0,T.fmtH)(a.start)} to ${(0,T.fmtH)(a.end)}`:'no shift'}${i?', on time off':''}`,disabled:!_,onPress:()=>R({staffId:e.id,date:ae[n],shift:a}),style:({pressed:e})=>({width:Se,height:52,borderRadius:12,borderWidth:1,borderStyle:a&&!a.published?'dashed':'solid',borderColor:a?a.published?C.colours.gold:C.colours.amber:C.colours.border,backgroundColor:e?C.colours.goldTint:a?a.published?'#2b2414':'#241f14':i?'#1d2a3a':o?'#2a1d1d':'transparent',alignItems:'center',justifyContent:'center',paddingHorizontal:4}),children:[a?(0,F.jsxs)(f.T,{size:Ie.big?13:12,weight:"semibold",center:!0,numberOfLines:1,children:[(0,T.fmtH)(a.start),"\u2013",(0,T.fmtH)(a.end)]}):(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:i?'Off':o?'Unavail.':_?'Add':'\u2013'}),a&&i?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.blue,children:(0,p.leaveLabel)((0,s.leaveOn)(m,e.id,ae[n])).toLowerCase()}):a&&o?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.red,children:"unavailable"}):a&&_&&(!a.published||a.changed)?(0,F.jsx)(f.T,{size:10,center:!0,colour:C.colours.amber,children:a.published?'changed':'draft'}):null]},n)}).filter(we)]},e.id)),_?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X,marginTop:4},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour"})}),ce.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,children:(0,I.gbp)(e).replace('.00','')})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:'example'===te.mode?'Fcst sales (ex.)':'Fcst sales'})}),se.map((e,t)=>(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,colour:C.colours.muted,children:e?`\xa3${Math.round(e/100)}`:'shut'})},t)).filter(we)]}),ne?null:(0,F.jsxs)(h.default,{style:{flexDirection:'row',gap:X},children:[(0,F.jsx)(h.default,{style:{width:Ce},children:(0,F.jsx)(f.Muted,{children:"Labour %"})}),ce.map((e,t)=>{const s=fe(e,se[t]);return(0,F.jsx)(h.default,{style:{width:Se,alignItems:'center'},children:(0,F.jsx)(f.T,{size:12,center:!0,weight:"semibold",colour:se[t]?s>32?C.colours.red:s>26?C.colours.amber:C.colours.ok:C.colours.muted,children:se[t]?`${s}%`:'\u2013'})},t)}).filter(we)]})]}):null]})})}),!_&&o?(0,F.jsx)(h.default,{testID:"rota-team-on",children:(0,F.jsx)(f.Card,{children:ae.map((e,t)=>(0,F.jsx)(b.TeamOnDay,{date:e,meId:o,label:(0,S.niceDate)((0,S.parseYmd)(e))},e)).filter(we)})}):null,_&&ne?(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:"labour-no-forecast",style:{gap:6},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour this week"}),(0,F.jsx)(h.default,{testID:"labour-week-cost",children:(0,F.jsx)(f.T,{weight:"semibold",children:(0,I.gbp)(ue)})})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour from the rota (paid hours \xd7 hourly rates, owner salaries excluded)."]}),(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Not enough history yet for labour vs sales"}),(0,F.jsx)(f.Muted,{children:`Forecasts start once CoverCharge has ${1===te.weeks?'1 week':`${te.weeks} weeks`} of your bookings and cash-ups. Until then no sales forecast or labour % is shown.`}),te.booked?(0,F.jsx)(h.default,{testID:"labour-booked",children:(0,F.jsxs)(f.T,{children:["Booked so far: ",te.booked," Covers this week"]})}):null]})}):null,_&&!ne?(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Labour vs forecast sales"}),(0,F.jsxs)(f.Row,{gap:6,children:['example'===te.mode?(0,F.jsx)(A.ExampleBadge,{}):null,(0,F.jsx)(f.Badge,{kind:fe(ue,he)>30?'red':'ok',label:`${fe(ue,he)}% this week`})]})]}),(0,F.jsxs)(f.Muted,{children:[(0,I.gbp)(ue)," labour (paid hours \xd7 hourly rates, owner salaries excluded) vs about ",(0,I.gbp)(he)," forecast sales. Target 25\u201330%. ",'example'===te.mode?'Example figures: forecast sales use an example spend per cover.':'Forecast sales are your average takings for each weekday from your cash-ups.']}),(()=>{const e=fe(ce[5],se[5]);return e&&e<24?(0,F.jsxs)(f.T,{size:14,colour:C.colours.gold,children:["Tip: Saturday is forecast busy and labour is only ",e,"%. Consider an extra server 18:00\u201321:00."]}):null})()]}):null,_?(0,F.jsx)(f.Muted,{center:!0,children:"New and copied shifts are drafts (dashed) until you publish. Publishing only makes shifts visible in the Staff app and on the Display. Nothing is sent by text or email."}):null]}):null,'requests'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(D.SectionHead,{title:"Shift swaps & cover"}),g.filter(e=>_||e.fromId===o||e.toId===o).map(e=>{const t=r.find(t=>t.id===e.shiftId),n=i.find(t=>t.id===e.fromId),a=i.find(t=>t.id===e.toId);return(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{weight:"semibold",style:{flex:1},children:['swap'===e.kind?'Swap':'Cover needed',": ",n?.name]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'amber':'approved'===e.status?'ok':'neutral',label:e.status})]}),(0,F.jsxs)(f.Muted,{children:[t?`${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)}`:'Shift',a?` \u2192 ${a.name}`:''," \xb7 ",e.note]}),'open'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,children:['cover'!==e.kind||e.toId?null:i.filter(e=>E(n,e)).map(t=>(0,F.jsx)(f.Chip,{label:`Give to ${t.name.split(' ')[0]}`,onPress:()=>{s.useOwner.setState(s=>({swaps:s.swaps.map(s=>s.id===e.id?{...s,toId:t.id}:s)}))}},t.id)),(0,F.jsx)(f.Button,{small:!0,label:"Approve",disabled:!e.toId||!E(n,a),onPress:()=>{s.useOwner.getState().setSwap(e.id,'approved');const n=e=>(i.find(t=>t.id===e)?.name??'').replace(' (example)','');(0,v.autoPost)('all','swap'===e.kind?`Shift swap: ${n(e.fromId)} \u2194 ${n(e.toId)} approved`:`Cover approved: ${n(e.toId)} covers ${n(e.fromId)}${t?` (${T.DAY3[t.day]} ${(0,T.fmtH)(t.start)}\u2013${(0,T.fmtH)(t.end)})`:''}`)}}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setSwap(e.id,'declined')})]}):null]},e.id)}),_?null:(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Ask for a swap or cover"}),(0,F.jsx)(f.Muted,{children:"Your shifts this week. Your manager approves every swap."}),(0,F.jsx)(f.Muted,{testID:"swap-dept-note",children:(0,j.isAnchorageVenue)(w.VENUE_RID)?j.ANCHORAGE_SWAP_NOTE:W(i.find(e=>e.id===o))?j.SWAP_DEPT_NOTE:'Your department isn\u2019t set yet, so swaps are off. Ask a manager to set it in Staff & roles.'}),oe.filter(e=>e.staffId===o).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{const t=g.some(t=>t.shiftId===e.id&&'open'===t.status);return(0,F.jsxs)(h.default,{style:{gap:4,paddingVertical:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:14,weight:"medium",children:[T.DAY3[e.day]," ",(0,T.fmtH)(e.start),"\u2013",(0,T.fmtH)(e.end)]}),t?(0,F.jsx)(f.Badge,{kind:"amber",label:"Request open"}):null]}),t?null:(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Ask for cover",onPress:()=>{s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,kind:'cover',note:'Can anyone cover?'}),(0,v.autoPost)('all',`Cover needed: ${T.DAY3[e.day]} ${(0,T.fmtH)(e.start)}\u2013${(0,T.fmtH)(e.end)} (${(i.find(e=>e.id===o)?.name??'').replace(' (example)','')})`)}}),i.filter(e=>E(i.find(e=>e.id===o),e)).map(t=>(0,F.jsx)(f.Chip,{label:`Swap with ${t.name.replace(' (example)','')}`,onPress:()=>s.useOwner.getState().addSwap({shiftId:e.id,fromId:o,toId:t.id,kind:'swap',note:'Agreed between us'})},t.id))]})]},e.id)}),oe.some(e=>e.staffId===o)?null:(0,F.jsx)(f.Muted,{children:"No shifts on the rota this week."})]}),(0,F.jsx)(D.SectionHead,{title:"Holiday & time off"}),_?(0,F.jsx)(f.Button,{label:"Add time off for someone",testID:"rota-add-time-off",onPress:()=>N(!0)}):o?(0,F.jsx)(y.RequestTimeOff,{meId:o,me:Y,testID:"rota-requests-time-off"}):null,m.filter(e=>_||e.staffId===o).sort((e,t)=>e.from.localeCompare(t.from)).map(e=>(0,F.jsx)(f.Card,{children:(0,F.jsxs)(h.default,{testID:`leave-${e.id}`,style:{gap:4},children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(i.find(t=>t.id===e.staffId)?.name??'').replace(' (example)','')}),(0,F.jsx)(f.Badge,{kind:'pending'===e.status?'amber':'approved'===e.status?'ok':'red',label:'pending'===e.status?'waiting':e.status})]}),(0,F.jsxs)(f.Muted,{children:[(0,y.rangeLabel)(e.from,e.to)," \xb7 ",e.reason,e.decidedBy?` \xb7 ${'declined'===e.status?'declined':'approved'} by ${e.decidedBy}`:e.by?` \xb7 asked by ${e.by}`:'']}),'pending'===e.status&&_?(0,F.jsxs)(f.Row,{gap:6,style:{justifyContent:'center'},children:[(0,F.jsx)(f.Button,{small:!0,label:"Approve",onPress:()=>s.useOwner.getState().setLeave(e.id,'approved')}),(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>s.useOwner.getState().setLeave(e.id,'declined')})]}):null]})},e.id)),_&&o?(0,F.jsx)(y.TimeOffSheet,{visible:H,onClose:()=>N(!1),meId:o,me:Y,manager:!0}):null]}):null,'availability'===B?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.Muted,{children:["Days each person can\u2019t work. ",_?'Tap to toggle.':'Tap to set your own.'," The rota flags clashes."]}),me.filter(e=>'owner'!==e.role||!_).map(e=>(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{gap:8,children:[(0,F.jsx)($.StaffAvatar,{id:e.id,size:30}),(0,F.jsx)(f.T,{weight:"semibold",children:e.name})]}),(0,F.jsx)(f.Row,{wrap:!0,gap:4,children:T.DAY3.map((t,n)=>{const a=(u[e.id]??[]).includes(n);return(0,F.jsx)(f.Chip,{label:`${t} ${a?'\u2715':'\u2713'}`,selected:!a,onPress:()=>s.useOwner.getState().toggleAvail(e.id,n)},t)})})]},e.id))]}):null,P?(0,F.jsx)(Q,{init:P,onClose:()=>R(null)}):null]})},_e.ClockInOut=function(){const{now:e,today:t,role:a,meId:u,me:m,r:p,rid:g}=(0,T.useCtx)(5e3),b=((0,O.useClockArea)(e=>e.areas[g]),(0,O.areaOf)(g));const j=(0,M.privateClockVenue)(g),[w,y]=(0,l.useState)(!1),k=(0,s.useOwner)(e=>e.consent[u]),I=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),D=(0,s.useOwner)(e=>e.shifts),[v,A]=(0,l.useState)(!1),[H,L]=(0,l.useState)(null),[N,Y]=(0,l.useState)(null),[W,E]=(0,l.useState)(void 0),[_,q]=(0,l.useState)(null),[V,K]=(0,l.useState)(!1),[U,G]=(0,l.useState)(null),Q=I.filter(t=>t.staffId===u&&t.in&&!t.out&&e.getTime()-new Date(t.in).getTime()<72e6).sort((e,t)=>t.in.localeCompare(e.in))[0],X=Q&&(0,s.isOnBreak)(Q)?Q.breaks[Q.breaks.length-1]:void 0,J=(0,s.visibleShifts)(D,'staff'!==a).find(e=>e.staffId===u&&e.date===t),Z='staff'!==a,ee=Q?(0,T.paidMins)({in:Q.in},e).worked:0,ne=b.on&&(0,P.areaSet)(b),ae=Q?.geo?.[Q.geo.length-1],oe=I.filter(e=>e.staffId===u&&e.date===t).sort((e,t)=>(t.in??'').localeCompare(e.in??''))[0],ie=(0,r.useClockNotSent)(Q?.id??_?.id??oe?.id),[le,re]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(ie)re(!0);else if(le){const e=setTimeout(()=>re(!1),6e3);return()=>clearTimeout(e)}},[ie]);const de=!ie&&le,ce=async(s,n={})=>{L(s),Y(null),E(void 0);const a=await(0,R.clockAction)(s,{rid:g,staffId:u,date:t,at:new Date(e.getTime()).toISOString(),...n});return L(null),a.ok?('out'===s&&a.att&&(q(a.att),(0,i.hrSettingsOf)(p.settings?.hr).on&&!o.useHr.getState().hasAnswered(g,a.att.id)&&G(a.att)),'in'===s&&q(null),a.att&&(0,r.markClockUnsent)(a.att.id),!0):(Y(a.message),E(a.fix),(0,B.notify)({id:'clock-blocked',tone:'warn',icon:'\ud83d\udccd',kicker:'CLOCK',title:a.message.split('. ')[0]+'.',body:a.message.split('. ').slice(1).join('. '),timeoutMs:9e3,testID:'clock-blocked'}),!1)};return k?(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.Row,{gap:10,style:{flex:1},children:[(0,F.jsx)($.StaffAvatar,{id:u,size:48}),(0,F.jsx)(f.T,{weight:"semibold",style:{flex:1},children:m})]}),(0,F.jsx)(f.Badge,{kind:Q?'ok':'neutral',label:Q?`On shift since ${(0,S.hm)(new Date(Q.in))}`:'Not clocked in'})]}),(0,F.jsx)(f.Muted,{children:J?`Today's shift: ${(0,T.fmtH)(J.start)}\u2013${(0,T.fmtH)(J.end)}`:'No shift on the rota today'}),(0,F.jsx)(h.default,{testID:"clock-area-line",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.muted,children:ne?j?`Location is checked only when you choose Clock in, at ${p.name}. Only pass or fail is saved.`:`\ud83d\udccd Your location is checked when you tap a button. You need to be at ${p.name}.`:b.on?'\ud83d\udccd The clock-in area isn\u2019t set yet, so location isn\u2019t checked.':'\ud83d\udccd Location checks are switched off for this venue.'})}),ae&&!0===ae.inside&&null!=ae.dist?(0,F.jsxs)(f.Muted,{children:["Last check: at the venue (about ",ae.dist," m from the centre)."]}):null,Q?(0,F.jsx)(f.T,{size:30,weight:"bold",center:!0,children:(0,T.hmDur)(ee)}):null,Q&&X?(0,F.jsx)(h.default,{testID:"on-break",children:(0,F.jsxs)(f.T,{size:15,weight:"semibold",colour:C.colours.gold,center:!0,children:["On a break since ",(0,S.hm)(new Date(X.start))," \xb7 ",(0,s.loggedBreakMins)(Q,e)," min so far"]})}):null,Q?(0,F.jsxs)(F.Fragment,{children:[X?(0,F.jsx)(f.Button,{testID:"break-end",kind:"success",label:'break_end'===H?'Checking your location\u2026':'End break',disabled:!!H,onPress:()=>{ce('break_end')}}):(0,F.jsx)(f.Button,{testID:"break-start",kind:"secondary",label:'break_start'===H?'Checking your location\u2026':'Start break',disabled:!!H,onPress:()=>{ce('break_start')}}),(0,F.jsx)(f.Button,{testID:"clock-out",kind:"danger",label:'out'===H?'Checking your location\u2026':'Clock out',disabled:!!H,onPress:()=>{Q.breaks?.length?ce('out'):(Y(null),A(!0))}})]}):(0,F.jsx)(f.Button,{testID:"clock-in",kind:"success",label:'in'===H?'Checking your location\u2026':'Clock in',disabled:!!H,onPress:()=>{j?y(!0):ce('in')}}),ie?(0,F.jsxs)(h.default,{testID:"clock-not-sent",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"polite",accessibilityLabel:"Not sent yet. Your clock time is saved on this phone and will send as soon as it can. Keep the app open for a moment.",style:{alignSelf:'center',alignItems:'center',gap:4,borderRadius:14,borderWidth:1.5,borderColor:C.colours.gold,backgroundColor:'rgba(212,175,106,0.12)',paddingVertical:10,paddingHorizontal:16,maxWidth:460,width:'100%'},children:[(0,F.jsx)(f.T,{size:18,weight:"bold",colour:C.colours.gold,center:!0,children:"Not sent yet"}),(0,F.jsx)(f.T,{size:14,center:!0,children:"Saved on this phone. It sends as soon as it can. Keep the app open for a moment."}),(0,F.jsx)(f.Button,{small:!0,kind:"secondary",testID:"clock-send-now",label:"Send now",accessibilityLabel:"Send my clock time now",onPress:()=>{d.mutationQueue.retryNow()}})]}):de?(0,F.jsx)(h.default,{testID:"clock-sent",accessible:!0,accessibilityLabel:"Sent to your manager",children:(0,F.jsx)(f.T,{size:14,colour:C.colours.ok,center:!0,children:"\u2713 Sent"})}):null,Q?.breaks?.length?(0,F.jsxs)(f.Muted,{center:!0,children:["Breaks today: ",Q.breaks.map(e=>`${(0,S.hm)(new Date(e.start))}\u2013${e.end?(0,S.hm)(new Date(e.end)):'now'}`).join(', ')," (",(0,s.loggedBreakMins)(Q,e)," min)"]}):null,N?(0,F.jsx)(h.default,{testID:"clock-message",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Not recorded",children:N})}):null,N&&'settings'===W?(0,F.jsx)(f.Button,{testID:"clock-open-settings",label:"Open app settings",accessibilityLabel:"Open app settings, to allow location",onPress:z.openAppSettings}):null,N&&'location'===W?(0,F.jsx)(f.Button,{testID:"clock-open-location",label:"Open location settings",accessibilityLabel:"Open location settings, to turn on location",onPress:z.openLocationSettings}):null,N&&'update'===W?(0,F.jsx)(f.Button,{testID:"clock-check-update",label:"Look for the app update",accessibilityLabel:"Look for the app update",onPress:z.checkAppUpdate}):null]}),Z&&!(0,P.areaSet)(b)?(0,F.jsx)(h.default,{testID:"clock-area-warning",children:(0,F.jsx)(f.Banner,{kind:"warn",title:"Set the clock-in area",children:"Location isn\u2019t checked until a manager sets the venue\u2019s centre. Stand at the venue and go to Settings \u203a Advanced \u203a Clock-in area \u203a Use my current location."})}):null,(0,F.jsx)(c.default,{testID:"forgot-link",accessibilityRole:"button",onPress:()=>K(!0),style:{alignSelf:'center',padding:6},children:(0,F.jsx)(f.T,{size:14,colour:C.colours.gold,children:"Forgot to clock in or out?"})}),V?(0,F.jsx)(se,{onClose:()=>K(!1)}):null,(0,F.jsx)(x.BreakRoomCard,{staffId:u,name:m,now:e}),_?(()=>{const t=(0,T.paidMins)(_,e);return(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsxs)(f.T,{weight:"semibold",colour:C.colours.gold,children:["Clocked out at ",(0,S.hm)(new Date(_.out))]}),(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Clocked ",(0,T.hmDur)(t.worked),", break ",t.brk,"m, paid ",(0,T.hmDur)(t.paid)]}),(0,F.jsxs)(f.Muted,{children:["In ",(0,S.hm)(new Date(_.in))," \xb7 out ",(0,S.hm)(new Date(_.out))," \xb7 paid hours = (out \u2212 in) \u2212 break",_.breakAddedAtClockOut?' \xb7 break added at clock-out':'']}),t.worked>360&&0===t.brk?(0,F.jsx)(f.Banner,{kind:"info",title:"A note on breaks",children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours. Your clock-out is saved; have a word with your manager if you didn\u2019t get one."}):null]})})():null,(0,F.jsx)(f.Sheet,{visible:w,onClose:()=>y(!1),title:"Why we ask for location",testID:"clock-location-reason",children:(0,F.jsxs)(h.default,{style:{gap:12},children:[(0,F.jsxs)(f.T,{children:["We check once that you are at ",p.name,", within about ",b.radius," m, when you clock in. Only pass or fail is saved, not your position. We never track you in the background."]}),(0,F.jsx)(f.T,{children:"If you refuse or are too far away, no clock-in is made. A manager can override it with a recorded reason."}),(0,F.jsx)(f.Button,{testID:"clock-location-continue",label:"Check my location and clock in",accessibilityLabel:"Check my location once and clock in at the pub",onPress:()=>{y(!1),ce('in')}}),(0,F.jsx)(f.Button,{testID:"clock-location-cancel",kind:"secondary",label:"Not now",onPress:()=>y(!1)})]})}),Z?(0,F.jsx)(te,{rid:g,today:t,now:e}):null,U?(0,F.jsx)(n.ShiftCheckout,{rid:g,shiftKey:U.id,day:U.date,meId:u,onClose:()=>G(null)}):null,(0,F.jsx)(f.Sheet,{visible:v,onClose:()=>A(!1),title:"Did you take a break? If so, how long?",children:(0,F.jsxs)(h.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,F.jsx)(f.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:b.breakOptions.map(e=>(0,F.jsx)(f.Chip,{testID:`forgot-break-${e}`,label:(0,P.breakLabel)(e),disabled:e>=ee,onPress:()=>{A(!1),ce('out',{addedBreak:e})}},e))}),(0,F.jsx)(f.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{A(!1),ce('out',{breakMins:0})}}),ee>360?(0,F.jsx)(f.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null,(0,F.jsx)(f.Muted,{children:j?'Clock-out and breaks do not use your location.':'Tip: your location is checked when you clock out, like clocking in.'})]})})]}):(0,F.jsx)(h.default,{style:{gap:10},children:(0,F.jsxs)(f.Card,{highlight:C.colours.gold,children:[(0,F.jsx)(f.T,{weight:"semibold",colour:C.colours.gold,children:"Before you clock in: location & your privacy"}),j?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(f.T,{size:14,children:["When you choose Clock in, we ask once for your phone\u2019s location to check you are at ",p.name,", within about ",b.radius," m."]}),(0,F.jsx)(f.T,{size:14,children:"Only pass or fail is kept with your clock-in time. Your map position, accuracy and distance are not saved. No location trails, background checks, clock-out checks or break checks."})]}):(0,F.jsxs)(F.Fragment,{children:[" ",(0,F.jsxs)(f.T,{size:14,children:["CoverCharge checks your phone\u2019s location ",(0,F.jsx)(f.T,{size:14,weight:"bold",children:"only at the moment you tap Clock in, Clock out, Start break or End break"}),", to confirm you are at ",p.name," (within about ",b.radius," m)."]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your location is never tracked continuously or in the background."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 With each clock record we keep that one reading (map position and how accurate the phone said it was), whether it was inside the area, and the time."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If the app is open while you\u2019re at the venue and you\u2019re not on the rota, it may ask whether you want to clock in (only if you have already allowed location)."})]}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Your employer uses this for timesheets and pay (UK GDPR lawful basis: contract / legitimate interests)."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 If your phone can\u2019t share its location, a manager can record it for you instead. You can see your own records anytime."}),(0,F.jsx)(f.T,{size:14,children:"\u2022 Records are kept for payroll (6 years, HMRC) and then deleted."}),(0,F.jsx)(f.Button,{label:"I understand \u2014 continue",onPress:()=>s.useOwner.getState().giveConsent(u,e.toISOString())})]})})},_e.Timesheets=function(){const{now:e,today:t,role:s,meId:n}=(0,T.useCtx)(3e4);return s!=='staff'?(0,F.jsx)(ae,{now:e,today:t,meId:n}):(0,F.jsx)(ne,{})};var t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),l=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]);_r(_d[9]);var c=e(_r(_d[10])),u=e(_r(_d[11])),h=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),p=_r(_d[15]),g=_r(_d[16]),x=_r(_d[17]),b=_r(_d[18]),j=_r(_d[19]),w=_r(_d[20]),y=_r(_d[21]),k=_r(_d[22]),I=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),D=_r(_d[26]),v=_r(_d[27]),T=_r(_d[28]),$=_r(_d[29]),O=_r(_d[30]),M=_r(_d[31]),P=_r(_d[32]),R=_r(_d[33]),B=_r(_d[34]),z=_r(_d[35]),A=_r(_d[36]),H=_r(_d[37]),L=_r(_d[38]),N=_r(_d[39]),Y=_r(_d[40]),F=_r(_d[41]);const W=e=>(0,j.deptKey)(e?.dept),E=(e,t)=>(0,j.canSwapWith)(e,t,w.VENUE_RID),_=2650,q=1900,V=e=>e.end-e.start,K=e=>e>8?.5:e>6?.3333333333333333:0,U=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.setDate(t.getDate()-(0,T.weekday)(e)),t};function G(e){const{rid:t,r:s,now:n}=(0,T.useCtx)(6e4),a=(0,m.useBookings)(t),o=(0,m.useOrders)(t),i=(0,m.useEvents)(t),r=(0,A.useRealHistory)(t,n);return(0,l.useMemo)(()=>{const t=Array.from({length:7},(t,s)=>{const n=(0,S.addMins)(e,1440*s);return n.setHours(11,0,0,0),n}),n=a.filter(e=>!e.walkIn&&'confirmed'===e.status&&t.some(t=>(0,S.ymd)(t)===e.date)).reduce((e,t)=>e+t.partySize,0),l=(0,H.clampWeeks)(s.settings.forecastMinWeeks);return r?r.salesEnough?{mode:'real',weeks:l,booked:n,sales:t.map(e=>s.kitchenHours[e.getDay()]?r.takingsByDay[e.getDay()]??0:0)}:{mode:'none',weeks:l,booked:n,sales:t.map(()=>0)}:{mode:'example',weeks:l,booked:n,sales:t.map(e=>{const t=(0,k.forecastToday)(s,a,o,i,e);return t.open?t.restOfDay.covers*_+t.restOfDay.takeaway*q:0})}},[s,a,o,i,r,(0,S.ymd)(e)])}function Q({init:e,onClose:t}){const n=(0,s.useOwner)(e=>e.staff),[a,o]=(0,l.useState)(e.shift?.start??12),[i,r]=(0,l.useState)(e.shift?.end??20),[d,c]=(0,l.useState)(e.shift?.breakAt),u=void 0===d||d>a&&dt.id===e.staffId),p=(0,s.leaveOn)((0,s.useOwner)(e=>e.leave),e.staffId,e.date);return(0,F.jsxs)(f.Sheet,{visible:!0,onClose:t,title:(0,Y.shiftTitle)(m?.name??'',e.date),testID:"shift-sheet",children:[p?(0,F.jsx)(f.Banner,{kind:"warn",title:`${(m?.name??'').replace(' (example)','')} has time off: ${(0,y.rangeLabel)(p.from,p.to)}`,children:"Only add a shift if they\u2019ve agreed to work."}):null,(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:[['Lunch',11,16],['Dinner',16.5,22.5],['Double',11,21],['Close',17,23.5],['Late close',18,25]].map(([e,t,s])=>(0,F.jsx)(f.Chip,{label:`${e} ${(0,T.fmtH)(t)}\u2013${(0,T.fmtH)(s)}`,selected:a===t&&i===s,onPress:()=>{o(t),r(s)}},e))}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{children:"Start"}),(0,F.jsx)(f.Stepper,{testID:"shift-start",value:a,step:.5,min:Y.SHIFT_MIN_START,max:i-1,onChange:o,format:T.fmtH,label:"Start time"})]}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:"End"}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.Stepper,{testID:"shift-end",value:i,step:.5,min:a+1,max:Y.SHIFT_MAX_END,onChange:r,format:T.fmtH,label:"End time"}),i>=24?(0,F.jsx)(f.Muted,{children:"next day"}):null]})]}),(0,F.jsxs)(f.Muted,{children:[(i-a).toFixed(1),"h scheduled",K(i-a)?`, ${Math.round(60*K(i-a))}m planned break`:'']}),(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,F.jsx)(f.T,{children:void 0===d?'Break: not set':'Break at'}),void 0===d?(0,F.jsx)(f.Chip,{label:"Set a break time",onPress:()=>c(Math.min(i-.5,Math.max(a+.5,Math.round(4*(a+Math.min(4,(i-a)/2)))/4)))}):(0,F.jsxs)(f.Row,{gap:6,children:[(0,F.jsx)(f.Stepper,{testID:"shift-break",value:d,step:.25,min:a+.25,max:i-.25,onChange:c,format:T.fmtH,label:"Break time"}),(0,F.jsx)(f.Chip,{label:"No set time",onPress:()=>c(void 0)})]})]}),(0,F.jsx)(f.Muted,{children:"Tip: with a break time, the person on this shift gets a break reminder at that time. Without one, they get it 4 hours after clocking in (change this in Settings, Advanced, Reminders)."}),(0,F.jsx)(f.Button,{label:e.shift?'Save shift':'Add shift',onPress:()=>{const n=s.useOwner.getState();e.shift?n.setShifts(n.shifts.map(t=>t.id===e.shift.id?{...t,start:a,end:i,breakAt:u?d:void 0,changed:!!t.published||t.changed}:t)):n.addShift({staffId:e.staffId,date:e.date,start:a,end:i,...void 0!==d&&u?{breakAt:d}:{}}),t()}}),(0,F.jsx)(f.Muted,{children:e.shift?.published?'Published: the change shows in the Staff app straight away and is marked as changed until you publish the week again.':'Draft: staff see it once you publish the week.'}),e.shift?(0,F.jsx)(f.Button,{kind:"danger",label:"Remove shift",onPress:()=>{s.useOwner.getState().removeShift(e.shift.id),t()}}):null]})}const X=6;function J(e,t){const s=1===t?150:e>=1100?190:e>=860?170:140,n=e?e-s-t*X:0,a=n>0?Math.floor(n/t):0,o=1===t?Math.max(150,Math.min(320,a||150)):Math.max(76,Math.min(196,a||92));return{name:s,cell:o,width:s+t*(o+X),big:o>=104,fits:!e||s+t*(o+X)<=e}}const Z={position:'sticky',top:0};function ee({fits:e,children:t}){return e?(0,F.jsx)(h.default,{style:{alignItems:'center'},children:t}):(0,F.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!0,contentContainerStyle:{flexGrow:1,justifyContent:'center'},children:t})}function te({rid:e,today:t,now:n}){const a=(0,s.useOwner)(e=>e.staff).filter(e=>e.active),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,T.useSignedIn)(),{me:r,meId:d}=(0,T.useCtx)(3e4),[c,u]=(0,l.useState)(null),[h,m]=(0,l.useState)(''),[p,g]=(0,l.useState)(null),x=c?o.filter(e=>e.staffId===c&&e.in&&!e.out&&n.getTime()-new Date(e.in).getTime()<72e6)[0]:void 0,b=!!x&&(0,s.isOnBreak)(x),j=s=>{if(!c)return;const n=(0,R.managerClockAction)(s,{rid:e,staffId:c,date:t,at:(new Date).toISOString()},{id:i?.id??d,name:i?.name??r},h);if(!n.ok)return void g(n.message);const o=a.find(e=>e.id===c)?.name??'them';(0,B.notify)({id:'mgr-clock',title:`Recorded for ${o}`,body:`Reason kept with the record: ${h.trim()}`,timeoutMs:6e3}),m(''),g(null)};return(0,F.jsxs)(f.Card,{children:[(0,F.jsx)(f.T,{weight:"semibold",children:"Record it for someone"}),(0,F.jsx)(f.Muted,{children:"If someone\u2019s phone can\u2019t share its location, you can clock them in or out, or start or end their break. No location check; your reason is kept with the record."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:a.map(e=>(0,F.jsx)(f.Chip,{label:e.name,selected:c===e.id,onPress:()=>u(e.id)},e.id))}),c?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Field,{label:"Reason (kept with the record)",value:h,onChangeText:m,placeholder:"e.g. Phone out of battery"}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:x?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(f.Button,{kind:"secondary",label:b?'End their break':'Start their break',onPress:()=>j(b?'break_end':'break_start')}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Clock them out",onPress:()=>j('out')})]}):(0,F.jsx)(f.Button,{testID:"mgr-clock-in",kind:"secondary",label:"Clock them in",onPress:()=>j('in')})}),p?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:p}):null]}):null]})}function se({onClose:e}){const{now:t,today:n,meId:a}=(0,T.useCtx)(3e4),o=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),i=(0,s.useOwner)(e=>e.shifts),r=Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),[d,c]=(0,l.useState)(n),u=o.filter(e=>e.staffId===a&&e.date===d&&e.in).sort((e,t)=>t.in.localeCompare(e.in))[0],h=(0,s.visibleShifts)(i,!1).find(e=>e.staffId===a&&e.date===d),[m,p]=(0,l.useState)(u&&!u.out?'out':'in'),[x,b]=(0,l.useState)(h?Math.round(60*h.start):720),[j,w]=(0,l.useState)(h?Math.round(60*h.end):1200),[y,k]=(0,l.useState)(''),[I,D]=(0,l.useState)(!1),v=e=>`${String(Math.floor(e%1440/60)).padStart(2,'0')}:${String(e%60).padStart(2,'0')}`,$='out'!==m,O='in'!==m,M=$&&O&&j<=x,P=(e,t)=>(0,F.jsx)(f.Row,{gap:4,children:[-15,-5,5,15].map(s=>(0,F.jsx)(f.Button,{small:!0,kind:"ghost",label:s>0?`+${s}`:`${s}`,onPress:()=>e(Math.max(0,Math.min(2160,t+s)))},s))});return I?(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"Request sent",children:[(0,F.jsx)(f.Banner,{kind:"success",title:"Sent to your manager",children:"They\u2019ll see it on the sign-off screen and fix the time. You\u2019ll see the change on your timesheet. Nothing is sent by text or email."}),(0,F.jsx)(f.Button,{label:"Done",onPress:e})]}):(0,F.jsxs)(f.Sheet,{visible:!0,onClose:e,title:"I forgot to clock in or out",testID:"request-sheet",children:[(0,F.jsx)(f.Muted,{children:"Pick the day and suggest the right time. Your manager checks it before it counts."}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,children:r.map(e=>(0,F.jsx)(f.Chip,{label:e===n?'Today':(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,10),selected:d===e,onPress:()=>c(e)},e))}),(0,F.jsxs)(f.Muted,{children:[h?`Your rota that day: ${(0,T.fmtH)(h.start)}\u2013${(0,T.fmtH)(h.end)}`:'Not on the rota that day',u?` \xb7 clocked ${(0,S.hm)(new Date(u.in))}\u2013${u.out?(0,S.hm)(new Date(u.out)):'no clock-out'}`:' \xb7 no clock record']}),(0,F.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,F.jsx)(f.Chip,{label:"Forgot to clock in",selected:'in'===m,onPress:()=>p('in')}),(0,F.jsx)(f.Chip,{label:"Forgot to clock out",selected:'out'===m,onPress:()=>p('out')}),(0,F.jsx)(f.Chip,{label:"Forgot both",selected:'both'===m,onPress:()=>p('both')})]}),$?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["In ",v(x)]}),P(b,x)]}):null,O?(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(f.T,{size:18,weight:"bold",children:["Out ",v(j),j>=1440?' (next day)':'']}),P(w,j)]}):null,M?(0,F.jsx)(f.T,{size:13,colour:C.colours.red,children:"Clock-out must be after clock-in."}):null,(0,F.jsx)(f.Field,{label:"Note for your manager (optional)",value:y,onChangeText:k,placeholder:"e.g. phone died",maxLength:200}),(0,F.jsx)(f.Button,{testID:"request-send",kind:"success",label:"Send to my manager",disabled:M,onPress:()=>{s.useOwner.getState().addTimeRequest({staffId:a,date:d,attendanceId:u?.id,kind:m,suggestedIn:$?(0,g.isoAt)(d,x):void 0,suggestedOut:O?(0,g.isoAt)(d,j):void 0,note:y.trim(),at:t.toISOString()}),D(!0)}})]})}function ne(){const{now:e,today:t,meId:n}=(0,T.useCtx)(3e4),a=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),o=(0,s.useOwner)(e=>e.shifts),i=(0,s.useOwner)(e=>e.timeRequests),[r,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(null),m=(0,S.ymd)(U(e)),p=a.filter(e=>e.staffId===n&&e.in&&e.date>=(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(t),-38880))).sort((e,t)=>t.date.localeCompare(e.date)||t.in.localeCompare(e.in)),x=p.filter(e=>e.date>=m),b=x.filter(s.isConfirmed).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),j=x.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),w=i.filter(e=>e.staffId===n).sort((e,t)=>t.at.localeCompare(e.at)).slice(0,6);return(0,F.jsxs)(h.default,{style:{gap:10},testID:"my-timesheet",children:[(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',alignItems:'flex-end'},children:[(0,F.jsxs)(h.default,{children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"CONFIRMED THIS WEEK"}),(0,F.jsx)(f.T,{size:28,weight:"bold",colour:C.colours.ok,children:(0,T.hmDur)(b)})]}),(0,F.jsxs)(h.default,{style:{alignItems:'flex-end'},children:[(0,F.jsx)(f.T,{size:12,colour:C.colours.muted,children:"PENDING SIGN-OFF"}),(0,F.jsx)(f.T,{size:18,weight:"semibold",colour:j?C.colours.amber:C.colours.muted,children:(0,T.hmDur)(j)})]})]}),(0,F.jsx)(f.Muted,{children:"Your manager signs off your hours. Only confirmed hours count for pay. You can\u2019t change your own times; ask for a correction instead."})]}),(0,F.jsx)(f.Button,{testID:"forgot-clock",kind:"secondary",label:"I forgot to clock in or out",onPress:()=>d(!0)}),w.length?(0,F.jsx)(D.SectionHead,{title:"My correction requests"}):null,w.map(e=>(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsxs)(f.T,{size:14,children:[(0,S.niceDate)((0,S.parseYmd)(e.date))," \xb7 ",'in'===e.kind?'Forgot to clock in':'out'===e.kind?'Forgot to clock out':'Forgot both']}),(0,F.jsxs)(f.Muted,{children:[e.suggestedIn?`in ${(0,S.hm)(new Date(e.suggestedIn))} `:'',e.suggestedOut?`out ${(0,S.hm)(new Date(e.suggestedOut))}`:'',e.resolvedBy?` \xb7 ${'applied'===e.status?'applied':'declined'} by ${e.resolvedBy.replace(' (example)','')}`:'']})]}),(0,F.jsx)(f.Badge,{kind:'open'===e.status?'blue':'applied'===e.status?'ok':'neutral',label:'open'===e.status?'Waiting':'applied'===e.status?'Applied':'Declined'})]},e.id)),(0,F.jsx)(D.SectionHead,{title:"My shifts",sub:"Last 4 weeks"}),p.map(t=>{const n=(0,s.shiftOf)((0,s.visibleShifts)(o,!1),t.staffId,t.date),a=(0,T.paidMins)(t,e),i=t.audit?.filter(e=>'confirmed'!==e.action).slice(-1)[0];return(0,F.jsxs)(f.Card,{onPress:()=>u(c===t.id?null:t.id),children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsxs)(h.default,{style:{flex:1},children:[(0,F.jsx)(f.T,{weight:"semibold",children:(0,S.niceDate)((0,S.parseYmd)(t.date))}),(0,F.jsxs)(f.Muted,{children:[(0,S.hm)(new Date(t.in)),"\u2013",t.out?(0,S.hm)(new Date(t.out)):'on now',t.out?` \xb7 ${a.brk}m break \xb7 ${(0,T.hmDur)(a.paid)} paid`:'',n?` \xb7 rota ${(0,T.fmtH)(n.start)}\u2013${(0,T.fmtH)(n.end)}`:'']})]}),(0,F.jsx)(f.Badge,{kind:(0,g.statusKind)(t),label:'awaiting'===(0,s.attStatus)(t)?t.adjusted?'Adjusted \xb7 pending':'Pending':(0,g.statusLabel)(t)})]}),i?(0,F.jsxs)(f.T,{size:13,colour:C.colours.gold,children:["Adjusted by ",i.by.replace(' (example)',''),i.reason?`: ${i.reason}`:'']}):null,t.signOff?(0,F.jsxs)(f.Muted,{children:["Confirmed by ",t.signOff.by.replace(' (example)','')]}):null,c===t.id?(0,F.jsx)(g.AuditTrail,{a:t}):null]},t.id)}),p.length?null:(0,F.jsx)(f.Muted,{children:"No clocked shifts yet."}),r?(0,F.jsx)(se,{onClose:()=>d(!1)}):null]})}function ae({now:e,today:n}){const o=(0,s.useOwner)(e=>e.staff),i=(0,s.useOwner)(e=>e.shifts),r=(0,T.useHourly)(),d=(0,s.useOwner)(e=>(0,s.liveAttendance)(e.attendance)),u=(0,s.useOwner)(e=>e.timeRequests),m=(0,s.useOwner)(e=>e.leave),x=(0,s.useOwner)(e=>e.attLog),[b,j]=(0,l.useState)(n),[w,y]=(0,l.useState)(null),[k,v]=(0,l.useState)(!1),[O,M]=(0,l.useState)(!1),P=!!(0,T.useSignedIn)(),R=O?(0,L.pastWeekDays)(b,n):Array.from({length:7},(e,t)=>(0,S.ymd)((0,S.addMins)((0,S.parseYmd)(n),1440*-t))),B=d.filter(e=>e.date===b&&e.in),z=i.filter(e=>e.date===b&&!1!==e.published).filter(e=>!B.some(t=>t.staffId===e.staffId)),A=d.filter(e=>R.includes(e.date)&&e.out),H=A.filter(s.isConfirmed),Y=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),W=A.filter(e=>!(0,s.isConfirmed)(e)).reduce((t,s)=>t+(0,T.paidMins)(s,e).paid,0),E=H.reduce((t,s)=>t+(0,T.paidMins)(s,e).paid/60*(r[s.staffId]??0),0),_=['Staff,Date,Rostered,In,Out,Break (min),Paid hours,Rate,Pay,Status,Confirmed by,Tax note'].concat(H.sort((e,t)=>e.date.localeCompare(t.date)).map(t=>{const n=o.find(e=>e.id===t.staffId),a=(0,s.shiftOf)(i,t.staffId,t.date),l=(0,T.paidMins)(t,e),d=r[t.staffId]??0;return`${n?.name},${t.date},${a?`${(0,T.fmtH)(a.start)}-${(0,T.fmtH)(a.end)}`:'-'},${(0,S.hm)(new Date(t.in))},${(0,S.hm)(new Date(t.out))},${l.brk},${(l.paid/60).toFixed(2)},${(d/100).toFixed(2)},${(l.paid/60*d/100).toFixed(2)},${t.adjusted?'Confirmed (adjusted)':'Confirmed'},${t.signOff?.by??''},${n?.salaried?'Owner, no hourly wage':null==r[t.staffId]?'Rate not set':n?.noTax&&P?'No tax deducted':''}`}));return(0,F.jsxs)(h.default,{style:{gap:10},children:[(0,F.jsx)(N.HoursDayPicker,{testID:"ts-pick",date:b,today:n,custom:O,onDate:e=>{j(e),M(!0)},resetLabel:"Back to the last 7 days",onReset:()=>{j(n),M(!1)}}),(0,F.jsx)(f.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:R.map(e=>(0,F.jsx)(f.Chip,{testID:`ts-day-${e}`,accessibilityLabel:`${(0,L.longDay)(e)}${e===n?', today':''}`,label:e===n?'Today':O?(0,L.chipDay)(e):(0,S.niceDate)((0,S.parseYmd)(e)).slice(0,6).trim(),selected:b===e,onPress:()=>j(e)},e))}),(0,F.jsxs)(f.Card,{children:[(0,F.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,F.jsx)(f.T,{weight:"semibold",testID:"ts-week-title",children:O?(0,L.weekTitle)(b,n):'Last 7 days'}),(0,F.jsx)(f.Badge,{kind:"ok",label:`${(0,T.hmDur)(Y)} confirmed`})]}),W?(0,F.jsxs)(f.T,{size:13,colour:C.colours.amber,children:[(0,T.hmDur)(W)," pending sign-off (not counted yet)"]}):null,(0,F.jsxs)(f.Muted,{children:["Labour cost ",(0,I.gbp)(Math.round(E))," from confirmed hours (paid hours \xd7 hourly rates; owner salaries excluded). Sign off in Team \u203a Sign off hours."]})]}),(0,F.jsx)(a.WideTable,{children:(0,F.jsxs)(h.default,{style:{gap:2},children:[(0,F.jsx)(a.TRow,{head:!0,style:{borderBottomWidth:1,borderColor:C.colours.border,paddingBottom:4},children:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''].map((e,t)=>(0,F.jsx)(f.T,{size:12,weight:"semibold",colour:C.colours.gold,style:{width:[110,86,52,52,52,74,120,140,50][t]},children:e},e+t))}),B.map(t=>{const l=o.find(e=>e.id===t.staffId),r=(0,s.shiftOf)(i,t.staffId,b),d=(0,T.paidMins)(t,e),h=(0,g.flagsFor)(t,r,e,n,u).map(e=>e.label);return(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6,borderBottomWidth:1,borderColor:'#222'},children:[(0,F.jsxs)(f.Row,{gap:4,style:{width:110},children:[(0,F.jsx)($.StaffAvatar,{id:t.staffId,size:20,ring:!1}),(0,F.jsx)(f.T,{size:12,style:{flex:1},numberOfLines:1,testID:`ts-name-${t.staffId}`,children:l?.name.replace(' (example)','')})]}),(0,F.jsx)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:r?`${(0,T.fmtH)(r.start)}\u2013${(0,T.fmtH)(r.end)}`:'\u2013'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:(0,S.hm)(new Date(t.in))}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?(0,S.hm)(new Date(t.out)):'on'}),(0,F.jsx)(f.T,{size:12,style:{width:52},children:t.out?`${d.brk}m`:'\u2013'}),(0,F.jsx)(f.T,{size:12,weight:"semibold",style:{width:74},testID:`ts-paid-${t.staffId}`,children:t.out?(0,T.hmDur)(d.paid):`${(0,T.hmDur)(d.worked)}\u2026`}),(0,F.jsx)(f.T,{size:11,style:{width:120},colour:'confirmed'===(0,s.attStatus)(t)?C.colours.ok:'open'===(0,s.attStatus)(t)?C.colours.blue:C.colours.amber,children:(0,g.statusLabel)(t)}),(0,F.jsx)(f.T,{size:11,style:{width:140},colour:h.length?C.colours.amber:C.colours.ok,children:h.join(', ')||'OK'}),(0,F.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:`Edit ${l?.name}`,onPress:()=>y(t),style:{width:50,minHeight:44,justifyContent:'center'},children:(0,F.jsx)(f.T,{size:12,colour:C.colours.gold,children:"Edit"})})]},t.id)}),z.map(t=>(0,F.jsxs)(a.TRow,{heads:['Staff','Rostered','In','Out','Break','Paid hours','Status','Flags',''],style:{paddingVertical:6},children:[(0,F.jsx)(f.T,{size:12,style:{width:110},children:o.find(e=>e.id===t.staffId)?.name.replace(' (example)','')}),(0,F.jsxs)(f.T,{size:12,style:{width:86},colour:C.colours.muted,children:[(0,T.fmtH)(t.start),"\u2013",(0,T.fmtH)(t.end)]}),(()=>{const s=(0,p.leaveCovering)(m,t.staffId,t.date);return s?(0,F.jsxs)(f.T,{size:12,colour:C.colours.blue,testID:`ts-leave-${t.staffId}`,children:[(0,p.leaveLabel)(s)," (rota covered)"]}):(0,F.jsx)(f.T,{size:12,colour:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?C.colours.muted:C.colours.red,children:b===n&&60*t.start>60*e.getHours()+e.getMinutes()?'Not started yet':'No clock-in'})})()]},t.id))]})}),B.length||z.length?null:(0,F.jsx)(f.Muted,{children:"No shifts or clock records for this day."}),(0,F.jsx)(f.Muted,{children:"Paid hours = (clock-out \u2212 clock-in) \u2212 break. Only confirmed hours count for pay, tips and the export."}),(0,F.jsx)(f.Button,{kind:"secondary",label:"Payroll export (CSV preview)",onPress:()=>v(!0)}),(0,F.jsx)(D.SectionHead,{title:"Audit log",sub:"Every manual change and sign-off"}),x.length?x.slice(0,12).map(e=>(0,F.jsxs)(f.Muted,{children:[(0,S.niceDate)(new Date(e.at))," ",(0,S.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,F.jsx)(f.Muted,{children:"No manual changes yet."}),w?(0,F.jsx)(g.OverrideSheet,{a:w,staffId:w.staffId,date:w.date,onClose:()=>y(null)}):null,(0,F.jsxs)(f.Sheet,{visible:k,onClose:()=>v(!1),title:"Payroll export",children:[(0,F.jsxs)(f.Banner,{kind:"demo",title:"Preview: nothing is sent",children:["Confirmed hours only. ",W?`${(0,T.hmDur)(W)} still pending sign-off is left out.`:'']}),(0,F.jsxs)(h.default,{style:{backgroundColor:(0,t.soutersSurface)('#111'),borderRadius:8,padding:8},children:[_.slice(0,14).map((e,t)=>(0,F.jsx)(f.T,{size:10,colour:t?C.colours.text:C.colours.gold,children:e},t)),_.length>14?(0,F.jsxs)(f.Muted,{children:["\u2026 ",_.length-14," more rows"]}):null]}),(0,F.jsxs)(f.Muted,{children:[_.length-1," confirmed rows \xb7 paid hours (after breaks)."]})]})]})}},1213,[828,891,1214,1194,1006,1007,34,1013,1014,236,402,295,102,794,874,1098,1204,1182,1215,1090,5,1216,1161,867,858,821,1195,1180,1088,925,1042,997,998,1095,1001,1097,1166,1164,1207,1209,1091,25]); +__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,"useHrSettings",{enumerable:!0,get:function(){return f}}),_e.MoraleScale=b,_e.StaffingSlider=j,_e.ShiftCheckout=function({rid:e,shiftKey:o,day:a,meId:d,onClose:y}){const w=f(e),S=w.wording,k=(0,i.useOwner)(e=>e.staff),C=(0,i.useOwner)(e=>(0,i.liveAttendance)(e.attendance)),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)('up'),[z,P]=(0,s.useState)(null),[W,A]=(0,s.useState)(''),[q,B]=(0,s.useState)(null),[N,E]=(0,s.useState)(!1),$=(0,s.useMemo)(()=>{const e=new Set(C.filter(e=>e.date===a&&e.staffId!==d).map(e=>e.staffId)),t=k.filter(e=>e.active&&e.id!==d&&!e.temp);return[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))].slice(0,14)},[k,C,a,d]),O=()=>{u.useHr.getState().skip(e,o),y()};return(0,c.jsx)(l.Sheet,{visible:!0,onClose:O,title:"How was today?",testID:"hr-checkout",children:N?(0,c.jsxs)(n.default,{testID:"hr-checkout-thanks",style:{gap:6,paddingVertical:10},children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",colour:r.colours.goldLight,center:!0,children:"Thanks. Sent anonymously."}),(0,c.jsx)(l.Muted,{center:!0,children:"Have a good evening."})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l.Muted,{size:13,children:S.intro}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.morale}),(0,c.jsx)(b,{value:v,onChange:T,w:S})]}),(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(l.T,{weight:"semibold",children:S.staffing}),(0,c.jsx)(j,{value:R,onChange:M,w:S})]}),w.askQuestion||w.askShout?(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[w.askQuestion?(0,c.jsx)(l.Chip,{testID:"hr-more-question",label:"\uff0b Ask the team a question",selected:'q'===q,onPress:()=>B('q'===q?null:'q')}):null,w.askShout?(0,c.jsx)(l.Chip,{testID:"hr-more-shout",label:"\uff0b Shout out a teammate",selected:'shout'===q,onPress:()=>B('shout'===q?null:'shout')}):null]}):null,'q'===q&&w.askQuestion?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.question," Optional."]}),(0,c.jsx)(t.TextInput,{testID:"hr-question",accessibilityLabel:"Your question",value:I,onChangeText:D,maxLength:280,multiline:!0,placeholder:"e.g. Could we start staff meals earlier?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===H,onPress:()=>L('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===H,onPress:()=>L('yesno')})]})]}):null,'shout'===q&&w.askShout?(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Muted,{size:13,children:[S.shout," Optional. Your name isn\u2019t shown."]}),(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:$.map(e=>(0,c.jsx)(l.Chip,{testID:`hr-shout-${e.id}`,label:p(e.nickname||e.name).split(' ')[0],selected:z===p(e.nickname||e.name).split(' ')[0],onPress:()=>{const t=p(e.nickname||e.name).split(' ')[0];P(z===t?null:t)}},e.id))}),z?(0,c.jsx)(t.TextInput,{testID:"hr-shout-note",accessibilityLabel:"What for (optional)",value:W,onChangeText:A,maxLength:140,placeholder:"What for? (optional)",placeholderTextColor:r.colours.muted,style:x}):null]}):null,(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-checkout-send",label:"Send anonymously",disabled:null==v&&null==R,onPress:()=>{u.useHr.getState().submit({rid:e,shiftKey:o,day:a,morale:v??3,staffing:R,question:w.askQuestion&&I.trim()?I:void 0,kind:H,shoutTo:w.askShout&&z?z:void 0,shoutBody:W||void 0}),E(!0),setTimeout(y,2400)},style:{flexGrow:1}}),(0,c.jsx)(l.Button,{testID:"hr-checkout-skip",kind:"ghost",label:"Skip",onPress:O})]}),(0,c.jsxs)(l.Muted,{size:12,children:["No name, no staff number and no clock time is saved with these answers. Managers only see a day once ",h.MIN_ANSWERS," or more people have answered."]})]})})},_e.QuestionBoard=function({rid:e,today:o,manager:i,by:a}){const d=f(e);(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,o),u.hrRemote.live&&u.hrRemote.refresh&&u.hrRemote.refresh()},[e,o]);const p=(0,u.useHr)(e=>e.questions),y=(0,u.useHr)(e=>e.voted),b=(0,u.useHr)(e=>e.log),[j,S]=(0,s.useState)(''),[k,C]=(0,s.useState)('up'),[v,T]=(0,s.useState)(null),[R,M]=(0,s.useState)(null),[I,D]=(0,s.useState)(''),[H,L]=(0,s.useState)(null),[z,P]=(0,s.useState)(''),[W,A]=(0,s.useState)(!1),[q,B]=(0,s.useState)(null);(0,s.useEffect)(()=>{i&&W&&u.hrRemote.live&&u.hrRemote.log&&u.hrRemote.log(e).then(e=>B(e))},[i,W,e,b.length]);const N=(0,h.boardOrder)(p.filter(t=>t.venue===e),i),E=(q??b.filter(t=>t.venue===e)).slice(0,30);if(!d.board)return(0,c.jsx)(l.Card,{children:(0,c.jsxs)(l.Muted,{children:["The question board is switched off for this venue.",i?' Turn it on in Settings \u203a Advanced \u203a Shift check-out & question board.':'']})});return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-board",children:[(0,c.jsx)(l.Muted,{children:"Ask anything about work. No names are shown or saved, not even to managers. Vote on what matters to you."}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Post a question"}),(0,c.jsx)(t.TextInput,{testID:"hr-board-input",accessibilityLabel:"Your question",value:j,onChangeText:e=>{S(e),T(null)},maxLength:280,multiline:!0,placeholder:"e.g. Can the rota go up by Thursday?",placeholderTextColor:r.colours.muted,style:[x,{minHeight:64}]}),(0,c.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'space-between'},children:[(0,c.jsxs)(l.Row,{wrap:!0,gap:6,children:[(0,c.jsx)(l.Chip,{label:"Vote up",selected:'up'===k,onPress:()=>C('up')}),(0,c.jsx)(l.Chip,{label:"Yes / No",selected:'yesno'===k,onPress:()=>C('yesno')})]}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-board-post",label:"Post anonymously",disabled:!(0,h.cleanQuestion)(j),onPress:()=>{u.useHr.getState().post(e,j,k,o)?(S(''),T('Posted anonymously.')):T('Write a few more words first.')}})]}),v?(0,c.jsx)(l.Muted,{size:13,children:v}):null]}),N.length?N.map(e=>(0,c.jsx)(w,{q:e,mine:y[e.id],manager:i,onHide:()=>{M(e),D('')},onReply:()=>{L(e),P(e.reply??'')},by:a},e.id)):(0,c.jsx)(l.Muted,{center:!0,children:"No questions yet. Be the first."}),i?(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",center:!0,children:"Moderation log"}),(0,c.jsx)(l.Button,{small:!0,kind:"secondary",testID:"hr-log-toggle",label:W?'Hide moderation log':'Show moderation log',onPress:()=>A(!W)}),(0,c.jsx)(l.Muted,{size:13,children:"Every hide, unhide and reply is logged with who did it and when. Questions never show who asked."}),W?E.length?E.map(e=>(0,c.jsxs)(n.default,{testID:"hr-log-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:['hide'===e.action?'Hidden':'unhide'===e.action?'Shown again':'Replied'," by ",e.by]}),(0,c.jsxs)(l.Muted,{size:12,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}),e.reason?` \xb7 ${e.reason}`:'']})]},e.id)):(0,c.jsx)(l.Muted,{children:"Nothing logged yet."}):null]}):null,(0,c.jsxs)(l.Sheet,{visible:!!R,onClose:()=>M(null),title:"Hide this question?",testID:"hr-hide-sheet",children:[(0,c.jsx)(l.Muted,{children:"It disappears for staff straight away. You can show it again later. This is logged with your name."}),(0,c.jsx)(t.TextInput,{testID:"hr-hide-reason",accessibilityLabel:"Reason",value:I,onChangeText:D,maxLength:140,placeholder:"Reason, e.g. rude or names someone",placeholderTextColor:r.colours.muted,style:x}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-hide-confirm",kind:"danger",label:"Hide",disabled:I.trim().length<3,onPress:()=>{R&&u.useHr.getState().moderate(R.id,'hide',I,a),M(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>M(null)})]})]}),(0,c.jsxs)(l.Sheet,{visible:!!H,onClose:()=>L(null),title:"Reply to the team",testID:"hr-reply-sheet",children:[H?(0,c.jsxs)(l.Muted,{children:["\u201c",H.body,"\u201d"]}):null,(0,c.jsx)(t.TextInput,{testID:"hr-reply-input",accessibilityLabel:"Your reply",value:z,onChangeText:P,maxLength:600,multiline:!0,placeholder:"Your reply, shown under the question",placeholderTextColor:r.colours.muted,style:[x,{minHeight:80}]}),(0,c.jsx)(l.Muted,{size:12,children:"Shown as \u201cReply from the managers\u201d. Your name is kept in the moderation log only."}),(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{testID:"hr-reply-save",label:"Post reply",disabled:!z.trim(),onPress:()=>{H&&u.useHr.getState().reply(H.id,z,a),L(null)}}),(0,c.jsx)(l.Button,{kind:"ghost",label:"Cancel",onPress:()=>L(null)})]})]})]})},_e.coversByDay=k,_e.exampleCovers=C,_e.MoraleTrend=function({rid:e,today:t}){const o=f(e).wording;(0,s.useEffect)(()=>{u.useHr.getState().ensure(e,t)},[e,t]);const[i,a]=(0,s.useState)(14),p=(0,u.useHr)(e=>e.checkins),x=(0,u.useHr)(e=>e.shouts),b=(0,d.useBookings)(e),j=(0,s.useMemo)(()=>k(b),[b]),w=e=>j[e]??(z?C(e):void 0),v=S(t,-i),[T,R]=(0,s.useState)(null),[M,I]=(0,s.useState)(null);(0,s.useEffect)(()=>{let s=!0;return u.hrRemote.live&&u.hrRemote.trend&&u.hrRemote.trend(e,v,t).then(e=>{s&&R(e)}),u.hrRemote.live&&u.hrRemote.shouts&&u.hrRemote.shouts(e,S(t,-30)).then(e=>{s&&I(e)}),()=>{s=!1}},[e,v,t]);const D=(0,s.useMemo)(()=>(0,h.dayResults)(p.filter(s=>s.venue===e&&s.day>=v&&s.day<=t)),[p,e,v,t]),H=u.hrRemote.live,L=H?T??[]:D.shown,z=!H&&p.some(t=>t.venue===e&&t.example),P=(H?M??[]:x.filter(t=>t.venue===e)).slice().sort((e,t)=>t.day.localeCompare(e.day)).slice(0,8),W=L.length?Math.round(L.reduce((e,t)=>e+t.morale,0)/L.length*10)/10:null,A=Array.from({length:i},(e,s)=>S(t,1-i+s)),q=new Map(L.map(e=>[e.day,e]));return(0,c.jsxs)(n.default,{style:{gap:10},testID:"hr-trend",children:[(0,c.jsxs)(l.Muted,{children:["From the anonymous check-out when people clock out. A day only shows once ",h.MIN_ANSWERS," or more people have answered."]}),z?(0,c.jsx)(l.Banner,{kind:"example",title:"Example answers",children:"These are made-up answers so you can see how it looks. Real answers replace them once your team is signed in."}):null,(0,c.jsx)(l.Row,{wrap:!0,gap:6,children:[14,28,56].map(e=>(0,c.jsx)(l.Chip,{label:14===e?'2 weeks':28===e?'4 weeks':'8 weeks',selected:i===e,onPress:()=>a(e)},e))}),(0,c.jsxs)(l.Card,{children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:6,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:"Team morale"}),null!=W?(0,c.jsx)(l.Badge,{kind:"gold",label:`AVERAGE ${W} \xb7 ${(0,h.moraleWord)(Math.round(W),o).toUpperCase()}`}):null]}),(0,c.jsx)(n.default,{testID:"hr-trend-chart",accessibilityLabel:`Morale over the last ${i} days`,style:{height:110,flexDirection:'row',alignItems:'flex-end',gap:i>30?1:3,borderBottomWidth:1,borderColor:r.colours.border},children:A.map(e=>{const t=q.get(e);return(0,c.jsx)(n.default,{style:{flex:1,minWidth:0,height:'100%',justifyContent:'flex-end',alignItems:'center'},children:t?(0,c.jsx)(n.default,{style:{width:'100%',maxWidth:22,height:t.morale/5*100+"%",borderTopLeftRadius:4,borderTopRightRadius:4,backgroundColor:t.morale<2.5?r.colours.amber:r.colours.gold}}):(0,c.jsx)(n.default,{style:{width:4,height:4,borderRadius:2,backgroundColor:r.colours.border,marginBottom:2}})},e)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:12,children:y(A[0])}),(0,c.jsx)(l.Muted,{size:12,children:y(A[A.length-1])})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Bar height: average morale (1 low to 5 high). Amber: below 2.5. A dot: fewer than ",h.MIN_ANSWERS," answers or none."]})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Staffing vs Covers, night by night"}),L.length?L.slice().reverse().map(e=>(0,c.jsxs)(n.default,{testID:"hr-trend-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:8,gap:4},children:[(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},gap:6,wrap:!0,children:[(0,c.jsx)(l.T,{weight:"semibold",style:{flexShrink:1},children:y(e.day)}),(0,c.jsx)(l.T,{size:14,colour:r.colours.goldLight,style:{flexShrink:1},children:null!=w(e.day)?`${w(e.day)} Covers`:'No bookings'})]}),(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'center'},children:[(0,c.jsxs)(n.default,{style:{flex:1,minWidth:60,height:6,borderRadius:3,backgroundColor:r.colours.border},children:[null!=e.staffing?(0,c.jsx)(n.default,{style:{position:'absolute',left:`${e.staffing}%`,marginLeft:-6,top:-3,width:12,height:12,borderRadius:6,backgroundColor:r.colours.gold}}):null,(0,c.jsx)(n.default,{style:{position:'absolute',left:'50%',marginLeft:-1,top:-4,width:2,height:14,backgroundColor:r.colours.goldMuted}})]}),(0,c.jsx)(l.T,{size:13,style:{flexShrink:1,maxWidth:'55%'},children:null!=e.staffing?(0,h.staffingWord)(e.staffing,o):'\u2014'})]}),(0,c.jsxs)(l.Muted,{size:12,children:["Morale ",e.morale," \xb7 ",e.answers," answers \xb7 ",e.short," said short, ",e.perfect," perfect, ",e.over," over"]})]},e.day)):(0,c.jsxs)(l.Muted,{children:["No days with ",h.MIN_ANSWERS," or more answers yet."]}),!H&&D.held?(0,c.jsxs)(l.Muted,{size:12,children:[D.held," day",1===D.held?'':'s'," held back (fewer than ",h.MIN_ANSWERS," answers)."]}):null,(0,c.jsx)(l.Muted,{size:12,children:"Covers come from that day\u2019s bookings (cancelled and no-shows left out)."})]}),(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.T,{weight:"semibold",children:"Shout-outs"}),P.length?P.map(e=>(0,c.jsxs)(n.default,{testID:"hr-shout-row",style:{borderTopWidth:1,borderColor:r.colours.border,paddingTop:6},children:[(0,c.jsxs)(l.T,{size:14,children:[(0,c.jsx)(l.T,{size:14,weight:"semibold",colour:r.colours.goldLight,children:e.to}),e.body?`: ${e.body}`:'']}),(0,c.jsxs)(l.Muted,{size:12,children:[y(e.day)," \xb7 from a teammate"]})]},e.id)):(0,c.jsx)(l.Muted,{children:"No shout-outs yet."})]})]})},_e.HrSettingsCard=function({rid:e}){const o=(0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr),i=(0,h.hrSettingsOf)(o),d=t=>a.useStore.getState().updateSettings(e,{hr:{...i,...t}}),[u,f]=(0,s.useState)({});return(0,c.jsxs)(n.default,{style:{gap:8},testID:"hr-settings",children:[(0,c.jsx)(l.Toggle,{testID:"hr-set-on",label:"Ask a quick check-out when people clock out",value:i.on,onChange:e=>d({on:e})}),(0,c.jsx)(l.Toggle,{label:"Let them post a question for the board",value:i.askQuestion,onChange:e=>d({askQuestion:e})}),(0,c.jsx)(l.Toggle,{label:"Let them shout out a teammate",value:i.askShout,onChange:e=>d({askShout:e})}),(0,c.jsx)(l.Toggle,{testID:"hr-set-board",label:"Question board in the Staff, Head Chef and Managers apps",value:i.board,onChange:e=>d({board:e})}),(0,c.jsx)(l.Muted,{size:13,children:"Tip: it only shows after Clock out, never at clock in, and anyone can tap Skip. It\u2019s a card in the app, not a phone notification."}),(0,c.jsxs)(l.Muted,{size:13,children:["Tip: answers are anonymous. No name or staff number is saved, and a day\u2019s results only show once ",h.MIN_ANSWERS," people have answered."]}),(0,c.jsx)(l.T,{weight:"semibold",style:{marginTop:4},children:"Wording"}),v.map(({k:e,label:s})=>(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(l.Muted,{size:13,children:s}),(0,c.jsx)(t.TextInput,{testID:`hr-word-${e}`,accessibilityLabel:s,value:u[e]??i.wording[e],onChangeText:t=>f({...u,[e]:t}),onBlur:()=>{null!=u[e]&&(d({wording:{...i.wording,[e]:u[e].trim()||h.DEFAULT_HR.wording[e]}}),f(t=>{const s={...t};return delete s[e],s}))},maxLength:'intro'===e||'staffing'===e||'question'===e?160:60,multiline:'intro'===e||'staffing'===e||'question'===e,placeholderTextColor:r.colours.muted,style:[x,'intro'===e||'staffing'===e||'question'===e?{minHeight:92,textAlignVertical:'top'}:null]})]},e)),(0,c.jsx)(l.Muted,{size:13,children:"Tip: keep it short and plain. Leave a box empty to go back to the standard words."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=e(_r(_d[2])),n=e(_r(_d[3])),l=_r(_d[4]),r=_r(_d[5]),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]),c=_r(_d[11]);const f=e=>(0,h.hrSettingsOf)((0,a.useStore)(t=>t.restaurants.find(t=>t.id===e)?.settings?.hr)),p=e=>e.replace(' (example)','').trim(),x={minHeight:46,borderRadius:12,borderWidth:1,borderColor:r.colours.accentBorder,backgroundColor:r.colours.surface2,color:r.colours.text,paddingHorizontal:12,paddingVertical:10,fontSize:16},y=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});function b({value:e,onChange:t,w:s}){return(0,c.jsxs)(n.default,{style:{gap:6},testID:"hr-morale",children:[(0,c.jsx)(l.Row,{gap:6,style:{justifyContent:'space-between'},children:h.MORALE_STEPS.map(n=>{const i=e===n;return(0,c.jsx)(o.default,{testID:`hr-morale-${n}`,accessibilityRole:"button",accessibilityState:{selected:i},accessibilityLabel:`Morale ${n} of 5: ${(0,h.moraleWord)(n,s)}`,onPress:()=>t(n),hitSlop:4,style:{flex:1,minWidth:0,minHeight:48,borderRadius:12,borderWidth:1,borderColor:i?r.colours.gold:r.colours.border,backgroundColor:i?r.colours.goldTint:r.colours.surface2,alignItems:'center',justifyContent:'center'},children:(0,c.jsx)(l.T,{size:18,weight:"bold",colour:i?r.colours.goldLight:r.colours.text,children:n})},n)})}),(0,c.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1},children:s.moraleLow}),e?(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,style:{flexShrink:1,textAlign:'center'},children:(0,h.moraleWord)(e,s)}):null,(0,c.jsx)(l.Muted,{size:13,style:{flexShrink:1,textAlign:'right'},children:s.moraleHigh})]})]})}function j({value:e,onChange:t,w:i}){const a=(0,s.useRef)(null),d=(0,s.useRef)(0),u=(0,s.useRef)(1),f=()=>{a.current?.measureInWindow?.((e,t,s)=>{d.current=e,u.current=Math.max(1,s)})},p=e=>t((0,h.snapStaffing)((e-d.current)/u.current*100)),x=e??50,y=null!=e;return(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(n.default,{testID:"hr-staffing",accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:`Staffing: ${y?(0,h.staffingWord)(x,i):'not answered'}`,accessibilityActions:[{name:'increment'},{name:'decrement'}],onAccessibilityAction:e=>{const s=h.STAFF_STOPS.indexOf((0,h.snapStaffing)(x)),o='increment'===e.nativeEvent.actionName?Math.min(8,s+1):Math.max(0,s-1);t(h.STAFF_STOPS[o])},onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderGrant:e=>{f(),p(e.nativeEvent.pageX)},onResponderMove:e=>p(e.nativeEvent.pageX),style:{height:48,justifyContent:'center',paddingHorizontal:15},children:(0,c.jsxs)(n.default,{ref:a,onLayout:f,style:{height:48,justifyContent:'center'},children:[(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border}}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:h.STAFF_STOPS.map(e=>(0,c.jsx)(n.default,{style:{width:e%50==0?4:2,height:e%50==0?18:10,borderRadius:2,backgroundColor:e%50==0?r.colours.goldMuted:r.colours.muted}},e))}),(0,c.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:`${x}%`,top:10,marginLeft:-14,width:28,height:28,borderRadius:14,borderWidth:2,borderColor:y?r.colours.gold:r.colours.muted,backgroundColor:y?r.colours.gold:r.colours.surface}})]})}),(0,c.jsx)(l.Row,{style:{justifyContent:'space-between',gap:8},children:[[0,i.staffLow],[50,i.staffMid],[100,i.staffHigh]].map(([e,s],n)=>(0,c.jsx)(o.default,{testID:`hr-staffing-${e}`,accessibilityRole:"button",accessibilityLabel:s,onPress:()=>t(e),hitSlop:6,style:{flexShrink:1,flexGrow:0,minWidth:0},children:(0,c.jsx)(l.T,{size:13,colour:y&&(0,h.snapStaffing)(x)===e?r.colours.goldLight:r.colours.muted,weight:y&&(0,h.snapStaffing)(x)===e?'semibold':'regular',style:{textAlign:0===n?'left':1===n?'center':'right'},children:s})},e))}),y&&(0,h.snapStaffing)(x)%50!=0?(0,c.jsx)(l.T,{size:13,colour:r.colours.goldLight,center:!0,children:(0,h.staffingWord)(x,i)}):null]})}function w({q:e,mine:t,manager:s,onHide:o,onReply:i,by:a}){const d=e.yes+e.no,h=d?Math.round(e.yes/d*100):0;return(0,c.jsx)(l.Card,{style:e.hidden?{opacity:.75}:void 0,children:(0,c.jsxs)(n.default,{testID:"hr-question-card",style:{gap:8},children:[(0,c.jsxs)(l.Row,{gap:8,style:{alignItems:'flex-start'},children:[(0,c.jsx)(l.T,{style:{flex:1,minWidth:0},children:e.body}),e.hidden?(0,c.jsx)(l.Badge,{kind:"amber",label:"HIDDEN"}):null]}),(0,c.jsxs)(l.Muted,{size:12,children:["Asked ",y(e.postedOn)," \xb7 anonymous"]}),'up'===e.kind?(0,c.jsx)(l.Row,{gap:8,wrap:!0,children:(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-up",kind:t?'success':'secondary',label:t?`\u25b2 Voted \xb7 ${e.up}`:`\u25b2 Vote up \xb7 ${e.up}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)})}):(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-yes",kind:1===t?'success':'secondary',label:`Yes \xb7 ${e.yes}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,1)}),(0,c.jsx)(l.Button,{small:!0,testID:"hr-vote-no",kind:-1===t?'success':'secondary',label:`No \xb7 ${e.no}`,disabled:!!t||e.hidden,onPress:()=>u.useHr.getState().vote(e.id,-1)})]}),d?(0,c.jsx)(n.default,{style:{height:6,borderRadius:3,backgroundColor:r.colours.border,overflow:'hidden'},children:(0,c.jsx)(n.default,{style:{width:`${h}%`,height:6,backgroundColor:r.colours.gold}})}):null,d?(0,c.jsxs)(l.Muted,{size:12,children:[h,"% yes from ",d," vote",1===d?'':'s']}):null]}),t?(0,c.jsx)(l.Muted,{size:12,children:"You\u2019ve voted. Votes are anonymous."}):null,e.reply?(0,c.jsxs)(n.default,{style:{borderLeftWidth:3,borderColor:r.colours.gold,paddingLeft:10,gap:2},children:[(0,c.jsx)(l.T,{size:13,weight:"semibold",colour:r.colours.goldLight,children:"Reply from the managers"}),(0,c.jsx)(l.T,{size:14,children:e.reply})]}):null,s?(0,c.jsxs)(l.Row,{gap:8,wrap:!0,children:[(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-reply",label:e.reply?'Edit reply':'Reply',onPress:i}),e.hidden?(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-unhide",label:"Show again",onPress:()=>u.useHr.getState().moderate(e.id,'unhide','',a)}):(0,c.jsx)(l.Button,{small:!0,kind:"ghost",testID:"hr-hide",label:"Hide",onPress:o})]}):null]})})}const S=(e,t)=>{const s=new Date(`${e}T12:00:00Z`);return s.setUTCDate(s.getUTCDate()+t),s.toISOString().slice(0,10)};function k(e){const t={};for(const s of e)'cancelled'!==s.status&&'noshow'!==s.status&&(t[s.date]=(t[s.date]??0)+(s.partySize||0));return t}function C(e){let t=0;for(const s of e)t=(31*t+s.charCodeAt(0))%997;return 40+t%90}const v=[{k:'intro',label:'Opening line'},{k:'morale',label:'Morale question'},{k:'moraleLow',label:'Morale: low end'},{k:'moraleHigh',label:'Morale: high end'},{k:'staffing',label:'Staffing question'},{k:'staffLow',label:'Staffing: left'},{k:'staffMid',label:'Staffing: middle'},{k:'staffHigh',label:'Staffing: right'},{k:'question',label:'Question prompt'},{k:'shout',label:'Shout-out prompt'}]},1214,[827,34,402,102,794,821,891,831,876,1006,1007,25]); +__d(function(_g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TeamOnDay=function({date:e,meId:t,label:b}){const f=(0,o.useOwner)(e=>e.shifts),g=(0,o.useOwner)(e=>e.staff),j=(0,o.useOwner)(e=>e.leave),y=(0,s.useMemo)(()=>(0,c.teamOnDay)((0,h.workingShifts)(f,j),g,e,t),[f,j,g,e,t]);return(0,p.jsxs)(n.default,{testID:`team-on-${e}`,accessible:!0,accessibilityLabel:(0,c.teamOnDaySpoken)(b,y),style:{gap:6,alignItems:'center',paddingVertical:4},children:[(0,p.jsxs)(l.T,{size:14,weight:"semibold",colour:u.colours.gold,center:!0,children:["Also on ",b]}),y.length?y.map(e=>(0,p.jsxs)(n.default,{testID:"team-on-dept",style:{gap:2,alignItems:'center'},children:[(0,p.jsx)(l.T,{size:13,weight:"semibold",center:!0,children:e.dept}),e.people.map(e=>(0,p.jsxs)(l.T,{size:13,center:!0,children:[e.name,e.job?(0,p.jsxs)(l.T,{size:13,colour:u.colours.muted,children:[" \xb7 ",e.job]}):null," \xb7 ",e.times]},e.id))]},e.dept)):(0,p.jsx)(l.Muted,{center:!0,size:13,children:"Nobody else is on the rota."})]})};var e,s=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),p=r(d[7])},1215,[34,102,794,891,1090,821,1098,25]); +__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,"daysBetween",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"rangeLabel",{enumerable:!0,get:function(){return h}}),_e.TimeOffSheet=b,_e.RequestTimeOff=function({meId:e,me:s,testID:l="request-time-off"}){const[d,f]=(0,t.useState)(!1),m=(0,o.ymd)(new Date),u=(0,r.useOwner)(e=>e.leave).filter(t=>t.staffId===e&&t.to>=m).sort((e,t)=>e.from.localeCompare(t.from));return(0,i.jsxs)(n.Card,{children:[(0,i.jsxs)(a.default,{testID:l,style:{gap:8,alignItems:'stretch'},children:[(0,i.jsx)(n.Button,{label:"Request time off",sub:"Holiday, appointments, days you can\u2019t work",testID:`${l}-open`,onPress:()=>f(!0)}),u.map(e=>(0,i.jsxs)(n.Row,{style:{justifyContent:'space-between',alignItems:'center'},gap:8,children:[(0,i.jsxs)(n.T,{size:14,style:{flex:1},children:[h(e.from,e.to)," \xb7 ",e.reason]}),(0,i.jsx)(n.Badge,{kind:'approved'===e.status?'ok':'declined'===e.status?'red':'amber',label:y(e.status)})]},e.id))]}),(0,i.jsx)(b,{visible:d,onClose:()=>f(!1),meId:e,me:s})]})};var t=_r(_d[0]),s=e(_r(_d[1])),a=e(_r(_d[2])),n=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),i=_r(_d[7]);const d=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],f=['January','February','March','April','May','June','July','August','September','October','November','December'],m=['Holiday','Appointment','Family','Other'],u=e=>(e??'').replace(' (example)',''),c=(e,t)=>Math.round(((0,o.parseYmd)(t).getTime()-(0,o.parseYmd)(e).getTime())/864e5)+1,h=(e,t)=>e===t?(0,o.niceDateYear)((0,o.parseYmd)(e)):`${(0,o.niceDateYear)((0,o.parseYmd)(e))} to ${(0,o.niceDateYear)((0,o.parseYmd)(t))}`,y=e=>'approved'===e?'Approved':'declined'===e?'Declined':'Waiting for a manager';function p({from:e,to:r,onChange:m,today:u}){const c=(0,o.parseYmd)(e||u),[h,y]=(0,t.useState)({y:c.getFullYear(),m:c.getMonth()}),p=(new Date(h.y,h.m,1).getDay()+6)%7,b=new Date(h.y,h.m+1,0).getDate(),x=[...Array(p).fill(null),...Array.from({length:b},(e,t)=>(0,o.ymd)(new Date(h.y,h.m,t+1)))],j=(0,o.parseYmd)(u),w=h.y>j.getFullYear()||h.y===j.getFullYear()&&h.m>j.getMonth(),D=e=>y(({y:t,m:s})=>{const a=new Date(t,s+e,1);return{y:a.getFullYear(),m:a.getMonth()}}),I=t=>{!e||e&&r||tD(-1)}),(0,i.jsxs)(n.T,{weight:"semibold",testID:"time-off-month",children:[f[h.m]," ",h.y]}),(0,i.jsx)(n.Button,{small:!0,kind:"ghost",label:"\u203a",accessibilityLabel:"Next month",testID:"time-off-next-month",onPress:()=>D(1)})]}),(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:d.map(e=>(0,i.jsx)(a.default,{style:{flex:1,alignItems:'center'},children:(0,i.jsx)(n.Muted,{children:e})},e))}),Array.from({length:Math.ceil(x.length/7)},(t,d)=>(0,i.jsx)(a.default,{style:{flexDirection:'row'},children:Array.from({length:7},(t,f)=>{const m=x[7*d+f];if(!m)return(0,i.jsx)(a.default,{style:{flex:1,height:40}},f);const c=me&&mI(m),style:{flex:1,height:40,margin:1,borderRadius:8,alignItems:'center',justifyContent:'center',backgroundColor:h?l.colours.gold:y?'#3a3020':'transparent',opacity:c?.35:1},children:(0,i.jsx)(n.T,{size:14,weight:h?'semibold':'regular',colour:h?'#1a1407':l.colours.text,children:Number(m.slice(8))})},f)})},d))]})}function b({visible:e,onClose:s,meId:l,me:d,manager:f}){const y=(0,r.useOwner)(e=>e.staff).filter(e=>e.active),b=(0,o.ymd)(new Date),[x,j]=(0,t.useState)(f?'':l),[w,D]=(0,t.useState)(''),[I,v]=(0,t.useState)(''),[S,Y]=(0,t.useState)('Holiday'),[C,T]=(0,t.useState)(null),M=I||w,A=!!x&&!!w&&M>=w,P=()=>{T(null),s()};return(0,i.jsx)(n.Sheet,{visible:e,onClose:P,title:f?'Add time off':'Request time off',testID:"time-off-sheet",children:C?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.Banner,{kind:"success",title:C}),(0,i.jsx)(n.Button,{label:"Done",testID:"time-off-done",onPress:P})]}):(0,i.jsxs)(i.Fragment,{children:[f?(0,i.jsxs)(a.default,{style:{gap:6},children:[(0,i.jsx)(n.T,{weight:"semibold",children:"Who\u2019s off?"}),(0,i.jsx)(n.Row,{wrap:!0,gap:6,children:y.filter(e=>'owner'!==e.role).map(e=>(0,i.jsx)(n.Chip,{testID:`time-off-who-${e.id}`,label:u(e.name),selected:x===e.id,onPress:()=>j(e.id)},e.id))})]}):null,(0,i.jsx)(n.Muted,{center:!0,children:w?I?'Tap a day to start again.':'Now tap your last day off (or tap Send for just that day).':'Tap your first day off.'}),(0,i.jsx)(p,{from:w,to:I,today:b,onChange:(e,t)=>{D(e),v(t)}}),w?(0,i.jsxs)(n.T,{center:!0,weight:"semibold",testID:"time-off-summary",children:[h(w,M)," \xb7 ",c(w,M)," ",1===c(w,M)?'day':'days']}):null,(0,i.jsx)(n.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:m.map(e=>(0,i.jsx)(n.Chip,{label:e,selected:S===e,onPress:()=>Y(e)},e))}),(0,i.jsx)(n.Button,{label:f?'Add time off':'Send request',testID:"time-off-send",disabled:!A,onPress:()=>{const e=r.useOwner.getState().addLeave({staffId:x,from:w,to:M,reason:S,by:u(d),...f?{status:'approved',decidedBy:u(d)}:{}}),t=u(y.find(e=>e.id===x)?.name);T(f?`${t} is off ${h(e.from,e.to)}. It shows on the rota now.`:`Sent: ${h(e.from,e.to)}. A manager will approve it, and you\u2019ll see it here.`),D(''),v('')}}),(0,i.jsx)(n.Muted,{center:!0,children:f?'Approved straight away. The rota shows them off and Copy last week won\u2019t give them shifts on those days.':'Your manager sees it in Rota \u203a Swaps & time off and approves it. Nothing is sent by text or email.'})]})})}},1216,[34,402,102,794,891,858,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.MyShiftCard=function({go:e}){const{now:t,today:l}=(0,d.useCtx)(3e4),c=(0,d.useSignedIn)(),j=(0,o.useOwner)(e=>(0,o.liveAttendance)(e.attendance)),x=(0,o.useOwner)(e=>e.shifts),p=(0,o.useOwner)(e=>e.leave);if(!c)return null;const b=(0,o.openShiftOf)(j,c.id,t),v=!!b?.breaks?.some(e=>!e.end),w=(0,h.workingShifts)(x,p).filter(e=>e.staffId===c.id&&e.date===l),k=(0,h.leaveCovering)(p,c.id,l),I=k?`${(0,h.leaveLabel)(k)} today`:w.length?w.map(e=>`${e.start}\u2013${e.end}`).join(', '):'Not on today\u2019s rota';return(0,u.jsx)(s.default,{testID:"my-shift-card",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shift"}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:I}),(0,u.jsx)(y,{staffId:c.id}),(0,u.jsx)(n.T,{center:!0,children:b?v?'On a break':`Clocked in since ${f(b.in)}`:'Not clocked in'}),(0,u.jsx)(n.Muted,{center:!0,size:12,children:"Tip: clock in and out here, the same as in the Front of House app. It checks you\u2019re at the venue."}),(0,u.jsxs)(n.Row,{gap:8,wrap:!0,children:[(0,u.jsx)(n.Button,{testID:"my-shift-clock",label:b?'Clock out / break':'Clock in',onPress:()=>e('more','clock')}),(0,u.jsx)(n.Button,{testID:"my-shift-rota",kind:"ghost",label:"My rota",onPress:()=>e('more','rota')}),(0,u.jsx)(n.Button,{testID:"my-shift-pay",kind:"ghost",label:"My pay & tips",onPress:()=>e('more','mypay')})]})]})})},_e.MyUpcomingShifts=y,r(_d[0]);var e,t=r(_d[1]),s=(e=t)&&e.__esModule?e:{default:e},n=r(_d[2]),o=r(_d[3]),a=r(_d[4]),d=r(_d[5]),l=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]);const f=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}):'';function y({staffId:e,team:t}){const{today:f}=(0,d.useCtx)(6e4),y=(0,o.useOwner)(e=>e.shifts),j=(0,o.useOwner)(e=>e.leave),x=y.filter(t=>t.staffId===e&&!1!==t.published&&t.date>=f).sort((e,t)=>(e.date+e.start).localeCompare(t.date+t.start)).slice(0,14),p=e=>new Date(`${e}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'});return(0,u.jsx)(s.default,{testID:"my-upcoming-shifts",children:(0,u.jsxs)(n.Card,{children:[(0,u.jsx)(n.T,{weight:"semibold",colour:a.colours.gold,center:!0,accessibilityRole:"header",children:"My shifts"}),x.length?x.map(o=>(0,u.jsxs)(s.default,{style:{gap:4},children:[(0,u.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(n.T,{children:p(o.date)}),(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(n.T,{colour:a.colours.blue,children:(0,h.leaveLabel)((0,h.leaveCovering)(j,o.staffId,o.date))}):(0,u.jsxs)(n.T,{children:[(0,l.fmtH)(o.start),"\u2013",(0,l.fmtH)(o.end)]})]}),t&&!(0,h.leaveCovering)(j,o.staffId,o.date)?(0,u.jsx)(c.TeamOnDay,{date:o.date,meId:e,label:p(o.date)}):null]},o.id)):(0,u.jsx)(n.Muted,{center:!0,children:"No shifts on the rota yet."})]})})}},1217,[34,102,794,891,821,1088,1091,1215,1098,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.WhoBar=function(){const e=(0,n.useSignedIn)();if(!e)return null;const l=`Signed in as ${e.name.replace(' (example)','')}${e.level?` \xb7 ${e.level}`:''}`;return(0,o.jsx)(t.default,{testID:"who-bar",dataSet:{centre:'heading'},accessible:!0,accessibilityLabel:l,style:{paddingVertical:4,alignItems:'center',alignSelf:'stretch',width:'100%'},children:(0,o.jsx)(c.T,{size:18,weight:"semibold",colour:s.colours.gold,center:!0,children:l})})},r(d[0]);var e,l=r(d[1]),t=(e=l)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),c=r(d[4]),o=r(d[5])},1218,[34,102,1088,821,794,25]); +__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:t,now:s,app:a,seeAll:c}){const p=(0,d.useSafety)(e=>e.accidents),[y,x]=(0,n.useState)(c?'list':'add'),w=p.filter(e=>e.reportedById===t),f=p.length-w.length;return(0,h.jsxs)(o.default,{style:{gap:12},testID:"accident-book",children:[(0,h.jsx)(u.Tabs,{value:y,onChange:x,options:[{id:'add',label:'Report an accident or near miss'},{id:'list',label:c?`All entries (${p.length})`:`My entries (${w.length})`}]}),'add'===y?(0,h.jsx)(j,{me:e,meId:t,now:s,app:a,onSaved:()=>x('list')}):null,'list'===y?(0,h.jsxs)(u.Box,{testID:"accident-list",children:[(c?p:w).length?(c?p:w).map(e=>(0,h.jsx)(b,{a:e,manager:c},e.id)):(0,h.jsx)(l.Muted,{children:"No entries yet."}),!c&&f>0?(0,h.jsx)(o.default,{testID:"accident-others",children:(0,h.jsxs)(l.Muted,{children:[f," other entr",1===f?'y is':'ies are'," in the book. Only managers can see other people\u2019s entries and personal details."]})}):null]}):null,(0,h.jsx)(l.Muted,{children:"In an emergency call 999 first. The accident book is kept on this device for now; nothing is sent or reported to anyone."})]})};var t=r(_d[0]),s=r(_d[1]),n=r(_d[2]),a=e(r(_d[3])),o=e(r(_d[4])),l=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]),h=r(_d[9]);const p=e=>String(e).padStart(2,'0'),y=e=>`${e.getFullYear()}-${p(e.getMonth()+1)}-${p(e.getDate())}T${p(e.getHours())}:${p(e.getMinutes())}`,x=e=>{const t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',year:'numeric'})} ${p(t.getHours())}:${p(t.getMinutes())}`};function j({me:e,meId:a,now:p,app:x,onSaved:j}){const[b,w]=(0,n.useState)({date:y(p).slice(0,10),time:y(p).slice(11),location:'',person:'',personType:'Staff',category:'',what:'',injury:'',firstAid:'',witnesses:'',reportedBy:e.replace(' (example)','')}),[f,T]=(0,n.useState)(''),[D,I]=(0,n.useState)(''),S=e=>w({...b,...e}),C='Near miss'===b.category,v=(e,s,n,a=!1)=>(0,h.jsxs)(o.default,{style:{gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:e}),(0,h.jsx)(t.TextInput,{accessibilityLabel:e,value:String(b[s]),onChangeText:e=>S({[s]:e}),placeholder:n,placeholderTextColor:"#7D776C",multiline:a,style:[l.styles.input,a&&{minHeight:70,textAlignVertical:'top'}]})]});return(0,h.jsxs)(u.Box,{testID:"accident-form",children:[(0,h.jsx)(l.T,{size:18,weight:"semibold",children:"Report an accident or near miss"}),(0,h.jsxs)(l.Row,{gap:8,children:[(0,h.jsxs)(o.default,{style:{flex:1,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Date (DD/MM/YYYY)"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Date (DD/MM/YYYY)",...(0,s.slashBox)(b.date,e=>S({date:e})),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[l.styles.input,{minWidth:0,width:40}]})]}),(0,h.jsxs)(o.default,{style:{width:110,gap:4},children:[(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"Time"}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"Time",value:b.time,onChangeText:e=>S({time:e}),placeholder:"HH:MM",placeholderTextColor:"#7D776C",style:l.styles.input})]})]}),(0,h.jsx)(l.T,{size:14,weight:"medium",colour:c.colours.muted,children:"What kind?"}),(0,h.jsx)(l.Row,{wrap:!0,gap:6,children:d.ACCIDENT_CATEGORIES.map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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,h.jsx)(l.Row,{wrap:!0,gap:6,children:['Staff','Customer','Contractor','Visitor'].map(e=>(0,h.jsx)(l.Chip,{label:e,selected:b.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'),f?(0,h.jsx)(l.Banner,{kind:"warn",children:f}):null,(0,h.jsx)(l.Button,{label:"Save to the accident book",testID:"accident-save",onPress:()=>/^\d{4}-\d{2}-\d{2}$/.test(b.date)&&/^([01]\d|2[0-3]):[0-5]\d$/.test(b.time)?b.category?b.location.trim()&&b.person.trim()&&b.what.trim()?(d.useSafety.getState().addAccident({when:`${b.date}T${b.time}`,location:b.location.trim(),person:b.person.trim(),personType:b.personType,category:b.category,what:b.what.trim(),injury:b.injury.trim()||(C?'None (near miss)':'Not recorded'),firstAid:b.firstAid.trim()||'None recorded',witnesses:b.witnesses.trim()||'None',reportedBy:b.reportedBy.trim()||e,reportedById:a,app:x}),I(`Saved to the accident book: ${b.category}, ${b.location.trim()}.`),T(''),w({...b,location:'',person:'',category:'',what:'',injury:'',firstAid:'',witnesses:''}),void j()):T('Fill in where it happened, who was involved and what happened.'):T('Pick what kind of accident or near miss it was.'):T('Enter the date as DD/MM/YYYY and the time as HH:MM.')}),D?(0,h.jsx)(o.default,{testID:"accident-saved",children:(0,h.jsx)(l.T,{size:14,colour:c.colours.ok,children:D})}):null,(0,h.jsx)(l.Muted,{children:"Personal details are only visible to managers. You can see your own entries."})]})}function b({a:e,manager:s}){const u=d.RIDDOR_CATEGORIES.includes(e.category),[p,y]=(0,n.useState)(e.riddorNote??''),[j,b]=(0,n.useState)(!1);return(0,h.jsxs)(o.default,{testID:"accident-entry",style:{paddingVertical:10,borderTopWidth:1,borderColor:c.colours.border,gap:4},children:[(0,h.jsxs)(a.default,{accessibilityRole:"button",accessibilityLabel:`${e.category} at ${e.location}`,onPress:()=>b(!j),children:[(0,h.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(l.T,{weight:"semibold",style:{flex:1},children:[e.category," \xb7 ",e.location]}),(0,h.jsx)(l.Badge,{kind:'Near miss'===e.category?'blue':u?'red':'amber',label:'Near miss'===e.category?'Near miss':u?'Serious':'Accident'})]}),(0,h.jsxs)(l.Muted,{children:[x(e.when)," \xb7 ",e.person," (",e.personType,") \xb7 reported by ",e.reportedBy]})]}),j||s?(0,h.jsxs)(o.default,{style:{gap:2},children:[(0,h.jsxs)(l.T,{size:14,children:["What happened: ",e.what]}),(0,h.jsxs)(l.T,{size:14,children:["Injury: ",e.injury]}),(0,h.jsxs)(l.T,{size:14,children:["First aid: ",e.firstAid]}),(0,h.jsxs)(l.T,{size:14,children:["Witnesses: ",e.witnesses]})]}):null,s&&u?(0,h.jsxs)(o.default,{testID:"riddor-prompt",style:{gap:6},children:[(0,h.jsx)(l.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. CoverCharge never reports anything for you."}),(0,h.jsx)(t.TextInput,{accessibilityLabel:"RIDDOR decision note",value:p,onChangeText:y,placeholder:"Your decision, e.g. reported on \u2026 ref \u2026, or not reportable because \u2026",placeholderTextColor:"#7D776C",style:l.styles.input}),(0,h.jsx)(l.Button,{small:!0,label:"Save note",disabled:p===(e.riddorNote??''),onPress:()=>d.useSafety.getState().setRiddorNote(e.id,p)}),e.riddorNote?(0,h.jsxs)(l.Muted,{children:["Saved note: ",e.riddorNote]}):null]}):null]})}},1219,[827,1063,34,402,102,794,1034,821,930,25]); +__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=S,_e.HaccpLog=function({me:e,meId:t,now:n,mode:s}){const[i,l]=(0,r.useState)('today'),d=(e,t)=>({id:e,label:t}),c='chef'===s?[d('today','Today'),d('units','Fridges & units'),d('record','Quick entry'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:'managers'===s?[d('today','Today'),d('units','Fridges & units'),d('diary','Diary'),d('weekly','Weekly sign-off'),d('report','EHO report'),d('history','History'),d('limits','Safe limits'),d('probes','Wireless probes')]:[d('today','Today'),d('record','Quick entry'),d('diary','Diary'),d('history','My entries')],p={me:e,meId:t,now:n,mode:s},m=(0,j.useMaySendInspectorLog)(p);m&&c.splice(c.findIndex(e=>'report'===e.id)+1,0,d('inspector','Inspector'));return(0,w.jsxs)(u.default,{style:{gap:12},testID:"haccp-log",children:[(0,w.jsx)(o.TempSaveBanner,{}),'today'!==i?(0,w.jsx)(S,{mode:s,now:n,onPress:()=>l('today')}):null,(0,w.jsx)(y.Tabs,{value:i,onChange:l,options:c}),'today'===i?(0,w.jsx)(f.TodayView,{who:p}):null,'units'===i?(0,w.jsx)(f.UnitsView,{who:p}):null,'record'===i?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(I,{who:p}),(0,w.jsx)(D,{who:p})]}):null,'diary'===i?(0,w.jsx)(f.DiaryView,{who:p}):null,'weekly'===i?(0,w.jsx)(f.WeeklyView,{who:p}):null,'report'===i?(0,w.jsx)(f.ReportView,{who:p}):null,'inspector'===i&&m?(0,w.jsx)(j.InspectorView,{who:p}):null,'history'===i?(0,w.jsx)(P,{who:p}):null,'limits'===i?(0,w.jsx)(B,{mode:s,editable:'chef'===s}):null,'probes'===i?(0,w.jsx)(A,{mode:s,me:e,now:n}):null,(0,w.jsx)(h.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. Shared with every device at the venue: a reading taken offline sends by itself when the connection is back."})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=_r(_d[3]),i=_r(_d[4]),l=_r(_d[5]),r=_r(_d[6]),d=e(_r(_d[7])),c=e(_r(_d[8])),u=e(_r(_d[9])),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),x=_r(_d[13]),b=_r(_d[14]),y=_r(_d[15]),f=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]);const v=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),k=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),C=e=>{const t=e.trim().replace(',','.').replace(/^\u2212/,'-');return t&&/^-?\d+(\.\d+)?$/.test(t)?Number(t):null};function S({now:e,onPress:t,mode:n="managers"}){const o=(0,s.useSafetyView)(n).points,i=(0,s.useSafetyView)(n).entries,l=(0,m.missedChecks)(o,i,e);if(!l.length)return(0,w.jsx)(u.default,{testID:"haccp-uptodate",children:(0,w.jsx)(h.Banner,{kind:"success",title:"Food safety checks up to date",children:"No checks overdue right now."})});const r=(0,w.jsx)(u.default,{testID:"haccp-missed",children:(0,w.jsx)(h.Banner,{kind:"warn",title:`${l.length} food safety check${1===l.length?'':'s'} overdue`,children:l.map(e=>`${e.point.name} (due ${e.due})`).join(' \xb7 ')})});return t?(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Open the food safety log",onPress:t,children:r}):r}function T(e,t){p.useSafety.getState().addEntries(t.filter(t=>'chef'!==e.mode||(0,i.chefCanSee)(l.useOwner.getState().site,t.point)).map(t=>{const n=(0,m.isTempKind)(t.point.kind)?(0,m.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,m.initialsOf)(e.me)}}))}function I({who:e}){const o=(0,s.useSafetyView)(e.mode).points,[d,p]=(0,r.useState)(''),[b,f]=(0,r.useState)(null),[j,v]=(0,r.useState)(''),[k,S]=(0,r.useState)(!1),[I,D]=(0,r.useState)(!1),P=(0,r.useRef)(null),R=(t,n)=>{if('chef'===e.mode&&!(0,i.chefCanSee)(l.useOwner.getState().site,t))return f(null),void v('That check is managed in the Managers app.');const s=(0,m.parseQuick)(t,o);D(n),v(''),f(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,m.isTempKind)(e.point.kind)||!/\b(done|yes|complete|completed|ok|signed)\b/i.test(e.text))||void 0,corrective:'',problem:e.problem})))},B=(e,t)=>f(n=>n&&n.map(n=>n.key===e?{...n,...t}:n)),L=(b??[]).map(e=>{const t=o.find(t=>t.id===e.pointId),n=C(e.value),s=!!t&&(0,m.isTempKind)(t.kind),i=!!t&&(s?null!=n:void 0!==e.done),l=t?s?null!=n?(0,m.inRange)(t,n):null:void 0===e.done?null:e.done:null;return{d:e,point:t,v:n,temp:s,ready:i,ok:l,needsAction:!1===l&&!e.corrective.trim()}}),$=L.length>0&&L.every(e=>e.ready&&!e.needsAction);return(0,w.jsxs)(y.Box,{testID:"haccp-quick",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Quick entry: say or type readings"}),(0,w.jsx)(h.Muted,{children:"For example \u201cprep fridge 3, freezer minus 19\u201d. You check every value before anything is saved."}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Readings",value:d,onChangeText:p,placeholder:"prep fridge 3, freezer minus 19",placeholderTextColor:"#7D776C",onSubmitEditing:()=>R(d,!1),style:[h.styles.input,{flex:1,minWidth:0,width:40}]}),(0,w.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Speak readings",testID:"haccp-mic",onPress:()=>{const e=(0,y.speechRecognition)();if(!e)return void v("Voice input isn't available in this browser (for example Huawei Browser). Please type the readings instead.");if(k)return void P.current?.stop();const t=new e;P.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&&R(t,!0)},t.onerror=()=>v("Didn't catch that. Try again or type the readings."),t.onend=()=>S(!1);try{t.start(),S(!0)}catch{v("Voice input couldn't start. Please type the readings.")}},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:x.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:k?x.colours.gold:'transparent'},children:(0,w.jsx)(h.T,{size:20,children:k?'\u25a0':'\ud83c\udfa4'})})]}),(0,w.jsx)(h.Button,{label:"Check readings",disabled:!d.trim(),onPress:()=>R(d,!1)}),j?(0,w.jsx)(u.default,{testID:"haccp-quick-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:j})}):null,b?(0,w.jsxs)(u.default,{style:{gap:10},testID:"haccp-confirm",children:[(0,w.jsxs)(h.T,{weight:"semibold",children:["Check these ",b.length," reading",1===b.length?'':'s']}),L.map(({d:e,point:s,temp:i,ok:l,needsAction:r})=>(0,w.jsxs)(u.default,{testID:"haccp-draft",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:!1===l?x.colours.red:x.colours.border,backgroundColor:x.colours.surface2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(h.Muted,{style:{flex:1},children:["Heard: \u201c",e.text,"\u201d"]}),(0,w.jsx)(n.GoldClose,{size:"sm",label:`Remove ${s?.name??e.text}`,onPress:()=>f(t=>t.filter(t=>t.key!==e.key))})]}),s?(0,w.jsxs)(h.T,{weight:"semibold",children:[s.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 safe: ",(0,m.limitText)(s)]})]}):(0,w.jsxs)(u.default,{style:{gap:6},children:[(0,w.jsx)(h.T,{colour:x.colours.amber,children:e.problem}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:o.map(t=>(0,w.jsx)(h.Chip,{label:t.name,onPress:()=>B(e.key,{pointId:t.id,problem:void 0})},t.id))})]}),s&&i?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Reading for ${s.name}`,value:e.value,onChangeText:t=>B(e.key,{value:t}),placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:96,fontSize:20}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===l?(0,w.jsx)(h.Badge,{kind:"amber",label:"Type the reading"}):(0,w.jsx)(h.Badge,{kind:l?'ok':'red',label:l?'OK':'OUT OF RANGE'})]}):null,s&&!i?(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===e.done,onPress:()=>B(e.key,{done:!0})}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===e.done,onPress:()=>B(e.key,{done:!1})})]}):null,!1===l?(0,w.jsx)(t.TextInput,{accessibilityLabel:`Corrective action for ${s.name}`,value:e.corrective,onChangeText:t=>B(e.key,{corrective:t}),placeholder:"What did you do? e.g. moved stock, called engineer, re-checked",placeholderTextColor:"#7D776C",style:[h.styles.input,r&&{borderColor:x.colours.red}]}):null,r?(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"A corrective action note is needed before saving."}):null]},e.key)),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:`Save ${L.length} reading${1===L.length?'':'s'}`,testID:"haccp-save-quick",disabled:!$,onPress:()=>{T(e,L.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:I?'voice':'typed'}))),v(`Saved ${L.length} reading${1===L.length?'':'s'}.`),f(null),p('')},style:{flex:1}}),(0,w.jsx)(h.Button,{kind:"secondary",label:"Cancel",onPress:()=>{f(null),v('Nothing saved.')}})]}),(0,w.jsx)(h.Muted,{children:"Nothing is saved until you tap Save."})]}):null]})}function D({who:e}){const n=(0,s.useSafetyView)(e.mode).points,[o,i]=(0,r.useState)(n[0]?.id),[l,d]=(0,r.useState)(''),[c,u]=(0,r.useState)(),[p,b]=(0,r.useState)(''),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),S=n.find(e=>e.id===o),I=!!S&&(0,m.isTempKind)(S.kind),D=C(l),P=S?I?null==D?null:(0,m.inRange)(S,D):void 0===c?null:c:null,R=null!==P&&(P||p.trim());return(0,w.jsxs)(y.Box,{testID:"haccp-manual",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Record one check"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:n.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:e.id===o,onPress:()=>{i(e.id),d(''),u(void 0),b(''),k('')}},e.id))}),S?(0,w.jsxs)(h.Muted,{children:[m.KIND_LABEL[S.kind]," \xb7 safe: ",(0,m.limitText)(S)]}):null,I?(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Temperature reading",value:l,onChangeText:d,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",style:[h.styles.input,{width:110,fontSize:22}]}),(0,w.jsx)(h.T,{size:18,children:"\xb0C"}),null===P?null:(0,w.jsx)(h.Badge,{kind:P?'ok':'red',label:P?'OK':'OUT OF RANGE'})]}):(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(h.Chip,{label:"Done",selected:!0===c,onPress:()=>u(!0)}),(0,w.jsx)(h.Chip,{label:"Not done",selected:!1===c,onPress:()=>u(!1)})]}),!1===P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h.Banner,{kind:"danger",title:I?'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,w.jsx)(t.TextInput,{accessibilityLabel:"Corrective action",value:p,onChangeText:b,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:h.styles.input})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:"Note (optional)",value:f,onChangeText:j,placeholder:"Note (optional), e.g. probe used, batch",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Button,{label:"Save check",testID:"haccp-save-one",disabled:!R,onPress:()=>{T(e,[{point:S,value:I?D:void 0,done:I?void 0:c,corrective:p,note:f,source:'typed'}]),d(''),u(void 0),b(''),j(''),k(`Saved: ${S.name}.`)}}),v?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:v}):null]})}function P({who:e}){const t=(0,s.useSafetyView)(e.mode).entries,n=(0,s.useSafetyView)(e.mode).allPoints,[o,i]=(0,r.useState)('7'),[l,d]=(0,r.useState)('all'),[c,p]=(0,r.useState)(!1),[b,f]=(0,r.useState)(''),j='staff'===e.mode,v=(0,r.useMemo)(()=>{const n=new Date(e.now);n.setHours(0,0,0,0);const s='today'===o?n.getTime():'all'===o?0:e.now.getTime()-864e5*Number(o);return t.filter(t=>!(j&&t.byId!==e.meId||!(new Date(t.at).getTime()>=s)||'all'!==l&&t.kind!==l||c&&t.ok))},[t,o,l,c,j,e.meId,e.now.getTime()]),k=Array.from(new Set(n.map(e=>e.kind))),C=e.now.toISOString().slice(0,10);return(0,w.jsxs)(y.Box,{testID:"haccp-history",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:j?'My entries':'Food safety log'}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:[['today','Today'],['7','7 days'],['30','30 days'],['all','All']].map(([e,t])=>(0,w.jsx)(h.Chip,{label:t,selected:o===e,onPress:()=>i(e)},e))}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Chip,{label:"All checks",selected:'all'===l,onPress:()=>d('all')}),k.map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:l===e,onPress:()=>d(e)},e))]}),(0,w.jsx)(h.Toggle,{label:"Out of range only",value:c,onChange:p}),(0,w.jsx)(u.default,{testID:"haccp-count",children:(0,w.jsxs)(h.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,w.jsx)(R,{e:e},e.id)):(0,w.jsx)(h.Muted,{children:"No entries for these filters yet."}),j?null:(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[(0,w.jsx)(h.Button,{small:!0,label:"Download CSV",testID:"haccp-csv",disabled:!v.length,onPress:()=>f((0,y.downloadText)(`food-safety-log-${C}.csv`,(0,m.toCsv)(v,n))?`CSV downloaded: ${v.length} entries.`:'Downloads work in the web app.')}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Print for EHO",testID:"haccp-print",disabled:!v.length,onPress:()=>f((0,y.printTable)('Food safety log (HACCP)',`${v.length} entries \xb7 printed ${e.now.toLocaleString('en-GB')} \xb7 all readings entered by staff`,m.LOG_HEAD,(0,m.logRows)(v,n))?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')})]}),b?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:b}):null]})}function R({e:e}){return(0,w.jsxs)(u.default,{testID:"haccp-row",style:{paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border,gap:2},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(h.T,{size:15,weight:"medium",style:{flex:1},children:e.name}),(0,w.jsx)(h.T,{size:17,weight:"bold",colour:e.ok?x.colours.ok:x.colours.red,children:(0,m.fmtEntryValue)(e)})]}),(0,w.jsxs)(h.Row,{gap:6,children:[(0,w.jsx)(b.StaffAvatar,{id:e.byId,name:e.by,size:20,ring:!1}),(0,w.jsxs)(h.Muted,{style:{flex:1},children:[k(e.at)," ",v(e.at)," \xb7 ",e.initials??(0,m.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,w.jsxs)(h.T,{size:13,colour:x.colours.amber,children:["Action: ",e.corrective]}):null,e.note?(0,w.jsxs)(h.Muted,{children:["Note: ",e.note]}):null,e.photo?(0,w.jsx)(d.default,{source:{uri:e.photo},style:{width:72,height:72,borderRadius:8},accessibilityLabel:"Corrective action photo"}):null]})}function B({editable:e,mode:t}){const n=(0,s.useSafetyView)(t).points,[o,i]=(0,r.useState)('');return(0,w.jsxs)(y.Box,{testID:"haccp-limits",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Check points and safe limits"}),(0,w.jsx)(h.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 CoverCharge for Head Chef.'}),n.map(t=>(0,w.jsx)(L,{p:t,editable:e,onSaved:()=>i(`Saved limits for ${t.name}.`)},t.id)),e?(0,w.jsx)($,{onAdded:e=>i(`Added ${e}.`)}):null,o?(0,w.jsx)(h.T,{size:14,colour:x.colours.ok,children:o}):null]})}function L({p:e,editable:n,onSaved:s}){const[o,i]=(0,r.useState)(null==e.min?'':String(e.min)),[l,d]=(0,r.useState)(null==e.max?'':String(e.max)),[c,b]=(0,r.useState)(e.due.join(', ')),y=(0,m.isTempKind)(e.kind),f=''===c.trim()||c.split(',').every(e=>/^\s*([01]\d|2[0-3]):[0-5]\d\s*$/.test(e)),j=o!==(null==e.min?'':String(e.min))||l!==(null==e.max?'':String(e.max))||c!==e.due.join(', '),v=f&&(''===o||null!=C(o))&&(''===l||null!=C(l));return n?(0,w.jsxs)(u.default,{style:{gap:6,paddingVertical:8,borderTopWidth:1,borderColor:x.colours.border},testID:`limit-${e.id}`,children:[(0,w.jsxs)(h.T,{weight:"medium",children:[e.name," ",(0,w.jsxs)(h.Muted,{children:["\xb7 ",m.KIND_LABEL[e.kind]]})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:8,children:[y?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:`Minimum for ${e.name}`,value:o,onChangeText:i,placeholder:"min \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]}),(0,w.jsx)(t.TextInput,{accessibilityLabel:`Maximum for ${e.name}`,value:l,onChangeText:d,placeholder:"max \xb0C",placeholderTextColor:"#7D776C",style:[h.styles.input,{width:90}]})]}):null,(0,w.jsx)(t.TextInput,{accessibilityLabel:`Due times for ${e.name}`,value:c,onChangeText:b,placeholder:"e.g. 09:00, 16:00",placeholderTextColor:"#7D776C",style:[h.styles.input,{flex:1,minWidth:140,width:40}]}),j?(0,w.jsx)(h.Button,{small:!0,label:"Save",disabled:!v,onPress:()=>{p.useSafety.getState().setPoint(e.id,{min:''===o?void 0:C(o),max:''===l?void 0:C(l),due:c.split(',').map(e=>e.trim()).filter(Boolean).sort()}),s()}}):null]}),f?null:(0,w.jsx)(h.T,{size:13,colour:x.colours.red,children:"Use 24-hour times like 09:00, 16:00."})]}):(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between',paddingVertical:4},children:[(0,w.jsx)(h.T,{size:14,style:{flex:1},children:e.name}),(0,w.jsxs)(h.Muted,{children:[(0,m.limitText)(e),e.due.length?` \xb7 due ${e.due.join(', ')}`:'']})]})}function $({onAdded:e}){const[n,s]=(0,r.useState)(''),[o,d]=(0,r.useState)('fridge');return(0,w.jsxs)(u.default,{style:{gap:6,paddingTop:8,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsx)(h.T,{weight:"medium",children:"Add a check point"}),(0,w.jsx)(t.TextInput,{accessibilityLabel:"New check point name",value:n,onChangeText:s,placeholder:"e.g. Dessert fridge",placeholderTextColor:"#7D776C",style:h.styles.input}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:Object.keys(m.KIND_LABEL).map(e=>(0,w.jsx)(h.Chip,{label:m.KIND_LABEL[e],selected:e===o,onPress:()=>d(e)},e))}),(0,w.jsx)(h.Button,{small:!0,label:"Add check point",disabled:!n.trim()||!(0,i.chefCanSee)(l.useOwner.getState().site,n),onPress:()=>{if(!(0,i.chefCanSee)(l.useOwner.getState().site,n))return;const t='fridge'===o?{max:5}:'freezer'===o?{max:-18}:'cook'===o?{min:75}:'hothold'===o?{min:63}:'cool'===o||'delivery'===o?{max:8}:{};p.useSafety.getState().addPoint({name:n.trim(),kind:o,due:[],aliases:[n.trim().toLowerCase()],...t}),e(n.trim()),s('')}})]})}function A({me:e,now:n,mode:o}){const d=(0,s.useSafetyView)(o).probes??[],c=(0,s.useSafetyView)(o).points.filter(e=>'fridge'===e.kind||'freezer'===e.kind),[m,b]=(0,r.useState)(!1),[f,j]=(0,r.useState)(''),[v,k]=(0,r.useState)(''),[C,S]=(0,r.useState)(null),[T,I]=(0,r.useState)(''),D=c.find(e=>e.id===v);return(0,w.jsxs)(y.Box,{testID:"haccp-probes",children:[(0,w.jsx)(h.T,{weight:"semibold",size:17,children:"Wireless probes"}),(0,w.jsx)(h.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."}),d.length?d.map(e=>(0,w.jsxs)(u.default,{testID:"probe-row",style:{gap:6,paddingVertical:10,borderTopWidth:1,borderColor:x.colours.border},children:[(0,w.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(u.default,{style:{flex:1,gap:2},children:[(0,w.jsx)(h.T,{weight:"semibold",children:e.name}),(0,w.jsx)(h.Muted,{children:e.location})]}),(0,w.jsx)(h.Badge,{kind:'connected'===e.status?'ok':'amber',label:'connected'===e.status?'Connected':'Not connected'})]}),(0,w.jsxs)(h.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(h.Button,{small:!0,label:"Connect your probe",accessibilityLabel:`Connect your probe: ${e.name}`,onPress:()=>S(C===e.id?null:e.id)}),(0,w.jsx)(h.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove probe ${e.name}`,onPress:()=>p.useSafety.getState().removeProbe(e.id)})]}),C===e.id?(0,w.jsxs)(u.default,{testID:"probe-connect",style:{gap:6,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(h.T,{weight:"semibold",children:"Connect your probe"}),(0,w.jsxs)(h.T,{size:14,children:["1. Put the probe in ",e.location," and switch it on."]}),(0,w.jsx)(h.T,{size:14,children:"2. Keep this device near the probe."}),(0,w.jsx)(h.T,{size:14,children:"3. Tap Search for probe and pick it from the list."}),(0,w.jsx)(h.Button,{small:!0,kind:"secondary",label:"Search for probe",onPress:()=>I(`No probe found for ${e.name}. Probe hardware isn\u2019t set up yet, so it stays Not connected and nothing is added to the log.`)})]}):null]},e.id)):(0,w.jsx)(u.default,{testID:"probes-empty",children:(0,w.jsx)(h.Muted,{children:"No probes yet."})}),T?(0,w.jsx)(u.default,{testID:"probe-msg",children:(0,w.jsx)(h.Banner,{kind:"info",children:T})}):null,m?(0,w.jsxs)(u.default,{testID:"probe-add",style:{gap:8,padding:10,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,w.jsx)(t.TextInput,{accessibilityLabel:"Probe name",value:f,onChangeText:j,placeholder:"e.g. Walk-in probe 1",placeholderTextColor:"#7D776C",style:[h.styles.input,{minWidth:0}]}),(0,w.jsx)(h.Muted,{children:"Where is it?"}),(0,w.jsx)(h.Row,{wrap:!0,gap:6,children:c.map(e=>(0,w.jsx)(h.Chip,{label:e.name,selected:v===e.id,onPress:()=>k(e.id)},e.id))}),(0,w.jsxs)(h.Row,{gap:8,children:[(0,w.jsx)(h.Button,{label:"Save probe",disabled:!f.trim()||!D,onPress:()=>{f.trim()&&D&&('chef'!==o||(0,i.chefCanSee)(l.useOwner.getState().site,D))&&(p.useSafety.getState().addProbe({name:f.trim(),pointId:D.id,location:D.name,addedBy:e.replace(' (example)',''),addedAt:n.toISOString()}),I(`Added \u201c${f.trim()}\u201d for ${D.name}. Next: connect your probe.`),j(''),k(''),b(!1))}}),(0,w.jsx)(h.Button,{kind:"ghost",label:"Cancel",onPress:()=>b(!1)})]})]}):(0,w.jsx)(h.Button,{kind:"secondary",label:"Add probe",onPress:()=>{b(!0),I('')}}),(0,w.jsx)(h.Muted,{children:"No probe hardware is connected, so no probe readings appear. The app never makes up a temperature."})]})}},1220,[827,796,1221,1149,835,891,34,336,402,102,794,1034,1035,821,925,930,1222,1225,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useSafetyView=function(o){const l=(0,n.useSafety)(),c=(0,s.useOwner)(t=>t.site);return(0,t.useMemo)(()=>{if('chef'!==o)return{...l,points:l.points.filter(t=>!t.archived),allPoints:l.points};const t=l.points.filter(t=>(0,f.chefCanSee)(c,t)),n=t.filter(t=>!t.archived),s=new Set(l.points.filter(t=>!(0,f.chefCanSee)(c,t)).map(t=>t.id)),u=t=>(0,f.chefCanSee)(c,t)&&!s.has(t.pointId||'');return{...l,points:n,allPoints:t,entries:l.entries.filter(u),probes:l.probes.filter(u),diary:l.diary.filter(t=>u(t)&&(0,f.chefCanSee)(c,t.text)),weekly:l.weekly.filter(t=>(0,f.chefCanSee)(c,t.note))}},[l,c,o])};var t=r(d[0]),n=r(d[1]),s=r(d[2]),f=r(d[3])},1221,[34,1034,891,835]); +__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.saveEntry=R,_e.ProgressRing=O,_e.Keypad=z,_e.RecordPanel=E,_e.TodayView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points,o=(0,i.useSafetyView)(e.mode).entries,[s,n]=(0,a.useState)('all'),[r,l]=(0,a.useState)(null),[d,h]=(0,a.useState)(''),y=(0,a.useMemo)(()=>(0,m.todayTasks)(t,o,e.now),[t,o,e.now.getTime()]).filter(e=>'all'===s||(0,m.sectionOf)(e.point)===s),f=e=>y.filter(t=>t.status===e).length;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-today",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.Row,{gap:16,children:[(0,S.jsx)(O,{done:f('done'),total:y.length}),(0,S.jsxs)(u.default,{style:{flex:1,gap:6},children:[(0,S.jsx)(x.T,{weight:"semibold",size:18,children:"Today\u2019s checks"}),(0,S.jsx)(x.Muted,{children:e.now.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(u.default,{testID:"today-overdue",children:(0,S.jsx)(x.Badge,{kind:f('overdue')?'red':'neutral',label:`${f('overdue')} overdue`})}),(0,S.jsx)(u.default,{testID:"today-due",children:(0,S.jsx)(x.Badge,{kind:f('due')?'amber':'neutral',label:`${f('due')} due now`})}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${f('upcoming')} later`})]}),(0,S.jsx)(x.Muted,{children:"Tap a check to record it. Each one is signed with your initials and the time."})]})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"All",selected:'all'===s,onPress:()=>n('all')}),m.SECTIONS.map(e=>(0,S.jsx)(x.Chip,{label:m.SECTION_LABEL[e],selected:s===e,onPress:()=>n(e)},e))]})]}),d?(0,S.jsx)(u.default,{testID:"today-msg",children:(0,S.jsx)(x.Banner,{kind:"success",children:d})}):null,m.SLOTS.map(t=>{const o=y.filter(e=>e.slot===t);return o.length?(0,S.jsxs)(w.Box,{testID:`slot-${t}`,children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:[m.SLOT_LABEL[t]," ",(0,S.jsxs)(x.Muted,{children:["\xb7 ",m.SLOT_HINT[t]]})]}),(0,S.jsx)(x.Badge,{kind:o.every(e=>'done'===e.status)?'ok':'gold',label:`${o.filter(e=>'done'===e.status).length}/${o.length}`})]}),o.map(t=>(0,S.jsxs)(u.default,{style:{gap:8},children:[(0,S.jsxs)(c.default,{accessibilityRole:"button",accessibilityLabel:`${t.point.name}, due ${t.due}, ${M[t.status]}`,testID:`task-${t.point.id}-${t.due.replace(':','')}`,onPress:()=>{h(''),l(r===t.key?null:t.key)},style:({pressed:e})=>({minHeight:64,flexDirection:'column',alignItems:'center',gap:12,paddingHorizontal:12,paddingVertical:10,borderRadius:14,borderWidth:1,borderColor:'overdue'===t.status?j.colours.red:'due'===t.status?j.colours.amber:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2}),children:[(0,S.jsx)(u.default,{style:{width:34,height:34,borderRadius:17,borderWidth:2,borderColor:P[t.status],backgroundColor:'done'===t.status?t.entry?.ok?j.colours.ok:j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{weight:"bold",colour:'done'===t.status?'#0B0B0B':P[t.status],children:'done'===t.status?t.entry?.ok?'\u2713':'!':'overdue'===t.status?'!':'\u25cb'})}),(0,S.jsxs)(u.default,{style:{width:'100%',gap:2},children:[(0,S.jsx)(x.T,{weight:"medium",children:t.point.name}),(0,S.jsxs)(x.Muted,{children:[t.due," \xb7 ",m.SECTION_LABEL[(0,m.sectionOf)(t.point)],(0,m.isTempKind)(t.point.kind)?` \xb7 ${(0,m.limitText)(t.point)}`:'']}),t.entry?(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(p.StaffAvatar,{id:t.entry.byId,name:t.entry.by,size:18,ring:!1}),(0,S.jsxs)(x.Muted,{children:[(0,m.fmtEntryValue)(t.entry)," \xb7 ",t.entry.initials??(0,m.initialsOf)(t.entry.by)," ",D(t.entry.at),t.entry.ok?'':` \xb7 action: ${t.entry.corrective}`]})]}):null]}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:P[t.status],children:M[t.status]})]}),r===t.key?(0,S.jsx)(E,{who:e,point:t.point,onCancel:()=>l(null),onDone:e=>{l(null),h(e)}}):null]},t.key))]},t):null}),y.length?null:(0,S.jsxs)(x.Muted,{children:["No scheduled checks",'all'===s?'':` in ${m.SECTION_LABEL[s]}`,". Add due times in Safe limits."]})]})},_e.UnitsView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).points.filter(e=>['fridge','freezer','hothold'].includes(e.kind)),o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).probes??[],[n,r]=(0,a.useState)(null),[l,d]=(0,a.useState)('');return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-units",children:[l?(0,S.jsx)(x.Banner,{kind:"success",children:l}):null,(0,S.jsx)(x.Row,{wrap:!0,gap:10,style:{alignItems:'stretch'},children:t.map(t=>{const i=(0,m.unitStatus)(t,o,e.now),l=s.find(e=>e.pointId===t.id);return(0,S.jsxs)(u.default,{testID:`unit-${t.id}`,style:{flexGrow:1,flexBasis:260,gap:8,padding:14,borderRadius:16,borderWidth:1.5,borderColor:'none'===i.rag?j.colours.border:C[i.rag],backgroundColor:j.colours.surface},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",children:t.name}),(0,S.jsxs)(x.Muted,{children:[m.KIND_LABEL[t.kind]," \xb7 safe ",(0,m.limitText)(t)]})]}),(0,S.jsxs)(u.default,{testID:`unit-rag-${t.id}`,style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,S.jsx)(u.default,{style:{width:12,height:12,borderRadius:6,backgroundColor:C[i.rag]}}),(0,S.jsx)(x.T,{size:13,weight:"semibold",colour:C[i.rag],children:'amber'===i.rag?i.why:I[i.rag]})]})]}),i.latest?(0,S.jsxs)(x.Row,{style:{alignItems:'flex-end',gap:8},children:[(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:C[i.rag],children:[i.latest.value,"\xb0C"]}),(0,S.jsxs)(x.Muted,{style:{paddingBottom:8},children:[T(i.latest.at)," ",D(i.latest.at)," \xb7 ",i.latest.initials??(0,m.initialsOf)(i.latest.by)]})]}):(0,S.jsx)(x.T,{size:20,colour:j.colours.muted,children:"\u2014 \xb0C"}),(0,S.jsx)(N,{p:t,history:i.history}),l?(0,S.jsxs)(x.Muted,{children:["Wireless probe: ",l.name," \xb7 ",'connected'===l.status?'Connected':'Not connected']}):null,(0,S.jsx)(x.Button,{small:!0,label:"Record reading",testID:`unit-record-${t.id}`,onPress:()=>{d(''),r(n===t.id?null:t.id)}}),n===t.id?(0,S.jsx)(E,{who:e,point:t,onCancel:()=>r(null),onDone:e=>{r(null),d(e)}}):null]},t.id)})}),(0,S.jsx)(x.Muted,{children:"Gold: in range \xb7 Amber: near the limit (within 1 \xb0C) or no reading yet today \xb7 Red: last reading out of range. Only readings people entered are shown."})]})},_e.DiaryView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).diary??[],o=(0,i.useSafetyView)(e.mode).daySigns??[],s=(0,i.useSafetyView)(e.mode).entries,r=(0,m.ymdLocal)(e.now),[l,d]=(0,a.useState)(r),[c,h]=(0,a.useState)('Note'),[y,b]=(0,a.useState)(''),[k,T]=(0,a.useState)(''),C=Array.from({length:7},(t,o)=>(0,m.ymdLocal)(L(e.now,-o))),I=t.filter(e=>e.date===l),v=o.find(e=>e.date===l),R=s.filter(e=>(0,m.ymdLocal)(new Date(e.at))===l),O='staff'!==e.mode;return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-diary",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:C.map(e=>(0,S.jsx)(x.Chip,{label:e===r?'Today':B(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric'}),selected:e===l,onPress:()=>d(e)},e))}),(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:B(l).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}),(0,S.jsxs)(x.Muted,{children:[R.length," check",1===R.length?'':'s'," recorded",R.filter(e=>!e.ok).length?` \xb7 ${R.filter(e=>!e.ok).length} out of range or not done`:'']}),I.length?I.map(e=>(0,S.jsxs)(u.default,{testID:"diary-note",style:{gap:2,paddingVertical:8,borderTopWidth:1,borderColor:j.colours.border},children:[(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.byId,name:e.by,size:22,ring:!1}),(0,S.jsx)(x.Badge,{kind:'Problem'===e.kind?'red':'Extra check'===e.kind?'blue':'neutral',label:e.kind}),(0,S.jsxs)(x.Muted,{children:[D(e.at)," \xb7 ",e.by]})]}),(0,S.jsx)(x.T,{size:14,children:e.text}),e.action?(0,S.jsxs)(x.T,{size:13,colour:j.colours.amber,children:["What we did: ",e.action]}):null]},e.id)):(0,S.jsx)(x.Muted,{children:"Nothing written for this day yet."})]}),(0,S.jsxs)(w.Box,{testID:"diary-add",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Add to the diary"}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:W.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:c===e,onPress:()=>h(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Diary note",testID:"diary-text",value:y,onChangeText:b,multiline:!0,placeholder:"What happened? e.g. chilled delivery arrived at 9\xb0C, rejected",placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:70}]}),'Problem'===c?(0,S.jsx)(n.TextInput,{accessibilityLabel:"What did you do about it",value:k,onChangeText:T,placeholder:"What did you do about it?",placeholderTextColor:"#7D776C",style:x.styles.input}):null,(0,S.jsx)(x.Button,{label:"Save note",testID:"diary-save",disabled:y.trim().length<3||'Problem'===c&&k.trim().length<3,onPress:()=>{f.useSafety.getState().addNote({date:l,at:e.now.toISOString(),by:$(e.me),byId:e.meId,kind:c,text:y.trim(),action:k.trim()||void 0}),b(''),T('')}})]}),(0,S.jsxs)(w.Box,{testID:"diary-daysign",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Daily sign-off"}),v?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:v.byId,name:v.by,size:30}),(0,S.jsxs)(x.T,{size:14,colour:j.colours.ok,style:{flex:1},children:["Safe methods followed: signed by ",v.by," at ",D(v.at)]})]}):O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x.Muted,{children:"Sign to confirm the opening and closing checks were done and the safe methods were followed today."}),(0,S.jsx)(x.Button,{label:"Sign: safe methods followed",testID:"diary-sign",disabled:l!==r,onPress:()=>f.useSafety.getState().signDay({date:l,by:$(e.me),byId:e.meId,at:e.now.toISOString()})}),l!==r?(0,S.jsx)(x.Muted,{children:"Only today can be signed."}):null]}):(0,S.jsx)(x.Muted,{children:"Not signed yet. The Head Chef or a manager signs the diary each day."})]})]})},_e.WeeklyView=function({who:e}){const t=(0,i.useSafetyView)(e.mode).weekly??[],o=(0,i.useSafetyView)(e.mode).entries,s=(0,i.useSafetyView)(e.mode).daySigns??[],r=(0,m.weekStart)(e.now),l=(0,m.weekStart)(L(B(r),-7)),[d,c]=(0,a.useState)(r),[h,y]=(0,a.useState)(m.WEEKLY_QUESTIONS.map(()=>{})),[b,k]=(0,a.useState)(''),[C,I]=(0,a.useState)(''),v=B(d).getTime(),R=L(B(d),7).getTime(),O=o.filter(e=>{const t=new Date(e.at).getTime();return t>=v&&t!e.ok).length,actions:O.filter(e=>!e.ok&&e.corrective).length,daysSigned:s.filter(e=>{const t=B(e.date).getTime();return t>=v&&te.week===d),E='staff'!==e.mode,P=h.every(e=>void 0!==e),M=h.some(e=>!1===e);return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-weekly",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Chip,{label:"This week",selected:d===r,onPress:()=>c(r)}),(0,S.jsx)(x.Chip,{label:"Last week",selected:d===l,onPress:()=>c(l)})]}),(0,S.jsxs)(w.Box,{children:[(0,S.jsxs)(x.T,{weight:"semibold",size:17,children:["Week of ",B(d).toLocaleDateString('en-GB',{day:'numeric',month:'long'})]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${z.entries} checks`}),(0,S.jsx)(x.Badge,{kind:z.outOfRange?'red':'ok',label:`${z.outOfRange} out of range`}),(0,S.jsx)(x.Badge,{kind:z.actions(0,S.jsxs)(x.Muted,{children:[_.answers[t]?'\u2713':'\u2715'," ",e]},e)),_.note?(0,S.jsxs)(x.T,{size:14,children:["Note: ",_.note]}):null]}):E?(0,S.jsxs)(w.Box,{testID:"weekly-form",children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Weekly review"}),m.WEEKLY_QUESTIONS.map((e,t)=>(0,S.jsxs)(u.default,{style:{gap:6,paddingVertical:6,borderTopWidth:t?1:0,borderColor:j.colours.border},children:[(0,S.jsx)(x.T,{size:14,children:e}),(0,S.jsxs)(x.Row,{gap:6,children:[(0,S.jsx)(x.Chip,{label:"Yes",selected:!0===h[t],onPress:()=>y(h.map((e,o)=>o===t||e))}),(0,S.jsx)(x.Chip,{label:"No",selected:!1===h[t],onPress:()=>y(h.map((e,o)=>o!==t&&e))})]})]},e)),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Weekly note",value:b,onChangeText:k,multiline:!0,placeholder:M?'What went wrong and what you are doing about it (needed)':'Note (optional)',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:60},M&&!b.trim()&&{borderColor:j.colours.red}]}),(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signing as ",$(e.me)," (",'chef'===e.mode?'Head Chef':'Manager',")"]})]}),(0,S.jsx)(x.Button,{label:"Sign off this week",testID:"weekly-sign",disabled:!P||M&&b.trim().length<3,onPress:()=>{f.useSafety.getState().signWeek({week:d,by:$(e.me),byId:e.meId,role:'chef'===e.mode?'Head Chef':'Manager',at:e.now.toISOString(),answers:h.map(Boolean),note:b.trim(),summary:z}),I('Week signed off.')}}),C?(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:C}):null]}):(0,S.jsx)(w.Box,{children:(0,S.jsx)(x.Muted,{children:"Not signed off yet. The Head Chef or a manager signs off each week."})}),t.filter(e=>e.week!==d).length?(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",children:"Earlier sign-offs"}),t.filter(e=>e.week!==d).slice(0,8).map(e=>(0,S.jsxs)(x.Muted,{children:["Week of ",B(e.week).toLocaleDateString('en-GB',{day:'numeric',month:'short'}),": ",e.by," (",e.role,"), ",T(e.at)]},e.id))]}):null]})},_e.ReportView=function({who:e,venue:t=(0,k.venueInfo)().address}){const s=(0,i.useSafetyView)(e.mode).entries,r=(0,i.useSafetyView)(e.mode).allPoints,l=(0,i.useSafetyView)(e.mode).diary??[],d=(0,i.useSafetyView)(e.mode).daySigns??[],c=(0,i.useSafetyView)(e.mode).weekly??[],[h,y]=(0,a.useState)('week'),p=(0,m.ymdLocal)(e.now),[f,C]=(0,a.useState)((0,m.ymdLocal)(L(e.now,-13))),[I,v]=(0,a.useState)(p),[R,O]=(0,a.useState)(''),z=(0,m.weekStart)(e.now),[_,E]='week'===h?[z,p]:'lastweek'===h?[(0,m.ymdLocal)(L(B(z),-7)),(0,m.ymdLocal)(L(B(z),-1))]:'7'===h?[(0,m.ymdLocal)(L(e.now,-6)),p]:'28'===h?[(0,m.ymdLocal)(L(e.now,-27)),p]:[f,I],P=/^\d{4}-\d{2}-\d{2}$/.test(_)&&/^\d{4}-\d{2}-\d{2}$/.test(E)&&_<=E,M=e=>P&&e>=_&&e<=E,N=s.filter(e=>M((0,m.ymdLocal)(new Date(e.at)))).sort((e,t)=>e.at.localeCompare(t.at)),W=l.filter(e=>M(e.date)),V=d.filter(e=>M(e.date)),A=c.filter(e=>M(e.week)||M((0,m.ymdLocal)(L(B(e.week),6)))),G=N.filter(e=>!e.ok),Y=e=>r.find(t=>t.id===e.pointId),F=m.SECTIONS.map(e=>{const t=N.filter(t=>{const o=Y(t);return!!o&&(0,m.sectionOf)(o)===e});return{s:e,n:t.length,bad:t.filter(e=>!e.ok).length}}),H=`${B(_).toLocaleDateString('en-GB')} to ${B(E).toLocaleDateString('en-GB')}`,U=['Date','Time','Section','Check','Reading','Safe limit','Result','Corrective action','Signed'],K=N.map(e=>[new Date(e.at).toLocaleDateString('en-GB'),D(e.at),Y(e)?m.SECTION_LABEL[(0,m.sectionOf)(Y(e))]:'',e.name,(0,m.fmtEntryValue)(e),Y(e)?(0,m.limitText)(Y(e)):'',e.ok?'OK':'OUT OF RANGE',e.corrective??'',`${e.initials??(0,m.initialsOf)(e.by)} ${e.by}`]),Q=[U,...K].map(e=>e.map(e=>/[",\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e).join(',')).join('\r\n')+'\r\n';return(0,S.jsxs)(u.default,{style:{gap:12},testID:"haccp-report",children:[(0,S.jsxs)(w.Box,{children:[(0,S.jsx)(x.T,{weight:"semibold",size:17,children:"EHO report"}),(0,S.jsx)(x.Muted,{children:"Pick the dates an inspector asks for, then download a PDF, print it or export the readings."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:[['week','This week'],['lastweek','Last week'],['7','Last 7 days'],['28','Last 28 days'],['custom','Choose dates']].map(([e,t])=>(0,S.jsx)(x.Chip,{label:t,selected:h===e,onPress:()=>y(e)},e))}),'custom'===h?(0,S.jsxs)(x.Row,{gap:8,children:[(0,S.jsx)(n.TextInput,{accessibilityLabel:"From date (DD/MM/YYYY)",testID:"report-from",...(0,o.slashBox)(f,C),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"To date (DD/MM/YYYY)",testID:"report-to",...(0,o.slashBox)(I,v),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#7D776C",style:[x.styles.input,{flex:1,minWidth:0,width:40}]})]}):null,P?(0,S.jsx)(u.default,{testID:"report-period",children:(0,S.jsx)(x.Muted,{children:H})}):(0,S.jsx)(x.T,{size:13,colour:j.colours.red,children:"Use dates like 2026-10-01, with the first date before the second."})]}),(0,S.jsxs)(w.Box,{testID:"report-summary",children:[(0,S.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,S.jsx)(x.Badge,{kind:"gold",label:`${N.length} checks`}),(0,S.jsx)(x.Badge,{kind:G.length?'red':'ok',label:`${G.length} out of range`}),(0,S.jsx)(x.Badge,{kind:"blue",label:`${V.length} diary days signed`}),(0,S.jsx)(x.Badge,{kind:"neutral",label:`${A.length} weekly sign-offs`})]}),F.map(e=>(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(x.T,{size:14,children:m.SECTION_LABEL[e.s]}),(0,S.jsxs)(x.Muted,{children:[e.n," check",1===e.n?'':'s',e.bad?` \xb7 ${e.bad} out of range`:'']})]},e.s)),G.length?(0,S.jsxs)(u.default,{style:{gap:4},children:[(0,S.jsx)(x.T,{weight:"semibold",colour:j.colours.red,children:"Out of range"}),G.slice(0,10).map(e=>(0,S.jsxs)(x.Muted,{children:[T(e.at)," ",D(e.at)," \xb7 ",e.name," ",(0,m.fmtEntryValue)(e)," \xb7 action: ",e.corrective]},e.id))]}):null]}),(0,S.jsxs)(x.Row,{wrap:!0,gap:8,children:[(0,S.jsx)(x.Button,{label:"Download PDF",testID:"report-pdf",disabled:!P,onPress:()=>{const o=[{text:'Food safety report (HACCP)',bold:!0,size:18},{text:t,size:11},{text:`Period: ${H}. Produced ${e.now.toLocaleString('en-GB')} by ${$(e.me)}.`,size:9,colour:[.35,.35,.35]},{text:'Every reading in this report was entered and signed by a member of staff. The app never fills in or estimates a reading.',size:9,colour:[.35,.35,.35]},{text:'Summary',bold:!0,size:13,gap:10},{text:`${N.length} checks recorded \xb7 ${G.length} out of range or not done \xb7 ${G.filter(e=>e.corrective).length} with a corrective action \xb7 diary signed on ${V.length} day(s) \xb7 ${A.length} weekly sign-off(s).`},{text:'By Safer Food, Better Business section',bold:!0,size:13,gap:10},...F.map(e=>({text:`${m.SECTION_LABEL[e.s]}: ${e.n} check${1===e.n?'':'s'}, ${e.bad} out of range / not done`})),{text:'Out of range and corrective actions',bold:!0,size:13,gap:10},...G.length?G.map(e=>({text:`${new Date(e.at).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.name}: ${(0,m.fmtEntryValue)(e)} (safe ${Y(e)?(0,m.limitText)(Y(e)):'-'}) \xb7 Action: ${e.corrective??'none recorded'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} ${e.by}${e.photo?' \xb7 photo kept on device':''}`,colour:[.65,.12,.1]})):[{text:'None in this period.'}],{text:'All checks by day',bold:!0,size:13,gap:10}];let s='';for(const e of N){const t=new Date(e.at).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',year:'numeric'});t!==s&&(s=t,o.push({text:t,bold:!0,gap:6})),o.push({text:`${D(e.at)} ${e.name}: ${(0,m.fmtEntryValue)(e)} ${e.ok?'OK':'OUT OF RANGE'} \xb7 ${e.initials??(0,m.initialsOf)(e.by)} (${e.by})${'voice'===e.source?' \xb7 voice, confirmed':'probe'===e.source?' \xb7 wireless probe':''}${e.note?` \xb7 note: ${e.note}`:''}`,indent:10,size:9})}N.length||o.push({text:'No checks recorded in this period.'}),o.push({text:'Diary',bold:!0,size:13,gap:10}),W.length?W.slice().sort((e,t)=>e.at.localeCompare(t.at)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')} ${D(e.at)} \xb7 ${e.kind}: ${e.text}${e.action?` \xb7 What we did: ${e.action}`:''} \xb7 ${e.by}`,size:9})):o.push({text:'No diary notes in this period.'}),o.push({text:'Daily sign-offs (safe methods followed)',bold:!0,size:13,gap:10}),V.length?V.slice().sort((e,t)=>e.date.localeCompare(t.date)).forEach(e=>o.push({text:`${B(e.date).toLocaleDateString('en-GB')}: ${e.by} at ${D(e.at)}`,size:9})):o.push({text:'None in this period.'}),o.push({text:'Weekly sign-offs',bold:!0,size:13,gap:10}),A.length?A.forEach(e=>{o.push({text:`Week of ${B(e.week).toLocaleDateString('en-GB')}: ${e.by} (${e.role}), ${new Date(e.at).toLocaleString('en-GB')}`,size:9}),m.WEEKLY_QUESTIONS.forEach((t,s)=>o.push({text:`${e.answers[s]?'Yes':'No'}: ${t}`,size:9,indent:10})),e.note&&o.push({text:`Note: ${e.note}`,size:9,indent:10})}):o.push({text:'None in this period.'}),o.push({text:'Signed (manager): ____________________ Date: ____________',gap:24});const n=(0,w.downloadBytes)(`food-safety-report-${_}-to-${E}.pdf`,(0,b.buildPdf)(o,`${t} \xb7 Food safety report \xb7 ${H}`),'application/pdf');O(n?`PDF downloaded: ${N.length} checks, ${H}.`:'Downloads work in the web app.')}}),(0,S.jsx)(x.Button,{kind:"secondary",label:"Print",testID:"report-print",disabled:!P||!N.length,onPress:()=>O((0,w.printTable)(`Food safety report: ${t}`,`${H} \xb7 ${N.length} checks \xb7 all readings entered by staff`,U,K)?'Print view opened in a new tab.':'Pop-ups are blocked: allow them to print.')}),(0,S.jsx)(x.Button,{kind:"secondary",label:"CSV",testID:"report-csv",disabled:!P||!N.length,onPress:()=>O((0,w.downloadText)(`food-safety-${_}-to-${E}.csv`,Q)?`CSV downloaded: ${N.length} checks.`:'Downloads work in the web app.')})]}),R?(0,S.jsx)(u.default,{testID:"report-msg",children:(0,S.jsx)(x.T,{size:14,colour:j.colours.ok,children:R})}):null]})};var t=_r(_d[0]),o=_r(_d[1]),s=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),a=_r(_d[7]),d=e(_r(_d[8])),c=e(_r(_d[9])),u=e(_r(_d[10])),h=_r(_d[11]),y=e(h),x=_r(_d[12]),p=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]),j=_r(_d[17]),w=_r(_d[18]),k=_r(_d[19]),S=_r(_d[20]);const D=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),T=e=>new Date(e).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'}),$=e=>e.replace(' (example)',''),C={ok:j.colours.ok,amber:j.colours.amber,red:j.colours.red,none:j.colours.muted},I={ok:'In range',amber:'Check',red:'Out of range',none:'No readings yet'},v=e=>{const t=e.trim().replace(',','.');return/^-?\d+(\.\d+)?$/.test(t)?Number(t):null},B=e=>{const[t,o,s]=e.split('-').map(Number);return new Date(t,o-1,s)},L=(e,t)=>{const o=new Date(e);return o.setDate(o.getDate()+t),o};function R(e,t,o){if('chef'===e.mode&&!(0,r.chefCanSee)(l.useOwner.getState().site,t))return;const s=(0,m.isTempKind)(t.kind)?(0,m.inRange)(t,o.value):!!o.done;f.useSafety.getState().addEntries([{pointId:t.id,name:t.name,kind:t.kind,at:e.now.toISOString(),by:$(e.me),byId:e.meId,app:e.mode,value:o.value,done:o.done,ok:s,corrective:o.corrective?.trim()||void 0,note:o.note?.trim()||void 0,source:o.source,photo:o.photo,initials:(0,m.initialsOf)(e.me)}])}function O({done:e,total:t,size:o=132}){const s=o/2-10,n=2*Math.PI*s,i=t?e/t:0;return(0,S.jsxs)(u.default,{testID:"today-ring",accessibilityLabel:`${e} of ${t} checks done`,style:{width:o,height:o,alignItems:'center',justifyContent:'center'},children:[(0,S.jsxs)(y.default,{width:o,height:o,style:{position:'absolute'},children:[(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:"#2A2722",strokeWidth:12,fill:"none"}),i>0?(0,S.jsx)(h.Circle,{cx:o/2,cy:o/2,r:s,stroke:i>=1?j.colours.ok:j.colours.gold,strokeWidth:12,fill:"none",strokeDasharray:`${n*i} ${n}`,strokeLinecap:"round",transform:`rotate(-90 ${o/2} ${o/2})`}):null]}),(0,S.jsxs)(x.T,{size:o/4.2,weight:"bold",children:[Math.round(100*i),"%"]}),(0,S.jsxs)(x.Muted,{children:[e," of ",t]})]})}function z({value:e,onChange:t}){const o=o=>'back'===o?t(e.slice(0,-1)):'\xb1'===o?t(e.startsWith('-')?e.slice(1):`-${e}`):'.'===o?t(e.includes('.')?e:`${e||'0'}.`):void(e.replace('-','').replace('.','').length>=4||t(e+o));return(0,S.jsxs)(u.default,{style:{gap:8},testID:"keypad",children:[(0,S.jsx)(x.Row,{wrap:!0,gap:8,children:['1','2','3','4','5','6','7','8','9','\xb1','0','.'].map(e=>(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:'\xb1'===e?'Minus':'.'===e?'Point':e,testID:`key-${'\xb1'===e?'minus':'.'===e?'dot':e}`,onPress:()=>o(e),style:({pressed:e})=>({flexBasis:'30%',flexGrow:1,height:58,borderRadius:14,borderWidth:1,borderColor:j.colours.border,backgroundColor:e?j.colours.goldTint:j.colours.surface2,alignItems:'center',justifyContent:'center'}),children:(0,S.jsx)(x.T,{size:24,weight:"semibold",children:'\xb1'===e?'\u2212/+':e})},e))}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Delete",testID:"key-back",onPress:()=>o('back'),style:{height:48,borderRadius:14,borderWidth:1,borderColor:j.colours.border,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,children:"\u232b Delete"})})]})}const _=['Moved food to another fridge','Re-checked in 30 minutes','Adjusted the thermostat','Called the engineer','Thrown away','Cooked for longer and re-probed'];function E({who:e,point:o,onDone:i,onCancel:r}){const l=(0,m.isTempKind)(o.kind),[h,y]=(0,a.useState)(''),[f,b]=(0,a.useState)(),[k,D]=(0,a.useState)(''),[T,C]=(0,a.useState)(''),[I,B]=(0,a.useState)(),[L,O]=(0,a.useState)(!1),[E,P]=(0,a.useState)(''),[M,N]=(0,a.useState)(!1),W=(0,a.useRef)(null),V=v(h),A=l?null==V?null:(0,m.inRange)(o,V):void 0===f?null:f,G=null!==A&&(A||k.trim().length>2);return(0,S.jsxs)(u.default,{testID:`record-${o.id}`,style:{gap:10,padding:12,borderRadius:14,borderWidth:1.5,borderColor:!1===A?j.colours.red:j.colours.gold,backgroundColor:(0,t.soutersSurface)('#14120F')},children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsxs)(u.default,{style:{flex:1},children:[(0,S.jsx)(x.T,{weight:"semibold",size:16,children:o.name}),(0,S.jsxs)(x.Muted,{children:[m.SECTION_LABEL[(0,m.sectionOf)(o)]," \xb7 safe: ",(0,m.limitText)(o)]})]}),(0,S.jsx)(s.GoldClose,{testID:"check-close",onPress:r,style:{marginRight:-6}})]}),l?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(x.Row,{style:{justifyContent:'center',gap:12},children:[(0,S.jsx)(u.default,{testID:"reading-display",style:{minWidth:150,paddingVertical:8,paddingHorizontal:16,borderRadius:14,borderWidth:2,borderColor:null==A?j.colours.border:A?j.colours.ok:j.colours.red,alignItems:'center'},children:(0,S.jsxs)(x.T,{size:40,weight:"bold",colour:null==A?j.colours.text:A?j.colours.ok:j.colours.red,children:[h||'\u2014',(0,S.jsx)(x.T,{size:22,children:" \xb0C"})]})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Say the reading",testID:"record-mic",onPress:()=>{const e=(0,w.speechRecognition)();if(!e)return void P("Voice isn't available in this browser. Use the keypad.");if(M)return void W.current?.stop();const t=new e;W.current=t,t.lang='en-GB',t.interimResults=!1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript??'',o=(0,m.spokenNumber)(t);P(null==o?`Heard \u201c${t}\u201d but no number. Use the keypad.`:`Heard \u201c${t}\u201d. Check it, then save.`),null!=o&&(y(String(o)),O(!0))},t.onerror=()=>P("Didn't catch that. Try again or use the keypad."),t.onend=()=>N(!1);try{t.start(),N(!0)}catch{P("Voice couldn't start. Use the keypad.")}},style:{width:64,height:64,borderRadius:32,borderWidth:2,borderColor:j.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:M?j.colours.gold:'transparent'},children:(0,S.jsx)(x.T,{size:26,children:M?'\u25a0':'\ud83c\udfa4'})})]}),null!=A?(0,S.jsx)(x.Row,{style:{justifyContent:'center'},children:(0,S.jsx)(x.Badge,{kind:A?'ok':'red',label:A?'OK':'OUT OF RANGE'})}):null,E?(0,S.jsx)(x.Muted,{center:!0,children:E}):null,(0,S.jsx)(z,{value:h,onChange:e=>{y(e),O(!1)}})]}):(0,S.jsxs)(x.Row,{gap:10,children:[(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Done",testID:"check-done",onPress:()=>b(!0),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.gold,backgroundColor:!0===f?j.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!0===f?'#0B0B0B':j.colours.gold,children:"\u2713 Done"})}),(0,S.jsx)(c.default,{accessibilityRole:"button",accessibilityLabel:"Not done",testID:"check-notdone",onPress:()=>b(!1),style:{flex:1,height:64,borderRadius:14,borderWidth:2,borderColor:j.colours.red,backgroundColor:!1===f?j.colours.red:'transparent',alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(x.T,{size:18,weight:"bold",colour:!1===f?'#0B0B0B':j.colours.red,children:"\u2715 Not done"})})]}),!1===A?(0,S.jsxs)(u.default,{testID:"corrective",style:{gap:8},children:[(0,S.jsx)(x.Banner,{kind:"danger",title:l?'Out of range: corrective action needed':'Not done: say what happened',children:"Write what you did before you can save."}),(0,S.jsx)(x.Row,{wrap:!0,gap:6,children:_.map(e=>(0,S.jsx)(x.Chip,{label:e,selected:k===e,onPress:()=>D(e)},e))}),(0,S.jsx)(n.TextInput,{accessibilityLabel:"Corrective action",testID:"corrective-input",value:k,onChangeText:D,placeholder:"Corrective action taken",placeholderTextColor:"#7D776C",style:[x.styles.input,!k.trim()&&{borderColor:j.colours.red}]}),(0,S.jsx)(x.Row,{gap:8,children:I?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(d.default,{source:{uri:I},style:{width:64,height:64,borderRadius:10},accessibilityLabel:"Photo added"}),(0,S.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove photo",onPress:()=>B(void 0)})]}):(0,S.jsx)(x.Button,{small:!0,kind:"secondary",label:"Add photo (optional)",testID:"add-photo",onPress:async()=>{const e=await(0,w.pickImageDataUrl)(480,!0);e&&B(e)}})})]}):null,(0,S.jsx)(n.TextInput,{accessibilityLabel:"Note (optional)",value:T,onChangeText:C,placeholder:"Note (optional)",placeholderTextColor:"#7D776C",style:x.styles.input}),(0,S.jsxs)(x.Row,{gap:8,style:{alignItems:'center'},children:[(0,S.jsx)(p.StaffAvatar,{id:e.meId,size:30}),(0,S.jsxs)(x.Muted,{style:{flex:1},children:["Signed ",(0,m.initialsOf)(e.me)," \xb7 ",$(e.me)," \xb7 ",e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})]})]}),(0,S.jsx)(x.Button,{label:"Sign and save",testID:"record-save",disabled:!G,onPress:()=>{R(e,o,{value:l?V:void 0,done:l?void 0:f,corrective:A?void 0:k,note:T,photo:A?void 0:I,source:L?'voice':'typed'}),i(`Saved: ${o.name}${l?` ${V}\xb0C`:f?' done':' not done'}, signed ${(0,m.initialsOf)(e.me)} at ${e.now.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`)}})]})}const P={done:j.colours.ok,overdue:j.colours.red,due:j.colours.amber,upcoming:j.colours.muted},M={done:'Done',overdue:'Overdue',due:'Due now',upcoming:'Later'};function N({p:e,history:t,w:o=220,h:s=54}){const n=t.slice(-14);if(n.length<2)return(0,S.jsx)(x.Muted,{children:"The trend line appears after two readings."});const i=n.map(e=>e.value),r=[e.min,e.max].filter(e=>null!=e),l=Math.min(...i,...r)-1,a=Math.max(...i,...r)+1,d=e=>6+e*(o-12)/(n.length-1),c=e=>s-6-(e-l)*(s-12)/(a-l||1);return(0,S.jsxs)(y.default,{width:o,height:s,testID:`spark-${e.id}`,children:[r.map(e=>(0,S.jsx)(h.Line,{x1:0,x2:o,y1:c(e),y2:c(e),stroke:j.colours.red,strokeOpacity:.6,strokeDasharray:"4 4",strokeWidth:1},e)),(0,S.jsx)(h.Polyline,{points:n.map((e,t)=>`${d(t)},${c(e.value)}`).join(' '),fill:"none",stroke:j.colours.gold,strokeWidth:2}),n.map((e,t)=>(0,S.jsx)(h.Circle,{cx:d(t),cy:c(e.value),r:3,fill:e.ok?j.colours.ok:j.colours.red},e.id))]})}const W=['Note','Problem','Extra check','Delivery']},1222,[828,1063,796,827,1221,835,891,34,336,402,102,797,794,925,1034,1035,1223,821,930,1224,25]); +__d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.buildPdf=function(n,c){const u=[];let i=[],f=794;const p=()=>{i.length&&u.push(i),i=[],f=794};for(const c of n){const n=c.size??10,u=1.35*n,l=c.indent??0;f-=c.gap??0;for(const $ of r(c.text,n,499-l,c.bold)){f-u<68&&p(),f-=u;const[r,g,h]=c.colour??[.07,.07,.07];for(const u of t(o(`BT /${c.bold?'F2':'F1'} ${n} Tf ${r} ${g} ${h} rg ${48+l} ${f.toFixed(1)} Td (`),s($),o(') Tj ET\n')))i.push(u)}}p();const l=[],$=n=>(l.push('string'==typeof n?o(n):n),l.length),g=$(''),h=$(''),T=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'),F=$('<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'),y=[];u.forEach((n,r)=>{const i=t(o("BT /F1 8 Tf 0.4 0.4 0.4 rg 48 28 Td ("),s(`${c} \xb7 Page ${r+1} of ${u.length}`),o(') Tj ET')),f=t(n,i),p=$(t(o(`<< /Length ${f.length} >>\nstream\n`),f,o('\nendstream')));y.push($(`<< /Type /Page /Parent ${h} 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 ${T} 0 R /F2 ${F} 0 R >> >> /Contents ${p} 0 R >>`))}),l[g-1]=o(`<< /Type /Catalog /Pages ${h} 0 R >>`),l[h-1]=o(`<< /Type /Pages /Kids [${y.map(n=>`${n} 0 R`).join(' ')}] /Count ${y.length} >>`);let E=t(o('%PDF-1.4\n'),[37,226,227,207,211,10]);const P=[];l.forEach((n,s)=>{P.push(E.length),E=t(E,o(`${s+1} 0 obj\n`),n,o('\nendobj\n'))});const R=E.length;return E=t(E,o(`xref\n0 ${l.length+1}\n0000000000 65535 f \n${P.map(n=>`${String(n).padStart(10,'0')} 00000 n \n`).join('')}trailer\n<< /Size ${l.length+1} /Root ${g} 0 R >>\nstartxref\n${R}\n%%EOF\n`)),new Uint8Array(E)};const n={8364:128,8218:130,402:131,8222:132,8230:133,8224:134,8225:135,710:136,8240:137,352:138,8249:139,338:140,381:142,8216:145,8217:146,8220:147,8221:148,8226:149,8211:150,8212:151,732:152,8482:153,353:154,8250:155,339:156,382:158,376:159},t=(...n)=>{const t=[];for(const o of n)for(const n of o)t.push(n);return t},o=n=>[...n].map(n=>255&n.charCodeAt(0));function s(t){const o=[];for(const s of t.replace(/\u2212/g,'-').replace(/[\u2190-\u21ff]/g,'>').replace(/[\u2713\u2714]/g,'Y')){const t=s.codePointAt(0),c=t<128||t>=160&&t<=255?t:n[t]??63;40!==c&&41!==c&&92!==c||o.push(92),o.push(c)}return o}const c=(n,t)=>[...n].reduce((n,t)=>n+(/[il.,:;'|!]/.test(t)?.28:/[mwMW@]/.test(t)?.86:/[A-Z0-9\xb0]/.test(t)?.66:' '===t?.28:.53),0)*(t?1.06:1);function r(n,t,o,s){const r=n.split(/\s+/),u=[];let i='';for(const n of r){const r=i?`${i} ${n}`:n;c(r,s)*t>o&&i?(u.push(i),i=n):i=r}return u.push(i),u}},1223,[]); +__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=r.IS_ISOLATED_VENUE?r.VENUE_RID: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=r.IS_ISOLATED_VENUE?r.VENUE_RID:s??o??r.VENUE_RID,E=(0,t.useStore)(t=>t.restaurants.find(t=>t.id===c));return u(c,E)}},1224,[831,891,5]); +__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.useMaySendInspectorLog=function(e){const t=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId));return(0,y.maySendInspectorLog)(e.mode,t)},_e.InspectorView=function({who:e}){const S=(0,x.useSafetyView)(e.mode),D=(0,t.useMemo)(()=>({...S,points:S.allPoints}),[S]),C=(0,h.useSafety)(e=>e.inspectorSends)??j,v=(0,c.useOwner)(t=>t.staff.find(t=>t.id===e.meId)),T=(0,u.useVenueInfo)(),L=(0,y.maySendInspectorLog)(e.mode,v),R=(0,p.ymdLocal)(e.now),k=(0,t.useMemo)(()=>(0,y.firstLogDay)(D,e.now),[D,e.now]),[$,M]=(0,t.useState)(''),[P,B]=(0,t.useState)(''),[E,Y]=(0,t.useState)(!0),[N,O]=(0,t.useState)(''),[A,W]=(0,t.useState)(''),[F,_]=(0,t.useState)(!1),[z,U]=(0,t.useState)(!1),[H,V]=(0,t.useState)(null);if(!L)return(0,I.jsx)(o.default,{testID:"inspector-locked",children:(0,I.jsx)(l.Banner,{kind:"info",title:"Owner, managers and Head Chef only",children:"Only the owner, a manager or the Head Chef can send the food-safety log to an inspector."})});const Q=E?k:(0,y.parseDmy)(N)??'',G=E?R:(0,y.parseDmy)(A)??'',q=!!Q&&!!G&&Q<=G,J=(0,y.inspectorNameProblem)($),K=(0,y.inspectorEmailProblem)(P),X=q?(0,y.logInRange)(D,Q,G):null,Z=!J&&!K&&q&&!!X&&X.records>0,ee=(0,y.senderRoleWords)(e.mode,v),te=e.me.replace(' (example)',''),ne=async()=>{U(!1);const t=(0,y.buildInspectorCsv)({log:{...D,inspectorSends:C},from:Q,to:G,venue:T.address||T.name,by:te,now:e.now,inspectorName:$,inspectorEmail:P}),n=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`,s=await w(t.fileName,t.csv,n);if(!s)return void V({kind:'warn',text:'Nothing was sent. Sharing and downloads work in the app on your phone or in the web app.'});const o=(0,y.prepareInspectorSend)({allowed:L,confirmed:!0,method:s,at:(new Date).toISOString(),by:te,byId:e.meId,role:ee,inspectorName:$,inspectorEmail:P,from:Q,to:G,records:t.records});o.ok?(h.useSafety.getState().logInspectorSend(o.send),V({kind:'success',text:'shared'===s?`Shared: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Pick your email and send it to ${P.trim()}. This is recorded in the log.`:`Downloaded: ${t.records} records, ${(0,y.rangeWords)(Q,G)}. Attach the file to an email to ${P.trim()}. This is recorded in the log.`})):V({kind:'warn',text:o.why})};return(0,I.jsxs)(o.default,{style:{gap:12,alignItems:'stretch'},testID:"inspector-view",children:[(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",size:17,center:!0,accessibilityRole:"header",children:"Inspector"}),(0,I.jsx)(l.Muted,{center:!0,children:"An environmental health inspector can have the full food-safety log: every temperature, delivery, cleaning and allergen check, diary notes and sign-offs."}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(o.default,{testID:"inspector-email-not-set-up",style:{alignSelf:'stretch'},children:(0,I.jsx)(l.Banner,{kind:"info",title:"Email isn\u2019t set up yet \u2014 share the file instead",children:"When you press Send logs and confirm, your phone\u2019s share sheet opens with the file, so you can email it yourself. If sharing isn\u2019t available, the file downloads."})}),(0,I.jsx)(l.Field,{label:"Inspector\u2019s name",testID:"inspector-name",value:$,onChangeText:e=>{M(e),U(!1)},autoCapitalize:"words",maxLength:80,textContentType:"name"}),F&&J?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:J})}):null,(0,I.jsx)(l.Field,{label:"Inspector\u2019s email",testID:"inspector-email",value:P,onChangeText:e=>{B(e),U(!1)},autoCapitalize:"none",autoCorrect:!1,keyboardType:"email-address",textContentType:"emailAddress",placeholder:"name@council.gov.uk",maxLength:254}),F&&K?(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",testID:"inspector-email-problem",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:K})}):null]}),(0,I.jsxs)(b.Box,{style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Dates"}),(0,I.jsxs)(l.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[(0,I.jsx)(l.Chip,{label:"All history",testID:"inspector-all",selected:E,accessibilityLabel:"All history",onPress:()=>{Y(!0),U(!1)}}),(0,I.jsx)(l.Chip,{label:"Choose dates",testID:"inspector-choose",selected:!E,accessibilityLabel:"Choose dates",onPress:()=>{Y(!1),U(!1),N||O((0,y.dmy)(k)),A||W((0,y.dmy)(R))}})]}),E?null:(0,I.jsxs)(o.default,{style:{gap:8,alignSelf:'stretch'},children:[(0,I.jsx)(l.Field,{label:"From (DD/MM/YYYY)",testID:"inspector-from",value:N,onChangeText:e=>{O((0,n.slashDate)(e,N)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10}),(0,I.jsx)(l.Field,{label:"To (DD/MM/YYYY)",testID:"inspector-to",value:A,onChangeText:e=>{W((0,n.slashDate)(e,A)),U(!1)},keyboardType:"numbers-and-punctuation",maxLength:10})]}),q?(0,I.jsxs)(l.Muted,{center:!0,testID:"inspector-range",children:[(0,y.rangeWords)(Q,G)," \xb7 ",X.records," record",1===X.records?'':'s']}):(0,I.jsx)(o.default,{accessibilityRole:"alert",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.T,{size:14,colour:f.colours.red,center:!0,children:"Use dates like 01/10/2026, with the first date on or before the second."})}),q&&0===X.records?(0,I.jsx)(l.Muted,{center:!0,children:"Nothing is logged in these dates yet."}):null]}),z?(0,I.jsxs)(o.default,{testID:"inspector-confirm",accessibilityLiveRegion:"polite",style:{gap:10,padding:14,borderRadius:14,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.goldTint,alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:(0,y.confirmQuestion)(P,Q,G)}),y.INSPECTOR_EMAIL.ready?null:(0,I.jsx)(l.Muted,{center:!0,children:"Email isn\u2019t set up yet, so the file opens in your share sheet to send it yourself."}),(0,I.jsx)(l.Button,{label:"Yes, send",testID:"inspector-confirm-yes",accessibilityLabel:`Yes, ${(0,y.confirmQuestion)(P,Q,G).replace(/\?$/,'')}`,onPress:()=>{ne()},style:{alignSelf:'stretch'}}),(0,I.jsx)(l.Button,{kind:"secondary",label:"Cancel",testID:"inspector-confirm-no",accessibilityLabel:"Cancel, nothing is sent",onPress:()=>U(!1),style:{alignSelf:'stretch'}})]}):(0,I.jsx)(l.Button,{label:"Send logs",testID:"inspector-send",accessibilityLabel:"Send logs to the inspector. You confirm before anything is sent.",onPress:()=>{_(!0),V(null),Z&&U(!0)},style:{alignSelf:'stretch',minHeight:56}}),H?(0,I.jsx)(o.default,{testID:"inspector-msg",accessibilityLiveRegion:"polite",children:(0,I.jsx)(l.Banner,{kind:H.kind,children:H.text})}):null,'success'===H?.kind?(0,I.jsx)(l.Button,{kind:"secondary",label:"Open my email",testID:"inspector-open-email",accessibilityLabel:`Open your email app with a message to ${P.trim()}. Attach the file, then send.`,onPress:()=>{const e=`Food safety log, ${T.name}, ${(0,y.rangeWords)(Q,G)}`;s.default.openURL(`mailto:${encodeURIComponent(P.trim())}?subject=${encodeURIComponent(e)}&body=${encodeURIComponent(`Dear ${$.trim()},\n\nPlease find our food safety log attached.\n\n${te}, ${T.name}`)}`).catch(()=>{})},style:{alignSelf:'stretch'}}):null,(0,I.jsxs)(b.Box,{testID:"inspector-sends",style:{alignItems:'center'},children:[(0,I.jsx)(l.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Sent to inspectors"}),C.length?C.slice(0,20).map(e=>(0,I.jsxs)(l.Muted,{center:!0,children:[new Date(e.at).toLocaleString('en-GB',{day:'numeric',month:'short',year:'numeric',hour:'2-digit',minute:'2-digit'})," \xb7 ",e.by," (",e.role,") ",'emailed'===e.method?'emailed':'shared'===e.method?'shared':'downloaded'," ",(0,y.rangeWords)(e.from,e.to)," for ",e.inspectorName,", ",e.inspectorEmail]},e.id)):(0,I.jsx)(l.Muted,{center:!0,children:"Nothing sent yet."})]})]})};var t=r(d[0]),n=r(d[1]),s=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=r(d[5]),c=r(d[6]),h=r(d[7]),u=r(d[8]),p=r(d[9]),y=r(d[10]),f=r(d[11]),b=r(d[12]),x=r(d[13]),I=r(d[14]);async function w(e,t,n){if('undefined'==typeof window)return null;const s=globalThis.navigator;try{const o=globalThis.File;if(o&&s?.canShare){const l=new o(['\ufeff'+t],e,{type:'text/csv'});if(s.canShare({files:[l]}))return await s.share({files:[l],title:n,text:n}),'shared'}}catch(e){if(e&&'AbortError'===e.name)return null}return(0,b.downloadText)(e,t)?'downloaded':null}const j=[]},1225,[34,1063,379,236,102,794,891,1034,1224,1035,1226,821,930,1221,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"INSPECTOR_EMAIL",{enumerable:!0,get:function(){return t}}),_e.inspectorEmailProblem=n,Object.defineProperty(_e,"isInspectorEmail",{enumerable:!0,get:function(){return r}}),_e.inspectorNameProblem=a,_e.maySendInspectorLog=function(e,t){return'staff'!==e&&('chef'===e||!!t&&('owner'===t.role||'manager'===t.role||'Head Chef'===t.level))},_e.senderRoleWords=function(e,t){return'chef'===e||'Head Chef'===t?.level?'Head Chef':'owner'===t?.role?'Owner':'Manager'},_e.parseDmy=function(t){const o=/^\s*(\d{1,2})[/.\- ](\d{1,2})[/.\- ](\d{4})\s*$/.exec(t??'');if(!o)return null;const n=Number(o[1]),r=Number(o[2]),a=Number(o[3]),s=new Date(a,r-1,n);return s.getFullYear()!==a||s.getMonth()!==r-1||s.getDate()!==n?null:(0,e.ymdLocal)(s)},Object.defineProperty(_e,"dmy",{enumerable:!0,get:function(){return i}}),_e.rangeWords=c,_e.confirmQuestion=function(e,t,o){return`Send the full food-safety log, ${c(t,o)}, to ${e.trim()}?`},_e.firstLogDay=function(t,o){const n=[...t.entries.map(t=>(0,e.ymdLocal)(new Date(t.at))),...(t.diary??[]).map(e=>e.date),...(t.daySigns??[]).map(e=>e.date),...(t.weekly??[]).map(e=>e.week)].filter(e=>/^\d{4}-\d{2}-\d{2}$/.test(e)).sort(),r=(0,e.ymdLocal)(o);return n.length&&n[0]t.log.points.find(t=>t.id===e.pointId),r=[];for(const t of o.entries){const o=n(t);r.push(['Check',u(t.at),f(t.at),o?e.SECTION_LABEL[(0,e.sectionOf)(o)]:'',t.name,e.KIND_LABEL[t.kind]??'',(0,e.fmtEntryValue)(t),o?(0,e.limitText)(o):'',t.ok?'OK':null!=t.value?'OUT OF RANGE':'NOT DONE',t.corrective??'',t.note??'',`${t.initials??''} ${t.by}`.trim(),'probe'===t.source?'Wireless probe':'voice'===t.source?'Voice, confirmed':'Typed'])}for(const e of o.diary)r.push([`Diary: ${e.kind}`,i(e.date),f(e.at),'','','','','','',e.action??'',e.text,e.by,'']);for(const e of o.daySigns)r.push(['Daily sign-off: safe methods followed',i(e.date),f(e.at),'Management','','','','','Signed','','',e.by,'']);for(const t of o.weekly)r.push([`Weekly sign-off (week of ${i(t.week)})`,u(t.at),f(t.at),'Management','','',`${t.answers.filter(Boolean).length} of ${e.WEEKLY_QUESTIONS.length} answered yes`,'','Signed','',t.note??'',`${t.by} (${t.role})`,'']),e.WEEKLY_QUESTIONS.forEach((e,o)=>r.push([`Weekly question (week of ${i(t.week)})`,u(t.at),'','Management',e,'',t.answers[o]?'Yes':'No','','','','',t.by,'']));for(const e of(t.log.inspectorSends??[]).filter(e=>e.at.slice(0,10)<=t.to))r.push(['Log sent to inspector',u(e.at),f(e.at),'Management','','',`${i(e.from)} to ${i(e.to)}`,'','emailed'===e.method?'Emailed':'shared'===e.method?'Shared':'Downloaded','',`${e.inspectorName} <${e.inspectorEmail}>`,`${e.by} (${e.role})`,'']);const a=[['Food safety log (HACCP): full record'],[t.venue],[`Dates: ${c(t.from,t.to)}`],[`For: ${t.inspectorName.trim()} <${t.inspectorEmail.trim()}>`],[`Produced ${t.now.toLocaleString('en-GB')} by ${t.by}`],['Every reading was entered and signed by a member of staff. The app never fills in or estimates a reading.'],[]];return{csv:[...a,y,...r].map(e=>e.map(m).join(',')).join('\r\n')+'\r\n',records:o.records,fileName:`food-safety-log-${t.from}-to-${t.to}.csv`}},_e.prepareInspectorSend=function(e){if(!e.allowed)return{ok:!1,why:'Only the owner, a manager or the Head Chef can send the food-safety log.'};if(!e.confirmed)return{ok:!1,why:'Confirm before anything is sent.'};const o=a(e.inspectorName);if(o)return{ok:!1,why:o};const r=n(e.inspectorEmail);return r?{ok:!1,why:r}:!/^\d{4}-\d{2}-\d{2}$/.test(e.from)||!/^\d{4}-\d{2}-\d{2}$/.test(e.to)||e.from>e.to?{ok:!1,why:'Check the dates: the first date must be on or before the second.'}:'emailed'!==e.method||t.ready?{ok:!0,send:{at:e.at,by:e.by,byId:e.byId,role:e.role,inspectorName:e.inspectorName.trim(),inspectorEmail:e.inspectorEmail.trim(),from:e.from,to:e.to,records:e.records,method:e.method}}:{ok:!1,why:t.why}};var e=_r(_d[0]);const t={ready:!1,why:'Email isn\u2019t set up yet \u2014 share the file instead.'},o=/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/;function n(e){const t=(e??'').trim();return t?t.length>254||!o.test(t)||/\.\./.test(t)||/^\.|\.@|@\./.test(t)?'That email address doesn\u2019t look right. Check it, for example name@council.gov.uk.':'':'Enter the inspector\u2019s email address.'}const r=e=>''===n(e);function a(e){const t=(e??'').trim();return t.length<2?'Enter the inspector\u2019s name.':t.length>80?'Keep the name under 80 characters.':''}const s=e=>{const[t,o,n]=e.split('-').map(Number);return new Date(t,o-1,n)},i=e=>{const[t,o,n]=e.split('-');return`${n}/${o}/${t}`},l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];function c(e,t){const o=s(e),n=s(t),r=e=>`${e.getDate()} ${l[e.getMonth()]} ${e.getFullYear()}`;return e===t?r(n):`${o.getFullYear()===n.getFullYear()?`${o.getDate()} ${l[o.getMonth()]}`:r(o)} \u2013 ${r(n)}`}function d(t,o,n){const r=e=>e>=o&&e<=n,a=t.entries.filter(t=>r((0,e.ymdLocal)(new Date(t.at)))).sort((e,t)=>e.at.localeCompare(t.at)),i=(t.diary??[]).filter(e=>r(e.date)).sort((e,t)=>e.at.localeCompare(t.at)),l=(t.daySigns??[]).filter(e=>r(e.date)).sort((e,t)=>e.date.localeCompare(t.date)),c=(t.weekly??[]).filter(t=>{const a=new Date(s(t.week));return a.setDate(a.getDate()+6),r(t.week)||r((0,e.ymdLocal)(a))||t.weekn}).sort((e,t)=>e.week.localeCompare(t.week));return{entries:a,diary:i,daySigns:l,weekly:c,records:a.length+i.length+l.length+c.length}}const m=e=>{const t=null==e?'':String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t},f=e=>new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}),u=e=>new Date(e).toLocaleDateString('en-GB'),y=['Record','Date','Time','Section','Check','Type','Reading or answer','Safe limit','Result','Corrective action','Note','Recorded by','How entered']},1226,[1035]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.SpecialsEditor=function(t){return null}},1227,[]); +__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 k}}),_e.useCss=function(){(0,a.useEffect)(()=>{if(!h||document.getElementById('cc-alert-css'))return;const e=document.createElement('style');e.id='cc-alert-css',e.textContent=y,document.head.appendChild(e)},[])},_e.KindChip=function({kind:e,size:t=34}){return(0,x.jsx)(o.default,{testID:`kind-chip-${e}`,style:{width:t,height:t,borderRadius:10,backgroundColor:'rgba(207,164,95,0.16)',alignItems:'center',justifyContent:'center'},children:(0,x.jsx)(j,{kind:e,size:Math.round(.53*t),colour:"#CFA45F"})})},_e.KindIcon=j,_e.SoundToggle=function({big:e}){const t=(0,b.useAlerts)(e=>e.prefs.muted);return(0,x.jsx)(s.default,{accessibilityRole:"switch",accessibilityState:{checked:!t},accessibilityLabel:t?'Alert sound off, tap to turn on':'Alert sound on, tap to mute',onPress:()=>b.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:u.colours.border},children:(0,x.jsx)(p.T,{size:e?15:12,colour:t?u.colours.muted:u.colours.gold,children:t?'Sound off':'Sound on'})})},_e.AlertHost=function({variant:e,rid:t,me:s,onOpen:o,skipTakeaway:l}){const c=(0,b.useAlerts)(e=>e.live).filter(n=>!(n.rid!==t||'chef'===e&&'takeaway'!==n.kind&&'review'!==n.kind||l&&'takeaway'===n.kind&&!n.test)),d=e=>'booking'===e.kind||'pending'===e.kind,u=c.filter(d),p=c.filter(e=>!d(e));D('managers'===e&&!n.ALERTS_PROMPT_ON);const h=p.map(e=>e.id+':'+e.at).join('|'),k=(0,a.useRef)({me:s,onOpen:o});return k.current={me:s,onOpen:o},(0,a.useEffect)(()=>{const t=new Set(p.map(e=>`alert:${e.id}`));m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')&&!t.has(e.id)&&!e.id.startsWith('alert-keep:'));for(const t of p){const n=b.KIND_META[t.kind],a='display'===e;(0,m.notify)({id:`alert:${t.id}`,tone:A(t),big:a,testID:'alert-slider',kicker:`${n.kicker}${t.test?' \xb7 TEST':''}${t.nag?` \xb7 REMINDER ${t.nag}`:''} \xb7 ${w(t.at)}`,title:t.name,timeoutMs:I(t,e),content:({close:n})=>(0,x.jsx)(C,{a:t,variant:e,big:a,me:k.current.me,onOpen:k.current.onOpen,close:n}),onClose:()=>b.useAlerts.getState().dismiss(t.id)})}},[h,e]),(0,a.useEffect)(()=>()=>m.useSliders.getState().dismissWhere(e=>e.id.startsWith('alert:')),[]),(0,x.jsx)(f.BookingBanners,{alerts:u,big:'display'===e,managers:'managers'===e,me:s,onOpen:o,onClose:e=>b.useAlerts.getState().dismiss(e.id)})};var t=r(_d[0]),n=r(_d[1]),a=r(_d[2]);r(_d[3]);var s=e(r(_d[4])),o=e(r(_d[5])),l=r(_d[6]),c=e(l),d=r(_d[7]),u=r(_d[8]),p=r(_d[9]),f=r(_d[10]),m=r(_d[11]),b=r(_d[12]),x=r(_d[13]);const h='undefined'!=typeof document,k=e=>({dataSet:{ccal:e}}),y="\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-ok\"]{animation:ccal-glow-ok 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-ok{0%,100%{box-shadow:0 0 0 1.5px rgba(207,164,95,.9),0 10px 40px rgba(207,164,95,.22)}50%{box-shadow:0 0 0 1.5px #CFA45F,0 10px 70px rgba(207,164,95,.5)}}\n@keyframes ccal-glow-blue{0%,100%{box-shadow:0 0 0 1.5px rgba(226,196,137,.9),0 10px 40px rgba(226,196,137,.22)}50%{box-shadow:0 0 0 1.5px #E2C489,0 10px 70px rgba(226,196,137,.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";const w=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`};function j({kind:e,size:t=22,colour:n}){const a='booking'===e||'pending'===e||'takeaway'===e||'email'===e||'review'===e||'test'===e,s={stroke:n??b.KIND_META[e]?.colour??'#CFA45F',strokeWidth:2,fill:'none',strokeLinecap:'round',strokeLinejoin:'round'};return(0,x.jsxs)(c.default,{width:t,height:t,viewBox:"0 0 24 24",children:['booking'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"16",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 10h18M8 3v4M16 3v4M9 15l2 2 4-4",...s})]}):null,'pending'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Circle,{cx:"12",cy:"13",r:"8",...s}),(0,x.jsx)(l.Path,{d:"M12 9v4l2.5 2M9 2h6",...s})]}):null,'takeaway'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M5 8h14l-1.2 12H6.2z",...s}),(0,x.jsx)(l.Path,{d:"M9 8V6a3 3 0 0 1 6 0v2",...s})]}):null,'email'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Rect,{x:"3",y:"5",width:"18",height:"14",rx:"2",...s}),(0,x.jsx)(l.Path,{d:"M3 7l9 6 9-6",...s})]}):null,'review'===e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H10l-4 3.5V17H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z",...s}),(0,x.jsx)(l.Path,{d:"M12 7.6l1.1 2.3 2.5.3-1.8 1.7.5 2.5-2.3-1.2-2.3 1.2.5-2.5-1.8-1.7 2.5-.3z",...s,strokeWidth:1.4})]}):null,'test'===e?(0,x.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",...s}):null,a?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(l.Path,{d:"M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z",...s}),(0,x.jsx)(l.Path,{d:"M10 20a2 2 0 0 0 4 0",...s})]})]})}function S({label:e,value:t,big:n}){return(0,x.jsxs)(o.default,{style:{minWidth:n?130:66,flexGrow:1,paddingVertical:n?10:6,paddingHorizontal:n?14:10,borderRadius:10,backgroundColor:'rgba(255,255,255,0.04)',borderWidth:1,borderColor:'rgba(207,164,95,0.22)'},children:[(0,x.jsx)(p.T,{size:n?13:10,weight:"semibold",colour:m.SLIDER.quiet,style:{letterSpacing:1.4},children:e}),(0,x.jsx)(p.T,{size:n?28:16,weight:"bold",numberOfLines:1,children:t})]})}function T({label:e,onPress:t,kind:n="primary",testID:a,big:s}){return(0,x.jsx)(m.SliderButton,{a:{label:e,kind:n,testID:a,onPress:t,keepOpen:!0},onDone:()=>{},big:s})}const I=(e,t)=>'display'===t?12e3:'chef'===t?15e3:'pending'===e.kind||'takeaway'===e.kind?null:1e4,A=e=>e.allergy?'urgent':'pending'===e.kind?'warn':'normal';function C({a:e,variant:n,big:s,me:l,onOpen:c,close:f}){const[b,h]=(0,a.useState)(!1),[k,y]=(0,a.useState)(null),w=e=>{y(e),setTimeout(f,1800)},j='managers'===n,I=l??'Manager',A='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',(0,t.tableNumbers)(e.table)]]:[],['SOURCE',e.source??'']];return(0,x.jsxs)(o.default,{testID:`alert-${e.kind}`,style:{gap:s?12:8},children:['email'===e.kind?(0,x.jsx)(p.T,{size:s?22:14,numberOfLines:2,children:e.subject}):null,A.length?(0,x.jsx)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:s?10:6},children:A.map(([e,t])=>(0,x.jsx)(S,{label:e,value:t,big:s},e))}):null,e.allergy?(0,x.jsxs)(o.default,{testID:"alert-allergy",style:{flexDirection:'row',gap:10,alignItems:'center',borderLeftWidth:4,borderColor:u.colours.red,backgroundColor:'rgba(255,107,94,0.10)',borderRadius:8,padding:s?12:8},children:[(0,x.jsx)(p.T,{size:s?16:11,weight:"bold",colour:u.colours.red,style:{letterSpacing:1.6},children:"ALLERGY"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(p.T,{size:s?22:14,weight:"semibold",colour:"#FFE1DC",children:e.allergy}),e.allergyStep?(0,x.jsx)(p.T,{size:s?15:11,colour:"#FFC4BB",children:e.allergyStep}):null]})]}):null,'pending'===e.kind&&'managers'!==n?(0,x.jsx)(p.T,{size:s?18:13,colour:u.colours.amber,children:"Waiting for a manager to confirm it in the Managers app."}):null,'email'===e.kind&&e.test?(0,x.jsx)(p.T,{size:12,colour:m.SLIDER.quiet,children:"Test only. No venue email is connected yet."}):null,k?(0,x.jsx)(p.T,{size:14,weight:"semibold",colour:u.colours.goldLight,children:k}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'flex-end',alignItems:'center'},children:[j&&!k?'pending'===e.kind?b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(p.T,{size:14,colour:"#FFE1DC",style:{flexBasis:'100%'},children:["Decline this booking? We\u2019ll let ",e.name," know by text",e.test?' (test: nothing happens)':' (preview mode)',"."]}),(0,x.jsx)(T,{kind:"danger",label:"Yes, decline it",testID:"alert-decline-yes",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'declined',I),w('Declined. The guest\u2019s message is in the Outbox.')}}),(0,x.jsx)(T,{kind:"ghost",label:"Keep it",onPress:()=>h(!1)})]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Confirm",testID:"alert-confirm",onPress:()=>{e.refId&&!e.test&&d.repo.bookings.decide(e.refId,'confirmed',I),w(e.test?'Test alert: nothing to confirm.':'Confirmed. Their confirmation is ready in the Outbox.')}}),(0,x.jsx)(T,{kind:"danger",label:"Decline",testID:"alert-decline",onPress:()=>h(!0)})]}):'takeaway'===e.kind?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(T,{label:"Accept",testID:"alert-accept",onPress:async()=>{const t=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I);w(t?'Accepted.':'Accepted. The allergy sign-off is still needed before cooking.')}}),[15,20,30].map(t=>(0,x.jsx)(T,{kind:"ghost",label:`Ready in ${t}`,onPress:async()=>{const n=!(e.refId&&!e.test)||await d.repo.orders.accept(e.refId,I,t);w(`Accepted, ready in ${t} minutes.${n?'':' Allergy sign-off still needed.'}`)}},t))]}):'booking'===e.kind&&c?(0,x.jsx)(T,{kind:"ghost",label:"View bookings",onPress:()=>{f(),c(e)}}):null:null,k?null:(0,x.jsx)(T,{kind:"ghost",label:!j||'pending'!==e.kind&&'takeaway'!==e.kind?'Close':'Later',testID:"alert-close",onPress:f})]})]})}function D(e){const t=(0,b.useAlerts)(e=>e.askedSystem);(0,a.useEffect)(()=>{if(!e||t||'default'!==(0,b.systemSupport)())return;const n=setTimeout(()=>(0,m.notify)({id:'notify-prompt',testID:'notify-prompt',icon:'\ud83d\udd14',title:'Get booking alerts on this device?',body:'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.',actions:[{label:'Turn on alerts',testID:'notify-allow',onPress:()=>{(0,b.requestSystemPermission)().then(()=>b.useAlerts.getState().setAsked())}},{label:'Not now',kind:'ghost',onPress:()=>b.useAlerts.getState().setAsked()}]}),2500);return()=>clearTimeout(n)},[e,t])}},1228,[860,1058,34,236,402,102,797,874,821,794,1229,1130,1230,25]); +__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,"BANNER_MS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e2,"MAX_STACK",{enumerable:!0,get:function(){return I}}),_e2.BookingBanners=function({alerts:e,big:n,managers:t,me:l,onOpen:d,onClose:b}){const g=(0,a.useSafeAreaInsets)();if((0,o.useEffect)(()=>{if(!h||document.getElementById('cc-banner-css'))return;const e=document.createElement('style');e.id='cc-banner-css',e.textContent=p,document.head.appendChild(e)},[]),!e.length)return null;const y=e.slice(0,I),x=e.length-y.length,R=(0,f.jsxs)(s.default,{testID:"booking-banners",pointerEvents:"box-none",style:{position:h?'fixed':'absolute',left:10,right:n?10:76,top:8+g.top,zIndex:2147483001,gap:8,alignItems:'center',...h?{top:"calc(8px + env(safe-area-inset-top))"}:{}},children:[y.map(e=>(0,f.jsx)(C,{a:e,big:n,managers:t,me:l,onOpen:d,onClose:()=>b(e)},e.id+':'+e.at)),x>0?(0,f.jsx)(s.default,{style:{paddingHorizontal:12,paddingVertical:4,borderRadius:999,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:u.SLIDER.border},children:(0,f.jsxs)(c.T,{size:13,colour:u.SLIDER.quiet,children:[x," more new ",1===x?'booking':'bookings']})}):null]});if(h)try{const e=r(_d[13],"react-dom");if(e?.createPortal)return e.createPortal(R,document.body)}catch{}return R};var n=r(_d[0]),o=r(_d[1]),t=e(r(_d[2]));r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),a=r(_d[6]),d=r(_d[7]),c=r(_d[8]),b=r(_d[9]),u=r(_d[10]),g=r(_d[11]),f=r(_d[12]);const h='undefined'!=typeof document,p="[data-ccbn=\"in\"]{animation:ccbn-in .42s cubic-bezier(.2,1,.3,1) both}\n@keyframes ccbn-in{from{opacity:0;transform:translate3d(0,-120%,0)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion: reduce){[data-ccbn]{animation:none !important}}",y=e=>h?{dataSet:{ccbn:e}}:{},x=7e3,I=3;function C({a:e,big:a,managers:p,me:I,onOpen:C,onClose:R}){const j='pending'===e.kind,[k,D]=(0,o.useState)(null),L=j&&p&&!k;(0,o.useEffect)(()=>{if(L)return;const e=setTimeout(R,k?1800:x);return()=>clearTimeout(e)},[L,k]);const S=(0,o.useRef)(t.default.create({onMoveShouldSetPanResponder:(e,n)=>n.dy<-12&&Math.abs(n.dy)>Math.abs(n.dx),onPanResponderRelease:(e,n)=>{n.dy<-30&&R()}})).current,E=e.covers?`${e.covers} ${1===e.covers?'Cover':'Covers'}`:'',z=[e.when,E,e.table?(0,n.tableNumbers)(e.table):''].filter(Boolean).join(' \xb7 '),v=j?'Booking request':'New booking',w=[e.when,E,e.table?(0,n.tableNumbersA11y)(e.table):''].filter(Boolean).join(', '),T=`${v}: ${e.name}${w?', '+w:''}${e.allergy?'. Allergy: '+e.allergy:''}.${C?' Tap to open bookings.':''}`,$=n=>{e.refId&&!e.test&&g.repo.bookings.decide(e.refId,n,I??'Manager'),D('confirmed'===n?'Confirmed.':'Declined.')};return(0,f.jsxs)(s.default,{...S.panHandlers,...y('in'),testID:`booking-banner-${e.kind}`,style:{width:'100%',maxWidth:a?720:520,alignSelf:'center',flexDirection:'row',alignItems:'center',borderRadius:14,backgroundColor:u.SLIDER.bg,borderWidth:1,borderColor:e.allergy?'rgba(255,107,94,.75)':u.SLIDER.border,borderLeftWidth:5,borderLeftColor:e.allergy?d.colours.red:j?d.colours.amber:d.colours.gold,...h?{boxShadow:'0 8px 24px rgba(0,0,0,.55)'}:{elevation:10}},children:[(0,f.jsxs)(l.default,{testID:"booking-banner-open",accessibilityRole:"button",accessibilityLabel:T,disabled:!C,onPress:()=>{R(),C?.(e)},style:{flex:1,minHeight:56,paddingVertical:a?12:8,paddingLeft:12,paddingRight:6,gap:2},children:[(0,f.jsx)(c.T,{size:a?14:12,weight:"bold",colour:j?d.colours.amber:d.colours.gold,style:{letterSpacing:1.2},children:k??v.toUpperCase()}),(0,f.jsx)(c.T,{size:a?22:17,weight:"semibold",colour:u.SLIDER.text,numberOfLines:1,children:e.name}),z?(0,f.jsx)(c.T,{size:a?18:15,colour:u.SLIDER.quiet,numberOfLines:1,children:z}):null,e.allergy?(0,f.jsxs)(c.T,{size:a?16:14,weight:"semibold",colour:d.colours.red,numberOfLines:2,children:["Allergy: ",e.allergy]}):null]}),L?(0,f.jsxs)(s.default,{style:{gap:6,paddingVertical:6},children:[(0,f.jsx)(l.default,{testID:"booking-banner-confirm",accessibilityRole:"button",accessibilityLabel:`Confirm ${e.name}'s booking`,onPress:()=>$('confirmed'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,backgroundColor:u.SLIDER.gold,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,weight:"bold",colour:u.SLIDER.ink,children:"Confirm"})}),(0,f.jsx)(l.default,{testID:"booking-banner-decline",accessibilityRole:"button",accessibilityLabel:`Decline ${e.name}'s booking`,onPress:()=>$('declined'),style:{minHeight:44,minWidth:88,paddingHorizontal:12,borderRadius:10,borderWidth:1,borderColor:d.colours.red,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(c.T,{size:15,colour:d.colours.red,children:"Decline"})})]}):null,(0,f.jsx)(b.ToastClose,{testID:"booking-banner-close",label:`Close ${v.toLowerCase()} for ${e.name}`,onPress:R,size:a?'lg':'md',colour:u.SLIDER.quiet,style:{minWidth:56,minHeight:56,marginRight:4}})]})}},1229,[860,34,380,236,402,102,36,821,794,796,1130,874,25,277]); +__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:'CoverCharge test',subject:'This is a test alert. No real email was received.'}:'review'===a?{...o,id:`test-review:${Date.now()}`,kind:'review',name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}:{...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]),s=r(d[6]);Object.keys(s).forEach(function(t){'default'===t||Object.prototype.hasOwnProperty.call(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return s[t]}})})},1230,[1231,1232,1234,1233,1235,1048,1236]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KIND_META",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"ALERT_KINDS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NAG_MS",{enumerable:!0,get:function(){return n}});const o={booking:{kicker:'NEW BOOKING',label:'New bookings',colour:'#CFA45F',glow:'rgba(207,164,95,'},pending:{kicker:'BOOKING NEEDS CONFIRMING',label:'Needs confirming',colour:'#FFB547',glow:'rgba(255,181,71,'},takeaway:{kicker:'NEW TAKEAWAY ORDER',label:'Takeaway orders',colour:'#CFA45F',glow:'rgba(207,164,95,'},email:{kicker:'NEW EMAIL',label:'Emails',colour:'#E2C489',glow:'rgba(226,196,137,'},review:{kicker:'NEW REVIEW',label:'Reviews',colour:'#CFA45F',glow:'rgba(207,164,95,'},test:{kicker:'TEST ALERT',label:'Tests',colour:'#E2C489',glow:'rgba(226,196,137,'}},l=['booking','pending','takeaway','email','review'],n=18e4},1231,[]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"isUnread",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isCleared",{enumerable:!0,get:function(){return A}}),Object.defineProperty(_e,"DEFAULT_PREFS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"useAlerts",{enumerable:!0,get:function(){return u}});var e,t=r(d[0]),s=(e=t)&&e.__esModule?e:{default:e},i=r(d[1]),n=r(d[2]),a=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]);const f=(e,t)=>!e.read[t.id]&&t.at>(e.readAllAt?.[t.rid]??0),A=(e,t)=>{const s=e.cleared?.[t.rid];return!!s&&(t.at<=s.all||void 0!==s.ids[t.id]&&t.at<=s.ids[t.id])},p=(e,t)=>Object.fromEntries(Object.entries(e).filter(([,e])=>e>t).sort((e,t)=>t[1]-e[1]).slice(0,1e3)),y={muted:!1,types:{booking:!0,pending:!0,takeaway:!0,email:!0,review:!0,test:!0},system:!0},u=(0,n.create)()((0,a.persist)((e,t)=>({history:[],read:{},seen:{},seenAt:{},todoSeen:{},readAllAt:{},prefs:y,askedSystem:!1,live:[],cleared:{},clearAlerts:(t,s,i)=>e(e=>{const n=e.cleared[t]??{all:0,ids:{}},a=Math.max(n.all,i??0),l={...n.ids};for(const[e,t]of Object.entries(s))l[e]=Math.max(l[e]??0,t);const o={...e.cleared,[t]:{all:a,ids:p(l,a)}};return{cleared:o,live:e.live.filter(e=>!A({cleared:o},e))}}),raise:(s,i)=>{const n=t().history.find(e=>e.id===s.id),a=!!n&&(s.nag??0)>(n.nag??0);e(e=>{const t={...e.read};return n&&!a||delete t[s.id],{history:[s,...e.history.filter(e=>e.id!==s.id)].slice(0,150),read:t}});const f=t().prefs;!1!==f.types[s.kind]&&(e(e=>({live:[s,...e.live.filter(e=>e.id!==s.id)].slice(0,12)})),f.muted||i?.quiet||'chef'===l.APP_VARIANT||'display'===l.APP_VARIANT||(0,o.chime)(a?'soft':'bright'),f.system&&'owner'===l.APP_VARIANT&&(0,c.showSystemNotification)(s))},dismiss:t=>e(e=>({live:e.live.filter(e=>e.id!==t)})),dropLive:s=>{t().live.some(s)&&e(e=>({live:e.live.filter(e=>!s(e))}))},markRead:t=>e(e=>({read:{...e.read,...Object.fromEntries(t.map(e=>[e,!0]))}})),setPrefs:t=>e(e=>({prefs:{...e.prefs,...t}})),setType:(t,s)=>e(e=>({prefs:{...e.prefs,types:{...e.prefs.types,[t]:s}}})),markSeen:(t,s)=>e(e=>({seen:{...e.seen,[t]:[...new Set([...e.seen[t]??[],...s])].slice(-2e4)}})),markAllRead:(t,s,i)=>e(e=>({readAllAt:{...e.readAllAt,[t]:Math.max(e.readAllAt[t]??0,s)},read:{...e.read,...Object.fromEntries(e.history.filter(e=>e.rid===t&&(i||e.at<=s)).map(e=>[e.id,!0]))},live:i?e.live.filter(e=>e.rid!==t):e.live})),markAllSeen:(t,s,i)=>e(e=>({seenAt:{...e.seenAt,[t]:Math.max(e.seenAt[t]??0,s)},todoSeen:i?{...e.todoSeen,[t]:[...new Set(i)].slice(-400)}:e.todoSeen})),setAsked:()=>e({askedSystem:!0}),clearHistory:()=>e({history:[],read:{}})}),{name:`covercharge-alerts-${l.APP_VARIANT}-v1`,version:2,storage:(0,a.createJSONStorage)(()=>s.default),partialize:e=>({history:e.history,read:e.read,seen:e.seen,seenAt:e.seenAt,todoSeen:e.todoSeen,readAllAt:e.readAllAt,prefs:e.prefs,askedSystem:e.askedSystem,cleared:e.cleared}),migrate:(e,t)=>{if(e&&t<2){const t={...e.read??{}};for(const s of e.history??[])'booking'!==s.kind&&'pending'!==s.kind||(t[s.id]=!0);return{...e,read:t,seenAt:{},todoSeen:{},readAllAt:{}}}return e},merge:(e,t)=>({...t,...e,cleared:e?.cleared??{},prefs:{...y,...e?.prefs??{},types:{...y.types,...e?.prefs?.types??{}}}})}));'undefined'!=typeof window&&'function'==typeof window.addEventListener&&window.addEventListener('storage',e=>{e.key===(0,i.venueKey)(u.persist.getOptions().name??'')&&u.persist.rehydrate()})},1232,[839,5,846,849,872,1048,1233]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.systemSupport=s,e.requestSystemPermission=async function(){if('unsupported'===s())return'unsupported';try{return await window.Notification.requestPermission()}catch{return s()}},Object.defineProperty(e,"isInstalled",{enumerable:!0,get:function(){return c}}),e.alertText=l,e.showSystemNotification=async function(t,o=!1){if('granted'!==s())return!1;if(!o&&'visible'===document.visibilityState)return!1;const{title:a,body:c}=l(t),u={body:c,tag:t.id,renotify:!0,icon:`/${n.APP_VARIANT}-app/icon-192.png`,data:{url:location.href}};try{const t=await(navigator.serviceWorker?.getRegistration?.());return t?.showNotification?(await t.showNotification(a,u),!0):(new window.Notification(a,u),!0)}catch{return!1}},Object.defineProperty(e,"PUSH_BACKEND",{enumerable:!0,get:function(){return u}}),e.subscribeToPush=async function(t,n){return{ok:!1,why:'Locked-phone alerts are not available through this connection. Alerts show while the app is open.'}};var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]);const a='undefined'!=typeof window;function s(){return a&&'Notification'in window?window.Notification.permission:'unsupported'}const c=()=>a&&(window.matchMedia?.('(display-mode: standalone)').matches||!0===navigator.standalone);function l(n){const a=o.KIND_META[n.kind].kicker,s=('takeaway'===n.kind?[n.orderNo,null!=n.items?`${n.items} items`:'',n.total,n.collect?`collect ${n.collect}`:'']:'email'===n.kind?[n.subject??'']:[n.when,null!=n.covers?`${n.covers} covers`:'',n.table?`${(0,t.tableNumbers)(n.table)}`:'',n.source??'']).filter(Boolean).join(' \xb7 ')+(n.allergy?`\nAllergy: ${n.allergy}`:'');return{title:`${a[0]}${a.slice(1).toLowerCase()}: ${n.name}`,body:s}}const u=null},1233,[860,236,872,1231]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.bookingSource=p,e.bookingAlert=k,e.orderAlert=S,Object.defineProperty(e,"FRESH_MS",{enumerable:!0,get:function(){return y}}),e.isFreshBooking=m,e.useAlertWatcher=function(a,r={}){const i=r.kinds??['booking','pending','takeaway'];(0,t.useEffect)(()=>{if(!1===r.enabled)return;const t=()=>{const t=n.useStore.getState(),r=o.useAlerts.getState();if(!t.restaurants.find(t=>t.id===a))return;const s=w(new Date('live'===t.clock.mode?Date.now():t.clock.simStartMs+(Date.now()-t.clock.anchorRealMs))),d=t.bookings.filter(t=>t.restaurantId===a),l=t.orders.filter(t=>t.restaurantId===a&&'takeaway'===t.type),c=[...d.map(t=>t.id),...l.map(t=>t.id)],u=r.seen[a];if(!u)return void r.markSeen(a,c);const f=new Set(u),p=c.filter(t=>!f.has(t));if(p.length){r.markSeen(a,p);const t=new Set(p);for(const n of d.filter(n=>t.has(n.id)&&m(n,Date.now(),s))){const t=k(n,s);i.includes(t.kind)&&r.raise(t)}if(i.includes('takeaway'))for(const n of l.filter(n=>t.has(n.id)&&'new'===n.status))r.raise(S(n,d))}r.dropLive(t=>t.rid===a&&('pending'===t.kind&&'pending'!==d.find(n=>n.id===t.refId)?.status||'takeaway'===t.kind&&!!l.find(n=>n.id===t.refId&&(n.accepted||'new'!==n.status))))};t();const d=n.useStore.subscribe(t),l=r.nag?setInterval(()=>{const t=o.useAlerts.getState();if(!1===t.prefs.types.pending)return;const r=n.useStore.getState();for(const n of r.bookings.filter(t=>t.restaurantId===a&&'pending'===t.status)){const a=t.history.find(t=>t.id===`pending:${n.id}`);a&&(Date.now()-a.at>=s.NAG_MS&&t.raise({...a,at:Date.now(),nag:(a.nag??0)+1}))}},2e4):null;return()=>{d(),l&&clearInterval(l)}},[a,r.enabled,r.nag,i.join(',')])};var t=_r(_d[0]),n=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),i=_r(_d[4]),o=_r(_d[5]),s=_r(_d[6]);const d=t=>t.trim().replace(/^(mr|mrs|ms|miss|dr)\.?\s+/i,'').split(/\s+/)[0]||t,l=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`},c=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],u=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],f=t=>t.map(t=>`${(0,a.allergenLabel)(t.allergen)} (${(0,a.severityLabel)(t.severity).toLowerCase()})`).join(', ');function p(t){return t.walkIn||'walk-in'===t.source?'Walk-in':'phone'===t.source?'Phone':'in-person'===t.source?'In person':'online'===t.source||t.customerId?'Online':'Phone'}function k(t,n){const[a,r,i]=t.date.split('-').map(Number),o=t.date===n?`Today ${t.time}`:`${c[new Date(a,r-1,i,12).getDay()]} ${i} ${u[r-1]}, ${t.time}`;return{id:`${'pending'===t.status?'pending':'booking'}:${t.id}`,kind:'pending'===t.status?'pending':'booking',rid:t.restaurantId,at:Date.now(),refId:t.id,name:t.walkIn?'Walk-in':d(t.name),when:o,covers:t.partySize,table:t.table,source:p(t),allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:t.allergies.length?t.allergyAck?`Step 1 of 5, Booked, signed by ${t.allergyAck.by}`:'Step 1 of 5 (Booked) needs signing off':void 0}}function S(t,n){const a=(0,r.nextStep)(t,(0,r.linkedBooking)(t,n));return{id:`takeaway:${t.id}`,kind:'takeaway',rid:t.restaurantId,at:Date.now(),refId:t.id,name:d(t.customerName),orderNo:t.ref,items:t.lines.reduce((t,n)=>t+n.qty,0),total:(0,i.gbp)(t.total),collect:t.readyBy?l(t.readyBy):t.slotTime?l(t.slotTime):'As soon as ready',source:'phone'===t.channel?'Phone':'walk-in'===t.channel?'In person':'Online',allergy:t.allergies.length?f(t.allergies):void 0,allergyStep:a?`Step ${(0,r.stepInfo)(a).n} of 5 (${(0,r.stepInfo)(a).label}) needs signing off`:void 0}}const y=18e5;function m(t,n,a){const r=Date.parse(t.createdAt??'');return!(!Number.isFinite(r)||n-r>y||r-n>3e5)&&(t.date>=a&&['confirmed','pending','seated'].includes(t.status))}const w=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`},1234,[34,874,861,869,867,1232,1231]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONNECTED_INBOX",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"INBOX_EMPTY",{enumerable:!0,get:function(){return n}});const t=null,n='Connect your venue email to get alerts'},1235,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAlertSeenSync=function(c){const u=(0,l.useSync)(t=>t.venueId&&'staff'===t.kind?t.venueId:null);(0,t.useEffect)(()=>{if(!u)return;let t=!1;return(async()=>{try{const{data:l}=await(0,s.getSupabase)().from('alert_seen').select('seen_at, todo_seen, read_all_at').eq('venue_id',u).maybeSingle();!t&&l&&(n.useAlerts.getState().markAllSeen(c,Date.parse(l.seen_at)||0,l.todo_seen??[]),l.read_all_at&&n.useAlerts.getState().markAllRead(c,Date.parse(l.read_all_at)||0))}catch{}try{const s=await(0,l.rpc)('alert_clears_get',{p_venue:u});!t&&s&&n.useAlerts.getState().clearAlerts(c,s.ids??{},s.allAt&&Date.parse(s.allAt)||0)}catch{}})(),()=>{t=!0}},[u,c])},e.markNotificationsSeen=async function(t,s){const u=Date.now();n.useAlerts.getState().markAllSeen(t,u,s);const _=c();if(!_)return;try{await(0,l.rpc)('alert_seen_mark',{p_venue:_,p_at:new Date(u).toISOString(),p_todo:s.slice(-400)})}catch{}},e.markAllAlertsRead=async function(t,s,u){const _=Date.now();n.useAlerts.getState().markAllRead(t,_,!0),u&&(0,l.markChatRead)(u,'*');n.useAlerts.getState().markAllSeen(t,_,s);const o=c();if(!o)return!0;try{return await(0,l.rpc)('alert_seen_mark',{p_venue:o,p_at:new Date(_).toISOString(),p_todo:s.slice(-400),p_read_all:!0}),!0}catch{return!1}},e.clearAlertsSynced=async function(t,s,u){n.useAlerts.getState().clearAlerts(t,s,u);const _=c();if(!_)return!0;try{return await(0,l.rpc)('alert_clear',{p_venue:_,p_ids:s,p_all_before:u?new Date(u).toISOString():null}),!0}catch{return!1}};var t=r(d[0]),n=r(d[1]),l=r(d[2]),s=r(d[3]);const c=()=>{const t=l.useSync.getState();return t.venueId&&'staff'===t.kind?t.venueId:null}},1236,[34,1232,987,933]); +__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,"needsConfirm",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"untickedAllergies",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"kitchenAlarms",{enumerable:!0,get:function(){return x}}),_e.KitchenFlash=function({rid:e,me:l}){const n=(0,c.useOrders)(e),s=x(n),o=s[0];(0,b.useBuildingChime)(!!o,4e3,6e4);const a=t.default.useRef(l);return a.current=l,t.default.useEffect(()=>{o?(0,f.notify)({id:'kitchen-flash',tone:'urgent',modal:!0,testID:'kitchen-flash',icon:'\u26a0\ufe0f',kicker:'TAKEAWAY \xb7 KITCHEN CHECK',title:`Order ${o.ref}: confirm it and tick each allergy`,body:"This stays up, with a low chime that builds, until both are done."+(s.length>1?` ${s.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,y.jsx)(T,{rid:e,id:o.id,me:a.current})}):(0,f.dismissNotice)('kitchen-flash')},[o?.id,s.length,e]),t.default.useEffect(()=>()=>(0,f.dismissNotice)('kitchen-flash'),[]),null};var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),s=e(r(d[3])),c=r(d[4]),o=r(d[5]),a=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),b=r(d[10]),y=r(d[11]);const k=e=>!['cancelled','collected','closed'].includes(e.status),j=e=>'new'===e.status&&!e.accepted,p=e=>e.allergyAck?[]:e.allergies.filter(t=>!e.allergyTicks?.[t.allergen]),x=e=>e.filter(e=>'takeaway'===e.type&&k(e)&&(j(e)||p(e).length>0)).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function T({rid:e,id:t,me:f}){const k=(0,c.useOrders)(e).find(e=>e.id===t),p=(0,c.useStore)(e=>e.tickOrderAllergy),{width:x}=(0,s.default)();if(!k)return null;const T=j(k);return(0,y.jsxs)(n.default,{style:{gap:12},children:[(0,y.jsx)(n.default,{style:{alignSelf:'flex-end'},children:(0,y.jsx)(h.SoundToggle,{})}),(0,y.jsx)(b.TakeawayFacts,{o:k,big:x>=700,personal:!1}),k.allergies.length&&!k.allergyAck?(0,y.jsxs)(n.default,{style:{gap:8},children:[(0,y.jsx)(u.T,{size:16,weight:"semibold",colour:"#FFB3AB",children:"Tick each allergy once you\u2019ve checked it:"}),k.allergies.map(e=>{const t=!!k.allergyTicks?.[e.allergen];return(0,y.jsxs)(l.default,{testID:`kitchen-tick-${e.allergen}`,accessibilityRole:"checkbox",accessibilityState:{checked:t},accessibilityLabel:`Allergy confirmed: ${(0,o.allergenLabel)(e.allergen)}`,onPress:()=>p(k.id,e.allergen,f,!t),style:{flexDirection:'row',alignItems:'center',gap:12,borderWidth:1.5,borderColor:t?a.colours.gold:a.colours.red,backgroundColor:'rgba(255,255,255,0.03)',borderRadius:12,padding:12,minHeight:60},children:[(0,y.jsx)(n.default,{style:{width:34,height:34,borderRadius:8,borderWidth:2.5,borderColor:t?a.colours.gold:'#FFFFFF',alignItems:'center',justifyContent:'center'},children:t?(0,y.jsx)(u.T,{size:22,weight:"bold",colour:a.colours.gold,children:"\u2713"}):null}),(0,y.jsxs)(u.T,{size:18,weight:"semibold",style:{flex:1},children:[(0,o.allergenLabel)(e.allergen)," (",(0,o.severityLabel)(e.severity),") ",t?'\xb7 confirmed':'\xb7 not checked yet']})]},e.allergen)})]}):null,T?(0,y.jsx)(u.Button,{label:`Confirm order ${k.ref}`,testID:"kitchen-confirm",onPress:()=>{c.repo.orders.accept(k.id,f)},style:{minHeight:64,borderRadius:14}}):(0,y.jsxs)(u.T,{size:16,colour:a.colours.goldLight,center:!0,children:["Order confirmed",k.accepted?` by ${k.accepted.by}`:'',". Tick the allergies above to finish."]})]})}},1237,[34,402,102,426,874,861,821,794,1228,1130,1238,25]); +__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 x}}),_e.useBuildingChime=function(e,s=4e3,i=6e4){const o=(0,a.useAlerts)(e=>e.prefs.muted);(0,t.useEffect)(()=>{if(!e||o)return;const t=Date.now(),l=()=>(0,c.lowChime)(Math.min(1,(Date.now()-t)/i));l();const n=setInterval(l,s);return()=>clearInterval(n)},[e,o,s,i])},_e.TakeawayFacts=b,_e.TakeawayTakeover=function({rid:e,me:i}){const o=(0,l.useOrders)(e),n=x(o),a=n[0],c=s.default.useRef(i);return c.current=i,(0,t.useEffect)(()=>{a?(0,f.notify)({id:'takeaway-takeover',tone:a.allergies.length?'urgent':'warn',modal:!0,big:!0,testID:'takeaway-takeover',icon:'\ud83e\udd61',kicker:'NEW TAKEAWAY ORDER',title:`Order ${a.ref}: read it, then tap Confirm`,body:"This stays on screen until someone confirms."+(n.length>1?` ${n.length-1} more waiting.`:''),timeoutMs:null,content:()=>(0,j.jsx)(y,{rid:e,id:a.id,me:c.current})}):(0,f.dismissNotice)('takeaway-takeover')},[a?.id,n.length,e]),(0,t.useEffect)(()=>()=>(0,f.dismissNotice)('takeaway-takeover'),[]),null};var t=r(d[0]),s=e(t),i=e(r(d[1])),o=e(r(d[2])),l=r(d[3]),n=r(d[4]),a=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8]),f=r(d[9]),j=r(d[10]);const w=e=>e?new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'As soon as possible',x=e=>e.filter(e=>'takeaway'===e.type&&'new'===e.status&&!e.accepted).sort((e,t)=>e.createdAt.localeCompare(t.createdAt));function b({o:e,big:t,personal:s=!0}){const o=t?1:.8;return(0,j.jsxs)(i.default,{style:{gap:10},children:[(0,j.jsxs)(i.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:18},children:[(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Collection"}),(0,j.jsx)(h.T,{size:34*o,weight:"bold",colour:u.colours.goldLight,children:w(e.slotTime)})]}),s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Customer"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.customerName})]}):null,s?(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Phone"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.phone??'Not given'})]}):null,(0,j.jsxs)(i.default,{children:[(0,j.jsx)(h.T,{size:13*o+2,colour:u.colours.muted,children:"Order"}),(0,j.jsx)(h.T,{size:26*o,weight:"semibold",children:e.ref})]})]}),e.allergies.length?(0,j.jsxs)(i.default,{testID:"takeover-allergy",style:{backgroundColor:'#7A140D',borderRadius:12,padding:12,borderWidth:2,borderColor:'#FFB3AB'},children:[(0,j.jsxs)(h.T,{size:22*o,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,j.jsxs)(h.T,{size:16*o,weight:"semibold",colour:"#FFE3DF",children:["Customer overrode a warning: ",e.name," contains ",e.contains.map(n.allergenLabel).join(', ')]},t))]}):(0,j.jsx)(h.T,{size:16*o,colour:u.colours.ok,children:"No allergies declared"}),(0,j.jsx)(i.default,{style:{gap:4},children:e.lines.map((e,t)=>(0,j.jsxs)(h.T,{size:22*o,weight:"semibold",children:[e.qty," \xd7 ",e.name,e.choices.length?` (${e.choices.join(', ')})`:'',e.notes?` \xb7 \u201c${e.notes}\u201d`:'']},t))})]})}function y({rid:e,id:t,me:s}){const n=(0,l.useOrders)(e).find(e=>e.id===t),{width:a}=(0,o.default)();return n?(0,j.jsxs)(i.default,{style:{gap:12},children:[(0,j.jsx)(b,{o:n,big:a>=700}),(0,j.jsx)(h.Button,{label:`Confirm order ${n.ref}`,testID:"takeover-confirm",onPress:()=>{l.repo.orders.accept(n.id,s)},style:{minHeight:72,borderRadius:14}})]}):null}},1238,[34,102,426,874,861,1230,1048,821,794,1130,25]); +__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.ReviewsSection=function({rid:e,mode:l,venueName:o}){const p=(0,c.useReviews)((0,n.useShallow)(t=>t.reviews.filter(t=>t.restaurantId===e))),f=(0,c.useReviews)(t=>t.settingsFor(e)),b=(0,c.useReviews)(t=>t.link[e]);(0,t.useEffect)(()=>(0,d.ensureReviewSync)(e,l),[e,l]);const[y,x]=(0,t.useState)(0),[j,R]=(0,t.useState)('all'),[k,S]=(0,t.useState)(''),[N,C]=(0,t.useState)({}),[M,P]=(0,t.useState)(f.googleUrl),T='manage'===l?p:p.filter(e=>'published'===e.status),O=T.filter(e=>!(y&&e.rating!==y||'manage'===l&&'all'!==j&&e.status!==j)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return(0,u.jsxs)(s.default,{testID:"reviews-section",style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(r.T,{center:!0,size:20,weight:"semibold",accessibilityRole:"header",children:"Reviews"}),(0,u.jsx)(r.Muted,{center:!0,children:'manage'===l?'Newest first. Publish genuine reviews, positive or negative.':'Published reviews, newest first.'}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:h.map(e=>(0,u.jsx)(r.Chip,{testID:`review-star-${e||'all'}`,label:e?`${e} star${e>1?'s':''}`:'All ratings',selected:y===e,onPress:()=>x(e)},e))}),'manage'===l?(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:['all','pending','published','hidden','removed'].map(e=>(0,u.jsx)(r.Chip,{label:'all'===e?'All':e[0].toUpperCase()+e.slice(1),selected:j===e,onPress:()=>R(e)},e))}):null,0===O.length?(0,u.jsx)(r.Muted,{center:!0,children:0===T.length?'No reviews yet':'No reviews for this filter.'}):null,'offline'===b&&T.length?(0,u.jsx)(r.Muted,{center:!0,children:"Showing reviews saved on this device."}):null,O.map(e=>(0,u.jsx)(v,{review:e,mode:l,venueName:o,reason:k,setReason:S,reply:N[e.id]??e.publicReply??'',setReply:t=>C({...N,[e.id]:t}),wixOn:f.wixOn},e.id)),'manage'===l?(0,u.jsxs)(r.Card,{children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Review policy"}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(r.Field,{label:"Google review link (https)",value:M,onChangeText:P,placeholder:"Leave blank if you do not have one",autoCapitalize:"none"}),(0,u.jsx)(r.Button,{label:"Save Google link",onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(M),f.emailOn,f.wixOn).then(e=>{e.ok&&P((0,c.safeGoogleUrl)(M)),(0,a.notify)({id:'review-google',title:e.ok?(0,c.safeGoogleUrl)(M)?'Google link saved':'Google link cleared. Only an https address is kept.':e.error||'Not saved',timeoutMs:4e3})})}}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Website"}),(0,u.jsx)(r.Muted,{center:!0,children:f.wixOn?'The website mirror is on. Only published reviews are sent.':'The website mirror is off. Nothing is sent until you switch it on.'}),(0,u.jsx)(r.Button,{kind:"secondary",label:f.wixOn?'Switch website mirror off':'Switch website mirror on',onPress:()=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(f.googleUrl),f.emailOn,!f.wixOn).then(e=>(0,a.notify)({id:'review-wix',title:e.ok?f.wixOn?'Website mirror off':'Website mirror on':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(w,{rid:e,venueName:o})]}):null]})},_e.ReviewAskCard=w,_e.CopyReviewLink=function({rid:e,bookingId:n}){const[a,h]=(0,t.useState)('');return(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(l.default,{testID:`copy-review-link-${n}`,accessibilityRole:"button",accessibilityLabel:"Copy review link",onPress:()=>{(0,d.issueReviewLink)(e,n).then(t=>{if(!t.ok||!t.token)return void h(t.error||'No review link.');const l=(0,c.reviewLink)(e,t.token),s='undefined'!=typeof navigator?navigator.clipboard:void 0;s?s.writeText(l).then(()=>h('Review link copied.')).catch(()=>h(l)):h(l)})},style:{minHeight:44,justifyContent:'center',paddingHorizontal:12,borderRadius:12,borderWidth:1,borderColor:o.colours.gold},children:(0,u.jsx)(r.T,{colour:o.colours.gold,children:"Copy review link"})}),a?(0,u.jsx)(r.Muted,{style:{textAlign:'left'},children:a}):null]})},_e.ReviewOptOut=function({token:e}){const[l,s]=(0,t.useState)('Checking this link.');return(0,t.useEffect)(()=>{(0,d.optOutReviewEmail)(e).then(e=>{s(e.ok?'You will not get a review email after a visit. Nothing else was sent.':e.error||'This opt-out link is not valid.')})},[e]),(0,u.jsx)(r.Muted,{center:!0,accessibilityRole:"text",children:l})},_e.ReviewForm=function({rid:e,venueName:n,token:a}){const h=(0,c.useReviews)(t=>t.settingsFor(e)),p=(0,c.safeGoogleUrl)(h.googleUrl);(0,t.useEffect)(()=>{(0,d.refreshReviews)(e,'read')},[e]);const[w,v]=(0,t.useState)(0),[f,b]=(0,t.useState)(''),[y,x]=(0,t.useState)(''),[j,R]=(0,t.useState)(''),[k,S]=(0,t.useState)('');return(0,u.jsxs)(s.default,{testID:"review-form",style:{gap:12},children:[(0,u.jsx)(r.T,{center:!0,size:22,weight:"semibold",accessibilityRole:"header",children:"How was your visit?"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Your rating, comments and chosen public name may appear on the ",n," website and app after moderation under the review policy. Honest feedback is welcome, positive or negative."]}),(0,u.jsx)(r.Muted,{center:!0,children:c.REVIEW_POLICY}),(0,u.jsx)(s.default,{style:{flexDirection:'row',justifyContent:'center',gap:8,alignSelf:'center'},children:[1,2,3,4,5].map(e=>(0,u.jsx)(l.default,{testID:`review-rate-${e}`,accessibilityRole:"button",accessibilityLabel:`${e} star${e>1?'s':''}${w===e?', selected':''}`,accessibilityState:{selected:w===e},onPress:()=>v(e),style:{minWidth:44,minHeight:44,alignItems:'center',justifyContent:'center'},children:(0,u.jsx)(r.T,{size:32,colour:e<=w?o.colours.gold:'#555',children:"\u2605"})},e))}),(0,u.jsx)(r.Field,{label:"Your review",value:f,onChangeText:b,multiline:!0,placeholder:"What should others know about your visit?"}),(0,u.jsx)(r.Field,{label:"Name to show with the review",value:y,onChangeText:x,placeholder:"The name guests will see"}),k?(0,u.jsx)(r.Muted,{center:!0,children:k}):null,j?(0,u.jsx)(r.Muted,{center:!0,children:j}):(0,u.jsx)(r.Button,{testID:"review-submit",label:"Send review",disabled:!w||y.trim().length<2,onPress:()=>{(0,d.submitReview)(a,w,f,y).then(t=>{t.ok?(S(''),R('Thank you. A manager will read it before anything is published.'),(0,d.refreshReviews)(e,'read')):S(t.error||'Not sent.')})}}),p?(0,u.jsx)(r.Button,{kind:"secondary",label:"Also review us on Google",accessibilityLabel:"Also review us on Google",onPress:()=>{window.open(p,'_blank','noopener')}}):null]})};var t=_r(_d[0]);_r(_d[1]);var l=e(_r(_d[2])),s=e(_r(_d[3])),n=_r(_d[4]),r=_r(_d[5]),o=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]);const h=[0,1,2,3,4,5];function p(e){const t=new Date(e);return Number.isNaN(t.getTime())?e.slice(0,10):t.toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric'})}function w({rid:e,venueName:t}){const l=(0,c.useReviews)(t=>t.settingsFor(e)),n=(0,c.reviewEmail)(t,'[link]',(0,c.safeGoogleUrl)(l.googleUrl));return(0,u.jsxs)(s.default,{style:{gap:8},children:[(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Post-visit email"}),(0,u.jsx)(r.Toggle,{testID:"review-email-toggle",label:"Ask guests for a review after their visit",value:l.emailOn,onChange:t=>{(0,d.saveReviewSettings)(e,(0,c.safeGoogleUrl)(l.googleUrl),t,l.wixOn).then(e=>(0,a.notify)({id:'review-email',title:e.ok?t?'Saved. Review emails are on. Nothing is sent from this screen.':'Saved. Review emails are off. Nothing is sent.':e.error||'Not saved',timeoutMs:4e3}))}}),(0,u.jsx)(r.Muted,{center:!0,children:l.emailOn?'On. A finished visit with an email address is asked once, about two and a half hours later, or at 10:00 the next morning if that would be after 9pm.':'Off. No review email is sent.'}),(0,u.jsx)(r.T,{center:!0,weight:"semibold",children:"Email preview"}),(0,u.jsxs)(r.Muted,{center:!0,children:["Subject: ",n.subject]}),(0,u.jsx)(r.Muted,{center:!0,children:n.body}),(0,u.jsx)(r.Muted,{center:!0,children:"Nothing is sent from this screen."})]})}function v({review:e,mode:t,venueName:l,reason:n,setReason:h,reply:w,setReply:v,wixOn:f}){const b=t=>{(0,d.moderateReview)(e.restaurantId,e.id,t,'published'===t?void 0:n,e.reply??'').then(l=>{(0,a.notify)({id:`review-mod-${e.id}`,title:l.ok?`Review ${t}`:l.error||'Not saved',timeoutMs:4e3})})},y='up_to_date'===e.wix?'Website up to date':'pending'===e.wix?'Website update pending':f?'Website mirror is on':'Website mirror is off';return(0,u.jsxs)(r.Card,{children:[(0,u.jsxs)(s.default,{style:{alignItems:'flex-start',gap:4},children:[(0,u.jsx)(r.T,{weight:"semibold",style:{textAlign:'left'},children:e.publicName}),(0,u.jsxs)(r.T,{style:{textAlign:'left'},children:[(x=e.rating,'\u2605\u2605\u2605\u2605\u2605'.slice(0,x)+'\u2606\u2606\u2606\u2606\u2606'.slice(0,5-x))," (",e.rating," of 5)"]}),(0,u.jsx)(r.T,{size:16,style:{textAlign:'left'},children:e.comment||'No written comment.'}),(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[p(e.createdAt),'manage'===t?` \xb7 ${e.status}`:'']}),'manage'===t?(0,u.jsxs)(r.Muted,{style:{textAlign:'left'},children:[y,e.reason?` \xb7 ${e.reason.replace('_',' ')}`:'']}):null,!e.publicReply||'read'!==t&&'published'!==e.status?null:(0,u.jsxs)(s.default,{accessibilityRole:"text",accessibilityLabel:`Reply from ${l}. ${e.publicReply}`,style:{alignSelf:'stretch',gap:4,marginTop:8},children:[(0,u.jsxs)(r.T,{center:!0,weight:"semibold",colour:o.colours.gold,children:["Reply from ",l]}),(0,u.jsx)(r.Muted,{center:!0,children:e.publicReply})]})]}),'manage'===t?(0,u.jsxs)(s.default,{style:{gap:8},children:[e.audit.length?(0,u.jsxs)(r.Muted,{center:!0,children:["History: ",e.audit.map(e=>`${p(e.at)} ${e.action}${e.reason?` (${e.reason.replace('_',' ')})`:''} by ${e.by}`).join('. ')]}):null,'published'!==e.status?(0,u.jsx)(r.Muted,{center:!0,children:"Guests do not see a reply unless the review is published."}):null,(0,u.jsx)(r.Field,{label:"Public reply",accessibilityLabel:`Public reply to ${e.publicName}`,value:w,onChangeText:v,multiline:!0}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{testID:`review-reply-save-${e.id}`,label:e.publicReply?'Save public reply':'Write public reply',accessibilityLabel:e.publicReply?'Save public reply':'Write public reply',onPress:()=>{(0,d.setReviewReply)(e.restaurantId,e.id,w).then(t=>{(0,a.notify)({id:`review-reply-${e.id}`,title:t.ok?w.trim()?'Public reply saved':'Public reply removed':t.error||'Not saved',timeoutMs:4e3})})}}),e.publicReply?(0,u.jsx)(r.Button,{kind:"secondary",testID:`review-reply-delete-${e.id}`,label:"Delete public reply",accessibilityLabel:"Delete public reply",onPress:()=>{v(''),(0,d.setReviewReply)(e.restaurantId,e.id,'').then(t=>(0,a.notify)({id:`review-reply-del-${e.id}`,title:t.ok?'Public reply removed':t.error||'Not saved',timeoutMs:4e3}))}}):null]}),(0,u.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:c.REVIEW_REASONS.map(e=>(0,u.jsx)(r.Chip,{label:e.label,selected:n===e.id,onPress:()=>h(e.id)},e.id))}),(0,u.jsxs)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,alignSelf:'center'},children:[(0,u.jsx)(r.Button,{label:"Publish",onPress:()=>b('published')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Hide",onPress:()=>b('hidden')}),(0,u.jsx)(r.Button,{kind:"secondary",label:"Remove",onPress:()=>b('removed')})]})]}):null]});var x}},1239,[34,236,402,102,879,794,821,1001,1240,1241,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.refreshReviews=k,_e.ensureReviewSync=function(t,n){const s=`${t}:${n}`;if(_.has(s)||!t)return()=>{};let u=!1,c=null;const l=()=>{u||k(t,n)};l();const v=setInterval(l,3e4);(async()=>{const s=await p('public_venue',{p_venue_slug:w(t)}),l=s.data?.[0]?.id;if(u||!l||!(0,o.isSupabaseConfigured)()||'customer'===e.APP_VARIANT)return;const _=(0,a.getSupabase)().channel(`reviews:${l}:${n}`).on('postgres_changes',{event:'INSERT',schema:'public',table:'review_signals',filter:`venue_id=eq.${l}`},e=>{const a=e.new;'submitted'===a.kind&&a.review_id&&b(t,a.review_id),k(t,n)}).subscribe();c=_,u&&(0,a.getSupabase)().removeChannel(_)})();const f=()=>{u=!0,clearInterval(v),c&&(0,a.getSupabase)().removeChannel(c),_.delete(s)};return _.set(s,f),f},_e.submitReview=async function(e,t,a,o){const n=await p('submit_review',{p_token:e,p_rating:t,p_comment:a,p_public_name:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?{ok:!0}:{ok:!1,error:n.data?.error||'Not sent.'}},_e.moderateReview=async function(e,t,a,o,n){const s=await p('moderate_review',{p_id:t,p_status:a,p_reason:o??null,p_reply:n});return s.error?{ok:!1,error:s.error}:s.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:s.data?.error||'Not saved.'}},_e.setReviewReply=async function(e,t,a){const o=await p('set_review_reply',{p_id:t,p_reply:a});return o.error?{ok:!1,error:o.error}:o.data?.ok?(await k(e,'manage'),{ok:!0}):{ok:!1,error:o.data?.error||'Not saved.'}},_e.optOutReviewEmail=async function(e){const t=await p('opt_out_review_email',{p_token:e});return t.error?{ok:!1,error:t.error}:t.data?.ok?{ok:!0}:{ok:!1,error:t.data?.error||'This opt-out link is not valid.'}},_e.issueReviewLink=async function(e,t){const a=await p('issue_review_token',{p_slug:w(e),p_booking:t});return a.error?{ok:!1,error:a.error}:a.data?.ok&&a.data.token?{ok:!0,token:a.data.token}:{ok:!1,error:a.data?.error||'No review link.'}},_e.saveReviewSettings=async function(e,t,a,o){const n=await p('save_review_settings',{p_slug:w(e),p_google_url:t,p_email_on:a,p_wix_mirror:o});return n.error?{ok:!1,error:n.error}:n.data?.ok?(u.useReviews.getState().setSettings(e,{googleUrl:n.data.google_url??t,emailOn:a,wixOn:o}),{ok:!0}):{ok:!1,error:n.data?.error||'Not saved.'}};var e=r(d[0]),t=r(d[1]),a=r(d[2]),o=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]);const c='This device is not connected to the shared system.',l=new Set,_=new Map;async function p(e,t){if(!(0,o.isSupabaseConfigured)())return{data:null,error:c};try{const{data:o,error:n}=await(0,a.getSupabase)().rpc(e,t);return n?{data:null,error:n.message}:{data:o}}catch(e){return{data:null,error:e instanceof Error?e.message:c}}}function w(e){return(0,t.queuedDatabaseSlug)(e)}function v(e,t){return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:'published',publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:'off',audit:[]}}function f(e,t){const a=(t.audit??[]).map(e=>({at:e.at,by:e.by??'',action:e.action,reason:e.reason??void 0}));return{id:t.id,restaurantId:e,rating:Number(t.rating),comment:t.comment??'',publicName:t.public_name,status:t.status,reason:t.reason??void 0,reply:t.reply??void 0,publicReply:t.public_reply||void 0,createdAt:t.created_at,wix:(o=t.wix_state,'synced'===o?'up_to_date':'pending_push'===o||'pending_delete'===o?'pending':'off'),audit:a};var o}async function k(e,t){const a='manage'===t?'list_reviews':'published_reviews',o=await p(a,{p_slug:w(e)});if(o.error||!o.data)return u.useReviews.getState().setStatus(e,'offline'),o.error??c;const n='manage'===t?o.data.map(t=>f(e,t)):o.data.map(t=>v(e,t));u.useReviews.getState().replaceVenue(e,n);const s=await p('review_venue_settings',{p_slug:w(e)});if(s.data){const t={googleUrl:s.data.google_url??''};'boolean'==typeof s.data.email_on&&(t.emailOn=s.data.email_on),'boolean'==typeof s.data.wix_mirror&&(t.wixOn=s.data.wix_mirror),u.useReviews.getState().setSettings(e,t)}return''}function b(t,a){if('customer'===e.APP_VARIANT||l.has(a))return;l.add(a);const o=`review:${a}`;s.useAlerts.getState().history.some(e=>e.id===o)||(s.useAlerts.getState().raise({id:o,kind:'review',rid:t,at:Date.now(),refId:a,name:'New review',subject:'A guest left a review. Managers can publish, hide or remove it.'}),s.useAlerts.getState().dismiss(o),(0,n.notify)({id:o,kicker:'NEW REVIEW',title:'New review',body:'A guest left a review.',timeoutMs:8e3,testID:'review-alert'}))}},1240,[872,6,933,976,1001,1230,1241]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"REVIEW_POLICY",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"REVIEW_REASONS",{enumerable:!0,get:function(){return u}}),_e.reviewEmail=function(e,t,n){return(0,r.reviewRequestText)(e,t,n,'[opt-out link]')},_e.safeGoogleUrl=function(e){const t=(e??'').trim();return/^https:\/\/[^\s]+$/i.test(t)?t:''},Object.defineProperty(_e,"useReviews",{enumerable:!0,get:function(){return v}}),_e.reviewLink=function(e,t){const n=`/customer/${e}/feedback?token=${t}`;return'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n};var e,t=_r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},r=_r(d[1]),s=_r(d[2]),l=_r(d[3]);const o='We publish genuine reviews, whether they are positive or negative. A review is removed or hidden only when it is fake, abusive, irrelevant to a visit, unlawful, or includes someone\u2019s personal data. The reason is recorded.',u=[{id:'fake',label:'Fake'},{id:'abusive',label:'Abusive'},{id:'irrelevant',label:'Irrelevant'},{id:'unlawful',label:'Unlawful'},{id:'personal_data',label:'Personal data'}],c={googleUrl:'',emailOn:!1,wixOn:!1};const v=(0,s.create)()((0,l.persist)((e,t)=>({reviews:[],settings:{},link:{},settingsFor:e=>t().settings[e]??c,setSettings:(t,n)=>e(e=>({settings:{...e.settings,[t]:{...e.settings[t]??c,...n,emailOn:n.emailOn??e.settings[t]?.emailOn??!1,wixOn:n.wixOn??e.settings[t]?.wixOn??!1,googleUrl:n.googleUrl??e.settings[t]?.googleUrl??''}}})),setStatus:(t,n)=>e(e=>({link:{...e.link,[t]:n}})),replaceVenue:(t,n)=>e(e=>({reviews:[...e.reviews.filter(e=>e.restaurantId!==t),...n],link:{...e.link,[t]:'live'}}))}),{name:'covercharge-reviews-v1',version:2,storage:(0,l.createJSONStorage)(()=>n.default),migrate:()=>({reviews:[],settings:{},link:{}})}))},1241,[839,1242,846,849]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.reviewRequestText=function(o,n,s,u){const c=o.trim()||'the restaurant';let v=`Thank you for visiting ${c}. We'd love to hear about your experience. Leave your review: ${n}. Your rating, comments and chosen public name may appear on our website and app after moderation under our review policy. We welcome honest feedback, positive or negative.`;const l=s.trim();t.test(l)&&(v+=` You can also review us on Google: ${l}`);u.trim()&&(v+=` If you would rather not get these emails, opt out: ${u.trim()}`);return{subject:`How was your visit to ${c}?`,body:v}},e.reviewRequestMaySend=function(t,o){const n=(o??'').trim();return'finished'===String(t??'').toLowerCase()&&/^[^\s@<>()",;:\\[\]]+@[^\s@<>()",;:\\[\]]+\.[A-Za-z]{2,}$/.test(n)};const t=/^https:\/\/\S+$/i},1242,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useReviewAlerts=function(s){(0,n.useEffect)(()=>(0,u.ensureReviewSync)(s,'owner'===t.APP_VARIANT?'manage':'read'),[s])};var n=r(d[0]),t=r(d[1]),u=r(d[2])},1243,[34,872,1240]); +__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,"useChefAssistant",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"CHEF_PROMPTS",{enumerable:!0,get:function(){return P}}),_e.ChefAssistantButton=function({compact:e}){return e?(0,S.jsx)(u.default,{testID:"chef-assistant-open",accessibilityRole:"button",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0),style:{borderRadius:12,backgroundColor:w.colours.accentBg,borderWidth:1,borderColor:w.colours.accentBorder,paddingVertical:6,paddingHorizontal:12,minHeight:36,justifyContent:'center'},children:(0,S.jsx)(m.T,{weight:"semibold",colour:w.colours.goldLight,size:13,children:"\u2726 Assistant"})}):(0,S.jsx)(d.ActionTile,{primary:!0,testID:"chef-assistant-open",icon:"sparkle",label:"Assistant",sub:"Recipe card, order, allergens, GP, temps",accessibilityLabel:"Assistant",onPress:()=>I.getState().setOpen(!0)})},_e.ChefAssistantSheet=function({go:e}){const l=I(e=>e.open),d=()=>I.getState().setOpen(!1),{rid:f,me:W,menu:L,k:B,c:F}=(0,$.useChef)(3e4),G=(0,T.useSuggestions)(),E=(0,r.useSafetyView)('chef').points,[M,H]=(0,o.useState)([]),[N,_]=(0,o.useState)(''),[V,K]=(0,o.useState)(!1),[Y,q]=(0,o.useState)(!1),Q=(0,o.useRef)(null),U=(0,o.useRef)(null);if((0,o.useEffect)(()=>{setTimeout(()=>Q.current?.scrollToEnd?.({animated:!0}),50)},[M.length]),!l)return null;const J=(e,t=!1)=>H(n=>[...n,{id:R(),from:'bot',text:e,demo:t}]),X=e=>H(t=>[...t,{id:R(),from:'bot',plan:e,state:'open'}]),Z=L.filter(e=>!e.name.includes('(example)')||!0),ee=(t,n)=>{const r=A(t);if(!(0,s.chefCanSee)(f,t))return void J('That check is managed in the Managers app.');if(/\b(send|email|text|pay|delete|remove|order now|place the order)\b/.test(r)&&!/\b(build|draft|make|prepare)\b/.test(r))return void J('I can\u2019t send, pay for or delete anything. I can prepare it for you to check and do yourself, for example \u201cbuild the fish order\u201d.');const o=(0,y.parseQuick)(t,E).filter(e=>e.point&&(0,y.isTempKind)(e.point.kind));if(o.length&&(/\b(fridge|freezer|walk ?in|core|probe|cool|hot|deliver|degree|temp)/.test(r)||o.some(e=>null!=e.value))){const t=o.filter(e=>null!=e.value),r=o.filter(e=>null==e.value);if(r.length&&J(`I didn\u2019t hear a temperature for ${r.map(e=>e.point.name).join(', ')}. Say or type the reading, for example \u201c${r[0].point.name} 4 degrees\u201d. I never fill one in.`),!t.length)return;const s=t.filter(e=>!(0,y.inRange)(e.point,e.value));return void X({title:`Log ${1===t.length?'a reading':`${t.length} readings`} in the food safety log`,detail:t.map(e=>`${e.point.name}: ${e.value}\xb0C (${(0,y.limitText)(e.point)})${(0,y.inRange)(e.point,e.value)?'':' \xb7 OUT OF RANGE'}`).join('\n')+`\nSigned ${(0,y.initialsOf)(W)} \xb7 ${n?'voice':'typed'}`,warn:s.length?`${s.map(e=>e.point.name).join(', ')} out of range: you\u2019ll need to add the corrective action in the food safety log.`:void 0,confirm:'Log it',run:()=>{const r=(new Date).toISOString();return v.useSafety.getState().addEntries(t.map(e=>({pointId:e.point.id,name:e.point.name,kind:e.point.kind,at:r,by:W.replace(' (example)',''),byId:$.CHEF_ID,app:'chef',value:e.value,ok:(0,y.inRange)(e.point,e.value),source:n?'voice':'typed',initials:(0,y.initialsOf)(W)}))),s.length&&setTimeout(()=>e('haccp'),600),`Logged ${t.map(e=>`${e.point.name} ${e.value}\xb0C`).join(', ')}.${s.length?' Opening the food safety log for the corrective action.':''}`}})}if(/\b(fridge|freezer|temp|temperature|degrees)\b/.test(r))return void J('Which unit, and what does it read? For example \u201cprep fridge 4 degrees\u201d or \u201cfreezer minus 19\u201d. I only log the number you give me.');if(/allergen|allerg|contain|gluten|nut|dairy|milk|shellfish|crustacean|coeliac/.test(r)){const e=D(t,Z,e=>e.name);if(!e)return void J('Which dish? For example \u201callergens in the fish and chips\u201d.');const n=(0,j.recipeCards)().byMenuItem(e.id),r=e=>b.ALLERGENS.find(t=>t.id===e)?.label??e,s=Object.entries(e.allergens??{}).filter(([,e])=>'contains'===e).map(([e])=>r(e)),a=Object.entries(e.allergens??{}).filter(([,e])=>'may'===e).map(([e])=>r(e));return void J(`${e.name}: ${s.length?`contains ${s.join(', ')}`:'no allergens recorded as \u201ccontains\u201d'}${a.length?`; may contain ${a.join(', ')}`:''}. ${n?n.signOff?`From the signed-off recipe card (${n.signOff.by}).`:'The recipe card is awaiting your sign-off, so check it before telling a guest.':'There\u2019s no recipe card for it yet.'} Always check the card and the ingredients with the guest.`)}if(/\bgp\b|gross profit|margin|price for|what price|cost of|costing/.test(r)){const e=D(t,F,e=>e.item.name),n=Number((t.toLowerCase().match(/(\d{2})\s*(?:%|percent|per cent)/)??[])[1])||B.targetGp;if(!e)return void J(`Which dish? I can cost the dishes that have a recipe in GP & costing (${F.length} do). For example \u201cGP on the haddock\u201d.`);const r=(0,C.priceForTarget)(e.cost,n);return void J(`${e.item.name}: food cost ${(0,x.gbp)(e.cost)}, sells at ${(0,x.gbp)(e.priceInc)} (inc VAT) = ${e.gp.toFixed(1)}% GP. For ${n}% GP it would need ${(0,x.gbp)(r)} inc VAT. Prices are changed by a manager; I haven\u2019t changed anything.`)}if(/\border|supplier|delivery|par\b|restock/.test(r)){const n=D(t,G,e=>`${e.s.name} ${e.s.category??''}`)??(1===G.length?G[0]:void 0);return n?void X({title:`Build an order for ${n.s.name}`,detail:(n.lines.length?n.lines.map(e=>`${e.i.name}: ${(0,a.fishQtyText)(f,e.i,e.qty)}`).join('\n')+`\nAbout ${(0,x.gbp)(n.total)} at the latest prices.`:'Nothing is below par for this supplier yet.')+'\nI\u2019ll open it in Ordering for you to check, change and place yourself. Nothing is sent.',confirm:'Open the order',run:()=>(setTimeout(()=>{d(),e('orders',n.s.id)},400),`Opening the ${n.s.name} order. You check it and place it yourself.`)}):void J(G.length?`Which supplier? ${G.map(e=>e.s.name).join(', ')}.`:'Nothing is below par and no supplier orders today.')}if(/recipe|card|new dish|write up|spec/.test(r)){const n=t.replace(/^.*?(?:recipe card|card|recipe|dish|spec)\s*(?:for|of)?\s*/i,'').replace(/[.?!]+$/,'').trim();if(!n||n.length<3)return void J('What\u2019s the dish called? For example \u201cdraft a recipe card for crab linguine\u201d.');const r=n.replace(/^the\s+/i,'').replace(/^./,e=>e.toUpperCase()).slice(0,60),s=(0,j.recipeCards)().list(f).find(e=>A(e.dish)===A(r));return s?(J(`There\u2019s already a card for ${s.dish}. Opening Recipe cards.`),void setTimeout(()=>{d(),e('recipes')},600)):void X({title:`Draft a recipe card: ${r}`,detail:'A new card, awaiting your sign-off, with the dish name and section filled in. You add the ingredients, method, allergens, photo and price, then sign it off. It isn\u2019t shown to guests until you do.',confirm:'Make the draft',run:async()=>(await(0,j.recipeCards)().create(f,{dish:r,section:'Specials',price:null,ingredients:[],steps:[]},{name:W,role:'head-chef'}),setTimeout(()=>{d(),e('recipes')},500),`Draft card for ${r} saved, awaiting sign-off. Opening Recipe cards.`)})}const l='I can help with: drafting a recipe card, building a supplier order, a dish\u2019s allergens, GP pricing, and logging a temperature you read out. Try one of the suggestions.';(0,k.askServer)('chef',t,[]).then(e=>J('text'===e.kind?e.text:l)).catch(()=>J(l))},te=(e,t=!1)=>{const n=e.trim();if(n){_(''),H(e=>[...e,{id:R(),from:'you',text:n}]);try{ee(n,t)}catch(e){J(`Sorry, that didn\u2019t work: ${e.message}`)}}},ne=async e=>{if(e.plan){H(t=>t.map(t=>t.id===e.id?{...t,state:'done'}:t));try{J(String(await e.plan.run()))}catch(e){J(`Couldn\u2019t do that: ${e.message}`)}}},ie=e=>{H(t=>t.map(t=>t.id===e.id?{...t,state:'cancelled'}:t)),J('Cancelled. Nothing was changed.')},re=()=>{te(N,Y),q(!1)};return(0,S.jsx)(c.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:d,children:(0,S.jsx)(p.default,{style:[m.styles.overlay,{justifyContent:'flex-end',padding:0}],children:(0,S.jsxs)(p.default,{testID:"chef-assistant",style:{backgroundColor:w.colours.surface,borderTopLeftRadius:18,borderTopRightRadius:18,borderWidth:1,borderColor:w.colours.border,width:'100%',maxWidth:640,alignSelf:'center',maxHeight:'92%',minHeight:'70%',padding:14,gap:10},children:[(0,S.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,S.jsx)(m.T,{size:20,weight:"semibold",children:"\u2726 Kitchen Assistant"}),(0,S.jsx)(n.GoldClose,{testID:"chef-assistant-close",onPress:d,style:{marginRight:-6}})]}),(0,S.jsx)(p.default,{testID:"chef-assistant-demo",children:(0,S.jsx)(m.Badge,{kind:"amber",label:O})}),(0,S.jsxs)(h.default,{ref:Q,style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:6},keyboardShouldPersistTaps:"handled",children:[0===M.length?(0,S.jsxs)(p.default,{style:{gap:8},children:[(0,S.jsxs)(m.T,{children:["Hi ",W.split(' ')[0],". Type or tap \ud83c\udfa4 and say what you need. I\u2019ll show you what I\u2019m about to do and wait for you to confirm. I never send, pay or delete."]}),P.map(e=>(0,S.jsx)(u.default,{accessibilityRole:"button",onPress:()=>te(e),style:{borderWidth:1,borderColor:w.colours.border,borderRadius:12,paddingVertical:9,paddingHorizontal:12,backgroundColor:w.colours.surface2},children:(0,S.jsx)(m.T,{size:14,children:e})},e))]}):null,M.map(e=>'you'===e.from?(0,S.jsx)(p.default,{style:{alignSelf:'flex-end',maxWidth:'85%',backgroundColor:'#3A2F12',borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id):e.plan?(0,S.jsxs)(p.default,{testID:"chef-confirm-card",style:{borderWidth:1.5,borderColor:'open'===e.state?w.colours.gold:w.colours.border,borderRadius:14,padding:12,gap:8,backgroundColor:w.colours.surface2},children:[(0,S.jsx)(m.T,{weight:"semibold",children:e.plan.title}),(0,S.jsx)(m.T,{size:14,colour:w.colours.muted,children:e.plan.detail}),e.plan.warn?(0,S.jsxs)(m.T,{size:13,colour:w.colours.amber,children:["\u26a0 ",e.plan.warn]}):null,'open'===e.state?(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(m.Button,{small:!0,testID:"chef-confirm",label:e.plan.confirm,onPress:()=>ne(e)}),(0,S.jsx)(m.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>ie(e)})]}):(0,S.jsx)(m.Badge,{kind:'done'===e.state?'ok':'neutral',label:'done'===e.state?'Confirmed':'Cancelled: nothing done'}),'open'===e.state?(0,S.jsxs)(m.Muted,{children:["Nothing happens until you tap ",e.plan.confirm,"."]}):null]},e.id):(0,S.jsx)(p.default,{testID:"chef-assistant-reply",style:{alignSelf:'flex-start',maxWidth:'92%',backgroundColor:w.colours.surface2,borderRadius:14,padding:10},children:(0,S.jsx)(m.T,{children:e.text})},e.id))]}),(0,S.jsxs)(m.Row,{gap:8,children:[(0,S.jsx)(t.TextInput,{testID:"chef-assistant-input",accessibilityLabel:"Ask the Assistant",placeholder:"Type a kitchen task\u2026",placeholderTextColor:"#7D776C",value:N,onChangeText:e=>{_(e),e||q(!1)},onSubmitEditing:re,returnKeyType:"send",style:[m.styles.input,{flex:1,minWidth:0,width:40}]}),(0,S.jsx)(u.default,{testID:"chef-assistant-mic",accessibilityRole:"button",accessibilityLabel:V?'Stop listening':'Speak',onPress:()=>{const e=z();if(e)if(V)U.current?.stop?.();else try{const t=new e;U.current=t,t.lang='en-GB',t.interimResults=!1,t.maxAlternatives=1,t.onresult=e=>{const t=e.results?.[0]?.[0]?.transcript;t&&(_(t),q(!0))},t.onend=()=>K(!1),t.onerror=()=>{K(!1),J('Sorry, I didn\u2019t catch that. You can type instead.')},K(!0),t.start()}catch{K(!1),J('Voice input isn\u2019t available here. Please type instead.')}else J('Voice input isn\u2019t available in this browser. Please type instead.')},style:{width:48,height:48,borderRadius:24,borderWidth:1.5,borderColor:w.colours.gold,alignItems:'center',justifyContent:'center',backgroundColor:V?w.colours.gold:'transparent'},children:(0,S.jsx)(m.T,{size:20,children:"\ud83c\udfa4"})}),(0,S.jsx)(m.Button,{label:"Send",disabled:!N.trim(),onPress:re})]}),(0,S.jsx)(m.Muted,{center:!0,children:"Every action waits for your Confirm \xb7 nothing is sent, paid or deleted"})]})})})};var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),o=_r(_d[5]),l=_r(_d[6]),d=_r(_d[7]),c=e(_r(_d[8]));_r(_d[9]);var u=e(_r(_d[10])),h=e(_r(_d[11])),p=e(_r(_d[12])),f=_r(_d[13]),m=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),v=_r(_d[19]),w=_r(_d[20]),$=_r(_d[21]),C=_r(_d[22]),T=_r(_d[23]),k=_r(_d[24]),S=_r(_d[25]);const I=(0,f.create)(e=>({open:!1,setOpen:t=>e({open:t})})),R=()=>Math.random().toString(36).slice(2,9),P=['Draft a recipe card for crab linguine','Build the fish order','What allergens are in the fish and chips?','What price gives 70% GP on the lobster?','Walk-in fridge 3.5 degrees'],O='The secure AI server: not set up yet',A=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').replace(/\s+/g,' ').trim(),W=new Set(['the','and','with','for','our','house','served','side','of','in','on','from']);function D(e,t,n){const r=` ${A(e)} `;let s,a=0;for(const e of t){const t=A(n(e).replace(/\(example\)/i,'')).split(' ').filter(e=>e.length>2&&!W.has(e)),o=t.filter(e=>r.includes(` ${e} `)||r.includes(` ${e}s `)).length,l=t.length?o/t.length+.01*o:0;o&&l>a&&(s=e,a=l)}return s}function z(){return'undefined'==typeof window?null:(0,l.speechRecognizer)()}},1244,[827,796,1221,835,984,34,931,1200,395,236,402,295,102,846,794,861,1035,867,882,1034,821,1165,1159,1186,932,25]); +__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,"BOTTOM_TABS_HEIGHT",{enumerable:!0,get:function(){return h}}),_e.BottomTabs=function({tabs:e,active:b,onPress:y,background:x,tablist:p}){const{width:j}=(0,s.default)(),v=j/Math.max(1,e.length),w=v>=60?11:10,I=v<56?20:22,[F,S]=(0,t.useState)({}),[H,_]=(0,t.useState)(0),M=H>0&&e.some(e=>(F[e.id]??0)>H-6),z={flexDirection:'row',flexWrap:'nowrap',alignItems:'stretch',borderTopWidth:1,borderColor:c.colours.border,backgroundColor:x};return(0,f.jsx)(l.default,{testID:"app-bottom-tabs",accessibilityRole:p?'tablist':void 0,style:z,children:e.map(t=>{const s=b===t.id,x=s?c.colours.gold:c.colours.muted;return(0,f.jsxs)(n.default,{onLayout:t===e[0]?e=>_(e.nativeEvent.layout.width):void 0,testID:`tab-${t.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:t.a11y??t.label,onPress:()=>y(t.id),style:{flexGrow:1,flexShrink:1,flexBasis:0,minWidth:44,minHeight:h,alignItems:'center',justifyContent:'center',paddingVertical:4,paddingHorizontal:1,gap:2},children:[(0,f.jsxs)(l.default,{style:{width:I,height:I,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(u.Icon,{name:t.icon,size:I,colour:x}),t.badge?(0,f.jsx)(l.default,{testID:t.badge.testID,style:{position:'absolute',right:-10,top:-5,backgroundColor:t.badge.bg,borderRadius:8,minWidth:16,height:16,paddingHorizontal:3,alignItems:'center',justifyContent:'center'},children:(0,f.jsx)(o.default,{style:{fontFamily:c.fonts.bold,fontSize:10,lineHeight:12,color:t.badge.fg??'#FFFFFF'},children:t.badge.text})}):null]}),(0,f.jsx)(l.default,{pointerEvents:"none","aria-hidden":!0,importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,style:{position:'absolute',left:0,top:0,width:0,height:0,overflow:'hidden',opacity:0},children:(0,f.jsx)(l.default,{style:{width:400,flexDirection:'row',alignItems:'flex-start'},children:(0,f.jsx)(o.default,{onLayout:e=>{const n=Math.ceil(e.nativeEvent.layout.width);S(e=>e[t.id]===n?e:{...e,[t.id]:n})},style:{fontFamily:c.fonts.semibold,fontSize:w,lineHeight:Math.round(1.3*w),flexShrink:0},children:t.short??t.label})})}),M?null:(0,f.jsx)(o.default,{numberOfLines:1,style:{fontFamily:s?c.fonts.semibold:c.fonts.regular,fontSize:w,lineHeight:Math.round(1.3*w),color:x,textAlign:'center',alignSelf:'center',maxWidth:'100%'},children:t.short??t.label})]},t.id)})})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=r(d[5]),u=r(d[6]),f=r(d[7]);const h=56},1245,[34,402,346,102,426,821,1201,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return(0,u.canShow)('chef')?(0,c.jsx)(n.ChefApp,{}):(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]})}},1246,[30,34,792,872,25]); +__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 A}});var e,t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),s=_r(d[3]),l=_r(d[4]),i=_r(d[5]),a=_r(d[6]),r=_r(d[7]),u=(e=r)&&e.__esModule?e:{default:e},c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]),f=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),v=_r(d[17]),S=_r(d[18]),w=_r(d[19]),T=_r(d[20]),C=_r(d[21]),D=_r(d[22]),$=_r(d[23]),P=_r(d[24]),M=_r(d[25]),B=_r(d[26]),O=_r(d[27]);function A(){const{rid:e,date:r}=(0,s.useLocalSearchParams)(),A=(0,j.useRestaurant)(e),N=(0,j.useCustomer)(),z=(0,j.useBookings)(e),I=(0,j.useEvents)(e),R=(0,j.useNow)(6e4),[q]=(0,l.useState)(()=>(0,a.startForm)()),[F,L]=(0,l.useState)(''),[E,H]=(0,l.useState)(2),[W,_]=(0,l.useState)(0),Y=Math.min(W,Math.max(0,E-1)),[U,G]=(0,l.useState)(r??(0,k.ymd)(R)),[Q,V]=(0,l.useState)(null),[J,K]=(0,l.useState)(N.name),[X,Z]=(0,l.useState)(N.phone??''),[ee,te]=(0,l.useState)(N.email??''),[oe,ne]=(0,l.useState)(!1),[se,le]=(0,l.useState)(''),[ie,ae]=(0,l.useState)(!1),[re,de]=(0,l.useState)([]),[ue,ce]=(0,l.useState)(!1),he=[...N.allergies,...re.filter(e=>!N.allergies.some(t=>t.allergen===e)).map(e=>({allergen:e,severity:'allergy'}))],[me,ge]=(0,l.useState)(null),pe=(0,C.useBlocks)(e=>e.blocks);(0,v.usePublicDayStore)(e=>e.n);const be=e?(0,v.publicDay)(e,U):null,fe=be?[...be.bookings,...z.filter(e=>e.date!==U)]:z,ye=be?[...pe.filter(t=>t.rid!==e||t.date!==U),...be.blocks]:pe,xe=(0,D.usePlan)(e),[ke,je]=(0,l.useState)((0,P.emptyNeeds)()),ve=!0===ke.dog,Se=ve?ke.dogs:0;if(!A)return(0,O.jsx)(b.Screen,{title:"Not found",children:(0,O.jsx)(b.T,{children:"Restaurant not found."})});const we=A.settings,Te=(0,k.parseYmd)(U),Ce=(0,x.onlinePartyBounds)(A),De=(0,C.blocksOn)(ye,A.id,U),$e=fe.filter(e=>e.date===U),Pe=xe.areas.filter(e=>e.dogs),Me=(0,M.dogSetUp)(xe),Be=e=>(0,$.freeTablesAt)(xe,$e,E,new Date(`${U}${(0,t.tableNumbers)(e)}:00`),(0,$.turnFor)(E,we.turnMins),we.turnMins,{dog:!0,closed:(0,C.closedAreasAt)(ye,A.id,U,e)}),Oe=(0,x.bookingSlots)(A,Te,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).reduce((e,t)=>e+t.partySize,0),E,R,e=>fe.filter(t=>t.date===U&&t.time===e&&!['cancelled','noshow'].includes(t.status)).length).map(e=>{const t=(0,C.blockAt)(ye,A.id,U,e.time),o=ve&&Me&&e.available&&!t&&(!Be(e.time).length||!(0,P.dogTimeOk)(A,fe,U,e.time,Se));return{...e,blocked:!!t,noDog:o,available:e.available&&!t&&!o}}),Ae=Oe.some(e=>e.available),Ne=(0,c.depositOf)(we),ze=(0,c.depositDue)(Ne,E,Y),Ie=ze>0?'deposit':'none',Re=(0,c.depositWords)(Ne,E,A.name,Y),qe=I.filter(e=>e.date===U),Fe=(0,T.ukPhone)(X),Le=(0,T.emailOk)(ee),Ee=(0,P.needsMissing)(ke,N.allergies),He=!!Q&&ie&&!Ee.length&&J.trim().length>1&&Fe.ok&&Le,We=async()=>{const e=(0,P.needsPatch)(ke,N.allergies),t=ve&&Me?Be(Q).map(e=>e.table):[],o=ve?ke.tableReq.find(e=>t.includes(e))??t[0]:void 0,n=await j.repo.bookings.create({restaurantId:A.id,customerId:N.id,name:J,partySize:E,...Y?{children:Y}:{},date:U,time:Q,notes:se.trim(),security:Ie,depositPaid:0,...ze?{depositDue:ze,depositPolicy:Re.join(' '),depositRefundable:Ne.refundable,depositCutoffHours:Ne.cutoffHours}:{},phone:Fe.pretty,email:ee.trim()||void 0,source:'online',...e,...Oe.find(e=>e.time===Q)?.drinksOnly?{drinksOnly:!0}:{},allergies:e.allergies??he,...o?{table:o}:{}});(0,a.rememberGuard)(n.id,(0,a.guardFor)({...q,hp:F})),ge(n)},Ye=(0,j.useStore)(e=>me?e.bookings.find(e=>e.id===me.id)?.ref:void 0),Ue=e=>(0,w.waMeLink)(A.settings.whatsapp,(0,w.guestWhatsAppText)({name:e.name,ref:Ye??e.ref,date:e.date,time:e.time,partySize:e.partySize},A.name));if(me){const e='pending'===me.status;return(0,O.jsxs)(b.Screen,{title:e?'Booking request received':'Booking confirmed',subtitle:A.name,children:[(0,O.jsx)(b.Banner,{kind:e?'info':'success',title:`Reference ${Ye??me.ref}`,children:`${me.partySize} people \xb7 ${(0,k.niceDateYear)((0,k.parseYmd)(me.date))} at ${me.time}`}),e?(0,O.jsx)(b.Banner,{kind:"warn",title:"The team will confirm shortly",children:"For larger parties and special requests, a member of the team checks your booking first. Contact the venue if you need an update."}):null,(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(b.T,{children:["Name: ",me.name]}),(0,O.jsxs)(b.T,{children:["Mobile: ",me.phone]}),me.email?(0,O.jsxs)(b.T,{children:["Email: ",me.email]}):null,(0,O.jsxs)(b.T,{children:["Allergies shared with the restaurant: ",me.allergies.length?me.allergies.map(e=>`${(0,f.allergenLabel)(e.allergen)} (${(0,f.severityLabel)(e.severity)})`).join(', '):'none']}),me.notes?(0,O.jsxs)(b.T,{children:["Notes: ",me.notes]}):null,me.dog?(0,O.jsxs)(b.T,{children:["\ud83d\udc15 Dog coming too",me.table?` \xb7 dog-friendly table ${me.table}`:'']}):null,me.holds?.length?(0,O.jsxs)(b.T,{children:["Reserved: ",me.holds.map(e=>`${e.qty} \xd7 ${'item'===e.kind?(A.settings.reservables??M.ANCHORAGE_RESERVABLES).find(t=>t.id===e.id)?.name??'item':e.id}`).join(', ')," (the kitchen confirms it)"]}):null,me.tableReq?.length?(0,O.jsxs)(b.T,{children:["Table requested: ",me.tableReq.map(e=>`${(0,t.tableNumbers)(e)}`).join(' or ')," (not guaranteed, but we\u2019ll do our best)"]}):null,'deposit'===me.security&&me.depositDue?(0,O.jsxs)(b.T,{weight:"semibold",children:["Deposit due: ",(0,y.gbp)(me.depositDue),". ",A.name," will tell you how to pay it."]}):null,'deposit'===me.security&&me.depositPolicy?(0,O.jsx)(b.Muted,{children:me.depositPolicy}):null,(0,O.jsx)(b.Muted,{children:"Your booking details are shown above. If you need confirmation, contact the venue and quote your reference."}),(0,O.jsxs)(b.Muted,{children:["Need to change or cancel? Call ",A.phone," and quote ",Ye??me.ref,"."]})]}),Ue(me)?(0,O.jsxs)(u.default,{style:{gap:4},children:[(0,O.jsx)(b.Button,{kind:"secondary",label:"\ud83d\udcac Message us on WhatsApp",testID:"guest-whatsapp",onPress:()=>{const e=Ue(me);e&&(0,w.openWhatsApp)(e)}}),(0,O.jsx)(b.Muted,{size:13,children:"Opens WhatsApp with your booking details typed in. You can change the message before you send it."})]}):null,(0,O.jsx)(b.Button,{label:"Back to restaurant",onPress:()=>s.router.replace(`/customer/${A.id}`)})]})}return(0,O.jsxs)(b.Screen,{title:"Book a table",subtitle:A.name,footer:(0,O.jsx)(b.Button,{label:Ee.length?Ee[0]:E>(we.autoAcceptUpTo??7)?'Send booking request':'Confirm booking',disabled:!He,onPress:()=>We(),testID:"confirm-booking"}),children:[(0,O.jsx)(P.FirstQuestions,{rid:A.id,value:ke,onChange:e=>{e.dog===ke.dog&&e.dogs===ke.dogs||V(null),je(e)},party:E,audience:"guest",profile:N.allergies}),(0,O.jsxs)(b.Card,{children:[(0,O.jsxs)(u.default,{style:{gap:6,alignItems:'center'},children:[(0,O.jsx)(b.H2,{children:"Party size"}),(0,O.jsx)(o.PartySizeInput,{value:E,onChange:e=>{H(e),V(null)},min:Ce.min,max:Ce.max,label:"Party size",testID:"party-size"})]}),(0,O.jsx)(h.ChildrenCount,{guest:!0,party:E,value:Y,onChange:_,depositsOn:Ne.on&&Ne.perPersonPence>0,testID:"book-children"}),ze?(0,O.jsx)(b.Banner,{kind:"info",title:Y?`Deposit: ${(0,y.gbp)(ze)} for ${E-Y} adults (children free)`:`Deposit: ${(0,y.gbp)(ze)} for ${E} guests`,children:(0,O.jsx)(u.default,{style:{gap:4},children:Re.map(e=>(0,O.jsx)(b.T,{size:13,children:e},e))})}):Ne.on&&Ne.perPersonPence>0?(0,O.jsxs)(b.Muted,{children:["No deposit for fewer than ",Ne.fromParty," guests."]}):null,E>(we.autoAcceptUpTo??7)?(0,O.jsxs)(b.Muted,{children:["For ",E," people the team checks the booking first, then texts you to confirm."]}):null,ve&&Me?(0,O.jsxs)(b.Muted,{children:["Dogs are welcome in the ",Pe.map(e=>`${e.name}${e.outdoor?' (outdoors, weather permitting)':''}`).join(' and ')||'dog-friendly tables',". We\u2019ll only show times with a dog-friendly table",A.settings.maxDogsPerSlot?' and room for your dog':'',"."]}):null]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Date"}),(0,O.jsx)(B.CustomerDatePicker,{r:A,today:R,value:U,events:I,onChange:e=>{G(e),V(null)}}),qe.map(e=>(0,O.jsx)(b.Banner,{kind:"demo",title:e.title,children:e.description},e.id))]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Time"}),0===Oe.length?(0,O.jsx)(b.Muted,{children:"Closed on this day (per listed kitchen hours)."}):(0,O.jsx)(b.Row,{wrap:!0,gap:6,children:Oe.map(e=>(0,O.jsx)(b.Chip,{testID:`book-slot-${e.time}`,label:e.time,sub:e.available?e.drinksOnly?'Drinks only':void 0:e.blocked?'Unavailable':e.noDog?'No dog table':e.leftV(e.time)},e.time))}),De.length>0&&Oe.some(e=>e.blocked)?(0,O.jsx)(b.Banner,{kind:"info",title:Ae?'Some times aren\u2019t available online':'Online booking isn\u2019t available for this time',children:`We\u2019re not taking online bookings ${De.map(e=>`${e.from}\u2013${e.to}`).join(', ')} on ${(0,k.niceDate)(Te)}. Please give us a ring on ${A.phone??"the restaurant"} and we\u2019ll do our best to fit you in.`}):null,(()=>{const e=(0,n.lastFoodOn)(A,U);return e&&Oe.some(e=>e.drinksOnly)?(0,O.jsx)(b.Banner,{kind:"info",title:`Last food orders ${(0,n.fmt12)(e.time)}${'kitchen closes'!==e.reason?` (${e.reason})`:''}`,children:"Times marked \u201cDrinks only\u201d are after the kitchen\u2019s last food orders that day: you\u2019re welcome for drinks, but we can\u2019t serve food."}):null})(),ve&&Oe.some(e=>e.noDog)?(0,O.jsx)(b.Banner,{kind:"info",title:"Some times are full for dogs",children:`Times marked "No dog table" are full in the ${Pe.map(e=>e.name).join(' and ')}${A.settings.maxDogsPerSlot?' or already have the most dogs we can look after':''}${(0,C.closedAreasAt)(ye,A.id,U,Q??'12:00').size?', or the garden is closed for weather':''}. We\u2019d love to see you both, so please try one of the other times shown.`}):null,(0,O.jsx)(b.Muted,{children:(0,x.bookingLimitsHint)(A)})]}),(0,O.jsx)(P.MoreQuestions,{rid:A.id,r:A,value:ke,onChange:je,party:E,date:U,time:Q,today:(0,k.ymd)(R),bookings:fe,audience:"guest",showTables:!0}),(0,O.jsxs)(b.Card,{highlight:ie?void 0:S.colours.amber,children:[(0,O.jsx)(b.Field,{label:"Notes (optional)",value:se,onChangeText:le,placeholder:p.NOTES_PLACEHOLDER,multiline:!0,numberOfLines:3,testID:"book-notes"}),(0,O.jsx)(b.Toggle,{label:"I confirm the allergy information for this booking",value:ie,onChange:ae}),(0,O.jsx)(b.Muted,{children:"Table requests aren\u2019t guaranteed, but we\u2019ll do our best. Nothing here is charged now; reserved dishes are paid on the night."})]}),(0,O.jsxs)(b.Card,{children:[(0,O.jsx)(b.H2,{children:"Your details"}),(0,O.jsx)(b.Field,{label:"Name for the booking",value:J,onChangeText:K}),(0,O.jsx)(b.Field,{testID:"book-phone",label:"Mobile number (needed to book)",value:X,onChangeText:Z,onBlur:()=>ne(!0),keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),Fe.ok||!oe&&!X?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:Fe.error}),(0,O.jsx)(b.Field,{testID:"book-email",label:"Email (optional)",value:ee,onChangeText:te,keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",placeholder:"you@example.com"}),Le?null:(0,O.jsx)(b.T,{size:13,colour:S.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,O.jsxs)(b.Muted,{children:["We\u2019ll text you a confirmation",ee.trim()?' and email it too':'',", with how to change or cancel. We only use your number for this booking."]})]}),(0,O.jsx)(i.Honeypot,{value:F,onChange:L})]})}},1247,[860,1127,877,30,34,1248,1002,102,14,1129,1138,794,861,867,1131,858,874,987,821,1198,864,1026,1029,1105,1133,1101,1249,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Honeypot=function({value:t,onChange:n}){return(0,l.jsx)(o.default,{"aria-hidden":!0,pointerEvents:"none",style:{position:'absolute',left:-1e4,top:0,width:1,height:1,overflow:'hidden',opacity:0},children:(0,l.jsx)(e.TextInput,{testID:"hp-field",accessibilityLabel:"Leave this empty",value:t,onChangeText:n,tabIndex:-1,autoComplete:'off',name:'cc_extra_info','aria-hidden':!0})})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},l=r(d[4])},1248,[827,34,236,102,25]); +__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.CustomerDatePicker=function({r:e,today:m,value:D,events:x,onChange:f}){const p=(0,n.ymd)(m),j=(0,r.lastBookableDay)(p,e),[C,w]=(0,t.useState)(!1),[Y,k]=(0,t.useState)((0,i.slashDay)(D)),[I,P]=(0,t.useState)(D);I!==D&&(P(D),k((0,i.slashDay)(D)));const T=new Date(m);T.setHours(12,0,0,0);const $=Array.from({length:b},(e,t)=>{const s=new Date(T);return s.setDate(T.getDate()+t),s}).filter(e=>(0,n.ymd)(e)<=j),v=t=>!!(0,o.hoursFor)(e,t),F=(0,n.parseYmd)(D),[L,M]=(0,t.useState)(()=>({y:F.getFullYear(),m:F.getMonth()})),S=(new Date(L.y,L.m,1,12).getDay()+6)%7,R=new Date(L.y,L.m+1,0).getDate(),A=[...Array.from({length:S},()=>null),...Array.from({length:R},(e,t)=>new Date(L.y,L.m,t+1,12))];for(;A.length%7;)A.push(null);const z=(0,n.parseYmd)(j),W=L.y>m.getFullYear()||L.y===m.getFullYear()&&L.m>m.getMonth(),B=L.yM(({y:t,m:s})=>{const l=new Date(t,s+e,1);return{y:l.getFullYear(),m:l.getMonth()}}),_=Y===(0,i.slashDay)(D)?null:(0,r.typedBookDateProblem)(Y,p,e),O=e=>{f(e),w(!1)},G=(e,t)=>0===t?'Today':1===t?'Tomorrow':`${(0,n.dayShort)(e)} ${e.getDate()}`,N=$.some(e=>(0,n.ymd)(e)===D);return(0,h.jsxs)(l.default,{testID:"cust-date",style:{gap:10,alignItems:'center',width:'100%'},children:[(0,h.jsx)(l.default,{accessible:!0,accessibilityLiveRegion:"polite",testID:"cust-date-chosen",children:(0,h.jsx)(d.T,{center:!0,weight:"semibold",colour:c.colours.goldLight,children:`Booking for ${(0,n.niceDateYear)(F)}${v(F)?'':' (closed that day)'}`})}),(0,h.jsxs)(d.Row,{wrap:!0,gap:6,style:{justifyContent:'center'},children:[$.map((e,t)=>{const s=(0,n.ymd)(e),l=x.some(e=>e.date===s);return(0,h.jsx)(d.Chip,{testID:`cust-day-${s}`,label:G(e,t),sub:v(e)?l?'\u2605 event':void 0:'Closed',disabled:!v(e),selected:D===s,accessibilityLabel:`${(0,n.niceDate)(e)}${v(e)?l?', event':'':', closed'}`,onPress:()=>O(s)},s)}),N?null:(0,h.jsx)(d.Chip,{label:(0,n.niceDate)(F),sub:v(F)?void 0:'Closed',selected:!0,onPress:()=>w(!0),accessibilityLabel:`Chosen: ${(0,n.niceDateYear)(F)}. Opens the calendar`})]}),(0,h.jsxs)(l.default,{style:{width:'100%',maxWidth:360,gap:4},children:[(0,h.jsx)(d.Field,{label:"Any other date (DD/MM/YYYY)",testID:"cust-date-typed",value:Y,placeholder:"24/12/2026",keyboardType:"numbers-and-punctuation",maxLength:10,autoCapitalize:"none",autoCorrect:!1,style:{textAlign:'center'},accessibilityLabel:"Booking date, typed as day, month and four-digit year",onChangeText:t=>{const s=(0,i.slashDate)(t,Y);k(s);const l=(0,i.dayFromSlash)(s);l&&!(0,r.typedBookDateProblem)(s,p,e)&&f(l)}}),_&&Y.length>=10?(0,h.jsx)(d.T,{center:!0,size:15,colour:c.colours.amber,testID:"cust-date-problem",children:_}):null]}),(0,h.jsx)(d.Button,{kind:"secondary",label:C?'Hide calendar':'\ud83d\udcc5 Pick a date from a calendar',testID:"cust-date-cal",style:{minHeight:48},accessibilityLabel:C?'Hide the calendar':'Pick a date from a month calendar',onPress:()=>{C||M({y:F.getFullYear(),m:F.getMonth()}),w(!C)}}),C?(0,h.jsxs)(l.default,{testID:"cust-calendar",style:{borderWidth:1,borderColor:c.colours.border,borderRadius:14,padding:10,gap:6,backgroundColor:c.colours.surface2,width:'100%',maxWidth:420},children:[(0,h.jsx)(l.default,{style:{alignItems:'flex-end'},children:(0,h.jsx)(u.GoldClose,{label:"Close the calendar",testID:"cust-calendar-close",onPress:()=>w(!1),size:"sm"})}),(0,h.jsxs)(d.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Previous month",accessibilityState:{disabled:!W},disabled:!W,onPress:()=>H(-1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:W?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u2039"})}),(0,h.jsxs)(d.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:[(0,n.monthLong)(L.m)," ",L.y]}),(0,h.jsx)(s.default,{accessibilityRole:"button",accessibilityLabel:"Next month",accessibilityState:{disabled:!B},disabled:!B,onPress:()=>H(1),style:{minWidth:48,minHeight:48,alignItems:'center',justifyContent:'center',opacity:B?1:.3},children:(0,h.jsx)(d.T,{size:22,colour:c.colours.gold,children:"\u203a"})})]}),(0,h.jsx)(l.default,{style:{flexDirection:'row'},importantForAccessibility:"no-hide-descendants",children:y.map(e=>(0,h.jsx)(d.T,{size:12,colour:c.colours.muted,center:!0,style:{flex:1},children:e},e))}),Array.from({length:A.length/7},(e,t)=>(0,h.jsx)(l.default,{style:{flexDirection:'row',gap:4},children:A.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,h.jsx)(l.default,{style:{flex:1,height:44}},t);const o=(0,n.ymd)(e),i=oj,r=o===D,u=!v(e);return(0,h.jsx)(s.default,{testID:`cust-cal-${o}`,accessibilityRole:"button",accessibilityLabel:`${(0,n.niceDateYear)(e)}${i?', not bookable online':u?', closed':''}`,accessibilityState:{disabled:i||u,selected:r},disabled:i||u,onPress:()=>O(o),style:{flex:1,height:44,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:o===p?1.5:0,borderColor:c.colours.gold,backgroundColor:r?c.colours.gold:'transparent',opacity:i?.3:1},children:(0,h.jsx)(d.T,{size:15,center:!0,weight:r?'bold':'regular',colour:r?c.colours.onGold:u?c.colours.muted:c.colours.text,style:u&&!i?{textDecorationLine:'line-through'}:void 0,children:e.getDate()})},t)})},t)),(0,h.jsxs)(d.Muted,{center:!0,children:["Crossed-out days: closed. ",(0,r.bookAheadUnlimited)(e)?`You can book up to ${(0,i.slashDay)(j)}.`:`Online booking is open up to ${(0,i.slashDay)(j)}.`]})]}):null]})};var t=_r(_d[0]),s=e(_r(_d[1])),l=e(_r(_d[2])),o=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),r=_r(_d[6]),c=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),h=_r(_d[10]);const y=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],b=14},1249,[34,402,102,878,858,1063,1250,821,794,796,25]); +__d(function(g,_r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SERVER_MAX_DAYS_AHEAD",{enumerable:!0,get:function(){return n}}),e.bookAheadDays=r,Object.defineProperty(e,"bookAheadUnlimited",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"lastBookableDay",{enumerable:!0,get:function(){return u}}),e.typedBookDateProblem=function(n,r,o){const s=(n??'').trim();if(!s)return'Type a date as DD/MM/YYYY, for example 24/12/2026.';const l=(0,t.dayFromSlash)(s);if(!l)return'That isn\u2019t a date yet. Type it as DD/MM/YYYY, for example 24/12/2026.';if(lc){const[t,n,r]=c.split('-');return`Online booking is open up to ${r}/${n}/${t}. For later dates, please call us.`}return null};var t=_r(_d[0]);const n=366;function r(t){const r=Number(t?.settings?.onlineBookDaysAhead);return Number.isFinite(r)&&r>=1?Math.min(Math.round(r),n):n}const o=t=>r(t)>=n,s=(t,n)=>{const r=new Date(t+'T12:00:00Z');return r.setUTCDate(r.getUTCDate()+n),r.toISOString().slice(0,10)},u=(t,n)=>s(t,r(n))},1250,[1063]); +__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 b}});var n=_r(_d[0]),t=_r(_d[1]),s=_r(_d[2]),a=e(_r(_d[3])),l=e(_r(_d[4])),r=_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]),f=_r(_d[13]);function b(){const{rid:e,did:b}=(0,t.useLocalSearchParams)(),j=(0,h.useRestaurant)(e),x=(0,h.useMenu)(e).find(e=>e.id===b),y=(0,h.useCustomer)(),m=(0,h.useRecipeCards)(e).find(e=>e.id===x?.recipeCardId),k=m?.signOff&&m.photo?(0,g.recipeCards)().photoSource(m.photo):null,v=(0,h.useStore)(e=>e.addLine),w=(0,n.useTakeawayMenu)(n=>n.byVenue[e]),S=(0,h.useStore)(n=>n.basket.restaurantId===e&&'table'===n.basket.mode),[C,B]=(0,s.useState)(()=>(x?.optionGroups??[]).filter(e=>e.required).map(e=>e.choices[0].id)),[$,I]=(0,s.useState)(1),[P,T]=(0,s.useState)(''),[L,O]=(0,s.useState)(!1),[D,A]=(0,s.useState)(!1),[M,R]=(0,s.useState)(!1),[q,_]=(0,s.useState)(!1),N=(0,s.useMemo)(()=>x?(0,c.effectiveAllergens)(x,C):{},[x,C]);if(!j||!x)return(0,f.jsx)(d.Screen,{title:"Not found",children:(0,f.jsx)(d.T,{children:"Dish not found."})});const G=(0,c.conflictsFor)(N,y.allergies),Y=(x.price??0)+(x.optionGroups??[]).flatMap(e=>e.choices).filter(e=>C.includes(e.id)).reduce((e,n)=>e+n.priceDelta,0),z=S||j.fictional?'on':(0,n.takeawayAvail)(x,w),F=x.soldOut||!x.signOff||null===x.price||'on'!==z,Q=(e,n)=>{const t=x.optionGroups.find(n=>n.id===e);B(e=>{const s=t.choices.map(e=>e.id);return t.multi?e.includes(n)?e.filter(e=>e!==n):[...e,n]:e.includes(n)&&!t.required?e.filter(e=>e!==n):[...e.filter(e=>!s.includes(e)),n]})},V=e=>{h.useStore.getState().basket.restaurantId!==j.id&&h.useStore.getState().startBasket(j.id,'takeaway'),v({itemId:x.id,qty:$,choiceIds:C,notes:P,override:e?{allergens:G.contains,at:(new Date).toISOString()}:void 0}),O(!1),_(!0)};return(0,f.jsxs)(d.Screen,{title:x.name,subtitle:j.name,right:(0,f.jsx)(o.BasketButton,{}),children:[k?(0,f.jsx)(a.default,{testID:"dish-photo",source:k,accessibilityLabel:`${x.name}${'example'===m?.origin?' (example photo)':''}`,style:{width:'100%',height:200,borderRadius:12},resizeMode:"cover"}):null,(0,f.jsxs)(d.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(d.T,{weight:"bold",size:20,colour:p.colours.gold,children:null===x.price?x.priceNote:(0,u.gbp)(Y)}),x.dietary.map(e=>(0,f.jsx)(d.Badge,{kind:"ok",label:e},e))]}),(0,f.jsx)(d.T,{children:x.description}),G.contains.length?(0,f.jsx)(d.Banner,{kind:"danger",title:`Blocked: contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`You\u2019ve told us: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}. This dish can\u2019t be added unless you deliberately override (for example, ordering for someone else).`}):null,G.may.length?(0,f.jsx)(d.Banner,{kind:"warn",title:`Warning: may contain ${G.may.map(c.allergenLabel).join(', ')}`,children:"Cross-contact is possible (e.g. shared fryer). Please speak to staff before ordering."}):null,(x.optionGroups??[]).map(e=>(0,f.jsxs)(d.Card,{children:[(0,f.jsxs)(d.T,{weight:"semibold",children:[e.name,e.required?' (required)':' (optional)']}),(0,f.jsx)(d.Row,{wrap:!0,gap:6,children:e.choices.map(n=>(0,f.jsx)(d.Chip,{label:n.label,sub:n.priceDelta?`+${(0,u.gbp)(n.priceDelta)}`:void 0,selected:C.includes(n.id),onPress:()=>Q(e.id,n.id)},n.id))})]},e.id)),(0,f.jsx)(d.Card,{children:(0,f.jsx)(r.AllergenPanel,{item:x,map:N,declared:y.allergies})}),j.fictional?null:(0,f.jsx)(d.AllergenNotice,{phone:j.phone}),(0,f.jsx)(d.Field,{label:"Notes for the kitchen (optional)",placeholder:"e.g. no gherkins",value:P,onChangeText:T}),(0,f.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(d.T,{weight:"semibold",children:"Quantity"}),(0,f.jsx)(d.Stepper,{value:$,onChange:I,label:"quantity"})]}),q?(0,f.jsx)(d.Banner,{kind:"success",title:"Added to basket",children:G.contains.length?'Allergy override recorded \u2014 the kitchen will see a large allergy alert.':'Carry on browsing or go to your basket.'}):null,F?(0,f.jsx)(d.Banner,{kind:"warn",children:x.soldOut||'sold-out'===z?'Sold out today.':'off'===z&&x.signOff&&null!==x.price?'This dish isn\u2019t on the takeaway menu. You can have it when you eat in.':x.signOff?'Price on the specials board \u2014 ask staff.':'Not available to order online until the head chef signs off its allergens.'}):G.contains.length?(0,f.jsxs)(l.default,{style:{gap:8},children:[(0,f.jsx)(d.Button,{kind:"secondary",label:"Choose something else",onPress:()=>t.router.back()}),(0,f.jsx)(d.Button,{kind:"danger",label:"Override and add anyway\u2026",onPress:()=>{A(!1),R(!1),O(!0)},testID:"override-open"})]}):(0,f.jsxs)(d.Row,{gap:8,children:[(0,f.jsx)(d.Button,{style:{flex:1},label:`Add ${$} to basket \xb7 ${(0,u.gbp)(Y*$)}`,onPress:()=>V(!1),testID:"add-to-basket"}),q?(0,f.jsx)(d.Button,{kind:"secondary",label:"Basket",onPress:()=>t.router.push('/customer/basket')}):null]}),(0,f.jsxs)(d.Sheet,{visible:L,onClose:()=>O(!1),title:"Allergy override",children:[(0,f.jsx)(d.Banner,{kind:"danger",title:`${x.name} contains ${G.contains.map(c.allergenLabel).join(', ')}`,children:`Your profile says: ${y.allergies.filter(e=>G.contains.includes(e.allergen)).map(e=>`${(0,c.allergenLabel)(e.allergen)} \u2014 ${(0,c.severityLabel)(e.severity)}`).join('; ')}.`}),(0,f.jsx)(d.Toggle,{label:"I understand this dish contains an allergen I have declared",value:D,onChange:A}),(0,f.jsx)(d.Toggle,{label:"It is for someone without this allergy, or I have spoken to staff",value:M,onChange:R}),(0,f.jsx)(d.Muted,{children:"The override is logged and shown to the kitchen as an allergy alert that must be acknowledged."}),(0,f.jsx)(d.Button,{kind:"danger",disabled:!D||!M,label:"Confirm override and add",onPress:()=>V(!0),testID:"override-confirm"})]})]})}},1251,[988,30,34,336,102,1252,1254,794,861,867,874,882,821,25]); +__d(function(g,r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenPanel=function({item:e,map:n,declared:u}){return(0,d.jsxs)(s.default,{style:{gap:6},accessibilityLabel:"Allergen panel",children:[(0,d.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,d.jsx)(o.T,{weight:"semibold",children:"Allergen panel (14 UK allergens)"}),(0,l.isLiveVenue)()?null:(0,d.jsx)(o.Badge,{label:"NOT CONNECTED",kind:"amber"})]}),(0,d.jsx)(s.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:a.ALLERGENS.map(e=>{const l=n[e.id],c=u.find(l=>l.allergen===e.id),f='contains'===l?t.colours.redBg:'may'===l?t.colours.amberBg:t.colours.surface2,h='contains'===l?'#FFD9D4':'may'===l?'#FFE2A8':t.colours.muted;return(0,d.jsxs)(s.default,{style:{width:'48%',flexGrow:1,backgroundColor:f,borderRadius:8,padding:8,borderWidth:c?2:1,borderColor:c?t.colours.red:t.colours.border},children:[(0,d.jsx)(o.T,{size:14,weight:"medium",colour:l?h:t.colours.text,children:e.label}),(0,d.jsxs)(o.T,{size:13,colour:h,children:['contains'===l?'Contains':'may'===l?'May contain':'Not listed',c?` \xb7 YOUR ALLERGY (${(0,a.severityLabel)(c.severity)})`:'']})]},e.id)})}),e.allergenNotes?(0,d.jsxs)(o.Muted,{children:["Notes: ",e.allergenNotes]}):null,(0,d.jsx)(s.default,{testID:"allergen-signoff",children:(0,d.jsx)(o.Muted,{children:e.signOff?`From the dish's recipe card. Signed off by ${e.signOff.by} on ${c(e.signOff.at)}.`:"Awaiting the head chef's allergen sign-off: not available to order online."})}),(0,d.jsx)(o.Muted,{children:"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,d.jsx)(o.Row,{wrap:!0,gap:5,children:n.sort((e,l)=>e[1]===l[1]?0:'contains'===e[1]?-1:1).map(([e,n])=>{const s=l.some(l=>l.allergen===e);return(0,d.jsx)(o.Badge,{label:`${s?'\u26a0 ':''}${(0,a.allergenLabel)(e)}${'may'===n?' (may)':''}`,kind:s?'contains'===n?'red':'amber':'neutral'},e)})}):(0,d.jsx)(o.Muted,{children:"No listed allergens"})},r(_d[0]);var e,l=r(_d[1]),n=r(_d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(_d[3]),t=r(_d[4]),o=r(_d[5]),d=r(_d[6]);const c=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'})}},1252,[34,1253,102,861,821,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"isLiveVenue",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"useLiveVenue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"NOT_SET_UP",{enumerable:!0,get:function(){return f}});var t=r(d[0]),n=r(d[1]);const u=n=>!(t.PITCH||'live'!==n.mode&&'offline'!==n.mode||!n.venueId),o=()=>u(n.useSync.getState()),c=()=>(0,n.useSync)(t=>u(t)),f='Not set up yet'},1253,[2,987]); +__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])},1254,[30,34,402,874,821,794,25]); +__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 c}});var t=_r(d[0]),a=_r(d[1]),s=_r(d[2]),n=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]);const u=['Food','Service','Takeaway','Booking','Allergens','Something else'];function c(){const{rid:c,token:h,optout:p}=(0,t.useLocalSearchParams)(),b=(0,r.useRestaurant)(c),v=(0,r.useCustomer)(),[j,x]=(0,a.useState)(0),[y,w]=(0,a.useState)('Food'),[f,S]=(0,a.useState)(''),[k,C]=(0,a.useState)(!1),[P,R]=(0,a.useState)(!1);return b?'string'==typeof p&&p?(0,l.jsx)(s.Screen,{title:"Review emails",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewOptOut,{token:p})})}):'string'==typeof h&&h?(0,l.jsx)(s.Screen,{title:"Your review",subtitle:b.name,children:(0,l.jsx)(s.Card,{children:(0,l.jsx)(o.ReviewForm,{rid:b.id,venueName:b.name,token:h})})}):(0,l.jsxs)(s.Screen,{title:"Private feedback",subtitle:`Straight to the team at ${b.name}`,children:[P?(0,l.jsxs)(s.Banner,{kind:"success",title:"Thank you",children:["Your feedback went privately to ",b.name,". It is never published.",k?' They may reply by email (demo: nothing is sent).':'']}):null,P?(0,l.jsx)(s.Button,{kind:"secondary",label:"Send more feedback",onPress:()=>{R(!1),x(0),S('')}}):(0,l.jsxs)(s.Card,{children:[(0,l.jsx)(s.H2,{children:"How did we do?"}),(0,l.jsx)(n.Stars,{value:j,onChange:x}),(0,l.jsx)(s.T,{size:14,children:"What's it about?"}),(0,l.jsx)(s.Row,{wrap:!0,gap:6,children:u.map(t=>(0,l.jsx)(s.Chip,{label:t,selected:y===t,onPress:()=>w(t)},t))}),(0,l.jsx)(s.Field,{label:"Tell us more (optional)",value:f,onChangeText:S,multiline:!0,placeholder:"What went well, what could be better?"}),(0,l.jsx)(s.Chip,{label:k?'\u2713 Happy to be contacted':'Happy to be contacted?',selected:k,onPress:()=>C(!k)}),(0,l.jsx)(s.Button,{label:"Send privately",disabled:!j,onPress:()=>{r.repo.feedback.add({restaurantId:b.id,customerId:v.id,customerName:v.name,stars:j,comment:`${y}: ${f.trim()}${k?` (happy to be contacted: ${v.email})`:''}`,context:`App feedback \xb7 ${y}`}),R(!0)}})]}),(0,l.jsx)(s.Muted,{children:"Every rating, from 1 to 5 stars, goes the same way: privately to the restaurant. We never ask only happy guests to post a public review, and stamps or rewards are never given for reviews. A public review uses the link from your visit."}),(0,l.jsx)(o.ReviewsSection,{rid:b.id,mode:"read",venueName:b.name})]}):(0,l.jsx)(s.Screen,{title:"Not found",children:(0,l.jsx)(s.T,{children:"Restaurant not found."})})}},1255,[30,34,794,1256,874,1239,25]); +__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])},1256,[34,402,821,794,25]); +__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 x}});var t=_r(d[0]),a=_r(d[1]),n=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),b=_r(d[10]);function x(){const{rid:n}=(0,a.useLocalSearchParams)(),s=(0,o.useRestaurant)(n);(0,o.useCustomer)();return t.LIVE_VENUE_BUILD||(0,h.guestServer)()?s?(0,b.jsx)(c.GiftLive,{slug:n,venue:s.name}):(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})}):(0,b.jsx)(f,{})}function f(){const{rid:t}=(0,a.useLocalSearchParams)(),c=(0,o.useRestaurant)(t),h=(0,o.useGiftCards)(t),[x,f]=(0,n.useState)(5e3),[j,p]=(0,n.useState)(''),[g,y]=(0,n.useState)(''),[C,S]=(0,n.useState)(''),[v,w]=(0,n.useState)(!1),[P,T]=(0,n.useState)(null);if(!c)return(0,b.jsx)(r.Screen,{title:"Not found",children:(0,b.jsx)(r.T,{children:"Restaurant not found."})});const B=j?Math.round(100*Number(j))||0:x;return(0,b.jsxs)(r.Screen,{title:"Gift cards",subtitle:`${c.name} \u2014 redeemable only at ${c.name}`,children:[P?(0,b.jsx)(r.Banner,{kind:"success",title:`Gift card created \u2014 ${(0,l.gbp)(P.initial)}`,children:`Code ${P.code}. In production it would be emailed or sent in-app to ${P.recipientName||'the recipient'} (nothing sent in this demo).`}):null,(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Your gift cards"}),h.length?h.map(t=>(0,b.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(r.T,{style:{flex:1},children:t.code}),(0,b.jsxs)(r.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balance)," of ",(0,l.gbp)(t.initial)]})]},t.id)):(0,b.jsx)(r.Muted,{children:"None yet."}),(0,b.jsx)(r.Muted,{children:"Balances can be used at checkout on takeaway orders and table bills. Part-use leaves a balance."})]}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Buy a gift card"}),(0,b.jsx)(r.Row,{wrap:!0,children:[1e3,2500,5e3,15e3].map(t=>(0,b.jsx)(r.Chip,{label:(0,l.gbp)(t),selected:!j&&x===t,onPress:()=>{p(''),f(t)}},t))}),(0,b.jsx)(r.Field,{label:"Or another amount (\xa3)",keyboardType:"decimal-pad",value:j,onChangeText:p,placeholder:"e.g. 40"}),(0,b.jsx)(r.Field,{label:"Recipient\u2019s name",value:g,onChangeText:y}),(0,b.jsx)(r.Field,{label:"Message",value:C,onChangeText:S,multiline:!0,placeholder:"Happy birthday!"}),(0,b.jsx)(r.Muted,{children:"Valid for 24 months from purchase (suggested terms \u2014 to be confirmed by the restaurant)."}),(0,b.jsx)(r.Button,{label:`Buy ${(0,l.gbp)(B)} gift card`,disabled:B<500||B>5e4,onPress:()=>w(!0)})]}),(0,b.jsx)(s.MockPay,{visible:v,onClose:()=>w(!1),amount:B,restaurantId:c.id,allowGiftCard:!1,title:"Buy gift card",onPaid:async()=>{const t=await o.repo.giftCards.purchase(c.id,B,g,C);w(!1),T(t)}})]})}},1257,[837,30,34,1258,794,867,874,821,1259,1263,25]); +__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:h,amount:p,restaurantId:j,allowGiftCard:b=!0,onPaid:x,title:f="Pay"}){const y=(0,o.useRestaurant)(j),g=(0,o.useGiftCards)(j).filter(e=>e.balance>0),[m,w]=(0,s.useState)(),[P,C]=(0,s.useState)('Test card \u2022\u2022\u2022\u2022 4242'),[T,v]=(0,s.useState)(!1),M=g.find(e=>e.code===m),R=M?Math.min(M.balance,p):0,_=p-R;if(!y?.fictional)return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsxs)(c.T,{children:["Online card payment isn\u2019t set up for this yet, so nothing can be paid here. Please ask at the restaurant",y?.phone?` or phone ${y.phone}`:'',"."]}),(0,u.jsx)(c.Button,{kind:"secondary",label:"Close",onPress:h})]});return(0,u.jsxs)(c.Sheet,{visible:e,onClose:h,title:f,children:[(0,u.jsx)(c.DemoPaymentNotice,{}),b&&g.length>0?(0,u.jsxs)(l.default,{style:{gap:6},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"Use a gift card"}),(0,u.jsxs)(c.Row,{wrap:!0,children:[(0,u.jsx)(c.Chip,{label:"None",selected:!m,onPress:()=>w(void 0)}),g.map(e=>(0,u.jsx)(c.Chip,{label:`${e.code.slice(0,8)}\u2026`,sub:`${(0,n.gbp)(e.balance)} left`,selected:m===e.code,onPress:()=>w(e.code)},e.id))]})]}):null,(0,u.jsx)(c.T,{weight:"semibold",children:"Payment method"}),(0,u.jsx)(c.Row,{wrap:!0,children:['Test card \u2022\u2022\u2022\u2022 4242','Apple Pay (test)','Google Pay (test)'].map(e=>(0,u.jsx)(c.Chip,{label:e,selected:P===e,onPress:()=>C(e)},e))}),(0,u.jsxs)(l.default,{style:{gap:2},children:[(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Amount"}),(0,u.jsx)(c.T,{children:(0,n.gbp)(p)})]}),R?(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.Muted,{children:"Gift card"}),(0,u.jsxs)(c.T,{colour:r.colours.ok,children:["\u2212",(0,n.gbp)(R)]})]}):null,(0,u.jsxs)(c.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(c.T,{weight:"semibold",children:"To pay now"}),(0,u.jsx)(c.T,{weight:"bold",size:20,colour:r.colours.gold,children:(0,n.gbp)(_)})]})]}),T?(0,u.jsx)(t.default,{color:r.colours.gold}):(0,u.jsx)(c.Button,{label:`Pay ${(0,n.gbp)(_)} \u2014 demo`,onPress:()=>{v(!0),setTimeout(()=>{v(!1),x({giftCardCode:m,giftApplied:R,method:P})},700)},testID:"mock-pay-confirm"})]})};var s=_r(d[0]),t=e(_r(d[1])),l=e(_r(d[2])),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1258,[34,385,102,874,867,821,794,25]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftLive=function({slug:e,venue:n}){const{info:x,mine:b,err:S,load:w,pay:k}=j(e),[T,P]=(0,t.useState)(null),[D,C]=(0,t.useState)(''),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(''),[I,M]=(0,t.useState)(''),[E,L]=(0,t.useState)(!1),[R,A]=(0,t.useState)(''),[_,H]=(0,t.useState)(null),F=f(e);if(!x)return(0,h.jsx)(a.Screen,{title:"Gift cards",subtitle:n,children:S?(0,h.jsx)(a.Banner,{kind:"warn",title:S}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const N=D?(0,o.poundsToPence)(D)??0:T??x.amounts[1]??x.amounts[0]??0;return(0,h.jsxs)(a.Screen,{title:"Gift cards",subtitle:`${n}: used only at ${n}`,children:[_?(0,h.jsx)(s.default,{testID:"gift-made",children:(0,h.jsx)(a.Card,{highlight:u.colours.gold,children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift card code"}),(0,h.jsx)(a.T,{size:26,weight:"bold",colour:u.colours.gold,center:!0,children:_.code}),(0,h.jsxs)(a.Muted,{center:!0,children:["Shown once and kept on this phone. Write it down or take a screenshot to give it to ",O||'them',"."]}),(0,h.jsxs)(a.Banner,{kind:"warn",title:`Pay ${(0,l.gbp)(_.pence)} at the bar or till`,children:["Show reference ",_.ref,". The card works once staff mark it paid.",k.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"gift",id:_.id,pay:k})]})})}):null,(0,h.jsx)(g,{onDone:w}),(0,h.jsx)(s.default,{testID:"gift-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsx)(a.H2,{children:"Your gift cards"}),b.cards.length?b.cards.map(t=>(0,h.jsxs)(s.default,{style:{gap:2},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{style:{flex:1},children:F[t.id]??`\u2022\u2022\u2022\u2022 ${t.last4}`}),(0,h.jsxs)(a.T,{weight:"semibold",colour:u.colours.gold,children:[(0,l.gbp)(t.balancePence)," of ",(0,l.gbp)(t.initialPence)]})]}),(0,h.jsxs)(a.Muted,{size:12,children:[o.STATUS_WORDS[t.status]??t.status,t.expiresAt?` \xb7 use by ${p(t.expiresAt)}`:'','waiting-payment'===t.status?` \xb7 reference ${t.ref}`:'']}),'waiting-payment'===t.status&&_?.id!==t.id?(0,h.jsx)(m,{slug:e,kind:"gift",id:t.id,pay:k}):null]},t.id)):(0,h.jsx)(a.Muted,{children:"None yet."})]})})}),x.giftsOn?(0,h.jsx)(s.default,{testID:"gift-buy",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:8},children:[(0,h.jsx)(a.H2,{children:"Buy a gift card"}),(0,h.jsx)(a.Row,{wrap:!0,children:x.amounts.map(e=>(0,h.jsx)(a.Chip,{label:(0,l.gbp)(e),selected:!D&&N===e,onPress:()=>{C(''),P(e)}},e))}),(0,h.jsx)(a.Field,{label:`Or another amount (\xa3${x.minPence/100} to \xa3${x.maxPence/100})`,keyboardType:"decimal-pad",value:D,onChangeText:C,placeholder:"e.g. 40",testID:"gift-custom"}),(0,h.jsx)(a.Field,{label:"Who it\u2019s for",value:O,onChangeText:$,testID:"gift-recipient"}),(0,h.jsx)(a.Field,{label:"From",value:v,onChangeText:B}),(0,h.jsx)(a.Field,{label:"Message",value:I,onChangeText:M,multiline:!0,placeholder:"Happy birthday!"}),(0,h.jsxs)(a.Muted,{size:12,children:["Use within ",(0,o.expiryWords)(x.expiryMonths)," of paying. Part-use leaves a balance.",x.terms?` ${x.terms}`:'']}),(0,h.jsx)(s.default,{testID:"gift-pay-placeholder",children:(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER})}),R?(0,h.jsx)(a.Banner,{kind:"warn",title:R}):null,(0,h.jsx)(a.Button,{label:E?'Saving\u2026':`Get a ${(0,l.gbp)(N)} gift card, pay at the till`,testID:"gift-buy-btn",disabled:E||Nx.maxPence,onPress:async()=>{L(!0),A('');try{const t=await(0,c.buyGift)(e,{amount:N,recipient:O,from:v,message:I});t.code&&y(e,t.id,t.code),H({id:t.id,code:t.code??'',ref:t.ref,pence:t.initialPence}),w()}catch(e){A((0,r.plainError)(e))}finally{L(!1)}}})]})})}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n} isn\u2019t selling gift cards in the app yet`,children:"Ask at the bar."})]})},_e.ShopLive=function({slug:e,venue:n,guestName:p}){const{info:x,mine:f,err:y,load:b,pay:S}=j(e),[w,k]=(0,t.useState)({}),[T,P]=(0,t.useState)(p),[D,C]=(0,t.useState)(!1),[O,$]=(0,t.useState)(''),[v,B]=(0,t.useState)(null);if(!x)return(0,h.jsx)(a.Screen,{title:"Shop",subtitle:n,children:y?(0,h.jsx)(a.Banner,{kind:"warn",title:y}):(0,h.jsx)(a.Muted,{children:"Loading\u2026"})});const I=Object.entries(w).filter(([,e])=>e>0).map(([e,t])=>({id:e,qty:t})),M=(0,o.basketTotal)(I,x.products);return(0,h.jsxs)(a.Screen,{title:"Shop",subtitle:`${n}: collect at the venue`,children:[v?(0,h.jsxs)(s.default,{testID:"shop-done",children:[(0,h.jsxs)(a.Banner,{kind:"warn",title:`Order ${v.ref}: pay ${(0,l.gbp)(v.total)} at the bar or till`,children:["Staff will have it ready to collect once it\u2019s paid.",S.cardOn?'':' Card payment in the app is coming soon.']}),(0,h.jsx)(m,{slug:e,kind:"shop",id:v.id,pay:S})]}):null,(0,h.jsx)(g,{onDone:b}),x.shopOn?(0,h.jsxs)(h.Fragment,{children:[x.products.length?x.products.map(e=>(0,h.jsx)(s.default,{testID:`shop-item-${e.id}`,children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",style:{flex:1},children:e.name}),(0,h.jsx)(a.T,{colour:u.colours.gold,children:(0,l.gbp)(e.pricePence)})]}),e.details?(0,h.jsx)(a.Muted,{children:e.details}):null,e.soldOut?(0,h.jsx)(a.Badge,{kind:"amber",label:"Sold out"}):(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,h.jsx)(a.Muted,{children:"How many"}),(0,h.jsx)(a.Stepper,{value:w[e.id]??0,min:0,max:20,label:`${e.name} quantity`,onChange:t=>k({...w,[e.id]:t})})]})]})})},e.id)):(0,h.jsx)(a.Muted,{children:"Nothing in the shop yet."}),I.length?(0,h.jsx)(s.default,{testID:"shop-basket",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:6},children:[(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(a.T,{weight:"semibold",children:"Total"}),(0,h.jsx)(a.T,{weight:"semibold",colour:u.colours.gold,children:(0,l.gbp)(M)})]}),(0,h.jsx)(a.Field,{label:"Name for collection",value:T,onChangeText:P,testID:"shop-name"}),(0,h.jsx)(a.Banner,{kind:"demo",title:"Payment",children:o.PAY_PLACEHOLDER}),O?(0,h.jsx)(a.Banner,{kind:"warn",title:O}):null,(0,h.jsx)(a.Button,{label:D?'Sending\u2026':'Order, pay at the till',testID:"shop-order-btn",disabled:D||!T.trim(),onPress:async()=>{C(!0),$('');try{const t=await(0,c.shopOrder)(e,I,T);B({id:t.id,ref:t.ref,total:t.totalPence}),k({}),b()}catch(e){$((0,r.plainError)(e))}finally{C(!1)}}})]})})}):null]}):(0,h.jsx)(a.Banner,{kind:"demo",title:`${n}\u2019s shop isn\u2019t open in the app yet`,children:"Ask at the bar."}),f.orders.length?(0,h.jsx)(s.default,{testID:"shop-mine",children:(0,h.jsx)(a.Card,{children:(0,h.jsxs)(s.default,{style:{gap:4},children:[(0,h.jsx)(a.H2,{children:"Your shop orders"}),f.orders.map(e=>(0,h.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsxs)(a.T,{style:{flex:1},children:[e.ref," \xb7 ",e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')]}),(0,h.jsx)(a.Muted,{children:o.STATUS_WORDS[e.status]??e.status})]},e.ref))]})})}):null]})};var e,t=_r(d[0]),n=_r(d[1]),s=(e=n)&&e.__esModule?e:{default:e},a=_r(d[2]),l=_r(d[3]),r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]);const p=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},x=e=>`cc-gift-codes:${e}:v1`;function f(e){try{return JSON.parse(globalThis.localStorage?.getItem(x(e))||'{}')}catch{return{}}}function y(e,t,n){try{const s=f(e);s[t]=n,globalThis.localStorage?.setItem(x(e),JSON.stringify(s))}catch{}}function j(e){const[n,s]=(0,t.useState)(null),[a,l]=(0,t.useState)({cards:[],orders:[]}),[o,u]=(0,t.useState)(''),[h,p]=(0,t.useState)({provider:'none',cardOn:!1,testMode:!0}),x=(0,t.useCallback)(()=>{u(''),(0,c.shopPublic)(e).then(s).catch(e=>u((0,r.plainError)(e))),(0,c.myShop)(e).then(l).catch(()=>{}),(0,c.payPublic)(e).then(p)},[e]);return(0,t.useEffect)(()=>{x()},[x]),{info:n,mine:a,err:o,load:x,pay:h}}function g({onDone:e}){const[n,l]=(0,t.useState)('');return(0,t.useEffect)(()=>{const t='undefined'!=typeof window?new URLSearchParams(window.location.search).get('paid'):null;if(!t||!/^[0-9a-f-]{36}$/.test(t))return;let n=0;const s=()=>(0,c.payStatus)(t).then(t=>{l(t.status),'paid'===t.status?e():n++<10&&setTimeout(s,2e3)}).catch(()=>{});s()},[e]),n?(0,h.jsx)(s.default,{testID:"pay-back",children:(0,h.jsx)(a.Banner,{kind:'paid'===n?'success':'warn',title:'paid'===n?'Paid by card (TEST MODE: no real money)':'expired'===n?'The card payment timed out. Pay at the bar or till.':'Checking the card payment\u2026'})}):null}function m({slug:e,kind:n,id:l,pay:o}){const[u,p]=(0,t.useState)(!1),[x,f]=(0,t.useState)('');return o.cardOn?(0,h.jsxs)(s.default,{testID:`pay-card-${n}`,style:{gap:4},children:[(0,h.jsx)(a.Button,{label:u?'Opening card payment\u2026':'Pay by card (TEST MODE)',kind:"secondary",disabled:u,onPress:async()=>{p(!0),f('');try{const t=await(0,c.payStart)(e,n,l);window.location.assign(t.url)}catch(e){f((0,r.plainError)(e))}finally{p(!1)}}}),(0,h.jsx)(a.Muted,{size:12,children:"Test mode: use a Stripe test card. No real money is taken."}),x?(0,h.jsx)(a.Banner,{kind:"warn",title:x}):null]}):null}},1259,[34,102,794,867,1260,1261,1262,821,25]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DEFAULT_LOYALTY",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"consentText",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"prettyCardNo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"cleanCode",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"cardQr",{enumerable:!0,get:function(){return s}}),_e.readCardQr=function(e){const r=/^covercharge:card:[^:]+:([A-Za-z0-9-]{8,9})$/.exec(e.trim());return r?n(r[1]):null},Object.defineProperty(_e,"codeQr",{enumerable:!0,get:function(){return o}}),_e.checkSettings=function(e){return!Number.isInteger(e.stampsNeeded)||e.stampsNeeded<2||e.stampsNeeded>30?'Stamps needed must be between 2 and 30.':e.reward.trim()?e.reward.length>80?'Keep the reward under 80 letters.':e.gapMinutes<0||e.gapMinutes>1440?'Time between stamps must be 0 to 24 hours.':e.maxPerDay<1||e.maxPerDay>10?'Stamps a day must be 1 to 10.':!Number.isInteger(e.stampExpiryDays)||e.stampExpiryDays<0||e.stampExpiryDays>1095?'Stamps last 0 (never run out) to 1095 days.':!Number.isInteger(e.rewardExpiryDays)||e.rewardExpiryDays<0||e.rewardExpiryDays>1095?'Rewards last 0 (never run out) to 1095 days.':!e.referralOn||e.referralGiver.trim()&&e.referralFriend.trim()?e.referralMonthlyCap<0||e.referralMonthlyCap>50?'Friend rewards a month must be 0 to 50.':null:'Say what both people get before you switch Bring a friend on.':'Say what the reward is, for example Free dessert.'},_e.checkOffer=function(e){if(!e.title.trim())return'Give the offer a title.';if(e.title.length>80)return'Keep the title under 80 letters.';if(e.details.length>500)return'Keep the details under 500 letters.';const r=/^\d{4}-\d{2}-\d{2}$/;return e.startsOn&&!r.test(e.startsOn)?'Start date should look like 2026-11-30.':e.endsOn&&!r.test(e.endsOn)?'End date should look like 2026-11-30.':e.startsOn&&e.endsOn&&e.endsOn`I agree to ${e} keeping my name and the phone or email I give, only to run my stamp card and offers here. I can leave at any time and my details are removed.`,t=e=>e&&8===e.length?`${e.slice(0,4)}-${e.slice(4)}`:e,n=e=>e.toUpperCase().replace(/[^A-Z0-9]/g,''),s=(e,r)=>`covercharge:card:${e}:${r}`;const o=(e,r,t)=>`${e.replace(/\/$/,'')}/customer/${r}/loyalty?code=${t}`;const l=(e,r)=>e.isOn&&(!e.startsOn||e.startsOn<=r)&&(!e.endsOn||e.endsOn>=r),p=r=>r?{saved:!!r.updated_by,cardOn:!!r.card_on,stampsNeeded:r.stamps_needed??8,reward:r.reward??'',stampExpiryDays:r.stamp_expiry_days??0,rewardExpiryDays:r.reward_expiry_days??0,gapMinutes:r.gap_minutes??60,maxPerDay:r.max_per_day??1,referralOn:!!r.referral_on,referralGiver:r.referral_giver??'',referralFriend:r.referral_friend??'',referralMonthlyCap:r.referral_monthly_cap??5}:{...e},u=e=>({card_on:e.cardOn,stamps_needed:e.stampsNeeded,reward:e.reward.trim(),stamp_expiry_days:e.stampExpiryDays,reward_expiry_days:e.rewardExpiryDays,gap_minutes:e.gapMinutes,max_per_day:e.maxPerDay,referral_on:e.referralOn,referral_giver:e.referralGiver.trim(),referral_friend:e.referralFriend.trim(),referral_monthly_cap:e.referralMonthlyCap}),y=e=>({id:String(e.id),title:e.title??'',details:e.details??'',startsOn:e.starts_on??null,endsOn:e.ends_on??null,isOn:!1!==e.is_on})},1260,[]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOP_DEFAULT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PAY_PLACEHOLDER",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"cleanGiftCode",{enumerable:!0,get:function(){return o}}),e.prettyGiftCode=function(t){const n=o(t);return 16===n.length?n.match(/.{4}/g).join('-'):n},e.poundsToPence=i,e.redeemKey=function(t=Math.random){const n='abcdefghijkmnpqrstuvwxyz23456789';let r='r-';for(let o=0;o<20;o++)r+=n[Math.floor(32*t())%32];return r},Object.defineProperty(e,"expiryWords",{enumerable:!0,get:function(){return c}}),e.amountsFromText=function(t){const n=t.split(/[,\s]+/).filter(Boolean).map(i);return!n.length||n.length>6||n.some(t=>null===t||t<100)?null:[...new Set(n)].sort((t,n)=>t-n)},e.basketTotal=function(t,n){return t.reduce((t,r)=>t+(n.find(t=>t.id===r.id)?.pricePence??0)*r.qty,0)},Object.defineProperty(e,"settingsFromRow",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"settingsToRow",{enumerable:!0,get:function(){return a}});const t={giftsOn:!1,shopOn:!1,expiryMonths:24,amounts:[2500,5e3,1e4],minPence:500,maxPence:25e3,terms:''},n='Gift cards are sold through your website. You can also pay at the bar or till.',r={'waiting-payment':'Waiting for payment at the till',active:'Ready to use',used:'Used up',expired:'Expired',void:'Cancelled',paid:'Paid',ready:'Ready to collect',collected:'Collected',cancelled:'Cancelled'},o=t=>(t??'').toUpperCase().replace(/[^A-Z0-9]/g,'');function i(t){const n=(t??'').trim().replace(/^\xa3/,'');return/^\d{1,4}(\.\d{1,2})?$/.test(n)?Math.round(100*Number(n)):null}const c=t=>t%12==0?`${t/12} year${12===t?'':'s'}`:`${t} months`;const s=n=>n?{giftsOn:!!n.gifts_on,shopOn:!!n.shop_on,expiryMonths:n.expiry_months??24,amounts:n.amounts??t.amounts,minPence:n.min_pence??500,maxPence:n.max_pence??25e3,terms:n.terms??''}:{...t},a=t=>({gifts_on:t.giftsOn,shop_on:t.shopOn,expiry_months:t.expiryMonths,amounts:t.amounts,min_pence:t.minPence,max_pence:t.maxPence,terms:t.terms})},1261,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"shopPublic",{enumerable:!0,get:function(){return p}}),e.myShop=async function(t){return await(0,n.guestSession)()?(0,n.rpc)('guest_my_shop',{p_slug:t}):{cards:[],orders:[]}},e.buyGift=async function(t,o){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_gift_buy',{p_slug:t,p_amount:o.amount,p_recipient:o.recipient,p_from:o.from,p_message:o.message})},e.shopOrder=async function(t,o,c){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');return(0,n.rpc)('guest_shop_order',{p_slug:t,p_lines:o,p_name:c})},Object.defineProperty(e,"giftCheck",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"giftRedeem",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"giftActivate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"giftIssue",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"giftHonourWix",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"giftVoid",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"giftSummary",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"shopStatus",{enumerable:!0,get:function(){return v}}),e.waitingCards=async function(){const{data:t,error:n}=await c().from('gift_cards').select('id,last4,ref,initial_pence,balance_pence,status,source,recipient_name,issued_at,expires_at').eq('venue_id',s()).order('issued_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.shopOrders=async function(){const{data:t,error:n}=await c().from('shop_orders').select('*').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(60);if(n)throw n;return t??[]},e.readShopSettings=async function(){const{data:t,error:n}=await c().from('shop_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return(0,o.settingsFromRow)(t)},e.saveShopSettings=async function(t){const{error:n}=await c().from('shop_settings').upsert({venue_id:s(),...(0,o.settingsToRow)(t),updated_by:u(),updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readProducts=async function(){const{data:t,error:n}=await c().from('shop_products').select('*').eq('venue_id',s()).order('sort').order('name');if(n)throw n;return t??[]},e.saveProduct=async function(t){const n={venue_id:s(),name:t.name.trim(),details:t.details.trim(),price_pence:t.pricePence,stock:t.stock,is_live:t.live,updated_by:u(),updated_at:(new Date).toISOString()},{error:o}=t.id?await c().from('shop_products').update(n).eq('id',t.id):await c().from('shop_products').insert(n);if(o)throw o},Object.defineProperty(e,"payPublic",{enumerable:!0,get:function(){return S}}),e.payStart=async function(t,o,s){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const u='undefined'!=typeof window?window.location.href.split('?')[0]:'',{data:p,error:_}=await c().functions.invoke('pay-checkout',{body:{slug:t,kind:o,target:s,successUrl:u,cancelUrl:u}});if(_||!p?.url)throw new Error(p?.error??'Card payment isn\u2019t available yet. Pay at the bar or till.');if(!/^https:\/\/checkout\.stripe\.com\//.test(p.url))throw new Error('Card payment isn\u2019t available yet. Pay at the bar or till.');return p},Object.defineProperty(e,"payStatus",{enumerable:!0,get:function(){return P}}),e.readPaySettings=async function(){const{data:t,error:n}=await c().from('payment_settings').select('*').eq('venue_id',s()).maybeSingle();if(n)throw n;return{provider:t?.provider??'none',cardOn:!!t?.card_on,account:t?.stripe_account_id??''}},Object.defineProperty(e,"savePaySettings",{enumerable:!0,get:function(){return O}}),e.recentPayments=async function(){const{data:t,error:n}=await c().from('payments').select('id,kind,amount_pence,status,provider,created_at,paid_at').eq('venue_id',s()).order('created_at',{ascending:!1}).limit(20);if(n)throw n;return t??[]};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const c=()=>(0,t.getSupabase)(),s=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},u=()=>(n.useSync.getState().staffRef??'').slice(0,80)||null,p=t=>(0,n.rpc)('shop_public',{p_slug:t});const _=t=>(0,n.rpc)('staff_gift_check',{p_venue:s(),p_code:t}),f=(t,o,c,u)=>(0,n.rpc)('staff_gift_redeem',{p_venue:s(),p_code:t,p_amount:o,p_key:c,p_by:u}),y=(t,o)=>(0,n.rpc)('staff_gift_activate',{p_card:t,p_by:o}),l=(t,o,c)=>(0,n.rpc)('staff_gift_issue',{p_venue:s(),p_amount:t,p_recipient:o,p_by:c}),b=(t,o,c)=>(0,n.rpc)('staff_gift_honour_wix',{p_venue:s(),p_code:t,p_balance:o,p_by:c}),w=(t,o,c)=>(0,n.rpc)('staff_gift_void',{p_card:t,p_reason:o,p_by:c}),h=()=>(0,n.rpc)('staff_gift_summary',{p_venue:s()}),v=(t,o,c,s)=>(0,n.rpc)('staff_shop_status',{p_order:t,p_status:o,p_reason:c,p_by:s});const S=async t=>{try{return await(0,n.rpc)('pay_public',{p_slug:t})}catch{return{provider:'none',cardOn:!1,testMode:!0}}};const P=t=>(0,n.rpc)('guest_pay_status',{p_payment:t});const O=t=>(0,n.rpc)('staff_payment_settings_save',{p_venue:s(),p_provider:t.provider,p_card_on:t.cardOn,p_account:t.account,p_by:u()})},1262,[933,987,1261]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"guestServer",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"useGuestLoyalty",{enumerable:!0,get:function(){return _}}),e.refreshGuest=async function(t){if(!c())return;_.setState(n=>({loading:{...n.loading,[t]:!0}}));try{const n=await(0,o.rpc)('loyalty_public',{p_venue_slug:t});if(_.setState(r=>({info:{...r.info,[t]:n}})),await(0,o.guestSession)()){const n=await(0,o.rpc)('loyalty_my_card',{p_venue_slug:t});_.setState(r=>({card:{...r.card,[t]:n??null}}))}}finally{_.setState(n=>({loading:{...n.loading,[t]:!1}}))}},e.guestJoin=async function(t,n){if(!await(0,o.guestSession)())throw new Error('No connection. Try again when you are back online.');const r=await(0,o.rpc)('loyalty_guest_join',{p_venue_slug:t,p_name:n.name.trim(),p_phone:n.phone.trim()||null,p_email:n.email.trim()||null,p_consent:n.consent,p_consent_text:n.consentText,p_referral:n.referral?(0,l.cleanCode)(n.referral):null});return p(t,r),r},e.guestClaim=async function(t,n){if(!await(0,o.guestSession)())return{ok:!1,error:'No connection. Try again when you are back online.'};const r=await(0,o.rpc)('loyalty_guest_claim',{p_venue_slug:t,p_code:(0,l.cleanCode)(n)});return r?.error?{ok:!1,error:String(r.error)}:(p(t,r),{ok:!0,card:r,linked:!!r.linked})},e.guestLinkCode=async function(t){return(0,o.rpc)('loyalty_guest_link_code',{p_venue_slug:t})},e.guestLeave=async function(t){await(0,o.rpc)('loyalty_guest_leave',{p_venue_slug:t}),p(t,null)},Object.defineProperty(e,"staffFind",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"staffCard",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"staffStamp",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"staffRedeem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"staffJoin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"staffCode",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"staffRemove",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"loyaltySummary",{enumerable:!0,get:function(){return P}}),e.readSettings=async function(){const{data:t,error:n}=await u().from('loyalty_settings').select('*').eq('venue_id',y()).maybeSingle();if(n)throw n;return(0,l.settingsFromRow)(t)},e.saveSettings=async function(t){const{error:n}=await u().from('loyalty_settings').upsert({venue_id:y(),...(0,l.settingsToRow)(t),updated_by:(o.useSync.getState().staffRef??'').slice(0,80)||'manager',updated_at:(new Date).toISOString()},{onConflict:'venue_id'});if(n)throw n},e.readOffers=k,e.saveOffer=C,e.watchLoyalty=function(t){if(!f())return()=>{};const n=y();let r=u().channel(`cc-loyalty:${n}:${Math.random().toString(36).slice(2,8)}`);for(const o of['loyalty_settings','loyalty_offers','loyalty_guests','loyalty_stamps','loyalty_rewards','loyalty_referrals'])r=r.on('postgres_changes',{event:'*',schema:'public',table:o,filter:`venue_id=eq.${n}`},()=>t());return r.subscribe(),()=>{try{u().removeChannel(r)}catch{}}},e.migrateLocalOnce=async function(t,n,r){if(!f())return 0;const o=`loyalty:migrated:${y()}`;if(await n(o))return 0;let s=0;if(!(await k()).length)for(const n of t.offers.filter(t=>'offer'===t.kind&&!JSON.stringify(t).includes('(example)')))await C({title:n.title.slice(0,80),details:(n.body??'').slice(0,500),startsOn:null,endsOn:n.until??null,isOn:!!n.live}),s++;return await r(o),s};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),l=_r(d[5]);const u=()=>(0,n.getSupabase)(),c=()=>(0,r.isSupabaseConfigured)()&&!s.PITCH,f=()=>c()&&'staff'===o.useSync.getState().kind&&!!o.useSync.getState().venueId,y=()=>{const t=o.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},_=(0,t.create)(()=>({info:{},card:{},loading:{}}));const p=(t,n)=>_.setState(r=>({card:{...r.card,[t]:n}}));const b=t=>(0,o.rpc)('loyalty_staff_find',{p_venue:y(),p_q:t}),w=t=>(0,o.rpc)('loyalty_staff_card',{p_guest:t}),v=t=>(0,o.rpc)('loyalty_staff_stamp',{p_guest:t}),S=t=>(0,o.rpc)('loyalty_staff_redeem',{p_reward:t}),O=t=>(0,o.rpc)('loyalty_staff_join',{p_venue:y(),p_name:t.name.trim(),p_phone:t.phone.trim()||null,p_email:t.email.trim()||null,p_consent:t.consent,p_consent_text:t.consentText}),h=(t,n)=>(0,o.rpc)('loyalty_staff_code',{p_venue:y(),p_kind:t,p_guest:n??null}),j=t=>(0,o.rpc)('loyalty_staff_remove',{p_guest:t}),P=()=>(0,o.rpc)('loyalty_summary',{p_venue:y()});async function k(){const{data:t,error:n}=await u().from('loyalty_offers').select('*').eq('venue_id',y()).order('created_at');if(n)throw n;return(t??[]).map(l.offerFromRow)}async function C(t){const n={venue_id:y(),title:t.title.trim(),details:t.details.trim(),starts_on:t.startsOn||null,ends_on:t.endsOn||null,is_on:t.isOn,updated_at:(new Date).toISOString()},{error:r}=t.id?await u().from('loyalty_offers').update(n).eq('id',t.id):await u().from('loyalty_offers').insert(n);if(r)throw r}},1263,[846,933,976,987,2,1260]); +__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 H}});var t=e(_r(_d[0])),l=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),n=e(_r(_d[4])),o=e(_r(_d[5])),r=e(_r(_d[6])),i=_r(_d[7]),d=_r(_d[8]),u=_r(_d[9]),c=e(u);_r(_d[10]);var h=e(_r(_d[11])),b=e(_r(_d[12])),f=_r(_d[13]),p=_r(_d[14]),m=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),k=_r(_d[19]),w=_r(_d[20]),S=_r(_d[21]),T=_r(_d[22]),I=_r(_d[23]),O=_r(_d[24]),R=_r(_d[25]),A=_r(_d[26]),B=_r(_d[27]),P=_r(_d[28]),C=_r(_d[29]),_=_r(_d[30]),N=_r(_d[31]),v=_r(_d[32]);const M=['book','takeaway'].includes(C.START_GO??'')?C.START_GO:null;let $=!1,E=!1,L=!1;const D=[{id:'main',label:'Main menu'},{id:'specials',label:'Specials'},{id:'takeaway',label:'Takeaway'}];function H(){const{rid:e}=(0,d.useLocalSearchParams)(),i=(0,k.useRestaurant)(e),u=a.IS_QUEUED_VENUE?(0,v.jsx)(t.default,{}):a.IS_ABBOTSFORD?(0,v.jsx)(o.default,{}):a.IS_KIRKTON?(0,v.jsx)(r.default,{}):a.IS_GREENSIDE?(0,v.jsx)(n.default,{}):l.IsolatedCustomerHome&&(a.IS_WILDINGS||a.IS_KIRKMICHAEL||a.IS_SOUTERS)?(0,v.jsx)(l.IsolatedCustomerHome,{}):(0,v.jsx)(K,{});return a.IS_ABBOTSFORD||a.IS_KIRKTON||a.IS_WILDINGS||!i?.settings.hotel?.enabled?u:(0,v.jsx)(s.HotelRequestGate,{rid:e,hotel:i.settings.hotel,children:u})}function K(){const{rid:e}=(0,d.useLocalSearchParams)(),t=(0,k.useRestaurant)(e),l=(0,k.useMenu)(e),a=(0,k.useCustomer)(),s=(0,k.useBasket)(),n=(0,k.useStore)(e=>e.startBasket),o=(0,k.useNow)(3e4),[r,H]=(0,u.useState)('All'),[K,W]=(0,u.useState)(null),[G,F]=(0,u.useState)(!1),[U,V]=(0,u.useState)(!1),[Q,Y]=(0,u.useState)('takeaway'===M?'takeaway':'main');c.default.useEffect(()=>{M&&!$&&($=!0,'book'===M?setTimeout(()=>d.router.push(`/customer/${e}/book`),0):setTimeout(()=>{try{document.querySelector('[data-testid="menu-tabs"]')?.scrollIntoView({block:'start'})}catch{}},400))},[e]);const q=(0,B.useSpecials)(t=>t.current[e]??null),z=!!q&&(0,P.isToday)(q.postedAt,o),J=(0,R.useOwner)(e=>e.offers.filter(e=>e.live).length),X=(0,k.useStore)(t=>t.stampCards.find(l=>l.restaurantId===e&&l.customerId===t.customer.id)),Z=(0,_.useLiveTile)(e),ee=(0,N.guestServer)();c.default.useEffect(()=>{C.START_TABLE_TOKEN&&!L&&(L=!0,setTimeout(()=>d.router.push(`/table/live/${C.START_TABLE_TOKEN}`),0))},[e]),c.default.useEffect(()=>{C.START_LOYALTY_CODE&&!E&&(E=!0,setTimeout(()=>d.router.push(`/customer/${e}/loyalty`),0))},[e]);const te=(0,k.useOrderAtTable)(e),le=(0,w.useTakeawayMenu)(t=>t.byVenue[e]);if(c.default.useEffect(()=>{te||s.restaurantId!==e||'table'!==s.mode||k.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[te,s.mode,s.restaurantId,e]),!t)return(0,v.jsx)(m.Screen,{title:"Not found",children:(0,v.jsx)(m.T,{children:"Restaurant not found."})});const ae=te&&s.restaurantId===t.id&&'table'===s.mode,se=t.sections.length?t.sections:Array.from(new Set(l.map(e=>e.section))),ne=e=>ae||t.fictional?e.signOff&&null!==e.price?e.soldOut?'sold-out':'on':'off':(0,w.takeawayAvail)(e,le),oe=l.filter(e=>!('All'!==r&&e.section!==r||'takeaway'===Q&&'off'===ne(e))),re=(0,j.hoursFor)(t,o),ie=e=>()=>d.router.push(`/customer/${t.id}${e}`),de=[{icon:'box',label:'Takeaway',sub:'Order to collect',on:()=>{H('All'),Y('takeaway'),ae&&n(t.id,'takeaway')}},...te?[{icon:'phone',label:'Order at table',sub:'Scan the QR',on:()=>V(!0)}]:[],{icon:'calendarPlus',label:'Book a table',on:ie('/book')},{icon:'clock',label:'Waitlist',sub:'Walk in',on:ie('/waitlist')},{icon:'star',label:'Stamp card',sub:ee?Z.stamps:`${X?.stamps??0} of ${t.settings.stampTarget}`,on:ie('/loyalty')},{icon:'userPlus',label:'Bring a friend',on:ie('/refer')},{icon:'gift',label:'Gift cards',on:ie('/gift')},{icon:'alert',label:'My allergens',sub:a.allergies.length?`${a.allergies.length} declared`:'None declared',on:()=>d.router.push('/customer/profile')},{icon:'tag',label:'Offers',sub:ee?void 0:a.marketingOptIn[t.id]?'Opted in':'Opt in',on:ie('/offers'),badge:(ee?Z.offers:J)?String(ee?Z.offers:J):void 0},{icon:'sparkle',label:"What's on",on:ie('/whatson')},{icon:'chat',label:'Feedback',sub:'Private',on:ie('/feedback')},{icon:'star',label:'Reviews',sub:'Published',on:ie('/feedback')},{icon:'hanger',label:'Lost property',on:ie('/lost')},{icon:'bag',label:'Shop',sub:'Merch',on:ie('/merch')}];return(0,v.jsxs)(m.Screen,{title:t.name,subtitle:`${t.location}${t.phone?` \xb7 ${t.phone}`:''}`,back:'customer'!==O.APP_VARIANT,right:(0,v.jsxs)(m.Row,{children:[(0,v.jsx)(p.BasketButton,{}),(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:"Account",onPress:()=>d.router.push('/customer/profile')})]}),children:[t.fictional?(0,v.jsx)(m.Banner,{kind:"warn",title:"Fictional demo restaurant",children:"Shown only to demonstrate multi-restaurant support."}):null,ae?(0,v.jsx)(m.Banner,{kind:"success",title:`Ordering at ${(0,i.tableNumbers)(s.tableNo)}`,children:"Your order goes straight to the kitchen. Pay and split the bill from your order page. A member of staff is always available \u2014 tap \u201cCall staff\u201d any time."}):(0,v.jsx)(m.Card,{children:(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between'},children:[(0,v.jsxs)(b.default,{style:{flex:1},children:[(0,v.jsx)(m.T,{weight:"semibold",children:"Takeaway \u2014 collection"}),(0,v.jsxs)(m.Muted,{children:[re?`Kitchen today ${(0,j.kitchenHoursOn)(t,o)[0]}\u2013${(0,j.kitchenHoursOn)(t,o)[1]}`:'Kitchen closed today',t.settings.takeawayPaused?' \xb7 slots paused by the restaurant':'']})]}),(0,v.jsx)(m.Badge,{kind:t.settings.takeawayPaused||!re?'amber':'ok',label:t.settings.takeawayPaused?'Paused':re?'Taking orders':'Closed'})]})}),t.fictional?(0,v.jsx)(m.Row,{wrap:!0,gap:8,children:de.slice(2,7).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:e.label,onPress:e.on},e.label))}):(0,v.jsx)(b.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:de.map(e=>(0,v.jsx)(T.HubTile,{icon:e.icon,label:e.label,sub:e.sub,badge:e.badge,onPress:e.on},e.label))}),ae?(0,v.jsx)(m.Button,{small:!0,kind:"danger",label:"Call staff",onPress:()=>F(!0)}):null,G?(0,v.jsx)(m.Banner,{kind:"success",children:"We've told the staff on this device. Calling staff: not set up yet."}):null,t.hoursNote?(0,v.jsx)(m.Muted,{children:t.hoursNote}):null,t.fictional?null:(0,v.jsx)(m.AllergenNotice,{phone:t.phone}),(0,v.jsxs)(m.Muted,{children:["Menu dishes and prices from ",t.name,"\u2019s menu. Items marked \u26a0 conflict with your declared allergies."]}),(0,v.jsx)(b.default,{accessibilityRole:"tablist",testID:"menu-tabs",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6,backgroundColor:S.colours.surface,borderRadius:14,borderWidth:1,borderColor:S.colours.border,padding:4},children:D.map(e=>{const t=Q===e.id;return(0,v.jsxs)(h.default,{testID:`menu-tab-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:'specials'===e.id&&z?'Specials, updated today':e.label,onPress:()=>Y(e.id),style:{flex:1,minWidth:120,flexBasis:120,minHeight:44,borderRadius:10,alignItems:'center',justifyContent:'center',paddingHorizontal:4,backgroundColor:t?S.colours.gold:'transparent'},children:[(0,v.jsx)(m.T,{size:14,weight:"semibold",colour:t?S.colours.onGold:S.colours.text,center:!0,children:e.label}),'specials'===e.id&&z&&!t?(0,v.jsx)(b.default,{style:{position:'absolute',top:6,right:8,width:7,height:7,borderRadius:4,backgroundColor:S.colours.gold}}):null]},e.id)})}),'specials'===Q?(0,v.jsx)(A.SpecialsTab,{rid:t.id,declared:a.allergies,now:o}):null,'takeaway'===Q?(0,v.jsx)(m.Muted,{children:"Order to collect. Only dishes available to order online are shown; pick a collection slot at checkout."}):null,'specials'!==Q?(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[(0,v.jsx)(m.Chip,{label:"All",selected:'All'===r,onPress:()=>H('All')}),se.map(e=>(0,v.jsx)(m.Chip,{label:e,selected:r===e,onPress:()=>H(e)},e))]}):null,'takeaway'!==Q||oe.length?null:(0,v.jsx)(m.Muted,{children:le||t.fictional?'Nothing is on the takeaway menu right now. Please ring the restaurant.':'Loading the takeaway menu\u2026'}),'specials'!==Q?se.filter(e=>('All'===r||e===r)&&oe.some(t=>t.section===e)).map(e=>(0,v.jsxs)(b.default,{style:{gap:10},children:[(0,v.jsx)(m.H2,{style:{color:S.colours.gold,marginTop:6},children:e}),oe.filter(t=>t.section===e).map(e=>{const l=(0,y.conflictsFor)(e.allergens,a.allergies),o=ne(e),r='on'!==o,i=e.soldOut||'sold-out'===o;return(0,v.jsxs)(m.Card,{highlight:l.contains.length?S.colours.red:l.may.length?S.colours.amber:void 0,children:[(0,v.jsxs)(h.default,{accessibilityRole:"button",onPress:()=>{r?W(K===e.id?null:e.id):(s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`))},children:[(0,v.jsxs)(m.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,v.jsx)(m.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%',paddingRight:8},children:e.name}),(0,v.jsx)(m.T,{weight:"semibold",colour:S.colours.gold,children:null===e.price?e.priceNote??'\u2014':(0,x.gbp)(e.price)})]}),(0,v.jsx)(m.Muted,{numberOfLines:2,children:e.description})]}),(0,v.jsxs)(m.Row,{wrap:!0,gap:6,children:[e.dietary.map(e=>(0,v.jsx)(m.Badge,{kind:"ok",label:e},e)),e.special?(0,v.jsx)(m.Badge,{kind:"gold",label:"Special"}):null,i?(0,v.jsx)(m.Badge,{kind:"neutral",label:"Sold out"}):null,e.signOff?null:(0,v.jsx)(m.Badge,{kind:"amber",label:"Awaiting allergen sign-off"}),l.contains.length?(0,v.jsx)(m.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,v.jsx)(m.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null]}),(0,v.jsx)(f.AllergenChips,{map:e.allergens,declared:a.allergies}),K===e.id?(0,v.jsx)(f.AllergenPanel,{item:e,map:e.allergens,declared:a.allergies}):null,(0,v.jsxs)(m.Row,{gap:8,children:[(0,v.jsx)(m.Button,{small:!0,kind:"ghost",label:K===e.id?'Hide allergen panel':'Allergen panel',onPress:()=>W(K===e.id?null:e.id)}),(0,v.jsx)(b.default,{style:{flex:1}}),(0,v.jsx)(m.Button,{small:!0,label:r?i?'Sold out':e.signOff&&null!==e.price?'Not on the takeaway menu':'Not available online':'Choose',disabled:r,onPress:()=>{s.restaurantId&&s.restaurantId===t.id||n(t.id,'takeaway'),d.router.push(`/customer/${t.id}/dish/${e.id}`)}})]})]},e.id)})]},e)):null,(0,v.jsx)(I.ReviewsSection,{rid:t.id,mode:"read",venueName:t.name}),(0,v.jsx)(m.Muted,{children:"Drinks list coming soon. Ask your server for today\u2019s drinks."}),(0,v.jsx)(m.Muted,{children:"Card payments: not set up yet. Pay at the till as usual."}),(0,v.jsx)(T.LauncherLine,{}),te?(0,v.jsxs)(m.Sheet,{visible:U,onClose:()=>V(!1),title:"Order at your table",children:[(0,v.jsx)(m.Muted,{children:"Scan the QR code on your table with your phone camera, or pick your table number."}),(0,v.jsx)(m.Row,{wrap:!0,gap:6,children:Array.from({length:12},(e,t)=>String(t+1)).map(e=>(0,v.jsx)(m.Button,{small:!0,kind:"secondary",label:`${(0,i.tableNumbers)(e)}`,onPress:()=>{V(!1),n(t.id,'table',e)}},e))}),(0,v.jsx)(m.Muted,{children:"Orders go straight to the kitchen. Card payments: not set up yet. Pay at the till as usual."})]}):null]})}},1264,[1265,1274,5,1275,1276,1277,1280,860,30,34,236,402,102,1252,1254,794,861,867,878,874,988,821,1281,1239,872,891,1282,995,996,1004,1284,1263,25]); +__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 f}});var e,n=_r(d[0]),t=_r(d[1]),s=(e=t)&&e.__esModule?e:{default:e},r=_r(d[2]),o=_r(d[3]),u=_r(d[4]),l=_r(d[5]),c=_r(d[6]),h=_r(d[7]),j=_r(d[8]),x=_r(d[9]),b=_r(d[10]);function f(){const e=j.VENUE_RID,t=x.queuedVenues[e],f=(0,h.useRestaurant)(e)??(0,x.queuedRestaurant)(e),[p,k]=(0,n.useState)(!1),y=f.kitchenSessionsByDay;return(0,b.jsxs)(r.Screen,{title:t.name,back:!1,children:[(0,b.jsx)(o.RestaurantHero,{rid:e,size:240}),p?(0,b.jsx)(l.NativeRequestSetup,{rid:e,kind:"table",sessionHours:y,onClose:()=>k(!1)}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(r.Button,{testID:`${e}-book-table`,label:"Book a table",onPress:()=>k(!0)}),t.phone?(0,b.jsx)(r.Button,{kind:"secondary",label:`Call ${t.phone}`,onPress:()=>{s.default.openURL('tel:'+t.phone.replace(/[^0-9+]/g,''))}}):null,(0,b.jsx)(r.Muted,{children:"Send a table request for this venue\u2019s managers to confirm. This is not an instant booking. No deposit or payment is taken. No emails or texts are sent by this app."}),(0,b.jsxs)(r.Card,{children:[(0,b.jsx)(r.H2,{children:"Kitchen and venue hours"}),(0,b.jsx)(r.T,{children:t.hours.note})]}),t.clockArea.on?(0,b.jsx)(u.FindPub,{rid:e}):(0,b.jsxs)(r.Muted,{children:["Find us: ",t.address,". Precise map location to confirm."]}),(0,b.jsx)(c.QueuedMenus,{menu:t.menu,context:t.menuServiceContext,allergens:t.allergenCaveat}),(0,b.jsxs)(r.Banner,{kind:"warn",title:"To confirm",children:[t.gatesToConfirm.join(', '),"."]}),(0,b.jsx)(r.Muted,{children:"Ordering, takeaway, delivery and loyalty: to set up. Deposits are blank and off."})]})]})}},1265,[34,379,794,873,1266,1267,1273,874,5,6,25]); +__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.FindPub=function({rid:e}){const p=(0,l.pubLocation)(e),[b,y]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),[j,w]=(0,n.useState)(null),[I,v]=(0,n.useState)(null);if(!p)return null;const D=async()=>{y(!1),x(!0),v(null);const e=await(0,u.getFix)();x(!1),'object'==typeof e?(w(Math.round((0,c.distanceM)(p,e))),v(null)):(w(null),v('Your location was not shared. You can still use the address and open directions.'))};return(0,h.jsx)(o.Card,{children:(0,h.jsxs)(t.default,{testID:"find-pub",style:{gap:10},children:[(0,h.jsx)(o.T,{accessibilityRole:"header",weight:"bold",children:"Find us"}),(0,h.jsx)(o.T,{children:p.address}),(0,h.jsx)(o.Muted,{children:"See your approximate distance, or open directions. Location is optional and is never saved."}),(0,h.jsx)(o.Button,{testID:"find-pub-distance",label:f?'Finding your distance\u2026':'Find us \u2014 show my distance',accessibilityLabel:`Find ${p.name}, show my distance using my location once`,disabled:f,onPress:()=>y(!0)}),(0,h.jsxs)(t.default,{accessibilityLiveRegion:"polite",testID:"find-pub-result",children:[null!=j?(0,h.jsxs)(o.T,{children:["About ",j<1e3?`${j} m`:`${(j/1e3).toFixed(1)} km`," away, in a straight line."]}):null,I?(0,h.jsx)(o.T,{children:I}):null]}),(0,h.jsx)(o.Button,{testID:"find-pub-directions",kind:"secondary",label:"Open directions in Maps",accessibilityLabel:`Open directions to ${p.name}, ${p.address}, without sharing my location with CoverCharge`,onPress:()=>{s.default.openURL(`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(p.address)}`)}}),(0,h.jsx)(o.Sheet,{visible:b,onClose:()=>y(!1),title:"Use your location for distance?",testID:"find-pub-reason",children:(0,h.jsxs)(t.default,{style:{gap:12},children:[(0,h.jsxs)(o.T,{children:["We use your phone\u2019s location once to estimate how far you are from ",p.name,". Your position stays on this screen only: it is not stored or sent to the pub."]}),(0,h.jsx)(o.T,{children:"You can refuse location and still see the address and use directions."}),(0,h.jsx)(o.Button,{testID:"find-pub-allow",label:"Use my location once",onPress:()=>{D()}}),(0,h.jsx)(o.Button,{testID:"find-pub-cancel",kind:"secondary",label:"Not now \u2014 keep the address",onPress:()=>y(!1)})]})})]})})};var n=r(d[0]),s=e(r(d[1])),t=e(r(d[2])),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7])},1266,[34,379,102,794,997,998,1096,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.NativeRequestSetup=function(l){const[h,p]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let u=!0;p(null);const s=(0,t.isQueuedVenue)(l.rid),o=s?'queued_venue_request_setup_ready':'kirkton'===l.rid?'kirkton_request_setup_ready':'abbotsford_request_setup_ready';return(0,n.getSupabase)().rpc(o,s?{p_slug:(0,t.queuedDatabaseSlug)(l.rid)}:void 0).then(({data:t,error:n})=>{u&&p(!n&&!0===t)},()=>{u&&p(!1)}),()=>{u=!1}},[l.rid,l.kind]),!0===h?(0,c.jsx)(o.VenueRequestForm,{...l}):(0,c.jsxs)(s.Card,{children:[(0,c.jsx)(s.H2,{children:null===h?'Checking booking setup\u2026':'Manager setup needed'}),(0,c.jsx)(s.Muted,{children:null===h?'Checking whether requests are ready.':(0,t.isQueuedVenue)(l.rid)?'An authorised manager must complete setup and confirm current kitchen hours before requests can be sent.':'kirkton'===l.rid?'An authorised manager must complete setup and confirm current kitchen hours before table requests can be sent. Contact details are to confirm.':'An authorised hotel manager must complete setup before requests can be sent.'}),(0,c.jsx)(s.Button,{kind:"secondary",label:"Back to Customer home",onPress:l.onClose})]})};var t=r(d[0]),u=r(d[1]),n=r(d[2]),s=r(d[3]),o=r(d[4]),c=r(d[5])},1267,[6,34,933,794,1268,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestForm=function({rid:e,kind:u,hotel:h,allDayHours:q,sessionHours:T,onClose:D}){const[f,v]=(0,l.useState)({name:'',phone:'',email:'',notes:'',date:(0,b.localDate)(),service:(0,t.isQueuedVenue)(e)||'greenside'===e?void 0:'Lunch',time:q||'greenside'===e?'10:00':'12:00',covers:2,checkIn:(0,b.localDate)(),checkOut:'',roomType:h?.roomTypes[0]?.id,guests:2,addDinner:!1}),C=e=>v(t=>({...t,...e})),[I,S]=(0,l.useState)(''),[w,B]=(0,l.useState)(''),[P,R]=(0,l.useState)(null),[Y,M]=(0,l.useState)(''),[N,$]=(0,l.useState)(!1),[L,V]=(0,l.useState)(!1),z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let s=!0;return(0,x.requestChallenge)(e,u).then(e=>{s&&R(e)}).catch(n=>{s&&M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(n).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(n))}),()=>{s=!1}},[e,u]);const F=async()=>{if(z.current)return;const s=(0,t.isQueuedVenue)(e)?(0,n.queuedRequestError)(e,f,T):q&&'table'===u?(0,o.allDayRequestError)(f,q):(0,r.errorForVenue)(e,u,f,h);if(s)M(s);else if(P&&I.trim()){z.current=!0,V(!0),M('');try{await(0,x.sendVenueRequest)(e,u,f,P.id,I,w),$(!0)}catch(s){M((0,t.isQueuedVenue)(e)||['greenside','kirkton'].includes(e)?(0,x.requestMessage)(s).replace(/the hotel/g,'the restaurant'):(0,x.requestMessage)(s))}finally{z.current=!1,V(!1)}}else M('Complete the security check.')},H={minHeight:48,fontSize:18,color:p.colours.text};return(0,k.jsxs)(c.default,{testID:`venue-${u}-form`,style:{gap:16,alignItems:'stretch'},children:[(0,k.jsx)(y.H2,{children:'table'===u?'Book a table':'Book a room'}),(0,k.jsx)(y.T,{size:18,center:!0,children:'greenside'===e?'No payment is taken for this request. Deposit terms to confirm. This is a request, not an instant confirmation.':'No deposit. No payment. This is a request, not an instant confirmation.'}),N?(0,k.jsx)(y.Banner,{kind:"info",title:'greenside'===e?'Request sent. A Greenside manager must confirm your table.':h?.enabled?'Request sent. The hotel will contact you to confirm.':'Request sent. The venue will contact you to confirm.',children:"Nothing has been charged. No email or text is sent by this app."}):(0,k.jsxs)(k.Fragment,{children:['table'===u?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(j,{label:"Date (DD/MM/YYYY)",testID:"request-date",...(0,s.slashBox)(f.date,e=>C({date:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,t.isQueuedVenue)(e)||'greenside'===e||q?null:(0,k.jsx)(y.Row,{wrap:!0,children:['Lunch','Dinner'].map(e=>(0,k.jsx)(y.Button,{testID:`request-service-${e.toLowerCase()}`,label:e+(f.service===e?' \xb7 selected':''),kind:f.service===e?'primary':'secondary',onPress:()=>C({service:e,time:'Lunch'===e?'12:00':'18:00'}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Time within kitchen hours"}),(0,k.jsx)(y.Row,{wrap:!0,children:((0,t.isQueuedVenue)(e)?(0,n.queuedRequestSlots)(e,f.date||'',T):q?(0,o.allDaySlots)(f.date||'',q):(0,r.slotsForVenue)(e,f.date||'',f.service||'Lunch')).map(e=>(0,k.jsx)(y.Button,{testID:`request-time-${e.replace(':','')}`,label:e+(f.time===e?' \xb7 selected':''),kind:f.time===e?'primary':'secondary',onPress:()=>C({time:e}),style:{alignSelf:'auto'}},e))}),(0,k.jsx)(j,{label:"Covers",testID:"request-covers",keyboardType:"number-pad",value:String(f.covers??''),onChangeText:e=>C({covers:Number(e)}),style:H})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(y.T,{size:18,center:!0,children:[null==h?.bedrooms?'':`${h.bedrooms} bedrooms. `,h?.priceNote,"."]}),(0,k.jsx)(j,{label:"Check-in date (DD/MM/YYYY)",testID:"request-check-in",...(0,s.slashBox)(f.checkIn,e=>C({checkIn:e})),placeholder:"20/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(j,{label:"Check-out date (DD/MM/YYYY)",testID:"request-check-out",...(0,s.slashBox)(f.checkOut,e=>C({checkOut:e})),placeholder:"21/11/2026",keyboardType:"numbers-and-punctuation",maxLength:10,style:H}),(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:"Room type"}),h?.roomTypes.map(e=>(0,k.jsx)(y.Button,{testID:`request-room-${e.id}`,label:`${e.name} \xb7 ${null==e.pricePence?'Price to confirm with the hotel':`${e.from?'from ':''}\xa3${e.pricePence/100}`} \xb7 ${h.breakfast}${f.roomType===e.id?' \xb7 selected':''}`,kind:f.roomType===e.id?'primary':'secondary',onPress:()=>C({roomType:e.id})},e.id)),(0,k.jsx)(j,{label:"Guests",testID:"request-guests",keyboardType:"number-pad",value:String(f.guests??''),onChangeText:e=>C({guests:Number(e)}),style:H}),(0,k.jsx)(y.Button,{testID:"request-add-dinner",label:"Add dinner \xb7 "+(f.addDinner?'Yes':'No'),kind:f.addDinner?'primary':'secondary',onPress:()=>C({addDinner:!f.addDinner})}),(0,k.jsx)(y.T,{size:18,center:!0,children:"The hotel will arrange dinner details with you."})]}),(0,k.jsx)(j,{label:"Name",testID:"request-name",autoComplete:"name",value:f.name,onChangeText:e=>C({name:e}),style:H}),(0,k.jsx)(j,{label:"Phone",testID:"request-phone",keyboardType:"phone-pad",autoComplete:"tel",value:f.phone,onChangeText:e=>C({phone:e}),style:H}),(0,k.jsx)(j,{label:"Email",testID:"request-email",keyboardType:"email-address",autoCapitalize:"none",autoComplete:"email",value:f.email,onChangeText:e=>C({email:e}),style:H}),(0,k.jsx)(j,{label:'table'===u?'Notes (allergies, occasion)':'Notes',testID:"request-notes",multiline:!0,maxLength:2e3,value:f.notes,onChangeText:e=>C({notes:e}),style:H}),(0,k.jsx)(c.default,{style:{display:'none'},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,k.jsx)(j,{label:"Leave this empty",value:w,onChangeText:B})}),P?(0,k.jsx)(j,{label:`Security check: ${P.question} = ?`,testID:"request-answer",keyboardType:"number-pad",value:I,onChangeText:S,style:H}):(0,k.jsx)(y.T,{size:18,center:!0,children:"Preparing security check\u2026"}),Y?(0,k.jsx)(y.Banner,{kind:"warn",title:"Please check your request",children:Y}):null,(0,k.jsx)(y.Button,{testID:"request-submit",label:L?'Sending request\u2026':'Send request',disabled:L||!P,onPress:()=>{F()}})]}),(0,k.jsx)(y.Button,{kind:"secondary",label:N?'greenside'===e?'Back to the restaurant':h?.enabled?'Back to the hotel':'Back to Customer home':'Back to Customer home',onPress:D})]})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),r=_r(d[3]),o=_r(d[4]),l=_r(d[5]),u=_r(d[6]),c=(e=u)&&e.__esModule?e:{default:e},h=_r(d[7]),y=_r(d[8]),p=_r(d[9]),b=_r(d[10]),x=_r(d[11]),k=_r(d[12]);function j({label:e,...t}){return(0,k.jsxs)(c.default,{style:{gap:6,alignSelf:'stretch',width:'100%'},children:[(0,k.jsx)(y.T,{size:18,weight:"semibold",center:!0,children:e}),(0,k.jsx)(h.TextInput,{accessibilityLabel:e,placeholderTextColor:p.colours.muted,...t,style:[{minHeight:48,fontSize:18,color:p.colours.text,backgroundColor:p.colours.surface2,borderWidth:1,borderColor:p.colours.border,borderRadius:12,padding:12},t.multiline?{minHeight:96,textAlignVertical:'top'}:null,t.style]})]})}},1268,[6,1063,1269,1270,1271,34,102,827,794,821,11,1272,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedSessions=o,e.queuedRequestSlots=u,e.queuedRequestError=function(t,o,s,a=new Date){if(o.name.trim().length<2||o.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(o.phone)||!/^[0-9]{7,15}$/.test(o.phone.replace(/\D/g,''))||o.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email))return'Enter your name, phone number and email.';if(o.notes.length>2e3)return'Keep notes under 2000 characters.';const c=(0,n.localDate)(a),d=(0,n.localDate)(new Date(+a+63072e6));if(!o.date||o.dated||!u(t,o.date,s).includes(o.time||''))return'Choose a future date and a time within confirmed kitchen service hours.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return o.date===c&&(o.time||'')<=l?'Choose a future time.':!Number.isInteger(o.covers)||o.covers<1||o.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]),n=r(_d[1]);function o(n){const o=t.queuedVenues[n];return o?.kitchenSessionsByDay??o?.hours.sessionsByDay??void 0}const s=t=>60*+t.slice(0,2)+ +t.slice(3);function u(n,u,a){if(!/^\d{4}-\d{2}-\d{2}$/.test(u))return[];const c=new Date(u+'T12:00:00Z');if(!Number.isFinite(+c)||c.toISOString().slice(0,10)!==u)return[];const d=(a??o(n))?.[c.getUTCDay()];if(!Array.isArray(d))return[];const l=[],f=t.queuedVenues[n]?.booking.lastSittingMinutesBeforeClose??0;for(const t of d){if(!Array.isArray(t)||2!==t.length||!t.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))continue;const n=s(t[0]),o=s(t[1]);if(!(n>=o))for(let t=n;t60*Number(t.slice(0,2))+Number(t.slice(3)),u=s(i[0]),l=s(i[1]);return Array.from({length:Math.floor((l-u)/15)+1},(t,n)=>{const o=u+15*n;return`${String(Math.floor(o/60)).padStart(2,'0')}:${String(o%60).padStart(2,'0')}`})}function i(t,i,s=new Date){if('table'!==t)return'Only table requests are available at this restaurant.';if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const u=(0,n.localDate)(s),l=(0,n.localDate)(new Date(+s+63072e6));if(!i.date||i.datel||!o(i.date).includes(i.time||''))return'Choose an open date and a time within kitchen hours. Closed Monday and Tuesday.';const d=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(s);return i.date===u&&(i.time||'')<=d?'Choose a future time within kitchen hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''}const s=(t,i,s)=>'greenside'===t?o(i):(0,n.requestSlots)(i,s),u=(t,o,s,u,l=new Date)=>'greenside'===t?i(o,s,l):(0,n.requestError)(o,s,u,l)},1270,[4,11]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allDaySlots=n,e.allDayRequestError=function(i,o,a=new Date){if(i.name.trim().length<2||i.name.trim().length>100||!/^[0-9 +()\-]{7,30}$/.test(i.phone)||!/^[0-9]{7,15}$/.test(i.phone.replace(/\D/g,''))||i.email.length>254||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i.email))return'Enter your name, phone number and email.';if(i.notes.length>2e3)return'Keep notes under 2000 characters.';const s=(0,t.localDate)(a),u=(0,t.localDate)(new Date(+a+63072e6));if(!i.date||i.dateu||!n(i.date,o).includes(i.time||''))return'Choose a future date and a time within the published hours, which are to confirm.';const l=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(a);return i.date===s&&(i.time||'')<=l?'Choose a future time within the published hours.':!Number.isInteger(i.covers)||i.covers<1||i.covers>200?'Enter 1 to 200 Covers.':''};var t=r(_d[0]);function n(t,n){if(!/^\d{4}-\d{2}-\d{2}$/.test(t))return[];const i=new Date(t+'T12:00:00Z');if(!Number.isFinite(+i)||i.toISOString().slice(0,10)!==t)return[];const o=n[i.getUTCDay()];if(!Array.isArray(o)||2!==o.length||!o.every(t=>'string'==typeof t&&/^([01]\d|2[0-3]):[0-5]\d$/.test(t)))return[];const a=t=>60*+t.slice(0,2)+ +t.slice(3),s=a(o[0]),u=a(o[1]);return!Number.isFinite(s)||!Number.isFinite(u)||s>u?[]:Array.from({length:Math.floor((u-s)/15)+1},(t,n)=>{const i=s+15*n;return`${String(Math.floor(i/60)).padStart(2,'0')}:${String(i%60).padStart(2,'0')}`})}},1271,[11]); +__d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.requestChallenge=async function(t,s){const{data:u,error:o}=await n().rpc('venue_request_challenge',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s});if(o)throw o;return u},_e.sendVenueRequest=async function(t,s,u,o,c,l){const{data:_,error:p}=await n().rpc('submit_venue_request',{p_slug:(0,e.queuedDatabaseSlug)(t),p_kind:s,p_payload:u,p_challenge:o,p_answer:c,p_website:l});if(p)throw p;return _},_e.listVenueRequests=async function(e,t){const{data:s,error:u}=await n().from('venue_booking_requests').select('*').eq('venue_id',e).eq('kind',t).order('status',{ascending:!1}).order('created_at',{ascending:!1}).limit(100);if(u)throw u;return s||[]},_e.decideVenueRequest=async function(e,t){const{data:s,error:u}=await n().rpc('decide_venue_request',{p_id:e,p_decision:t});if(u)throw u;return s},Object.defineProperty(_e,"requestMessage",{enumerable:!0,get:function(){return s}});var e=r(d[0]),t=r(d[1]);const n=()=>(0,t.getSupabase)();const s=e=>{const t=String(e?.message||'');return/^(Requests are not enabled|Too many|Please complete|Enter your|Choose |This request|Only this venue)/.test(t)?t:'Unable to send or load requests. Check your connection and try again, or call the hotel.'}},1272,[6,933]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.QueuedMenus=function({menu:c,context:o,allergens:a}){const u=c,f=(0,n.useMemo)(()=>t(c),[c]),[p,b]=(0,n.useState)(null);return(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.H2,{children:"Published menus"}),(0,s.jsx)(i.Banner,{kind:"warn",title:"Menu \u2014 to confirm",children:"Published reference only. Current prices, availability and allergens need confirmation. Items cannot be ordered here."}),o?(0,s.jsx)(i.Muted,{children:o}):null,a?(0,s.jsx)(i.Muted,{children:a}):(0,s.jsx)(i.Muted,{children:"Ask the restaurant about every allergy. Published dietary labels are not an allergen guarantee."}),u.offers?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:["Published offer \u2014 ",n.name,'number'==typeof n.priceGbp?` \xb7 \xa3${n.priceGbp.toFixed(2)}`:'',": ",n.when||'Terms to confirm',". To confirm."]},'offer'+t)),u.buffetSessionPrices?.sessions?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.label,": \xa3",n.price.toFixed(2)," \xb7 to confirm"]},'session'+t)),u.buffetSessionPrices?.kids?(0,s.jsxs)(i.Muted,{children:["Published children\u2019s prices \u2014 ",u.buffetSessionPrices.kids,". To confirm."]}):null,f.map((n,t)=>(0,s.jsx)(i.Button,{kind:"secondary",label:n.name+(p===t?' \xb7 selected':''),onPress:()=>b(p===t?null:t)},t)),null!==p?f[p]?.items.map((n,t)=>(0,s.jsxs)(i.Card,{children:[(0,s.jsx)(i.T,{weight:"bold",children:n.name||n.label||'Published item'}),(0,s.jsx)(i.T,{children:l(n)}),n.description||n.desc?(0,s.jsx)(i.Muted,{children:n.description||n.desc}):null,n.options?.map((n,t)=>(0,s.jsxs)(i.Muted,{children:[n.name||n.label,": ",l(n)]},t))]},t)):null]})};var n=r(d[0]),i=r(d[1]),s=r(d[2]);function t(n,i=""){if(Array.isArray(n))return n.flatMap(n=>t(n,i));if(!n||'object'!=typeof n)return[];const s=n,l='string'==typeof s.name?s.name:'string'==typeof s.label?s.label:i;return(Array.isArray(s.items)?[{name:[i,l].filter((n,i,s)=>n&&s.indexOf(n)===i).join(' \xb7 ')||'Published menu',items:s.items}]:[]).concat(Object.entries(s).filter(([n])=>'items'!==n&&'options'!==n).flatMap(([,n])=>t(n,l||i)))}const l=n=>'included_in_buffet'===n.priceType?'Included in buffet \xb7 session price to confirm':n.priceLabel||('number'==typeof(n.priceGbp??n.price)?`\xa3${(n.priceGbp??n.price).toFixed(2)}`:'Price to confirm')},1273,[34,794,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedCustomerHome",{enumerable:!0,get:function(){return t}});const t=null},1274,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.HotelRequestGate=function({rid:e,hotel:l,children:c}){const[h,f]=(0,t.useState)(!1);return l?.enabled?(0,u.jsxs)(o.default,{style:{flex:1},children:[c,(0,u.jsx)(o.default,{style:{padding:12},children:(0,u.jsx)(s.Button,{label:"Book a room",onPress:()=>f(!0)})}),(0,u.jsx)(s.Sheet,{visible:h,onClose:()=>f(!1),title:"Room request",children:(0,u.jsx)(n.VenueRequestForm,{rid:e,kind:"room",hotel:l,onClose:()=>f(!1)})})]}):(0,u.jsx)(u.Fragment,{children:c})};var e,t=r(d[0]),l=r(d[1]),o=(e=l)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),u=r(d[4])},1275,[34,102,794,1268,25]); +__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 x}});var e,n=r(d[0]),s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},o=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),h=r(d[6]),b=r(d[7]),j=r(d[8]);function x(){const[e,s]=(0,n.useState)(!1),[x,p]=(0,n.useState)(null);return(0,n.useEffect)(()=>{if(!e)return;let n=!0;return p(null),(0,o.getSupabase)().rpc('greenside_request_setup_ready').then(({data:e,error:s})=>{n&&p(!s&&!0===e)},()=>{n&&p(!1)}),()=>{n=!1}},[e]),(0,j.jsxs)(l.Screen,{title:b.GREENSIDE_RESTAURANT.name,back:!1,children:[(0,j.jsx)(u.RestaurantHero,{rid:"greenside",size:240}),e?!0===x?(0,j.jsx)(h.VenueRequestForm,{rid:"greenside",kind:"table",onClose:()=>s(!1)}):(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:null===x?'Checking booking setup\u2026':'Manager setup needed'}),(0,j.jsx)(l.Muted,{children:null===x?'Checking whether table requests are ready.':'An authorised manager must complete setup before table requests can be sent. Please call 01655 889685.'}),(0,j.jsx)(l.Button,{label:"Call 01655 889685",kind:"secondary",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}}),(0,j.jsx)(l.Button,{label:"Back to Customer home",kind:"secondary",onPress:()=>s(!1)})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(l.T,{center:!0,children:"Bar, restaurant and wood-fired pizza"}),(0,j.jsxs)(l.Row,{wrap:!0,children:[(0,j.jsx)(l.Button,{testID:"greenside-book-table",label:"Book a table",onPress:()=>s(!0)}),(0,j.jsx)(l.Button,{testID:"greenside-book-phone",kind:"secondary",label:"Call 01655 889685",onPress:()=>{t.default.openURL(b.GREENSIDE_BOOKING_PHONE)}})]}),(0,j.jsx)(l.Muted,{children:"Send a table request for a Greenside manager to confirm. This is not an instant booking. No deposit, payment, email or text is taken or sent by this app."}),(0,j.jsxs)(l.Card,{children:[(0,j.jsx)(l.H2,{children:"Kitchen hours"}),(0,j.jsx)(l.T,{children:"Wednesday, Thursday and Sunday: 10:00\u201320:00"}),(0,j.jsx)(l.T,{children:"Friday and Saturday: 10:00\u201321:00"}),(0,j.jsx)(l.T,{children:"Closed Monday and Tuesday"}),(0,j.jsx)(l.H2,{children:"Venue hours"}),(0,j.jsx)(l.T,{children:"Wednesday and Thursday: 10:00\u201323:00"}),(0,j.jsx)(l.T,{children:"Friday to Sunday: 10:00\u201300:00"}),(0,j.jsx)(l.T,{children:"Cash only"})]}),(0,j.jsx)(c.FindPub,{rid:"greenside"}),(0,j.jsx)(l.Banner,{kind:"warn",title:"Menus \u2014 unconfirmed",children:"The published menus, prices, availability and allergens need confirmation. Ask the restaurant about every allergy. No menu items are available to order here."}),(0,j.jsx)(l.Muted,{children:"Deposit policy needs confirmation. Deposits are off. The public email address needs confirmation."}),(0,j.jsx)(l.Button,{kind:"secondary",label:"View published menus on our website",onPress:()=>{t.default.openURL('https://thegreensiderestaurant.co.uk/menus/')}})]})]})}},1276,[34,379,933,794,873,1266,1268,4,25]); +__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 j}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]),s=r(d[3]),c=r(d[4]),u=r(d[5]),h=r(d[6]),b=r(d[7]),f=r(d[8]);function j(){const[e,t]=(0,o.useState)(null);return(0,f.jsxs)(l.Screen,{title:"The Abbotsford Hotel",back:!1,children:[(0,f.jsx)(c.RestaurantHero,{rid:"abbotsford",size:240}),(0,f.jsx)(l.T,{center:!0,children:"Epicurious restaurant \xb7 The Copper Bar"}),(0,f.jsx)(l.T,{children:"14 Corsehill Road, Ayr KA7 2ST"}),(0,f.jsx)(l.T,{children:"Daily 10:00\u201320:30 \u2014 to confirm. Copper Bar hours to confirm."}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Book with the hotel"}),(0,f.jsx)(l.T,{children:"Table and room requests go to the hotel managers to confirm. They are not instant bookings or a guarantee of availability. No payment or deposit."}),(0,f.jsx)(l.Button,{label:"Book a table",onPress:()=>t('table')}),(0,f.jsx)(l.Button,{label:"Book a room",onPress:()=>t('room')}),(0,f.jsx)(l.Muted,{children:"Rooms: Prices to confirm with the hotel. Room details and inclusions need confirmation."})]}),(0,f.jsx)(b.AbbotsfordMenus,{}),(0,f.jsx)(s.FindPub,{rid:"abbotsford"}),(0,f.jsxs)(l.Card,{children:[(0,f.jsx)(l.H2,{children:"Contact the hotel"}),(0,f.jsx)(l.Button,{kind:"secondary",label:"Call 01292 261506",onPress:()=>{n.default.openURL('tel:01292261506')}}),(0,f.jsx)(l.T,{children:"info@abbotsfordhotel.co.uk"})]}),(0,f.jsx)(l.Banner,{kind:"info",title:"Details to confirm",children:"Covers and table plan, deposit, Copper Bar hours, dog policy and allergens are still to confirm."}),(0,f.jsx)(l.Sheet,{visible:!!e,onClose:()=>t(null),title:'room'===e?'Book a room':'Book a table',children:e?(0,f.jsx)(u.NativeRequestSetup,{rid:"abbotsford",kind:e,hotel:h.ABBOTSFORD_HOTEL,allDayHours:h.ABBOTSFORD_HOURS,onClose:()=>t(null)}):null})]})}},1277,[34,379,794,1266,873,1267,8,1278,25]); +__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.AbbotsfordMenus=function(){const[e,t]=(0,n.useState)(null),h=o.find(n=>n.id===e);return(0,c.jsxs)(s.default,{testID:"abbotsford-menus",style:{gap:12},children:[(0,c.jsxs)(l.Card,{children:[(0,c.jsx)(l.H2,{children:"Menus"}),(0,c.jsx)(l.T,{children:"Published menus for reference. Confirm availability, current prices and allergens with the team. No ordering is available here."}),(0,c.jsx)(l.T,{children:"Allergens: please speak to staff. Published dietary marks are not a complete allergen check."}),o.map(n=>(0,c.jsx)(l.Button,{kind:n.id===e?'primary':'secondary',label:`${n.name}${n.id===e?' \xb7 selected':''}`,onPress:()=>t(n.id)},n.id))]}),h?(0,c.jsxs)(s.default,{style:{gap:12},children:[(0,c.jsx)(l.H2,{children:h.name}),h.when?(0,c.jsx)(l.Muted,{children:h.when}):null,h.note?(0,c.jsx)(l.T,{children:h.note}):null,h.categories.map((e,n)=>(0,c.jsxs)(s.default,{style:{gap:10},children:[(0,c.jsx)(l.H2,{children:e.name}),e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.items.map((e,n)=>(0,c.jsx)(l.Card,{children:(0,c.jsxs)(s.default,{style:{gap:8},children:[(0,c.jsxs)(l.Row,{wrap:!0,children:[(0,c.jsx)(l.T,{size:18,weight:"semibold",style:{flex:1},children:e.name}),(0,c.jsx)(l.T,{children:'number'==typeof e.price?u(e.price):'Price to confirm'})]}),e.description?(0,c.jsx)(l.T,{children:e.description}):null,e.note?(0,c.jsx)(l.T,{children:e.note}):null,e.priceOptions?.length?(0,c.jsxs)(l.T,{children:["Published price options: ",e.priceOptions.map(u).join(' / ')]}):null,'number'==typeof e.sharedPrice?(0,c.jsxs)(l.T,{children:["Published group price: ",u(e.sharedPrice)," \u2014 confirm with staff"]}):null,e.dietary?.length?(0,c.jsxs)(l.Muted,{children:["Published marks: ",e.dietary.join(', '),". Ask staff about allergens."]}):null]})},n))]},n))]}):null]})};var n=r(d[0]),s=e(r(d[1])),l=r(d[2]),t=e(r(d[3])),c=r(d[4]);const o=t.default.menus,u=e=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(e)},1278,[34,102,794,1279,25]); +__d(function(e,i,a,r,n,t,o){n.exports={currency:"GBP",note:"Parsed with pdftotext. Do not invent dishes. Menus subject to change. Dietary codes from a la carte: GF, GFA, V, VV.",menus:[{id:"breakfast",name:"Breakfast \u2014 Morning Edition",when:"Breakfast service; Morning Deals Monday\u2013Friday",sourcePdf:"raw/menu-breakfast.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/10/Abbotsford-Breakfast-Menu-1.pdf",categories:[{name:"Morning Deals (Monday\u2013Friday)",items:[{name:"Rolling Report",description:"Morning roll with choice of 2 fillings: Ayrshire Bacon, Pork Link Sausage, Potato Scone or Egg, plus filter tea or coffee",price:6.5,dietary:[]},{name:"The Full Feature",description:"The Abbotsford Breakfast plus fruit juice and filter tea or coffee",price:15,dietary:[]}]},{name:"The Epicurious Express",items:[{name:"The Abbotsford Breakfast",description:"Ayrshire bacon, link sausage, black pudding, haggis, potato scone, beans, tomato, mushrooms and two eggs (poached, scrambled or fried) with white or wholemeal toasted bloomer",price:11.95,dietary:[]},{name:"Light Breakfast",description:"Ayrshire bacon, link sausage, beans, tomato and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:[]},{name:"Vegetarian Breakfast",description:"Potato scone, tomato, mushrooms, beans and two eggs with white or wholemeal toasted bloomer",price:9.5,dietary:["V"]},{name:"Breakfast Roll",description:"Choice of Ayrshire bacon, pork link sausage, potato scone or egg; 2 items 4.50 | 3 items 5.50",price:3.95,dietary:[]},{name:"Eggs Benedict",description:"Two poached eggs with Ayrshire bacon on toasted muffin, hollandaise",price:10.95,dietary:[]},{name:"Eggs Royale",description:"Two poached eggs with flaked smoked salmon on toasted muffin, hollandaise",price:11.45,dietary:[]},{name:"Smashed Avocado Benedict",description:"Smashed avocado guacamole, two poached eggs on toasted muffin, hollandaise",price:10.95,dietary:["V"]},{name:"Pancake Stack",description:"American-style pancakes with Biscoff, Nutella, chocolate sauce and fresh strawberries",price:9.95,dietary:["V"]},{name:"French Toast",description:"Two slices of bloomer eggy bread with Ayrshire bacon and maple syrup",price:10.95,dietary:[]},{name:"The Morning Stack",description:"American-style pancakes with Ayrshire bacon and maple syrup; add two eggs 2.00",price:9.95,dietary:[]},{name:"Granola Bowl",description:"Almond and raisin granola topped with berries, natural yoghurt and honey",price:8.95,dietary:["V"]},{name:"Brunch \xc0 La Tina",description:"Wholemeal toasted bloomer, smashed avocado, grilled Bonnet goats cheese, smoked salmon, fried free-range egg and balsamic glaze",price:12.5,dietary:[]}]},{name:"Little Legends Ledger (Kids)",items:[{name:"Kids Breakfast",description:"Pork link sausage, beans, potato scone, slice of toast",price:5.95,dietary:[]},{name:"Kids Pancakes",description:"American-style pancakes with syrup, Nutella or butter and jam; add banana or strawberries 1.50",price:5.95,dietary:[]}]},{name:"Extras Desk",items:[{name:"Black Pudding",description:null,price:1.5,dietary:[]},{name:"Pork Link Sausage",description:null,price:1.5,dietary:[]},{name:"Ayrshire Bacon (2)",description:null,price:1.5,dietary:[]},{name:"Smashed Avocado",description:null,price:2,dietary:[]},{name:"Haggis",description:null,price:1.5,dietary:[]},{name:"Mushrooms",description:null,price:1.5,dietary:[]},{name:"Beans",description:null,price:1,dietary:[]},{name:"Tomato",description:null,price:1,dietary:[]},{name:"Egg",description:null,price:1,dietary:[]},{name:"Potato Scone",description:null,price:1,dietary:[]},{name:"Bucket of Chips",description:null,price:4.25,dietary:[]},{name:"Toasted White or Wholemeal Bread",description:"Served with butter and preserve",price:4.5,dietary:[]}]},{name:"Treat Tales",items:[{name:"Scone with butter, jam and hot drink",description:"9am\u201312noon offer",price:4.5,dietary:[]},{name:"Scones, Traybakes and Cakes",description:"From 2.50, available all day",price:2.5,dietary:[],note:"Price 'from' as printed"}]},{name:"Coffee",items:[{name:"Latte",description:null,price:3.75,dietary:[]},{name:"Espresso",description:null,price:3.25,dietary:[]},{name:"Cappuccino",description:null,price:3.75,dietary:[]},{name:"Americano",description:null,price:3.5,dietary:[]},{name:"Double Espresso",description:null,price:3.75,dietary:[]},{name:"Macchiato",description:null,price:3.75,dietary:[]},{name:"Espresso Con Panna",description:null,price:3.75,dietary:[]},{name:"Flavour Shot",description:null,price:.75,dietary:[]},{name:"Extra Shot of Coffee",description:null,price:.75,dietary:[]}]},{name:"Tea and Hot Chocolate",items:[{name:"Breakfast Tea",description:null,price:3.5,dietary:[]},{name:"Camomile Tea",description:null,price:3.5,dietary:[]},{name:"Earl Grey Tea",description:null,price:3.5,dietary:[]},{name:"Green Tea",description:null,price:3.5,dietary:[]},{name:"Peppermint Tea",description:null,price:3.5,dietary:[]},{name:"Red Berry Tea",description:null,price:3.5,dietary:[]},{name:"Lemon and Ginger Tea",description:null,price:3.5,dietary:[]},{name:"Hot Chocolate",description:null,price:3.95,dietary:[]},{name:"Luxury Hot Chocolate",description:"With cream and marshmallows",price:4.95,dietary:[]}]}]},{id:"alacarte",name:"\xc0 La Carte \u2014 Epicurious",when:"Sept 2026 menu; sandwiches 12noon\u20134pm",sourcePdf:"raw/menu-alacarte.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/09/Sept-2026-NEW-Menu-Abbotsford-A-La-Carte.pdf",categories:[{name:"The Birch Wine Board",items:[{name:"The Birch Wine Board",description:"Charred halloumi, roasted cauliflower, cured meats, chicken liver parfait, chutney, Scottish cheese, pickled onions, gherkins and fresh seasonal vegetables",price:19.95,dietary:[]}]},{name:"Starters",items:[{name:"Haggis Scotch Egg",description:"Smoked turnip veloute, Arran mustard and crispy leeks",price:10.95,dietary:[]},{name:"Traditional Cullen Skink",description:"With crusty ciabatta bread",price:10.95,dietary:["GFA"]},{name:"Chef's Soup of the Day",description:"With freshly baked bread",price:6.5,dietary:["GFA","VV"]},{name:"Moules Marini\xe8re",description:"Shetland mussels, white wine and garlic cream with garlic ciabatta",price:12.95,dietary:["GFA"]},{name:"Chicken Liver and Brandy Parfait",description:"Red onion chutney and bannocks",price:9.5,dietary:["GFA"]},{name:"Sweet Chilli and Soy Glazed Pork Belly Bites",description:"Chilli mint yogurt and pickled cucumber ribbons",price:10.5,dietary:["GFA"]},{name:"Fruit Platter",description:"Duo of melon, seasonal berries, passionfruit sorbet and raspberry coulis",price:9.95,dietary:["GF","VV"]}]},{name:"Sandwiches",note:"Served 12noon\u20134pm. White or malted bloomer with tortilla chips, house salad and coleslaw. GF on request. Add soup 3.95 | chips 4.50",items:[{name:"Tuna Mayonnaise",description:null,price:10.95,dietary:[]},{name:"Ploughman's",description:null,price:11.95,dietary:[]},{name:"Coronation Chicken",description:null,price:10.95,dietary:[]},{name:"Chicken and Bacon Club",description:null,price:12.95,dietary:[]}]},{name:"Burgers",note:"Toasted brioche, house slaw and hand-cut chips",items:[{name:"6oz Homemade Abbotsford Burger",description:"Burger sauce, pickles, tomato and baby gem; add cheese/blue cheese/bacon 1.50",price:16.95,dietary:[]},{name:"Abbotsford Spiced Buttermilk Chicken Burger",description:"BBQ pulled beef, garlic mayonnaise, pickles, tomato and baby gem",price:18.95,dietary:[]},{name:"The Burns Burger",description:"6oz Scotch beef, haggis, tattie scone, smoked Arran cheddar and peppercorn sauce",price:18.95,dietary:[]},{name:"Moving Mountains Burger",description:"Plant-based patty, lettuce, tomato, red onion and vegan garlic mayonnaise",price:16.95,dietary:["VV"]}]},{name:"From the Grill",note:"Flat-cap mushrooms, grilled plum tomato, fries and onion rings (GFA). Sauce 2.50: peppercorn | garlic butter | red wine jus",items:[{name:"8 oz Fillet Steak",description:null,price:38.95,dietary:["GFA"]},{name:"10 oz Sirloin Steak",description:null,price:35.95,dietary:["GFA"]}]},{name:"Mains",items:[{name:"Cajun Spiced Breast of Chicken",description:"Rice pilaf, proven\xe7al vegetables, coconut curry cream and spiced onions",price:null,dietary:["GFA"],note:"Printed 14.50 // 18.50",priceOptions:[14.5,18.5]},{name:"Confit Pork Belly",description:"Chorizo creamed potatoes, black pudding bon bons, beer-braised onion and mustard jus",price:21.95,dietary:[]},{name:"Individual Steak and Ale Pie",description:"Creamed potatoes, roasted carrot, tenderstem broccoli and red wine jus",price:19.95,dietary:[]},{name:"Trio of Seafood",description:"Chef's catch of the day, potato fondant, buttered greens and white wine chive cream",price:23.95,dietary:["GF"]},{name:"Beer Battered Haddock",description:"Pickled onion, mushy peas, tartare, fries and lemon",price:null,dietary:["GFA"],note:"Printed 13.45 // 18.50",priceOptions:[13.45,18.5]},{name:"Wild Mushroom Stroganoff",description:"Pilaf rice and tempura gherkins",price:null,dietary:["V"],note:"Printed 13.95 // 17.95",priceOptions:[13.95,17.95]}]},{name:"Sides",note:"All sides vegetarian; ask for GF",items:[{name:"Onion Rings",description:null,price:4,dietary:["V"]},{name:"House Slaw",description:null,price:4,dietary:["V"]},{name:"Creamed Potatoes",description:null,price:5,dietary:["V"]},{name:"House Salad",description:null,price:4,dietary:["V"]},{name:"Hand Cut Chips",description:null,price:4.5,dietary:["V"]},{name:"Sweet Potato Wedges",description:null,price:5.25,dietary:["V"]},{name:"Chilli and Parmesan Hand Cut Chips",description:null,price:5.25,dietary:["V"]}]},{name:"Desserts",items:[{name:"Sticky Toffee Pudding",description:"Butterscotch sauce and vanilla ice cream",price:8.95,dietary:["V","GF"]},{name:"Passionfruit Martini Panna Cotta",description:"Passionfruit syrup and prosecco sorbet",price:9.95,dietary:["GF"]},{name:"Warm Orange Scented Rice Pudding",description:"Ginger biscuit crumb",price:8.95,dietary:["VV","GF"]},{name:"Cheesecake of the Day",description:"With vanilla ice cream and fresh fruit garnish",price:9.95,dietary:["V"]},{name:"Traditional Tiramisu",description:"Coffee sponge fingers, amaretto mascarpone and dark chocolate powder",price:9.95,dietary:["V"]},{name:"Trio of Scottish Cheeses",description:"Cheese, fig chutney, biscuits and grapes",price:10.95,dietary:["GFA"]}]},{name:"Notes",items:[{name:"Chef's Daily Specials",description:"Ask your server",price:null,dietary:[]},{name:"The Ultimate Sunday Roast",description:"Every Sunday until stock runs out",price:null,dietary:[]}]}]},{id:"kids",name:"Kids \u2014 Abby's Favourites",when:null,sourcePdf:"raw/menu-kids.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/02/NEW-Menu-Abbotsford-Kids-Menu.pdf",categories:[{name:"Wee Lamb \xb7 Starters (\xa33)",items:[{name:"Garlic Bread",description:null,price:3,dietary:[]},{name:"Soup of the Day",description:null,price:3,dietary:[]}]},{name:"Rowan Pony \xb7 Mains (\xa37)",note:"Add bacon \xa31 | add cheese \xa31",items:[{name:"Chicken Goujons and Chips",description:null,price:7,dietary:[]},{name:"Cheesy Pasta and Garlic Bread",description:null,price:7,dietary:[]},{name:"Haddock and Chips",description:null,price:7,dietary:[]},{name:"3oz Beef Burger and Chips",description:null,price:7,dietary:[]}]},{name:"Scottie Dog \xb7 Treats (\xa33)",items:[{name:"Sticky Toffee Pudding",description:null,price:3,dietary:[]},{name:"Two Scoops of Ice Cream",description:null,price:3,dietary:[]}]}]},{id:"taco-tuesday",name:"Taco Tuesday",when:"Tuesdays",sourcePdf:"raw/menu-taco-tuesday.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/Taco-Tuesday-Menu-The-Abbotsford.pdf",categories:[{name:"Tacos",note:"Salad, pickled red onion, pico de gallo, fresh lime. Single \xa35 / Double \xa310",items:[{name:"Crispy Fried Chicken",description:"Sriracha mayo",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Beef Birria and Cheese",description:"Birria dip",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Breaded Haddock",description:"Tartare sauce",price:null,dietary:[],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]},{name:"Sweet Potato and Chickpea Falafel",description:"Sriracha mayo",price:null,dietary:["V"],note:"Single 5.00 / Double 10.00",priceOptions:[5,10]}]},{name:"Sides and Extras",items:[{name:"Nachos",description:"Guacamole, pico de gallo, sour cream and cheese",price:5,dietary:[]},{name:"Onion Rings",description:null,price:4,dietary:[]},{name:"Fries",description:null,price:4,dietary:[]},{name:"House Slaw",description:null,price:4,dietary:[]},{name:"Mexican Black Bean and Rice",description:null,price:4,dietary:[]},{name:"Chargrilled Cob",description:null,price:null,dietary:[],note:"Single \xa32 / Double \xa34",priceOptions:[2,4]}]},{name:"Cocktails",items:[{name:"Classic Margarita",description:"Or Spicy | Mango | Passionfruit",price:9.95,dietary:[]}]}]},{id:"bar-bites",name:"Bar Bites",when:"The Copper Bar",sourcePdf:"raw/menu-bar-bites.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Bar-Bites.pdf",categories:[{name:"Small Plates (\xa35)",items:[{name:"Ham Hough, Confit Chicken and Apricot Croquette",description:null,price:5,dietary:[]},{name:"Sriracha and Maple Glazed Chicken Goujons",description:null,price:5,dietary:[]},{name:"Goats Cheese, Caramelised Onion and Truffle Oil Arancini",description:null,price:5,dietary:["V"]},{name:"Homemade Sausage Roll",description:"Whole grain mustard, Arran cheddar, apple and walnut ketchup",price:5,dietary:[]}]},{name:"Loaded Fries (\xa38.95)",items:[{name:"Cajun Chicken Loaded Fries",description:"Cajun fries, diced cajun chicken, peppers, onions, cheddar and sriracha mayo",price:8.95,dietary:[]},{name:"Locally Caught Haggis Loaded Fries",description:"Seasoned fries, haggis, cheese and peppercorn sauce",price:8.95,dietary:[]}]},{name:"Sharing Plates",items:[{name:"Nice to Meat You",description:"Cold meats, olives and sun-dried tomatoes",price:10,dietary:[]},{name:"Say Cheese",description:"Scottish cheeses, quince jelly, chutney and oatcakes",price:10,dietary:[]},{name:"Sharing is Caring",description:"Nice to Meat You and Say Cheese combo",price:18,dietary:[]}]}]},{id:"drinks",name:"Drinks \u2014 Social Pours",when:null,sourcePdf:"raw/menu-drinks.pdf",sourceUrl:"https://www.abbotsfordhotel.co.uk/wp-content/uploads/2026/08/The-Abbotsford-Drinks-Menu.pdf",note:"Some cocktail groups share one printed price on the PDF.",categories:[{name:"The Classics",note:"Shared price line 9.95",items:[{name:"Daiquiri",description:"White rum, lime and sugar syrup; Strawberry, Passionfruit or Mango",price:null,dietary:[],sharedPrice:9.95},{name:"Old Fashioned",description:"Bourbon, sugar syrup and orange bitters",price:null,dietary:[],sharedPrice:9.95},{name:"Whisky Sour",description:"Whisky, lemon, sugar syrup, Angostura and egg white",price:null,dietary:[],sharedPrice:9.95},{name:"Margarita",description:"Tequila, lime, sugar syrup and triple sec",price:null,dietary:[],sharedPrice:9.95},{name:"Cosmopolitan",description:"Heroes vodka, cranberry, lime, triple sec and sugar syrup",price:9.95,dietary:[]}]},{name:"Martini Style",items:[{name:"Pornstar Martini",description:"Vanilla vodka, passionfruit, Passoa and pineapple",price:null,dietary:[],sharedPrice:10.95},{name:"French Martini",description:"Heroes vodka, pineapple and Chambord",price:null,dietary:[],sharedPrice:10.95},{name:"Espresso Martini",description:"Heroes vodka, coffee liqueur, sugar syrup and espresso",price:10.95,dietary:[]}]},{name:"That's the Spritz",note:"Shared price 9.95",items:[{name:"Aperol Spritz",description:"Aperol, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Hugo Spritz",description:"Elderflower liqueur, prosecco and soda",price:null,dietary:[],sharedPrice:9.95},{name:"Limoncello Spritz",description:"Limoncello, prosecco and lemonade",price:null,dietary:[],sharedPrice:9.95},{name:"Pink Gin Spritz",description:"Pink gin, prosecco and lemonade",price:9.95,dietary:[]}]},{name:"Hangover Free (Mocktails)",note:"Shared price 6.95",items:[{name:"Abbotsford Sunset",description:"Tanqueray Flor De Sevilla 0%, orange, lemon, grenadine and lemonade",price:null,dietary:[],sharedPrice:6.95},{name:"Mixed Berry Fizz",description:"Whitley Neill Raspberry 0%, lemon and soda",price:null,dietary:[],sharedPrice:6.95},{name:"Not So Mojito",description:"Apple juice, lime, sugar syrup, mint and soda",price:6.95,dietary:[]}]},{name:"Wine by the Glass \u2014 White",items:[{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}},{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:null,dietary:[],glass:{"175ml":9.95,"250ml":11.95}}]},{name:"Wine by the Glass \u2014 Rose",items:[{name:"La Maglia Rosa Pinot Grigio Blush, Pavia, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Whispering Hills Zinfandel Rose, California, USA",description:null,price:null,dietary:[],glass:{"175ml":6.5,"250ml":8.5}}]},{name:"Wine by the Glass \u2014 Red",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:null,dietary:[],glass:{"175ml":6.95,"250ml":8.95}},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:null,dietary:[],glass:{"175ml":7.95,"250ml":10.5}},{name:"Fico Grande Sangiovese, Italy",description:null,price:null,dietary:[],glass:{"175ml":7.5,"250ml":10}},{name:"Alma Mora Malbec, San Juan, Argentina",description:null,price:null,dietary:[],glass:{"175ml":8.95,"250ml":10.95}}]},{name:"Cellar Table \u2014 White (bottle)",items:[{name:"Petal and Stem Sauvignon Blanc, Marlborough, New Zealand",description:null,price:29.95,dietary:[]},{name:"Berri Estates Chardonnay, South Eastern Australia",description:null,price:24.95,dietary:[]},{name:"Grave del Friuli Pinot Grigio, Fantinel, Italy",description:null,price:29.95,dietary:[]},{name:"Mas Puech Picpoul de Pinet, France",description:null,price:29.95,dietary:[]},{name:"Monte di Sarocco Gavi, Italy",description:null,price:34.95,dietary:[]},{name:"Leiras Albarino, Rias Baixas, Spain",description:null,price:35.95,dietary:[]},{name:"Chateau Ste Michelle Chardonnay, Washington State, USA",description:null,price:47.95,dietary:[]},{name:"Louis Jadot Macon-Villages, France",description:null,price:60,dietary:[]}]},{name:"Cellar Table \u2014 Red (bottle)",items:[{name:"Berri Estates Shiraz, South Eastern Australia",description:null,price:25.95,dietary:[]},{name:"La Campagne Merlot, Pays d'Oc, France",description:null,price:30.95,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Zensa Primitivo Salento, Italy",description:null,price:30.95,dietary:[]},{name:"Chateauneuf-du-Pape, France",description:null,price:74.95,dietary:[]},{name:"Louis Jadot Pinot Noir, France",description:null,price:42,dietary:[]},{name:"Vina Pomal Reserva Centenario, Spain",description:null,price:55,dietary:[]}]},{name:"Cellar Table \u2014 Rose (bottle)",items:[{name:"Coteaux Varois en Provence Rose, Estandon, France",description:null,price:55,dietary:[]},{name:"La Maglia Rosa Pinot Grigio Blush, Italy",description:null,price:29.95,dietary:[]},{name:"Whispering Hills Zinfandel, USA",description:null,price:24.95,dietary:[]}]},{name:"Sparkling and Champagne",items:[{name:"Oliver and Greg's Prosecco Brut, Italy",description:null,price:29.95,dietary:[],note:"200ml 8.95 | Bottle 29.95",glass:{"200ml":8.95}},{name:"Bottega Gold Prosecco Brut, Italy",description:null,price:40,dietary:[]},{name:"Veuve Clicquot Yellow Label, France",description:null,price:89,dietary:[]},{name:"Veuve Clicquot Rose, France",description:null,price:99,dietary:[]}]},{name:"Abbotsford Top Picks",items:[{name:"Sancerre, Domaine des Chaintres, France",description:null,price:70,dietary:[]},{name:"Peth Wetz Riesling, Germany",description:null,price:55,dietary:[]},{name:"Fico Grande Sangiovese, Italy",description:null,price:29.95,dietary:[]},{name:"Valpolicella Classico Superiore Ripasso, Italy",description:null,price:65,dietary:[]},{name:"Chateau Ste. Michelle Cabernet Sauvignon, USA",description:null,price:60,dietary:[]},{name:"Chateau Grand Jauga Sauternes, France",description:null,price:40,dietary:[],note:"Dessert wine"}]}]}]}},1279,[]); +__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 k}});var n=r(d[0]),t=r(d[1]),o=r(d[2]),s=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=r(d[7]);function k(){const[k,j]=(0,n.useState)(!1),p=(0,c.useRestaurant)('kirkton')??u.KIRKTON_RESTAURANT;return(0,h.jsxs)(t.Screen,{title:p.name,back:!1,children:[(0,h.jsx)(o.RestaurantHero,{rid:"kirkton",size:240}),(0,h.jsx)(t.T,{center:!0,children:"Bar and restaurant in Dalrymple"}),k?(0,h.jsx)(l.NativeRequestSetup,{rid:"kirkton",kind:"table",allDayHours:p.kitchenHours,onClose:()=>j(!1)}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Book a table"}),(0,h.jsx)(t.Button,{testID:"kirkton-book-table",label:"Book a table",onPress:()=>j(!0)}),(0,h.jsx)(t.T,{children:"Send a table request for the venue managers to confirm once setup is complete. This is not an instant booking."}),(0,h.jsx)(t.Muted,{children:"No deposit, payment, email or text is taken or sent by this app."})]}),(0,h.jsxs)(t.Card,{children:[(0,h.jsx)(t.H2,{children:"Venue setup in progress"}),(0,h.jsx)(t.T,{children:"Contact phone: to confirm"}),(0,h.jsx)(t.T,{children:"Opening and kitchen hours: to confirm"}),(0,h.jsx)(t.T,{children:"Table plan and Covers: to confirm"}),(0,h.jsx)(t.T,{children:"Takeaway: to confirm"}),(0,h.jsx)(t.Muted,{children:"Table requests need an authorised manager and confirmed kitchen hours. Orders and payments are not enabled. Deposit policy needs confirmation; deposits are off."})]}),(0,h.jsx)(s.FindPub,{rid:"kirkton"}),(0,h.jsx)(t.Banner,{kind:"warn",title:"Menus \u2014 provisional and unconfirmed",children:"The available menu records are archived from 2019. They are not current prices, availability or allergen information. No menu items are available to order here."})]})]})}},1280,[34,794,873,1266,1267,874,9,25]); +__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 b}}),_e.LauncherLine=function(){return(0,u.jsx)(t.default,{style:{borderTopWidth:1,borderColor:s.colours.border,paddingTop:10,marginTop:4},children:(0,u.jsx)(n.Muted,{center:!0,children:b})})},_e.HubTile=function({icon:e,label:b,sub:f,onPress:p,badge:x}){const j=(0,l.default)().width<600;return(0,u.jsxs)(o.default,{accessibilityRole:"button",accessibilityLabel:b,onPress:p,style:({pressed:e})=>({flexBasis:j?'45%':'30%',flexGrow:1,maxWidth:j?'100%':'31.5%',minWidth:j?140:96,backgroundColor:e?'#1d1a14':s.colours.surface,borderRadius:14,borderWidth:1,borderColor:s.colours.border,padding:10,gap:2,alignItems:'center',justifyContent:'center'}),children:[h.includes(e)?(0,u.jsx)(c.Icon,{name:e,size:24,colour:s.colours.gold}):(0,u.jsx)(n.T,{size:22,children:e}),(0,u.jsx)(n.T,{size:13,weight:"semibold",center:!0,children:b}),f?(0,u.jsx)(n.T,{size:11,colour:s.colours.muted,center:!0,children:f}):null,x?(0,u.jsx)(t.default,{style:{position:'absolute',top:6,right:6,backgroundColor:s.colours.gold,borderRadius:8,paddingHorizontal:5},children:(0,u.jsx)(n.T,{size:10,weight:"bold",colour:s.colours.onGold,children:x})}):null]})},r(d[0]);var o=e(r(d[1])),t=e(r(d[2])),l=e(r(d[3])),n=r(d[4]),s=r(d[5]),c=r(d[6]),u=r(d[7]);const b='Card payments: not set up yet';const h=['bag','phone','box','calendarPlus','clock','star','userPlus','gift','alert','tag','sparkle','chat','hanger']},1281,[34,402,102,426,794,821,1201,25]); +__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,"photoSource",{enumerable:!0,get:function(){return T}}),_e.BoardPhoto=M,_e.PhotoZoom=S,_e.SpecialRow=I,_e.SpecialsTab=function({rid:e,declared:t,now:l}){const n=(0,f.useSpecials)(t=>t.current[e]??null),[o,c]=(0,s.useState)(null),[h,x]=(0,s.useState)('');if((0,s.useEffect)(()=>(0,w.watchGuestSpecials)(e,x),[e]),!n)return(0,k.jsx)(p.Card,{children:(0,k.jsxs)(u.default,{testID:"specials-empty",style:{alignItems:'center',gap:6,paddingVertical:18},children:[(0,k.jsx)(p.T,{size:34,children:"\ud83e\uddd1\u200d\ud83c\udf73"}),(0,k.jsx)(p.T,{weight:"semibold",size:18,center:!0,children:"Today\u2019s specials are on their way"}),(0,k.jsx)(p.Muted,{center:!0,children:"The kitchen posts the specials board here as soon as it\u2019s written up. Check back soon, or ask a member of staff."}),h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null]})});const C=n.allergenCheck;return(0,k.jsxs)(u.default,{style:{gap:10},testID:"specials-tab",children:[h?(0,k.jsx)(p.Muted,{center:!0,testID:"specials-sync-note",children:h}):null,(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(u.default,{testID:"specials-updated",style:{flex:1},children:(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.goldLight,children:(0,y.freshness)(n,l)})}),(0,y.isToday)(n.postedAt,l)?(0,k.jsx)(p.Badge,{kind:"ok",label:"Today"}):(0,k.jsx)(p.Badge,{kind:"amber",label:"Not updated today"})]}),(0,y.isToday)(n.postedAt,l)?null:(0,k.jsx)(p.Muted,{children:"These are the most recent specials posted. Today\u2019s may differ, so please ask."}),n.photo?(0,k.jsxs)(u.default,{style:{gap:4},children:[(0,k.jsx)(M,{photo:n.photo,testID:"specials-photo",onPress:()=>c(n.photo)}),(0,k.jsx)(p.Muted,{center:!0,children:"Tap the photo to zoom"})]}):null,n.items.map(e=>(0,k.jsx)(I,{it:e,declared:t,signedBy:C?.by},e.id)),C?(0,k.jsxs)(p.Muted,{children:["Allergens for the typed specials were checked by ",C.by.replace(' (example)','')," at ",(0,j.hm)(new Date(C.at)),"."]}):null,n.photo&&!n.items.length?(0,k.jsx)(p.Muted,{children:"For allergens in these specials, please ask a member of staff before you order."}):null,(0,k.jsx)(p.Muted,{children:"Specials are served in the restaurant while they last. Ask your server to order one."}),(0,k.jsx)(S,{photo:o,onClose:()=>c(null)})]})};var t=r(d[0]),s=r(d[1]),l=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=r(d[7]),p=r(d[8]),f=r(d[9]),x=r(d[10]),y=r(d[11]),j=r(d[12]),b=r(d[13]),w=r(d[14]),k=r(d[15]);const C=r(d[16]),T=e=>e===y.SAMPLE_PHOTO?C:{uri:e};function M({photo:e,width:n,onPress:c,testID:h,label:p="Photo of the specials board"}){const[f,x]=(0,s.useState)(.75);(0,s.useEffect)(()=>{e!==y.SAMPLE_PHOTO?l.default.getSize(e,(e,t)=>e&&t&&x(e/t),()=>{}):x(.75)},[e]);const j=(0,k.jsx)(l.default,{source:T(e),resizeMode:"contain",accessibilityLabel:p,style:{width:n??'100%',aspectRatio:f,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#1b1f1d')}});return c?(0,k.jsx)(o.default,{testID:h,accessibilityRole:"button",accessibilityLabel:`${p}. Tap to zoom`,onPress:c,children:j}):(0,k.jsx)(u.default,{testID:h,children:j})}function S({photo:e,onClose:l}){const[h,f]=(0,s.useState)(!1);return(0,s.useEffect)(()=>f(!1),[e]),(0,k.jsx)(n.default,{visible:!!e,transparent:!0,animationType:"fade",onRequestClose:l,children:(0,k.jsxs)(u.default,{testID:"specials-zoom",style:{flex:1,backgroundColor:(0,t.soutersSurface)('rgba(5,5,5,0.97)')},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',padding:12},children:[(0,k.jsx)(p.Button,{small:!0,kind:"secondary",label:h?'Zoom out':'Zoom in',onPress:()=>f(!h)}),(0,k.jsx)(p.Button,{small:!0,label:"Close",accessibilityLabel:"Close photo",onPress:l})]}),(0,k.jsx)(c.default,{horizontal:h,contentContainerStyle:{padding:12,alignItems:'center',justifyContent:'center',flexGrow:1},children:(0,k.jsx)(c.default,{contentContainerStyle:{alignItems:'center'},children:e?(0,k.jsx)(o.default,{onPress:()=>f(!h),accessibilityLabel:h?'Zoom out':'Zoom in',children:(0,k.jsx)(M,{photo:e,width:h?820:360})}):null})})]})})}function I({it:e,declared:t,signedBy:s}){const l=(0,x.conflictsFor)(e.allergens,t);return(0,k.jsx)(p.Card,{highlight:l.contains.length?b.colours.red:l.may.length?b.colours.amber:void 0,children:(0,k.jsxs)(u.default,{testID:"special-item",style:{gap:6},children:[(0,k.jsxs)(p.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,k.jsx)(p.T,{weight:"semibold",style:{flex:1,paddingRight:8},children:e.name}),(0,k.jsx)(p.T,{weight:"semibold",colour:b.colours.gold,children:(0,y.priceText)(e.price)})]}),e.description?(0,k.jsx)(p.Muted,{children:e.description}):null,l.contains.length?(0,k.jsx)(p.Badge,{kind:"red",label:"\u26a0 Contains your allergen"}):l.may.length?(0,k.jsx)(p.Badge,{kind:"amber",label:"\u26a0 May contain your allergen"}):null,e.noAllergens&&!Object.keys(e.allergens).length?(0,k.jsx)(p.Muted,{children:"None of the 14 allergens listed"}):(0,k.jsx)(h.AllergenChips,{map:e.allergens,declared:t}),s?(0,k.jsxs)(p.Muted,{children:["Allergens checked by ",s.replace(' (example)','')]}):null]})})}},1282,[828,34,336,395,402,295,102,1252,794,995,861,996,858,821,1049,25,1283]); +__d(function(g,r,i,a,m,e,d){"use strict";m.exports={uri:"/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg",width:900,height:1200,toString(){return this.uri}}},1283,[]); +__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.LoyaltyLive=function({slug:e,venue:r}){const{info:t,card:l,loading:i,err:u,load:y}=p(e),[S,v]=(0,n.useState)('');return t?t.cardOn||l?(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${r}. This card is just for ${r}.`,children:[S?(0,f.jsx)(o.Banner,{kind:"success",title:S}):null,t.cardOn?null:(0,f.jsxs)(o.Banner,{kind:"info",children:[r," has paused the stamp card. Your stamps and rewards are kept."]}),l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[l.stamps," of ",l.needed," stamps"]}),(0,f.jsxs)(o.T,{colour:h.colours.gold,weight:"semibold",children:["Reward: ",l.reward]})]}),(0,f.jsx)(w,{n:l.stamps,of:l.needed}),(0,f.jsxs)(o.Muted,{children:["Staff add a stamp when you visit. ",t.stampExpiryDays?`Stamps last ${t.stampExpiryDays} days.`:'']})]}),l.rewards.length?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Ready to use"}),l.rewards.map(e=>(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Muted,{children:e.expiresAt?`Use by ${x(e.expiresAt)}`:''})]},e.id)),(0,f.jsx)(o.Muted,{children:"Show this screen or your card to staff when you'd like to use a reward. Staff mark it used; each one works once."})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Your card"}),(0,f.jsx)(o.Muted,{children:"Staff scan this, or look you up by name, to add a stamp."}),(0,f.jsx)(s.QR,{value:(0,c.cardQr)(e,l.cardNo),size:170}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:l.name}),(0,f.jsx)(o.T,{center:!0,size:20,weight:"bold",colour:h.colours.gold,children:(0,c.prettyCardNo)(l.cardNo)})]}),(0,f.jsx)(b,{slug:e,joined:!0,onDone:v}),t.referralOn?(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:h.colours.gold,center:!0,children:l.referralCode}),(0,f.jsxs)(o.Muted,{children:["Your friend types it when they join. After their first stamp you get: ",t.referralGiver,". They get: ",t.referralFriend,"."]}),(0,f.jsxs)(o.Muted,{children:["Waiting: ",l.referrals.waiting," \xb7 Rewarded: ",l.referrals.rewarded]})]}):null,(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),l.history.length?l.history.map((e,n)=>(0,f.jsxs)(o.Muted,{children:[x(e.at)," ",j(e.at)," \xb7 ",e.what]},n)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(C,{slug:e}),(0,f.jsx)(k,{slug:e})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:[t.needed," stamps = ",t.reward]}),(0,f.jsx)(w,{n:0,of:t.needed})]}),(0,f.jsx)(T,{slug:e,venue:r,referralOn:t.referralOn,onJoined:e=>v(e.note?`You're in. ${e.note}`:"You're in. Show your card to staff on your next visit.")}),(0,f.jsx)(b,{slug:e,joined:!1,onDone:v})]}),(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", not on this phone, so you won't lose it. Rewards are kept on food, not drinks."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[(0,f.jsx)(o.Banner,{kind:"info",title:`${r} hasn't started a stamp card yet`,children:"When they do, you can join here."}),(0,f.jsxs)(o.Muted,{children:["Tip: offers from ",r," are under Offers on the home screen."]})]}):(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:r,children:[u?(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load the stamp card",children:u}):(0,f.jsx)(o.Muted,{children:i?'Loading your card\u2026':'Loading\u2026'}),u?(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:y}):null,(0,f.jsxs)(o.Muted,{children:["Tip: your card is saved by ",r,", so it's the same on any phone once you sign in with a code."]})]})},_e.OffersLive=function({slug:e,venue:n}){const{info:r,err:t,load:s}=p(e);return(0,f.jsxs)(o.Screen,{title:"Offers",subtitle:n,children:[!r&&t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(o.Banner,{kind:"warn",title:"Couldn't load offers",children:t}),(0,f.jsx)(o.Button,{kind:"secondary",label:"Try again",onPress:s})]}):null,r?r.offers.length?r.offers.map(e=>(0,f.jsxs)(o.Card,{children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(o.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,f.jsx)(o.Badge,{kind:"gold",label:"Offer"})]}),e.details?(0,f.jsx)(o.Muted,{children:e.details}):null,e.endsOn?(0,f.jsxs)(o.Muted,{children:["Until ",x(e.endsOn+'T12:00:00Z')]}):null]},e.id)):(0,f.jsxs)(o.Muted,{children:["No offers from ",n," right now."]}):t?null:(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: offers are set by ",n," and shown here only. Nothing is sent to your phone. Drinks promotions follow Scottish licensing rules."]})]})},_e.ReferLive=function({slug:e,venue:n}){const{info:r,card:t}=p(e);return(0,f.jsxs)(o.Screen,{title:"Bring a friend",subtitle:n,children:[r?r.referralOn?(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsxs)(o.H2,{children:["You get: ",r.referralGiver]}),(0,f.jsxs)(o.T,{children:["Your friend gets: ",r.referralFriend]}),(0,f.jsx)(o.Muted,{children:"Your friend joins the stamp card with your code. You both get your reward after their first stamp."}),t?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:t.referralCode}):(0,f.jsx)(o.Banner,{kind:"info",children:"Join the stamp card first to get your code."}),t?(0,f.jsxs)(o.Muted,{children:["Waiting: ",t.referrals.waiting," \xb7 Rewarded: ",t.referrals.rewarded]}):null]}):(0,f.jsxs)(o.Banner,{kind:"info",children:[n," isn't running Bring a friend right now."]}):(0,f.jsx)(o.Muted,{children:"Loading\u2026"}),(0,f.jsxs)(o.Muted,{children:["Tip: tell your friend the code yourself. One reward per friend; it doesn't work on your own card, and ",n," may cap it each month."]})]})},_e.useLiveTile=function(e){const r=(0,u.useGuestLoyalty)(n=>n.info[e]),t=(0,u.useGuestLoyalty)(n=>n.card[e]);return(0,n.useEffect)(()=>{(0,u.refreshGuest)(e).catch(()=>{})},[e]),{stamps:r?t?`${t.stamps} of ${t.needed}`:r.cardOn?'Join':void 0:void 0,offers:r?.offers.length}};var n=_r(d[0]),r=e(n),t=e(_r(d[1])),s=_r(d[2]),o=_r(d[3]),l=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),f=_r(d[9]);const x=e=>{try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},j=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};let y=!1;function p(e){const t=(0,u.useGuestLoyalty)(n=>n.info[e]),s=(0,u.useGuestLoyalty)(n=>n.card[e]),o=(0,u.useGuestLoyalty)(n=>!!n.loading[e]),[l,i]=(0,n.useState)(''),h=r.default.useCallback(()=>{i(''),(0,u.refreshGuest)(e).catch(e=>i((0,c.plainError)(e)))},[e]);return(0,n.useEffect)(()=>{h();const e=setInterval(h,3e4);return()=>clearInterval(e)},[h]),{info:t,card:s,loading:o,err:l,load:h}}function w({n:e,of:n}){return(0,f.jsx)(t.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:n}).map((n,r)=>(0,f.jsx)(t.default,{accessibilityLabel:r!y&&i.START_LOYALTY_CODE?(y=!0,i.START_LOYALTY_CODE):''),[h,x]=(0,n.useState)(!1),[j,p]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:r?'Got a code from staff?':'Already have a card?'}),(0,f.jsx)(o.Muted,{children:r?'Staff can give you a one-time code for a stamp. Type it here.':'Ask staff for a sign-in code, or make one on your other phone (Stamp card \u203a Use on another phone). Type it here to open your card.'}),(0,f.jsx)(o.Field,{label:"Code",value:s,onChangeText:e=>l(e.toUpperCase()),autoCapitalize:"characters",maxLength:9,placeholder:"e.g. 7KQ2MX",testID:"loyalty-code"}),j?(0,f.jsx)(o.Banner,{kind:"warn",children:j}):null,(0,f.jsx)(o.Button,{label:h?'Checking\u2026':'Use code',disabled:h||s.replace(/[^A-Za-z0-9]/g,'').length<6,onPress:async()=>{x(!0),p('');try{const n=await(0,u.guestClaim)(e,s);n.ok?(l(''),t(n.linked?'This phone now shows your card.':n.card.newReward?`Stamp added. You've earned: ${n.card.rewards[n.card.rewards.length-1]?.title??'a reward'}!`:'Stamp added.')):p(n.error)}catch(e){p((0,c.plainError)(e))}finally{x(!1)}},testID:"loyalty-use-code"})]})}function T({slug:e,venue:r,referralOn:t,onJoined:s}){const i=(0,l.useCustomer)(),[x,j]=(0,n.useState)(i.name??''),[y,p]=(0,n.useState)(i.phone??''),[w,b]=(0,n.useState)(i.email??''),[T,C]=(0,n.useState)(''),[k,S]=(0,n.useState)(!1),[v,L]=(0,n.useState)(!1),[M,B]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{highlight:h.colours.gold,children:[(0,f.jsx)(o.H2,{children:"Join the stamp card"}),(0,f.jsx)(o.Muted,{children:"Only your name is needed. A phone number or email helps staff find your card if you lose this phone. Nothing is sent to you."}),(0,f.jsx)(o.Field,{label:"Your name",value:x,onChangeText:j,maxLength:60,testID:"loyalty-name"}),(0,f.jsx)(o.Field,{label:"Phone (optional)",value:y,onChangeText:p,keyboardType:"phone-pad",maxLength:20}),(0,f.jsx)(o.Field,{label:"Email (optional)",value:w,onChangeText:b,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),t?(0,f.jsx)(o.Field,{label:"Friend's code (optional)",value:T,onChangeText:e=>C(e.toUpperCase()),autoCapitalize:"characters",maxLength:8}):null,(0,f.jsx)(o.Toggle,{label:(0,c.consentText)(r),value:k,onChange:S,testID:"loyalty-consent"}),M?(0,f.jsx)(o.Banner,{kind:"warn",children:M}):null,(0,f.jsx)(o.Button,{label:v?'Joining\u2026':'Join',disabled:v||!k||!x.trim(),onPress:async()=>{L(!0),B('');try{s(await(0,u.guestJoin)(e,{name:x,phone:y,email:w,consent:k,consentText:(0,c.consentText)(r),referral:T}))}catch(e){B((0,c.plainError)(e))}finally{L(!1)}},testID:"loyalty-join"})]})}function C({slug:e}){const[r,t]=(0,n.useState)(null),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Use on another phone"}),(0,f.jsxs)(o.Muted,{children:["Make a code here, then on the other phone open ","the stamp card"," and type it under \"Already have a card?\". The code works once, for 15 minutes."]}),r?(0,f.jsx)(o.T,{size:30,weight:"bold",colour:h.colours.gold,center:!0,children:r.code}):null,r?(0,f.jsxs)(o.Muted,{center:!0,children:["Works until ",j(r.expiresAt)]}):null,s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,(0,f.jsx)(o.Button,{kind:"secondary",label:r?'Make a new code':'Make a code',onPress:()=>{l(''),(0,u.guestLinkCode)(e).then(t).catch(e=>l((0,c.plainError)(e)))}})]})}function k({slug:e}){const[r,t]=(0,n.useState)(!1),[s,l]=(0,n.useState)('');return(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Leave the stamp card"}),(0,f.jsx)(o.Muted,{children:"Your name, phone and email are removed and your stamps and rewards go. This can't be undone."}),s?(0,f.jsx)(o.Banner,{kind:"warn",children:s}):null,r?(0,f.jsxs)(o.Row,{gap:8,children:[(0,f.jsx)(o.Button,{kind:"danger",label:"Yes, remove me",onPress:()=>(0,u.guestLeave)(e).catch(e=>l((0,c.plainError)(e)))}),(0,f.jsx)(o.Button,{kind:"ghost",label:"Keep my card",onPress:()=>t(!1)})]}):(0,f.jsx)(o.Button,{kind:"ghost",label:"Leave the stamp card",onPress:()=>t(!0)})]})}},1284,[34,102,1285,794,874,1004,1260,1263,821,25]); +__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.QR=function({value:e,size:t=180}){return(0,n.jsx)(o.default,{style:{padding:12,backgroundColor:'#FFFFFF',borderRadius:12,alignSelf:'center',borderWidth:3,borderColor:u.colours.gold},children:(0,n.jsx)(l.default,{value:e,size:t,color:"#0B0B0B",backgroundColor:"#FFFFFF"})})},r(d[0]);var o=e(r(d[1])),l=e(r(d[2])),u=r(d[3]),n=r(d[4])},1285,[34,102,1286,821,25]); +__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.default}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e}},1286,[1287]); +__d(function(g,r,i,a,m,_e,d){"use strict";function o(o){return o&&o.__esModule?o:{default:o}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var e=r(d[0]),t=r(d[1]),l=o(t),s=o(r(d[2])),n=o(r(d[3])),c=o(r(d[4])),h=r(d[5]);const u=({size:o,backgroundColor:e,logo:l,logoSVG:s,logoSize:n,logoBackgroundColor:u,logoColor:x,logoMargin:f,logoBorderRadius:p,clipPathId:j})=>{const C=(o-n-2*f)/2,y=n+2*f,b=p+f/n*p,k=`clip-logo-background-${j}`,G=`clip-logo-${j}`;return(0,h.jsxs)(t.G,{x:C,y:C,children:[(0,h.jsxs)(t.Defs,{children:[(0,h.jsx)(t.ClipPath,{id:k,children:(0,h.jsx)(t.Rect,{width:y,height:y,rx:b,ry:b})}),(0,h.jsx)(t.ClipPath,{id:G,children:(0,h.jsx)(t.Rect,{width:n,height:n,rx:p,ry:p})})]}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{width:y,height:y,fill:e,clipPath:`url(#${k})`})}),(0,h.jsxs)(t.G,{x:f,y:f,clipPath:`url(#${G})`,children:[(0,h.jsx)(t.Rect,{width:y-f,height:y-f,fill:u}),s?(0,h.jsx)(c.default,{svg:s,logoSize:n,logoColor:x}):(0,h.jsx)(t.Image,{width:n,height:n,preserveAspectRatio:"xMidYMid slice",href:l,clipPath:`url(#${G})`})]})]})};var x=({value:o="this is a QR code",size:c=100,color:x="black",backgroundColor:f="white",logo:p,logoSVG:j,logoSize:C=.2*c,logoBackgroundColor:y="transparent",logoColor:b,logoMargin:k=2,logoBorderRadius:G=0,quietZone:R=0,enableLinearGradient:w=!1,gradientDirection:P=['0%','0%','100%','100%'],linearGradient:S=['rgb(255,0,0)','rgb(0,255,255)'],ecl:M="M",getRef:z,onError:v,testID:B})=>{const I=(0,e.useId)(),_=(0,e.useMemo)(()=>{try{return(0,n.default)((0,s.default)(o,M),c)}catch(o){if(!v||'function'!=typeof v)throw o;v(o)}},[o,c,M]);if(!_)return null;const{path:D,cellSize:$}=_,O=p||j;return(0,h.jsxs)(l.default,{testID:B,ref:z,viewBox:[-R,-R,c+2*R,c+2*R].join(' '),width:c,height:c,children:[(0,h.jsx)(t.Defs,{children:(0,h.jsxs)(t.LinearGradient,{id:"grad",x1:P[0],y1:P[1],x2:P[2],y2:P[3],children:[(0,h.jsx)(t.Stop,{offset:"0",stopColor:S[0],stopOpacity:"1"}),(0,h.jsx)(t.Stop,{offset:"1",stopColor:S[1],stopOpacity:"1"})]})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Rect,{x:-R,y:-R,width:c+2*R,height:c+2*R,fill:f})}),(0,h.jsx)(t.G,{children:(0,h.jsx)(t.Path,{d:D,strokeLinecap:"butt",stroke:w?'url(#grad)':x,strokeWidth:$})}),O&&u({size:c,backgroundColor:f,logo:p,logoSVG:j,logoSize:C,logoBackgroundColor:y,logoColor:b,logoMargin:k,logoBorderRadius:G,clipPathId:I})]})}},1287,[34,797,1288,1317,1318,25]); +__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 l}});var e,t=r(d[0]),u=(e=t)&&e.__esModule?e:{default:e},l=(e,t)=>{const l=Array.prototype.slice.call(u.default.create(e,{errorCorrectionLevel:t}).modules.data,0),n=Math.sqrt(l.length);return l.reduce((e,t,u)=>(u%n===0?e.push([t]):e[e.length-1].push(t))&&e,[])}},1288,[1289]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]),n=r(d[1]),e=r(d[2]),o=r(d[3]);function c(e,o,c,l,u){const f=[].slice.call(arguments,1),s=f.length,v='function'==typeof f[s-1];if(!v&&!t())throw new Error('Callback required as last argument');if(!v){if(s<1)throw new Error('Too few arguments provided');return 1===s?(c=o,o=l=void 0):2!==s||o.getContext||(l=c,c=o,o=void 0),new Promise(function(t,u){try{const u=n.create(c,l);t(e(u,o,l))}catch(t){u(t)}})}if(s<2)throw new Error('Too few arguments provided');2===s?(u=c,c=o,o=l=void 0):3===s&&(o.getContext&&void 0===u?(u=l,l=void 0):(u=l,l=c,c=o,o=void 0));try{const t=n.create(c,l);u(null,e(t,o,l))}catch(t){u(t)}}_e.create=n.create,_e.toCanvas=c.bind(null,e.render),_e.toDataURL=c.bind(null,e.renderToDataURL),_e.toString=c.bind(null,function(t,n,e){return o.render(t,e)})},1289,[1290,1291,1314,1316]); +__d(function(g,r,i,a,m,e,d){m.exports=function(){return'function'==typeof Promise&&Promise.prototype&&Promise.prototype.then}},1290,[]); +__d(function(g,_r,_i,a,m,e,d){const t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=_r(d[3]),s=_r(d[4]),i=_r(d[5]),f=_r(d[6]),c=_r(d[7]),l=_r(d[8]),u=_r(d[9]),h=_r(d[10]),w=_r(d[11]),C=_r(d[12]);function y(t,o){const n=t.size,r=i.getPositions(o);for(let o=0;o=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?t.set(s+o,i+r,!0,!0):t.set(s+o,i+r,!1,!0))}}function S(t){const o=t.size;for(let n=8;n>o&1),t.set(s,i,f,!0),t.set(i,s,f,!0)}function B(t,o,n){const r=t.size,s=h.getEncodedBits(o,n);let i,f;for(i=0;i<15;i++)f=1==(s>>i&1),i<6?t.set(i,8,f,!0):i<8?t.set(i+1,8,f,!0):t.set(r-15+i,8,f,!0),i<8?t.set(8,r-i-1,f,!0):i<9?t.set(8,15-i-1+1,f,!0):t.set(8,15-i-1,f,!0);t.set(r-8,8,1,!0)}function b(t,o){const n=t.size;let r=-1,s=n-1,i=7,f=0;for(let c=n-1;c>0;c-=2)for(6===c&&c--;;){for(let n=0;n<2;n++)if(!t.isReserved(s,c-n)){let r=!1;f>>i&1)),t.set(s,c-n,r),i--,-1===i&&(f++,i=7)}if(s+=r,s<0||n<=s){s-=r,r=-r;break}}}function M(o,r,s){const i=new n;s.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),w.getCharCountIndicator(t.mode,o)),t.write(i)});const f=8*(t.getSymbolTotalCodewords(o)-c.getTotalCodewordsCount(o,r));for(i.getLengthInBits()+4<=f&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);const l=(f-i.getLengthInBits())/8;for(let t=0;t=7&&v(I,n),b(I,h),isNaN(i)&&(i=f.getBestMask(I,B.bind(null,I,s))),f.applyMask(i,I),B(I,s,i),{modules:I,version:n,errorCorrectionLevel:s,maskPattern:i,segments:c}}e.create=function(n,r){if(void 0===n||''===n)throw new Error('No input text');let s,i,c=o.M;return void 0!==r&&(c=o.from(r.errorCorrectionLevel,o.M),s=u.from(r.version),i=f.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),A(n,s,c,i)}},1291,[1292,1293,1294,1295,1296,1297,1298,1299,1300,1303,1307,1304,1308]); +__d(function(g,r,i,a,m,e,d){let n;const o=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return 4*n+17},e.getSymbolTotalCodewords=function(n){return o[n]},e.getBCHDigit=function(n){let o=0;for(;0!==n;)o++,n>>>=1;return o},e.setToSJISFunction=function(o){if('function'!=typeof o)throw new Error('"toSJISFunc" is not a valid function.');n=o},e.isKanjiModeEnabled=function(){return void 0!==n},e.toSJIS=function(o){return n(o)}},1292,[]); +__d(function(g,r,i,a,m,_e,d){function t(t){if('string'!=typeof t)throw new Error('Param is not a string');switch(t.toLowerCase()){case'l':case'low':return _e.L;case'm':case'medium':return _e.M;case'q':case'quartile':return _e.Q;case'h':case'high':return _e.H;default:throw new Error('Unknown EC Level: '+t)}}_e.L={bit:1},_e.M={bit:0},_e.Q={bit:3},_e.H={bit:2},_e.isValid=function(t){return t&&void 0!==t.bit&&t.bit>=0&&t.bit<4},_e.from=function(e,n){if(_e.isValid(e))return e;try{return t(e)}catch(t){return n}}},1293,[]); +__d(function(g,r,_i,a,m,e,d){function t(){this.buffer=[],this.length=0}t.prototype={get:function(t){const n=Math.floor(t/8);return 1==(this.buffer[n]>>>7-t%8&1)},put:function(t,n){for(let h=0;h>>n-h-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},m.exports=t},1294,[]); +__d(function(g,r,i,a,m,e,d){function t(t){if(!t||t<1)throw new Error('BitMatrix size must be defined and greater than 0');this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}t.prototype.set=function(t,s,n,o){const h=t*this.size+s;this.data[h]=n,o&&(this.reservedBit[h]=!0)},t.prototype.get=function(t,s){return this.data[t*this.size+s]},t.prototype.xor=function(t,s,n){this.data[t*this.size+s]^=n},t.prototype.isReserved=function(t,s){return this.reservedBit[t*this.size+s]},m.exports=t},1295,[]); +__d(function(g,r,_i,a,m,e,d){const o=r(d[0]).getSymbolSize;e.getRowColCoords=function(t){if(1===t)return[];const n=Math.floor(t/7)+2,s=o(t),l=145===s?26:2*Math.ceil((s-13)/(2*n-2)),f=[s-7];for(let o=1;o=0&&t<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(n){const s=n.size;let l=0,o=0,P=0,T=null,c=null;for(let u=0;u=5&&(l+=t+(o-5)),T=s,o=1),s=n.get(N,u),s===c?P++:(P>=5&&(l+=t+(P-5)),c=s,P=1)}o>=5&&(l+=t+(o-5)),P>=5&&(l+=t+(P-5))}return l},e.getPenaltyN2=function(t){const s=t.size;let l=0;for(let n=0;n=10&&(1488===o||93===o)&&l++,P=P<<1&2047|t.get(T,s),T>=10&&(1488===P||93===P)&&l++}return l*s},e.getPenaltyN4=function(t){let n=0;const s=t.data.length;for(let l=0;l0){const t=new Uint8Array(this.degree);return t.set(s,h),t}return s},m.exports=n},1300,[1301]); +__d(function(g,r,_i,a,m,e,d){const n=r(d[0]);e.mul=function(t,l){const o=new Uint8Array(t.length+l.length-1);for(let u=0;u=0;){const t=o[0];for(let u=0;u1)return C(t,u);if(0===t.length)return 1;f=t[0]}else f=t;return s(f.mode,f.getLength(),u)},e.getEncodedBits=function(n){if(!u.isValid(n)||n<7)throw new Error('Invalid QR Code version');let o=n<<12;for(;t.getBCHDigit(o)-c>=0;)o^=7973<=1&&e<10?n.ccBits[0]:e<27?n.ccBits[1]:n.ccBits[2]},_e.getBestModeForData=function(t){return n.testNumeric(t)?_e.NUMERIC:n.testAlphanumeric(t)?_e.ALPHANUMERIC:n.testKanji(t)?_e.KANJI:_e.BYTE},_e.toString=function(t){if(t&&t.id)return t.id;throw new Error('Invalid mode')},_e.isValid=function(t){return t&&t.bit&&t.ccBits},_e.from=function(t,n){if(_e.isValid(t))return t;try{return e(t)}catch(t){return n}}},1304,[1305,1306]); +__d(function(g,r,i,a,m,e,d){e.isValid=function(n){return!isNaN(n)&&n>=1&&n<=40}},1305,[]); +__d(function(g,r,i,a,m,e,d){let u="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";u=u.replace(/u/g,'\\u');const n='(?:(?![A-Z0-9 $%*+\\-./:]|'+u+')(?:.|[\r\n]))+';e.KANJI=new RegExp(u,'g'),e.BYTE_KANJI=new RegExp('[^A-Z0-9 $%*+\\-./:]+','g'),e.BYTE=new RegExp(n,'g'),e.NUMERIC=new RegExp('[0-9]+','g'),e.ALPHANUMERIC=new RegExp('[A-Z $%*+\\-./:]+','g');const t=new RegExp('^'+u+'$'),E=new RegExp("^[0-9]+$"),A=new RegExp('^[A-Z0-9 $%*+\\-./:]+$');e.testKanji=function(u){return t.test(u)},e.testNumeric=function(u){return E.test(u)},e.testAlphanumeric=function(u){return A.test(u)}},1306,[]); +__d(function(g,r,i,a,m,e,_d){const t=r(_d[0]),n=t.getBCHDigit(1335);e.getEncodedBits=function(o,c){const B=o.bit<<3|c;let d=B<<10;for(;t.getBCHDigit(d)-n>=0;)d^=1335<=0?t[t.length-1]:null;return o&&o.mode===n.mode?(t[t.length-1].data+=n.data,t):(t.push(n),t)},[])}function C(n){const o=[];for(let u=0;u0&&(o=this.data.substr(n),s=parseInt(o,10),t.put(s,3*i+1))},m.exports=n},1309,[1304]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]),n=['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':'];function i(n){this.mode=t.ALPHANUMERIC,this.data=n}i.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let h=45*n.indexOf(this.data[i]);h+=n.indexOf(this.data[i+1]),t.put(h,11)}this.data.length%2&&t.put(n.indexOf(this.data[i]),6)},m.exports=i},1310,[1304]); +__d(function(g,r,_i,a,m,e,d){const t=r(d[0]);function n(n){this.mode=t.BYTE,this.data='string'==typeof n?(new TextEncoder).encode(n):new Uint8Array(n)}n.getBitsLength=function(t){return 8*t},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(t){for(let n=0,o=this.data.length;n=33088&&o<=40956)o-=33088;else{if(!(o>=57408&&o<=60351))throw new Error('Invalid SJIS character: '+this.data[i]+"\nMake sure your charset is UTF-8");o-=49472}o=192*(o>>>8&255)+(255&o),t.put(o,13)}},m.exports=i},1312,[1304,1292]); +__d(function(g,r,i,_a,m,e,_d){'use strict';var t={single_source_shortest_paths:function(o,s,u){var n={},a={};a[s]=0;var h,f,p,_,c,v,d,l=t.PriorityQueue.make();for(l.push(s,0);!l.empty();)for(p in f=(h=l.pop()).value,_=h.cost,c=o[f]||{})c.hasOwnProperty(p)&&(v=_+c[p],d=a[p],(void 0===a[p]||d>v)&&(a[p]=v,l.push(p,v),n[p]=f));if(void 0!==u&&void 0===a[u]){var y=['Could not find a path from ',s,' to ',u,'.'].join('');throw new Error(y)}return n},extract_shortest_path_from_predecessor_list:function(t,o){for(var s=[],u=o;u;)s.push(u),t[u],u=t[u];return s.reverse(),s},find_path:function(o,s,u){var n=t.single_source_shortest_paths(o,s,u);return t.extract_shortest_path_from_predecessor_list(n,u)},PriorityQueue:{make:function(o){var s,u=t.PriorityQueue,n={};for(s in o=o||{},u)u.hasOwnProperty(s)&&(n[s]=u[s]);return n.queue=[],n.sorter=o.sorter||u.default_sorter,n},default_sorter:function(t,o){return t.cost-o.cost},push:function(t,o){var s={value:t,cost:o};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};void 0!==m&&(m.exports=t)},1313,[]); +__d(function(g,r,i,a,m,_e,d){const t=r(d[0]);function e(t,e,n){t.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=n,e.width=n,e.style.height=n+'px',e.style.width=n+'px'}function n(){try{return document.createElement('canvas')}catch(t){throw new Error('You need to specify a canvas element')}}_e.render=function(o,c,s){let u=s,h=c;void 0!==u||c&&c.getContext||(u=c,c=void 0),c||(h=n()),u=t.getOptions(u);const l=t.getImageWidth(o.modules.size,u),p=h.getContext('2d'),y=p.createImageData(l,l);return t.qrToImageData(y.data,o,u),e(p,h,l),p.putImageData(y,0,0),h},_e.renderToDataURL=function(t,e,n){let o=n;void 0!==o||e&&e.getContext||(o=e,e=void 0),o||(o={});const c=_e.render(t,e,o),s=o.type||'image/png',u=o.rendererOpts||{};return c.toDataURL(s,u.quality)}},1314,[1315]); +__d(function(g,r,_i,a,m,e,d){function t(t){if('number'==typeof t&&(t=t.toString()),'string'!=typeof t)throw new Error('Color should be defined as hex string');let o=t.slice().replace('#','').split('');if(o.length<3||5===o.length||o.length>8)throw new Error('Invalid hex color: '+t);3!==o.length&&4!==o.length||(o=Array.prototype.concat.apply([],o.map(function(t){return[t,t]}))),6===o.length&&o.push('F','F');const n=parseInt(o.join(''),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:'#'+o.slice(0,6).join('')}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=void 0===o.margin||null===o.margin||o.margin<0?4:o.margin,i=o.width&&o.width>=21?o.width:void 0,l=o.scale||4;return{width:i,scale:i?4:l,margin:n,color:{dark:t(o.color.dark||'#000000ff'),light:t(o.color.light||'#ffffffff')},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(t,o){return o.width&&o.width>=t+2*o.margin?o.width/(t+2*o.margin):o.scale},e.getImageWidth=function(t,o){const n=e.getScale(t,o);return Math.floor((t+2*o.margin)*n)},e.qrToImageData=function(t,o,n){const i=o.modules.size,l=o.modules.data,c=e.getScale(i,n),f=Math.floor((i+2*n.margin)*c),h=n.margin*c,s=[n.color.light,n.color.dark];for(let o=0;o=h&&u>=h&&o0&&f>0&&t[u-1]||(l+=s?n('M',f+i,.5+w+i):n('m',h,0),h=0,s=!1),f+1':'',p='',v="viewBox=\"0 0 "+f+' '+f+'"',x=''+w+p+'\n';return'function'==typeof h&&h(null,x),x}},1316,[1315]); +__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 t=(t,n)=>{const l=n/t.length;let c='';return t.forEach((n,u)=>{let o=!1;n.forEach((n,f)=>{n?(o||(c+=`M${l*f} ${l/2+l*u} `,o=!0),o&&f===t.length-1&&(c+=`L${l*(f+1)} ${l/2+l*u} `)):o&&(c+=`L${l*f} ${l/2+l*u} `,o=!1)})}),{cellSize:l,path:c}}},1317,[]); +__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}}),r(d[0]);var t=r(d[1]),n=r(d[2]),o=r(d[3]);var s=({svg:s,logoSize:l,logoColor:u})=>{if((0,n.isString)(s)){const u=(0,n.isUrlString)(s)?s:`data:image/svg+xml;base64,${window.btoa(s)}`;return(0,o.jsx)(t.Image,{href:encodeURI(u),width:l,height:l})}const c=s;return(0,o.jsx)(c,{fill:u,width:l,height:l})}},1318,[34,797,1319,25]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return'string'==typeof t}Object.defineProperty(e,'__esModule',{value:!0}),e.isString=t,e.isUrlString=function(n){return t(n)&&n.startsWith('http')}},1319,[]); +__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]),n=_r(d[1]),s=_r(d[2]),r=_r(d[3]),l=_r(d[4]),o=_r(d[5]);function u(){const{rid:u}=(0,t.useLocalSearchParams)(),h=(0,r.useRestaurant)(u),c=(0,r.useCustomer)(),x=(0,r.useNow)(6e4),j=(0,l.useOwner)(t=>t.lost),p=(0,l.useOwner)(t=>t.lostReports),[f,y]=(0,n.useState)(''),[w,b]=(0,n.useState)(''),[S,C]=(0,n.useState)(''),[R,v]=(0,n.useState)(!1);if(!h)return(0,o.jsx)(s.Screen,{title:"Not found",children:(0,o.jsx)(s.T,{children:"Restaurant not found."})});const O=p.filter(t=>t.contact.includes(c.email));return(0,o.jsxs)(s.Screen,{title:"Lost property",subtitle:h.name,children:[(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Recently handed in"}),j.filter(t=>'held'===t.status).map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsx)(s.T,{style:{flex:1},children:t.item}),(0,o.jsx)(s.Muted,{children:t.foundAt.slice(0,10)})]},t.id)),j.some(t=>'held'===t.status)?null:(0,o.jsx)(s.Muted,{children:"Nothing handed in right now."}),(0,o.jsx)(s.Muted,{children:"To collect, bring ID or describe the item to staff. Items are kept for 3 months."})]}),R?(0,o.jsxs)(s.Banner,{kind:"success",children:["Report sent to ",h.name,". They'll be in touch if it turns up (sent to the venue on this device only: messaging is not set up yet)."]}):null,(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Lost something?"}),(0,o.jsx)(s.Field,{label:"What did you lose?",value:f,onChangeText:y,placeholder:"e.g. Grey scarf"}),(0,o.jsx)(s.Field,{label:"When were you in?",value:w,onChangeText:b,placeholder:"e.g. Saturday evening"}),(0,o.jsx)(s.Field,{label:"Where were you sitting? (optional)",value:S,onChangeText:C,placeholder:"e.g. By the window"}),(0,o.jsxs)(s.Muted,{children:["We'll share your name and email (",c.email,") with ",h.name," for this report only."]}),(0,o.jsx)(s.Button,{label:"Send report",disabled:f.trim().length<2||w.trim().length<2,onPress:()=>{l.useOwner.getState().setOwner({lostReports:[{id:`lr-${Date.now()}`,item:f.trim(),when:w.trim(),where:S.trim()||'Not sure',contact:`${c.name} \xb7 ${c.email}`,at:x.toISOString(),status:'open'},...l.useOwner.getState().lostReports]}),y(''),b(''),C(''),v(!0)}})]}),O.length?(0,o.jsxs)(s.Card,{children:[(0,o.jsx)(s.H2,{children:"Your reports"}),O.map(t=>(0,o.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,o.jsxs)(s.T,{style:{flex:1},children:[t.item," \xb7 ",t.when]}),(0,o.jsx)(s.Badge,{kind:'matched'===t.status?'ok':'open'===t.status?'amber':'neutral',label:'matched'===t.status?'Found!':'open'===t.status?'Looking':'Closed'})]},t.id))]}):null]})}},1320,[30,34,794,874,891,25]); +__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 j}});var e=_r(d[0]),r=_r(d[1]);_r(d[2]);var s,t=_r(d[3]),n=(s=t)&&s.__esModule?s:{default:s},i=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),p=_r(d[10]),f=_r(d[11]);function j(){const{rid:s}=(0,r.useLocalSearchParams)(),t=(0,c.useRestaurant)(s);return e.LIVE_VENUE_BUILD||(0,p.guestServer)()?t?(0,f.jsx)(h.LoyaltyLive,{slug:s,venue:t.name}):(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:e}=(0,r.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),t=(0,c.useCustomer)(),h=(0,c.useStampCard)(e);if(!s)return(0,f.jsx)(o.Screen,{title:"Not found",children:(0,f.jsx)(o.T,{children:"Restaurant not found."})});const p=s.settings.stampTarget,j=h?.stamps??0;return(0,f.jsxs)(o.Screen,{title:"Stamp card",subtitle:`${s.name} \u2014 this card is just for ${s.name}`,children:[(0,f.jsx)(o.Banner,{kind:"example",title:"Example card (demo)",children:"On a real venue your card is saved by the venue and is the same on any phone."}),(0,f.jsxs)(o.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.H2,{children:[j," of ",p," stamps"]}),(0,f.jsxs)(o.T,{colour:u.colours.gold,weight:"semibold",children:["Reward: ",s.settings.stampReward]})]}),(0,f.jsx)(n.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center',paddingVertical:8},children:Array.from({length:p}).map((e,r)=>(0,f.jsx)(n.default,{accessibilityLabel:r1?'s':''} ready: ${s.settings.stampReward}`,children:(0,f.jsx)(o.Button,{small:!0,label:"Use reward (show staff)",onPress:()=>c.repo.loyalty.redeemReward(s.id,t.id)})}):null]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Show this to staff"}),(0,f.jsx)(o.Muted,{children:"Staff scan this on the tablet to add a stamp for dine-in visits not paid by table QR."}),(0,f.jsx)(i.QR,{value:`covercharge:stamp:${s.id}:${t.id}`,size:190}),(0,f.jsx)(o.T,{center:!0,weight:"semibold",children:t.name})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"Bring a friend"}),(0,f.jsx)(o.T,{children:"Your referral code"}),(0,f.jsx)(o.T,{size:28,weight:"bold",colour:u.colours.gold,center:!0,children:t.referralCode}),(0,f.jsx)(o.Muted,{children:"When a friend completes their first qualifying paid visit or order, you both get a stamp. One referral reward per new account, phone and card; monthly cap applies."})]}),(0,f.jsxs)(o.Card,{children:[(0,f.jsx)(o.H2,{children:"History"}),(h?.history??[]).length?h.history.slice(0,10).map((e,r)=>(0,f.jsxs)(o.Muted,{children:[e.at.slice(0,10)," \xb7 ",e.source]},r)):(0,f.jsx)(o.Muted,{children:"No stamps yet."})]}),(0,f.jsx)(o.Muted,{children:"Rewards are kept on food (Scottish licensing rules restrict drinks promotions). Stamps are never given for reviews."})]})}},1321,[837,30,34,102,1285,794,867,874,821,1284,1263,25]); +__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 y}});var e,t=_r(d[0]),n=_r(d[1]),s=_r(d[2]),l=_r(d[3]),r=(e=l)&&e.__esModule?e:{default:e},u=_r(d[4]),o=_r(d[5]),c=_r(d[6]),m=_r(d[7]),h=_r(d[8]),j=_r(d[9]),x=_r(d[10]),f=_r(d[11]),b=_r(d[12]),p=_r(d[13]);function y(){const{rid:e}=(0,n.useLocalSearchParams)(),s=(0,c.useRestaurant)(e),l=(0,c.useCustomer)();return t.LIVE_VENUE_BUILD||(0,b.guestServer)()?s?(0,p.jsx)(f.ShopLive,{slug:e,venue:s.name,guestName:l.name}):(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})}):(0,p.jsx)(S,{})}function S(){const{rid:e}=(0,n.useLocalSearchParams)(),t=(0,c.useRestaurant)(e),l=(0,c.useCustomer)(),f=(0,c.useNow)(6e4),b=(0,m.useOwner)(e=>e.merch),[y,S]=(0,s.useState)({}),[k,w]=(0,s.useState)(null),[v,C]=(0,s.useState)(null);if(!t)return(0,p.jsx)(o.Screen,{title:"Not found",children:(0,p.jsx)(o.T,{children:"Restaurant not found."})});const $=b.find(e=>e.id===k),O=e=>y[e]??1;return(0,p.jsxs)(o.Screen,{title:"Shop",subtitle:`${t.name} merch \xb7 collect in the restaurant`,children:[v?(0,p.jsxs)(o.Banner,{kind:"success",title:"Order noted (no payment taken)",children:[v," Collect it at the bar on your next visit."]}):null,b.filter(e=>e.live||0===e.stock).map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(r.default,{style:{flex:1},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),(0,p.jsx)(o.T,{colour:x.colours.gold,weight:"semibold",children:(0,h.gbp)(e.price)})]}),0!==e.stock&&e.live?e.stock<8?(0,p.jsx)(o.Badge,{kind:"amber",label:`${e.stock} left`}):null:(0,p.jsx)(o.Badge,{kind:"neutral",label:"Sold out"})]}),e.live&&e.stock>0?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:O(e.id),min:1,max:Math.min(5,e.stock),onChange:t=>S({...y,[e.id]:t}),label:`${e.name} quantity`}),(0,p.jsx)(o.Button,{small:!0,label:`Buy \xb7 ${(0,h.gbp)(e.price*O(e.id))}`,onPress:()=>w(e.id)})]}):null]},e.id)),(0,p.jsxs)(o.Muted,{children:["Collection only. Prices set by ",t.name,"."]}),$?(0,p.jsx)(u.MockPay,{visible:!0,onClose:()=>w(null),amount:$.price*O($.id),restaurantId:t.id,allowGiftCard:!1,title:`Buy ${$.name}`,onPaid:()=>{const e=m.useOwner.getState();e.setOwner({merch:e.merch.map(e=>e.id===$.id?{...e,stock:Math.max(0,e.stock-O($.id))}:e),merchOrders:[{id:`mo-${Date.now()}`,productId:$.id,qty:O($.id),customer:l.name,at:(0,j.ymd)(f),status:'new'},...e.merchOrders]}),C(`${O($.id)} \xd7 ${$.name}, ${(0,h.gbp)($.price*O($.id))}.`),w(null)}}):null]})}},1322,[837,30,34,102,1258,794,874,891,867,858,821,1259,1263,25]); +__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 j}});var n=_r(d[0]),t=_r(d[1]);_r(d[2]);var s=_r(d[3]),r=_r(d[4]),o=_r(d[5]),l=_r(d[6]),c=_r(d[7]),u=_r(d[8]),f=_r(d[9]),h=_r(d[10]);function j(){const{rid:o}=(0,t.useLocalSearchParams)(),l=(0,r.useRestaurant)(o);return n.LIVE_VENUE_BUILD||(0,f.guestServer)()?l?(0,h.jsx)(u.OffersLive,{slug:o,venue:l.name}):(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})}):(0,h.jsx)(x,{})}function x(){const{rid:n}=(0,t.useLocalSearchParams)(),u=(0,r.useRestaurant)(n),f=(0,r.useCustomer)(),j=(0,o.useOwner)(n=>n.offers);if(!u)return(0,h.jsx)(s.Screen,{title:"Not found",children:(0,h.jsx)(s.T,{children:"Restaurant not found."})});const x=!!f.marketingOptIn[u.id],b=j.filter(n=>n.live),p=b.filter(n=>'special'===n.kind),y=b.filter(n=>'offer'===n.kind);return(0,h.jsxs)(s.Screen,{title:"Specials & offers",subtitle:u.name,children:[(0,h.jsxs)(s.Card,{highlight:x?c.colours.ok:c.colours.gold,children:[(0,h.jsx)(s.Toggle,{label:`Send me offers from ${u.name}`,value:x,onChange:n=>r.repo.customers.update({marketingOptIn:{...f.marketingOptIn,[u.id]:n}})}),(0,h.jsx)(s.Muted,{children:x?'You can switch this off any time. We only use it for this restaurant.':'Off by default. Turn on to see member offers and get the occasional notification (max one a week). You can switch it off any time.'})]}),(0,h.jsx)(s.H2,{children:"Today's specials"}),p.length?p.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"gold",label:"Special"})]}),(0,h.jsx)(s.Muted,{children:n.body})]},n.id)):(0,h.jsx)(s.Muted,{children:"No specials on the board right now."}),(0,h.jsx)(s.H2,{children:"Member offers"}),x?y.length?y.map(n=>(0,h.jsxs)(s.Card,{children:[(0,h.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,h.jsx)(s.T,{weight:"semibold",style:{flex:1},children:n.title}),(0,h.jsx)(s.Badge,{kind:"ok",label:"Offer"})]}),(0,h.jsx)(s.Muted,{children:n.body}),n.until?(0,h.jsxs)(s.Muted,{children:["Until ",(0,l.niceDate)((0,l.parseYmd)(n.until))]}):null]},n.id)):(0,h.jsx)(s.Muted,{children:"No offers right now."}):(0,h.jsxs)(s.Banner,{kind:"info",children:["Turn on offers above to see ",y.length," member offer",1===y.length?'':'s',"."]}),(0,h.jsxs)(s.Muted,{children:["Offers are set by ",u.name,". Drinks promotions follow Scottish licensing rules. Demo: no notifications are sent."]})]})}},1323,[837,30,34,794,874,891,858,821,1284,1263,25]); +__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 j}});var r=_r(d[0]),n=_r(d[1]),s=_r(d[2]),t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),u=_r(d[6]),c=_r(d[7]),h=_r(d[8]),f=_r(d[9]);function j(){const{rid:s}=(0,n.useLocalSearchParams)(),o=(0,l.useRestaurant)(s);return r.LIVE_VENUE_BUILD||(0,h.guestServer)()?o?(0,f.jsx)(c.ReferLive,{slug:s,venue:o.name}):(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})}):(0,f.jsx)(x,{})}function x(){const{rid:r}=(0,n.useLocalSearchParams)(),c=(0,l.useRestaurant)(r),h=(0,l.useCustomer)(),j=(0,o.useOwner)(r=>r.referral),x=(0,o.useOwner)(r=>r.referrals),[p,w]=(0,s.useState)(!1);if(!c)return(0,f.jsx)(t.Screen,{title:"Not found",children:(0,f.jsx)(t.T,{children:"Restaurant not found."})});const b=x.filter(r=>r.referrer===h.name);return(0,f.jsxs)(t.Screen,{title:"Bring a friend",subtitle:c.name,children:[j.active?null:(0,f.jsxs)(t.Banner,{kind:"info",children:[c.name," isn't running referrals right now."]}),(0,f.jsxs)(t.Card,{highlight:u.colours.gold,children:[(0,f.jsxs)(t.H2,{children:["You get: ",j.giverReward]}),(0,f.jsxs)(t.T,{children:["Your friend gets: ",j.friendReward]}),(0,f.jsx)(t.Muted,{children:"When your friend makes their first paid visit or order."}),(0,f.jsx)(t.T,{size:30,weight:"bold",colour:u.colours.gold,center:!0,children:h.referralCode}),(0,f.jsx)(t.Button,{label:"Share my code",disabled:!j.active,onPress:()=>w(!0)}),p?(0,f.jsx)(t.Muted,{center:!0,children:"Demo: in the real app this opens your phone's share sheet. Nothing is sent from here."}):null]}),(0,f.jsxs)(t.Card,{children:[(0,f.jsx)(t.H2,{children:"Your referrals"}),b.length?b.map(r=>(0,f.jsxs)(t.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(t.T,{style:{flex:1},children:r.friend}),(0,f.jsx)(t.Badge,{kind:'rewarded'===r.status?'ok':'amber',label:r.status})]},r.id)):(0,f.jsx)(t.Muted,{children:"No referrals yet."})]}),(0,f.jsx)(t.Muted,{children:"One reward per new account, phone and card. Monthly cap applies. Rewards are on food, not drinks."})]})}},1324,[837,30,34,794,874,891,821,1284,1263,25]); +__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 h}});var t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),r=_r(d[4]),o=_r(d[5]),u=_r(d[6]),l=_r(d[7]),c=_r(d[8]);function h(){const{rid:h}=(0,t.useLocalSearchParams)(),x=(0,u.useRestaurant)(h),j=(0,u.useCustomer)(),b=(0,u.useWaitlist)(h),f=(0,u.useBookings)(h),w=(0,u.useOrders)(h),y=(0,u.useEvents)(h),p=(0,u.useNow)(15e3),[v,M]=(0,s.useState)(2),[P,S]=(0,s.useState)(j.name);if(!x)return(0,c.jsx)(n.Screen,{title:"Not found",children:(0,c.jsx)(n.T,{children:"Restaurant not found."})});const T=b.filter(t=>'waiting'===t.status||'notified'===t.status).sort((t,s)=>t.number-s.number),k=T.find(t=>t.customerId===j.id),B=(0,r.forecastToday)(x,f,w,y,p),C=B.nextHour?Math.min(1.6,Math.max(.8,B.nextHour.covers/(.75*x.settings.capacityPerHour))):1;if(k){const t=T.indexOf(k)+1;return(0,c.jsxs)(n.Screen,{title:"You\u2019re on the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{highlight:l.colours.gold,children:[(0,c.jsx)(n.Muted,{children:"Your queue number"}),(0,c.jsxs)(n.T,{size:56,weight:"bold",colour:l.colours.gold,children:["#",k.number]}),(0,c.jsx)(n.T,{children:1===t?'You\u2019re next':`${t-1} part${t-1==1?'y':'ies'} ahead of you`}),(0,c.jsxs)(n.T,{weight:"semibold",children:["Estimated wait: about ",(0,o.estimateWait)(t,x.settings.turnMins,C)," minutes"]}),(0,c.jsxs)(n.Muted,{children:["Estimate only \u2014 based on tables in use, typical turn times and today\u2019s forecast. Joined ",(0,a.minsBetween)(new Date(k.joinedAt),p)," min ago."]})]}),'notified'===k.status?(0,c.jsx)(n.Banner,{kind:"success",title:"Your table is ready!",children:"Please come to the door within 5 minutes to keep your table."}):(0,c.jsx)(n.Banner,{kind:"info",children:"Keep this page open to see when your table is ready. Text alerts are not connected."}),(0,c.jsx)(n.Button,{kind:"secondary",label:"Leave the waitlist",onPress:()=>u.repo.waitlist.setStatus(k.id,'removed')})]})}return(0,c.jsxs)(n.Screen,{title:"Join the waitlist",subtitle:x.name,children:[(0,c.jsxs)(n.Card,{children:[(0,c.jsxs)(n.H2,{children:[T.length," part",1===T.length?'y':'ies'," waiting"]}),(0,c.jsxs)(n.Muted,{children:["Estimated wait if you join now: about ",(0,o.estimateWait)(T.length+1,x.settings.turnMins,C)," minutes (estimate)."]})]}),(0,c.jsx)(n.Field,{label:"Name",value:P,onChangeText:S}),(0,c.jsxs)(n.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(n.T,{weight:"semibold",children:"Party size"}),(0,c.jsx)(n.Stepper,{value:v,onChange:M,min:1,max:12,label:"party size"})]}),(0,c.jsx)(n.Button,{label:"Join the queue",disabled:P.trim().length<2,onPress:()=>u.repo.waitlist.join(x.id,P,v,j.id),testID:"join-waitlist"}),(0,c.jsx)(n.Muted,{children:"Waitlist messages are service messages only \u2014 no marketing."})]})}},1325,[30,34,794,858,1161,1326,874,821,25]); +__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}},1326,[]); +__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 h}});var t=_r(_d[0]),l=_r(_d[1]),n=_r(_d[2]),s=e(_r(_d[3])),o=e(_r(_d[4])),a=_r(_d[5]),r=_r(_d[6]),d=_r(_d[7]),i=_r(_d[8]),u=_r(_d[9]);const c=e=>'bank-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"blue",label:"Scottish bank holiday"}):'school-holiday'===e.kind?(0,u.jsx)(a.Badge,{kind:"neutral",label:"School holiday"}):'occasion'===e.kind?(0,u.jsx)(a.Badge,{kind:"gold",label:"Key dining date"}):(0,u.jsx)(a.Badge,{kind:"ok",label:"Restaurant event"});function h(){const{rid:e}=(0,t.useLocalSearchParams)(),h=(0,d.useRestaurant)(e),x=(0,d.useEvents)(e),y=(0,d.useNow)(6e4),[j,f]=(0,n.useState)(()=>new Date(y.getFullYear(),y.getMonth(),1)),[b,k]=(0,n.useState)(null);if(!h)return(0,u.jsx)(a.Screen,{title:"Not found",children:(0,u.jsx)(a.T,{children:"Restaurant not found."})});const p=(new Date(j).getDay()+6)%7,w=new Date(j.getFullYear(),j.getMonth()+1,0).getDate(),M=[...Array(p).fill(null),...Array.from({length:w},(e,t)=>new Date(j.getFullYear(),j.getMonth(),t+1))];for(;M.length%7;)M.push(null);const D=e=>x.filter(t=>t.date===e),v=x.filter(e=>e.date>=(0,r.ymd)(y)).sort((e,t)=>e.date.localeCompare(t.date)),B=b?D(b):v.slice(0,20);return(0,u.jsxs)(a.Screen,{title:"What\u2019s on",subtitle:`${h.name} \xb7 holidays, key dates and events`,children:[(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"\u2039 Prev",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()-1,1))}),(0,u.jsxs)(a.H2,{children:[(0,r.monthLong)(j.getMonth())," ",j.getFullYear()]}),(0,u.jsx)(a.Button,{small:!0,kind:"ghost",label:"Next \u203a",onPress:()=>f(new Date(j.getFullYear(),j.getMonth()+1,1))})]}),(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,u.jsx)(a.T,{size:13,colour:i.colours.muted,style:{flex:1,textAlign:'center'},children:e},e))}),Array.from({length:M.length/7}).map((e,t)=>(0,u.jsx)(o.default,{style:{flexDirection:'row'},children:M.slice(7*t,7*t+7).map((e,t)=>{if(!e)return(0,u.jsx)(o.default,{style:{flex:1,height:44}},t);const l=(0,r.ymd)(e),n=D(l),d=l===(0,r.ymd)(y);return(0,u.jsxs)(s.default,{accessibilityLabel:`${l}${n.length?`, ${n.length} events`:''}`,onPress:()=>k(b===l?null:l),style:{flex:1,height:44,alignItems:'center',justifyContent:'center',borderRadius:8,backgroundColor:b===l?i.colours.goldTint:'transparent',borderWidth:d?1:0,borderColor:i.colours.gold},children:[(0,u.jsx)(a.T,{size:15,colour:n.length?i.colours.text:i.colours.muted,weight:n.length?'semibold':'regular',children:e.getDate()}),(0,u.jsx)(a.Row,{gap:2,children:n.slice(0,3).map(e=>(0,u.jsx)(o.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:'bank-holiday'===e.kind?i.colours.blue:'event'===e.kind?i.colours.ok:i.colours.gold}},e.id))})]},t)})},t))]}),(0,u.jsx)(a.H2,{children:b?(0,r.niceDateYear)((0,r.parseYmd)(b)):'Coming up'}),0===B.length?(0,u.jsx)(a.Muted,{children:"Nothing on this day."}):B.map(e=>(0,u.jsxs)(a.Card,{children:[(0,u.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(a.T,{center:!0,weight:"semibold",style:{width:'100%',flexBasis:'100%'},children:(0,l.holidayName)(e.title)}),c(e)]}),(0,u.jsxs)(a.Muted,{children:[(0,r.niceDateYear)((0,r.parseYmd)(e.date)),e.source?` \xb7 source: ${e.source}`:'']}),(0,u.jsx)(a.T,{size:15,children:e.description}),e.example?(0,u.jsx)(a.Badge,{kind:"amber",label:"EXAMPLE EVENT"}):null,e.date>=(0,r.ymd)(y)?(0,u.jsx)(a.Button,{small:!0,kind:"secondary",label:"Book for this date",onPress:()=>t.router.push({pathname:'/customer/[rid]/book',params:{rid:h.id,date:e.date}})}):null]},e.id)),(0,u.jsx)(a.Muted,{children:"Bank holidays from gov.uk (Scotland division). Easter Monday is not a Scottish bank holiday; local council holidays vary."})]})}},1327,[30,1101,34,402,102,794,858,874,821,25]); +__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 v}});var l=_r(d[0]),t=_r(d[1]),a=_r(d[2]),n=e(a),o=_r(d[3]),r=_r(d[4]),s=e(_r(d[5])),i=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),m=_r(d[10]),b=_r(d[11]),y=_r(d[12]),j=_r(d[13]),x=_r(d[14]),k=_r(d[15]),p=_r(d[16]),f=_r(d[17]);function v(){const e=(0,b.useBasket)(),v=(0,b.useRestaurant)(e.restaurantId??void 0),w=(0,b.useAllMenu)(e.restaurantId??void 0),C=(0,b.useCustomer)(),S=(0,b.useOrders)(v?.id),T=(0,b.useStore)(e=>e.setLineQty),B=(0,b.useStore)(e=>e.overrideLine),P=(0,b.useStore)(e=>e.startBasket),I=(0,b.useNow)(15e3),[O,$]=(0,a.useState)(null),[N,M]=(0,a.useState)(!1),[F,L]=(0,a.useState)(''),[z]=(0,a.useState)(()=>(0,r.startForm)()),[A,R]=(0,a.useState)(''),[Y,D]=(0,a.useState)(C.phone??''),[E,_]=(0,a.useState)(C.email??''),[q,H]=(0,a.useState)(C.name&&'Guest'!==C.name?C.name:''),[G,V]=(0,a.useState)(!1),K=(0,b.useOrderAtTable)(e.restaurantId??void 0),Q=(0,p.useTakeawayMenu)(l=>e.restaurantId?l.byVenue[e.restaurantId]:void 0);n.default.useEffect(()=>{K||'table'!==e.mode||b.useStore.setState(e=>({basket:{...e.basket,mode:'takeaway',tableNo:void 0}}))},[K,e.mode]);const[U,J]=(0,a.useState)(null),[W,X]=(0,a.useState)(!1),Z=(0,a.useMemo)(()=>(0,y.linesFromBasket)(e,w,C.allergies),[e,w,C.allergies]);if(!v||!e.lines.length)return(0,f.jsxs)(i.Screen,{title:"Your basket",children:[(0,f.jsx)(i.Muted,{children:"Your basket is empty."}),(0,f.jsx)(i.Button,{label:"Browse restaurants",onPress:()=>t.router.replace('/customer')})]});const ee=K&&'table'===e.mode,le=(0,h.takeawaySlots)(v,S,I),te=Z.reduce((e,l)=>e+l.unitPrice*l.qty,0),ae=Z.some(e=>e.contains.length&&!e.overridden),ne=e.lines.filter(e=>{const l=w.find(l=>l.id===e.itemId);return!l||l.soldOut||!l.signOff||!ee&&'on'!==(0,p.takeawayAvail)(l,Q)}),oe=!ee&&!O,re=!ee&&v.settings.takeawayPaused,se=(0,x.ukPhone)(Y),ie=q.trim().length>=2&&'guest'!==q.trim().toLowerCase(),de=ee||(0,p.takesCardTakeaway)(v,k.IS_ISOLATED_VENUE),ue=!G&&de&&!ae&&!ne.length&&N&&!oe&&!re&&(ee||ie&&se.ok&&(0,x.emailOk)(E)),ce=async()=>{V(!0);try{const e=await b.repo.orders.placeFromBasket({slotTime:ee?void 0:O,tip:0,notes:F,phone:ee?void 0:se.pretty,email:ee?void 0:E.trim()||void 0,customerName:ee?void 0:q.trim()});(0,r.rememberGuard)(e.id,(0,r.guardFor)({...z,hp:A})),t.router.replace(`/customer/order/${e.id}`)}finally{V(!1)}},he=e.lines.find(e=>e.key===U),me=he?Z[e.lines.indexOf(he)]:void 0;return(0,f.jsxs)(i.Screen,{title:"Your basket",subtitle:`${v.name} \xb7 ${ee?`${(0,l.tableNumbers)(e.tableNo)} (order at table)`:'Takeaway \u2014 collection'}`,footer:(0,f.jsxs)(s.default,{style:{gap:8},children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Subtotal"}),(0,f.jsx)(i.T,{weight:"bold",size:20,colour:j.colours.gold,children:(0,c.gbp)(te)})]}),de?ae?(0,f.jsx)(i.T,{size:14,colour:j.colours.red,children:"Resolve the blocked allergy item(s) before continuing."}):N?oe&&!re?(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Choose a collection time."}):ee||ie?ee||se.ok?null:(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your mobile number."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Add your name for the order."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Confirm your allergies to continue."}):(0,f.jsx)(i.T,{size:14,colour:j.colours.amber,children:"Online takeaway orders aren\u2019t available for this restaurant. Please ring them to order."}),ee?(0,f.jsx)(i.Button,{label:"Send order to the kitchen",disabled:!ue,onPress:()=>ce(),testID:"send-table-order"}):(0,f.jsx)(i.Button,{label:G?'Saving your order\u2026':`Continue to card payment \xb7 ${(0,c.gbp)(te)}`,disabled:!ue,onPress:()=>ce(),testID:"checkout"}),ee?null:(0,f.jsx)(i.Muted,{children:"You pay by card on the restaurant\u2019s secure checkout. Your order goes to the kitchen once it\u2019s paid. You have 15 minutes to pay."})]}),children:[(ee||e.tableNo,null),ee?(0,f.jsx)(i.Banner,{kind:"success",title:`${(0,l.tableNumbers)(e.tableNo)}`,children:"Ordered food goes to the kitchen straight away; you pay at the end (split the bill if you like)."}):null,v.fictional?null:(0,f.jsx)(i.AllergenNotice,{phone:v.phone}),Z.map((l,t)=>{const a=e.lines[t],n=l.contains.length&&!l.overridden;return(0,f.jsxs)(i.Card,{highlight:l.contains.length?j.colours.red:l.may.length?j.colours.amber:void 0,children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,f.jsxs)(s.default,{style:{flex:1,paddingRight:8},children:[(0,f.jsx)(i.T,{weight:"semibold",children:l.name}),l.choices.length?(0,f.jsx)(i.Muted,{children:l.choices.join(' \xb7 ')}):null,l.notes?(0,f.jsxs)(i.Muted,{children:["Note: ",l.notes]}):null]}),(0,f.jsx)(i.T,{weight:"semibold",children:(0,c.gbp)(l.unitPrice*l.qty)})]}),n?(0,f.jsxs)(i.Banner,{kind:"danger",title:`BLOCKED \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:[(0,f.jsx)(i.T,{size:14,colour:"#FFE3DF",children:`Conflicts with your declared ${C.allergies.filter(e=>l.contains.includes(e.allergen)).map(e=>`${(0,u.allergenLabel)(e.allergen)} (${(0,u.severityLabel)(e.severity)})`).join(', ')}.`}),(0,f.jsxs)(i.Row,{gap:8,style:{marginTop:6},children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Override\u2026",onPress:()=>{X(!1),J(a.key)}})]})]}):l.contains.length?(0,f.jsx)(i.Banner,{kind:"danger",title:`Allergy override recorded \u2014 contains ${l.contains.map(u.allergenLabel).join(', ')}`,children:"The kitchen will get an allergy alert that must be acknowledged, and staff will check with you at handover."}):null,l.may.length?(0,f.jsx)(i.Banner,{kind:"warn",title:`May contain ${l.may.map(u.allergenLabel).join(', ')}`,children:"Cross-contact risk (e.g. shared fryer). Please check with staff."}):null,ne.includes(a)?(0,f.jsx)(i.Badge,{kind:"amber",label:!ee&&Q&&w.find(e=>e.id===a.itemId)&&'sold-out'===(0,p.takeawayAvail)(w.find(e=>e.id===a.itemId),Q)?'Sold out \u2014 please remove':'Not available for takeaway \u2014 please remove'}):null,(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>T(a.key,0)}),(0,f.jsx)(i.Stepper,{value:a.qty,onChange:e=>T(a.key,e),min:1,label:l.name})]})]},a.key)}),(0,f.jsx)(i.Button,{kind:"ghost",label:"Add more items",onPress:()=>t.router.push(`/customer/${v.id}`)}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.H2,{children:["Collection time \u2014 ",(0,m.niceDate)(I)]}),re?(0,f.jsx)(i.Banner,{kind:"warn",title:"Takeaway paused",children:"The restaurant has paused takeaway slots for now. Please try again later or book a table."}):0===le.length?(0,f.jsx)(i.Banner,{kind:"warn",children:"No collection slots left today."}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(i.Muted,{children:["15-minute slots, max ",v.settings.slotCap," orders each so the kitchen isn\u2019t overloaded."]}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:le.slice(0,16).map(e=>(0,f.jsx)(i.Chip,{label:e.label,sub:e.full?'Full':e.cap-e.taken+" left",disabled:e.full,selected:O===e.time.toISOString(),onPress:()=>$(e.time.toISOString())},e.label))})]})]}),(0,f.jsxs)(i.Card,{highlight:N?void 0:j.colours.amber,children:[(0,f.jsx)(i.H2,{children:"Confirm allergies for this order"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:C.allergies.length?C.allergies.map(e=>(0,f.jsx)(i.Badge,{kind:"red",label:`${(0,u.allergenLabel)(e.allergen)} \u2014 ${(0,u.severityLabel)(e.severity)}`},e.allergen)):(0,f.jsx)(i.Muted,{children:"No allergies declared on your profile."})}),(0,f.jsx)(i.Toggle,{label:C.allergies.length?'Yes, these are correct for everyone this order is for':'I confirm no one in this order has a food allergy',value:N,onChange:M}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Edit allergies in profile",onPress:()=>t.router.push('/customer/profile')})]}),ee?null:(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.H2,{children:"Your details"}),(0,f.jsx)(i.Field,{testID:"order-name",label:"Name for the order",value:q,onChangeText:H,autoComplete:"name",placeholder:"e.g. Sam Smith"}),q&&!ie?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"Please add your name."}):null,(0,f.jsx)(i.Field,{testID:"order-phone",label:"Mobile number (needed for collection)",value:Y,onChangeText:D,keyboardType:"phone-pad",autoComplete:"tel",placeholder:"e.g. 07700 900123"}),!se.ok&&Y?(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:se.error}):null,(0,f.jsx)(i.Field,{label:"Email (optional)",value:E,onChangeText:_,keyboardType:"email-address",autoCapitalize:"none",placeholder:"you@example.com"}),(0,x.emailOk)(E)?null:(0,f.jsx)(i.T,{size:13,colour:j.colours.amber,children:"That email doesn\u2019t look quite right. Check it, or leave it blank."}),(0,f.jsx)(i.Muted,{children:"Your order confirmation and collection time are shown here. Text messages are not connected."})]}),(0,f.jsx)(i.Field,{label:"Order notes (optional)",value:F,onChangeText:L,placeholder:"e.g. cutlery please"}),ee?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Switch to takeaway instead",onPress:()=>P(v.id,'takeaway')}):null,(0,f.jsxs)(i.Sheet,{visible:!!he,onClose:()=>J(null),title:"Allergy override",children:[me?(0,f.jsx)(i.Banner,{kind:"danger",title:`${me.name} contains ${me.contains.map(u.allergenLabel).join(', ')}`,children:"Only continue if this item is for someone without this allergy, or you have spoken to staff."}):null,(0,f.jsx)(i.Toggle,{label:"I understand and want to add it anyway",value:W,onChange:X}),(0,f.jsx)(i.Button,{kind:"danger",disabled:!W,label:"Confirm override",onPress:()=>{he&&me&&B(he.key,me.contains),J(null)}})]}),(0,f.jsx)(o.Honeypot,{value:A,onChange:R})]})}},1328,[860,30,34,1248,1002,102,794,861,867,1131,858,874,831,821,864,5,988,25]); +__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 f}});var e=_r(d[0]);_r(d[1]);var s,r=_r(d[2]),n=(s=r)&&s.__esModule?s:{default:s},t=_r(d[3]),l=_r(d[4]),o=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),j=_r(d[10]),x=_r(d[11]);function f(){const s=(0,u.useStore)(e=>e.restaurants),r=(0,u.useCustomer)(),f=(0,u.useNow)(3e4);return(0,x.jsxs)(l.Screen,{title:"Restaurants",subtitle:"Book, order and pay at local restaurants",right:(0,x.jsxs)(l.Row,{children:[(0,x.jsx)(t.BasketButton,{}),(0,x.jsx)(l.Button,{small:!0,kind:"ghost",label:"Profile",onPress:()=>e.router.push('/customer/profile')})]}),children:[(0,x.jsxs)(l.Card,{onPress:()=>e.router.push('/customer/profile'),children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.T,{weight:"semibold",children:r.name?`Hello, ${r.name.split(' ')[0]}`:'Add your profile'}),(0,x.jsx)(l.Muted,{children:"Edit profile \u203a"})]}),(0,x.jsx)(l.Muted,{children:"Your allergies (stored once, confirmed on every order and booking):"}),(0,x.jsx)(l.Row,{wrap:!0,gap:6,children:r.allergies.length?r.allergies.map(e=>(0,x.jsx)(l.Badge,{kind:"red",label:`${(0,o.allergenLabel)(e.allergen)} \u2014 ${(0,o.severityLabel)(e.severity)}`},e.allergen)):(0,x.jsx)(l.Muted,{children:"None declared"})})]}),s.map(s=>{const r=(0,a.hoursFor)(s,f);return(0,x.jsxs)(l.Card,{onPress:()=>e.router.push(`/customer/${s.id}`),highlight:s.id===j.VENUE_RID?c.colours.gold:void 0,children:[(0,x.jsxs)(l.Row,{style:{justifyContent:'space-between'},children:[(0,x.jsx)(l.H2,{style:{flex:1},children:s.name}),s.fictional?(0,x.jsx)(l.Badge,{kind:"amber",label:"FICTIONAL DEMO"}):(0,x.jsx)(l.Badge,{kind:"gold",label:"VENUE"})]}),(0,x.jsx)(l.Muted,{children:s.tagline}),(0,x.jsx)(l.Muted,{children:s.location}),(0,x.jsx)(l.T,{size:14,colour:r?c.colours.ok:c.colours.amber,children:r?`Kitchen today ${(0,a.kitchenHoursOn)(s,f)[0]}\u2013${(0,a.kitchenHoursOn)(s,f)[1]}`:'Kitchen closed today (hours not listed)'})]},s.id)}),(0,x.jsx)(l.Banner,{kind:"info",children:"Each venue uses only its own saved menu, cards and booking details."}),(0,x.jsx)(h.LauncherLine,{}),(0,x.jsx)(n.default,{style:{height:8}})]})}},1329,[30,34,102,1254,794,861,878,874,821,1281,5,25]); +__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 f}});var e,t=_r(d[0]),l=_r(d[1]),s=_r(d[2]),r=_r(d[3]),n=(e=r)&&e.__esModule?e:{default:e},o=_r(d[4]),i=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),p=_r(d[9]),y=_r(d[10]),b=_r(d[11]),j=_r(d[12]);const x=[['new','Placed'],['acknowledged','Accepted'],['preparing','Cooking'],['ready','Ready to collect'],['collected','Collected']],w=[['new','Sent'],['acknowledged','Accepted'],['preparing','Cooking'],['served','Food out'],['closed','Paid']];function f(){const{oid:e}=(0,l.useLocalSearchParams)(),r=(0,p.useOrder)(e),f=(0,p.useRestaurant)(r?.restaurantId),[k,T]=(0,s.useState)(0),[S,C]=(0,s.useState)(''),[v,M]=(0,s.useState)(!1),[P,A]=(0,s.useState)(0),[R,$]=(0,s.useState)(r?.split?.ways??1);if(!r||!f)return(0,j.jsx)(i.Screen,{title:"Order",children:(0,j.jsx)(i.T,{children:"Order not found."})});const O='takeaway'===r.type?x:w,I=Math.max(0,O.findIndex(([e])=>e===r.status)),N=Math.round(r.subtotal*P/100),B='table'===r.type?r.subtotal+(r.split?r.tip:N):r.total,_=B-r.paid,H=r.split?.ways??R,D=r.split?.paidShares??0,F=Math.ceil(B/H),q='collected'===r.status||'closed'===r.status;return(0,j.jsxs)(i.Screen,{title:`Order ${r.ref}`,subtitle:`${f.name} \xb7 ${'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Collection at ${r.slotTime?(0,h.hm)(new Date(r.slotTime)):'\u2014'}`}`,children:['takeaway'===r.type?(0,j.jsx)(b.TakeawayPayCard,{o:r,phone:f.phone}):null,'takeaway'===r.type&&'awaiting_payment'!==r.status&&'cancelled'!==r.status?(0,j.jsx)(i.Banner,{kind:"success",title:'ready'===r.status?'Your order is ready!':'Order placed',children:'ready'===r.status?'Head to the bar and give your order number. Staff will check allergies with you at handover.':`Show order number ${r.ref} at the bar when you arrive.`}):null,'awaiting_payment'===r.status||'cancelled'===r.status?null:(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Status"}),O.map(([e,t],l)=>(0,j.jsxs)(i.Row,{gap:10,children:[(0,j.jsx)(n.default,{style:{width:22,height:22,borderRadius:11,backgroundColor:l<=I?y.colours.gold:y.colours.surface2,borderWidth:1,borderColor:y.colours.gold}}),(0,j.jsx)(i.T,{weight:l===I?'semibold':'regular',colour:l<=I?y.colours.text:y.colours.muted,children:t})]},e)),r.allergyAck?(0,j.jsxs)(i.Muted,{children:["Kitchen signed off your allergies (",r.allergyAck.by,", ",(0,h.hm)(new Date(r.allergyAck.at)),")"]}):r.allergies.length?(0,j.jsx)(i.Muted,{children:"Waiting for the kitchen to sign off your allergies\u2026"}):null,'takeaway'!==r.type||q?null:(0,j.jsxs)(i.Row,{gap:8,children:[(0,j.jsx)(i.Button,{small:!0,kind:'on-my-way'===r.customerSignal?'primary':'secondary',label:"On my way",onPress:()=>p.repo.orders.customerSignal(r.id,'on-my-way')}),(0,j.jsx)(i.Button,{small:!0,kind:'here'===r.customerSignal?'primary':'secondary',label:"I\u2019m here",onPress:()=>p.repo.orders.customerSignal(r.id,'here')})]})]}),(0,j.jsxs)(i.Card,{children:[(0,j.jsx)(i.H2,{children:"Items"}),r.lines.map((e,t)=>(0,j.jsxs)(n.default,{children:[(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(i.T,{style:{flex:1},children:[e.qty,"\xd7 ",e.name]}),(0,j.jsx)(i.T,{children:(0,u.gbp)(e.unitPrice*e.qty)})]}),e.choices.length?(0,j.jsx)(i.Muted,{children:e.choices.join(' \xb7 ')}):null,e.overridden?(0,j.jsx)(i.Badge,{kind:"red",label:`Allergy override: ${e.contains.map(c.allergenLabel).join(', ')}`}):null]},t)),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Subtotal"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.subtotal)})]}),r.giftCardApplied?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Of which gift card"}),(0,j.jsxs)(i.T,{colour:y.colours.ok,children:["\u2212",(0,u.gbp)(r.giftCardApplied)]})]}):null,r.tip?(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.Muted,{children:"Tip"}),(0,j.jsx)(i.T,{children:(0,u.gbp)(r.tip)})]}):null,(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Paid (test, no real money)"}),(0,j.jsx)(i.T,{weight:"semibold",colour:y.colours.gold,children:(0,u.gbp)(r.paid)})]})]}),'table'===r.type&&'closed'!==r.status&&'cancelled'!==r.status?(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsxs)(i.H2,{children:["Your bill \u2014 ",(0,t.tableNumbers)(r.tableNo)]}),r.split?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(B)," \xb7 split ",H," way",H>1?'s':''," \xb7 ",(0,u.gbp)(F)," each"]}),(0,j.jsxs)(i.T,{children:["Shares paid: ",D," of ",H," \xb7 remaining ",(0,u.gbp)(_)]}),(0,j.jsx)(i.Muted,{children:"Pay with a member of staff at your table. Online card payment for the table bill isn\u2019t set up."})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Add a tip?"}),(0,j.jsx)(i.Row,{wrap:!0,children:[0,10,12.5,15].map(e=>(0,j.jsx)(i.Chip,{label:e?`${e}%`:'No tip',selected:P===e,onPress:()=>A(e)},e))}),(0,j.jsx)(i.Muted,{children:"Tips go to staff under the restaurant\u2019s tipping policy (Employment (Allocation of Tips) Act 2023)."}),(0,j.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(i.T,{weight:"semibold",children:"Split evenly between"}),(0,j.jsx)(i.Stepper,{value:R,onChange:$,min:1,max:8,label:"people"})]}),(0,j.jsxs)(i.T,{children:["Total ",(0,u.gbp)(r.subtotal+N),R>1?` \xb7 ${(0,u.gbp)(Math.ceil((r.subtotal+N)/R))} each`:'']}),(0,j.jsx)(i.Button,{label:"Get the bill",onPress:()=>p.repo.orders.setSplit(r.id,R,N),testID:"get-bill"})]})]}):null,!q||r.rated||v?null:(0,j.jsxs)(i.Card,{highlight:y.colours.gold,children:[(0,j.jsx)(i.H2,{children:"How was everything?"}),(0,j.jsxs)(i.Muted,{children:["One tap \u2014 this goes privately to ",f.name," only, never published."]}),(0,j.jsx)(o.Stars,{value:k,onChange:T}),k?(0,j.jsx)(i.Field,{label:"Anything to add? (optional)",value:S,onChangeText:C}):null,(0,j.jsx)(i.Button,{label:"Send feedback",disabled:!k,onPress:()=>{p.repo.feedback.add({restaurantId:f.id,orderId:r.id,customerId:r.customerId,customerName:r.customerName,stars:k,comment:S,context:'table'===r.type?`${(0,t.tableNumbers)(r.tableNo)}`:`Takeaway ${r.ref}`}),M(!0)},testID:"send-rating"})]}),v||r.rated?(0,j.jsx)(i.Banner,{kind:"success",children:"Thanks \u2014 your feedback went privately to the restaurant."}):null,q?(0,j.jsx)(i.Button,{kind:"secondary",label:"View stamp card",onPress:()=>l.router.push(`/customer/${f.id}/loyalty`)}):null]})}},1330,[860,30,34,102,1256,794,861,867,858,874,821,1331,25]); +__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.TakeawayPayCard=function({o:e,phone:y}){const[f,k]=(0,n.useState)(Date.now()),[w,x]=(0,n.useState)(!1),[j,b]=(0,n.useState)(''),[P,v]=(0,n.useState)(null),_=(0,n.useRef)(!1),B=(0,c.payView)(e,f);(0,n.useEffect)(()=>{const e=setInterval(()=>k(Date.now()),1e3);return()=>clearInterval(e)},[]);const T='pay'===B.kind||'expired'===B.kind&&_.current&&'awaiting_payment'===e.status;(0,n.useEffect)(()=>{if(!T||!_.current)return;const n=setInterval(()=>{(0,h.checkPaid)(e.id)},1e4),r=t.default.addEventListener('change',n=>{'active'===n&&(0,h.checkPaid)(e.id)});return()=>{clearInterval(n),r.remove()}},[T,e.id]);if('none'===B.kind)return null;if('sending'===B.kind)return(0,p.jsx)(s.Banner,{kind:"warn",title:"Saving your order\u2026",children:"Sending it to the restaurant. Card payment opens in a moment."});if('refused'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"danger",title:"The restaurant couldn\u2019t take this order",children:[(0,p.jsx)(s.T,{size:14,colour:"#FFE3DF",children:`${B.reason} Nothing has been charged.`}),(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Back to the menu",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)})]});if('paid'===B.kind)return(0,p.jsx)(s.Banner,{kind:"success",title:`Paid ${(0,l.gbp)(B.amount)} by card`,children:B.late?'Your payment came in after the time ran out. The restaurant has your order and will contact you if the collection time needs to change.':'Your order has gone to the kitchen.'});if('expired'===B.kind)return(0,p.jsxs)(s.Banner,{kind:"warn",title:'awaiting_payment'===e.status?'Checking your payment\u2026':'Time ran out: order not sent',children:[(0,p.jsx)(s.T,{size:14,children:'awaiting_payment'===e.status?'We\u2019re checking with the payment page. If you paid, your order will show as paid shortly.':`Nothing has been charged. You can order again${y?` or ring ${y}`:''}.`}),'awaiting_payment'!==e.status?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Order again",onPress:()=>o.router.replace(`/customer/${e.restaurantId}`)}):null]});return(0,p.jsxs)(s.Card,{highlight:u.colours.gold,children:[(0,p.jsx)(s.H2,{children:"Pay to send your order"}),(0,p.jsxs)(s.T,{children:["Your order goes to the kitchen once it\u2019s paid. Time left to pay: ",(0,p.jsx)(s.T,{weight:"bold",colour:B.secondsLeft<120?u.colours.red:u.colours.gold,children:(0,c.mmss)(B.secondsLeft)})]}),(0,p.jsx)(s.Button,{label:w?'Opening the payment page\u2026':`Pay ${(0,l.gbp)(e.total)} by card`,disabled:w||B.secondsLeft<120,onPress:async()=>{x(!0),b('');const n='undefined'!=typeof window?window.open('','_blank'):null,t=await(0,h.getPayLink)(e.id);if(x(!1),!t.ok)return n?.close(),void b(t.message);if(v(t.url),_.current=!0,n)try{return void(n.location.href=t.url)}catch{}},testID:"pay-card"}),B.secondsLeft<120?(0,p.jsx)(s.Muted,{children:"Not enough time left to pay. Wait for this order to expire, then order again."}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"secondary",label:"Open the payment page again",onPress:()=>{'undefined'!=typeof window?window.open(P,'_blank'):r.default.openURL(P)}}):null,P?(0,p.jsx)(s.Button,{small:!0,kind:"ghost",label:"I\u2019ve paid: check now",onPress:()=>{(0,h.checkPaid)(e.id)}}):null,j?(0,p.jsx)(s.T,{size:14,colour:u.colours.red,children:j}):null,(0,p.jsx)(s.Muted,{children:"Secure card payment on the restaurant\u2019s website. Apple Pay and Google Pay may be offered there."})]})};var n=_r(d[0]),t=e(_r(d[1])),r=e(_r(d[2]));_r(d[3]);var o=_r(d[4]),s=_r(d[5]),l=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10])},1331,[34,371,379,236,30,794,867,821,988,1332,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"PAY_OFF",{enumerable:!0,get:function(){return o}}),e.getPayLink=async function(u){try{if(!await(0,n.guestSession)())return{ok:!1,message:'Can\u2019t reach the restaurant. Check your signal and try again.'};const{data:c,error:y}=await(0,t.getSupabase)().functions.invoke('takeaway-pay',{body:{order_id:u}}),f=await s(c,y);return f&&'string'==typeof f.url&&f.url.startsWith('https://')?{ok:!0,url:f.url,expiresAt:String(f.expiresAt??''),amountPence:Number(f.amountPence??0)}:{ok:!1,message:'string'==typeof f?.error?f.error:o}}catch{return{ok:!1,message:o}}},e.checkPaid=async function(o){try{const{data:u,error:c}=await(0,t.getSupabase)().functions.invoke('takeaway-pay-check',{body:{order_id:o}}),y=await s(u,c);return(0,n.nudgeGuestSync)(),y?.off?'off':String(y?.state??'unknown')}catch{return'unknown'}};var t=r(d[0]),n=r(d[1]);const o='Card payment isn\u2019t available right now. Nothing has been charged. Please ring the restaurant.';async function s(t,n){if(t&&'object'==typeof t)return t;const o=n?.context;try{const t=o?.json?await o.json():null;return t&&'object'==typeof t?t:null}catch{return null}}},1332,[933,987]); +__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 y}});var e=_r(d[0]),r=_r(d[1]),s=_r(d[2]);_r(d[3]);var t,l=_r(d[4]),n=(t=l)&&t.__esModule?t:{default:t},a=_r(d[5]),o=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),b=_r(d[11]);function y(){const t=(0,h.useCustomer)(),l=(0,h.useStore)((0,p.useShallow)(e=>e.orders.filter(r=>r.customerId===e.customer.id))),y=(0,h.useStore)((0,p.useShallow)(e=>e.bookings.filter(r=>r.customerId===e.customer.id))),x=(0,h.useStore)(e=>e.restaurants),j=e=>x.find(r=>r.id===e)?.name??e;return(0,b.jsxs)(a.Screen,{title:"Your account",subtitle:"One CoverCharge account for every restaurant",children:[(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.Field,{label:"Name",value:t.name,onChangeText:e=>h.repo.customers.update({name:e})}),(0,b.jsx)(a.Field,{label:"Email",value:t.email,keyboardType:"email-address",onChangeText:e=>h.repo.customers.update({email:e})}),(0,b.jsx)(a.Field,{label:"Mobile",value:t.phone,keyboardType:"phone-pad",onChangeText:e=>h.repo.customers.update({phone:e})}),(0,b.jsx)(a.Muted,{children:(0,r.guestServer)()?'Your bring-a-friend code is on each restaurant\u2019s stamp card.':`Referral code: ${t.referralCode}`})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Allergies & severity"}),(0,b.jsx)(a.Muted,{children:"Stored once and shared with a restaurant only when you order or book there. You confirm them on every order, table session and booking."}),(0,b.jsx)(a.Toggle,{label:"I consent to CoverCharge storing my allergy information (health data, UK GDPR)",value:t.allergyConsent,onChange:e=>h.repo.customers.update({allergyConsent:e})}),t.allergyConsent?null:(0,b.jsx)(a.Banner,{kind:"warn",children:"Without consent your allergies won\u2019t be stored \u2014 tell staff directly."}),o.ALLERGENS.map(e=>{const r=t.allergies.find(r=>r.allergen===e.id);return(0,b.jsxs)(n.default,{style:{gap:6,paddingVertical:6},children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsx)(a.T,{weight:r?'semibold':'regular',children:e.label}),r?(0,b.jsx)(a.Badge,{kind:"red",label:"Declared"}):null]}),(0,b.jsxs)(a.Row,{wrap:!0,gap:6,children:[(0,b.jsx)(a.Chip,{label:"None",selected:!r,onPress:()=>h.repo.customers.setAllergy(e.id,null),disabled:!t.allergyConsent&&!r}),o.SEVERITIES.map(s=>(0,b.jsx)(a.Chip,{label:s.label,selected:r?.severity===s.id,disabled:!t.allergyConsent,onPress:()=>h.repo.customers.setAllergy(e.id,s.id)},s.id))]})]},e.id)})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your orders"}),l.length?l.map(r=>(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{style:{flex:1},children:[r.ref," \xb7 ",j(r.restaurantId)," \xb7 ",'table'===r.type?`${(0,e.tableNumbers)(r.tableNo)}`:'Takeaway']}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:`${r.status} \xb7 ${(0,u.gbp)(r.subtotal+r.tip)}`,onPress:()=>s.router.push(`/customer/order/${r.id}`)})]},r.id)):(0,b.jsx)(a.Muted,{children:"No orders yet."})]}),(0,b.jsxs)(a.Card,{children:[(0,b.jsx)(a.H2,{children:"Your bookings"}),y.length?y.map(e=>(0,b.jsxs)(a.T,{children:[e.ref," \xb7 ",j(e.restaurantId)," \xb7 ",(0,c.niceDate)((0,c.parseYmd)(e.date))," ",e.time," \xb7 ",e.partySize," people \xb7 ",e.status]},e.id)):(0,b.jsx)(a.Muted,{children:"No bookings yet."})]}),(0,b.jsx)(a.Muted,{children:"Account deletion and data export would live here (Apple 5.1.1(v); Google web deletion link)."})]})}},1333,[860,1263,30,34,102,794,861,867,858,874,879,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1334,[30,34,872,25]); +__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 f}});var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),u=_r(d[4]),c=_r(d[5]),s=_r(d[6]),l=_r(d[7]);function f(){const{n:f,r:b}=(0,r.useLocalSearchParams)(),E=(0,u.useStore)(t=>t.startBasket),[_,h]=(0,n.useState)(!1),S=b??c.VENUE_RID,j=(0,u.useOrderAtTable)(S),I=(0,s.guestServer)();return(0,n.useEffect)(()=>{t.LIVE_VENUE_BUILD||I||(j&&E(S,'table',String(f)),h(!0))},[S,f,j,I]),t.LIVE_VENUE_BUILD||I?(0,l.jsx)(o.Screen,{title:"Order at the table",children:(0,l.jsx)(o.Banner,{kind:"demo",title:"Scan the code on your table",children:"To order from your table, scan the QR code printed on it. Or order at the bar."})}):_?(0,l.jsx)(r.Redirect,{href:`/customer/${S}`}):null}},1335,[837,30,34,794,874,5,1263,25]); +__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]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]);function u(){const{token:u}=(0,t.useLocalSearchParams)(),h=(0,c.cleanToken)(u);return h?(0,s.guestServer)()?(0,l.jsx)(o.TableOrderLive,{token:h}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"demo",title:"Not connected",children:"This preview isn't connected to a venue, so table orders can't be sent from here."})}):(0,l.jsx)(n.Screen,{title:"Order at the table",children:(0,l.jsx)(n.Banner,{kind:"warn",title:"This code isn't working",children:"Please scan the QR code on your table again, or ask a member of staff."})})}},1336,[30,34,794,1337,1175,1263,25]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderLive=function({token:e}){const[s,m]=(0,l.useState)(null),[x,y]=(0,l.useState)(null),[j,f]=(0,l.useState)([]),[k,w]=(0,l.useState)(null),T=(0,h.useCustomer)(),[C,S]=(0,l.useState)(()=>(T?.allergies??[]).map(e=>e.allergen)),[v,O]=(0,l.useState)(''),[P,R]=(0,l.useState)(''),[I,M]=(0,l.useState)(''),[L,N]=(0,l.useState)(!1),[$,A]=(0,l.useState)(null),[B,D]=(0,l.useState)([]),q=(0,l.useCallback)(async()=>{try{m(await(0,c.tablePublic)(e)),y(null)}catch(e){y((0,d.tableOrderError)(e,'menu'))}},[e]),_=(0,l.useCallback)(async()=>{try{D(await(0,c.myTableOrders)(e))}catch{}},[e]);(0,l.useEffect)(()=>{q(),_();const e=setInterval(()=>{_(),q()},8e3);return()=>clearInterval(e)},[q,_]);const W=s?.menu??[];(0,l.useEffect)(()=>{f(e=>e.filter(e=>W.some(t=>t.id===e.id&&!t.soldOut)))},[s]);const E=(0,l.useMemo)(()=>{const e=new Map;for(const t of W)e.set(t.section,[...e.get(t.section)??[],t]);return[...e.entries()]},[s]),Y=(0,d.cartTotal)(j,W),z='yes'===k?C.map(e=>({allergen:e,severity:T?.allergies?.find(t=>t.allergen===e)?.severity??'allergy'})):[],G=(0,d.allergyClashes)(j,W,z.map(e=>e.allergen)),V=e=>j.find(t=>t.id===e)?.qty??0,F=(e,t)=>f(n=>t<=0?n.filter(t=>t.id!==e):n.some(t=>t.id===e)?n.map(n=>n.id===e?{...n,qty:t}:n):[...n,{id:e,qty:t,note:''}]),H=(e,t)=>f(n=>n.map(n=>n.id===e?{...n,note:t}:n)),J=async()=>{N(!0),A(null);try{const t=await(0,c.sendTableOrder)(e,j,{note:I,name:v,phone:P,allergies:z});f([]),M(''),A({kind:'success',text:t.held?`Order ${t.ref} sent. A member of staff will check it, then it goes to the kitchen.`:`Order ${t.ref} sent to the kitchen.`}),_()}catch(e){A({kind:'warn',text:(0,d.tableOrderError)(e,'send')}),q()}finally{N(!1)}};if(x)return(0,p.jsxs)(o.Screen,{title:"Order at the table",children:[(0,p.jsx)(o.Banner,{kind:"warn",title:"Couldn't open the menu",children:x}),(0,p.jsx)(o.Button,{label:"Try again",onPress:()=>{q()}})]});if(!s)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Muted,{children:"Opening the menu\u2026"})});if(!s.ok)return(0,p.jsx)(o.Screen,{title:"Order at the table",children:(0,p.jsx)(o.Banner,{kind:"warn",title:"This code isn't working",children:s.reason??'Please ask a member of staff.'})});const K=s.open&&j.length>0&&null!==k&&('none'===k||C.length>0)&&(0,d.nameOk)(v)&&(0,d.phoneOk)(P)&&!L,Q=s.askServer??[],U=[...new Set(Q.map(e=>e.section))],X=L?'Sending\u2026':j.length?null===k?'Answer the allergy question':(0,d.nameOk)(v)?(0,d.phoneOk)(P)?`Send order to the kitchen (${(0,i.gbp)(Y)})`:'Check the phone number':'Add your name to send':'Add a dish to order';return(0,p.jsxs)(o.Screen,{title:`Table ${(0,n.tableNumbers)(s.table)}`,subtitle:s.venueName,footer:s.open?(0,p.jsx)(o.Button,{label:X,disabled:!K,onPress:()=>{J()},testID:"send-table-order-live"}):void 0,children:[(0,p.jsxs)(o.Muted,{center:!0,children:["Tip: add dishes, answer the allergy question, add your name, then send. Staff bring it to table ",(0,n.tableNumbers)(s.table),". ",d.PAY_WORDS]}),s.tip?(0,p.jsx)(o.Banner,{kind:"demo",children:s.tip}):null,s.open?null:(0,p.jsx)(o.Banner,{kind:"warn",title:"Not taking table orders right now",children:s.reason}),s.open&&s.staffAccept&&!B.some(e=>e.accepted)?(0,p.jsx)(o.Muted,{children:"The first order from your phone is checked by a member of staff before it goes to the kitchen."}):null,$?(0,p.jsx)(o.Banner,{kind:$.kind,children:$.text}):null,B.length?(0,p.jsx)(r.default,{testID:"my-table-orders",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Your orders at this table"}),B.map(e=>(0,p.jsxs)(r.default,{style:{gap:2,paddingVertical:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{children:e.ref}),(0,p.jsx)(o.T,{size:13,colour:'cancelled'===e.status?u.colours.amber:u.colours.gold,children:(0,d.guestStatusWords)(e)})]}),(0,p.jsxs)(o.Muted,{children:[e.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",(0,i.gbp)(e.totalPence)," to pay at the bar or with the server"]})]},e.id))]})}):null,s.open?E.map(([e,t])=>(0,p.jsxs)(r.default,{style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,p.jsxs)(r.default,{style:{flex:1,gap:2},children:[(0,p.jsx)(o.T,{weight:"semibold",children:e.name}),e.description?(0,p.jsx)(o.Muted,{children:e.description}):null,(0,p.jsxs)(o.T,{size:13,colour:u.colours.muted,children:[e.allergens.length?`Contains: ${e.allergens.map(a.allergenLabel).join(', ')}`:'No allergens listed: ask staff if unsure',e.mayContain.length?` \xb7 May contain: ${e.mayContain.map(a.allergenLabel).join(', ')}`:'']})]}),(0,p.jsx)(o.T,{weight:"semibold",colour:u.colours.gold,children:(0,i.gbp)(e.pricePence)})]}),e.soldOut?(0,p.jsx)(o.Badge,{kind:"amber",label:"Sold out today"}):V(e.id)?(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.Stepper,{value:V(e.id),min:0,max:20,onChange:t=>F(e.id,t),label:e.name}),(0,p.jsx)(o.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>F(e.id,0)})]}):(0,p.jsx)(o.Button,{small:!0,kind:"secondary",label:"Add",accessibilityLabel:`Add ${e.name}`,onPress:()=>F(e.id,1)})]},e.id))]},e)):null,s.open&&!W.length?(0,p.jsx)(o.Banner,{kind:"demo",title:"No dishes to order from your phone yet",children:"The kitchen is still checking the allergens on the menu. Please order with your server or at the bar."}):null,s.open&&Q.length?(0,p.jsxs)(r.default,{testID:"table-ask-server",style:{gap:8},children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:u.colours.gold,accessibilityRole:"header",children:W.length?'Also on the menu':'On the menu'}),(0,p.jsx)(o.Muted,{center:!0,children:"Ask your server for these. They can't be ordered from your phone yet, while the kitchen checks their allergens."}),U.map(e=>(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:e}),Q.filter(t=>t.section===e).map((e,t)=>(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{style:{flex:1},children:e.name}),(0,p.jsx)(o.T,{colour:u.colours.muted,children:(0,i.gbp)(e.pricePence)})]},`${e.name}-${t}`))]},e))]}):null,s.open&&j.length?(0,p.jsx)(r.default,{testID:"table-cart",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Review your order"}),j.map(e=>{const n=W.find(t=>t.id===e.id);return(0,p.jsxs)(r.default,{style:{gap:4},children:[(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsxs)(o.T,{children:[e.qty,"\xd7 ",n?.name]}),(0,p.jsx)(o.T,{children:(0,i.gbp)(e.qty*(n?.pricePence??0))})]}),(0,p.jsx)(t.TextInput,{style:b,value:e.note,onChangeText:t=>H(e.id,t),placeholder:"Note for the kitchen (optional), e.g. no onions",placeholderTextColor:u.colours.muted,maxLength:140,accessibilityLabel:`Note for ${n?.name}`,testID:`table-note-${e.id}`})]},e.id)}),(0,p.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,p.jsx)(o.T,{weight:"semibold",children:"Total"}),(0,p.jsx)(o.T,{weight:"semibold",children:(0,i.gbp)(Y)})]})]})}):null,s.open?(0,p.jsx)(r.default,{testID:"table-allergy",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Does anyone at the table have a food allergy?"}),(0,p.jsx)(o.Muted,{center:!0,children:"We ask everyone, so the kitchen can keep you safe."}),(0,p.jsxs)(o.Row,{gap:8,style:{justifyContent:'center'},children:[(0,p.jsx)(o.Chip,{label:"No allergies",selected:'none'===k,onPress:()=>w('none')}),(0,p.jsx)(o.Chip,{label:"Yes, allergies",selected:'yes'===k,onPress:()=>w('yes')})]}),'yes'===k?(0,p.jsx)(o.Row,{wrap:!0,gap:6,children:a.ALLERGENS.map(e=>(0,p.jsx)(o.Chip,{label:e.short,selected:C.includes(e.id),onPress:()=>S(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},e.id))}):null,G.length?(0,p.jsxs)(o.Banner,{kind:"warn",title:"Check with staff",children:[G.map(e=>e.name).join(', ')," ",G.length>1?'contain':'contains'," or may contain an allergy you picked. The kitchen will see your allergies on the ticket."]}):null]})}):null,s.open?(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Who's the order for?"}),(0,p.jsx)(t.TextInput,{style:b,value:v,onChangeText:O,placeholder:"Your name (needed)",placeholderTextColor:u.colours.muted,maxLength:40,accessibilityLabel:"Your name, needed",testID:"table-name",autoComplete:"name"}),(0,p.jsx)(t.TextInput,{style:b,value:P,onChangeText:R,placeholder:"Phone number (optional)",placeholderTextColor:u.colours.muted,maxLength:20,keyboardType:"phone-pad",accessibilityLabel:"Phone number, optional",testID:"table-phone",autoComplete:"tel"}),P&&!(0,d.phoneOk)(P)?(0,p.jsx)(o.Muted,{center:!0,children:"Please check the phone number, or leave it blank."}):null,(0,p.jsx)(o.Muted,{center:!0,children:"We only use these for this order."}),(0,p.jsx)(t.TextInput,{style:b,value:I,onChangeText:M,placeholder:"Note for the staff (optional)",placeholderTextColor:u.colours.muted,maxLength:300,accessibilityLabel:"Note for the staff (optional)"})]}):null,(0,p.jsx)(r.default,{testID:"pay-placeholder",children:(0,p.jsxs)(o.Card,{children:[(0,p.jsx)(o.T,{center:!0,weight:"semibold",children:"Paying"}),(0,p.jsx)(o.T,{center:!0,children:d.PAY_WORDS}),(0,p.jsx)(o.Muted,{center:!0,children:"No card details are asked for or kept in this app."})]})})]})};var e,t=_r(_d[0]),n=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),r=(e=s)&&e.__esModule?e:{default:e},o=_r(_d[4]),a=_r(_d[5]),i=_r(_d[6]),d=_r(_d[7]),c=_r(_d[8]),h=_r(_d[9]),u=_r(_d[10]),p=_r(_d[11]);const b={borderWidth:1,borderColor:u.colours.border,borderRadius:10,padding:10,color:u.colours.text,backgroundColor:u.colours.surface2}},1337,[827,860,34,102,794,861,867,1175,1338,874,821,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tablePublic",{enumerable:!0,get:function(){return s}}),e.sendTableOrder=async function(t,r,a){if(!await(0,n.guestSession)())throw new Error('No connection. Try again when you are back online.');const o=await(0,n.rpc)('guest_table_order_v2',{p_phone:(a.phone??'').trim().slice(0,20)||null,p_token:t,p_lines:r.map(t=>({id:t.id,qty:t.qty,note:t.note.trim().slice(0,140)})),p_note:a.note.trim().slice(0,300)||null,p_allergies:a.allergies.map(t=>({allergen:t.allergen,severity:t.severity})),p_name:a.name.trim().slice(0,40)||null});if(!o||!1===o.ok||!o.id)throw new Error(o?.reason||'This table code isn\u2019t working any more. Please ask a member of staff.');return{id:o.id,ref:o.ref,held:!!o.held,totalPence:o.totalPence}},e.myTableOrders=async function(t){return await(0,n.guestSession)()?await(0,n.rpc)('guest_table_my_orders',{p_token:t})??[]:[]},e.loadTableSettings=async function(){const{data:t,error:n}=await a().from('table_order_settings').select('*').eq('venue_id',o()).maybeSingle();if(n)throw n;return(0,r.fromRow)(t)},e.saveTableSettings=async function(t,n){const{error:s}=await a().from('table_order_settings').upsert({venue_id:o(),...(0,r.toRow)(t),updated_at:(new Date).toISOString(),updated_by:n.slice(0,80)});if(s)throw s},e.listTableCodes=async function(){const{data:t,error:n}=await a().from('table_qr_codes').select('table_no, token, created_at').eq('venue_id',o()).eq('is_on',!0);if(n)throw n;return(t??[]).map(t=>({table:String(t.table_no),token:String(t.token),createdAt:String(t.created_at)})).sort((t,n)=>Number(t.table)-Number(n.table))},Object.defineProperty(e,"tableReadiness",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"makeTableCodes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"renewTableCode",{enumerable:!0,get:function(){return u}}),e.watchTableSettings=function(t){const r=n.useSync.getState().venueId;if(!r)return()=>{};const o=a().channel(`tos-${r}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'table_order_settings',filter:`venue_id=eq.${r}`},()=>t()).subscribe();return()=>{a().removeChannel(o)}};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]);const a=()=>(0,t.getSupabase)(),o=()=>{const t=n.useSync.getState().venueId;if(!t)throw new Error('Not connected to the venue yet.');return t},s=t=>(0,n.rpc)('table_public',{p_token:t});const l=()=>(0,n.rpc)('table_order_readiness',{p_venue:o()}),c=t=>(0,n.rpc)('table_qr_make',{p_venue:o(),p_tables:t}),u=t=>(0,n.rpc)('table_qr_renew',{p_venue:o(),p_table:t})},1338,[933,987,1175]); +__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 l}});var n=r(d[0]);r(d[1]);var t=r(d[2]),s=r(d[3]),u=r(d[4]),c=r(d[5]);function l(){return(0,t.canShow)('display')?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(s.DisplayBoard,{}),(0,c.jsx)(u.DisplayPairing,{})]}):(0,c.jsx)(n.Redirect,{href:t.ENTRY[t.APP_VARIANT]})}},1339,[30,34,872,1340,1404,25]); +__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,"EDIT_IDLE_MS",{enumerable:!0,get:function(){return Fe}}),_e2.DisplayBoard=function({embedded:e=!1,boardW:b,headerExtra:K,subHeader:Pe,noVoice:Ee=!1}={}){const Ke=(0,N.default)(),Xe=b??Ke.width,Ze=Ke.height,et=Xe<700,tt=Xe>=Ze,lt=!et&&tt&&Xe>=600,st=lt,it=Math.round(Math.min(520,Math.max(Xe>=1e3?448:280,.3*Xe))),ot=$.default.useRef(null),nt=$.default.useRef(0),[at,rt]=(0,T.useState)({w:0,h:0}),dt=(0,X.useOwner)(e=>e.site),ct=(0,Y.useRestaurant)(dt);(0,Ie.useAlertWatcher)(dt,{enabled:!e});const ut=(0,Y.useOrders)(dt),ht=(0,Y.useBookings)(dt),gt=(0,Y.useEvents)(dt),bt=(0,Y.useStore)(e=>e.skipMinutes),yt=(0,Y.useStore)(e=>e.clock.mode),pt=(0,Y.useNow)(5e3),ft=(0,X.useOwner)(e=>e.staff),mt=(0,X.useOwner)(e=>e.attendance),xt=(0,X.useOwner)(e=>e.shifts),jt=(0,X.useOwner)(e=>e.leave),wt=$.default.useMemo(()=>(0,ze.workingShifts)(xt,jt),[xt,jt]);$.default.useEffect(()=>{(0,ee.ensureAttendance)((0,q.ymd)(pt),pt)},[(0,q.ymd)(pt)]);const kt=mt.filter(e=>e.in&&!e.out&&pt.getTime()-new Date(e.in).getTime()<72e6&&pt.getTime()>=new Date(e.in).getTime()),It=Ve(ft.find(e=>e.id===kt[0]?.staffId)?.name)||'Duty Manager',vt=k.IS_CAR?'Car':'Display';(0,D.useSoldOutLink)(!1,e?void 0:vt,!0);const Dt=(0,q.ymd)(pt),St=(0,R.useTravelDay)('display',Dt),Ct=(0,Z.useFrontDoor)(Dt,tt),Tt=(0,te.useDisplaySettings)(dt),$t=Tt.privacy,Bt=(0,ce.useSaverSync)(),Rt=(0,te.usePlan)(dt),Lt=(0,te.useFloor)(e=>e.live[dt]),zt=(0,ve.useBlocks)(e=>e.blocks),[Wt,Ht]=(0,T.useState)('plan'),[Mt,Pt]=(0,T.useState)(!1),[Et,At]=(0,T.useState)('all'),[Ot,Nt]=(0,T.useState)(null),[_t,Gt]=(0,T.useState)(null),[Ft,Vt]=(0,T.useState)(null),[Ut,Kt]=(0,T.useState)(!1),[qt,Yt]=(0,T.useState)(!1),[Qt,Jt]=(0,T.useState)(null),[Xt,Zt]=(0,T.useState)(!1),[el,tl]=(0,T.useState)(!1),[ll,sl]=(0,T.useState)(null),[il,ol]=(0,T.useState)(null),[nl,al]=(0,T.useState)(null),rl=$.default.useRef(0),dl=e=>{rl.current=Date.now(),al(e)};$.default.useEffect(()=>{if(!nl)return;const e=setInterval(()=>{Date.now()-rl.current>=Te.DAY_IDLE_MS&&al(null)},5e3);return()=>clearInterval(e)},[nl]);const cl=(0,Y.useWaitlist)(dt),ul=(0,Y.useStore)(e=>e.walkIns[dt]??0),[hl,gl]=(0,T.useState)(!1),[bl,yl]=(0,T.useState)(!1),[pl,fl]=(0,T.useState)(!1);(0,V.useReviewAlerts)(dt);const[ml,xl]=(0,T.useState)({view:0,content:0}),[jl,wl]=(0,T.useState)(null);$.default.useEffect(()=>{jl&&((0,S.notify)({id:`floor-note:${Date.now()}`,title:jl,timeoutMs:4500,big:!0,testID:'floor-toast'}),wl(null))},[jl]),$.default.useEffect(()=>{if(!e)return(0,L.setDisplaySilent)(!0),()=>(0,L.setDisplaySilent)(!1)},[e]);const[kl,Il]=(0,T.useState)(null),vl=$.default.useRef(0),[Dl,Sl]=(0,T.useState)(null);$.default.useEffect(()=>{if(!kl)return;vl.current=Date.now();const e=setInterval(()=>{const e=Date.now()-vl.current;if(e>=Fe)return Il(null),void wl('Table plan locked again after 2 minutes with no touches. Unsaved changes were not kept.');Sl(e>=105e3?Math.ceil((Fe-e)/1e3):null)},1e3);return()=>clearInterval(e)},[kl]);const Cl=e=>e.date!==Dt?Vt({title:`Guest details \xb7 ${(0,Te.dayWord)(e.date,Dt)} ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[!e.walkIn&&e.date>Dt?(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${(0,Te.dayWord)(e.date,Dt)}, ${e.time}`,disabled:!Ks.ok,accessibilityHint:Ks.hint,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}):null,(0,xe.bookingDetails)(e)]})}):Vt({title:`Guest details \xb7 ${e.time}`,body:(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(Je,{rid:dt,id:e.id,turnBase:ct.settings.turnMins}),e.walkIn?null:(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Edit booking",testID:"details-edit-booking",accessibilityLabel:`Edit booking, ${e.name}, ${e.time}`,onPress:()=>{Vt(null),Jt(e.id)},style:{minHeight:56}}),e.walkIn?(0,Ne.jsx)(ye.CancelWalkInButton,{rid:dt,b:e,big:!0,onDone:e=>{Vt(null),wl(e)}}):null,e.walkIn?(0,Ne.jsx)(ye.ReinstateWalkInButton,{rid:dt,b:e,today:Dt,onDone:e=>{Vt(null),wl(e)}}):null,(0,xe.bookingDetails)(e)]})}),Tl=ht.filter(e=>e.date===Dt).sort((e,t)=>e.time.localeCompare(t.time)),$l=Tl.filter(e=>!['cancelled','noshow'].includes(e.status)),Bl=ut.filter(Ue).sort((e,t)=>Number('new'===t.status)-Number('new'===e.status)||(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt)),Rl=(0,T.useMemo)(()=>(0,c.forecastToday)(ct,ht,ut,gt,pt),[ct,ht,ut,gt,pt.getTime()/6e4|0]),Ll=(0,ve.closedAreasAt)(zt,dt,Dt,(0,q.hm)(pt)),zl=[...Ll].join(','),Wl=(0,T.useMemo)(()=>(0,le.floorView)(Rt,ht,ut,Lt??{},pt,ct.settings.turnMins,Ll),[Rt,ht,ut,Lt,pt.getTime(),zl]),Hl=(0,me.hoursFor)(ct,pt),Ml=Hl?.open??new Date(`${Dt}T12:00:00`),Pl=Hl?.close??new Date(`${Dt}T21:00:00`),El=(0,q.addMins)(Ml,-Ml.getMinutes()),Al=(0,q.addMins)(Pl,30),Ol=e=>new Date(`${Dt}T${e}:00`),Nl=(0,ve.blocksOn)(zt,dt,Dt).map(e=>({from:Ol(e.from),to:Ol(e.to),label:e.reason??'Paused'})).concat((0,o.queuedServicePauses)(ct,pt,Dt)),_l=Object.keys(Wl).filter(e=>'blocked'===Wl[e]?.status),Gl=nl&&nl!==Dt?nl:Dt,Fl=Gl!==Dt,Vl=(0,Te.dayWord)(Gl,Dt),Ul=/^(Today|Yesterday|Tomorrow)$/.test(Vl),Kl=Fl?(0,Te.bookingsForDay)(ht,Gl,Dt).sort((e,t)=>e.time.localeCompare(t.time)):Tl,ql=(0,q.parseYmd)(Gl);ql.setHours(12);const Yl=Fl?(0,me.hoursFor)(ct,ql):Hl,Ql=Yl?.open??new Date(`${Gl}T12:00:00`),Jl=Yl?.close??new Date(`${Gl}T21:00:00`),Xl=e=>new Date(`${Gl}T${e}:00`),Zl=[...Fl?(0,ve.blocksOn)(zt,dt,Gl).map(e=>({from:Xl(e.from),to:Xl(e.to),label:e.reason??'Paused'})):Nl,...Fl?(0,o.queuedServicePauses)(ct,ql,Gl):[]],es=(0,o.queuedServiceSessions)(ct,ql),ts=s.IS_QUEUED_VENUE&&(void 0===es||!es.length),ls=(0,Ne.jsxs)(O.default,{testID:"queued-hours-gate",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:void 0===es?'Opening and kitchen hours: to confirm':'Kitchen closed this day'}),(0,Ne.jsx)(G.Muted,{children:i.queuedVenues[dt]?.hours.note})]}),ss=Fl?Yl||Kl.length?GlFl?(0,le.dayFloorView)(Rt,Kl,Gl):Wl,[Fl,Rt,Kl,Gl,Wl]),[os,ns]=(0,T.useState)(null),[as,rs]=(0,T.useState)(null),[ds,cs]=(0,T.useState)(null),us=Fl?Kl.filter(e=>!['cancelled','noshow'].includes(e.status)):$l,hs=us.reduce((e,t)=>e+t.partySize,0),gs=(0,u.coversSplit)(us,Gl),bs=(0,$e.cancelledDayTally)(ht,Gl),ys=(0,Be.cancellationsFor)(ht,Gl,e=>e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)','')),ps=(0,$e.cancelledTallyWords)(bs,Ul?Vl.toLowerCase():Fl?`on ${Vl}`:'today'),fs=zt.filter(e=>e.rid===dt&&e.date===Gl&&!e.removedAt),ms=(0,Ce.chartBands)(fs,60*Ql.getHours()+Ql.getMinutes(),60*Jl.getHours()+Jl.getMinutes()),xs=new Set((0,Ce.blockedHours)(ms)),js=pt.getHours()+(pt.getMinutes()>=30?1:0),ws=Rl.hours.filter(e=>e.hour>=js&&!xs.has(e.hour)),ks=ws.reduce((e,t)=>e+t.coversHigh,0),Is=ws.reduce((e,t)=>e+t.coversLow,0),vs=Math.round((Is+ks)/2),Ds=!Rl.example&&Rl.open&&Rl.enough&&ks>0?`Usually ${(0,c.coversRange)(vs,vs)} more`:void 0,Ss=async(e,t)=>{const l=Wl[e]?.booking;if(!l||e===t)return;const s=Wl[t]?.status;if(s&&!['free','soon'].includes(s))return void wl('dirty'===s?`${(0,d.tableNumbers)(t)} needs clearing first.`:`${(0,d.tableNumbers)(t)} is ${le.STATUS[s].label.toLowerCase()}. Pick a free table.`);if(!(0,pe.guardBookingChange)(wl,{b:l,tables:[t]}))return;await Y.repo.bookings.update(l.id,{table:t});const i=Lt?.[e]?.stage;te.useFloor.getState().setLive(dt,t,{stage:i??'seated',dirty:!1}),te.useFloor.getState().setLive(dt,e,{stage:void 0,dirty:!0}),wl(`Saving: ${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}\u2026`),(0,pe.reportBookingSave)(l.id,`${(0,ue.privName)(l,$t)} moved ${(0,d.tableNumbers)(e)} \u2192 ${t}. ${(0,d.tableNumbers)(e)} needs clearing.`,`${(0,ue.privName)(l,$t)} to ${(0,d.tableNumbers)(t)}`,wl)},Cs=e=>{if(il)return rs(null),void ol(t=>t?{...t,tables:(0,fe.toggleTable)(t.tables,e)}:t);Fl?ns(e):_t?(e!==_t&&Ss(_t,e),Gt(null)):Nt(e)},Ts=il?ht.find(e=>e.id===il.id):void 0,$s=il&&Ts?(()=>{const e=Ts.walkIn?(0,ue.privName)(Ts,$t):Ve(Ts.name),t=(0,fe.seatsOf)(Rt,il.tables).total,l=(0,fe.seatLine)(t,Ts.partySize),s=(0,fe.pickClashes)(Ts,il.tables,ht.filter(e=>e.date===Ts.date),ct.settings.turnMins),i=(0,fe.tableKey)(il.tables)!==(0,fe.tableKey)((0,te.tablesOf)(Ts.table));return(0,Ne.jsxs)(O.default,{testID:"plan-pick-bar",style:{gap:6,backgroundColor:Q.colours.goldTint,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,padding:10},children:[(0,Ne.jsxs)(O.default,{accessible:!0,accessibilityLabel:`Picking tables for ${e}, ${(0,Te.dayWord)(Ts.date,Dt)} ${Ts.time}. Tap tables on the plan to add or take them off. ${(0,fe.tablesWords)(il.tables)}. ${l.text}.${s.length?` ${s.length} clash${1===s.length?'':'es'} with other bookings.`:''}`,children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.goldLight,children:["Tap tables for ",e," \xb7 ",(0,Te.dayWord)(Ts.date,Dt)," ",Ts.time]}),(0,Ne.jsxs)(G.T,{size:16,colour:Q.colours.text,children:[(0,fe.tablesWords)(il.tables)," \xb7 ",l.text,s.length?` \xb7 ${[...new Set(s.map(e=>(0,d.tableNumbers)(e.table)))].join(', ')} booked then`:'']})]}),as?(0,Ne.jsx)(O.default,{testID:"plan-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:as,style:{padding:10,borderRadius:10,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:(0,Ne.jsx)(G.T,{size:16,weight:"semibold",center:!0,colour:"#FFE2A8",children:as})}):null,(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:as?'plan-pick-overcap-yes':'plan-pick-save',label:as?'Use it anyway':s.length?'Save anyway':'Save tables',disabled:!i,style:{minHeight:56},accessibilityLabel:`${as?'Use it anyway':s.length?'Save anyway':'Save'}, ${(0,fe.tablesWords)(il.tables)} for ${e}. ${l.text}.`,onPress:async()=>{if(!Ts)return void ol(null);if(!(0,pe.guardBookingChange)(wl,{b:Ts,tables:il.tables}))return rs(null),void ol(null);const l=(0,fe.overCapacityAsk)(il.tables,t,Ts.partySize);if(l&&!as)return void rs(l);rs(null);const s=il.tables;ol(null),await(0,pe.saveTablesReported)(dt,Ts,s,e,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"plan-pick-cancel",kind:"ghost",label:"Cancel",accessibilityLabel:"Cancel, keep the tables as they were",style:{minHeight:56},onPress:()=>{rs(null),ol(null)}})]})]})})():null,Bs=Rt.areas.filter(e=>Rt.tables.some(t=>t.areaId===e.id)),Rs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);return Fl?`${t.filter(e=>!is[e.name]?.dayBookings).length}/${t.length} unbooked`:`${t.filter(e=>['free','soon'].includes(Wl[e.name]?.status??'free')).length}/${t.length} free`},Ls='all'===Et||Bs.some(e=>e.id===Et)?Et:'all',zs=e=>(0,Ne.jsx)(se.FloorCanvas,{plan:Rt,areaId:e,mode:"live",fit:"contain",crop:!0,fill:lt,big:!0,view:is,privacy:$t,turnBase:ct.settings.turnMins,highlight:il?il.tables:_t?[_t]:void 0,onTap:e=>Cs(e.name),onDrop:(e,t)=>il||Fl?void 0:Ss(e.name,t.name)}),Ws=et?1:tt||Bs.length>2?2:1,Hs=e=>{const t=Rt.tables.filter(t=>t.areaId===e);if(!t.length)return.5;const l=Math.max(...t.map(e=>e.x+e.w))-Math.min(...t.map(e=>e.x))+92;return(Math.max(...t.map(e=>e.y+e.h))-Math.min(...t.map(e=>e.y))+92)/l},Ms=[];for(let e=0;e{const t=(0,se.areaBounds)(Rt,e.id);return{id:e.id,w:t.w,h:t.h,minScale:(0,se.minReadableScale)(Rt,e.id)}}),at.w,at.h):null,Es=e=>(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',height:ie.AREA_LABEL_H-2,paddingHorizontal:4},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),numberOfLines:1,style:{flexShrink:1},children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:Rs(e.id)})]}),As=(0,Ne.jsx)(O.default,{testID:"venue-grid",style:{flex:1,minHeight:0},onLayout:e=>{const{width:t,height:l}=e.nativeEvent.layout;(Math.abs(t-at.w)>1||Math.abs(l-at.h)>1)&&rt({w:t,h:l})},children:Ps?(0,Ne.jsx)(A.default,{style:{flex:1},scrollEnabled:Ps.scroll,showsVerticalScrollIndicator:Ps.scroll,contentContainerStyle:{gap:ie.GRID_GAP},children:Ps.rows.map((e,t)=>(0,Ne.jsx)(O.default,{style:{height:Ps.rowHeights[t],flexDirection:'row',gap:ie.GRID_GAP},children:e.map(e=>{const t=Bs.find(t=>t.id===e);return(0,Ne.jsxs)(O.default,{testID:`area-cell-${e}`,style:{width:Ps.cellW,gap:2},children:[Es(t),(0,Ne.jsx)(O.default,{style:{flex:1},children:zs(e)})]},e)})},t))}):null}),Os=(0,Ne.jsxs)(O.default,{testID:"venue-plan",style:{flex:et?void 0:1,gap:10,minWidth:0},children:[(0,Ne.jsx)(r.TableNumberWarning,{plan:Rt}),Rt.tables.length?null:(0,Ne.jsxs)(O.default,{testID:"venue-plan-pending",style:{flex:1,justifyContent:'center',alignItems:'center',gap:8,padding:24},children:[(0,Ne.jsx)(G.T,{size:24,weight:"semibold",children:"No table plan yet"}),(0,Ne.jsx)(G.Muted,{center:!0,children:"Waiting for the venue\u2019s real table plan. No sample tables have been added."}),s.IS_WILDINGS||s.IS_KIRKMICHAEL||s.IS_SOUTERS?(0,Ne.jsx)(G.Muted,{center:!0,testID:"display-venue-hours",children:(s.IS_WILDINGS?a.WILDINGS_GUIDE:s.IS_KIRKMICHAEL?a.KIRKMICHAEL_GUIDE:a.SOUTERS_GUIDE).hoursLines.join(' \xb7 ')}):null]}),(()=>{const e=[(0,Ne.jsx)(Ye,{chipId:"all",compact:!et,label:"Whole venue",selected:'all'===Ls,onPress:()=>At('all')},"__all"),...Bs.map(e=>(0,Ne.jsx)(Ye,{chipId:e.id,compact:!et,label:`${e.name}${(0,oe.areaMarks)(e)}`,colour:(0,Q.brandColour)(e.colour),sub:et?Ll.has(e.id)?'closed':Ls===e.id?Rs(e.id):void 0:void 0,selected:Ls===e.id,onPress:()=>At(e.id)},e.id))];return et?(0,Ne.jsx)(O.default,{testID:"area-chips",style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:8,maxWidth:'100%'},children:e}):(0,Ne.jsx)(A.default,{horizontal:!0,testID:"area-chips",showsHorizontalScrollIndicator:!1,onLayout:e=>{const t=e.nativeEvent.layout.width;xl(e=>e.view===t?e:{...e,view:t})},onContentSizeChange:e=>xl(t=>t.content===e?t:{...t,content:e}),style:{flexGrow:0,flexShrink:0,maxHeight:48,alignSelf:'stretch'},contentContainerStyle:{flexDirection:'row',flexWrap:'nowrap',alignItems:'center',justifyContent:ml.view>0&&ml.content>0&&ml.content<=ml.view+1?'center':'flex-start',gap:4,paddingRight:4,minWidth:ml.view>0&&ml.content<=ml.view+1?'100%':void 0},children:e})})(),(0,Ne.jsx)(g.FloorLegend,{}),$s,_t?(0,Ne.jsxs)(G.Row,{gap:8,style:{backgroundColor:Q.colours.goldTint,borderRadius:10,padding:8},children:[(0,Ne.jsxs)(G.T,{weight:"semibold",colour:Q.colours.goldLight,style:{flex:1},children:["Moving the party from ",(0,d.tableNumbers)(_t),": tap the new table."]}),(0,Ne.jsx)(G.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>Gt(null)})]}):null,'all'===Ls&<?As:'all'===Ls?(0,Ne.jsx)(O.default,{style:{flex:et?void 0:1,gap:12,minHeight:st?void 0:360},children:Ms.map((e,t)=>(0,Ne.jsxs)(O.default,{style:{flex:et?void 0:Math.max(.3,...e.map(e=>Hs(e.id))),flexDirection:'row',gap:8},children:[e.map(e=>(0,Ne.jsxs)(O.default,{style:{flex:1,gap:2},children:[et?(0,Ne.jsxs)(O.default,{style:{alignItems:'center',gap:4},children:[(0,Ne.jsxs)(G.T,{center:!0,size:18,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{center:!0,size:14,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{center:!0,children:Rs(e.id)})]}):(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:(0,Q.brandColour)(e.colour),children:[e.name,(0,oe.areaMarks)(e)]}),Ll.has(e.id)?(0,Ne.jsx)(G.T,{size:13,weight:"semibold",colour:Q.colours.blue,children:"Closed for weather"}):(0,Ne.jsx)(G.Muted,{children:Rs(e.id)})]}),(0,Ne.jsx)(O.default,{style:et?{height:Math.max(280,Math.round((Xe-40)*Hs(e.id)))}:{flex:1},children:zs(e.id)})]},e.id)),e.length{if(Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},Gl)}),_s='timeline'===Wt,Gs=Mt?(0,Ne.jsx)(M.default,{visible:!0,transparent:!1,animationType:"fade",onRequestClose:()=>Pt(!1),supportedOrientations:['landscape','portrait'],children:(0,Ne.jsxs)(O.default,{testID:"timeline-full",accessibilityViewIsModal:!0,style:{flex:1,backgroundColor:Q.colours.bg,paddingHorizontal:10,paddingTop:6,paddingBottom:6,gap:4},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:12,minHeight:64},children:[(0,Ne.jsx)(E.default,{testID:"timeline-back",accessibilityRole:"button",accessibilityLabel:"Back to the table plan",onPress:()=>Pt(!1),style:{minHeight:64,minWidth:Xe<600?120:180,paddingHorizontal:Xe<600?14:22,borderRadius:16,borderWidth:2,borderColor:Q.colours.goldLight,backgroundColor:Q.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:22,weight:"bold",colour:"#16120B",center:!0,children:"\u2039 Back"})}),(0,Ne.jsx)(O.default,{style:{flex:1,alignItems:'center',minWidth:0},children:(0,Ne.jsx)(G.T,{size:22,weight:"semibold",colour:Q.colours.goldLight,center:!0,numberOfLines:1,accessibilityRole:"header",children:`Timeline \xb7 ${Fl?(0,Te.dayLong)(Gl):'Today'}`})}),Xe<600?null:(0,Ne.jsx)(O.default,{style:{minWidth:180}})]}),ts?ls:(0,Ne.jsx)(O.default,{style:{flex:1,minHeight:0},children:(0,Ne.jsx)(re.Timeline,{hideNow:!0,fit:!0,plan:Rt,bookings:Fl?Kl:Tl,now:Fl?Ql:pt,privacy:$t,turnBase:ct.settings.turnMins,t0:Fl?(0,q.addMins)(Ql,-Ql.getMinutes()):El,t1:Fl?(0,q.addMins)(Jl,30):Al,pauses:Fl?Zl:Nl,blockedTables:Fl?[]:_l,onOpen:e=>{if(Pt(!1),Fl)return void sl(e.id);const t=(0,te.tablesOf)(e.table)[0];t&&Wl[t]?Nt(t):Cl(e)}},`full-${Gl}`)})]})}):null,Fs=Fl?(0,Ne.jsxs)(O.default,{testID:"display-day-bar",style:{flexDirection:'row',alignItems:'center',gap:8,marginBottom:4,paddingVertical:2,paddingHorizontal:8,minHeight:44,borderRadius:12,borderWidth:1,borderColor:Q.colours.gold,backgroundColor:Q.colours.goldTint},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,style:{flex:1},accessibilityRole:"header",children:Ul?`Showing ${Vl} \xb7 ${(0,q.niceDate)((0,q.parseYmd)(Gl))}`:`Showing ${(0,Te.dayWord)(Gl,Dt)}`}),(0,Ne.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:`${ps}. Showing ${(0,Te.dayLong)(Gl)}. Guests, table plan, Timeline and Covers are for that day.`,style:{position:'absolute',width:1,height:1,overflow:'hidden'}}),(0,Ne.jsx)(G.Button,{testID:"back-to-today",label:"Back to today",accessibilityLabel:"Back to today",onPress:()=>{ol(null),dl(null)},style:{minHeight:44}})]}):null,Vs=(0,Ne.jsx)(O.default,{accessibilityRole:"tablist",style:{flexDirection:'row',borderRadius:15,padding:4,gap:4,borderWidth:1,borderColor:'rgba(255,255,255,0.08)',backgroundColor:'rgba(255,255,255,0.035)',alignSelf:et?'stretch':'flex-start'},children:[['plan','Table plan','view-floor'],['timeline','Timeline','view-timeline']].map(([e,t,l])=>{const i='timeline'===e===(_s||Mt);return(0,Ne.jsx)(E.default,{testID:l,accessibilityRole:"tab",accessibilityLabel:t,accessibilityState:{selected:i},accessibilityHint:'timeline'===e?'Opens the timeline over the whole screen':void 0,onPress:()=>{'timeline'===e?(Ht('plan'),Pt(!0)):(Pt(!1),Ht('plan'))},style:{flex:et?1:void 0,minHeight:et?48:44,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',backgroundColor:i?Q.colours.gold:'transparent',...We.look.web(i?{backgroundImage:s.IS_ISOLATED_VENUE?'none':'linear-gradient(180deg, #DDB671 0%, #C29550 100%)',boxShadow:s.IS_ISOLATED_VENUE?'0 4px 12px rgba(0,0,0,0.3)':'0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 12px rgba(207,164,95,0.22)'}:{})},children:(0,Ne.jsx)(G.T,{size:et?16:13,weight:"semibold",colour:i?'#16120B':'#BDB5A6',children:t})},e)})}),Us='display'!==k.APP_VARIANT||e?Vs:(0,Ne.jsxs)(O.default,{testID:"display-view-row",style:{flexDirection:et?'column':'row',flexWrap:et?'nowrap':'wrap',gap:6,alignItems:et?'stretch':'center'},children:[Vs,(0,Ne.jsx)(w.DisplayRotaKitchenButtons,{phone:et,shifts:xt,staff:ft,today:Dt,leave:jt})]}),Ks=(0,h.useBookingWrite)(),qs=e=>(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Walk-in",onPress:Ct.openWalkIn,testID:"add-walkin",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"New booking",onPress:Ct.openBooking,testID:"add-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint}),(0,Ne.jsx)(He.BigAction,{premium:!0,label:"Edit booking",onPress:()=>Yt(!0),testID:"display-edit-booking",block:e,size:"s",disabled:!Ks.ok,accessibilityHint:Ks.hint})]});(0,Oe.useDisplayNotices)(dt,!e);const Ys=et?180:168,[Qs,Js]=(0,T.useState)(Ys),Xs=$.default.useRef(Ys),Zs=$.default.useRef(null),ei=$.default.useRef(null),ti=()=>{const e=Zs.current,t=ei.current;e?.measureInWindow&&t?.measureInWindow&&e.measureInWindow((e,l,s,i)=>{t.measureInWindow((e,t)=>{const s=Ze<820?8:12,o=44+(Ze<820?4:8),n=i>Xs.current?Math.ceil(i-Xs.current):Se.DAY_GRAPH_CHROME,a=Math.max(70,Math.min(Ys,Math.floor(t-s-l)-n-o));Math.abs(Xs.current-a)>=2&&(Xs.current=a,Js(a))})})};$.default.useEffect(()=>{const e=setTimeout(ti,60);return()=>clearTimeout(e)},[Xe,Ze]);const li=(0,Ne.jsxs)(O.default,{ref:ei,testID:"display-tools",accessibilityLabel:"Display tools",onLayout:t=>{e||x.useDisplayToolsH.setState({h:Math.round(t.nativeEvent.layout.height)}),ti()},style:{flexDirection:'row',flexWrap:Xe>=900?'nowrap':'wrap',gap:8,paddingHorizontal:14,paddingVertical:et?12:6,justifyContent:et?'center':void 0,borderTopWidth:1,borderTopColor:Q.colours.hairline,backgroundColor:(0,n.soutersSurface)('#0D0D0C')},children:[e?null:(0,Ne.jsx)(Ae.DisplayClockButton,{}),(0,Ne.jsx)(ae.HoldToEdit,{quiet:!0,onUnlock:()=>{Sl(null),Il({at:Date.now()})},onHint:()=>wl('Plan locked. Press and hold Edit plan for 2 seconds to unlock it.')}),(0,Ne.jsx)(De.BlockBookingsButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,display:!0,day:Gl}),Rt.areas.some(e=>e.outdoor)?(0,Ne.jsx)(De.CloseGardenButton,{rid:dt,r:ct,now:pt,by:It,quiet:!0,short:!0}):null,(0,Ne.jsx)(E.default,{testID:"display-add-soldout",accessibilityRole:"button",accessibilityLabel:"Add sold out, mark a dish sold out or put it back on",onPress:()=>fl(!0),style:({pressed:e})=>({...We.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.goldLight,style:{textAlign:'center'},children:"Add sold out"})}),k.IS_CAR||k.IS_OWNER_DESKTOP?null:(0,Ne.jsx)(f.GiftQrButton,{rid:dt,venue:ct.name})]}),si=Bl.length?(0,Ne.jsxs)(O.default,{testID:"takeaway-panel",style:[We.look.panel,{overflow:'hidden'}],children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between',paddingHorizontal:14,paddingTop:12},children:[(0,Ne.jsx)(G.T,{size:15,weight:"semibold",children:"Takeaway"}),(0,Ne.jsxs)(G.T,{size:12,colour:Q.colours.muted,children:[Bl.length," live"]})]}),(0,Ne.jsx)(O.default,{style:{padding:10},children:(0,Ne.jsx)(Qe,{list:Bl,me:It,compact:!0,bookings:ht})})]}):null,ii=(Le.DueToday,Fl?Kl:Tl.filter(e=>'confirmed'===e.status||'seated'===e.status).sort((e,t)=>e.time.localeCompare(t.time))),oi=Fl?Ul?`${Vl}\u2019s guests`:`Guests ${Vl}`:'Today\u2019s guests',ni=(0,Ne.jsxs)(Ne.Fragment,{children:[0===ii.length?(0,Ne.jsx)(G.Muted,{children:Fl?Gl{const t=(0,J.isSeatedHighlight)(e.status,{otherDay:Fl}),l=(0,he.guestRowText)(e,{name:e.walkIn?(0,ue.privName)(e,$t):(e.name??'').replace(' (example)',''),seated:t}),s=Q.colours.text,i=t?Q.colours.goldLight:Q.colours.muted,o=Q.colours.gold,n=l.depositWarn?Q.colours.amber:Q.colours.goldLight;return(0,Ne.jsxs)(E.default,{testID:`display-guest-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:l.a11y,accessibilityHint:Fl?'Opens assign table':'Opens seat, finished, no-show and assign table',onPress:()=>{tl(!1),sl(e.id)},style:({pressed:e})=>t?{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,...(0,J.seatedHighlightStyle)({backgroundColor:e?Ge:_e,borderColor:Q.colours.gold,borderLeftColor:Q.colours.gold,borderBottomWidth:1.5})}:{minHeight:64,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderBottomWidth:1,borderColor:Q.colours.hairline,backgroundColor:e?Q.colours.tilePressed:'transparent'},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'flex-start',gap:10},children:[(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:o,style:{width:58},children:l.time}),(0,Ne.jsx)(G.T,{size:18,weight:"semibold",colour:s,testID:"guest-row-name",style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l.name}),l.allergy?(0,Ne.jsx)(O.default,{style:{paddingTop:2},children:(0,Ne.jsx)(H.AllergyIcon,{text:l.allergy,size:22,colour:Q.colours.amber,ink:Q.colours.bg,testID:`display-allergy-${e.id}`})}):null]}),(0,Ne.jsxs)(G.T,{size:16,testID:"guest-row-detail",style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:16,colour:s,children:l.people}),l.deposit?(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}):null,l.deposit?(0,Ne.jsx)(G.T,{size:16,weight:"semibold",colour:n,testID:`display-deposit-${e.id}`,children:l.deposit}):null,(0,Ne.jsx)(G.T,{size:16,colour:i,children:" \xb7 "}),(0,Ne.jsx)(G.T,{size:16,weight:t?'semibold':'regular',colour:'No table yet'===l.table?i:s,children:l.table}),l.dog?(0,Ne.jsx)(G.T,{size:16,children:" "}):null,l.dog?(0,Ne.jsx)(O.default,{style:{width:18,height:18,transform:[{translateY:3}]},children:(0,Ne.jsx)(ge.DogIcon,{size:18,testID:`display-dog-${e.id}`})}):null]})]},e.id)}),(0,Ne.jsx)(Re.CancellationsSection,{items:ys,dayWord:Fl?Ul?Vl.toLowerCase():`on ${Vl}`:'today'})]}),ai=(0,Ne.jsx)(A.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{flex:1},contentContainerStyle:{padding:12,gap:4},children:ni}),ri=P.default.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>12&&Math.abs(t.dx)>Math.abs(t.dy),onPanResponderRelease:(e,t)=>{t.dx<-40&&tl(!1)}}),di=(0,Ne.jsxs)(E.default,{testID:"guests-handle",accessibilityRole:"button",accessibilityLabel:`${oi}, ${ii.length}`,accessibilityState:{expanded:el},'aria-expanded':el,dataSet:{centreExempt:'count-and-turned-label-centred-as-a-group'},onPress:()=>tl(e=>!e),style:({pressed:e})=>({width:44,alignSelf:'stretch',borderRadius:12,borderWidth:1,borderColor:el?Q.colours.gold:Q.colours.hairline,alignItems:'center',justifyContent:'center',gap:8,backgroundColor:e?Q.colours.tilePressed:el?Q.colours.goldTint:'rgba(255,255,255,0.03)'}),children:[(0,Ne.jsx)(G.T,{size:16,weight:"bold",colour:Q.colours.gold,children:ii.length}),(0,Ne.jsx)(O.default,{style:{width:44,height:150,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(O.default,{style:{position:'absolute',width:150,height:44,left:-53,top:53,alignItems:'center',justifyContent:'center',transform:[{rotate:'-90deg'}]},children:(0,Ne.jsxs)(G.T,{size:13,weight:"semibold",colour:Q.colours.goldLight,numberOfLines:1,children:[oi," ",el?'\u2039':'\u203a']})})})]}),ci=el?(0,Ne.jsxs)(O.default,{style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:40,flexDirection:'row'},children:[(0,Ne.jsxs)(O.default,{testID:"guests-drawer",...ri.panHandlers,accessibilityViewIsModal:!0,style:{width:Math.min(560,Math.max(320,.44*Xe)),backgroundColor:Q.colours.surface,borderRightWidth:1,borderColor:Q.colours.gold,borderRadius:14,...We.look.web({boxShadow:'6px 0 24px rgba(0,0,0,0.5)'})},children:[(0,Ne.jsxs)(O.default,{testID:"guests-head",style:{paddingHorizontal:12,paddingTop:8},children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",colour:Q.colours.gold,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:[oi.toUpperCase()," (",ii.length,")"]}),(0,Ne.jsx)(l.GoldClose,{testID:"guests-close",label:`Close ${oi}`,onPress:()=>tl(!1),style:{marginRight:-6}})]}),bs.count?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,testID:"cancelled-day-tally-guests",children:ps}):null]}),ai]}),(0,Ne.jsx)(E.default,{testID:"guests-backdrop",accessibilityLabel:`Close ${oi}`,accessibilityRole:"button",onPress:()=>tl(!1),style:{flex:1}})]}):null,ui=ts?ls:s.IS_KIRKTON&&!Object.values(ct.kitchenHours??{}).some(Boolean)?(0,Ne.jsxs)(O.default,{testID:"kirkton-hours-to-confirm",style:[We.look.panel,{padding:14,gap:8}],children:[(0,Ne.jsx)(G.T,{weight:"semibold",children:"Opening and kitchen hours: to confirm"}),(0,Ne.jsx)(G.Muted,{children:"No service hours have been set for this venue."})]}):(0,Ne.jsx)(Se.DayGraph,{busyThreshold:(0,t.venueBusy)(ct,ht,pt).busy,todays:Kl,open:Ql,close:Jl,now:pt,turnBase:ct.settings.turnMins,blocks:fs,pauses:Zl,compact:et,dense:!et,fit:lt,tight:lt&&Ze<600,height:Ys,forecastNote:Fl?void 0:Ds,emptyText:ss,past:Gl{Fl?tl(!0):Pt(!0)},yi=(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',padding:Ze<820?8:12,paddingTop:Ze<820?6:10,gap:12,minHeight:0,overflow:'hidden'},children:[St?null:di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[St?null:Fs,St?(0,Ne.jsx)(A.default,{contentContainerStyle:{gap:10,paddingBottom:14},children:(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"})}):_s?Ns:Os,Gs,ci]}),(0,Ne.jsxs)(O.default,{testID:"display-side",style:{width:it,gap:Ze<820?4:8,minHeight:0},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexShrink:0,flexWrap:'wrap',flexDirection:'row',gap:8},children:qs(!1)}),(0,Ne.jsx)(O.default,{style:{flexShrink:0},children:Us}),St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:Ze<820,snug:Ze<820,tight:Ze<700,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{ref:Zs,testID:"day-graph-slot",onLayout:ti,style:{flexGrow:0,flexShrink:1,flexBasis:Ys+52,minHeight:Ze<600?90:120,overflow:'visible'},children:hi}),(0,Ne.jsxs)(A.default,{testID:"display-side-scroll",style:{flexGrow:1,flexShrink:1,flexBasis:44,minHeight:44},contentContainerStyle:{gap:10,paddingBottom:6},children:[(0,Ne.jsx)(E.default,{testID:"display-reviews",accessibilityRole:"button",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:44,alignItems:'center',justifyContent:'center',borderRadius:12,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:(0,Ne.jsx)(G.T,{center:!0,weight:"semibold",children:"Reviews"})}),si,(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It})]})]})]});return(0,Ne.jsxs)(_.SafeAreaView,{style:{flex:1,backgroundColor:Q.colours.bg},onTouchStart:()=>{rl.current=Date.now()},onMouseDown:()=>{rl.current=Date.now()},children:[et?(0,Ne.jsxs)(O.default,{style:{flex:1},children:[(0,Ne.jsxs)(A.default,{ref:ot,testID:"phone-dashboard-scroll",style:{flex:1},contentContainerStyle:{padding:12,gap:16,paddingBottom:24,width:'100%',maxWidth:700,alignSelf:'center'},children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{alignItems:'center',gap:8,paddingVertical:12,position:'relative'},children:[e?null:(0,Ne.jsx)(O.default,{style:{position:'absolute',top:4,right:4,zIndex:2},children:(0,Ne.jsx)(j.ExitButton,{})}),(0,Ne.jsx)(U.RestaurantLogo,{rid:dt,size:64}),(0,Ne.jsx)(G.T,{center:!0,size:24,weight:"semibold",accessibilityRole:"header",children:ct.name}),(0,Ne.jsx)(U.PoweredBy,{}),(0,Ne.jsx)(C.AppBadge,{label:e?'RESTAURANT DASHBOARD':'DISPLAY'}),(0,Ne.jsx)(O.default,{accessible:!0,accessibilityLabel:`Current time ${(0,q.hm)(pt)}`,children:(0,Ne.jsx)(G.T,{center:!0,size:30,weight:"semibold",colour:Q.colours.goldLight,children:(0,q.hm)(pt)})}),(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:"m"}),(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:"m"}),K]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt}),gi,(0,Ne.jsx)(O.default,{testID:"phone-glance",style:{width:'100%'},children:(0,Ne.jsx)(qe,{phone:!0,split:gs,items:[{label:`Tables \xb7 ${Vl}`,value:us.length,testID:'badge-tables'},{label:`Covers \xb7 ${Vl}`,value:hs,testID:'badge-covers'},{label:'Takeaway',value:Bl.length,alert:Bl.some(e=>'new'===e.status),testID:'badge-takeaway',onPress:()=>Kt(!0)}]})}),(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{gap:8},children:qs(!0)}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),Us,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{width:'100%',minWidth:0},children:[_s?Ns:Os,Gs]}),(0,Ne.jsxs)(O.default,{onLayout:e=>{nt.current=e.nativeEvent.layout.y},testID:"phone-guests-section",style:[We.look.panel,{width:'100%',padding:12,gap:8}],children:[(0,Ne.jsxs)(G.T,{center:!0,size:20,weight:"semibold",colour:Q.colours.goldLight,accessibilityRole:"header",children:[oi," (",ii.length,")"]}),(0,Ne.jsx)(O.default,{testID:"display-guest-list",accessibilityLabel:oi,style:{gap:4},children:ni})]}),si,hi,(0,Ne.jsx)(O.default,{testID:"covers-dock",children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,compact:!0,sound:(0,L.flapSoundOn)(),onPress:()=>ot.current?.scrollTo({y:nt.current,animated:!0})})}),(0,Ne.jsxs)(O.default,{testID:"phone-display-settings",style:{gap:8,alignItems:'center'},children:[(0,Ne.jsx)(G.T,{center:!0,size:14,colour:$t?Q.colours.muted:Q.colours.amber,children:$t?'Privacy: names shown as initials on tables':'Privacy off: names shown on tables'}),(0,Ne.jsx)(G.Button,{testID:"colour-key-help",kind:"secondary",label:"Table colours & symbols",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:{minHeight:48,alignSelf:'stretch'}}),(0,Ne.jsx)(G.Button,{testID:"display-reviews",kind:"secondary",label:"Reviews",accessibilityLabel:"Reviews",onPress:()=>yl(!0),style:{minHeight:48,alignSelf:'stretch'}})]}),li]}),e?null:(0,Ne.jsx)(O.default,{testID:"phone-voice-footer",style:{alignItems:'center',paddingVertical:6,borderTopWidth:1,borderColor:Q.colours.hairline},children:(0,Ne.jsx)(W.VoiceSlot,{size:56})})]}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"display-header",style:{flexDirection:'row',alignItems:'center',paddingHorizontal:Xe>=1e3?18:14,paddingVertical:Ze<820?4:8,gap:8,minHeight:52,backgroundColor:(0,n.soutersSurface)('#0D0D0C'),...We.look.web({backgroundImage:s.IS_SOUTERS?'none':'linear-gradient(180deg, #121110 0%, #0B0B0B 100%)'})},children:[(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',gap:8,minWidth:0,overflow:'hidden'},children:[(0,Ne.jsx)(O.default,{style:{flex:1,flexShrink:1,minWidth:96,maxWidth:280},children:(0,Ne.jsx)(U.RestaurantBrand,{rid:ct.id,size:Xe<900?32:40,beside:!0})}),(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',alignItems:'baseline',gap:8,flexShrink:0},children:[(0,Ne.jsx)(G.T,{size:Xe<900?18:21,weight:"semibold",colour:Q.colours.goldLight,style:{letterSpacing:.4,lineHeight:26,fontVariant:['tabular-nums']},children:(0,q.hm)(pt)}),Xe>=900?(0,Ne.jsx)(G.T,{size:13,colour:Q.colours.muted,children:(0,q.niceDate)(pt)}):null]})]}),St?(0,Ne.jsx)(O.default,{style:{width:220}}):(0,Ne.jsx)(O.default,{testID:"display-day-centre",style:{alignItems:'center',justifyContent:'center'},children:gi}),(0,Ne.jsxs)(O.default,{style:{flex:1,flexDirection:'row',alignItems:'center',justifyContent:'flex-end',gap:8,minWidth:0,flexShrink:0},children:[(0,Ne.jsx)(Me.ShellfishChip,{rid:dt,by:It,app:"display",size:Xe<1200?'xs':Xe<1280||Ze<700?'s':'m'}),(0,Ne.jsx)(E.default,{testID:"colour-key-help",accessibilityRole:"button",accessibilityLabel:"Help: table colours and symbols",onPress:()=>gl(!0),style:({pressed:e})=>({width:44,height:44,borderRadius:22,borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(255,255,255,0.08)':'rgba(255,255,255,0.03)',alignItems:'center',justifyContent:'center'}),children:(0,Ne.jsx)(G.T,{size:15,weight:"semibold",colour:Q.colours.muted,children:"?"})}),'simulated'===yt?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:"Skip 15 minutes",onPress:()=>bt(15),style:{minHeight:44,minWidth:44,alignItems:'center',justifyContent:'center'},children:(0,Ne.jsx)(G.T,{size:11,colour:Q.colours.muted,children:"+15"})}):null,e?null:(0,Ne.jsx)(j.ExitButton,{}),K,Ee?null:(0,Ne.jsx)(W.VoiceSlot,{size:44})]})]}),Pe,(0,Ne.jsx)(pe.BookingSaveBanner,{rid:dt,margin:{marginHorizontal:12,marginTop:6}}),St?null:(0,Ne.jsxs)(O.default,{testID:"display-day-stats",style:{paddingHorizontal:12,paddingTop:2,paddingBottom:2,alignItems:'center'},children:[(0,Ne.jsx)(qe,{splitOnly:!0,split:gs,items:[]}),(0,Ne.jsx)(O.default,{testID:"roast-under-shellfish",style:{position:'absolute',top:2,right:104+(Xe>=1e3?18:14)+(e?0:52)+('simulated'===yt?52:0),zIndex:4},children:(0,Ne.jsx)(Me.SundayRoastChip,{rid:dt,by:It,app:"display",size:Xe<1100||Ze<700?'s':'m'})})]}),lt?yi:(pi=(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{testID:"front-door-bar",style:{gap:10},children:[(0,Ne.jsx)(O.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12},children:qs(!1)}),Us]}),(0,Ne.jsx)(De.BlocksBanner,{rid:dt,now:pt,big:!0,by:It}),St?(0,Ne.jsx)(R.DayView,{rid:dt,day:St,today:Dt,app:"display"}):(0,Ne.jsx)(Ne.Fragment,{children:(0,Ne.jsxs)(O.default,{style:{flexGrow:1,flexShrink:1,flexBasis:0,minHeight:140,flexDirection:'row',gap:10},children:[di,(0,Ne.jsxs)(O.default,{testID:"display-main",style:{flex:1,minWidth:0},children:[Fs,_s?Ns:Os,Gs,ci]})]})}),si,St?null:(0,Ne.jsx)(O.default,{testID:"covers-dock",style:{flexShrink:0},children:(0,Ne.jsx)(B.CoversToday,{rid:dt,day:Gl,sound:(0,L.flapSoundOn)(),onPress:bi})}),St?null:(0,Ne.jsx)(O.default,{testID:"day-graph-slot",style:{flexShrink:0,overflow:'visible',minHeight:Ys+Se.DAY_GRAPH_CHROME},children:hi})]}),(0,Ne.jsx)(A.default,{testID:"display-wrap-scroll",style:{flex:1,minHeight:0},contentContainerStyle:{flexGrow:1,padding:12,paddingTop:10,gap:10},children:pi})),li]}),(0,Ne.jsx)(I.SoldOutStrip,{rid:dt,by:vt,onOpen:()=>fl(!0)}),(0,Ne.jsx)(v.SoldOutSheet,{visible:pl,onClose:()=>fl(!1),rid:dt,by:vt,hideLinks:!0,testID:"display-soldout-sheet"}),(0,Ne.jsx)(p.TableOrderCue,{rid:dt}),Ct.elements,qt?(0,Ne.jsx)(y.EditBookingPicker,{rid:dt,today:Dt,who:It,hidePrivate:!0,onClose:()=>Yt(!1)}):null,Qt?(0,Ne.jsx)(y.EditBookingSheet,{rid:dt,id:Qt,who:It,hidePrivate:!0,onClose:()=>Jt(null)}):null,Ot?(0,Ne.jsx)(xe.TableSheet,{rid:dt,name:Ot,view:Wl,plan:Rt,todays:Tl,now:pt,privacy:$t,turnBase:ct.settings.turnMins,onClose:()=>Nt(null),onWalkIn:e=>Ct.openWalkInAt(e),onMove:e=>Gt(e),onDetails:Cl}):null,os?(()=>{const e=is[os],t=e?.dayBookings??[];return(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>{cs(null),ns(null)},title:`${(0,d.tableNumbersA11y)(os)} \xb7 ${Ul?Vl:(0,Te.dayLong)(Gl)}`,maxWidth:560,testID:"day-table-sheet",children:[(0,Ne.jsxs)(G.T,{size:16,center:!0,colour:Q.colours.text,children:[e?`${e.table.maxSeats} seats. `:'',t.length?`${t.length} ${1===t.length?'booking':'bookings'} on this table ${Ul?Vl.toLowerCase():'that day'}. Tap one to change its tables.`:`No bookings on this table ${Ul?Vl.toLowerCase():'that day'}.`]}),t.map(e=>{const t=e.walkIn?(0,ue.privName)(e,$t):Ve(e.name);return(0,Ne.jsx)(G.Button,{kind:"secondary",label:`${e.time} \xb7 ${t} \xb7 ${e.partySize} Covers`,testID:`day-table-booking-${e.id}`,accessibilityLabel:`${e.time}, ${t}, ${e.partySize} Covers, ${(0,fe.tablesWords)((0,te.tablesOf)(e.table))}. Opens assign table.`,onPress:()=>{ns(null),sl(e.id)},style:{minHeight:56}},e.id)}),Gl>=Dt?(()=>{const t=e?.table.maxSeats??0,l=ht.filter(e=>e.date===Gl&&!e.walkIn&&!['cancelled','noshow','finished'].includes(e.status)&&!(0,te.tablesOf)(e.table).includes(os)).sort((e,t)=>e.time.localeCompare(t.time));return l.length?(0,Ne.jsxs)(O.default,{testID:"day-table-put",style:{gap:8,alignItems:'stretch'},children:[(0,Ne.jsxs)(G.T,{size:17,weight:"semibold",center:!0,colour:Q.colours.goldLight,children:["Put a booking on ",(0,d.tableNumbersA11y)(os)]}),ds?(0,Ne.jsxs)(O.default,{testID:"day-table-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:ds.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:Q.colours.amber,backgroundColor:Q.colours.amberBg},children:[(0,Ne.jsx)(G.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:ds.ask}),(0,Ne.jsxs)(G.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-yes",label:"Use it anyway",disabled:!Ks.ok,accessibilityHint:Ks.hint,style:{minHeight:56,flexGrow:1},onPress:async()=>{const e=ht.find(e=>e.id===ds.id);if(cs(null),!e)return;const l=Ve(e.name);ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl)}}),(0,Ne.jsx)(G.Button,{testID:"day-table-overcap-no",kind:"secondary",label:"Pick another",style:{minHeight:56},onPress:()=>cs(null)})]})]}):null,ds?null:l.slice(0,12).map(e=>{const l=Ve(e.name),s=e.partySize>t;return(0,Ne.jsx)(G.Button,{kind:"secondary",testID:`day-table-put-${e.id}`,label:`${e.time} \xb7 ${l} \xb7 ${e.partySize} Covers`,sub:s?`Bigger than this table (${t} seats)`:e.table?`Now ${(0,d.tableNumbersA11y)(e.table)}`:'No table yet',disabled:!Ks.ok,accessibilityHint:Ks.hint,accessibilityLabel:`Put ${l}, ${e.time}, ${e.partySize} Covers, on ${(0,d.tableNumbersA11y)(os)}${s?`. This table seats ${t}`:''}`,onPress:async()=>{if(!(0,pe.guardBookingChange)(wl,{b:e,tables:[os]}))return;const s=(0,fe.overCapacityAsk)([os],t,e.partySize);s?cs({id:e.id,ask:s}):(ns(null),await(0,pe.saveTablesReported)(dt,e,[os],l,t,wl))},style:{minHeight:56}},e.id)})]}):null})():null,(0,Ne.jsx)(G.Button,{kind:"ghost",label:"Close",accessibilityLabel:"Close",onPress:()=>{cs(null),ns(null)},style:{minHeight:56}})]})})():null,ll?(()=>{const e=ht.find(e=>e.id===ll);return e?(0,Ne.jsx)(be.GuestActionsSheet,{rid:dt,b:e,name:e.walkIn?(0,ue.privName)(e,$t):Ve(e.name),view:Wl,now:pt,otherDay:e.date!==Dt,turnBase:ct.settings.turnMins,onClose:()=>sl(null),onDetails:Cl,onDone:wl,onEdit:e=>{sl(null),Jt(e.id)},onPickOnPlan:(e,t)=>{tl(!1),Ht('plan'),At('all'),ol({id:e.id,tables:t})}}):null})():null,Ft?(0,Ne.jsx)(xe.DetailsPanel,{title:Ft.title,onClose:()=>Vt(null),children:Ft.body}):null,Xt?(0,Ne.jsx)(xe.ServiceSummary,{r:ct,todays:Tl,orders:ut,waitlistAll:cl,walkInCount:ul,onClose:()=>Zt(!1)}):null,hl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>gl(!1),title:"Table colours and symbols",maxWidth:560,testID:"colour-key",children:[(0,Ne.jsx)(g.FloorLegend,{}),(0,Ne.jsx)(G.T,{center:!0,size:14,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>gl(!1)})]}):null,bl?(0,Ne.jsxs)(G.Sheet,{visible:!0,onClose:()=>yl(!1),title:"Reviews",maxWidth:640,testID:"display-reviews-sheet",children:[(0,Ne.jsx)(F.ReviewsSection,{rid:dt,mode:"read",venueName:ct.name}),(0,Ne.jsx)(G.Button,{kind:"secondary",label:"Close",onPress:()=>yl(!1)})]}):null,Ut?(0,Ne.jsxs)(xe.DetailsPanel,{title:"Takeaway",onClose:()=>Kt(!1),children:[(0,Ne.jsx)(G.Muted,{children:"In-house orders go through your till (EPOS). Only takeaway orders show here."}),(0,Ne.jsx)(Qe,{list:Bl,me:It,bookings:ht})]}):null,kl?(0,Ne.jsx)(O.default,{testID:"display-editor",style:{position:'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e3,backgroundColor:Q.colours.bg},children:(0,Ne.jsx)(ne.PlanDesigner,{initial:Rt,venue:ct.name,mode:"display",startStep:"arrange",onActivity:()=>{vl.current=Date.now(),null!==Dl&&Sl(null)},notice:null!==Dl?`Locking again in ${Dl} s \xb7 touch to keep editing`:null,onSave:e=>{te.useFloor.getState().setPlan(dt,e),Il(null),wl('Table plan saved for every screen. Editing is locked again.')},onLiveChange:e=>{te.useFloor.getState().setPlan(dt,e),wl('Live seating plan updated on every screen.')},onCancel:()=>{Il(null),wl('No changes kept. Editing is locked again.')}},kl.at)}):null,e?null:(0,Ne.jsx)(de.Screensaver,{rid:dt,idleMins:Tt.idleMins,pinOn:Tt.pinOn,wake:Tt,tonightCards:Tt.tonightCards,cfg:Bt}),e?null:(0,Ne.jsx)(we.PrintHost,{rid:dt}),e?null:(0,Ne.jsx)(je.AlertHost,{variant:"display",rid:dt,skipTakeaway:!0}),e?null:(0,Ne.jsx)(z.SeatAllergenReminder,{rid:dt}),e?null:(0,Ne.jsx)(ke.TakeawayTakeover,{rid:dt,me:It})]});var pi};var t=_r(_d[0]),l=_r(_d[1]),s=_r(_d[2]),i=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),g=_r(_d[12]),b=_r(_d[13]),y=_r(_d[14]),p=_r(_d[15]),f=_r(_d[16]),x=_r(_d[17]),j=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),I=_r(_d[21]),v=_r(_d[22]),D=_r(_d[23]),S=_r(_d[24]),C=_r(_d[25]),T=_r(_d[26]),$=e(T),B=_r(_d[27]),R=_r(_d[28]),L=_r(_d[29]),z=_r(_d[30]),W=_r(_d[31]),H=_r(_d[32]),M=e(_r(_d[33])),P=e(_r(_d[34])),E=e(_r(_d[35])),A=e(_r(_d[36])),O=e(_r(_d[37])),N=e(_r(_d[38])),_=_r(_d[39]),G=_r(_d[40]),F=_r(_d[41]),V=_r(_d[42]),U=_r(_d[43]),K=_r(_d[44]),q=_r(_d[45]),Y=_r(_d[46]),Q=_r(_d[47]),J=_r(_d[48]),X=_r(_d[49]),Z=_r(_d[50]),ee=_r(_d[51]),te=_r(_d[52]),le=_r(_d[53]),se=_r(_d[54]),ie=_r(_d[55]),oe=_r(_d[56]),ne=_r(_d[57]),ae=_r(_d[58]),re=_r(_d[59]),de=_r(_d[60]),ce=_r(_d[61]),ue=_r(_d[62]),he=_r(_d[63]),ge=_r(_d[64]),be=_r(_d[65]),ye=_r(_d[66]),pe=_r(_d[67]),fe=_r(_d[68]),me=_r(_d[69]),xe=_r(_d[70]),je=_r(_d[71]),we=_r(_d[72]),ke=_r(_d[73]),Ie=_r(_d[74]),ve=_r(_d[75]),De=_r(_d[76]),Se=_r(_d[77]),Ce=_r(_d[78]),Te=_r(_d[79]),$e=_r(_d[80]),Be=_r(_d[81]),Re=_r(_d[82]),Le=_r(_d[83]),ze=_r(_d[84]),We=_r(_d[85]),He=_r(_d[86]),Me=_r(_d[87]),Pe=_r(_d[88]),Ee=_r(_d[89]),Ae=_r(_d[90]),Oe=_r(_d[91]),Ne=_r(_d[92]);const _e='#221C12',Ge='#2E2618',Fe=12e4,Ve=e=>(e??'').replace(' (example)',''),Ue=e=>'takeaway'===e.type&&!['collected','closed','cancelled'].includes(e.status),Ke=e=>e.slotTime?(0,q.hm)(new Date(e.slotTime)):'ASAP';function qe({items:e,tight:t,phone:l,split:s,inline:i,splitOnly:o}){return(0,Ne.jsxs)(O.default,{style:{borderRadius:14,borderWidth:1,borderColor:'rgba(255,255,255,0.07)',backgroundColor:'rgba(255,255,255,0.025)',overflow:'hidden',alignSelf:o?'center':'stretch',maxWidth:o?560:void 0,width:o?'100%':void 0,flexDirection:i?'row':'column',alignItems:'center'},children:[o?null:(0,Ne.jsx)(O.default,{style:{flexDirection:'row',flexWrap:l?'wrap':'nowrap',justifyContent:'center',alignItems:'center',flexShrink:i?0:void 0},children:e.map((e,s)=>{const i=(0,Ne.jsxs)(O.default,{testID:e.testID,style:{flex:l?1:void 0,minWidth:l?148:void 0,flexBasis:l?148:void 0,flexDirection:l?'column':'row',alignItems:l?'center':'baseline',justifyContent:l?'center':void 0,gap:6,minHeight:44,paddingHorizontal:t?10:14,paddingVertical:6,borderLeftWidth:s?1:0,borderLeftColor:'rgba(255,255,255,0.07)',backgroundColor:e.alert?'rgba(232,168,56,0.14)':'transparent',...l?{minHeight:76}:{}},children:[(0,Ne.jsx)(G.T,{size:l?24:19,weight:"semibold",colour:e.alert?Q.colours.amber:Q.colours.text,children:e.value}),(0,Ne.jsx)(G.T,{size:l?14:12,colour:Q.colours.muted,style:{letterSpacing:.3},children:e.label})]});return e.onPress?(0,Ne.jsx)(E.default,{accessibilityRole:"button",accessibilityLabel:`${e.label} ${e.value}`,onPress:e.onPress,style:l?{flex:1,minWidth:148,flexBasis:148}:void 0,children:i},e.testID):(0,Ne.jsx)($.default.Fragment,{children:i},e.testID)})}),s?(0,Ne.jsx)(O.default,{testID:"covers-split",accessible:!0,accessibilityLabel:s.a11y,style:{width:i?void 0:'100%',flex:i?1:void 0,minWidth:i?180:void 0,paddingHorizontal:12,paddingBottom:i?6:8,paddingTop:i?6:8,gap:4,alignItems:'center',justifyContent:'center',borderTopWidth:i||o?0:1,borderLeftWidth:i?1:0,borderTopColor:'rgba(207,164,95,0.35)',borderLeftColor:'rgba(207,164,95,0.35)'},children:s.empty?(0,Ne.jsx)(G.T,{size:14,colour:Q.colours.muted,children:"No Covers yet"}):(0,Ne.jsxs)(Ne.Fragment,{children:[(0,Ne.jsxs)(O.default,{style:{flexDirection:'row',justifyContent:'center',gap:i?12:18,flexWrap:'wrap'},children:[(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",colour:Q.colours.gold,children:`Walk-ins ${s.walkIns} \xb7 ${s.walkInPct}%`}),(0,Ne.jsx)(G.T,{size:i?13:14,weight:"semibold",children:`Bookings ${s.bookings} \xb7 ${s.bookingPct}%`})]}),(0,Ne.jsxs)(O.default,{style:{width:'100%',maxWidth:i?280:420,height:6,borderRadius:3,overflow:'hidden',flexDirection:'row',backgroundColor:'#0B0B0B',borderWidth:1,borderColor:Q.colours.gold},children:[(0,Ne.jsx)(O.default,{style:{width:`${s.walkInPct}%`,backgroundColor:Q.colours.gold}}),(0,Ne.jsx)(O.default,{style:{flex:1,backgroundColor:'#0B0B0B'}})]})]})}):null]})}function Ye({chipId:e,label:t,sub:l,selected:s,onPress:i,colour:o,compact:n}){return(0,Ne.jsxs)(E.default,{testID:`area-chip-${e}`,accessibilityRole:"button",accessibilityState:{selected:s},accessibilityLabel:`${t}${l?`, ${l}`:''}${s?', selected':''}`,'aria-pressed':s,onPress:i,style:({pressed:e})=>({flexDirection:'row',alignItems:'center',flexShrink:0,gap:n?4:7,minHeight:44,paddingHorizontal:n?6:14,borderRadius:999,borderWidth:1,borderColor:s?'rgba(207,164,95,0.75)':'rgba(255,255,255,0.08)',backgroundColor:s?'rgba(207,164,95,0.16)':e?'rgba(255,255,255,0.06)':'rgba(255,255,255,0.03)'}),children:[o?(0,Ne.jsx)(O.default,{style:{width:7,height:7,borderRadius:4,backgroundColor:o}}):null,(0,Ne.jsx)(G.T,{size:n?12:14,weight:s?'semibold':'medium',colour:s?Q.colours.goldLight:'#CFC8BA',numberOfLines:1,center:!1,children:t}),l?(0,Ne.jsx)(G.T,{size:12,colour:Q.colours.muted,children:l}):null]})}function Qe({list:e,me:t,compact:l,bookings:s}){const i=(e,t)=>(0,Ee.statusBlock)(e,t,(0,Ee.linkedBooking)(e,s));return e.length?(0,Ne.jsx)(O.default,{style:{gap:8},children:e.map(e=>(0,Ne.jsxs)(O.default,{testID:`takeaway-${e.ref}`,style:{backgroundColor:Q.colours.surface2,borderRadius:12,padding:10,gap:4,borderLeftWidth:5,borderLeftColor:'ready'===e.status?Q.colours.ok:e.allergies.length?Q.colours.red:Q.colours.gold},children:[(0,Ne.jsxs)(G.Row,{style:{justifyContent:'space-between'},children:[(0,Ne.jsxs)(G.T,{size:l?16:18,weight:"bold",children:[Ke(e)," \xb7 ",Ve(e.customerName)]}),(0,Ne.jsx)(G.Badge,{kind:'ready'===e.status?'ok':'new'===e.status?'amber':'gold',label:'new'===e.status?'NEW':'ready'===e.status?'READY':'preparing'===e.status?'COOKING':'CONFIRMED'})]}),(0,Ne.jsxs)(G.Muted,{children:[e.ref," \xb7 ",e.lines.reduce((e,t)=>e+t.qty,0)," items",'here'===e.customerSignal?' \xb7 CUSTOMER IS HERE':e.customerSignal?' \xb7 on the way':'']}),e.allergies.length?(0,Ne.jsxs)(G.T,{size:14,weight:"semibold",colour:Q.colours.red,children:["\u26a0 ",e.allergies.map(e=>(0,K.allergenLabel)(e.allergen)).join(', ')]}):null,e.allergies.length?(0,Ne.jsx)(Pe.AllergyChain,{o:e,me:t,compact:!0}):null,(0,Ne.jsxs)(G.Row,{wrap:!0,gap:6,children:['new'!==e.status||e.accepted?null:(0,Ne.jsx)(G.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>Y.repo.orders.accept(e.id,t)}),e.accepted&&['new','acknowledged','preparing'].includes(e.status)?(0,Ne.jsx)(G.Button,{small:!0,kind:"success",label:i(e,'ready')?'Kitchen sign-off first':'Ready',disabled:!!i(e,'ready'),testID:`ready-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'ready',t)}):null,'ready'===e.status?(0,Ne.jsx)(G.Button,{small:!0,label:i(e,'collected')?'Sign-offs needed':'Collected',disabled:!!i(e,'collected'),testID:`collected-${e.ref}`,onPress:()=>Y.repo.orders.setStatus(e.id,'collected',t)}):null,(0,Ne.jsx)(we.ReprintButton,{rid:e.restaurantId,o:e})]})]},e.id))}):(0,Ne.jsx)(G.Muted,{children:"No takeaway orders right now."})}function Je({rid:e,id:t,turnBase:l}){const s=(0,Y.useBookings)(e).find(e=>e.id===t);return s?(0,Ne.jsx)(b.BookingTableButton,{rid:e,booking:s,turnBase:l}):null}},1340,[1162,796,5,6,1341,828,853,1122,860,1161,1342,1343,1344,1119,1143,1345,1346,1351,1352,1353,872,1354,1174,979,1130,1355,34,1099,1196,1048,1115,1157,1356,395,380,402,295,102,426,36,794,1239,1243,873,861,858,874,821,1118,891,1126,1088,1029,1105,1135,1357,1134,1358,1365,1367,1370,1373,1369,1374,1376,1377,1140,1123,1124,878,1381,1228,1382,1238,1230,1026,1387,1395,1396,1102,1142,1398,1399,1400,1098,1189,1401,1188,1181,869,1402,1403,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.queuedServiceSessions=u,e.queuedServicePauses=function(n,t,s){const i=u(n,t);return i?i.slice(1).flatMap((n,t)=>{const u=i[t][1],r=n[0];return u!!t.walkIn||'walk-in'===t.source},1342,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useBookingWrite=function(){const t=(0,s.useSignedIn)(),c=(0,n.canChangeBookings)(t);return{ok:c,hint:c?void 0:n.BOOKING_VIEW_ONLY,lock:s=>c?{disabled:!1,accessibilityLabel:s}:{disabled:!0,accessibilityLabel:s,accessibilityHint:n.BOOKING_VIEW_ONLY}}};var n=r(d[0]),s=r(d[1])},1343,[1027,1088]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.FloorLegend=function({inline:e=!1}){return(0,s.jsx)(l.default,{testID:"floor-legend",accessible:!0,accessibilityLabel:`Table colours: ${c.map(([,e])=>e).join(', ')}`,style:{flexDirection:'row',flexWrap:e?'nowrap':'wrap',gap:e?8:14,alignItems:'center',justifyContent:'center',flexShrink:0},children:c.map(([t,c])=>(0,s.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:e?4:6},children:[(0,s.jsx)(l.default,{testID:`legend-swatch-${t}`,style:{width:e?12:16,height:e?12:16,borderRadius:4,backgroundColor:o.STATUS[t].colour,borderWidth:1,borderColor:'rgba(255,255,255,0.25)'}}),(0,s.jsx)(n.T,{size:e?12:13,center:!0,children:c})]},t))})},r(d[0]);var e,t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},o=r(d[2]),n=r(d[3]),s=r(d[4]);const c=[['free','Free'],['soon','Booked later'],['seated','Seated'],['dirty','Needs clearing']]},1344,[34,102,1105,794,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.TableOrderCue=function({rid:o}){const t=(0,n.useNow)(15e3).getTime(),f=(0,n.useOrders)(o).filter(e=>(0,s.isTableQr)(e)&&('new'===e.status||(0,s.waitingForStaff)(e))&&t-new Date(e.createdAt).getTime()<6e5);if(!f.length)return null;const b=[...new Set(f.map(e=>e.tableNo??'?'))].sort((e,o)=>Number(e)-Number(o)),w=f.some(s.waitingForStaff);return(0,c.jsx)(a.default,{testID:"table-order-cue",style:{marginHorizontal:10,marginTop:6,paddingVertical:6,paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.surface2},children:(0,c.jsxs)(l.T,{weight:"semibold",colour:u.colours.gold,children:["New order \xb7 ",b.map(o=>`${(0,e.tableNumbers)(o)}`).join(', '),w?' \xb7 waiting for staff to accept':'']})})};var e=r(d[0]);r(d[1]);var o,t=r(d[2]),a=(o=t)&&o.__esModule?o:{default:o},l=r(d[3]),n=r(d[4]),s=r(d[5]),u=r(d[6]),c=r(d[7])},1345,[860,34,102,794,874,1175,821,25]); +__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,"VOUCHER_AUTO_SYNC_MS",{enumerable:!0,get:function(){return C}}),_e.GiftQrButton=function({rid:e,venue:R}){const F=(0,b.useFloor)(t=>t.settings[e]),[I,_]=(0,t.useState)(!1),[w,T]=(0,t.useState)(!1),{width:Q,height:S}=(0,l.default)(),z=Math.round(Math.max(180,Math.min(.7*Q,.55*S,520))),k=(0,x.giftQrShown)(F);return(0,t.useEffect)(()=>{const e=setInterval(()=>{(0,p.vouchersLive)()&&(0,p.refreshFromWebsite)()},C);return()=>clearInterval(e)},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(s.default,{testID:"gift-qr-open",accessibilityRole:"button",accessibilityLabel:"Gift vouchers. Opens the list of vouchers to search and mark as used",onPress:()=>_(!0),style:({pressed:e})=>({...h.look.quiet(e),flexGrow:1,flexShrink:1,minWidth:0,minHeight:48}),children:(0,v.jsx)(u.T,{size:15,weight:"semibold",colour:j.colours.goldLight,style:{textAlign:'center'},children:"Gift vouchers"})}),(0,v.jsx)(o.default,{visible:I,animationType:"fade",onRequestClose:()=>{T(!1),_(!1)},supportedOrientations:['portrait','landscape'],children:(0,v.jsx)(n.default,{testID:"gift-voucher-panel",style:{flex:1,backgroundColor:j.colours.bg,alignItems:'center'},children:w&&k?(0,v.jsxs)(n.default,{testID:"gift-qr-panel",style:{flex:1,alignItems:'center',justifyContent:'center',padding:24,gap:20},children:[(0,v.jsx)(n.default,{style:{position:'absolute',top:14,right:14},children:(0,v.jsx)(f.GoldClose,{size:"lg",testID:"gift-qr-close",label:"Close the QR code",onPress:()=>T(!1)})}),(0,v.jsx)(u.T,{size:30,weight:"bold",colour:j.colours.gold,style:{textAlign:'center'},children:x.GIFT_QR_TEXT}),(0,v.jsx)(n.default,{accessible:!0,accessibilityRole:"image",accessibilityLabel:`QR code for ${R}'s gift card page`,style:{padding:14,backgroundColor:'#FFFFFF',borderRadius:16,borderWidth:2,borderColor:j.colours.gold},children:(0,v.jsx)(c.QR,{value:(F.giftQrUrl??'').trim(),size:z})}),(0,v.jsxs)(u.T,{size:20,colour:j.colours.text,style:{textAlign:'center'},children:[R," gift vouchers are sold on our website."]})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(y.VoucherList,{mode:"display",onClose:()=>_(!1)}),k?(0,v.jsx)(s.default,{testID:"gift-qr-show",accessibilityRole:"button",accessibilityLabel:"Show the QR code for buying a gift voucher",onPress:()=>T(!0),style:({pressed:e})=>({minHeight:52,minWidth:260,marginBottom:16,paddingHorizontal:22,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:j.colours.accentBorder,backgroundColor:e?j.colours.goldTint:'transparent'}),children:(0,v.jsx)(u.T,{size:16,weight:"semibold",colour:j.colours.gold,center:!0,children:"Show the buy QR code"})}):null]})})})]})};var t=r(d[0]),o=e(r(d[1])),s=e(r(d[2])),l=e(r(d[3])),n=e(r(d[4])),c=r(d[5]),u=r(d[6]),h=r(d[7]),f=r(d[8]),b=r(d[9]),x=r(d[10]),y=r(d[11]),p=r(d[12]),j=r(d[13]),v=r(d[14]);const C=3e5},1346,[34,395,402,426,102,1285,794,1189,796,1029,1347,1348,1350,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GIFT_QR_TEXT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GIFT_QR_MAX",{enumerable:!0,get:function(){return n}}),e.giftQrUrlOk=o,Object.defineProperty(e,"giftQrShown",{enumerable:!0,get:function(){return u}});const t='Scan to buy a gift card on your phone',n=300;function o(t){const o=(t??'').trim();return!(!o||o.length>n||/\s/.test(o))&&/^https:\/\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+(:\d+)?(\/[^\s]*)?$/i.test(o)}const u=t=>!!t?.giftQrOn&&o(t?.giftQrUrl)},1347,[]); +__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.VoucherList=function({mode:e,onClose:o}){const[I,z]=(0,s.useState)([]),[S,$]=(0,s.useState)(!0),[A,P]=(0,s.useState)(''),[U,N]=(0,s.useState)(null),[W,R]=(0,s.useState)(''),[B,L]=(0,s.useState)('unused'),[O,M]=(0,s.useState)('purchased'),[H,_]=(0,s.useState)(null),[V,E]=(0,s.useState)(!1),[G,Y]=(0,s.useState)(''),[F,q]=(0,s.useState)(!1),[J,K]=(0,s.useState)(''),[Q,X]=(0,s.useState)(()=>Date.now()),[Z,ee]=(0,s.useState)(p.NO_RIGHTS),se=t.default.useRef([]);(0,s.useEffect)(()=>{se.current=I},[I]);const{width:te}=(0,u.default)(),re=(0,s.useCallback)(async()=>{try{z(await(0,y.listVouchers)()),P(''),N(await(0,y.voucherSyncState)()),ee(await(0,y.voucherRights)()),X(Date.now())}catch(e){P(`Could not load the vouchers. ${e.message??''}`.trim())}finally{$(!1)}},[]);(0,s.useEffect)(()=>{let e=!0;const s=setTimeout(()=>{re().then(async()=>{(0,y.vouchersLive)()&&e&&(await(0,y.refreshFromWebsite)(),e&&await re())})},0),t=setInterval(()=>{e&&re()},6e4);return()=>{e=!1,clearTimeout(s),clearInterval(t)}},[re]);const oe=(0,s.useMemo)(()=>(0,p.counts)(I,Q),[I,Q]),le=(0,s.useMemo)(()=>(0,p.filterSort)(I,{q:W,filter:B,sort:O,nowMs:Q}),[I,W,B,O,Q]),ie=te<700,ne=()=>{_(null),E(!1),Y(''),K('')},de=async(e=!1)=>{if(H){q(!0);try{const s=await(0,y.markVoucherUsed)(H.id,G,e);K(`${e?'Car'===s.usedBy?'Car override. ':'Manager override. ':''}Marked as used by ${s.usedBy}. The whole ${(0,p.pounds)(H.valuePence)} is used. Nothing is left on it. It is being switched off on the website.`),E(!1),await re(),_(t=>t?{...t,usedAt:(new Date).toISOString(),usedBy:s.usedBy,usedTable:G.trim()||null,overrideBy:e?s.usedBy:null,wixRedeemState:'sent'===t.wixRedeemState?'sent':'not-sent'}:t),setTimeout(()=>{re().then(()=>_(e=>e?se.current.find(s=>s.id===e.id)??e:e))},4e3)}catch(e){K(e.message||'That did not work. Try again.')}finally{q(!1)}}},ae=async()=>{if(H){q(!0);try{await(0,y.undoVoucherUsed)(H.id),K('Undone. The voucher is unused again.'),await re(),_(e=>e?{...e,usedAt:null,usedBy:null,usedTable:null}:e)}catch(e){K(e.message||'That did not work.')}finally{q(!1)}}},ce=(0,y.vouchersLive)()?U?.lastError?`Website check: ${U.lastError}.${U.lastOkAt?` Last copy ${(0,p.ukDateTime)(U.lastOkAt)}.`:''}`:U?.lastOkAt?`Up to date with the website, ${(0,p.ukDateTime)(U.lastOkAt)}.`:'Checking the website\u2026':'Sample vouchers (demo).',ue=H?(0,p.voucherStatus)(H,Q):'unused',he=H?(0,f.jsx)(r.default,{visible:!0,transparent:!0,animationType:"fade",onRequestClose:ne,supportedOrientations:['portrait','landscape'],children:(0,f.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,f.jsxs)(c.default,{testID:"voucher-detail",accessibilityViewIsModal:!0,style:{width:'100%',maxWidth:620,maxHeight:'96%',backgroundColor:x.colours.surface,borderRadius:20,borderWidth:1.5,borderColor:x.colours.gold,padding:20},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(c.default,{style:{width:44}}),(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:[(0,p.pounds)(H.valuePence)," gift voucher"]}),(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close this voucher",testID:"voucher-detail-close",onPress:ne})]}),(0,f.jsxs)(l.default,{contentContainerStyle:{alignItems:'center',gap:2,paddingVertical:8},children:[(0,f.jsxs)(b.T,{size:18,weight:"semibold",colour:w(ue),center:!0,children:[p.STATUS_WORD[ue],(0,p.expiryWarning)(H,Q)?` \xb7 ${(0,p.expiryWarning)(H,Q)}`:'']}),(0,f.jsx)(D,{k:"Code",v:`${(0,p.maskCode)(H.last4)} (check the end of the code matches)`}),(0,f.jsx)(D,{k:"For",v:[H.recipientName,H.recipientEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"From",v:[H.buyerName,H.buyerEmail].filter(Boolean).join(' \xb7 ')}),(0,f.jsx)(D,{k:"Message",v:H.message}),(0,f.jsx)(D,{k:"Bought",v:`${(0,p.ukDate)(H.purchasedAt)}${H.orderNumber?` \xb7 website order ${H.orderNumber}`:''}`}),(0,f.jsx)(D,{k:"Use by",v:H.expiresAt?(0,p.ukDate)(H.expiresAt):'No use by date'}),H.usedAt?(0,f.jsx)(D,{k:"Used",v:`${(0,p.ukDateTime)(H.usedAt)}${H.usedBy?` by ${H.usedBy}`:''}${H.usedTable?` \xb7 Table ${H.usedTable}`:''}`}):null,'used'!==ue||H.usedAt?null:(0,f.jsx)(D,{k:"Used",v:"On the website"}),H.overrideBy?(0,f.jsx)(D,{k:'Car'===H.overrideBy?'Car override':'Manager override',v:`Allowed after its use by date by ${H.overrideBy}`}):null,(0,p.websiteWords)(H)?(0,f.jsx)(b.T,{testID:"voucher-website",size:15,colour:'failed'===H.wixRedeemState?x.colours.amber:x.colours.muted,center:!0,style:{marginTop:6},children:(0,p.websiteWords)(H)}):null,J?(0,f.jsx)(b.T,{testID:"voucher-msg",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:8},accessibilityLabel:J,children:J}):null,'unused'!==ue&&'expired'!==ue||Z.canMark?null:(0,f.jsx)(b.T,{testID:"voucher-ask",size:17,weight:"semibold",colour:x.colours.goldLight,center:!0,style:{marginTop:12},children:"Ask a manager or use the Display."}),'expired'===ue&&Z.canMark&&!Z.canOverride?(0,f.jsx)(b.T,{testID:"voucher-expired-ask",size:17,weight:"semibold",colour:x.colours.amber,center:!0,style:{marginTop:12},children:"This voucher has run out. Ask a manager: they can allow it in the Managers app."}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&!V?(0,f.jsx)(c.default,{style:{marginTop:14},children:(0,f.jsx)(k,{testID:"voucher-use",label:'expired'===ue?'Manager override: use it':'Mark as used',spoken:'expired'===ue?`Manager override. Use this expired voucher, the whole ${(0,p.pounds)(H.valuePence)}`:`Mark as used. Uses the whole ${(0,p.pounds)(H.valuePence)}`,onPress:()=>{E(!0),K('')}})}):null,('unused'===ue||'expired'===ue&&Z.canOverride)&&Z.canMark&&V?(0,f.jsxs)(c.default,{testID:"voucher-confirm",style:{marginTop:12,alignItems:'center',gap:12,width:'100%',borderTopWidth:1,borderTopColor:x.colours.hairline,paddingTop:12},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",center:!0,accessibilityRole:"header",children:'expired'===ue?`Manager override: use the whole ${(0,p.pounds)(H.valuePence)} now?`:`Use the whole ${(0,p.pounds)(H.valuePence)} now?`}),'expired'===ue?(0,f.jsxs)(b.T,{size:16,colour:x.colours.amber,center:!0,children:["It ran out on ",(0,p.ukDate)(H.expiresAt),". Your name is recorded as allowing it."]}):null,(0,f.jsxs)(b.T,{size:16,colour:x.colours.muted,center:!0,children:["One time use. Nothing will be left on it. It is also switched off on the website. Check the code ends ",H.last4.toUpperCase(),"."]}),(0,f.jsxs)(c.default,{style:{width:220,alignItems:'center',gap:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:"Table (optional)"}),(0,f.jsx)(n.default,{testID:"voucher-table",accessibilityLabel:"Table number, optional",value:G,onChangeText:e=>Y(e.slice(0,12)),placeholder:"e.g. 14",placeholderTextColor:"#7D776C",style:{minHeight:52,width:220,textAlign:'center',fontSize:20,color:x.colours.text,borderWidth:1,borderColor:x.colours.border,borderRadius:12,backgroundColor:x.colours.surface2}})]}),(0,f.jsxs)(c.default,{style:{flexDirection:ie?'column':'row',gap:12,alignItems:'center',justifyContent:'center'},children:[(0,f.jsx)(k,{testID:"voucher-use-yes",label:'expired'===ue?'Yes, allow and use it':'Yes, mark as used',spoken:'expired'===ue?`Yes, manager override, use the expired ${(0,p.pounds)(H.valuePence)} voucher`:`Yes, mark the ${(0,p.pounds)(H.valuePence)} voucher as used`,disabled:F,onPress:()=>{de('expired'===ue)}}),(0,f.jsx)(k,{testID:"voucher-use-no",kind:"quiet",label:"Cancel",spoken:"Cancel, do not mark as used",disabled:F,onPress:()=>E(!1)})]})]}):null,'managers'===e&&Z.canUndo&&(0,p.canUndoNow)(H)?(0,f.jsx)(c.default,{style:{marginTop:12},children:(0,f.jsx)(k,{testID:"voucher-undo",kind:"quiet",label:"Undo, it was not used",spoken:"Undo mark as used. Only before the website switches it off",disabled:F,onPress:()=>{ae()}})}):null]})]})})}):null;return(0,f.jsxs)(c.default,{testID:"voucher-list",style:{flex:1,width:'100%',maxWidth:980,alignSelf:'center',alignItems:'stretch',gap:12,padding:'display'===e?18:0},children:[(0,f.jsxs)(c.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'center'},children:[o?(0,f.jsx)(c.default,{style:{width:54}}):null,(0,f.jsx)(b.T,{size:'display'===e?30:24,weight:"bold",colour:x.colours.gold,style:{flex:1},center:!0,accessibilityRole:"header",children:"Gift vouchers"}),o?(0,f.jsx)(h.GoldClose,{size:"lg",label:"Close gift vouchers",testID:"vouchers-close",onPress:o}):null]}),S||Z.canMark?null:(0,f.jsx)(b.T,{testID:"vouchers-viewonly",size:15,weight:"semibold",colour:x.colours.goldLight,center:!0,children:"You can look. Ask a manager or use the Display to mark one as used."}),(0,f.jsx)(b.T,{testID:"vouchers-sync",size:14,colour:U?.lastError?x.colours.amber:x.colours.muted,center:!0,children:ce}),(0,f.jsx)(n.default,{testID:"voucher-search",accessibilityLabel:"Search vouchers by code, name or email",value:W,onChangeText:R,placeholder:"Search code, name or email",placeholderTextColor:"#7D776C",autoCapitalize:"none",autoCorrect:!1,style:{minHeight:58,fontSize:20,textAlign:'center',color:x.colours.text,borderWidth:1.5,borderColor:x.colours.accentBorder,borderRadius:16,backgroundColor:x.colours.surface2,paddingHorizontal:16,alignSelf:'center',width:'100%',maxWidth:640}}),(0,f.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},accessibilityLabel:"Show",children:[j.map(e=>(0,f.jsx)(T,{testID:`voucher-filter-${e.id}`,label:`${e.label} ${oe[e.id]}`,spoken:`${e.label}, ${oe[e.id]}`,selected:B===e.id,onPress:()=>L(e.id)},e.id)),oe.cancelled?(0,f.jsx)(T,{testID:"voucher-filter-cancelled",label:`Cancelled ${oe.cancelled}`,spoken:`Cancelled on the website, ${oe.cancelled}`,selected:'cancelled'===B,onPress:()=>L('cancelled')}):null]}),(0,f.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10,justifyContent:'center'},children:v.map(e=>(0,f.jsx)(T,{testID:`voucher-sort-${e.id}`,label:e.label,spoken:e.spoken,selected:O===e.id,onPress:()=>M(e.id)},e.id))}),A?(0,f.jsx)(b.T,{size:16,colour:x.colours.red,center:!0,children:A}):null,(0,f.jsxs)(l.default,{style:{flex:1},contentContainerStyle:{gap:10,paddingBottom:24},children:[S?(0,f.jsx)(b.T,{size:17,colour:x.colours.muted,center:!0,children:"Loading vouchers\u2026"}):null,S||0!==le.length?null:(0,f.jsx)(b.T,{testID:"vouchers-none",size:18,colour:x.colours.muted,center:!0,children:W.trim()?'No voucher matches that search.':`No ${'all'===B?'':p.STATUS_WORD[B].toLowerCase()+' '}vouchers.`}),le.map(e=>(0,f.jsx)(C,{v:e,now:Q,onPress:()=>{_(e),E(!1),K(''),Y('')}},e.id))]}),he]})},Object.defineProperty(_e,"voucherCodeLabel",{enumerable:!0,get:function(){return I}});var s=_r(d[0]),t=e(s),r=e(_r(d[1])),o=e(_r(d[2])),l=e(_r(d[3])),n=e(_r(d[4])),c=e(_r(d[5])),u=e(_r(d[6])),h=_r(d[7]),b=_r(d[8]),x=_r(d[9]),p=_r(d[10]),y=_r(d[11]),f=_r(d[12]);const j=[{id:'unused',label:'Unused'},{id:'used',label:'Used'},{id:'expired',label:'Expired'},{id:'all',label:'All'}],v=[{id:'purchased',label:'Newest bought',spoken:'Sort by date bought, newest first'},{id:'expiry',label:'Use by soonest',spoken:'Sort by use by date, soonest first'}],w=e=>'unused'===e?x.colours.goldLight:'expired'===e?x.colours.red:x.colours.muted;function T({label:e,selected:s,onPress:t,testID:r,spoken:l}){return(0,f.jsx)(o.default,{testID:r,accessibilityRole:"button",accessibilityState:{selected:!!s},accessibilityLabel:`${l??e}${s?', selected':''}`,onPress:t,style:({pressed:e})=>({minHeight:52,minWidth:110,paddingHorizontal:18,borderRadius:26,alignItems:'center',justifyContent:'center',borderWidth:1.5,borderColor:s?x.colours.gold:x.colours.accentBorder,backgroundColor:s?x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:17,weight:"semibold",colour:s?x.colours.onGold:x.colours.text,center:!0,children:e})})}function k({label:e,onPress:s,testID:t,spoken:r,kind:l="gold",disabled:n}){const c='gold'===l;return(0,f.jsx)(o.default,{testID:t,accessibilityRole:"button",accessibilityLabel:r??e,accessibilityState:{disabled:!!n},disabled:n,onPress:s,style:({pressed:e})=>({minHeight:60,minWidth:200,paddingHorizontal:26,borderRadius:16,alignItems:'center',justifyContent:'center',opacity:n?.4:1,borderWidth:1.5,borderColor:x.colours.gold,backgroundColor:c?e?x.colours.goldLight:x.colours.gold:e?x.colours.goldTint:'transparent'}),children:(0,f.jsx)(b.T,{size:19,weight:"semibold",colour:c?x.colours.onGold:x.colours.gold,center:!0,children:e})})}function C({v:e,now:s,onPress:t}){const r=(0,p.voucherStatus)(e,s),l=(0,p.expiryWarning)(e,s),n=e.recipientName||e.buyerName||'No name given',h=(0,u.default)().width<600,y=`${e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:''}${(0,p.maskCode)(e.last4)}`;return h?(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:14,alignItems:'center',gap:4}),children:[(0,f.jsxs)(b.T,{size:24,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:[(0,p.pounds)(e.valuePence)," ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:w(r),children:p.STATUS_WORD[r]})]}),(0,f.jsx)(b.T,{size:18,weight:"semibold",center:!0,children:n}),(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:y}),(0,f.jsxs)(b.T,{size:14,center:!0,children:["Bought ",(0,p.ukDate)(e.purchasedAt)," \xb7 Use by ",(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}):(0,f.jsxs)(o.default,{testID:`voucher-${e.id}`,accessibilityRole:"button",accessibilityLabel:(0,p.voucherSpoken)(e,s),accessibilityHint:"Opens this voucher",onPress:t,style:({pressed:e})=>({minHeight:84,borderRadius:16,borderWidth:1,borderColor:l?x.colours.amber:x.colours.border,backgroundColor:e?x.colours.tilePressed:x.colours.tile,paddingVertical:12,paddingHorizontal:18,flexDirection:'row',alignItems:'center',gap:16}),children:[(0,f.jsxs)(c.default,{style:{width:92,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:26,weight:"bold",colour:'unused'===r?x.colours.gold:x.colours.muted,center:!0,children:(0,p.pounds)(e.valuePence)}),(0,f.jsx)(b.T,{size:13,weight:"semibold",colour:w(r),center:!0,children:p.STATUS_WORD[r]})]}),(0,f.jsxs)(c.default,{style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:19,weight:"semibold",numberOfLines:1,center:!0,children:n}),(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,numberOfLines:1,center:!0,children:[e.recipientName&&e.buyerName&&e.buyerName!==e.recipientName?`From ${e.buyerName} \xb7 `:'',(0,p.maskCode)(e.last4)]}),l?(0,f.jsx)(b.T,{size:14,weight:"semibold",colour:x.colours.amber,center:!0,children:l}):null,'used'===r&&e.usedAt?(0,f.jsxs)(b.T,{size:14,colour:x.colours.muted,center:!0,numberOfLines:1,children:["Used ",(0,p.ukDateTime)(e.usedAt),e.usedBy?` \xb7 ${e.usedBy}`:'',e.usedTable?` \xb7 Table ${e.usedTable}`:'']}):null,'used'!==r||e.usedAt?null:(0,f.jsx)(b.T,{size:14,colour:x.colours.muted,center:!0,children:"Used on the website"})]}),(0,f.jsxs)(c.default,{style:{width:132,alignItems:'center'},children:[(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Bought"}),(0,f.jsx)(b.T,{size:15,center:!0,children:(0,p.ukDate)(e.purchasedAt)}),(0,f.jsx)(b.T,{size:12,colour:x.colours.muted,center:!0,children:"Use by"}),(0,f.jsx)(b.T,{size:15,weight:"semibold",colour:'expired'===r?x.colours.red:l?x.colours.amber:x.colours.text,center:!0,children:e.expiresAt?(0,p.ukDate)(e.expiresAt):'No date'})]})]})}function D({k:e,v:s}){return s?(0,f.jsxs)(c.default,{accessible:!0,accessibilityLabel:`${e}: ${s}`,style:{alignItems:'center',paddingVertical:4},children:[(0,f.jsx)(b.T,{size:13,colour:x.colours.muted,center:!0,children:e}),(0,f.jsx)(b.T,{size:18,center:!0,children:s})]}):null}const I=p.spokenCode},1348,[34,395,402,295,412,102,426,796,794,821,1349,1350,25]); +__d(function(_g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NO_RIGHTS",{enumerable:!0,get:function(){return t}}),e.websiteWords=function(t){return t.usedAt?'sent'===t.wixRedeemState?'Switched off on the website too.':'failed'===t.wixRedeemState?`Not switched off on the website yet${t.wixError?` (${t.wixError})`:''}. CoverCharge keeps trying.`:'Switching it off on the website\u2026':null},Object.defineProperty(e,"canUndoNow",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"EXPIRY_WARN_DAYS",{enumerable:!0,get:function(){return a}}),e.voucherStatus=o,Object.defineProperty(e,"STATUS_WORD",{enumerable:!0,get:function(){return s}}),e.ukDate=c,e.ukDateTime=l,Object.defineProperty(e,"maskCode",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return f}}),e.daysLeft=b,e.expiryWarning=y,e.matchesSearch=A,e.filterSort=function(t,n){const a=t.filter(t=>('all'===n.filter||o(t,n.nowMs)===n.filter)&&A(t,n.q)),u=t=>t.expiresAt?Date.parse(t.expiresAt):Number.MAX_SAFE_INTEGER;return a.sort('expiry'===n.sort?(t,n)=>u(t)-u(n)||Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt):(t,n)=>Date.parse(n.purchasedAt)-Date.parse(t.purchasedAt))},e.counts=function(t,n){const a={all:t.length,unused:0,used:0,expired:0,cancelled:0};for(const u of t)a[o(u,n)]++;return a},e.voucherSpoken=function(t,n){const a=o(t,n),u=t.recipientName?`for ${t.recipientName}`:'',d=t.buyerName?`from ${t.buyerName}`:'',b=[`${f(t.valuePence)} voucher`,u,d,p(t.last4),s[a],`bought ${c(t.purchasedAt)}`,t.expiresAt?`use by ${c(t.expiresAt)}`:'no use by date'],x=y(t,n);x&&b.push(x);'used'===a&&t.usedAt&&b.push(`used ${l(t.usedAt)}${t.usedBy?` by ${t.usedBy}`:''}`);return b.filter(Boolean).join(', ')},e.sampleVouchers=function(t){const n=n=>new Date(t+n*u).toISOString(),a={wixDisabledAt:null,usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none',message:null};return[{...a,id:'s1',last4:'K7Q2',valuePence:5e3,wixBalancePence:5e3,buyerName:'Fiona Reid',buyerEmail:'fiona.reid@example.com',recipientName:'Callum Reid',recipientEmail:'callum.reid@example.com',orderNumber:'10702',purchasedAt:n(-3),expiresAt:n(180)},{...a,id:'s2',last4:'M3X9',valuePence:1e4,wixBalancePence:1e4,buyerName:'Iain Paterson',buyerEmail:'iain.p@example.com',recipientName:'Morag Paterson',recipientEmail:'morag@example.com',orderNumber:'10598',purchasedAt:n(-160),expiresAt:n(12)},{...a,id:'s3',last4:'T8B4',valuePence:3e3,wixBalancePence:3e3,buyerName:'Kirsty Boyd',buyerEmail:'kirsty.boyd@example.com',recipientName:'Euan Boyd',recipientEmail:null,orderNumber:'10655',purchasedAt:n(-40),expiresAt:n(140),usedAt:n(-1),usedBy:'Display',usedTable:'14',usedPence:3e3,wixRedeemState:'sent'},{...a,id:'s4',last4:'R2D6',valuePence:2e3,wixBalancePence:2e3,buyerName:'Graham Shaw',buyerEmail:'g.shaw@example.com',recipientName:'Ailsa Shaw',recipientEmail:'ailsa.shaw@example.com',orderNumber:'10102',purchasedAt:n(-200),expiresAt:n(-17)},{...a,id:'s5',last4:'W5N1',valuePence:15e3,wixBalancePence:15e3,buyerName:'Lorna Kerr',buyerEmail:'lorna.kerr@example.com',recipientName:'Lorna & Alan Kerr',recipientEmail:'lorna.kerr@example.com',orderNumber:'10688',purchasedAt:n(-10),expiresAt:n(172)}]};const t={canMark:!1,canOverride:!1,canUndo:!1};const n=t=>!!t.usedAt&&'sending'!==t.wixRedeemState&&'sent'!==t.wixRedeemState,a=30,u=864e5;function o(t,n){return t.usedAt||t.wixBalancePencea.find(n=>n.type===t)?.value??'';return`${u('day')}/${u('month')}/${u('year')}`}function l(t){if(!t)return'';const n=Date.parse(t);if(!Number.isFinite(n))return'';const a=new Intl.DateTimeFormat('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit',hour12:!1}).format(new Date(n));return`${c(t)} at ${a}`}const d=t=>`\u2022\u2022\u2022\u2022${(t||'????').toUpperCase()}`,p=t=>`code ending ${(t||'').toUpperCase().split('').join(' ')}`,f=t=>`\xa3${(Math.max(0,t)/100).toFixed(t%100==0?0:2)}`;function b(t,n){return t.expiresAt?Math.ceil((Date.parse(t.expiresAt)-n)/u):null}function y(t,n){if('unused'!==o(t,n))return null;const u=b(t,n);return null==u||u>a?null:u<=1?'Runs out today':`Runs out in ${u} days`}const x=t=>t.toLowerCase().replace(/\s+/g,' ').trim(),h=t=>t.toUpperCase().replace(/[^A-Z0-9]/g,'');function A(t,n){const a=x(n);if(!a)return!0;const u=h(n),o=(t.last4||'').toUpperCase();if(o&&u.length>=3&&(u.endsWith(o)||o.endsWith(u)))return!0;const s=[t.buyerName,t.buyerEmail,t.recipientName,t.recipientEmail,t.orderNumber?`order ${t.orderNumber}`:null].filter(Boolean).map(t=>x(String(t)));return a.split(' ').every(t=>s.some(n=>n.includes(t)))}},1349,[]); +__d(function(g,_r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"vouchersLive",{enumerable:!0,get:function(){return d}}),e.listVouchers=async function(){if(!d())return p().map(n=>({...n}));const{data:n,error:r}=await c().from('vouchers').select(o).eq('venue_id',s.useSync.getState().venueId).order('purchased_at',{ascending:!1}).limit(2e3);if(r)throw r;return(n??[]).map(y)},e.voucherSyncState=async function(){if(!d())return null;const{data:n}=await c().rpc('voucher_sync_status',{p_venue:s.useSync.getState().venueId}),r=n??null;return r?{lastOkAt:r.lastOkAt??null,lastError:r.lastError??null,count:r.count??null}:null},e.refreshFromWebsite=async function(){if(!d())return;try{await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'open'}})}catch{}},e.switchOffOnWebsiteNow=f,e.voucherRights=async function(){if(!d()){const n=s.useSync.getState(),u=n.perms.includes('*')||n.perms.includes('venue.settings')||['owner','manager','supervisor'].includes(String(n.role||''));if(r.IS_CAR)return t.NO_RIGHTS;const c='display'===r.APP_VARIANT;return{canMark:c||u||'owner'===r.APP_VARIANT,canOverride:!c&&(u||'owner'===r.APP_VARIANT),canUndo:!c&&(u||'owner'===r.APP_VARIANT)}}if(r.IS_CAR)return t.NO_RIGHTS;const{data:n,error:u}=await c().rpc('voucher_rights',{p_venue:s.useSync.getState().venueId});if(u||!n)return t.NO_RIGHTS;const o=n;return{canMark:!0===o.canMark,canOverride:!0===o.canOverride,canUndo:!0===o.canUndo}},e.markVoucherUsed=async function(n,r,t=!1){if(!d()){const u=p().find(r=>r.id===n);if(!u)throw new Error('That voucher was not found.');if(u.usedAt)throw new Error('This voucher has already been used.');return Object.assign(u,{usedAt:(new Date).toISOString(),usedBy:l(),usedTable:r?.trim()||null,usedPence:u.wixBalancePence,wixRedeemState:'sent',overrideBy:t?l():null}),{usedBy:u.usedBy}}const{data:u,error:s}=await c().rpc('voucher_mark_used',{p_id:n,p_by:l(),p_table:r?.trim()||null,p_booking:null,p_override:t});if(s)throw new Error(s.message);return f(),{usedBy:String(u?.usedBy||l())}},e.undoVoucherUsed=async function(n){if(!d()){const r=p().find(r=>r.id===n);return void(r&&Object.assign(r,{usedAt:null,usedBy:null,usedTable:null,usedPence:null,wixRedeemState:'none'}))}const{error:r}=await c().rpc('voucher_undo_used',{p_id:n,p_by:l()});if(r)throw new Error(r.message)};var n=_r(_d[0]),r=_r(_d[1]),t=_r(_d[2]),u=_r(_d[3]),s=_r(_d[4]);const c=()=>(0,u.getSupabase)(),o='id,last4,value_pence,wix_balance_pence,buyer_name,buyer_email,recipient_name,recipient_email,message,order_number,purchased_at,expires_at,wix_disabled_at,used_at,used_by,used_table,used_pence,wix_redeem_state,wix_error,override_by',d=()=>{const n=s.useSync.getState();return!!n.venueId&&'off'!==n.mode&&'local'!==n.mode},l=()=>(0,n.actorStamp)({isCar:r.IS_CAR,kind:s.useSync.getState().kind,staffRef:s.useSync.getState().staffRef,fallback:'display'===r.APP_VARIANT?'Display':'Staff'});let _=null;const p=()=>_??=(0,t.sampleVouchers)(Date.now());function y(n){const r=r=>null==n[r]?null:String(n[r]),t=String(n.wix_redeem_state||'none');return{id:String(n.id),last4:String(n.last4||''),valuePence:Number(n.value_pence||0),wixBalancePence:Number(n.wix_balance_pence??n.value_pence??0),buyerName:r('buyer_name'),buyerEmail:r('buyer_email'),recipientName:r('recipient_name'),recipientEmail:r('recipient_email'),message:r('message'),orderNumber:r('order_number'),purchasedAt:String(n.purchased_at||''),expiresAt:r('expires_at'),wixDisabledAt:r('wix_disabled_at'),usedAt:r('used_at'),usedBy:r('used_by'),usedTable:r('used_table'),usedPence:null==n.used_pence?null:Number(n.used_pence),wixRedeemState:['none','not-sent','sending','sent','failed'].includes(t)?t:'none',wixError:r('wix_error'),overrideBy:r('override_by')}}async function f(n=3e4){if(!d())return!1;const r=async()=>{try{return!(await(0,u.getSupabase)().functions.invoke('wix-vouchers-sync',{body:{source:'used'}})).error}catch{return!1}};return!!await r()||(await new Promise(r=>setTimeout(r,n)),r())}},1350,[1025,872,1349,933,987]); +__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 n}}),Object.defineProperty(e,"useDisplayToolsH",{enumerable:!0,get:function(){return s}});var t=r(d[0]);const n=(0,t.create)(t=>({asleep:!1,set:n=>t({asleep:n})})),s=(0,t.create)(()=>({h:65}))},1351,[846]); +__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,"EXIT_LABEL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"EXIT_ARMED_LABEL",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"EXIT_UPDATE_TEXT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"EXIT_ARM_MS",{enumerable:!0,get:function(){return j}}),_e.nativeExit=C,Object.defineProperty(_e,"inTabletApp",{enumerable:!0,get:function(){return w}}),_e.ExitButton=function(){const[e,D]=(0,o.useState)(!1),[E,I]=(0,o.useState)(!1),v=(0,o.useRef)(null);(0,o.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);const _=w();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.default,{testID:"display-exit",accessibilityRole:"button",accessibilityLabel:e?y:f,onPress:()=>{if(!e)return D(!0),v.current&&clearTimeout(v.current),void(v.current=setTimeout(()=>D(!1),j));v.current&&clearTimeout(v.current),D(!1);const t=C();if(t)try{t.exit()}catch{}else{try{T()?.CoverChargeNative?.checkUpdate?.()}catch{}I(!0)}},hitSlop:6,style:({pressed:e})=>({...p.look.quiet(e),flexGrow:0,minHeight:44,minWidth:44,paddingHorizontal:8,alignItems:'center',justifyContent:'center'}),children:(0,h.jsx)(u.T,{size:12,weight:e?'semibold':'regular',colour:e?b.colours.gold:b.colours.muted,children:e?'Exit?':'Exit'})}),(0,h.jsx)(s.default,{visible:E,transparent:!0,animationType:"fade",onRequestClose:()=>I(!1),supportedOrientations:['portrait','landscape'],children:(0,h.jsx)(c.default,{style:{flex:1,backgroundColor:'rgba(0,0,0,0.75)',alignItems:'center',justifyContent:'center',padding:24},children:(0,h.jsxs)(c.default,{testID:"display-exit-update",accessibilityViewIsModal:!0,style:{maxWidth:560,width:'100%',gap:16,padding:24,borderRadius:16,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:(0,t.soutersSurface)('#141414')},children:[(0,h.jsx)(u.T,{size:22,weight:"bold",colour:b.colours.gold,children:x}),_?(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"A new Display app is ready. Open the tablet's recent apps, swipe Cover Charge for Display away, then open it again. After a few seconds a large \u201cUpdate the Display app\u201d button appears at the bottom: tap it and Android asks you to confirm."}):(0,h.jsx)(u.T,{size:17,colour:b.colours.text,children:"Exit closes the Display tablet app. In a web browser, close the tab instead, or install the Display tablet app."}),(0,h.jsxs)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:[_?null:(0,h.jsx)(l.default,{testID:"display-exit-get",accessibilityRole:"link",accessibilityLabel:"Get the Display tablet app",onPress:()=>{n.default.openURL('/tablet.html')},style:({pressed:e})=>({minHeight:56,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Get the Display app"})}),(0,h.jsx)(l.default,{testID:"display-exit-close",accessibilityRole:"button",accessibilityLabel:"Close",onPress:()=>I(!1),style:({pressed:e})=>({minHeight:56,minWidth:120,paddingHorizontal:20,alignItems:'center',justifyContent:'center',borderRadius:14,borderWidth:1.5,borderColor:b.colours.gold,backgroundColor:e?b.colours.goldTint:'transparent'}),children:(0,h.jsx)(u.T,{size:18,weight:"semibold",colour:b.colours.gold,children:"Close"})})]})]})})})]})};var t=r(d[0]),o=r(d[1]),n=e(r(d[2])),s=e(r(d[3])),l=e(r(d[4])),c=e(r(d[5])),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]);const f='Exit the Display app',y='Tap again to exit the Display app',x='Update the Display app to use Exit',j=3e3,T=()=>'undefined'!=typeof window?window:void 0;function C(){const e=T()?.CoverChargeNative;return e&&'function'==typeof e.exit?e:null}const w=()=>/CoverChargeTablet\//.test(String(T()?.navigator?.userAgent??''))},1352,[828,34,379,395,402,102,794,1189,821,25]); +__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,"hh",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"isKitchen",{enumerable:!0,get:function(){return y}}),_e.rotaDay=p,_e.DisplayRotaKitchenButtons=function({phone:e,shifts:r,staff:l,today:a,leave:c}){const[h,u]=(0,t.useState)(null);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(o.default,{testID:"display-extra-tabs",style:{flexDirection:'row',gap:6,alignSelf:e?'stretch':'flex-start'},children:[(0,d.jsx)(s.default,{testID:"display-rota",accessibilityRole:"button",accessibilityLabel:"Rota",accessibilityHint:"Shows the published rota. View only.",onPress:()=>u('rota'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Rota"})}),(0,d.jsx)(s.default,{testID:"display-kitchen",accessibilityRole:"button",accessibilityLabel:"Kitchen",accessibilityHint:"For chefs: deliveries, stock, prices, GP and the kitchen tools",onPress:()=>u('kitchen'),style:({pressed:t})=>[m,{flex:e?1:void 0,backgroundColor:t?n.colours.goldTint:'rgba(255,255,255,0.035)'}],children:(0,d.jsx)(i.T,{size:e?16:13,weight:"semibold",colour:n.colours.goldLight,children:"Kitchen"})})]}),'rota'===h?(0,d.jsx)(x,{shifts:r,staff:l,today:a,leave:c,onClose:()=>u(null)}):null,'kitchen'===h?(0,d.jsx)(j,{onClose:()=>u(null)}):null]})};var t=_r(_d[0]);_r(_d[1]);var s=e(_r(_d[2])),o=e(_r(_d[3])),i=_r(_d[4]),n=_r(_d[5]),r=_r(_d[6]),l=_r(_d[7]),a=_r(_d[8]),c=_r(_d[9]),d=_r(_d[10]);const h=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],u=['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],f=e=>{const t=Math.round((e%24+24)%24*60);return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},b=/kitchen|chef|kp|porter|cook|commis|sous|pastry|larder/i,y=e=>!!e&&b.test(`${e.dept??''} ${e.job??''}`);function p(e,t,s,o){const i=new Map(t.map(e=>[e.id,e]));return e.filter(e=>e.date===s&&e.published).sort((e,t)=>e.start-t.start||e.end-t.end).map(e=>{const t=i.get(e.staffId),s=o?.length?(0,c.leaveCovering)(o,e.staffId,e.date):void 0;return{id:e.id,name:t?.nickname||t?.name||'Team member',job:t?.job??'',kitchen:y(t),from:f(e.start),to:f(e.end),note:e.note??'',off:s?(0,c.leaveLabel)(s):''}})}const m={minHeight:52,minWidth:88,paddingHorizontal:12,borderRadius:11,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:n.colours.accentBorder};function x({shifts:e,staff:l,today:f,leave:b,onClose:y}){const[m,x]=(0,t.useState)(f),j=(0,r.mondayOfDate)(m),k=(0,t.useMemo)(()=>h.map((e,t)=>(0,r.addDays)(j,t)),[j]),C=(0,t.useMemo)(()=>p(e,l,m,b),[e,l,m,b]),D=(0,t.useMemo)(()=>k.map(t=>(0,c.workingShifts)(e,b).filter(e=>e.date===t&&e.published).length),[k,e,b]),w=(0,r.weekdayOf)(m),v=`${m===f?'Today, ':''}${u[w]} ${(0,a.niceDate)((0,a.parseYmd)(m)).replace(/^\S+ /,'')}`,$=(e,t)=>t.length?(0,d.jsxs)(o.default,{style:{gap:6},children:[(0,d.jsx)(i.T,{size:12,weight:"semibold",colour:n.colours.goldMuted,style:{letterSpacing:1.4},children:e}),t.map(e=>(0,d.jsxs)(o.default,{testID:`rota-row-${e.id}`,accessible:!0,accessibilityLabel:`${e.name}${e.job?`, ${e.job}`:''}, ${e.off?`${e.off}, rota ${e.from} to ${e.to} covered`:`${e.from} to ${e.to}`}${e.note?`. ${e.note}`:''}`,style:{flexDirection:'row',alignItems:'center',gap:10,minHeight:48,paddingHorizontal:12,paddingVertical:6,borderRadius:12,borderWidth:1,borderColor:n.colours.hairline},children:[(0,d.jsxs)(o.default,{style:{flex:1,minWidth:0},children:[(0,d.jsx)(i.T,{size:16,weight:"semibold",numberOfLines:1,children:e.name}),e.job||e.note?(0,d.jsx)(i.Muted,{numberOfLines:1,center:!1,children:[e.job,e.note].filter(Boolean).join(' \xb7 ')}):null]}),e.off?(0,d.jsx)(i.T,{size:16,weight:"semibold",colour:n.colours.blue,testID:`rota-off-${e.id}`,children:e.off}):(0,d.jsxs)(i.T,{size:16,weight:"semibold",colour:n.colours.goldLight,children:[e.from,"\u2013",e.to]})]},e.id))]},e):null;return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:y,title:"Rota",maxWidth:720,testID:"display-rota-sheet",children:[(0,d.jsx)(i.Muted,{children:"View only. Changes are made in Cover Charge for Managers \u203a Rota."}),(0,d.jsxs)(o.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,d.jsx)(i.Button,{kind:"secondary",label:"\u2039 Week before",testID:"rota-prev-week",accessibilityLabel:"Week before",onPress:()=>x((0,r.addDays)(j,-7)),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"This week",testID:"rota-this-week",accessibilityLabel:"This week",onPress:()=>x(f),style:{minHeight:48,flex:1}}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Week after \u203a",testID:"rota-next-week",accessibilityLabel:"Week after",onPress:()=>x((0,r.addDays)(j,7)),style:{minHeight:48,flex:1}})]}),(0,d.jsx)(o.default,{accessibilityRole:"tablist",testID:"rota-days",style:{flexDirection:'row',gap:4},children:k.map((e,t)=>{const o=e===m;return(0,d.jsxs)(s.default,{testID:`rota-day-${e}`,accessibilityRole:"tab",accessibilityState:{selected:o},accessibilityLabel:`${u[t]} ${(0,a.niceDate)((0,a.parseYmd)(e)).replace(/^\S+ /,'')}${e===f?', today':''}, ${D[t]} on`,onPress:()=>x(e),style:{flex:1,minHeight:56,borderRadius:10,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:o?n.colours.gold:n.colours.hairline,backgroundColor:o?n.colours.gold:'transparent'},children:[(0,d.jsx)(i.T,{size:13,weight:"semibold",colour:o?n.colours.bg:e===f?n.colours.goldLight:n.colours.text,children:h[t]}),(0,d.jsx)(i.T,{size:12,colour:o?n.colours.bg:n.colours.muted,children:Number(e.slice(8))})]},e)})}),(0,d.jsxs)(i.T,{size:17,weight:"semibold",center:!0,testID:"rota-day-title",children:[v," \xb7 ",C.filter(e=>!e.off).length," on",C.some(e=>e.off)?` \xb7 ${C.filter(e=>e.off).length} on time off`:'']}),C.length?(0,d.jsxs)(d.Fragment,{children:[$('KITCHEN',C.filter(e=>e.kitchen)),$('FRONT OF HOUSE',C.filter(e=>!e.kitchen))]}):(0,d.jsx)(i.Muted,{testID:"rota-empty",children:"No published shifts this day."}),(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"rota-close",onPress:y,style:{minHeight:48}})]})}function j({onClose:e}){const s=(0,l.appUrl)('chef'),[n,r]=(0,t.useState)(null);return(0,d.jsxs)(i.Sheet,{visible:!0,onClose:e,title:"Kitchen",maxWidth:560,testID:"display-kitchen-sheet",children:[(0,d.jsx)(i.Muted,{children:"For chefs. Opens Cover Charge for Head Chef with your own sign-in, so prices and GP stay off the Display."}),(0,d.jsx)(o.default,{style:{gap:4},accessible:!0,accessibilityLabel:"In the Head Chef app: Deliveries and stock, Stock count, Prices, GP and costing, recipe cards, HACCP and kitchen checks",children:['Deliveries & stock: type in a delivery and its prices','Stock count: count items and see the stock value','Prices: the ingredient price list','GP & costing: every dish\u2019s GP against your target','Recipe cards, HACCP and kitchen checks'].map(e=>(0,d.jsxs)(i.T,{size:15,children:["\u2022 ",e]},e))}),(0,d.jsx)(i.Button,{label:"Open the Head Chef app",testID:"display-open-chef",accessibilityHint:"Opens in a new tab. The Display stays open.",onPress:()=>{if(!s)return void r('Open Cover Charge for Head Chef on this device.');const e=window.open(s,'_blank');if(e)try{e.opener=null}catch{}else r('Your browser blocked the new tab. Open Cover Charge for Head Chef from the home screen.')},style:{minHeight:56}}),n?(0,d.jsx)(i.Muted,{children:n}):null,(0,d.jsx)(i.Button,{kind:"secondary",label:"Close",testID:"kitchen-close",onPress:e,style:{minHeight:48}})]})}},1353,[34,236,402,102,794,821,891,1004,858,1098,25]); +__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,"STRIP_FONT",{enumerable:!0,get:function(){return F}}),_e.SoldOutStrip=function({rid:e,now:w,by:O,onOpen:I}){const C=(0,h.useSoldOut)(e=>e.entries),z=(0,f.useStore)(e=>e.clock),[_,A]=(0,n.useState)(0),[H,L]=(0,n.useState)(!1),D=(0,y.useAutoSoldOutView)(e);(0,n.useEffect)(()=>{$()},[]);const R=w??(0,p.nowFrom)(z),W=(0,b.activeSoldOut)(C,e,R);if(!W.length)return null;const E=W.map(e=>{const t=D.reason(e.itemId);return(0,x.withReason)(e.name,S.IS_CAR&&'none left'===t?'':t)}),M=(0,b.stripText)(E),P=_>0&&(0,b.stripNeedsTicker)(E,_,F),B=Math.round(.28*M.length);[20,30,40,50,60,80,100,120].find(e=>e>=B);return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(l.default,{testID:"display-soldout-strip",dataSet:{centreExempt:'moving-ticker'},accessibilityRole:"button",accessibilityLabel:`Sold out: ${E.join(', ')}. Tap for the list.`,onPress:()=>I?I():L(!0),onLayout:e=>A(e.nativeEvent.layout.width),style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingHorizontal:12,paddingVertical:4,gap:10,backgroundColor:(0,t.soutersSurface)('#161411'),borderTopWidth:1,borderTopColor:j.colours.accentBorder},children:[(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.bold,fontSize:12,lineHeight:16,letterSpacing:1,color:j.colours.amber},children:["SOLD OUT",W.length>1?` \xb7 ${W.length}`:'']}),(0,T.jsx)(d.default,{style:{flex:1,minWidth:0,maxWidth:'100%',overflow:'hidden'},children:((e,t=!1)=>(0,T.jsx)(o.Text,{numberOfLines:t?void 0:1,style:{flexShrink:t?0:1,...t&&k?{whiteSpace:'nowrap'}:{},fontFamily:j.fonts.medium,fontSize:F,lineHeight:20,color:j.colours.gold,paddingRight:48},children:M},e))('a')}),P&&!k?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:12,color:j.colours.muted},children:"Tap for all"}):null]}),I?null:(0,T.jsxs)(c.Sheet,{visible:H,onClose:()=>L(!1),title:(0,b.soldOutCount)(W.length),maxWidth:520,testID:"display-soldout-sheet",children:[O?(0,T.jsx)(u.SoldOutList,{rid:e,by:O,hideLinks:!0}):(0,T.jsx)(s.default,{style:{maxHeight:420},children:W.map(e=>(0,T.jsxs)(d.default,{style:{paddingVertical:8,borderBottomWidth:1,borderBottomColor:j.colours.border},children:[(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.semibold,fontSize:17,color:j.colours.text},children:e.name}),D.reason(e.itemId)?(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.medium,fontSize:14,color:j.colours.amber},children:D.reason(e.itemId).replace(/^./,e=>e.toUpperCase())}):null,(0,T.jsxs)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted},children:["Since ",v(e.at),e.auto?' \xb7 Auto, from the counts \xb7 back on when the count is back up':`${e.by?` \xb7 ${e.by}`:''}${e.clearAfter?` \xb7 back on at ${v(e.clearAfter)}`:''}`]})]},e.itemId))}),(0,T.jsx)(o.Text,{style:{fontFamily:j.fonts.regular,fontSize:13,color:j.colours.muted,marginTop:8},children:"A reminder for staff. It doesn't change your till."})]})]})};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]);r(_d[3]);var l=e(r(_d[4])),s=e(r(_d[5])),d=e(r(_d[6])),c=r(_d[7]),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),p=r(_d[11]),y=r(_d[12]),x=r(_d[13]),S=r(_d[14]),b=r(_d[15]),j=r(_d[16]),T=r(_d[17]);const k='undefined'!=typeof document,w=`\n${[20,30,40,50,60,80,100,120].map(e=>`[data-ccso="tick-${e}"]{display:inline-flex;white-space:nowrap;animation:ccso-tick ${e}s linear infinite}`).join('\n')}\n@keyframes ccso-tick{from{transform:translate3d(0,0,0)}to{transform:translate3d(-50%,0,0)}}\n@media (prefers-reduced-motion: reduce){[data-ccso^="tick"]{animation:none!important}}\n`;let O=!1;function $(){if(!k||O)return;O=!0;const e=document.createElement('style');e.setAttribute('data-ccso-css','1'),e.textContent=w,document.head.appendChild(e)}const v=e=>{const t=new Date(e);return`${String(t.getHours()).padStart(2,'0')}:${String(t.getMinutes()).padStart(2,'0')}`},F=15},1354,[828,827,34,236,402,295,102,794,1174,874,979,831,981,982,872,980,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AppBadge=function({label:o}){return(0,c.jsx)(t.default,{testID:"app-badge",accessibilityLabel:`${o} app`,style:{borderWidth:1,borderColor:s.colours.gold,borderRadius:6,paddingHorizontal:6,paddingVertical:1,backgroundColor:(0,e.soutersSurface)('#1c1a16')},children:(0,c.jsx)(u.T,{size:10,weight:"bold",colour:s.colours.gold,children:o})})};var e=r(d[0]);r(d[1]);var o,l=r(d[2]),t=(o=l)&&o.__esModule?o:{default:o},s=r(d[3]),u=r(d[4]),c=r(d[5])},1355,[828,34,102,821,794,25]); +__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.AllergyIcon=function({text:e,size:o=20,colour:n=c.colours.amber,ink:u=c.colours.bg,testID:x}){return(0,h.jsx)(t.default,{testID:x,accessible:!0,accessibilityRole:"image",accessibilityLabel:`Allergy noted: ${e}`,style:{width:o,height:o,flexShrink:0},children:(0,h.jsxs)(s.default,{width:o,height:o,viewBox:"0 0 24 24",children:[(0,h.jsx)(l.Path,{d:"M12 2.2 C12.7 2.2 13.3 2.6 13.7 3.2 L22.6 19.1 C23.4 20.5 22.4 22 20.9 22 L3.1 22 C1.6 22 0.6 20.5 1.4 19.1 L10.3 3.2 C10.7 2.6 11.3 2.2 12 2.2 Z",fill:n}),(0,h.jsx)(l.Rect,{x:10.7,y:8,width:2.6,height:7.6,rx:1.3,fill:u}),(0,h.jsx)(l.Rect,{x:10.7,y:17.2,width:2.6,height:2.6,rx:1.3,fill:u})]})})},r(d[0]);var t=e(r(d[1])),l=r(d[2]),s=e(l),c=r(d[3]),h=r(d[4])},1356,[34,102,797,821,25]); +__d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AREA_LABEL_H",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"GRID_GAP",{enumerable:!0,get:function(){return r}}),e.venueGrid=function(n,l,o,s=r,c=t){if(!n.length||l<=0||o<=0)return null;Math.max(0,...n.map(t=>t.minScale));const a=t=>{const r=[];for(let l=0;la/t.w)),h=r.reduce((t,r)=>t+Math.max(...r.map(t=>t.h)),0),i=(o-r.length*c-s*(r.length-1))/h;return{cols:t,rows:r,cellW:a,byW:u,byH:i,sumH:h,s:Math.min(u,i)}};let u=Array.from({length:n.length},(t,r)=>a(r+1)).reduce((t,r)=>r.s>t.s+1e-6?r:t),h=u.s;const i=u.rows.map(t=>Math.max(...t.map(t=>t.h))*h+c),p=i.reduce((t,r)=>t+r,0)+s*(u.rows.length-1),f=Math.max(0,o-p),w=i.map(t=>Math.floor(t+f*(t-c)/(u.sumH*h||1)));return{cols:u.cols,rows:u.rows.map(t=>t.map(t=>t.id)),rowHeights:w,cellW:u.cellW,scale:h,scroll:!1,totalH:w.reduce((t,r)=>t+r,0)+s*(u.rows.length-1)}};const t=24,r=8},1357,[]); +__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.cleanPlan=R,_e.PlanDesigner=function(e){const[a,l]=(0,i.useReducer)(D,{past:[],now:e.initial,future:[]}),N=a.now,F=e=>l({t:'set',p:e}),[H,O]=(0,i.useState)(e.startStep??'areas'),[U,G]=(0,i.useState)(e.initial.areas[0]?.id??''),[_,K]=(0,i.useState)(null),X=(0,w.useOwner)(e=>e.site),J=(0,y.useFloor)(e=>e.settings[X]),Y=!1!==J?.gridSnap,Z=(0,j.gridOf)(J?.gridSize),[q,V]=(0,i.useState)(null),[Q,ee]=(0,i.useState)(null),[se,te]=(0,i.useState)(null),ae=(0,T.useSync)(e=>e.venueId),le=e.role??'staff',[oe,ne]=(0,i.useState)(''),{width:re,height:ie}=(0,c.default)(),de=re>=900,ue=a.past.length>0||JSON.stringify(N)!==JSON.stringify(e.initial),ce=(0,b.planCounts)(N);(0,i.useEffect)(()=>{N.areas.some(e=>e.id===U)||G(N.areas[0]?.id??'')},[N.areas,U]),(0,i.useEffect)(()=>{oe&&((0,n.notify)({id:`plan-note:${Date.now()}`,title:oe,timeoutMs:3500,testID:'plan-toast'}),ne(''))},[oe]);const he='table'===_?.kind?N.tables.find(e=>e.id===_.id):void 0,be='fixture'===_?.kind?(N.fixtures??[]).find(e=>e.id===_.id):void 0,ge=(e,s)=>{const t=N.tables.find(s=>s.id===e),a=t&&s.name&&s.name!==t.name?N.joins.map(e=>({...e,tables:e.tables.map(e=>e===t.name?s.name:e)})):N.joins,l=t&&s.name&&s.name!==t.name?N.areas.map(e=>e.best?.includes(t.name)?{...e,best:e.best.map(e=>e===t.name?s.name:e)}:e):N.areas;F({...N,areas:l,joins:a,tables:N.tables.map(t=>t.id===e?{...t,...s}:t)})},pe=e=>{const s=N.tables.find(s=>s.id===e);F({...N,tables:N.tables.filter(s=>s.id!==e),joins:N.joins.filter(e=>!s||!e.tables.includes(s.name))}),K(null)},me=e=>{const s=b.FIXTURES.find(s=>s.id===e),t={id:(0,b.fid)('fx'),areaId:U,kind:e,x:25*Math.round((b.PLAN_W-s.w)/50),y:25,w:s.w,h:s.h};F({...N,fixtures:[...N.fixtures??[],t]}),K({kind:'fixture',id:t.id})},xe=e=>{const s=(0,j.tidyArea)(N,e,Z),t=(0,j.movedCount)(N,s);t?(F(s),ne(`Tidied: ${t} table${1===t?'':'s'} lined up on the grid. Undo (\u2318Z / Ctrl+Z) if you preferred it before.`)):ne('Already tidy: every table is on the grid and lined up.')},fe=e=>{const s=(0,b.autoArrange)(N.tables.filter(s=>s.areaId===e),$(N,e));F({...N,tables:[...N.tables.filter(s=>s.areaId!==e),...s]}),ne('Layout tidied. Undo if you preferred it before.')};(0,i.useEffect)(()=>{if('undefined'==typeof document)return;const e=e=>{const s=e.target?.tagName;if('INPUT'===s||'TEXTAREA'===s)return;if((e.ctrlKey||e.metaKey)&&'z'===e.key.toLowerCase())return e.preventDefault(),void l({t:e.shiftKey?'redo':'undo'});if((e.ctrlKey||e.metaKey)&&'y'===e.key.toLowerCase())return e.preventDefault(),void l({t:'redo'});if('arrange'!==H||!_)return;const t=e.altKey?1:Y?Z:5,a={ArrowLeft:[-t,0],ArrowRight:[t,0],ArrowUp:[0,-t],ArrowDown:[0,t]}[e.key];a&&(e.preventDefault(),je(_.kind,_.id,a[0],a[1],!0)),'Delete'!==e.key&&'Backspace'!==e.key||(e.preventDefault(),'table'===_.kind?pe(_.id):(F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==_.id)}),K(null))),'r'===e.key.toLowerCase()&&ye(_.kind,_.id)};return document.addEventListener('keydown',e),()=>document.removeEventListener('keydown',e)});const je=(e,s,t,a,l=!1)=>{const o=e=>({x:Math.max(0,Math.min(b.PLAN_W-e.w,l?e.x+t:t)),y:Math.max(0,Math.min(b.PLAN_H-e.h,l?e.y+a:a))});F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?{...e,...o(e)}:e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,...o(e)}:e)})},ye=(e,s)=>{F('table'===e?{...N,tables:N.tables.map(e=>e.id===s?(0,b.rotate90)(e):e)}:{...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?(0,b.rotate90)(e):e)})},we='display'===e.mode;return(0,I.jsxs)(h.default,{testID:"plan-designer",style:{flex:1,backgroundColor:p.colours.bg},onStartShouldSetResponderCapture:()=>(e.onActivity?.(),!1),onMoveShouldSetResponderCapture:()=>(e.onActivity?.(),!1),children:[we?(0,I.jsxs)(h.default,{testID:"editing-banner",accessibilityRole:"summary",style:{backgroundColor:p.colours.gold,paddingHorizontal:16,paddingVertical:8,flexDirection:'row',alignItems:'center',gap:10},children:[(0,I.jsx)(x.T,{size:18,weight:"bold",colour:p.colours.onGold,children:"\u270e EDITING THE TABLE PLAN"}),(0,I.jsx)(x.T,{size:14,weight:"medium",colour:p.colours.onGold,style:{flex:1},children:"The Display is unlocked. Nothing changes on the floor until you tap Save changes."}),e.notice?(0,I.jsx)(h.default,{style:{backgroundColor:(0,s.soutersSurface)('#0B0B0B'),borderRadius:8,paddingHorizontal:10,paddingVertical:4},children:(0,I.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.amber,children:e.notice})}):null]}):null,(0,I.jsxs)(h.default,{style:{flexDirection:'row',flexWrap:'wrap',alignItems:'center',gap:10,paddingHorizontal:14,paddingVertical:8,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:[(0,I.jsxs)(h.default,{style:{marginRight:6},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Table plan"}),(0,I.jsx)(x.Muted,{size:12,children:e.venue})]}),(0,I.jsx)(x.Row,{gap:6,children:k.map(e=>{const s=e.id===H;return(0,I.jsxs)(d.default,{testID:`step-${e.id}`,accessibilityRole:"tab",accessibilityState:{selected:s},accessibilityLabel:`Step ${e.n}: ${e.label}`,onPress:()=>{O(e.id),K(null),V(null)},style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:44,paddingHorizontal:12,borderRadius:22,borderWidth:1.5,borderColor:s?p.colours.gold:p.colours.border,backgroundColor:s?p.colours.goldTint:'transparent'},children:[(0,I.jsx)(h.default,{style:{width:24,height:24,borderRadius:12,alignItems:'center',justifyContent:'center',backgroundColor:s?p.colours.gold:p.colours.surface2},children:(0,I.jsx)(x.T,{size:13,weight:"bold",colour:s?p.colours.onGold:p.colours.muted,children:e.n})}),(0,I.jsx)(x.T,{weight:"semibold",size:15,colour:s?p.colours.goldLight:p.colours.text,children:e.label})]},e.id)})}),(0,I.jsx)(h.default,{style:{flex:1}}),(0,I.jsxs)(h.default,{testID:"plan-counts",style:{alignItems:'flex-end',marginRight:4},children:[(0,I.jsxs)(x.T,{weight:"bold",size:16,children:[ce.tables," tables \xb7 ",ce.seats," seats"]}),(0,I.jsxs)(x.Muted,{size:12,children:[N.areas.length," area",1===N.areas.length?'':'s',ue?' \xb7 unsaved changes':'']})]}),(0,I.jsx)(B,{label:"Undo",glyph:"\u21b6",disabled:!a.past.length,onPress:()=>l({t:'undo'})}),(0,I.jsx)(B,{label:"Redo",glyph:"\u21b7",disabled:!a.future.length,onPress:()=>l({t:'redo'})}),(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Cancel",testID:"designer-cancel",onPress:()=>ue?ee({title:'Discard your changes?',body:'The table plan goes back to how it was before you started editing.',ok:'Discard changes',danger:!0,run:e.onCancel}):e.onCancel(),style:{minHeight:44}}),(0,I.jsx)(x.Button,{small:!0,label:"Save changes",testID:"designer-save",disabled:!ue,onPress:()=>ee({title:'Save changes to the table plan?',body:`${ce.tables} tables \xb7 ${ce.seats} seats across ${N.areas.length} area${1===N.areas.length?'':'s'}. It updates straight away here and on every other screen and phone within a few seconds.`,ok:'Save changes',run:()=>e.onSave(R(N))}),style:{minHeight:44}}),ae?(0,I.jsx)(S.NamedPlanButtons,{onSaveAs:()=>te('save'),onList:()=>te('list')}):null]}),(0,I.jsxs)(h.default,{style:{flex:1},children:['areas'===H?(0,I.jsx)(M,{plan:N,set:F,confirm:ee,wide:de,next:()=>O('tables'),toast:ne}):null,'tables'===H?(0,I.jsx)(E,{plan:N,set:F,area:U,setArea:G,addTables:(e,s)=>{let t={...N,areas:[...N.areas],tables:[...N.tables]};const a=new Set(t.tables.map(e=>e.name)),l=[];let o=0;const n=new Set;for(const s of e){if(a.has(s.name)){l.push(s.name);continue}let e=U;if(s.area){const a=t.areas.find(e=>e.name.toLowerCase()===s.area.toLowerCase());a?e=a.id:(e=A(t,s.area),t.areas.push({id:e,name:s.area,dogs:!1,outdoor:!1}))}const i=(0,b.newTable)(s.name,e,s.seats,P(t,e)),[d]=(0,b.placeNew)(t.tables.filter(s=>s.areaId===e),[i],(t.fixtures??[]).filter(s=>s.areaId===e));t.tables.push(d),a.add(s.name),n.add(e),o++}if(s)for(const e of n){const s=t.tables.filter(s=>s.areaId===e),a=(0,b.autoArrange)(s,$(t,e));t={...t,tables:[...t.tables.filter(s=>s.areaId!==e),...a]}}return o&&F(t),ne(`${o} table${1===o?'':'s'} added${l.length?` \xb7 skipped ${l.join(', ')} (already on the plan)`:''}`),o},remove:pe,patch:ge,wide:de,next:()=>O('arrange'),back:()=>O('areas')}):null,'arrange'===H?(0,I.jsxs)(h.default,{style:{flex:1,flexDirection:de?'row':'column'},children:[(0,I.jsxs)(h.default,{style:{flex:1,padding:10,gap:8,minHeight:de?void 0:Math.min(420,.5*ie)},children:[(0,I.jsx)(L,{plan:N,area:U,onPick:e=>{G(e),K(null),V(null)}}),q?(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.blueBg,borderRadius:10,padding:8,flexDirection:'row',alignItems:'center',gap:8},children:[(0,I.jsxs)(x.T,{colour:p.colours.blue,style:{flex:1},children:["Tap the table to join with ",(0,o.tableNumbers)(N.tables.find(e=>e.id===q)?.name),"."]}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Stop joining",onPress:()=>V(null)})]}):null,(0,I.jsx)(f.DesignerCanvas,{plan:N,areaId:U,sel:_,onSelect:e=>{if(q&&'table'===e?.kind&&e.id!==q){const s=N.tables.find(e=>e.id===q),t=N.tables.find(s=>s.id===e.id),a=N.joins.find(e=>e.tables.includes(s.name)),l=a?N.joins.map(e=>e===a?{...e,tables:[...new Set([...e.tables,t.name])].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}:e).filter(e=>e===a||!e.tables.includes(t.name)):[...N.joins.filter(e=>!e.tables.includes(t.name)),{id:(0,b.fid)('j'),tables:[s.name,t.name].sort((e,s)=>(0,b.numOf)(e)-(0,b.numOf)(s))}];return F({...N,joins:l}),V(null),ne(`Joined: book as ${l.find(e=>e.tables.includes(s.name)).tables.join('+')}`),void K(e)}V(null),K(e)},snapOn:Y,grid:Z,joinFrom:q,onMove:(e,s,t,a)=>je(e,s,t,a),onResize:(e,s,t,a)=>{if('table'===e){const e=N.tables.find(e=>e.id===s);if('round'===e.shape){const l=Math.max(t,a);ge(s,{w:l,h:l,x:e.x,y:e.y})}else ge(s,{w:t,h:a,shape:t===a?'square':'rect',x:e.x,y:e.y})}else F({...N,fixtures:(N.fixtures??[]).map(e=>e.id===s?{...e,w:t,h:a}:e)})}}),(0,I.jsxs)(x.Muted,{size:12,children:["Drag to move \xb7 the gold dot resizes \xb7 ",Y?`tables snap to a ${Z} grid and line up with each other (gold guides)`:'snap to grid is off',' \xb7 hold Alt (Option on a Mac) to move freely \xb7 keys: arrows nudge, R rotates, Delete removes, Ctrl+Z / \u2318Z undoes']})]}),(0,I.jsx)(u.default,{style:{width:de?330:void 0,flexGrow:de?0:1,flexShrink:0,flexBasis:de?330:void 0,borderLeftWidth:de?1:0,borderTopWidth:de?0:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},contentContainerStyle:{padding:14,gap:12},children:he?(0,I.jsx)(W,{t:he,plan:N,patch:e=>ge(he.id,e),rotate:()=>ye('table',he.id),remove:()=>pe(he.id),duplicate:()=>{const e=z(N),s={...he,id:`t-${e}-${(0,b.fid)('d')}`,name:e,label:void 0},[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===he.areaId),[s],(N.fixtures??[]).filter(e=>e.areaId===he.areaId));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id}),ne(`${(0,o.tableNumbers)(e)} added`)},join:()=>V(he.id),split:e=>F({...N,joins:N.joins.filter(s=>s.id!==e)}),moveArea:e=>{const[s]=(0,b.placeNew)(N.tables.filter(s=>s.areaId===e),[{...he,areaId:e,sectionId:P(N,e)}],(N.fixtures??[]).filter(s=>s.areaId===e));F({...N,tables:N.tables.map(e=>e.id===he.id?s:e)}),G(e)},onDone:()=>K(null),toast:ne}):be?(0,I.jsxs)(h.default,{style:{gap:10},children:[(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:b.FIXTURES.find(e=>e.id===be.kind)?.label}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:()=>K(null)})]}),(0,I.jsx)(x.Muted,{children:"Drag it into place; the gold dot changes its length."}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(x.Chip,{label:e.label,selected:be.kind===e.id,onPress:()=>F({...N,fixtures:(N.fixtures??[]).map(s=>s.id===be.id?{...s,kind:e.id}:s)})},e.id))}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",onPress:()=>ye('fixture',be.id)}),(0,I.jsx)(x.Button,{kind:"danger",label:"Remove",onPress:()=>{F({...N,fixtures:(N.fixtures??[]).filter(e=>e.id!==be.id)}),K(null)}})]}):(0,I.jsxs)(h.default,{style:{gap:12},children:[(0,I.jsxs)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:["Arrange ",N.areas.find(e=>e.id===U)?.name??'']}),(0,I.jsx)(x.Muted,{children:"Tap a table to change its seats, rotate it or join it to another. Drag anything to move it."}),(0,I.jsx)(x.Button,{label:"Add table",testID:"arrange-add-table",onPress:()=>{const e=z(N),s=(0,b.newTable)(e,U,4,P(N,U)),[t]=(0,b.placeNew)(N.tables.filter(e=>e.areaId===U),[s],(N.fixtures??[]).filter(e=>e.areaId===U));F({...N,tables:[...N.tables,t]}),K({kind:'table',id:t.id})}}),(0,I.jsx)(x.T,{weight:"semibold",size:14,colour:p.colours.muted,children:"FIXTURES"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:b.FIXTURES.map(e=>(0,I.jsx)(h.default,{testID:`add-fixture-${e.id}`,children:(0,I.jsx)(x.Chip,{label:e.label,onPress:()=>me(e.id)})},e.id))}),(0,I.jsx)(x.Button,{label:"Tidy up",testID:"tidy-up",onPress:()=>xe(U)}),(0,I.jsx)(x.Muted,{size:12,children:"Snaps every table in this area to the grid and evens out the rows. Table numbers, covers and sizes stay the same. You can undo."}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Re-arrange from scratch",testID:"tidy-area",onPress:()=>fe(U)}),(0,I.jsx)(x.Toggle,{label:"Snap to grid",value:Y,onChange:e=>y.useFloor.getState().setSettings(X,{...y.DEFAULT_SETTINGS,...J??{},gridSnap:e})}),(0,I.jsx)(h.default,{style:{borderTopWidth:1,borderColor:p.colours.border,paddingTop:10,gap:4},children:N.areas.map(e=>{const s=(0,b.planCounts)(N,e.id);return(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsxs)(x.T,{size:14,children:[e.name,(0,C.areaMarks)(e)]}),(0,I.jsxs)(x.T,{size:14,colour:p.colours.muted,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})})]})})]}):null]}),Q?(0,I.jsx)(h.default,{testID:"designer-confirm",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16},children:(0,I.jsxs)(h.default,{style:{width:'100%',maxWidth:460,backgroundColor:p.colours.surface,borderRadius:16,borderWidth:1,borderColor:p.colours.gold,padding:20,gap:12},children:[(0,I.jsxs)(x.Row,{style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,style:{flex:1,textAlign:'center'},children:Q.title}),(0,I.jsx)(t.GoldClose,{onPress:()=>ee(null),label:"Close",testID:"designer-confirm-close"})]}),(0,I.jsx)(x.T,{colour:p.colours.muted,style:{textAlign:'center'},children:Q.body}),(0,I.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Keep editing",onPress:()=>ee(null)}),(0,I.jsx)(x.Button,{kind:Q.danger?'danger':'primary',label:Q.ok,testID:"confirm-ok",onPress:()=>{const e=Q;ee(null),e.run()}})]})]})}):null,'save'===se&&ae?(0,I.jsx)(S.SaveAsPlanDialog,{venueId:ae,plan:R(N),onClose:()=>te(null),onSaved:()=>te(null),toast:ne}):null,'list'===se&&ae?(0,I.jsx)(S.SavedPlansDialog,{venueId:ae,mode:e.mode,role:le,isCar:v.IS_CAR,onClose:()=>te(null),onLive:s=>{l({t:'reset',p:s}),e.onLiveChange?.(s),te(null)},toast:ne}):null]})};var s=r(_d[0]),t=r(_d[1]),a=r(_d[2]),l=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);r(_d[7]);var d=e(r(_d[8])),u=e(r(_d[9])),c=e(r(_d[10])),h=e(r(_d[11])),b=r(_d[12]),p=r(_d[13]),x=r(_d[14]),f=r(_d[15]),j=r(_d[16]),y=r(_d[17]),w=r(_d[18]),C=r(_d[19]),S=r(_d[20]),T=r(_d[21]),v=r(_d[22]),I=r(_d[23]);const k=[{id:'areas',n:1,label:'Areas'},{id:'tables',n:2,label:'Tables'},{id:'arrange',n:3,label:'Arrange'}];function D(e,s){return'set'===s.t?{past:[...e.past,e.now].slice(-80),now:s.p,future:[]}:'undo'===s.t?e.past.length?{past:e.past.slice(0,-1),now:e.past[e.past.length-1],future:[e.now,...e.future]}:e:'redo'===s.t?e.future.length?{past:[...e.past,e.now],now:e.future[0],future:e.future.slice(1)}:e:{past:[],now:s.p,future:[]}}function R(e){const s=new Set(e.tables.map(e=>e.name)),t=[...e.sections];for(const s of e.areas)t.some(e=>e.id===`s-${s.id}`)||e.tables.some(e=>e.areaId===s.id&&e.sectionId)||t.push({id:`s-${s.id}`,name:s.name,colour:'#CFA45F',server:''});return{...e,sections:t,fixtures:(e.fixtures??[]).filter(s=>e.areas.some(e=>e.id===s.areaId)),joins:e.joins.filter(e=>e.tables.length>1&&e.tables.every(e=>s.has(e)))}}const z=e=>{let s=1;const t=new Set(e.tables.map(e=>e.name));for(;t.has(String(s));)s++;return String(s)},P=(e,s)=>e.tables.find(e=>e.areaId===s)?.sectionId??`s-${s}`,$=(e,s)=>(e.fixtures??[]).some(e=>e.areaId===s&&e.y<100&&('bar'===e.kind||e.w>=300))?150:100;const A=(e,s)=>{let t=(0,b.slug)(s),a=2;for(;e.areas.some(e=>e.id===t);)t=`${(0,b.slug)(s)}-${a++}`;return t};function B({label:e,glyph:s,onPress:a,disabled:l}){return(0,I.jsx)(d.default,{accessibilityRole:"button",accessibilityLabel:e,testID:`designer-${e.toLowerCase()}`,disabled:l,onPress:a,style:({pressed:e})=>({minWidth:48,height:44,borderRadius:10,borderWidth:1.5,borderColor:p.colours.border,alignItems:'center',justifyContent:'center',opacity:l?.35:e?.7:1,paddingHorizontal:8}),children:'cross'===s?(0,I.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:6},children:[(0,I.jsx)(t.GoldX,{size:14}),(0,I.jsx)(x.T,{size:12,colour:p.colours.muted,children:e})]}):(0,I.jsxs)(x.T,{size:18,weight:"bold",colour:p.colours.gold,children:[s,(0,I.jsxs)(x.T,{size:12,colour:p.colours.muted,children:[" ",e]})]})})}function L({plan:e,area:s,onPick:t}){return(0,I.jsx)(u.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,style:{flexGrow:0},contentContainerStyle:{gap:6},children:e.areas.map(a=>{const l=a.id===s,o=(0,b.planCounts)(e,a.id);return(0,I.jsx)(d.default,{testID:`darea-${a.id}`,accessibilityRole:"tab",accessibilityState:{selected:l},accessibilityLabel:`Area ${a.name}`,onPress:()=>t(a.id),style:{minHeight:44,paddingHorizontal:14,borderRadius:22,borderWidth:1.5,borderColor:l?p.colours.gold:p.colours.border,backgroundColor:l?p.colours.gold:p.colours.surface,justifyContent:'center'},children:(0,I.jsxs)(x.T,{weight:"semibold",size:14,colour:l?p.colours.onGold:p.colours.text,children:[a.name,(0,C.areaMarks)(a)," ",(0,I.jsxs)(x.T,{size:12,colour:l?p.colours.onGold:p.colours.muted,children:[o.tables," \xb7 ",o.seats]})]})},a.id)})})}function M({plan:e,set:s,confirm:t,wide:l,next:n,toast:c}){const[f,j]=(0,i.useState)(''),y=(t,a)=>s({...e,areas:e.areas.map(e=>e.id===t?{...e,...a}:e)}),w=(t,a)=>{const l=[...e.areas],o=t+a;o<0||o>=l.length||([l[t],l[o]]=[l[o],l[t]],s({...e,areas:l}))},C=()=>{const t=f.trim();if(!t)return;if(e.areas.some(e=>e.name.toLowerCase()===t.toLowerCase()))return void c(`There's already an area called ${t}`);const a=A(e,t);s({...e,areas:[...e.areas,{id:a,name:t,dogs:!1,outdoor:!1}],sections:[...e.sections,{id:`s-${a}`,name:t,colour:'#CFA45F',server:''}]}),j('')};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:l?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:l?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"1. Areas"}),(0,I.jsx)(x.Muted,{children:"The rooms and spaces guests can sit in. Tick where dogs are welcome and which areas are outdoors (so you can close them in bad weather)."}),e.areas.map((a,l)=>{const n=(0,b.planCounts)(e,a.id);return(0,I.jsxs)(h.default,{testID:`area-card-${a.id}`,style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,gap:8},children:[(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(F,{value:a.name,onCommit:e=>e&&e!==a.name&&y(a.id,{name:e})}),(0,I.jsx)(x.Badge,{label:`${n.tables} tables \xb7 ${n.seats} seats`}),(0,I.jsx)(B,{label:"Up",glyph:"\u2191",disabled:0===l,onPress:()=>w(l,-1)}),(0,I.jsx)(B,{label:"Down",glyph:"\u2193",disabled:l===e.areas.length-1,onPress:()=>w(l,1)})]}),(0,I.jsx)(x.Row,{gap:8,children:(0,I.jsx)(F,{value:a.label??'',label:"Area description (optional)",placeholder:"Description, e.g. Covered conservatory, no pets",onCommit:e=>e!==(a.label??'')&&y(a.id,{label:e||void 0})})}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,style:{alignItems:'center'},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Colour"}),N.map(t=>{const l=(a.colour??e.sections.find(e=>e.id===`s-${a.id}`)?.colour)===t;return(0,I.jsx)(d.default,{testID:`area-colour-${a.id}-${t.slice(1)}`,accessibilityRole:"radio",accessibilityState:{selected:l},accessibilityLabel:`Area colour ${t}`,onPress:()=>s({...e,areas:e.areas.map(e=>e.id===a.id?{...e,colour:t}:e),sections:e.sections.map(e=>e.id===`s-${a.id}`?{...e,colour:t}:e)}),style:{width:32,height:32,borderRadius:16,backgroundColor:t,borderWidth:l?3:1,borderColor:l?'#FFFFFF':p.colours.border}},t)})]}),(()=>{const s=e.tables.filter(e=>e.areaId===a.id).sort((e,s)=>e.name.localeCompare(s.name,void 0,{numeric:!0})),t=a.best??[];return s.length?(0,I.jsxs)(h.default,{style:{gap:6},testID:`area-best-${a.id}`,children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Best tables"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.map(e=>(0,I.jsx)(x.Chip,{testID:`area-best-${a.id}-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:t.includes(e.name),onPress:()=>y(a.id,{best:t.includes(e.name)?t.filter(s=>s!==e.name):[...t,e.name]})},e.id))}),(0,I.jsx)(x.Muted,{size:12,children:"Tip: tap the tables you\u2019d seat first. They show as BEST for walk-ins and bookings when they suit the party size. None ticked: CoverCharge picks by size."})]}):null})(),(0,I.jsxs)(x.Row,{gap:16,wrap:!0,children:[(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83d\udc3e Dogs allowed",value:!!a.dogs,onChange:e=>y(a.id,{dogs:e})})}),(0,I.jsx)(h.default,{style:{minWidth:220,flex:1},children:(0,I.jsx)(x.Toggle,{label:"\ud83c\udf26 Outdoor (weather)",value:!!a.outdoor,onChange:e=>y(a.id,{outdoor:e})})}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Remove area",disabled:e.areas.length<2,onPress:()=>t({title:`Remove ${a.name}?`,body:n.tables?`Its ${n.tables} tables (${n.seats} seats) are removed too. You can undo this.`:'You can undo this.',ok:'Remove area',danger:!0,run:()=>s({...e,areas:e.areas.filter(e=>e.id!==a.id),tables:e.tables.filter(e=>e.areaId!==a.id),fixtures:(e.fixtures??[]).filter(e=>e.areaId!==a.id)})})})]})]},a.id)}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(a.TextInput,{accessibilityLabel:"New area name",placeholder:"New area, e.g. Snug",placeholderTextColor:"#7D776C",value:f,onChangeText:j,onSubmitEditing:C,style:[x.styles.input,{flex:1,minHeight:48}]}),(0,I.jsx)(x.Button,{label:"Add area",testID:"add-area",onPress:C,disabled:!f.trim()})]}),(0,I.jsx)(x.Button,{label:"Next: Tables",onPress:n,testID:"next-tables"})]}),(0,I.jsxs)(h.default,{style:{flex:l?2:void 0,alignSelf:'stretch',gap:10},testID:"templates",children:[(0,I.jsx)(x.T,{weight:"bold",size:18,colour:p.colours.gold,children:"Start from a template"}),(0,I.jsx)(x.Muted,{children:"Replaces the whole plan. You can undo, and nothing is saved until you tap Save changes."}),b.TEMPLATES.map(e=>(0,I.jsxs)(d.default,{testID:`template-${e.id}`,accessibilityRole:"button",accessibilityLabel:`Template: ${e.name}`,onPress:()=>t({title:`Start from ${e.name}?`,body:'This replaces the areas, tables and fixtures in the plan you are editing. You can undo it.',ok:'Use template',run:()=>{s(e.make()),c(`${e.name} template loaded`)}}),style:({pressed:e})=>({backgroundColor:e?p.colours.goldTint:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:12,minHeight:56}),children:[(0,I.jsx)(x.T,{weight:"semibold",children:e.name}),(0,I.jsx)(x.Muted,{children:e.sub})]},e.id))]})]})}const N=[...b.SECTION_COLOURS,'#E5736B','#F2F2F2'];function F({value:e,onCommit:s,label:t="Area name",placeholder:l}){const[o,n]=(0,i.useState)(e);return(0,i.useEffect)(()=>n(e),[e]),(0,I.jsx)(a.TextInput,{accessibilityLabel:t,placeholder:l,placeholderTextColor:"#7D776C",value:o,onChangeText:n,onBlur:()=>s(o.trim()),onSubmitEditing:()=>s(o.trim()),style:[x.styles.input,{flex:1,minHeight:48,fontSize:17}]})}function E({plan:e,set:s,area:t,setArea:l,addTables:n,remove:d,patch:c,wide:f,next:j,back:y}){const[w,C]=(0,i.useState)(''),[S,T]=(0,i.useState)(4),[v,k]=(0,i.useState)(''),[D,R]=(0,i.useState)(!0),P=(0,i.useMemo)(()=>(0,b.parseTableList)(v),[v]),$=e.tables.filter(e=>e.areaId===t).sort(b.byNumber),A=z(e),M=e.areas.find(e=>e.id===t),N=(e,s)=>{const t=(0,b.sizeFor)(s),a=(0,b.sizeFor)(e.maxSeats),l=e.w!==a.w||e.h!==a.h;c(e.id,{maxSeats:s,minSeats:Math.min(e.minSeats,s),...l?{}:'round'===e.shape?{w:t.h,h:t.h}:{w:t.w,h:t.h,shape:t.shape}})};return(0,I.jsxs)(u.default,{contentContainerStyle:{padding:16,gap:16,flexDirection:f?'row':'column',alignItems:'flex-start'},children:[(0,I.jsxs)(h.default,{style:{flex:f?3:void 0,alignSelf:'stretch',gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,children:"2. Tables"}),(0,I.jsx)(L,{plan:e,area:t,onPick:l}),(0,I.jsxs)(x.Muted,{children:[M?`${M.name}${M.dogs?' \xb7 dogs allowed':''}${M.outdoor?' \xb7 outdoor':''}`:'',". Table numbers are what you use in website bookings and on the floor."]}),(0,I.jsx)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border},children:$.length?$.map((e,s)=>(0,I.jsxs)(x.Row,{gap:10,style:{padding:10,borderTopWidth:s?1:0,borderColor:p.colours.border},children:[(0,I.jsxs)(h.default,{style:{width:92},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.goldLight,children:(0,b.tableLabel)(e)}),(0,I.jsxs)(x.Muted,{size:12,children:[(0,b.shapeLabel)(e.shape),(0,b.tableLabel)(e)!==e.name?` \xb7 no. ${e.name}`:'']})]}),(0,I.jsx)(h.default,{style:{flex:1},children:(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:`seats at table ${e.name}`,onChange:s=>N(e,s)})}),(0,I.jsx)(x.Muted,{children:"seats"}),(0,I.jsx)(B,{label:"Remove",glyph:"cross",onPress:()=>d(e.id)})]},e.id)):(0,I.jsx)(h.default,{style:{padding:16},children:(0,I.jsx)(x.Muted,{children:"No tables in this area yet. Add one, or paste a list."})})}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Back: Areas",onPress:y,style:{flex:1}}),(0,I.jsx)(x.Button,{label:"Next: Arrange",onPress:j,testID:"next-arrange",style:{flex:1}})]})]}),(0,I.jsxs)(h.default,{style:{flex:f?2:void 0,alignSelf:'stretch',gap:12},children:[(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.gold,padding:14,gap:10},children:[(0,I.jsxs)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:["Add a table to ",M?.name]}),(0,I.jsxs)(x.Row,{gap:10,children:[(0,I.jsxs)(h.default,{style:{width:120},children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Table number"}),(0,I.jsx)(a.TextInput,{testID:"add-number",accessibilityLabel:"Table number",value:w,placeholder:A,placeholderTextColor:"#7D776C",onChangeText:e=>C(e.replace(/[^0-9A-Za-z]/g,'').slice(0,4)),style:[x.styles.input,{minHeight:48,fontSize:18}]})]}),(0,I.jsxs)(h.default,{children:[(0,I.jsx)(x.T,{size:13,colour:p.colours.muted,children:"Seats"}),(0,I.jsx)(x.Stepper,{value:S,min:1,max:20,label:"seats",onChange:T})]})]}),(0,I.jsx)(x.Button,{label:`Add ${(0,o.tableNumbers)(w||A)}`,testID:"add-table",onPress:()=>{n([{name:(w||A).toUpperCase(),seats:S}],!1)&&C('')}})]}),(0,I.jsxs)(h.default,{style:{backgroundColor:p.colours.surface,borderRadius:14,borderWidth:1,borderColor:p.colours.border,padding:14,gap:10},children:[(0,I.jsx)(x.T,{weight:"bold",size:17,colour:p.colours.gold,children:"Or paste a list"}),(0,I.jsx)(x.Muted,{children:"One table per line, like \u201c7 - upto 5 people\u201d. A line with just a name (e.g. \u201cBeer Garden\u201d) puts the tables after it in that area."}),(0,I.jsx)(a.TextInput,{testID:"paste-list",accessibilityLabel:"Paste a list of tables",multiline:!0,value:v,onChangeText:k,placeholder:'7 - upto 5 people\n9 - upto 2 people',placeholderTextColor:"#7D776C",style:[x.styles.input,{minHeight:120,textAlignVertical:'top',fontSize:15}]}),v.trim()?(0,I.jsxs)(x.T,{size:14,colour:P.items.length?p.colours.ok:p.colours.amber,children:["Found ",P.items.length," table",1===P.items.length?'':'s'," \xb7 ",P.items.reduce((e,s)=>e+s.seats,0)," seats",P.skipped.length?` \xb7 couldn't read: ${P.skipped.slice(0,2).join('; ')}`:'']}):null,(0,I.jsx)(x.Toggle,{label:"Tidy the layout after adding",value:D,onChange:R}),(0,I.jsx)(x.Button,{label:P.items.length?`Add ${P.items.length} tables`:'Add tables',testID:"paste-add",disabled:!P.items.length,onPress:()=>{n(P.items,D)&&k('')}})]})]})]})}function W({t:e,plan:s,patch:t,rotate:n,remove:d,duplicate:u,join:c,split:f,moveArea:j,onDone:y,toast:w}){const[C,S]=(0,i.useState)(e.name);(0,i.useEffect)(()=>S(e.name),[e.id,e.name]);const T=s.joins.find(s=>s.tables.includes(e.name)),v=()=>{const a=C.trim().toUpperCase();if(a&&a!==e.name)return s.tables.some(e=>e.name===a)?(w(`${(0,o.tableNumbers)(a)} already exists`),void S(e.name)):void t({name:a})};return(0,I.jsxs)(h.default,{style:{gap:12},testID:"table-inspector",children:[(0,I.jsx)(l.TableNumberWarning,{plan:s}),(0,I.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,I.jsx)(x.T,{weight:"bold",size:20,colour:p.colours.gold,children:(0,b.tableLabel)(e)}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Done",onPress:y})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Number"}),(0,I.jsx)(a.TextInput,{accessibilityLabel:"Table number",value:C,onChangeText:S,onBlur:v,onSubmitEditing:v,style:[x.styles.input,{flex:1,minHeight:44}]})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Seats"}),(0,I.jsx)(x.Stepper,{value:e.maxSeats,min:1,max:20,label:"seats",onChange:s=>t({maxSeats:s,minSeats:Math.min(e.minSeats,s)})})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,style:{width:80},children:"Min Covers"}),(0,I.jsx)(x.Stepper,{value:e.minSeats,min:1,max:e.maxSeats,label:"minimum Covers",onChange:e=>t({minSeats:e})})]}),(0,I.jsxs)(x.Row,{gap:6,wrap:!0,children:[(0,I.jsx)(x.Chip,{label:"Square",selected:'square'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'square',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Round",selected:'round'===e.shape,onPress:()=>{const s=Math.max(e.w,e.h);t({shape:'round',w:s,h:s})}}),(0,I.jsx)(x.Chip,{label:"Rectangle",selected:'rect'===e.shape,onPress:()=>{if('rect'===e.shape)return;const s=(0,b.sizeFor)(Math.max(5,e.maxSeats));t({shape:'rect',w:e.h>e.w?e.w:s.w,h:e.h>e.w?s.w:s.h})}}),(0,I.jsx)(x.Chip,{label:"Fit to seats",onPress:()=>{const s=(0,b.sizeFor)(e.maxSeats);t({shape:s.shape,w:s.w,h:s.h,minSeats:Math.min(e.minSeats,e.maxSeats)||(0,b.minFor)(e.maxSeats)})}})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{kind:"secondary",label:"Rotate 90\xb0",testID:"rotate",onPress:n,style:{flex:1}}),(0,I.jsx)(x.Button,{kind:"secondary",label:"Duplicate",onPress:u,style:{flex:1}})]}),T?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsxs)(x.T,{size:14,children:["Joined with ",T.tables.filter(s=>s!==e.name).map(o.tableNumbers).join(', ')," \xb7 book as ",(0,I.jsx)(x.T,{weight:"bold",colour:p.colours.goldLight,children:(0,o.tableNumbers)(T.tables.join('+'))})]}),(0,I.jsxs)(x.Row,{gap:8,children:[(0,I.jsx)(x.Button,{small:!0,kind:"secondary",label:"Join another",onPress:c,style:{flex:1}}),(0,I.jsx)(x.Button,{small:!0,kind:"ghost",label:"Split",onPress:()=>f(T.id),style:{flex:1}})]})]}):(0,I.jsx)(x.Button,{kind:"secondary",label:"Join with another table",testID:"join",onPress:c}),(0,I.jsx)(x.Toggle,{label:"Bookable online",value:e.online,onChange:e=>t({online:e})}),s.areas.length>1?(0,I.jsxs)(h.default,{style:{gap:6},children:[(0,I.jsx)(x.T,{size:14,colour:p.colours.muted,children:"Move to area"}),(0,I.jsx)(x.Row,{gap:6,wrap:!0,children:s.areas.map(s=>(0,I.jsx)(x.Chip,{label:s.name,selected:s.id===e.areaId,onPress:()=>s.id!==e.areaId&&j(s.id)},s.id))})]}):null,(0,I.jsx)(x.Button,{kind:"danger",label:"Remove table",onPress:d})]})}},1358,[828,796,827,1122,860,1130,34,236,402,295,426,102,859,821,794,1359,1360,1029,891,1134,1362,987,872,25]); +__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.DesignerCanvas=function({plan:e,areaId:b,sel:g,onSelect:x,onMove:y,onResize:v,snapOn:w,grid:j=l.GRID,joinFrom:C}){const[I,L]=(0,n.useState)({w:0,h:0}),z=I.w&&I.h?Math.min(I.w/l.PLAN_W,I.h/l.PLAN_H):0,R=e=>e*z,S=e.tables.filter(e=>e.areaId===b),k=(e.fixtures??[]).filter(e=>e.areaId===b),[E,M]=(0,n.useState)(null),F=[...S,...k].map(e=>({id:e.id,x:e.x,y:e.y,w:e.w,h:e.h})),A=e=>S.some(t=>t.id===e),$=(t,n,r,i)=>(0,h.resizeBox)({...t,round:A(t.id)&&'round'===S.find(e=>e.id===t.id)?.shape},n,r,{snap:w&&!i,grid:j,min:A(t.id)?h.MIN_TABLE:h.MIN_FIXTURE,selfId:t.id,others:A(t.id)?e.tables.map(e=>({id:e.id,name:(0,o.tableNumbers)((0,l.tableLabel)(e)),w:e.w,h:e.h})):[]}),_=(0,n.useRef)(null),D=(e,t,o,n)=>(0,i.snapMove)(e,e.x+t,e.y+o,F,{grid:(0,h.snapStep)(j),snap:w,free:n});let T=[],N=[];const W=(0,n.useRef)(null),B=new Set;for(const e of S)for(const t of S)e.id!==t.id&&e.xt.x&&e.yt.y&&B.add(e.id);const H=e=>{if(E?.id!==e.id||!z)return e;const t=E.dx/z,o=E.dy/z;if('move'===E.kind){const n=D(e,t,o,E.free);return T=n.guides,N=n.spacing,{...e,x:n.x,y:n.y}}return{...e,...$(e,t,o,E.free)}},P=(e,t,o)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>!0,onResponderTerminationRequest:()=>!1,onResponderGrant:e=>{W.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY,moved:!1}},onResponderMove:n=>{const r=W.current;if(!r)return;const i=n.nativeEvent.pageX-r.x,s=n.nativeEvent.pageY-r.y;!r.moved&&Math.abs(i)+Math.abs(s)<6||(r.moved=!0,g&&g.id===t.id||x({kind:e,id:t.id}),_.current={id:t.id,dx:i,dy:s,free:p(n)},M({id:t.id,kind:o,dx:i,dy:s,free:p(n)}))},onResponderRelease:n=>{const r=W.current;W.current=null;const i=_.current&&_.current.id===t.id?_.current:null;if(_.current=null,M(null),!r||!r.moved||!z)return void('move'===o&&x({kind:e,id:t.id}));const s=i?i.dx:n.nativeEvent.pageX-r.x,l=i?i.dy:n.nativeEvent.pageY-r.y,a=s/z,u=l/z,c=i?i.free:p(n);if('move'===o){const o=D(t,a,u,c);y(e,t.id,o.x,o.y)}else{const o=$(t,a,u,c);v(e,t.id,o.w,o.h)}},onResponderTerminate:()=>{W.current=null,_.current=null,M(null)}}),O=(e,t,o)=>(0,f.jsx)(s.default,{testID:"resize-handle",accessibilityRole:"adjustable",accessibilityLabel:`Drag to resize, now ${t.w} by ${t.h}`,...P(e,o,'resize'),style:{position:'absolute',left:R(t.x+t.w)-22,top:R(t.y+t.h)-22,width:44,height:44,alignItems:'center',justifyContent:'center',zIndex:80,cursor:'nwse-resize',touchAction:'none'},children:(0,f.jsx)(s.default,{style:{width:26,height:26,borderRadius:13,backgroundColor:a.colours.gold,borderWidth:3,borderColor:'#FFFFFF'}})}),X=j,Y=4*j,G=S.map(e=>({t0:e,t:H(e)})),K=k.map(e=>({f0:e,f:H(e)})),V=(()=>{if('resize'!==E?.kind||!z)return;const e=S.find(e=>e.id===E.id);return e?$(e,E.dx/z,E.dy/z,E.free).matchId:void 0})();return(0,f.jsx)(s.default,{testID:"designer-canvas",style:{flex:1,alignSelf:'stretch',minHeight:240},onLayout:e=>L({w:e.nativeEvent.layout.width,h:e.nativeEvent.layout.height}),children:z?(0,f.jsxs)(s.default,{style:{width:R(l.PLAN_W),height:R(l.PLAN_H),alignSelf:'center',backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:14,borderWidth:1.5,borderColor:'#4A3F2C',overflow:'hidden'},children:[(0,f.jsx)(s.default,{accessibilityLabel:"Empty floor (tap to clear selection)",onStartShouldSetResponder:()=>!0,onResponderRelease:()=>x(null),style:{position:'absolute',left:0,top:0,right:0,bottom:0}}),Array.from({length:l.PLAN_W/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:R((t+1)*X),top:0,bottom:0,width:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`v${t}`)),Array.from({length:l.PLAN_H/X-1},(e,t)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',top:R((t+1)*X),left:0,right:0,height:1,backgroundColor:(t+1)*X%Y===0?'#2A251C':'#17150F'}},`h${t}`)),K.map(({f0:e,f:t})=>{const o='fixture'===g?.kind&&g.id===t.id;return(0,f.jsxs)(r.default.Fragment,{children:[(0,f.jsx)(c.FixtureShape,{f:t,S:R,selected:o}),(0,f.jsx)(s.default,{testID:`fixture-${t.kind}`,accessibilityRole:"button",accessibilityLabel:`${t.kind}, drag to move`,...P('fixture',e,'move'),style:{position:'absolute',left:R(t.x)-4,top:R(t.y)-4,width:R(t.w)+8,height:R(t.h)+8,zIndex:5,cursor:'grab',touchAction:'none'}}),o?O('fixture',t,e):null]},t.id)}),e.joins.map(e=>{const t=S.filter(t=>e.tables.includes(t.name)).map(H);if(t.length<2)return null;const[o,n]=t,r=o.x+o.w/2,i=o.y+o.h/2,l=n.x+n.w/2,a=n.y+n.h/2,u=Math.hypot(l-r,a-i),c=Math.atan2(a-i,l-r);return(0,f.jsx)(s.default,{pointerEvents:"none",testID:`join-${e.tables.join('+')}`,style:{position:'absolute',left:R((r+l)/2-u/2),top:R((i+a)/2)-3,width:R(u),height:6,borderRadius:3,backgroundColor:'rgba(207,164,95,0.6)',transform:[{rotate:`${c}rad`}],zIndex:6}},e.id)}),G.map(({t0:e,t:n})=>{const i='table'===g?.kind&&g.id===n.id,h=C===n.id,b=E?.id===n.id,p=(0,l.tableLabel)(n),x=(0,c.fitLabel)(Math.max(12,Math.min(26,R(Math.min(n.w,n.h))/2.6)),p,R(n.w)*('round'===n.shape?.85:1));return(0,f.jsxs)(r.default.Fragment,{children:[(0,c.seatSpots)(n).map((e,o)=>(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',zIndex:9,left:R(n.x+e.x)-Math.max(4,R(7)),top:R(n.y+e.y)-Math.max(4,R(7)),width:Math.max(8,R(14)),height:Math.max(8,R(14)),borderRadius:3,borderWidth:1.5,borderColor:'rgba(207,164,95,0.75)',backgroundColor:(0,t.soutersSurface)('#0C0B09')}},o)),(0,f.jsxs)(s.default,{testID:`dtable-${n.name}`,accessibilityRole:"button",accessibilityLabel:`Table ${(0,o.tableNumbers)(p)}${p!==n.name?` (number ${n.name})`:''}, ${n.maxSeats} seats, ${(0,l.shapeLabel)(n.shape).toLowerCase()}${B.has(n.id)?', overlapping another table':''}`,...P('table',e,'move'),style:{position:'absolute',left:R(n.x),top:R(n.y),width:R(n.w),height:R(n.h),zIndex:b?70:10,borderRadius:'round'===n.shape?R(Math.min(n.w,n.h))/2:R(8),backgroundColor:i?'#2A2216':'#15120D',borderWidth:i||h||V===n.id?3:2,borderStyle:V===n.id?'dashed':'solid',borderColor:B.has(n.id)?a.colours.red:i?'#FFFFFF':h?a.colours.blue:V===n.id?a.colours.goldLight:a.colours.gold,alignItems:'center',justifyContent:'center',cursor:'grab',touchAction:'none',shadowColor:a.colours.gold,shadowOpacity:i?.45:0,shadowRadius:12,opacity:b?.92:1},children:[(0,f.jsx)(u.T,{weight:"bold",size:x,colour:a.colours.goldLight,center:!0,numberOfLines:1,children:p}),R(n.h)>46?(0,f.jsxs)(u.T,{size:Math.max(10,.5*x),colour:a.colours.muted,center:!0,children:[n.maxSeats," seat",1===n.maxSeats?'':'s',n.online?'':' \xb7 staff']}):null]}),i?O('table',n,e):null]},n.id)}),E&&!E.free?T.map((e,t)=>(0,f.jsx)(s.default,{testID:"snap-guide",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:75,left:R(e.at)-.5,top:R(e.from)-8,width:1.5,height:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}:{position:'absolute',zIndex:75,top:R(e.at)-.5,left:R(e.from)-8,height:1.5,width:R(e.to-e.from)+16,backgroundColor:'centre'===e.kind?a.colours.goldLight:a.colours.gold,opacity:.9}},`g${t}`)):null,E&&!E.free?N.map((e,o)=>e.spans.map(([n,r],i)=>(0,f.jsx)(s.default,{testID:"spacing-hint",pointerEvents:"none",style:'x'===e.axis?{position:'absolute',zIndex:76,left:R(n),top:R(e.cross)-10,width:R(r-n),height:20,borderTopWidth:1.5,borderColor:a.colours.goldLight,alignItems:'center'}:{position:'absolute',zIndex:76,top:R(n),left:R(e.cross)-10,height:R(r-n),width:20,borderLeftWidth:1.5,borderColor:a.colours.goldLight,justifyContent:'center'},children:(0,f.jsx)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),paddingHorizontal:3,borderRadius:4},children:(0,f.jsx)(u.T,{size:10,colour:a.colours.goldLight,children:e.gap})})},`sp${o}-${i}`))):null,'resize'===E?.kind?(()=>{const e=[...S,...k].find(e=>e.id===E.id);if(!e||!z)return null;const o=$(e,E.dx/z,E.dy/z,E.free);return(0,f.jsx)(s.default,{testID:"resize-size",pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:8,zIndex:78,alignItems:'center'},children:(0,f.jsxs)(s.default,{style:{backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:8,paddingHorizontal:12,paddingVertical:4,borderWidth:1,borderColor:o.match?a.colours.goldLight:a.colours.gold,alignItems:'center'},children:[(0,f.jsxs)(u.T,{size:13,weight:"bold",colour:a.colours.goldLight,center:!0,children:[o.w," \xd7 ",o.h]}),o.match?(0,f.jsxs)(u.T,{testID:"resize-match",size:12,colour:a.colours.goldLight,center:!0,children:["Same size as table ",o.match]}):null]})})})():null,E?.free?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',right:8,top:8,zIndex:77,backgroundColor:(0,t.soutersSurface)('#0C0B09'),borderRadius:6,paddingHorizontal:6,paddingVertical:2,borderWidth:1,borderColor:a.colours.border},children:(0,f.jsx)(u.T,{size:11,colour:a.colours.muted,children:"Moving freely (Alt / Option)"})}):null,0===S.length&&0===k.length?(0,f.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:'44%'},children:(0,f.jsx)(u.T,{center:!0,colour:a.colours.muted,children:"No tables in this area yet. Add them in step 2, or use Add table."})}):null]}):null})};var t=_r(d[0]),o=_r(d[1]),n=_r(d[2]),r=e(n),i=_r(d[3]),s=e(_r(d[4])),l=_r(d[5]),a=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),f=_r(d[10]);let b=!1;if('undefined'!=typeof window&&window.addEventListener){const e=e=>{b=e.altKey};window.addEventListener('keydown',e),window.addEventListener('keyup',e),window.addEventListener('blur',()=>{b=!1})}const p=e=>b||!!e.nativeEvent?.altKey},1359,[828,860,34,1360,102,859,821,794,1135,1361,25]); +__d(function(_g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"GRID_SIZES",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"DEFAULT_GRID",{enumerable:!0,get:function(){return n}}),Object.defineProperty(_e,"GUIDE_PULL",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"snapTo",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"gridOf",{enumerable:!0,get:function(){return o}}),_e.snapMove=function(e,n,o,x,y){const c=y.pull??r,f=(n,r)=>({x:(0,t.clamp)(Math.round(n),0,t.PLAN_W-e.w),y:(0,t.clamp)(Math.round(r),0,t.PLAN_H-e.h)});if(y.free){return{...f(n,o),guides:[],spacing:[]}}let h=y.snap?s(n,y.grid):n,u=y.snap?s(o,y.grid):o;const d=x.filter(t=>t.id!==e.id),l=t=>{const r='x'===t?n:o,s='x'===t?e.w:e.h;let a=null;for(const e of d){const n='x'===t?e.x:e.y,o='x'===t?e.w:e.h,i=[[n,'edge'],[n+o-s,'edge'],[n+o/2-s/2,'centre'],[n-s,'edge'],[n+o,'edge']];for(const[t,e]of i){const n=Math.abs(r-t);n<=c&&(!a||nt.areaId===r);if(!a.length)return e;const i=(e.fixtures??[]).filter(t=>t.areaId===r).map(t=>({id:t.id,x:t.x,y:t.y,w:t.w,h:t.h})),c=new Map,f=(e,n)=>(0,t.clamp)(n,0,t.PLAN_W-e.w),h=(e,n)=>(0,t.clamp)(n,0,t.PLAN_H-e.h);for(const t of y(a)){const e=t.reduce((t,e)=>t+e.y+e.h/2,0)/t.length,n=s(e,o),r=t.map(t=>t.h),a=t.map(t=>t.y).sort((t,e)=>t-e),i=s(a[Math.floor(a.length/2)],o),y=Math.max(...r)-Math.min(...r)<=2*o,u=t=>h(t,y?i:Math.round(n-t.h/2)),d=t.map(t=>({...t,x:f(t,s(t.x,o)),y:u(t)}));let l=d;if(t.length>=3){const e=d[0],n=d[d.length-1],r=d.reduce((t,e)=>t+e.w,0),a=(n.x+n.w-e.x-r)/(t.length-1);if(a>=0){let t=e.x;l=d.map(e=>{const n={...e,x:f(e,s(t,5))};return t+=e.w+a,n}),l.some((t,e)=>Math.abs(t.x-d[e].x)>2*o)&&(l=d)}}const g=t=>t.some((e,n)=>t.some((t,r)=>nc.set(t.id,{x:t.x,y:t.y}))}let u=a.map(t=>({...t,...c.get(t.id)??{}}));for(let t=0;t<5;t++){let t=!1;if(u=u.map((e,n)=>{const r=a[n];if(e.x===r.x&&e.y===r.y)return e;return u.some((t,s)=>s!==n&&x(e,t)&&!x(r,a[s]))||i.some(t=>x(e,t)&&!x(r,t))?(t=!0,r):e}),!t)break}const d=new Map(u.map(t=>[t.id,t]));return{...e,tables:e.tables.map(t=>{const e=d.get(t.id);return e?{...t,x:e.x,y:e.y}:t})}},Object.defineProperty(_e,"backupOf",{enumerable:!0,get:function(){return c}}),_e.restoreFrom=function(t,e){return{...t,tables:t.tables.map(t=>{const n=e.tables.find(e=>e.id===t.id)??e.tables.find(e=>e.name===t.name);return n?{...t,x:n.x,y:n.y}:t})}},Object.defineProperty(_e,"movedCount",{enumerable:!0,get:function(){return f}}),_e.onlyPositionsChanged=function(t,e){if(t.tables.length!==e.tables.length)return!1;const n=t=>JSON.stringify({...t,x:0,y:0});return t.tables.every((t,r)=>n(t)===n(e.tables[r]))&&JSON.stringify(t.areas)===JSON.stringify(e.areas)&&JSON.stringify(t.joins)===JSON.stringify(e.joins)&&JSON.stringify(t.sections)===JSON.stringify(e.sections)&&JSON.stringify(t.fixtures??[])===JSON.stringify(e.fixtures??[])};var t=_r(_d[0]);const e=[10,25,50],n=25,r=8,s=(t,e)=>Math.round(t/e)*e,o=t=>e.includes(t)?t:n;function a(t,e){const n=[],r=t=>{if(n.some(e=>e.axis===t.axis&&e.at===t.at)){const e=n.find(e=>e.axis===t.axis&&e.at===t.at);e.from=Math.min(e.from,t.from),e.to=Math.max(e.to,t.to)}else n.push(t)};for(const n of e){const e=[[t.x,n.x,'edge'],[t.x+t.w,n.x+n.w,'edge'],[t.x,n.x+n.w,'edge'],[t.x+t.w,n.x,'edge'],[t.x+t.w/2,n.x+n.w/2,'centre']];for(const[s,o,a]of e)Math.abs(s-o)<.5&&r({axis:'x',at:s,from:Math.min(t.y,n.y),to:Math.max(t.y+t.h,n.y+n.h),kind:a});const s=[[t.y,n.y,'edge'],[t.y+t.h,n.y+n.h,'edge'],[t.y,n.y+n.h,'edge'],[t.y+t.h,n.y,'edge'],[t.y+t.h/2,n.y+n.h/2,'centre']];for(const[e,o,a]of s)Math.abs(e-o)<.5&&r({axis:'y',at:e,from:Math.min(t.x,n.x),to:Math.max(t.x+t.w,n.x+n.w),kind:a})}return n}function i(t,e){const n=[],r=e=>e.yt.y,s=e=>e.xt.x,o=e.filter(e=>r(e)&&e.x+e.w<=t.x).sort((t,e)=>e.x+e.w-(t.x+t.w))[0],a=e.filter(e=>r(e)&&e.x>=t.x+t.w).sort((t,e)=>t.x-e.x)[0];if(o&&a){const e=t.x-(o.x+o.w),r=a.x-(t.x+t.w);e>0&&Math.abs(e-r)<=2&&n.push({axis:'x',gap:Math.round(e),spans:[[o.x+o.w,t.x],[t.x+t.w,a.x]],cross:t.y+t.h/2})}const i=e.filter(e=>s(e)&&e.y+e.h<=t.y).sort((t,e)=>e.y+e.h-(t.y+t.h))[0],x=e.filter(e=>s(e)&&e.y>=t.y+t.h).sort((t,e)=>t.y-e.y)[0];if(i&&x){const e=t.y-(i.y+i.h),r=x.y-(t.y+t.h);e>0&&Math.abs(e-r)<=2&&n.push({axis:'y',gap:Math.round(e),spans:[[i.y+i.h,t.y],[t.y+t.h,x.y]],cross:t.x+t.w/2})}return n}const x=(t,e)=>t.xe.x&&t.ye.y;function y(t){const e=[...t].sort((t,e)=>t.y+t.h/2-(e.y+e.h/2)),n=[];for(const t of e){const e=t.y+t.h/2,r=n[n.length-1];if(r){const n=r.reduce((t,e)=>t+e.y+e.h/2,0)/r.length,s=Math.max(12,Math.min(t.h,...r.map(t=>t.h))/2);if(Math.abs(e-n)<=s){r.push(t);continue}}n.push([t])}return n.map(t=>t.sort((t,e)=>t.x-e.x))}const c=(t,e,n,r)=>({at:e,by:n,note:r,tables:t.tables.map(t=>({id:t.id,name:t.name,x:t.x,y:t.y}))});const f=(t,e)=>t.tables.filter(t=>{const n=e.tables.find(e=>e.id===t.id);return n&&(n.x!==t.x||n.y!==t.y)}).length},1360,[859]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_TABLE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_FIXTURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"SIZE_STEP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MATCH_PULL",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"snapStep",{enumerable:!0,get:function(){return d}}),e.resizeBox=function(o,a,c,s){const u=d(s.grid),h=t=>s.snap?(0,n.snapTo)(t,u):Math.round(t),l=t.PLAN_W-o.x,p=t.PLAN_H-o.y,b=o.w+a,M=o.h+c;let w,P,_=(0,t.clamp)(h(b),s.min,l),y=(0,t.clamp)(h(M),s.min,p);if(s.snap){const n=(s.others??[]).filter(n=>n.id!==s.selfId&&n.w<=l&&n.h<=p&&n.w>=s.min&&n.h>=s.min),t=(n,t)=>Math.abs(n-t)<=f;let o=null;for(const a of n)for(const[n,c]of[[a.w,a.h],[a.h,a.w]])if(!(n>l||c>p)&&(t(b,n)||t(_,n))&&(t(M,c)||t(y,c))){const t=Math.abs(b-n)+Math.abs(M-c);(!o||tn.id!==s.selfId&&(n.w===_&&n.h===y||n.w===y&&n.h===_));n&&(w=n.name,P=n.id)}return{w:_,h:y,...w?{match:w,matchId:P}:{}}};var n=r(_d[0]),t=r(_d[1]);const o=50,a=25,c=25,f=15,d=n=>Math.max(n,c)},1361,[1360,859]); +__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.SaveAsPlanDialog=function({venueId:e,plan:n,onClose:l,onSaved:s,toast:o}){const[p,h]=(0,t.useState)(''),[j,f]=(0,t.useState)(!1),[w,C]=(0,t.useState)('');return(0,y.jsxs)(v,{title:"Save as new plan",onClose:l,testID:"save-as-plan",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"Give this seating plan a name. The live plan stays as it is until you tap Use this plan."}),(0,y.jsx)(b,{value:p,onChange:e=>{h(e),C('')},testID:"save-as-plan-name"}),w?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:w}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:l}),(0,y.jsx)(x.Button,{label:"Save plan",testID:"save-as-plan-ok",disabled:j,onPress:async()=>{const t=(0,r.validatePlanName)(p);if(t.ok){f(!0),C('');try{const r=await(0,c.saveAsNewPlan)(e,n,t.name);o(`Saved \u201c${r.name}\u201d. The live plan is unchanged until you tap Use this plan.`),s(r.name),l()}catch(e){C((0,c.explainPlanError)(e))}finally{f(!1)}}else C(t.error)}})]})]})},_e.SavedPlansDialog=function({venueId:e,mode:p,role:h,isCar:j,onClose:f,onLive:w,toast:C}){const P=(0,r.canDeleteNamedPlan)(p,h,!!j),[D,S]=(0,t.useState)(null),[I,A]=(0,t.useState)(''),[k,T]=(0,t.useState)(null),[B,L]=(0,t.useState)(''),[R,E]=(0,t.useState)(null),[M,$]=(0,t.useState)(null),[_,z]=(0,t.useState)(!1),H=async()=>{try{S(await(0,c.listSavedPlans)(e)),A('')}catch(e){A((0,c.explainPlanError)(e))}};(0,t.useEffect)(()=>{H()},[e]);const N=async(t,n=!1)=>{if(!t.isActive){z(!0),A('');try{if(!n){const e=await(0,c.previewPlanSwitch)(t.id);if(e.length)return $({plan:t,rows:e}),void z(!1)}await(0,c.setLivePlan)(t.id);const l=(await(0,c.listSavedPlans)(e)).find(e=>e.id===t.id)??t;C(`Live plan is now \u201c${l.name}\u201d. It is on every screen.`),w(l.plan,l.name),$(null)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}},W=async()=>{if(!k)return;const e=(0,r.validatePlanName)(B);if(e.ok){z(!0);try{await(0,c.renameSavedPlan)(k.id,e.name),T(null),await H(),C(`Renamed to \u201c${e.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}else A(e.error)},U=async()=>{if(R){z(!0);try{await(0,c.softDeleteSavedPlan)(R.id),E(null),await H(),C(`Deleted \u201c${R.name}\u201d.`)}catch(e){A((0,c.explainPlanError)(e))}finally{z(!1)}}};if(M)return(0,y.jsxs)(v,{title:"Some bookings use tables this plan does not have",onClose:()=>$(null),testID:"plan-switch-warning",children:[(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:["If you make \u201c",M.plan.name,"\u201d live, these bookings today or coming up sit on table numbers that are not on that plan:"]}),(0,y.jsx)(l.default,{style:{maxHeight:280},contentContainerStyle:{gap:8},children:M.rows.map(e=>(0,y.jsxs)(s.default,{style:{borderWidth:1,borderColor:u.colours.border,borderRadius:12,padding:10},children:[(0,y.jsx)(x.T,{style:{textAlign:'center'},children:e.name}),(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[e.date.split('-').reverse().join('/')," at ",e.time," \xb7 table",1===e.missing.length?'':'s'," ",e.missing.join(', ')," \xb7 ",e.covers," ",1===e.covers?'cover':'covers']})]},e.id))}),(0,y.jsxs)(x.T,{colour:u.colours.muted,size:13,style:{textAlign:'center'},children:[(0,r.formatWarningList)(M.rows).split('\n').length," booking",1===M.rows.length?'':'s'," in all."]}),(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep the live plan",onPress:()=>$(null)}),(0,y.jsx)(x.Button,{label:"Use this plan anyway",testID:"plan-switch-anyway",disabled:_,onPress:()=>N(M.plan,!0)})]})]});if(k)return(0,y.jsxs)(v,{title:"Rename plan",onClose:()=>T(null),testID:"rename-plan",children:[(0,y.jsx)(b,{value:B,onChange:L,testID:"rename-plan-name"}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Cancel",onPress:()=>T(null)}),(0,y.jsx)(x.Button,{label:"Save name",testID:"rename-plan-ok",disabled:_,onPress:W})]})]});if(R)return(0,y.jsxs)(v,{title:"Delete this plan?",onClose:()=>E(null),testID:"delete-plan",children:[(0,y.jsxs)(x.T,{style:{textAlign:'center'},children:["Delete \u201c",R.name,"\u201d? This cannot be undone from this screen. The live plan is not affected."]}),I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsxs)(x.Row,{gap:10,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{kind:"secondary",label:"Keep this plan",onPress:()=>E(null)}),(0,y.jsx)(x.Button,{kind:"danger",label:"Delete plan",testID:"delete-plan-ok",disabled:_,onPress:U})]})]});return(0,y.jsxs)(v,{title:"Saved seating plans",onClose:f,testID:"saved-plans",children:[(0,y.jsx)(x.Muted,{style:{textAlign:'center'},children:"The live plan is the one every screen uses. Use this plan makes a saved plan live on every device."}),null===D?(0,y.jsx)(n.default,{color:u.colours.gold}):null,I?(0,y.jsx)(x.T,{colour:u.colours.red,style:{textAlign:'center'},children:I}):null,(0,y.jsx)(l.default,{style:{maxHeight:420},contentContainerStyle:{gap:10},children:(D??[]).map(e=>{const t=(0,o.planCounts)(e.plan);return(0,y.jsxs)(s.default,{testID:`saved-plan-${e.id}`,style:{borderWidth:1,borderColor:e.isActive?u.colours.gold:u.colours.border,borderRadius:14,padding:12,gap:8,alignItems:'center'},children:[(0,y.jsx)(x.T,{weight:"bold",size:18,style:{textAlign:'center'},children:e.name}),e.isActive?(0,y.jsx)(s.default,{testID:"live-plan-badge",style:{borderWidth:1,borderColor:u.colours.gold,borderRadius:999,paddingHorizontal:10,paddingVertical:2},children:(0,y.jsx)(x.T,{size:13,colour:u.colours.gold,weight:"semibold",children:"Live"})}):null,(0,y.jsxs)(x.Muted,{style:{textAlign:'center'},children:[t.tables," tables \xb7 ",t.seats," seats",e.updatedBy?` \xb7 last saved by ${e.updatedBy}`:'']}),(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[e.isActive?(0,y.jsx)(x.Muted,{children:"This is the live plan"}):(0,y.jsx)(x.Button,{small:!0,label:"Use this plan",testID:`use-plan-${e.id}`,disabled:_,onPress:()=>N(e)}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Rename",testID:`rename-plan-${e.id}`,onPress:()=>{A(''),T(e),L(e.name)}}),P&&!e.isActive?(0,y.jsx)(x.Button,{small:!0,kind:"danger",label:"Delete",testID:`delete-plan-${e.id}`,onPress:()=>{A(''),E(e)}}):null]})]},e.id)})})]})},_e.NamedPlanButtons=function({onSaveAs:e,onList:t}){return(0,y.jsxs)(x.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Saved plans",testID:"open-saved-plans",accessibilityLabel:"Saved seating plans",onPress:t,style:{minHeight:44}}),(0,y.jsx)(x.Button,{small:!0,kind:"secondary",label:"Save as new plan",testID:"open-save-as-plan",accessibilityLabel:"Save as new plan",onPress:e,style:{minHeight:44}})]})};var t=_r(d[0]),n=e(_r(d[1])),l=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),r=_r(d[5]),c=_r(d[6]),u=_r(d[7]),p=_r(d[8]),h=_r(d[9]),x=_r(d[10]),y=_r(d[11]);function v({title:e,onClose:t,testID:n,children:l}){return(0,y.jsx)(s.default,{testID:n,style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)',alignItems:'center',justifyContent:'center',padding:16,zIndex:40},children:(0,y.jsxs)(s.default,{style:{width:'100%',maxWidth:520,maxHeight:'92%',backgroundColor:u.colours.surface,borderRadius:16,borderWidth:1,borderColor:u.colours.gold,padding:20,gap:12},accessibilityViewIsModal:!0,children:[(0,y.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,y.jsx)(x.T,{weight:"bold",size:20,colour:u.colours.gold,style:{flex:1,textAlign:'center'},children:e}),(0,y.jsx)(p.GoldClose,{onPress:t,label:"Close",testID:`${n}-close`})]}),l]})})}function b({value:e,onChange:t,testID:n}){return(0,y.jsx)(h.TextInput,{testID:n,value:e,onChangeText:t,placeholder:r.SAVE_AS_PLACEHOLDER,placeholderTextColor:"#7A7468",accessibilityLabel:r.PLAN_NAME_LABEL,autoCapitalize:"words",autoCorrect:!0,maxLength:60,style:{minHeight:48,borderWidth:1,borderColor:u.colours.border,borderRadius:12,paddingHorizontal:14,color:u.colours.text,fontSize:17,textAlign:'center',backgroundColor:u.colours.surface2}})}},1362,[34,385,295,102,859,1363,1364,821,796,827,794,25]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAIN_PLAN_NAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVE_AS_PLACEHOLDER",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PLAN_NAME_LABEL",{enumerable:!0,get:function(){return r}}),e.normalizePlanName=o,e.validatePlanName=function(n){const t=o(n);return t?t.length>a?{ok:!1,error:`Use ${a} characters or fewer.`}:{ok:!0,name:t}:{ok:!1,error:'Give this plan a name.'}},e.planTableNames=function(n){const t=new Set;for(const r of n?.tables??[]){const n=String(r?.name??'').trim();n&&t.add(n)}return t},e.bookingsMissingTables=function(n,t,r){const a=new Set([...t].map(n=>String(n).trim()).filter(Boolean)),o=[];for(const t of n){if(t.dateString(n).trim()).filter(Boolean),l=n.filter(n=>!a.has(n));l.length&&o.push({id:t.id,name:t.name,date:t.date,time:c(t.time),covers:t.covers,tables:n,missing:l})}return o.sort((n,t)=>(n.date+n.time).localeCompare(t.date+t.time)||n.name.localeCompare(t.name)),o},e.formatWarningList=function(n){return n.length?n.map(n=>{const t=n.missing.join(', ');return`${n.name}, ${n.date.split('-').reverse().join('/')} at ${n.time}, table${1===n.missing.length?'':'s'} ${t} (${n.covers} ${1===n.covers?'cover':'covers'})`}).join('\n'):''},e.canDeleteNamedPlan=function(n,t,r=!1){return!r&&'managers'===n&&('owner'===t||'manager'===t)},e.isLivePlanName=function(t){const r=o(t);return r===n||'Main'===r};const n='Main plan',t='Christmas party',r='Plan name',a=60;function o(n){return String(n??'').replace(/\s+/g,' ').trim()}const s=new Set(['pending','confirmed','seated']);function c(n){const t=String(n||'');return t.length>=5?t.slice(0,5):t}},1363,[]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.listSavedPlans=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().from('table_plans').select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').eq('venue_id',e).is('deleted_at',null).order('name');if(t)throw t;return(a??[]).map(l).sort((e,a)=>Number(a.isActive)-Number(e.isActive)||e.name.localeCompare(a.name,'en-GB'))},_e.saveAsNewPlan=async function(a,t,r){const o=(0,e.validatePlanName)(r);if(!o.ok)throw new Error(o.error);const{data:c,error:u}=await(0,n.getSupabase)().from('table_plans').insert({venue_id:a,name:o.name,is_active:!1,areas:t.areas??[],tables:t.tables??[],joins:t.joins??[],sections:t.sections??[],fixtures:t.fixtures??[],updated_by:s()}).select('id,name,is_active,updated_at,updated_by,areas,tables,joins,sections,fixtures').single();if(u)throw u;return l(c)},_e.previewPlanSwitch=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('named_plan_switch_preview',{p_id:e});if(t)throw t;return c(a)},_e.setLivePlan=async function(e){const{data:a,error:t}=await(0,n.getSupabase)().rpc('set_live_table_plan',{p_id:e,p_by:s()});if(t)throw t;const r=a??{};return{name:String(r.name||''),warnings:c(r.warnings)}},_e.renameSavedPlan=async function(a,t){const r=(0,e.validatePlanName)(t);if(!r.ok)throw new Error(r.error);const{data:o,error:l}=await(0,n.getSupabase)().rpc('rename_table_plan',{p_id:a,p_name:r.name,p_by:s()});if(l)throw l;return String(o?.name||r.name)},_e.softDeleteSavedPlan=async function(e){const{error:a}=await(0,n.getSupabase)().rpc('soft_delete_table_plan',{p_id:e,p_by:s()});if(a)throw a},_e.explainPlanError=function(e){const a=String(e&&'object'==typeof e&&'message'in e?e.message:e||'');return/duplicate key|unique/i.test(a)?'A plan with that name is already saved.':/not found/i.test(a)?'That seating plan was not found.':/cannot delete/i.test(a)?'A Display or car cannot delete a seating plan.':/only seating plan/i.test(a)?'This is the only seating plan.':/Switch to another/i.test(a)?'Switch to another plan before deleting this one.':/Not allowed/i.test(a)?'You cannot change seating plans with this sign-in.':a||'That didn\u2019t save. Try again.'};var e=_r(d[0]),a=_r(d[1]),t=_r(d[2]),n=_r(d[3]),r=_r(d[4]);const s=()=>(0,a.actorStamp)({isCar:t.IS_CAR,kind:r.useSync.getState().kind,staffRef:r.useSync.getState().staffRef,fallback:'Staff'});function o(e){return{areas:Array.isArray(e.areas)?e.areas:[],tables:Array.isArray(e.tables)?e.tables:[],joins:Array.isArray(e.joins)?e.joins:[],sections:Array.isArray(e.sections)?e.sections:[],fixtures:Array.isArray(e.fixtures)?e.fixtures:[]}}function l(a){return{id:String(a.id),name:String(a.name||e.MAIN_PLAN_NAME),isActive:!0===a.is_active,updatedAt:String(a.updated_at||''),updatedBy:a.updated_by?String(a.updated_by):null,plan:o(a)}}function c(e){return Array.isArray(e)?e.map(e=>({id:String(e.id),name:String(e.name||'Guest'),date:String(e.date||''),time:String(e.time||''),covers:Number(e.covers||0),tables:Array.isArray(e.tables)?e.tables.map(String):[],missing:Array.isArray(e.missing)?e.missing.map(String):[]})):[]}},1364,[1363,1025,872,933,987]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return u.HOLD_SLOP_PX}}),_e.HoldToEdit=function({label:t="Edit plan",ms:n=2e3,onUnlock:h,onHint:f,testID:p="view-plan",big:b,quiet:k}){const[E,L]=(0,e.useState)(0),[x,w]=(0,e.useState)(!1),y=(0,e.useRef)((0,u.makeHold)(n)).current,D=(0,e.useRef)(null),j=(0,e.useRef)({onUnlock:h,onHint:f});j.current={onUnlock:h,onHint:f};const C=(0,e.useRef)(0),H=(0,e.useRef)(null),I=()=>{D.current&&clearInterval(D.current),D.current=null},T=e=>{const t=y.up();I(),L(0),e&&null!=t&&Date.now()-t{const e=H.current;if(!e||!e.addEventListener)return I;const t=e.style;t.touchAction='none',t.userSelect='none',t.webkitUserSelect='none',t.webkitTouchCallout='none',t.webkitTapHighlightColor='transparent';const n=t=>{if(!(t.button>0)){try{e.setPointerCapture(t.pointerId)}catch{}var n,o;n=t.clientX,o=t.clientY,I(),y.down(n,o,Date.now()),L(.001),D.current=setInterval(()=>{const e=y.tick(Date.now());if(!y.active()&&e<1)return I(),void L(0);L(e),e>=1&&(I(),L(0),C.current=Date.now()+1500,j.current.onUnlock())},40)}},o=e=>y.move(e.clientX,e.clientY),s=e=>T('mouse'!==e.pointerType),l=()=>T(!1),c=e=>{e.preventDefault()},u=()=>{Date.now(){'Enter'!==e.key&&' '!==e.key||(e.preventDefault(),w(!0))},h={passive:!1};return e.addEventListener('pointerdown',n),e.addEventListener('pointermove',o),e.addEventListener('pointerup',s),e.addEventListener('pointercancel',l),e.addEventListener('contextmenu',c),e.addEventListener('selectstart',c),e.addEventListener('touchstart',c,h),e.addEventListener('dragstart',c),e.addEventListener('click',u),e.addEventListener('keydown',v),()=>{I(),e.removeEventListener('pointerdown',n),e.removeEventListener('pointermove',o),e.removeEventListener('pointerup',s),e.removeEventListener('pointercancel',l),e.removeEventListener('contextmenu',c),e.removeEventListener('selectstart',c),e.removeEventListener('touchstart',c,h),e.removeEventListener('dragstart',c),e.removeEventListener('click',u),e.removeEventListener('keydown',v)}},[]);const _=E>0,P=k?{...c.look.quiet(!1),borderColor:_?s.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:'rgba(255,255,255,0.025)',flexGrow:1,minWidth:130,minHeight:44,overflow:'hidden',userSelect:'none'}:{minHeight:b?60:48,minWidth:150,borderRadius:16,borderWidth:1.5,borderColor:_?s.colours.gold:s.colours.border,overflow:'hidden',justifyContent:'center',paddingHorizontal:14,backgroundColor:s.colours.surface,userSelect:'none'},S={testID:p,accessible:!0,accessibilityRole:'button',accessibilityLabel:`${t}, locked. Double-tap to unlock with a confirm, or press and hold for 2 seconds.`},U=(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{testID:"hold-progress",pointerEvents:"none",style:{position:'absolute',left:0,top:0,bottom:0,width:`${Math.round(100*E)}%`,backgroundColor:s.colours.gold,opacity:.85}}),(0,v.jsxs)(o.default,{pointerEvents:"none",style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8},children:[(0,v.jsx)(l.T,{size:k?14:b?18:16,children:'\ud83d\udd11'}),(0,v.jsxs)(o.default,{children:[(0,v.jsx)(l.T,{size:k?14:b?17:15,weight:"semibold",colour:_&&E>.5?s.colours.onGold:k?s.colours.muted:s.colours.goldLight,children:_?'Keep holding\u2026':t}),(0,v.jsx)(l.T,{size:k?10:11,colour:_&&E>.5?s.colours.onGold:k?'#857D6E':s.colours.muted,children:_?`${Math.max(0,Math.ceil((1-E)*n/1e3))} s`:'Hold 2 s to unlock'})]})]})]});return(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(o.default,{ref:H,...S,tabIndex:0,style:P,children:U}),(0,v.jsxs)(l.Sheet,{visible:x,onClose:()=>w(!1),title:`Unlock ${t}?`,maxWidth:420,testID:"unlock-confirm",children:[(0,v.jsx)(l.T,{colour:s.colours.muted,children:"The table plan can then be changed on this Display."}),(0,v.jsxs)(o.default,{style:{flexDirection:'row',gap:10,marginTop:14},children:[(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Unlock",testID:"unlock-confirm-yes",onPress:()=>{w(!1),j.current.onUnlock()}})}),(0,v.jsx)(o.default,{style:{flex:1},children:(0,v.jsx)(l.Button,{label:"Cancel",kind:"secondary",testID:"unlock-confirm-no",onPress:()=>w(!1)})})]})]})]})};var e=r(d[0]);r(d[1]),r(d[2]);var t,n=r(d[3]),o=(t=n)&&t.__esModule?t:{default:t},s=r(d[4]),l=r(d[5]),c=r(d[6]),u=r(d[7]),v=r(d[8])},1365,[34,236,402,102,821,794,1189,1366,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HOLD_SLOP_PX",{enumerable:!0,get:function(){return n}}),e.makeHold=function(t,u=n){let l=null,o=0,c=0,f=!1;return{down(n,t,u){l=u,o=n,c=t,f=!1},move(n,t){null!=l&&Math.hypot(n-o,t-c)>u&&(l=null)},up(){const n=l;return l=null,n},tick(n){if(null==l||f)return 0;const u=Math.min(1,(n-l)/t);return u>=1&&(f=!0,l=null),u},active:()=>null!=l}};const n=15},1366,[]); +__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,"SLOT_W",{enumerable:!0,get:function(){return k}}),Object.defineProperty(_e,"ROW_H",{enumerable:!0,get:function(){return w}}),Object.defineProperty(_e,"FIT_ROW_MIN",{enumerable:!0,get:function(){return M}}),_e.Timeline=function({plan:e,bookings:T,now:S,privacy:v,onOpen:I,turnBase:D,t0:z,t1:E,height:$,pauses:L,blockedTables:R,hideNow:_,compact:O=!1,fit:B=!1}){const W=(0,i.useMemo)(()=>[{key:'__none',area:'',name:'To assign'},...e.areas.flatMap(t=>e.tables.filter(e=>e.areaId===t.id).map(e=>({key:e.name,area:t.name,name:(0,c.tableLabel)(e)})))],[e]),N=T.filter(e=>!['cancelled','noshow'].includes(e.status)),[A,F]=(0,i.useState)(0),P=B&&!N.some(e=>!e.table)?W.filter(e=>'__none'!==e.key):W,H=B&&A>0?Math.max(M,Math.min(w,Math.floor(A/Math.max(1,P.length)))):w,Y=H<44,V=(0,i.useMemo)(()=>(0,h.clashes)(N,D),[N,D]),U=Math.max(1,Math.ceil((E.getTime()-z.getTime())/9e5)),[X,G]=(0,i.useState)(0),q=Math.max(30,X-C-2),J=Math.min(U,Math.max(1,Math.floor(q/k))),K=X>0?Math.max(k,Math.floor(q/J*100)/100):k,[Q,Z]=(0,i.useState)(0),ee=Math.max(0,U-J),te=Math.max(0,Math.min(ee,Q)),le=(0,b.addMins)(z,15*te),oe=(0,b.addMins)(le,15*J),ie=e=>(e.getTime()-le.getTime())/9e5*K,[re,ne]=(0,i.useState)(null),se=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=_?0:Math.floor((S.getTime()-z.getTime())/9e5)-Math.floor(J/3);Z(Math.max(0,Math.min(ee,e)))},[z.getTime(),J,ee,_]);const[ae,de]=(0,i.useState)(''),[ce,he]=(0,i.useState)(null),ue=(0,i.useRef)(null);ue.current=ce,(0,i.useEffect)(()=>{if(!ce)return;const e=setTimeout(()=>he(null),a.ARM_MS);return()=>clearTimeout(e)},[ce]);const be=ce?N.find(e=>e.id===ce.id):void 0,me=(t,l)=>({onStartShouldSetResponder:()=>!0,onMoveShouldSetResponder:()=>(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderTerminationRequest:()=>!(0,a.isArmed)(ue.current,t.id,Date.now()),onResponderGrant:e=>{se.current={x:e.nativeEvent.pageX,y:e.nativeEvent.pageY}},onResponderMove:e=>{if(!se.current||!(0,a.isArmed)(ue.current,t.id,Date.now()))return;const o=e.nativeEvent.pageX-se.current.x,i=e.nativeEvent.pageY-se.current.y;(Math.abs(i)>=6||Math.abs(o)>=6)&&ne({id:t.id,row:l,dy:i})},onResponderRelease:i=>{const n=se.current;se.current=null,ne(null);const s=i.nativeEvent.pageX-(n?.x??0),c=i.nativeEvent.pageY-(n?.y??0),u=(0,a.releaseOn)(ue.current,t.id,!(Math.abs(s)<6&&Math.abs(c)<6),Date.now());if(he(u.arm),'select'===u.action){de('');try{r.default.announceForAccessibility(a.SELECTED_A11Y)}catch{}return}if('deselect'===u.action)return void de('');if('none'===u.action)return;de('');const g=P.findIndex(e=>e.key===l),p=Math.max(0,Math.min(P.length-1,g+Math.round(c/H))),x=(0,f.dragTables)(t.table,l,P[p].key);if(!x||(0,o.guardBookingChange)(de,{b:t,tables:x.split('+')}))if(x){d.repo.bookings.update(t.id,{table:x,tableSetHere:!0});const l=(0,f.overCapacityAsk)(x.split('+'),(0,f.seatsOf)(e,x.split('+')).total,t.partySize),i=`${(0,y.privName)(t,v)} \u2192 ${(0,f.tablesWords)(x.split('+'))}, still ${(0,b.hm)((0,h.startOf)(t))}${l?` \xb7 ${l.replace(' Use it anyway?','')} Drag back to undo.`:''}`;de(`Saving ${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}\u2026`),(0,o.reportBookingSave)(t.id,i,`${(0,f.tablesWords)(x.split('+'))} for ${(0,y.privName)(t,v)}`,de)}else Math.abs(s)>=6&&Math.abs(c)=600||ae?(0,j.jsx)(s.default,{style:{flex:X>=600?1:void 0,flexBasis:X>=600?void 0:'100%',minWidth:0},children:(0,j.jsx)(x.T,{size:13,center:X<600,colour:p.colours.muted,numberOfLines:X>=600?1:2,testID:"timeline-hint",children:ae||a.SELECT_HINT})}):null,L?.length?(0,j.jsxs)(x.Row,{gap:4,children:[(0,j.jsx)(s.default,{style:{width:14,height:14,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:13,children:"Blocked"})]}):null,(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.goldLight,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))})}),(0,j.jsx)(s.default,{style:{flexShrink:0},children:(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})})]}):null]}):(0,j.jsxs)(j.Fragment,{children:[O?(0,j.jsxs)(s.default,{testID:"timeline-instructions",style:{gap:8,alignItems:'center'},children:[(0,j.jsx)(s.default,{style:{alignSelf:'center'},children:(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'})}),(0,j.jsx)(x.Muted,{center:!0,testID:"timeline-hint",children:a.SELECT_HINT}),(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:"Use Earlier times and Later times for the rest of service"}),ae?(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{center:!0,size:14,colour:p.colours.goldLight,children:ae})}):null]}):(0,j.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(x.Row,{gap:8,children:[(0,j.jsx)(x.Badge,{kind:V.size?'red':'ok',label:V.size?`${V.size} bookings clash`:'No clashes'}),(0,j.jsx)(s.default,{style:{flex:1,minWidth:0},children:(0,j.jsx)(x.Muted,{testID:"timeline-hint",children:a.SELECT_HINT})})]}),(0,j.jsx)(s.default,{testID:"clash-count",accessibilityLabel:`clashes ${V.size}`,children:(0,j.jsx)(x.T,{size:13,colour:p.colours.goldLight,children:ae})})]}),(0,j.jsxs)(x.T,{center:!0,testID:"timeline-window",children:[(0,b.hm)(le)," to ",(0,b.hm)(oe)]}),U>J?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-earlier",label:"Earlier times",disabled:0===te,onPress:()=>Z(Math.max(0,te-J))}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-later",label:"Later times",disabled:te>=ee,onPress:()=>Z(Math.min(ee,te+J))})]}):null,L?.length?(0,j.jsxs)(x.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,j.jsx)(s.default,{style:{width:16,height:16,backgroundColor:'rgba(255,181,71,0.4)',borderRadius:3}}),(0,j.jsx)(x.T,{size:14,children:"Blocked"})]}):null]}),(0,j.jsxs)(s.default,{testID:"timeline-grid",onLayout:e=>{const t=e.nativeEvent.layout.width;Math.abs(t-X)>1&&G(t)},style:{flex:$?void 0:1,height:$,flexShrink:O?0:void 0,flexDirection:'column',borderRadius:14,borderWidth:1,borderColor:p.colours.border,overflow:'hidden',backgroundColor:(0,t.soutersSurface)('#0F0E0C')},children:[(0,j.jsxs)(s.default,{testID:"timeline-time-header",style:{flexDirection:'row',height:38,flexShrink:0,borderBottomWidth:1,borderColor:p.colours.border,backgroundColor:(0,t.soutersSurface)('#0F0E0C'),zIndex:40},children:[(0,j.jsx)(s.default,{testID:"timeline-table-head",style:{width:C,justifyContent:'center',paddingLeft:8,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:(0,j.jsx)(x.T,{size:13,weight:"semibold",colour:p.colours.goldLight,children:"Table"})}),(0,j.jsxs)(s.default,{style:{width:J*K,flexShrink:0},children:[Array.from({length:Math.ceil(J/4)},(e,t)=>(0,j.jsx)(s.default,{testID:"tl-time",pointerEvents:"none",style:{position:'absolute',left:4*t*K,top:26,bottom:0,width:1,backgroundColor:p.colours.border}},t)),Array.from({length:Math.ceil(J/4)},(e,t)=>{const l=4*t*K,o=Math.max(0,Math.min(J*K-56,l-28));return(0,j.jsx)(s.default,{testID:"tl-time-label",dataSet:{x:String(l)},pointerEvents:"none",style:{position:'absolute',left:o,width:56,top:4,height:22,justifyContent:'center'},children:(0,j.jsx)(x.T,{size:15,weight:"semibold",colour:p.colours.goldLight,center:!0,numberOfLines:1,children:(0,b.hm)((0,b.addMins)(le,60*t))})},`l${t}`)})]})]}),(0,j.jsxs)(n.default,{testID:"timeline-scroll",onLayout:e=>{const t=e.nativeEvent.layout.height;Math.abs(t-A)>1&&F(t)},style:{flex:1},contentContainerStyle:{flexDirection:'row',width:'100%'},children:[(0,j.jsx)(s.default,{style:{width:C,borderRightWidth:1,borderColor:p.colours.border,backgroundColor:p.colours.surface},children:P.map((e,t,l)=>(0,j.jsx)(s.default,{accessible:!0,accessibilityLabel:'__none'===e.key||/^tables?\b/i.test(e.name)?'__none'===e.key?'No table':e.name:`Table ${e.name}`,style:{height:H,justifyContent:'center',paddingLeft:8,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:t>0&&l[t-1].area!==e.area?2:0,borderTopColor:p.colours.gold},children:Y?(0,j.jsxs)(s.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6},children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,numberOfLines:1,style:{flexShrink:1},children:e.area.toUpperCase()})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(x.T,{size:14,weight:"semibold",children:e.name}),!e.area||0!==t&&l[t-1].area===e.area?null:(0,j.jsx)(x.T,{size:10,colour:p.colours.gold,children:e.area.toUpperCase()})]})},e.key))}),(0,j.jsx)(s.default,{style:{width:J*K,flexShrink:0,overflow:'hidden'},onStartShouldSetResponder:()=>!!ue.current,onResponderRelease:()=>{he(null),de('')},children:(0,j.jsxs)(s.default,{style:{width:J*K},children:[(L??[]).map((e,t)=>{const l=Math.max(0,ie(e.from)),o=Math.min(J*K,ie(e.to));return o<=l?null:(0,j.jsx)(s.default,{testID:"tl-pause",accessible:!0,accessibilityLabel:`Blocked: ${e.label}, ${(0,b.hm)(e.from)} to ${(0,b.hm)(e.to)}`,pointerEvents:"none",style:{position:'absolute',left:l,width:o-l,top:0,bottom:0,backgroundColor:'rgba(255,181,71,0.10)',borderLeftWidth:2,borderRightWidth:2,borderColor:'rgba(255,181,71,0.55)',zIndex:1}},`pz${t}`)}),P.map((e,o,i)=>{return(0,j.jsxs)(s.default,{testID:`tl-row-${e.key}`,style:{height:H,borderBottomWidth:1,borderColor:'#211E19',borderTopWidth:o>0&&i[o-1].area!==e.area?2:0,borderTopColor:'rgba(207,164,95,0.4)'},children:[Array.from({length:Math.ceil(J/4)},(e,l)=>(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:4*l*K,top:0,bottom:0,width:1,backgroundColor:(0,t.soutersSurface)('#1E1B16')}},l)),R?.includes(e.key)?(0,j.jsx)(s.default,{pointerEvents:"none",style:{position:'absolute',left:0,right:0,top:0,bottom:0,backgroundColor:'rgba(58,58,58,0.55)',justifyContent:'center',paddingLeft:6},children:(0,j.jsx)(x.T,{size:11,weight:"bold",colour:"#CFCFCF",children:"Table blocked"})}):null,(r=e.key,N.filter(e=>('__none'===r?!e.table:(0,c.tablesOf)(e.table).includes(r))&&(0,h.startOf)(e)le)).map(t=>{const o=re?.id===t.id&&re.row===e.key?re:null,i=ie((0,h.startOf)(t)),r=Math.max(0,Math.min(J*K-44,i)),n=Math.min(J*K,ie((0,b.addMins)((0,h.startOf)(t),(0,h.durOf)(t,D)))),d=Math.min(J*K-r,Math.max(44,n-Math.max(0,i))),c=V.has(t.id),f=ce?.id===t.id;return(0,j.jsx)(s.default,{testID:`tl-${t.id}`,accessibilityRole:"button",accessibilityLabel:`${(0,y.privName)(t,v)}, ${'__none'===e.key?'no table':`Table ${e.name}`}, ${t.partySize} Covers, ${(0,b.hm)((0,h.startOf)(t))}, ${(0,h.durOf)(t,D)} min${c?', clash':''}${(0,u.depositView)(t,!0)?`, ${(0,u.depositView)(t,!0).a11y}`:''}${f?`. ${a.SELECTED_A11Y}`:''}`,accessibilityState:{selected:f},accessibilityHint:f?void 0:'Tap to select, then drag to another table',dataSet:{tlSelected:f?'1':'0'},...me(t,e.key),style:[{position:'absolute',left:r,top:(Y?2:4)+(o?o.dy:0),width:d,height:H-(Y?4:8),borderRadius:8,backgroundColor:(0,g.blockColour)(t),borderWidth:f?3:c?2.5:1,borderColor:f?p.colours.gold:c?'#FF6B5E':'rgba(0,0,0,0.4)',...f?{boxShadow:'0 0 0 3px rgba(226,196,137,0.55), 0 0 14px rgba(226,196,137,0.6)'}:{},paddingHorizontal:6,justifyContent:'center',zIndex:o?40:f?20:2,opacity:'finished'===t.status?g.FINISHED_OPACITY:1,cursor:f?'ns-resize':'pointer',touchAction:f?'none':'pan-y'},o?null:{transitionProperty:'left, width, top',transitionDuration:'200ms'}],children:(0,j.jsx)(x.T,{size:14,weight:"semibold",colour:(0,g.blockTextColour)(t),numberOfLines:Y?1:2,style:{lineHeight:16},children:d<100?Y&&d>=70?`${t.partySize} \xb7 ${(0,b.hm)((0,h.startOf)(t))}`:String(t.partySize):(0,j.jsxs)(j.Fragment,{children:[c?'\u26a0 ':'','__none'===e.key||Y?'':`${(0,l.tableNumbers)(e.key)} \xb7 `,t.walkIn?'Walk-in':(0,y.privName)(t,v)," \xb7 ",t.partySize,Y?' \xb7 ':'\n',(0,b.hm)((0,h.startOf)(t)),t.allergies.length?' \u26a0':'',(0,u.depositView)(t,!0)?d>=150?` \xb7 ${(0,u.depositView)(t,!0).label}`:'Deposit paid'===(0,u.depositShort)(t)?' \u2713':'':'']})})},t.id)})]},e.key);var r}),!_&&fe>=0&&fe<=J*K?(0,j.jsx)(s.default,{testID:"now-line",pointerEvents:"none",style:{position:'absolute',left:fe,top:0,bottom:0,width:2,backgroundColor:p.colours.gold,zIndex:30},children:(0,j.jsx)(s.default,{style:{position:'absolute',top:0,left:Math.max(-fe,Math.min(-18,J*K-fe-38)),width:38,backgroundColor:p.colours.gold,borderRadius:6},children:(0,j.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",center:!0,children:(0,b.hm)(S)})})}):null]})})]}),be?(0,j.jsx)(s.default,{pointerEvents:"box-none",style:{position:'absolute',left:0,right:0,bottom:8,alignItems:'center',zIndex:60},children:(0,j.jsxs)(x.Row,{wrap:!0,gap:8,style:{justifyContent:'center',backgroundColor:'rgba(15,14,12,0.94)',borderWidth:1.5,borderColor:p.colours.gold,borderRadius:14,paddingHorizontal:10,paddingVertical:4},children:[(0,j.jsx)(s.default,{testID:"timeline-selected",accessible:!0,accessibilityLiveRegion:"polite",accessibilityLabel:`${(0,y.privName)(be,v)} ${a.SELECTED_A11Y}`,children:(0,j.jsxs)(x.T,{size:14,weight:"semibold",colour:p.colours.gold,center:!0,children:["Selected: ",(0,y.privName)(be,v)," \xb7 ",be.partySize]})}),(0,j.jsx)(x.Button,{small:!0,kind:"secondary",testID:"timeline-open-selected",label:"Open booking",onPress:()=>{he(null),I(be)}}),(0,j.jsx)(x.Button,{small:!0,kind:"ghost",testID:"timeline-deselect",label:"Deselect",onPress:()=>{he(null),de('')}})]})}):null]})]})};var t=_r(_d[0]),l=_r(_d[1]),o=_r(_d[2]),i=_r(_d[3]),r=e(_r(_d[4]));_r(_d[5]);var n=e(_r(_d[6])),s=e(_r(_d[7])),a=_r(_d[8]),d=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),u=_r(_d[12]),b=_r(_d[13]),f=_r(_d[14]),g=_r(_d[15]),p=_r(_d[16]),x=_r(_d[17]),y=_r(_d[18]),j=_r(_d[19]);const k=30,w=52,M=28,C=120},1367,[828,860,1123,34,281,236,295,102,1136,874,1029,1105,14,858,1124,1368,821,794,1369,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"blockColour",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"blockTextColour",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"FINISHED_OPACITY",{enumerable:!0,get:function(){return u}});const t=t=>'seated'===t.status?'#CFA45F':'finished'===t.status?'#3A352C':t.walkIn?'#B9925A':'#7A5C2E',n=t=>'seated'===t.status||t.walkIn&&'finished'!==t.status?'#0B0B0B':'#EAF4FF',u=.8},1368,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initials",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shortName",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pv",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"privName",{enumerable:!0,get:function(){return o}});const t=t=>t.replace(' (example)','').split(/\s+/).filter(Boolean).map(t=>`${t[0].toUpperCase()}.`).join(' '),n=t=>{const n=t.replace(' (example)','').split(/\s+/).filter(Boolean);return n.length<=1?n.length?n[0]:'':[n[0],...n.slice(1).map(t=>`${t[0].toUpperCase()}.`)].join(' ')},l=(t,l)=>t?l?n(t):t.replace(' (example)',''):'',o=(t,n)=>t.walkIn?`Walk-in ${t.ref}`:l(t.name,n)},1369,[]); +__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.Screensaver=function({rid:e,idleMins:t,pinOn:n,wake:i,tonightCards:s,cfg:l=null}){const[a,c]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),[h,f]=(0,o.useState)(''),w=(0,o.useRef)(Date.now()),j=(0,o.useRef)(!1),k=(0,o.useRef)(0);j.current=a,(0,o.useEffect)(()=>(v.useScreensaverAsleep.getState().set(a),()=>v.useScreensaverAsleep.getState().set(!1)),[a]);const I=(0,b.idleMsFor)(l,t);(0,o.useEffect)(()=>D?(0,y.keepFullscreen)():void 0,[]),(0,o.useEffect)(()=>{if(!D)return;const e=e=>'pointerdown'===e.type||'touchstart'===e.type||'mousedown'===e.type||'keydown'===e.type,t=t=>{const n=performance.now();return j.current&&e(t)?(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation?.(),k.current=n+800,j.current=!1,window.__ccWokeAt=n,c(!1),z.current&&d(!0),void(w.current=Date.now())):n{w.current=0});const n=['pointerdown','pointerup','mousedown','mouseup','touchstart','touchend','click','keydown','wheel'];n.forEach(e=>window.addEventListener(e,t,{capture:!0,passive:!1}));const o=setInterval(()=>{null!==I&&!j.current&&!T.current&&Date.now()-w.current>=I&&(j.current=!0,c(!0))},1e3);return()=>{n.forEach(e=>window.removeEventListener(e,t,{capture:!0})),clearInterval(o)}},[I]);const z=(0,o.useRef)(n);z.current=n;const T=(0,o.useRef)(u);return T.current=u,(0,o.useEffect)(()=>{if(!D)return;let e=null;const t=async()=>{try{e=await(navigator.wakeLock?.request?.('screen')),window.__ccWakeLock=e?'on':'unsupported'}catch{window.__ccWakeLock='refused'}};t();const n=()=>{'visible'===document.visibilityState&&t()};return document.addEventListener('visibilitychange',n),()=>{document.removeEventListener('visibilitychange',n);try{e?.release?.()}catch{}}},[]),u?(0,S.jsx)(E,{wake:i,entry:h,setEntry:f,onOk:()=>{d(!1),f(''),w.current=Date.now(),i.pinDefault&&(0,p.notify)({id:'wake-pin-default',tone:'warn',icon:'\ud83d\udd11',title:'Change the wake PIN',body:'This Display still uses the starting PIN (2580). A manager should set a new 6 to 8 digit PIN in Settings \u203a Display.',timeoutMs:12e3})}}):a?(0,S.jsx)(L,{rid:e,tonightCards:s,cfg:l}):null},_e.SaverLogoPreview=function({rid:e,path:t,size:n}){const[i,s]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t)return(0,j.saverPhotoUrl)(t).then(t=>{e&&s(t)}),()=>{e=!1};s(null)},[t]),(0,S.jsx)(M.Provider,{value:i,children:(0,S.jsx)(c.default,{testID:t?'saver-logo-uploaded':'saver-logo-default',style:{minWidth:n,height:n,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(P,{rid:e,size:n,textSize:14})})})},_e.Saver=L;var t=r(_d[0]),n=r(_d[1]),o=r(_d[2]),i=e(o),s=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var a=e(r(_d[6])),c=e(r(_d[7])),u=e(r(_d[8])),d=r(_d[9]),h=r(_d[10]),f=r(_d[11]),w=r(_d[12]),p=r(_d[13]),v=r(_d[14]),y=r(_d[15]),x=r(_d[16]),b=r(_d[17]),j=r(_d[18]),k=r(_d[19]),I=r(_d[20]),S=r(_d[21]);const D='undefined'!=typeof window;function E({wake:e,entry:t,setEntry:o,onOk:i}){const s=e.pinLen||4,l=n=>{const l=(t+n).slice(0,s);o(l),l.length===s&&((0,w.wakePinMatches)(e,l)?i():setTimeout(()=>o(''),300))};return(0,S.jsxs)(c.default,{testID:"wake-pin",style:{position:D?'fixed':'absolute',left:0,right:0,top:0,bottom:0,zIndex:1e5,backgroundColor:(0,n.soutersSurface)('rgba(5,5,5,0.97)'),alignItems:'center',justifyContent:'center',gap:16},children:[(0,S.jsx)(f.T,{size:22,weight:"semibold",colour:d.colours.gold,children:"Enter staff PIN"}),(0,S.jsxs)(f.T,{size:30,weight:"bold",children:['\u25cf'.repeat(t.length),'\u25cb'.repeat(Math.max(0,s-t.length))]}),(0,S.jsx)(c.default,{style:{flexDirection:'row',flexWrap:'wrap',width:252,gap:12,justifyContent:'center'},children:['1','2','3','4','5','6','7','8','9','0'].map(e=>(0,S.jsx)(a.default,{accessibilityRole:"button",accessibilityLabel:`PIN ${e}`,onPress:()=>l(e),style:{width:72,height:72,borderRadius:36,borderWidth:2,borderColor:d.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,S.jsx)(f.T,{size:26,colour:d.colours.gold,children:e})},e))})]})}const z=e=>'abbotsford'===e?'#32373C':'kirkton'===e?'#0B0B0B':'greenside'===e?'#1A1A1A':'wildings'===e?'#272A2F':t.IS_SOUTERS?d.colours.bg:'#000000',T={logo:'logo',clock:'clock and date',covers:'today\u2019s covers',photos:'photo slideshow',black:'black screen'};function L({rid:e,cfg:t=null,box:n}){const i=(0,u.default)(),l=n?.width??i.width,a=n?.height??i.height,d=(0,o.useRef)(new s.default.Value(0)).current;(0,o.useEffect)(()=>{s.default.timing(d,{toValue:1,duration:700,useNativeDriver:!1}).start()},[]);const[h,f]=(0,o.useState)(()=>new Date);(0,o.useEffect)(()=>{const e=setInterval(()=>f(new Date),15e3);return()=>clearInterval(e)},[]);const w=t?t.style:'still',p=!!t&&(0,b.dimNow)(t,h),[v,y]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let e=!0;if(t?.logo)return(0,j.saverPhotoUrl)(t.logo).then(t=>{e&&y(t)}),()=>{e=!1};y(null)},[t?.logo]),(0,S.jsx)(M.Provider,{value:v,children:(0,S.jsxs)(s.default.View,{testID:n?"saver-preview-box":"screensaver",accessibilityRole:n?void 0:"button",accessibilityLabel:`Screensaver, ${t?T[t.style]:'logo'}${p?', dimmed for the night':''}. Touch anywhere to wake.`,style:{position:n?'relative':D?'fixed':'absolute',left:0,top:0,right:n?void 0:0,bottom:n?void 0:0,width:n?l:void 0,height:n?a:void 0,zIndex:n?0:1e5,backgroundColor:z(e),opacity:d,overflow:'hidden',cursor:'pointer',alignItems:'center',justifyContent:'center'},children:['logo'===w?(0,S.jsx)(_,{rid:e,width:l,height:a}):'clock'===w?(0,S.jsx)(A,{rid:e,now:h,width:l,height:a}):'covers'===w?(0,S.jsx)(N,{rid:e,now:h,width:l,height:a}):'photos'===w?(0,S.jsx)(R,{rid:e,paths:t?.photos??[],width:l,height:a}):'black'===w?(0,S.jsx)(c.default,{testID:"saver-black"}):(0,S.jsx)(C,{rid:e,width:l,height:a}),p?(0,S.jsx)(c.default,{testID:"saver-dim",pointerEvents:"none",style:{position:'absolute',left:0,top:0,right:0,bottom:0,backgroundColor:'rgba(0,0,0,0.72)'}}):null]})})}const M=i.default.createContext(null);function P({rid:e,size:t,textSize:n}){const o=(0,h.useBrand)(e),s=h.HERO_LOGOS[e]??o.logo,a=i.default.useContext(M);return a?(0,S.jsx)(l.default,{testID:"saver-custom-logo",source:{uri:a},style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):s?(0,S.jsx)(l.default,{source:s,style:{width:t,height:t},resizeMode:"contain",accessibilityLabel:`${o.name} logo`}):(0,S.jsx)(f.T,{size:n??Math.max(20,t/6),weight:"bold",colour:d.colours.gold,style:{textAlign:'center'},children:o.name})}function C({rid:e,width:t,height:n}){return(0,S.jsx)(c.default,{testID:"saver-still",children:(0,S.jsx)(P,{rid:e,size:.5*Math.min(t,n)})})}function _({rid:e,width:t,height:n}){const i=.34*Math.min(t,n),l=(0,o.useRef)(new s.default.ValueXY({x:0,y:0})).current,[a,c]=(0,o.useState)({w:i,h:i}),u=Math.max(i,a.w),d=Math.max(i,a.h);return(0,o.useEffect)(()=>{const e=Math.max(0,(t-u)/2-12),o=Math.max(0,(n-d)/2-12),i=[{x:-e,y:.6*-o},{x:.7*e,y:-o},{x:e,y:.5*o},{x:.4*-e,y:o},{x:0,y:0}],a=s.default.loop(s.default.sequence(i.map(e=>s.default.timing(l,{toValue:e,duration:12e3,useNativeDriver:!1}))));return a.start(),()=>a.stop()},[t,n,u,d]),(0,S.jsx)(s.default.View,{testID:"saver-logo",onLayout:e=>{const{width:t,height:n}=e.nativeEvent.layout;(Math.abs(t-a.w)>1||Math.abs(n-a.h)>1)&&c({w:t,h:n})},style:{transform:l.getTranslateTransform()},children:(0,S.jsx)(P,{rid:e,size:i})})}function A({rid:e,now:t,width:n,height:o}){const i=Math.min(.22*n,.32*o),s=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),l=t.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long',timeZone:'Europe/London'});return(0,S.jsxs)(c.default,{testID:"saver-clock",style:{alignItems:'center',gap:.12*i},children:[(0,S.jsx)(P,{rid:e,size:.7*i}),(0,S.jsx)(f.T,{size:i,weight:"bold",colour:d.colours.gold,style:{textAlign:'center',lineHeight:1.1*i},children:s}),(0,S.jsx)(f.T,{size:.24*i,style:{textAlign:'center'},children:l})]})}function N({rid:e,now:t,width:n,height:o}){const i=(0,k.useStore)(e=>e.bookings),s=(0,I.venueYmd)(t),l=t.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',hour12:!1,timeZone:'Europe/London'}),a=i.filter(t=>t.restaurantId===e&&t.date===s&&!['cancelled','noshow'].includes(t.status)),u=a.reduce((e,t)=>e+t.partySize,0),h=a.filter(e=>'seated'!==e.status&&'finished'!==e.status&&e.time>=l).sort((e,t)=>e.time.localeCompare(t.time)).slice(0,3),w=Math.min(n/12,o/9);return(0,S.jsxs)(c.default,{testID:"saver-covers",style:{alignItems:'center',gap:.3*w},children:[(0,S.jsx)(P,{rid:e,size:2*w}),(0,S.jsx)(f.T,{size:.5*w,style:{textAlign:'center'},children:"Today"}),(0,S.jsxs)(c.default,{style:{flexDirection:'row',gap:1.4*w,justifyContent:'center'},children:[(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:u}),(0,S.jsx)(f.T,{size:.42*w,children:1===u?'cover':'covers'})]}),(0,S.jsxs)(c.default,{style:{alignItems:'center'},children:[(0,S.jsx)(f.T,{size:1.6*w,weight:"bold",colour:d.colours.gold,children:a.length}),(0,S.jsx)(f.T,{size:.42*w,children:1===a.length?'booking':'bookings'})]})]}),h.length?(0,S.jsxs)(f.T,{size:.4*w,style:{textAlign:'center'},colour:d.colours.muted,children:["Next: ",h.map(e=>`${e.time} \xb7 ${e.partySize}`).join(' ')]}):(0,S.jsx)(f.T,{size:.4*w,colour:d.colours.muted,children:"No more arrivals booked today"})]})}function R({rid:e,paths:t,width:n,height:i}){const[l,a]=(0,o.useState)([]),[u,d]=(0,o.useState)(0),h=(0,o.useRef)(new s.default.Value(1)).current;return(0,o.useEffect)(()=>{let e=!0;return Promise.all(t.map(j.saverPhotoUrl)).then(t=>{e&&a(t.filter(e=>!!e))}),()=>{e=!1}},[t.join('|')]),(0,o.useEffect)(()=>{if(l.length<2)return;const e=setInterval(()=>{s.default.timing(h,{toValue:0,duration:600,useNativeDriver:!1}).start(()=>{d(e=>(e+1)%l.length),s.default.timing(h,{toValue:1,duration:600,useNativeDriver:!1}).start()})},8e3);return()=>clearInterval(e)},[l.length]),l.length?(0,S.jsx)(s.default.Image,{testID:"saver-photos",source:{uri:l[u%l.length]},style:{width:n,height:i,opacity:h},resizeMode:"cover",accessibilityLabel:`Photo ${u%l.length+1} of ${l.length}`}):(0,S.jsx)(c.default,{testID:"saver-photos-empty",children:(0,S.jsx)(P,{rid:e,size:.4*Math.min(n,i)})})}},1370,[5,828,34,283,336,236,402,102,426,821,873,794,1030,1001,1351,1371,2,1372,1373,874,858,25]); +__d(function(g,_r,i,a,m,e,_d){"use strict";function n(){if('undefined'!=typeof document&&!c())try{const n=document;if(n.fullscreenElement||n.webkitFullscreenElement)return;const t=document.documentElement,c=t.requestFullscreen??t.webkitRequestFullscreen;if('function'!=typeof c)return;const u=t.requestFullscreen?t.requestFullscreen({navigationUI:'hide'}):c.call(t);u&&'function'==typeof u.catch&&u.catch(()=>{})}catch{}}Object.defineProperty(e,'__esModule',{value:!0}),e.enterFullscreen=n,Object.defineProperty(e,"FULLSCREEN_TAP_EVENTS",{enumerable:!0,get:function(){return t}}),e.inTabletApp=c,e.keepFullscreen=function(){if('undefined'==typeof document||c())return()=>{};const t=()=>{'hidden'!==document.visibilityState&&n()};t();const u=()=>t(),r=()=>{const n=document;n.fullscreenElement||n.webkitFullscreenElement?window.__ccFullscreen='on':window.__ccFullscreen='off, next tap'};return document.addEventListener('visibilitychange',u),document.addEventListener('fullscreenchange',r),document.addEventListener('webkitfullscreenchange',r),()=>{document.removeEventListener('visibilitychange',u),document.removeEventListener('fullscreenchange',r),document.removeEventListener('webkitfullscreenchange',r)}},_r(_d[0]);const t=['pointerup','touchend','click','keydown'];function c(){return'undefined'!=typeof navigator&&/CoverChargeTablet\//.test(navigator.userAgent||'')}},1371,[236]); +__d(function(g,_r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SAVER_DEFAULT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"IDLE_OPTIONS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SAVER_STYLES",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SAVER_PHOTOS",{enumerable:!0,get:function(){return r}}),e.saverFromRow=function(o){return o?{on:!1!==o.is_on,idleMins:l(o.idle_mins)?Number(o.idle_mins):2,style:s(o.style)?o.style:'logo',photos:Array.isArray(o.photos)?o.photos.filter(o=>'string'==typeof o).slice(0,r):[],dimOn:!!o.dim_on,dimFrom:a(o.dim_from)?String(o.dim_from).slice(0,5):'23:00',dimTo:a(o.dim_to)?String(o.dim_to).slice(0,5):'07:00',logo:'string'==typeof o.logo_path&&o.logo_path?o.logo_path:null}:null},Object.defineProperty(e,"saverToRow",{enumerable:!0,get:function(){return u}}),e.dimNow=function(o,n){if(!o.dimOn)return!1;const t=60*n.getHours()+n.getMinutes(),r=c(o.dimFrom),l=c(o.dimTo);return r!==l&&(r=r&&t=r||t_?'That logo is over 2 MB. Please pick a smaller file.':n<=0?'That file is empty. Please pick another.':null:'Please pick a PNG, JPG or SVG logo.'},Object.defineProperty(e,"svgSafe",{enumerable:!0,get:function(){return y}});const o={on:!0,idleMins:2,style:'logo',photos:[],dimOn:!1,dimFrom:'23:00',dimTo:'07:00',logo:null},n=[{mins:2,label:'2 min'},{mins:5,label:'5 min'},{mins:10,label:'10 min'},{mins:15,label:'15 min'},{mins:30,label:'30 min'},{mins:0,label:'Never'}],t=[{id:'logo',label:'Logo',sub:'Your logo drifting slowly round the screen'},{id:'clock',label:'Clock & date',sub:'The time and today\u2019s date, large'},{id:'covers',label:'Today\u2019s covers',sub:'Covers and bookings today, and the next arrivals (no names)'},{id:'photos',label:'Photo slideshow',sub:'Your own photos, one at a time'},{id:'black',label:'Black',sub:'A black screen, saves the screen and power'}],r=30,l=o=>[0,2,5,10,15,30].includes(Number(o)),s=o=>t.some(n=>n.id===o),a=o=>'string'==typeof o&&/^([01][0-9]|2[0-3]):[0-5][0-9]/.test(o);const u=o=>({is_on:o.on,idle_mins:o.idleMins,style:o.style,photos:o.photos.slice(0,r),dim_on:o.dimOn,dim_from:o.dimFrom,dim_to:o.dimTo,logo_path:o.logo??null}),c=o=>60*Number(o.slice(0,2))+Number(o.slice(3,5));const b=(o,n)=>n.startsWith(`${o}/`)&&/^[0-9a-f-]{36}\/[A-Za-z0-9._-]{1,80}$/.test(n)&&!n.includes('..'),f=o=>o.dimOn?`Dimmed ${o.dimFrom}\u2013${o.dimTo}`:'No night dim',p={'image/png':'png','image/jpeg':'jpg','image/svg+xml':'svg'},_=2097152;const y=o=>/]/i.test(o)&&!/=u.MAX_SAVER_PHOTOS)throw new Error(`Up to ${u.MAX_SAVER_PHOTOS} photos.`);if(!['image/jpeg','image/png','image/webp'].includes(e.type))throw new Error('Please pick a JPEG, PNG or WebP photo.');if(e.size>6291456)throw new Error('That photo is over 6 MB. Please pick a smaller one.');const o='image/png'===e.type?'png':'image/webp'===e.type?'webp':'jpg',s=`${n}/${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${o}`,{error:c}=await l().storage.from(w).upload(s,e,{upsert:!1,contentType:e.type});if(c)throw c;return s},_e.uploadSaverLogo=async function(e){const t=f();if(!t)throw new Error('Uploading a logo needs the venue connection.');const n=(0,u.logoFileProblem)(e.type,e.size);if(n)throw new Error(n);let o=e;if('image/svg+xml'===e.type){if(!(0,u.svgSafe)(await e.text()))throw new Error('That SVG can\u2019t be used (it contains scripts or links). Please export a plain SVG or a PNG.');o=await P(e)}const s='image/png'===o.type?'png':u.LOGO_TYPES[o.type],c=`${t}/logo-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}.${s}`,{error:p}=await l().storage.from(w).upload(c,o,{upsert:!1,contentType:o.type});if(p)throw p;return c},_e.svgToPng=P,_e.saverPhotoUrl=async function(e){if(/^(https?:|data:|blob:)/.test(e))return e;const t=b.get(e);if(t&&t.until>Date.now())return t.url;try{const{data:t}=await l().storage.from(w).createSignedUrl(e,3600);if(t?.signedUrl)return b.set(e,{url:t.signedUrl,until:Date.now()+3e6}),t.signedUrl}catch{}return null},_e.useSaverSync=function(){const e=(0,c.useSync)(e=>e.venueId)&&p()?c.useSync.getState().venueId:null,t=S(e=>e.cfg);return n.default.useEffect(()=>{if(!e)return;let t=!0;const n=()=>{v().catch(()=>{})};n();const o=y(()=>{t&&n()}),s=setInterval(n,3e5);return()=>{t=!1,o(),clearInterval(s)}},[e]),t};var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(d[1]),s=r(d[2]),c=r(d[3]),u=r(d[4]);const l=()=>(0,s.getSupabase)(),p=()=>{try{return(0,s.getSupabase)(),!0}catch{return!1}},f=()=>p()?c.useSync.getState().venueId??null:null,h=()=>!!f(),w='display-photos',S=(0,o.create)(e=>({cfg:null,set:t=>e({cfg:t})}));async function v(){const e=f();if(!e)return S.getState().cfg;const{data:t,error:n}=await l().from('display_screensaver').select('*').eq('venue_id',e).maybeSingle();if(n)throw n;const o=(0,u.saverFromRow)(t);return S.getState().set(o),o}function y(e){const t=f();if(!t)return()=>{};try{const n=l().channel(`saver-${t}-${Math.random().toString(36).slice(2,8)}`).on('postgres_changes',{event:'*',schema:'public',table:'display_screensaver',filter:`venue_id=eq.${t}`},()=>e()).subscribe();return()=>{try{l().removeChannel(n)}catch{}}}catch{return()=>{}}}async function P(e,t=1024){if('undefined'==typeof document)throw new Error('Please pick a PNG or JPG logo on this device.');const n=URL.createObjectURL(e);try{const e=new Image;await new Promise((t,o)=>{e.onload=()=>t(),e.onerror=()=>o(new Error('That SVG couldn\u2019t be read. Please export it again, or use a PNG.')),e.src=n});const o=e.naturalWidth||t,s=e.naturalHeight||t,c=t/Math.max(o,s),u=document.createElement('canvas');u.width=Math.max(1,Math.round(o*c)),u.height=Math.max(1,Math.round(s*c)),u.getContext('2d').drawImage(e,0,0,u.width,u.height);const l=await new Promise(e=>u.toBlob(e,'image/png'));if(!l)throw new Error('That SVG couldn\u2019t be turned into a picture. Please use a PNG.');if(l.size>2097152)throw new Error('That logo is too detailed. Please use a smaller PNG or JPG.');return l}finally{URL.revokeObjectURL(n)}}const b=new Map},1373,[34,846,933,987,1372]); +__d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.guestDeposit=u,e.guestRowText=function(o,p){const d=o.partySize,b=Math.max(0,Math.min(d-1,Math.round(Number(o.children)||0))),$=`${d} ${1===d?'person':'people'}${b?` (${b} ${1===b?'child':'children'})`:''}`,c=(0,n.tablesOf)(o.table??void 0),h=p.seated?"Seated"+(c.length?` \xb7 ${(0,t.tableNumbers)(o.table)}`:''):c.length?(0,t.tableNumbers)(o.table):'No table yet',f=u(o),w=c.length?`table${c.length>1?'s':''} ${l(c.map(t.plainTableNumber))}`:'no table yet',x=!!o.dog,D=(0,s.allergyLine)(o),m=[o.time,p.name,D?`allergy noted: ${D}`:'',$,p.seated?'seated':'',f?.spoken??'',w,x?'dog':''].filter(Boolean).join(', ')+'.';return{time:o.time,name:p.name,people:$,deposit:f?.text??null,depositWarn:!!f?.warn,table:h,dog:x,allergy:D,a11y:m}};var t=r(_d[0]),o=r(_d[1]),n=r(_d[2]),s=r(_d[3]);const p=t=>`\xa3${(t/100).toFixed(t%100?2:0)}`,d=t=>`${(t/100).toFixed(t%100?2:0)} pounds`,l=t=>t.length<=1?t.join(''):`${t.slice(0,-1).join(', ')} and ${t[t.length-1]}`;function u(t){const n=(0,o.depositBadge)(t,p);if(!n)return null;const s=(0,o.wixPayStatus)(t),l=t.depositPaid??0,u=t.depositDue??0;if('PARTIALLY_PAID'===s||l>0&&u>l&&!n.label.startsWith('Deposit paid')){const t=l||0;return t>0&&u>t?{text:`Deposit ${p(t)} of ${p(u)} paid`,spoken:`deposit ${d(t).replace(' pounds','')} of ${d(u)} paid`,warn:!0}:{text:'Deposit part paid',spoken:'deposit part paid',warn:!0}}if(n.label.startsWith('Deposit waived'))return{text:'Deposit waived',spoken:'deposit waived',warn:!1};const b=n.label.match(/\xa3[\d.,]+/);if(n.label.startsWith('Deposit paid')){const t=/about/.test(n.label);return b?{text:`Deposit paid ${t?'about ':''}${b[0]}`,spoken:`deposit ${t?'about ':''}${b[0].slice(1)} pounds paid`,warn:!1}:{text:'Deposit paid',spoken:'deposit paid',warn:!1}}return/refund/.test(n.label)?{text:'Deposit refunded',spoken:'deposit refunded',warn:!1}:/link sent/.test(n.label)?{text:'Deposit not paid yet',spoken:'deposit not paid yet',warn:!0}:b?{text:`Deposit ${b[0]} not paid`,spoken:`deposit ${b[0].slice(1)} pounds not paid`,warn:!0}:{text:'Deposit not paid',spoken:'deposit not paid',warn:!0}}},1374,[860,14,1029,1375]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.allergyLine=function(n){const o=(n.allergies??[]).map(n=>(0,l.allergenLabel)(n.allergen)).join(', '),a=n.allergyNote?.trim()??'';return o||a?[o,a].filter(Boolean).join(' \xb7 ')+(n.allergyPeople?` (${n.allergyPeople} ${1===n.allergyPeople?'person':'people'})`:''):null};var l=r(d[0])},1375,[861]); +__d(function(g,r,i,a,m,_e,d){"use strict";function l(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.DogIcon=function({size:l=18,colour:u=t.colours.gold,testID:f}){return(0,o.jsx)(e.default,{testID:f,accessible:!0,accessibilityRole:"image",accessibilityLabel:"Dog",style:{width:l,height:l},children:(0,o.jsxs)(c.default,{width:l,height:l,viewBox:"0 0 24 24",children:[(0,o.jsx)(s.Path,{d:"M5.2 4.5 C2.6 4.8 1.6 8.6 2.4 11.8 C2.8 13.3 4.6 13.2 5.1 11.8 L6.6 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M18.8 4.5 C21.4 4.8 22.4 8.6 21.6 11.8 C21.2 13.3 19.4 13.2 18.9 11.8 L17.4 7.4 Z",fill:u}),(0,o.jsx)(s.Path,{d:"M12 4.2 C8.3 4.2 6 6.9 6 10.8 C6 15.6 8.6 20 12 20 C15.4 20 18 15.6 18 10.8 C18 6.9 15.7 4.2 12 4.2 Z",fill:u}),(0,o.jsx)(s.Circle,{cx:9.6,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Circle,{cx:14.4,cy:10.4,r:1.1,fill:t.colours.bg}),(0,o.jsx)(s.Ellipse,{cx:12,cy:15.2,rx:1.9,ry:1.4,fill:t.colours.bg})]})})},r(d[0]);var e=l(r(d[1])),s=r(d[2]),c=l(s),t=r(d[3]),o=r(d[4])},1376,[34,102,797,821,25]); +__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.GuestActionsSheet=function({rid:e,b:D,name:I,view:P,now:L,onClose:z,onDetails:W,onDone:N,otherDay:H,turnBase:T=90,onPickOnPlan:_,onEdit:A}){const[R,E]=(0,n.useState)(null),[F,M]=(0,n.useState)(!1),G=(0,S.useBookingWrite)(),[O,U]=(0,n.useState)(!1),[q,J]=(0,n.useState)(!1),[K,Q]=(0,n.useState)(!1),V=(0,k.guestRowText)(D,{name:I,seated:'seated'===D.status&&!H}),X='seated'===D.status&&!H,Y=D.table?X?`Seated \xb7 ${(0,l.tableCardLabel)(D.table)}`:(0,l.tableCardLabel)(D.table):X?'Seated':'No table yet',Z=H?[]:(0,g.guestActions)(D,I,P,L).filter(e=>'details'!==e.id),ee=(0,h.tableActions)(D,I),te={id:'details',label:'Guest details',a11y:`Guest details, ${I}`},se=async t=>{if(!(0,a.guardBookingChange)(N,{b:D,tables:[t]}))return;const s={...D,table:t};t!==D.table&&await y.repo.bookings.update(D.id,{table:t}),await(0,u.seatBookingNow)(e,s),N(`Saving: ${I} at ${(0,g.tableWords)(t)}\u2026`),z(),(0,a.reportBookingSave)(D.id,`${I} seated at ${(0,g.tableWords)(t)}.`,`${I} at ${(0,g.tableWords)(t)}`,N)},ae=async t=>'seat'===t.id&&t.table?se(t.table):'pick'===t.id?M(e=>!e):'details'===t.id?(z(),W(D)):'finished'===t.id?('seated'===D.status?await(0,u.finishBookingNow)(e,D):await y.repo.bookings.setStatus(D.id,'finished'),N('seated'===D.status&&D.table?`${I} finished. ${(0,g.tableWords)(D.table).replace(/^t/,'T')} needs clearing.`:`${I} finished.`),z()):'noshow'===t.id?(await y.repo.bookings.setStatus(D.id,'noshow'),N(`${I} marked as a no-show.`),z()):void 0,ie=F?(0,g.freeTablesNow)(P,D.partySize,!0).slice(0,12):[];if(O)return(0,w.jsx)($.TablePicker,{rid:e,booking:D,name:I,turnBase:T,onClose:z,onSaved:N,onPickOnPlan:_?e=>{z(),_(D,e)}:void 0});if(q)return(0,w.jsx)(f.CancelWalkInConfirm,{rid:e,b:D,onClose:z,onDone:N});if(K)return(0,w.jsx)(x.CancelBookingConfirm,{rid:e,b:D,name:I,onClose:z,onDone:N});const le=[...Z];return(0,w.jsxs)(b.Sheet,{visible:!0,onClose:z,title:`${D.time} \xb7 ${I}`,maxWidth:560,testID:"guest-actions",children:[(0,w.jsx)(a.BookingNotSavedLine,{b:D}),(0,w.jsx)(c.default,{accessible:!0,accessibilityLabel:V.a11y,testID:"guest-actions-summary",children:(0,w.jsxs)(b.T,{size:18,children:[V.people,V.deposit?(0,w.jsxs)(b.T,{size:18,weight:"semibold",colour:V.depositWarn?C.colours.amber:C.colours.goldLight,children:[" \xb7 ",V.deposit]}):null," \xb7 ",Y]})}),(0,w.jsx)(t.ShowNumberButton,{b:D}),(0,w.jsxs)(c.default,{style:{gap:10},children:[le.map(e=>(0,w.jsxs)(o.default.Fragment,{children:[(0,w.jsx)(b.Button,{kind:B(e),label:e.label,accessibilityLabel:e.a11y,accessibilityHint:'details'===e.id?void 0:G.hint,disabled:'details'!==e.id&&!G.ok,testID:`guest-act-${e.id}`,onPress:()=>ae(e),style:v}),'pick'===e.id&&e.note&&'No table yet'!==e.note?(0,w.jsxs)(b.Muted,{children:[e.note,"."]}):null,'pick'===e.id&&F?(0,w.jsxs)(c.default,{style:{gap:8},testID:"guest-pick-tables",accessibilityLabel:"Free tables",children:[0===ie.length?(0,w.jsx)(b.Muted,{children:"No free tables right now."}):null,R?(0,w.jsxs)(c.default,{testID:"guest-pick-overcap",accessible:!0,accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:R.ask,style:{gap:8,padding:12,borderRadius:12,borderWidth:1.5,borderColor:C.colours.amber,backgroundColor:C.colours.amberBg},children:[(0,w.jsx)(b.T,{size:17,weight:"semibold",center:!0,colour:"#FFE2A8",children:R.ask}),(0,w.jsx)(b.Button,{label:"Use it anyway",testID:"guest-pick-overcap-yes",disabled:!G.ok,accessibilityHint:G.hint,onPress:()=>{const e=R.table;E(null),se(e)},style:v}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Pick another table",testID:"guest-pick-overcap-no",onPress:()=>E(null),style:v})]}):ie.map(e=>(0,w.jsx)(b.Button,{kind:"secondary",label:`${(0,s.tableNumbers)(e.table)} \xb7 ${e.seats} seats`,sub:e.seats{const t=(0,h.overCapacityAsk)([e.table],e.seats,D.partySize);t?E({table:e.table,ask:t}):se(e.table)},style:v},e.table))]}):null]},e.id)),ee.map(t=>(0,w.jsx)(b.Button,{kind:"secondary",label:t.label,accessibilityLabel:t.a11y,accessibilityHint:G.hint,disabled:!G.ok,testID:`guest-act-${t.id}`,style:v,onPress:async()=>{if(G.ok)return'assign'===t.id?U(!0):void((0,a.guardBookingChange)(N,{b:D,tables:[]})&&(z(),await(0,a.saveTablesReported)(e,D,[],I,0,N)))}},t.id)),!H&&(0,f.canCancelWalkIn)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel walk-in",accessibilityLabel:`Cancel walk-in ${D.ref}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelwalkin",onPress:()=>J(!0),style:v}):null,(0,j.canCancelBooking)(D)?(0,w.jsx)(b.Button,{kind:"secondary",label:"Cancel booking",accessibilityLabel:`Cancel booking for ${I}, ${D.time}, ${D.partySize} Covers`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-cancelbooking",onPress:()=>Q(!0),style:v}):null,!A||D.walkIn||['cancelled','noshow'].includes(D.status)||H&&!(D.date>=(0,p.ymd)(L))?null:(0,w.jsx)(b.Button,{kind:"secondary",label:"Edit booking",accessibilityLabel:`Edit booking, ${I}, ${D.time}. Date, time, covers, table, anything.`,accessibilityHint:G.hint,disabled:!G.ok,testID:"guest-act-edit",onPress:()=>{z(),A(D)},style:v}),(0,w.jsx)(b.Button,{kind:"ghost",label:te.label,accessibilityLabel:te.a11y,testID:"guest-act-details",onPress:()=>ae(te),style:v})]}),(0,w.jsx)(b.Button,{kind:"secondary",label:"Close",accessibilityLabel:"Close guest actions",testID:"guest-actions-close",onPress:z,style:v})]})};var t=r(d[0]),s=r(d[1]),a=r(d[2]),l=r(d[3]),n=r(d[4]),o=e(n),c=e(r(d[5])),b=r(d[6]),u=r(d[7]),y=r(d[8]),g=r(d[9]),k=r(d[10]),h=r(d[11]),p=r(d[12]),$=r(d[13]),f=r(d[14]),x=r(d[15]),j=r(d[16]),C=r(d[17]),S=r(d[18]),w=r(d[19]);const v={minHeight:64},B=e=>'seat'===e.id||'pick'===e.id?'primary':'finished'===e.id?'success':'details'===e.id?'ghost':'secondary'},1377,[1378,860,1123,1029,34,102,794,1126,874,1380,1374,1124,858,1121,1140,1141,1142,821,1343,25]); +__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.ShowNumberButton=function({b:e}){const y=(0,u.useSession)(e=>e.meId),w=(0,c.useOwner)(e=>e.staff.find(e=>e.id===y&&e.active)),[I,C]=(0,t.useState)(!1),[j,D]=(0,t.useState)(h.SHOW_NUMBER_SECS);if((0,t.useEffect)(()=>{if(!I)return;D(h.SHOW_NUMBER_SECS);const e=Date.now(),t=setInterval(()=>{const t=h.SHOW_NUMBER_SECS-Math.floor((Date.now()-e)/1e3);t<=0?C(!1):D(t)},1e3);return()=>clearInterval(t)},[I]),!(0,h.canShowNumber)(e,!y||(0,b.canChangeBookings)(w)))return null;const E=f.IS_CAR?'car':'display'===f.APP_VARIANT?'Display':'Managers app';if(!I)return(0,_.jsx)(p.Button,{kind:"secondary",label:"Show number",testID:"show-number",accessibilityLabel:`Show phone number for ${e.name}`,onPress:()=>{C(!0);const t=e.editLog??[];l.repo.bookings.update(e.id,{editLog:[...t,(0,h.revealEntry)(w?.name?.replace(' (example)','')??'',E,(new Date).toISOString())].slice(-50)}).catch(()=>{})},style:{minHeight:64}});const H=String(e.phone);return(0,_.jsxs)(s.default,{testID:"shown-number",style:{gap:8,padding:14,borderRadius:14,borderWidth:2,borderColor:S.colours.gold,backgroundColor:'#15130F'},children:[(0,_.jsx)(o.default,{accessibilityRole:"link",accessibilityLabel:`Call ${e.name} on ${H}`,testID:"call-number",onPress:()=>{n.default.openURL((0,h.telHrefOf)(H)).catch(()=>{})},style:{minHeight:56,justifyContent:'center'},children:(0,_.jsxs)(p.T,{size:28,weight:"bold",colour:S.colours.goldLight,children:["\ud83d\udcde ",H]})}),(0,_.jsxs)(p.T,{size:14,colour:S.colours.muted,children:["Tap the number to call. Hides in ",j,"s \xb7 saved in the booking history"]}),(0,_.jsx)(p.Button,{small:!0,kind:"ghost",label:"Hide number",testID:"hide-number",onPress:()=>C(!1)})]})};var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),s=e(r(d[3])),l=r(d[4]),u=r(d[5]),c=r(d[6]),b=r(d[7]),h=r(d[8]),f=r(d[9]),S=r(d[10]),p=r(d[11]),_=r(d[12])},1378,[34,379,402,102,874,1004,891,1027,1379,872,821,794,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"SHOW_NUMBER_SECS",{enumerable:!0,get:function(){return t}}),e.canShowNumber=function(t,n){return n&&!t.walkIn&&!!(t.phone??'').replace(/[^\d+]/g,'')},Object.defineProperty(e,"telHrefOf",{enumerable:!0,get:function(){return n}}),e.revealEntry=function(t,n,u){const c=(t||n).slice(0,80);return{at:u,by:c,app:n,fields:['phone'],text:`Phone number shown on the ${n} by ${c} ${o(u)}`}};const t=30;const n=t=>`tel:${t.replace(/[^\d+]/g,'')}`,o=t=>{const n=new Date(t);return`${String(n.getHours()).padStart(2,'0')}:${String(n.getMinutes()).padStart(2,'0')}`}},1379,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"dueOnTable",{enumerable:!0,get:function(){return a.dueOnTable}}),Object.defineProperty(e,"tableWords",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"timeHasCome",{enumerable:!0,get:function(){return u}}),e.freeTablesNow=function(t,a,s=!1){const l=Object.entries(t).filter(([,t])=>'free'===t.status||'soon'===t.status),n=l.filter(([,t])=>t.table.maxSeats>=a),o=t=>t.map(([t,a])=>({table:t,seats:a.table.maxSeats})).sort((t,a)=>t.seats-a.seats||t.table.localeCompare(a.table,void 0,{numeric:!0}));return s?[...o(n),...o(l.filter(([,t])=>t.table.maxSeatsc[t]&&(s.includes(c[t].status)||'dirty'===c[t].status||'blocked'===c[t].status));if(f.length&&f.every(t=>c[t])&&!t.length)$.push({id:'seat',label:`Seat at ${o(a.table).replace(/^t/,'T')}`,a11y:`Seat ${l}, ${b(a.partySize)}, at ${o(a.table)}`,table:a.table});else if(u(a,h)){const s=f.length?t.length?`${o(t.join('+')).replace(/^t/,'T')} ${t.length>1?'are':'is'} ${'dirty'===c[t[0]].status?'waiting to be cleared':'blocked'===c[t[0]].status?'blocked':'in use'}`:`${o(a.table).replace(/^t/,'T')} is not on the table plan`:'No table yet';$.push({id:'pick',label:'Pick a table',a11y:`Pick a table for ${l}, ${b(a.partySize)}. ${s}.`,note:s})}u(a,h)&&$.push({id:'finished',label:'Finished',a11y:`Finished, ${l}, ${a.time} booking, without seating at a table`}),n(h,a)<=0&&$.push({id:'noshow',label:'No-show',a11y:`No-show, ${l}, ${a.time} booking`})}return $.push({id:'details',label:'Guest details',a11y:`Guest details, ${l}`}),$};var t=r(d[0]),a=r(d[1]);const s=['seated','mains','dessert','bill'],l=t=>new Date(`${t.date}T${t.time}:00`),n=(t,a)=>(l(a).getTime()-t.getTime())/6e4,o=a=>{const s=(0,t.tablesOf)(a);return s.length>1?`tables ${l=s,l.length<=1?l.join(''):`${l.slice(0,-1).join(', ')} and ${l[l.length-1]}`}`:`table ${s[0]??''}`.trim();var l},b=t=>`${t} ${1===t?'person':'people'}`,u=(t,a)=>n(a,t)<=45},1380,[1029,1105]); +__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,"Card",{enumerable:!0,get:function(){return I}}),_e.ArrivalsStrip=function({todays:e,now:t,privacy:s}){const l=e.filter(e=>'confirmed'===e.status).map(e=>({b:e,m:(0,u.minsBetween)(t,new Date(`${e.date}T${e.time}:00`))})).filter(e=>e.m>=-20&&e.m<=60).sort((e,t)=>e.m-t.m);return(0,B.jsxs)(x.default,{testID:"arrivals-strip",style:{flexDirection:'row',alignItems:'center',gap:8,minHeight:40},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",colour:$.colours.gold,children:"NEXT HOUR"}),(0,B.jsxs)(m.default,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:{gap:6},children:[0===l.length?(0,B.jsx)(f.Muted,{children:"No arrivals due in the next hour."}):null,l.map(({b:e,m:t})=>(0,B.jsxs)(x.default,{style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:10,paddingVertical:5,borderRadius:16,backgroundColor:t<0?$.colours.amberBg:'#12263D',borderWidth:1,borderColor:t<0?$.colours.amber:'#3C78B5'},children:[(0,B.jsx)(f.T,{size:13,weight:"semibold",children:e.time}),(0,B.jsxs)(f.T,{size:13,children:[(0,y.privName)(e,s)," \xb7 ",e.partySize]}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,accessibilityLabel:e.table?(0,i.tableNumbersA11y)(e.table):'No table',children:e.table?`${(0,i.tableNumbers)(e.table)}`:'no table'}),(0,B.jsx)(f.T,{size:12,colour:t<0?$.colours.amber:$.colours.blue,children:t<0?-t+"m late":0===t?'now':`in ${t}m`}),e.allergies.length?(0,B.jsx)(f.T,{size:12,children:"\u26a0"}):null,e.occasion?(0,B.jsx)(f.T,{size:12,children:S.OCCASION_ICON[e.occasion]}):null]},e.id))]})]})},_e.Legend=function(){return(0,B.jsxs)(f.Row,{wrap:!0,gap:10,style:{paddingVertical:2},children:[['free','soon','seated','dirty'].map(e=>(0,B.jsxs)(f.Row,{gap:4,children:[(0,B.jsx)(x.default,{style:{width:12,height:12,borderRadius:4,backgroundColor:S.STATUS[e].colour}}),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:S.STATUS[e].label})]},e)),(0,B.jsx)(f.T,{size:12,colour:$.colours.muted,children:"\u26a0 allergy \xb7 \u2605 VIP \xb7 \u2665 regular \xb7 \ud83c\udf82 birthday \xb7 \ud83d\udc9d anniversary"})]})},_e.DetailsPanel=function({title:e,children:t,onClose:s}){const[l,a]=(0,c.useState)(20);return(0,c.useEffect)(()=>{const e=Date.now(),t=()=>a(20-Math.floor((Date.now()-e)/1e3)),s=setInterval(t,1e3),l=setTimeout(t,2e4);return()=>{clearInterval(s),clearTimeout(l)}},[]),(0,c.useEffect)(()=>{l<=0&&s()},[l]),(0,B.jsxs)(f.Sheet,{visible:!0,onClose:s,title:e,maxWidth:560,testID:"private-details",children:[(0,B.jsx)(f.Badge,{kind:"amber",label:`Private \xb7 closes in ${Math.max(0,l)}s`}),t,(0,B.jsx)(f.Button,{kind:"secondary",label:"Close now",onPress:s})]})},Object.defineProperty(_e,"bookingDetails",{enumerable:!0,get:function(){return D}}),_e.TableSheet=function({rid:e,name:t,view:s,plan:o,todays:b,now:m,privacy:k,turnBase:T,onClose:I,onWalkIn:D,onMove:z,onDetails:M}){const N=s[t],P=w.useFloor.getState(),[R,L]=(0,c.useState)(!1),[A,W]=(0,c.useState)(N?.note??''),[O,H]=(0,c.useState)(!1),F=(0,C.useBookingWrite)();if(!N)return null;const E=N.booking,_=['seated','mains','dessert','bill'].includes(N.status),G=b.filter(e=>'confirmed'===e.status).sort((e,t)=>Math.abs((0,u.minsBetween)(m,(0,S.startOf)(e)))-Math.abs((0,u.minsBetween)(m,(0,S.startOf)(t)))),U=e=>e.partySize<=N.table.maxSeats,V=N.next??N.due,Y=(0,S.turnFor)(N.covers||N.table.maxSeats,T);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:I,title:`${(0,i.tableNumbers)(t)} \xb7 ${S.STATUS[N.status].label}`,maxWidth:640,testID:"table-sheet",children:['dirty'===N.status?(0,B.jsx)(f.Button,{kind:"success",label:"Mark cleared \u2014 table free",accessibilityLabel:`Mark table ${t} cleared, table free`,onPress:()=>{w.useFloor.getState().setLive(e,t,{dirty:!1,stage:void 0}),I()},testID:"mark-clean",style:{minHeight:64}}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Badge,{kind:"neutral",label:`${N.table.minSeats}\u2013${N.table.maxSeats} seats`}),E?(0,B.jsx)(f.Badge,{kind:"gold",label:`${(0,y.privName)(E,k)} \xb7 ${E.partySize} \xb7 ${N.seatedMins}m`}):null,E?(0,B.jsx)(f.Badge,{kind:N.seatedMins>(0,S.durOf)(E,T)?'red':'neutral',label:`Turn about ${(0,S.durOf)(E,T)} min \xb7 free about ${(0,u.hm)((0,S.endOf)(E,T))} (est.)`}):(0,B.jsx)(f.Badge,{kind:"neutral",label:`Turn estimate for ${N.table.maxSeats}: about ${Y} min`}),N.next?(0,B.jsx)(f.Badge,{kind:"blue",label:`Next: ${N.next.time} ${(0,y.privName)(N.next,k)} (${N.next.partySize})`}):null,N.allergy?(0,B.jsx)(f.Badge,{kind:"red",label:"\u26a0 Allergy \u2014 see details"}):null,E??V?(0,B.jsx)(v.DepositChip,{b:E??V,money:!0,testID:"table-sheet-deposit"}):null]}),E??V?(0,B.jsx)(r.BookingTableButton,{rid:e,booking:E??V,turnBase:T,testID:"table-sheet-table-btn"}):null,E&&E.walkIn?(0,B.jsx)(n.CancelWalkInButton,{rid:e,b:E,big:!0}):null,E&&E.walkIn?(0,B.jsx)(n.ReinstateWalkInButton,{rid:e,b:E,today:(0,u.ymd)(new Date)}):null,!_&&'blocked'!==N.status&&V?(0,B.jsx)(f.Button,{label:`Seat ${(0,y.privName)(V,k)}`,accessibilityLabel:`Seat ${(0,y.privName)(V,k)}, ${V.time} booking, ${V.partySize} ${1===V.partySize?'person':'people'}, at table ${t}`,accessibilityHint:F.hint,disabled:!F.ok,testID:"seat-next-here",style:{minHeight:64},onPress:async()=>{if(!F.ok||!(0,l.guardBookingChange)(void 0,{b:V,tables:[t]}))return;const s=V;await j.repo.bookings.update(s.id,{table:s.table&&(0,w.tablesOf)(s.table).includes(t)?s.table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I()}}):null,!_&&'blocked'!==N.status&&V&&(0,S.startOf)(V)<=m?(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{kind:"success",label:"Finished",accessibilityLabel:`Finished, ${(0,y.privName)(V,k)}, ${V.time} booking, without seating`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-finished",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'finished'),I())}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"No-show",accessibilityLabel:`No-show, ${(0,y.privName)(V,k)}, ${V.time} booking`,accessibilityHint:F.hint,disabled:!F.ok,testID:"due-noshow",style:{flex:1,minHeight:56},onPress:async()=>{F.ok&&(await j.repo.bookings.setStatus(V.id,'noshow'),I())}})]}):null,_||'blocked'===N.status?null:(0,B.jsxs)(f.Row,{gap:8,children:[(0,B.jsx)(f.Button,{label:"Seat walk-in here",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&('dirty'===N.status&&w.useFloor.getState().setLive(e,t,{dirty:!1}),I(),D(t))},testID:"seat-walkin-here",style:{flex:1,minHeight:56}}),(0,B.jsx)(f.Button,{kind:"secondary",label:"Seat a booking",accessibilityHint:F.hint,disabled:!F.ok,onPress:()=>{F.ok&&H(!O)},testID:"seat-booking-here",style:{flex:1,minHeight:56}})]}),O?(0,B.jsxs)(x.default,{style:{gap:6},children:[0===G.length?(0,B.jsx)(f.Muted,{children:"No bookings left to seat today."}):null,G.slice(0,8).map(s=>(0,B.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Seat ${(0,y.privName)(s,k)} ${s.time}`,onPress:async()=>{(0,l.guardBookingChange)(void 0,{b:s,tables:[t]})&&(await j.repo.bookings.update(s.id,{table:t}),await j.repo.bookings.setStatus(s.id,'seated'),(0,p.resetTableLive)(e,t),I())},style:{padding:10,borderRadius:10,borderWidth:1,borderColor:U(s)?$.colours.border:$.colours.amber,backgroundColor:$.colours.surface2},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:[s.time," \xb7 ",(0,y.privName)(s,k)," \xb7 ",s.partySize,s.table?` \xb7 booked ${(0,i.tableNumbers)(s.table)}`:'',s.allergies.length?' \xb7 \u26a0':'']}),U(s)?null:(0,B.jsxs)(f.T,{size:12,colour:$.colours.amber,children:["Bigger than this table (",N.table.maxSeats," max)"]})]},s.id))]}):null,_?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(f.T,{size:14,colour:$.colours.muted,children:"Course / status"}),(0,B.jsx)(f.Row,{wrap:!0,gap:6,children:S.STAGES.map(s=>(0,B.jsx)(f.Chip,{label:S.STAGE_LABEL[s],selected:N.status===s,onPress:()=>P.setLive(e,t,{stage:s})},s))}),(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[E?(0,B.jsx)(f.Button,{kind:"secondary",label:"Move party\u2026",onPress:()=>{I(),z(t)},testID:"move-party"}):null,(0,B.jsx)(f.Button,{kind:"success",label:"Clear table",testID:"clear-table",onPress:async()=>{E&&await j.repo.bookings.setStatus(E.id,'finished'),P.setLive(e,t,{stage:void 0,dirty:!0}),I()}})]})]}):null,(0,B.jsxs)(f.Row,{wrap:!0,gap:8,children:[(0,B.jsx)(f.Button,{kind:"secondary",label:'blocked'===N.status?'Unblock table':'Block table',onPress:()=>{P.setLive(e,t,{blocked:'blocked'!==N.status}),I()},testID:"block-table"}),(0,B.jsx)(f.Button,{kind:"ghost",label:N.note?'Edit note':'Note',onPress:()=>L(!R)}),E||V?(0,B.jsx)(f.Button,{kind:"ghost",label:"Guest details",onPress:()=>{I(),M(E??V)},testID:"guest-details"}):null]}),R?(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Table note",value:A,onChangeText:W,placeholder:"e.g. wobbly leg, high chair here",placeholderTextColor:"#7D776C",style:[f.styles.input,{flex:1}]}),(0,B.jsx)(f.Button,{small:!0,label:"Save",onPress:()=>{P.setLive(e,t,{note:A.trim()||void 0}),L(!1)}})]}):null,k?(0,B.jsx)(f.Muted,{children:"Privacy mode: names as initials; tap Guest details for notes and allergies (closes after 20 s)."}):null,o.joins.some(e=>e.tables.includes(t))?(0,B.jsxs)(f.Muted,{children:["Joins with ",o.joins.find(e=>e.tables.includes(t)).tables.filter(e=>e!==t).join(', ')," for bigger parties (book as ",o.joins.find(e=>e.tables.includes(t)).tables.join('+'),")."]}):null]})},_e.WaitlistPanel=function({rid:e,r:t,plan:s,view:l,todays:i,waiting:o,now:r,privacy:n,busy:b,onToast:m}){const[k,v]=(0,c.useState)(''),[C,D]=(0,c.useState)(2),z=(0,w.useFloor)(e=>e.smsLog);return(0,B.jsxs)(I,{title:`Waitlist (${o.length})`,right:(0,B.jsxs)(f.Muted,{children:["new party about ",(0,T.estimateWait)(o.length+1,t.settings.turnMins,b)," min"]}),testID:"waitlist-panel",children:[0===o.length?(0,B.jsx)(f.Muted,{children:"Nobody waiting."}):null,o.map((a,o)=>{const c=(0,S.suggestTable)(s,i,l,a.partySize,r,(0,S.turnFor)(a.partySize,t.settings.turnMins)),h=(0,T.estimateWait)(o+1,t.settings.turnMins,b),k=Math.max(0,(0,u.minsBetween)(new Date(a.joinedAt),r)),v=z.find(t=>t.rid===e&&t.text.includes(`#${a.number} `));return(0,B.jsxs)(x.default,{style:{backgroundColor:$.colours.surface2,borderRadius:10,padding:8,gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsxs)(f.T,{weight:"semibold",children:["#",a.number," ",(0,y.pv)(a.name,n)," \xb7 ",a.partySize]}),(0,B.jsxs)(f.T,{size:12,colour:k>h?$.colours.amber:$.colours.muted,children:["waited ",k,"m \xb7 quoted about ",h,"m"]})]}),c?(0,B.jsxs)(f.T,{size:12,colour:c.clashes?$.colours.amber:$.colours.ok,children:["Best table: ",c.table," (",c.why,")"]}):(0,B.jsx)(f.T,{size:12,colour:$.colours.amber,children:"No table big enough \u2014 join tables in the plan"}),(0,B.jsxs)(f.Row,{wrap:!0,gap:6,children:[(0,B.jsx)(f.Button,{small:!0,label:v||'notified'===a.status?'Mark as told again':'Mark as told: table ready',testID:`sms-${a.number}`,onPress:()=>{w.useFloor.getState().logSms(e,r.toISOString(),`#${a.number} ${a.partySize}: Your table at ${t.name} is ready.`),j.repo.waitlist.setStatus(a.id,'notified'),m(`DEMO \u2014 no text sent. Would say: "Your table at ${t.name} is ready."`)}}),c?(0,B.jsx)(f.Button,{small:!0,kind:"success",label:`Seat at ${c.table}`,onPress:async()=>{await j.repo.waitlist.setStatus(a.id,'seated'),await j.repo.bookings.seatWalkIn(e,a.partySize,c.table,`From waitlist #${a.number}`),(0,p.resetTableLive)(e,c.table),m(`Waitlist #${a.number} seated at ${c.table}`)}}):null,(0,B.jsx)(f.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>j.repo.waitlist.setStatus(a.id,'removed')})]}),'notified'===a.status?(0,B.jsx)(f.Badge,{kind:"ok",label:`Told table ready${v?` ${(0,u.hm)(new Date(v.at))}`:''} `}):null]},a.id)}),(0,B.jsxs)(f.Row,{gap:6,children:[(0,B.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:k,onChangeText:v,style:[f.styles.input,{flex:1,minWidth:0,width:40,paddingVertical:6}]}),(0,B.jsx)(h.default,{accessibilityLabel:"Waitlist party size",onPress:()=>D(e=>e>=8?1:e+1),style:{width:48,height:48,borderRadius:10,borderWidth:1,borderColor:$.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,B.jsx)(f.T,{weight:"bold",colour:$.colours.gold,children:C})}),(0,B.jsx)(f.Button,{small:!0,label:"Add",disabled:k.trim().length<2,onPress:()=>{j.repo.waitlist.join(e,k.trim(),C),v('')}})]})]})},_e.PacePanel=function({r:e,fc:t,todays:l,now:a,walkInCount:i,staffOn:r,onSummary:n}){const c=i+l.filter(e=>['seated','finished'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),b=a.getHours(),h=Math.round(t.hours.filter(e=>e.houre+t.covers,0)+(t.hours.find(e=>e.hour===b)?.covers??0)*(a.getMinutes()/60)),m=h?c/h:1,p=m>=1.1?$.colours.amber:m>=.85?$.colours.ok:$.colours.blue,y=Array.from({length:8},(e,t)=>{const s=(0,u.addMins)(a,15*(t-4)-a.getMinutes()%15),i=(0,u.addMins)(s,15),o=l.filter(e=>!['cancelled','noshow'].includes(e.status)).filter(e=>{const t=(0,S.startOf)(e);return t>=s&&te+t.partySize,0);return{from:s,covers:o,future:t>=4}}),j=Math.max(4,Math.round(e.settings.capacityPerHour/4)),w=Math.max(j,...y.map(e=>e.covers)),k=y.filter(e=>e.future&&e.covers>j),v=t.nextHour?.covers??0,T=Math.ceil(v/16);return(0,B.jsxs)(I,{title:"Pace & kitchen",right:(0,B.jsx)(f.Badge,{kind:"amber",label:"ESTIMATE"}),testID:"pace-panel",children:[(0,B.jsxs)(x.default,{testID:"pace-meter",accessibilityLabel:`Covers so far ${c} vs forecast ${h}`,style:{gap:4},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{size:14,children:"Covers so far"}),(0,B.jsxs)(f.T,{weight:"bold",colour:p,children:[c," ",(0,B.jsxs)(f.T,{size:13,colour:$.colours.muted,children:["/ about ",h," forecast"]})]})]}),(0,B.jsx)(x.default,{style:{height:10,borderRadius:5,backgroundColor:(0,s.soutersSurface)('#2A2620'),overflow:'hidden'},children:(0,B.jsx)(x.default,{style:{width:`${Math.min(100,75*m)}%`,height:10,borderRadius:5,backgroundColor:p}})}),(0,B.jsxs)(f.Muted,{children:[m>=1.1?'Ahead of forecast':m>=.85?'On pace':'Behind forecast'," \xb7 next hour about ",t.nextHour?(0,o.coversRange)(t.nextHour.coversLow,t.nextHour.coversHigh):'0 Covers']})]}),(0,B.jsx)(f.T,{size:13,colour:$.colours.muted,children:"Covers seated per 15 min (last hour \xb7 next hour)"}),(0,B.jsx)(x.default,{testID:"kitchen-pacing",style:{flexDirection:'row',alignItems:'flex-end',gap:4,height:64},children:y.map((e,t)=>(0,B.jsxs)(x.default,{style:{flex:1,alignItems:'center',gap:2},children:[(0,B.jsx)(f.T,{size:10,colour:$.colours.muted,children:e.covers||''}),(0,B.jsx)(x.default,{style:{width:'80%',height:Math.max(2,e.covers/w*40),borderRadius:3,backgroundColor:e.covers>j?$.colours.red:e.future?'#6B5A3A':$.colours.gold}}),(0,B.jsx)(f.T,{size:9,colour:4===t?$.colours.gold:$.colours.muted,children:(0,u.hm)(e.from)})]},t))}),k.map(e=>(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Kitchen: ",e.covers," Covers due ",(0,u.hm)(e.from),"\u2013",(0,u.hm)((0,u.addMins)(e.from,15))," (pace about ",j,") \u2014 stagger seating if you can."]},e.from.getTime())),T>r?(0,B.jsxs)(f.T,{size:13,colour:$.colours.amber,children:["\u26a0 Next hour about ",v," Covers with ",r," on: about ",T-r," more on the floor suggested."]}):(0,B.jsxs)(f.T,{size:13,colour:$.colours.ok,children:["Staffing looks OK for the next hour (",r," on)."]}),(0,B.jsx)(f.Button,{small:!0,kind:"secondary",label:"End-of-service summary",onPress:n,testID:"eos-open"})]})},_e.ServiceSummary=function({r:e,todays:t,orders:s,waitlistAll:l,walkInCount:a,onClose:i}){const o=t.filter(e=>['seated','finished'].includes(e.status)),r=o.reduce((e,t)=>e+t.partySize,0)+a,n=t.filter(e=>e.walkIn),c=t.filter(e=>'finished'===e.status&&e.seatedAt&&e.finishedAt).map(e=>(0,u.minsBetween)(new Date(e.seatedAt),new Date(e.finishedAt))),b=(0,w.useFloor)(t=>t.smsLog.filter(t=>t.rid===e.id).length),h=(e,t)=>(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{children:e}),(0,B.jsx)(f.T,{weight:"semibold",children:t})]},e);return(0,B.jsxs)(f.Sheet,{visible:!0,onClose:i,title:`End of service \xb7 ${e.name}`,maxWidth:560,testID:"eos-summary",children:[h('Covers served',String(r)),h('Bookings seated',`${o.filter(e=>!e.walkIn).length} of ${t.filter(e=>!e.walkIn&&'cancelled'!==e.status).length}`),h('Walk-ins',`${n.length} parties \xb7 ${n.reduce((e,t)=>e+t.partySize,0)+a} Covers`),h('No-shows',String(t.filter(e=>'noshow'===e.status).length)),h('Average table time',c.length?`${Math.round(c.reduce((e,t)=>e+t,0)/c.length)} min`:'\u2014'),h('Waitlist seated',`${l.filter(e=>'seated'===e.status).length} (${l.filter(e=>'removed'===e.status).length} left)`),h('"Table ready" texts',`${b} (texts not set up yet, none sent)`),(0,B.jsx)(f.Muted,{children:"Nothing is sent anywhere: texting guests is not set up yet."})]})},Object.defineProperty(_e,"isWeb",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"tablesOf",{enumerable:!0,get:function(){return w.tablesOf}});var t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),a=_r(d[3]),i=_r(d[4]),o=_r(d[5]),r=_r(d[6]),n=_r(d[7]),u=_r(d[8]),c=_r(d[9]),b=_r(d[10]);_r(d[11]);var h=e(_r(d[12])),m=e(_r(d[13])),x=e(_r(d[14])),f=_r(d[15]),p=_r(d[16]),y=_r(d[17]),j=_r(d[18]),w=_r(d[19]),k=_r(d[20]),v=_r(d[21]),S=_r(d[22]),T=_r(d[23]),$=_r(d[24]),C=_r(d[25]),B=_r(d[26]);const I=({title:e,right:t,children:s,testID:l})=>(0,B.jsxs)(x.default,{testID:l,style:{backgroundColor:$.colours.surface,borderRadius:14,borderWidth:1,borderColor:$.colours.border,padding:10,gap:6},children:[(0,B.jsxs)(f.Row,{style:{justifyContent:'space-between'},children:[(0,B.jsx)(f.T,{weight:"semibold",colour:$.colours.gold,children:e}),t]}),s]});const D=e=>(0,B.jsxs)(x.default,{style:{gap:6},children:[(0,B.jsxs)(f.T,{size:18,weight:"semibold",children:[e.walkIn?`Walk-in ${e.ref}`:e.name.replace(' (example)','')," \xb7 ",e.partySize]}),(0,B.jsxs)(f.Muted,{children:[e.time," \xb7 ",e.table?(0,w.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref,e.tags?.length?` \xb7 ${e.tags.join(', ')}`:'',e.occasion?` \xb7 ${e.occasion}`:'']}),(0,B.jsx)(v.DepositChip,{b:e,money:!0,big:!0,testID:`details-deposit-${e.id}`}),(0,B.jsx)(b.BookingNeeds,{b:e,big:!0}),e.notes?(0,B.jsxs)(f.T,{children:["Notes: ",e.notes]}):(0,B.jsx)(f.Muted,{children:"No notes."}),e.allergies.length?(0,B.jsx)(x.default,{style:{backgroundColor:$.colours.redBg,borderRadius:8,padding:8},children:(0,B.jsxs)(f.T,{weight:"bold",colour:"#FFE3DF",children:["ALLERGY: ",e.allergies.map(e=>`${(0,k.allergenLabel)(e.allergen)} \u2014 ${(0,k.severityLabel)(e.severity)}`).join('; ')]})}):(0,B.jsx)(f.Muted,{children:"No allergies declared."}),(0,B.jsx)(t.ShowNumberButton,{b:e},`num-${e.id}`)]});const z=!0},1381,[1378,828,1123,827,860,1161,1119,1140,858,34,1107,236,402,295,102,794,1126,1369,874,1029,861,1117,1105,1326,821,1343,25]); +__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.PrintHost=function({rid:e}){const t=(0,l.useFloor)(t=>t.settings[e]?.printing),i=(0,o.useStore)(b),d=(0,p.usePrintStatus)(m);(0,r.useEffect)(()=>{(0,p.checkDue)(e)},[e,t,i]),(0,r.useEffect)(()=>{const t=setInterval(()=>(0,p.checkDue)(e),2e4);return()=>clearInterval(t)},[e]);const c=Object.values(d);return c.length?(0,u.jsxs)(n.default,{testID:"print-fail",accessibilityRole:"summary",style:{position:'fixed',left:12,bottom:76,zIndex:9e3,maxWidth:520,gap:8},children:[c.slice(0,3).map(t=>(0,u.jsxs)(n.default,{style:{backgroundColor:h.colours.amberBg,borderColor:h.colours.amber,borderWidth:2,borderRadius:12,padding:12,gap:6},children:[(0,u.jsxs)(s.T,{weight:"semibold",colour:h.colours.amber,children:["\u26a0 Ticket didn\u2019t print: #",t.ref," \xb7 ",t.name]}),(0,u.jsxs)(s.T,{size:14,children:[t.printer,": ",t.reason,". The order is safe and still on screen",t.tries>1?` (tried ${t.tries} times)`:'',". Read it from the screen, or print it another way."]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Try again",testID:`print-retry-${t.ref}`,onPress:()=>(0,p.retryFail)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Print on this screen",onPress:()=>(0,p.printHere)(e,t)}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Done, kitchen has it",onPress:()=>(0,p.dismissFail)(e,t)})]})]},`${t.orderId}:${t.printerId}`)),c.length>3?(0,u.jsxs)(s.T,{size:13,colour:h.colours.amber,children:["+ ",c.length-3," more tickets didn\u2019t print. Check the printer."]}):null]}):null},_e.ReprintButton=function({rid:e,o:t}){const[i,o]=(0,r.useState)('');return(0,u.jsxs)(n.default,{style:{gap:4},children:[(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Reprint ticket",testID:`reprint-${t.ref}`,onPress:()=>{o('Printing\u2026'),(0,p.reprint)(e,t).then(e=>o(e.ok?`Sent to ${e.where}.`:`Didn\u2019t print: ${e.error??'no answer'}.`))}}),i?(0,u.jsx)(s.Muted,{size:12,children:i}):null,t.printed?(0,u.jsxs)(s.Muted,{size:12,children:["Ticket printed ",new Date(t.printed.at).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})," on ",t.printed.printer]}):null]})},_e.PrintersSettings=function({rid:e,go:p}){const b=(0,l.useFloor)(t=>t.settings[e]?.printing),m=(0,d.normPrint)(b),k=t=>{const r=l.useFloor.getState().settings[e]??l.DEFAULT_SETTINGS;l.useFloor.getState().setSettings(e,{...r,printing:t})},y=(e,t)=>k({...m,printers:m.printers.map(r=>r.id===e?(0,d.normPrinter)({...r,...t}):r)}),P=(0,c.thisDevice)(),[j,T]=(0,r.useState)({}),[S,v]=(0,r.useState)({busy:!1,text:'',found:[]}),[I,C]=(0,r.useState)([]),D=e=>k({...m,printers:[...m.printers,(0,d.normPrinter)({id:f(),name:m.printers.length?`Printer ${m.printers.length+1}`:'Kitchen printer',from:'owner'===P||'display'===P?['tablet','mac',P]:[P,...['tablet','mac'].filter(e=>e!==P)],...e})]}),B=async t=>{T(e=>({...e,[t.id]:'Printing a test ticket\u2026'}));const r=await(0,c.sendTicket)(t,(0,c.testTicket)(o.useStore.getState().restaurants.find(t=>t.id===e)?.name??'',t));T(e=>({...e,[t.id]:r.ok?'Test ticket sent. Check the printer: the \xa3 sign and the allergy lines should be clear.':`Didn\u2019t print: ${r.error}.`}))};return(0,u.jsxs)(n.default,{style:{gap:10},testID:"adv-printers-body",children:[(0,u.jsx)(s.Toggle,{testID:"print-auto",label:"Print a kitchen ticket for every takeaway order",value:m.auto,onChange:e=>k({...m,auto:e,since:e?(new Date).toISOString():m.since}),a11y:"Print a kitchen ticket for every takeaway order"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Chip,{testID:"print-when-arrival",label:"As soon as it comes in",selected:'arrival'===m.when,onPress:()=>k({...m,when:'arrival'})}),(0,u.jsx)(s.Chip,{testID:"print-when-accept",label:"When it\u2019s accepted",selected:'accept'===m.when,onPress:()=>k({...m,when:'accept'})})]}),(0,u.jsx)(s.Muted,{size:13,children:"The ticket shows the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and whether it\u2019s paid. If a printer doesn\u2019t answer, an amber warning shows on screen and the order stays there. Nothing is lost."}),(0,u.jsxs)(s.Muted,{size:13,children:["You\u2019re on: ",d.DEVICE_LABEL[P],"."]}),m.printers.map(e=>{const r=(0,d.canDrive)(P,e);return(0,u.jsxs)(n.default,{testID:`printer-${e.id}`,style:{borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12,gap:8},children:[(0,u.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer name",value:e.name,onChangeText:t=>y(e.id,{name:t}),style:[w,{flex:1}]}),(0,u.jsx)(s.Toggle,{label:"On",value:e.on,onChange:t=>y(e.id,{on:t}),a11y:`${e.name} on`})]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Type"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:['epson','star','escpos','bluetooth','browser'].map(t=>(0,u.jsx)(s.Chip,{label:'epson'===t?'Epson':'star'===t?'Star':'escpos'===t?'Other (port 9100)':'bluetooth'===t?'Bluetooth':'Print dialog',selected:e.kind===t,onPress:()=>y(e.id,{kind:t})},t))}),(0,u.jsx)(s.Muted,{size:12,children:d.PRINTER_KIND_LABEL[e.kind]}),'epson'===e.kind||'star'===e.kind||'escpos'===e.kind?(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(t.TextInput,{accessibilityLabel:"Printer IP address",testID:`printer-ip-${e.id}`,value:e.host??'',onChangeText:t=>y(e.id,{host:t.trim()}),placeholder:"IP address, e.g. 192.168.1.50",placeholderTextColor:h.colours.muted,style:[w,{minWidth:220,borderColor:e.host&&!(0,d.hostOk)(e.host)?h.colours.amber:h.colours.hairline}]}),'escpos'===e.kind?(0,u.jsx)(t.TextInput,{accessibilityLabel:"Port",value:String(e.port??9100),onChangeText:t=>y(e.id,{port:Number(t.replace(/\D/g,''))||9100}),style:[w,{width:90}]}):(0,u.jsx)(s.Toggle,{label:"HTTPS",value:!!e.https,onChange:t=>y(e.id,{https:t}),a11y:"Use HTTPS"})]}):null,'bluetooth'===e.kind?(0,u.jsxs)(n.default,{style:{gap:6},children:[(0,u.jsx)(s.Muted,{size:13,children:e.btAddress?`Printer: ${e.btName??e.btAddress}`:'Pair the printer in the tablet\u2019s Bluetooth settings first, then choose it here.'}),(0,u.jsx)(s.Button,{small:!0,kind:"secondary",label:"Choose a paired printer",onPress:()=>{(0,c.pairedBluetooth)().then(t=>{C(t.devices),T(r=>({...r,[e.id]:t.ok?t.devices.length?'Tap your printer below.':'No paired Bluetooth devices. Pair the printer in Android Settings \u203a Bluetooth first.':t.error??''}))})}}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:I.map(t=>(0,u.jsx)(s.Chip,{label:t.name||t.address,selected:e.btAddress===t.address,onPress:()=>y(e.id,{btAddress:t.address,btName:t.name})},t.address))})]}):null,(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Prints"}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Chip,{label:"Kitchen ticket",selected:'kitchen'===e.role,onPress:()=>y(e.id,{role:'kitchen'})}),(0,u.jsx)(s.Chip,{label:"Front-of-house ticket (with prices)",selected:'foh'===e.role,onPress:()=>y(e.id,{role:'foh'})}),(0,u.jsx)(s.Chip,{label:"Both",selected:'both'===e.role,onPress:()=>y(e.id,{role:'both'})})]}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.T,{size:14,children:"Kitchen copies"}),[1,2,3].map(t=>(0,u.jsx)(s.Chip,{label:String(t),selected:e.copies===t,onPress:()=>y(e.id,{copies:t})},t)),(0,u.jsx)(s.T,{size:14,children:" Paper"}),[48,42,32].map(t=>(0,u.jsx)(s.Chip,{label:32===t?'58 mm':42===t?'80 mm (42)':'80 mm',selected:e.cols===t,onPress:()=>y(e.id,{cols:t})},t))]}),(0,u.jsx)(s.T,{size:14,weight:"semibold",children:"Which devices print to it (first one first)"}),(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:x.map(t=>{const r=e.from.indexOf(t);return(0,u.jsx)(s.Chip,{label:`${r>=0?`${r+1}. `:''}${'tablet'===t?'Tablet app':'mac'===t?'Mac app':'display'===t?'Display (browser)':'Managers (browser)'}`,selected:r>=0,onPress:()=>y(e.id,{from:r>=0?e.from.filter(e=>e!==t):[...e.from,t]})},t)})}),(0,u.jsx)(s.Muted,{size:12,children:"If the first device is off, the next one prints after a few seconds. A ticket is printed once, not by every device."}),r.ok?null:(0,u.jsx)(s.Banner,{kind:"warn",title:"This device can\u2019t reach this printer",children:r.why}),(0,u.jsxs)(s.Row,{wrap:!0,gap:6,children:[(0,u.jsx)(s.Button,{small:!0,label:"Test print",testID:`printer-test-${e.id}`,disabled:!r.ok,onPress:()=>{B(e)}}),(0,u.jsx)(s.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>k({...m,printers:m.printers.filter(t=>t.id!==e.id)})})]}),j[e.id]?(0,u.jsx)(s.T,{size:13,colour:/Didn/.test(j[e.id])?h.colours.amber:h.colours.goldLight,children:j[e.id]}):null]},e.id)}),(0,u.jsxs)(s.Row,{wrap:!0,gap:8,children:[(0,u.jsx)(s.Button,{testID:"printer-add",label:"Add a printer by IP address",onPress:()=>D({kind:'epson'})}),(0,u.jsx)(s.Button,{kind:"secondary",testID:"printer-scan",label:S.busy?'Looking\u2026':'Find printers on this Wi-Fi',disabled:S.busy,onPress:()=>{v({busy:!0,text:'Looking for printers on this Wi-Fi (up to 30 seconds)\u2026',found:[]}),(0,c.scanNetwork)().then(e=>v({busy:!1,text:e.ok?e.found.length?`Found ${e.found.length}. Tap one to add it.`:'No printers found. Check the printer is on and on the same Wi-Fi, or type its IP address.':e.error??'',found:e.found}))}}),(0,u.jsx)(s.Button,{kind:"secondary",label:"Use this device\u2019s Print dialog",onPress:()=>D({kind:'browser',name:'Print dialog',from:[P]})})]}),S.text?(0,u.jsx)(s.Muted,{size:13,children:S.text}):null,(0,u.jsx)(s.Row,{wrap:!0,gap:6,children:S.found.map(e=>(0,u.jsx)(s.Chip,{label:`${e.name??('epson'===e.kind?'Epson':'star'===e.kind?'Star':'Printer')} \xb7 ${e.host}`,onPress:()=>D({kind:'epson'===e.kind?'epson':'star'===e.kind?'star':'escpos',host:e.host,port:e.port,name:e.name??'Kitchen printer'})},`${e.host}:${e.port}`))}),p?(0,u.jsx)(i.default,{accessibilityRole:"link",onPress:()=>p('more','printerhelp'),children:(0,u.jsx)(s.T,{size:14,colour:h.colours.gold,children:"How to connect a Wi-Fi or Bluetooth printer \u203a"})}):null,(0,u.jsx)(s.Muted,{size:13,children:"Tip: print a test ticket after any change, and keep a spare roll by the printer."})]})},_e.PrinterHelpPage=function(){return(0,u.jsxs)(n.default,{style:{gap:12},testID:"printer-help",children:[(0,u.jsx)(s.Muted,{children:"Printing kitchen tickets for takeaway orders, in plain words."}),k.map(e=>(0,u.jsxs)(n.default,{style:{gap:6,borderWidth:1,borderColor:h.colours.hairline,borderRadius:12,padding:12},children:[(0,u.jsx)(s.T,{size:17,weight:"semibold",colour:h.colours.gold,children:e.h}),e.p.map(e=>(0,u.jsx)(s.T,{size:15,children:e},e))]},e.h)),(0,u.jsx)(s.Muted,{size:13,children:"Tip: put the printer where the kitchen sees it first, out of the way of steam and grease."})]})};var t=_r(_d[0]),r=_r(_d[1]);_r(_d[2]);var i=e(_r(_d[3])),n=e(_r(_d[4])),s=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),d=_r(_d[8]),h=_r(_d[9]),p=_r(_d[10]),c=_r(_d[11]),u=_r(_d[12]);const b=e=>e.orders,m=e=>e.fails;const w={minHeight:44,borderRadius:10,borderWidth:1,borderColor:h.colours.hairline,backgroundColor:h.colours.surface2,color:h.colours.text,paddingHorizontal:10,fontSize:15},f=()=>`pr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`,x=['tablet','mac','display','owner'];const k=[{h:'Which printers work',p:['Epson TM-m30, TM-T20 and TM-T88 with a network port or Wi-Fi (they understand Epson ePOS-Print).','Star printers with WebPRNT on the network, e.g. TSP143IV LAN or mC-Print3.','Most other receipt printers on the network that take ESC/POS on port 9100 (from the tablet app or the Mac app).','Bluetooth receipt printers that take ESC/POS, from the Display tablet app (Android) only.','Any printer your computer or tablet already prints to, using its own Print dialog (one tap per ticket).']},{h:'Wi-Fi or network printer',p:['1. Plug the printer into your router with a network cable, or join it to your Wi-Fi using the maker\u2019s app (Epson TM Utility or Star Quick Setup).','2. Find its IP address: switch the printer off, hold the Feed button and switch it on. It prints a page with the IP address (for example 192.168.1.50).','3. Ask whoever looks after your Wi-Fi to fix (reserve) that address for the printer, so it doesn\u2019t change.','4. In Settings \u203a Advanced \u203a Printers, tap Add a printer by IP address (or Find printers on this Wi-Fi in the tablet or Mac app), choose the type and type the address.','5. Tap Test print. You should see a ticket with \xa3 signs and white-on-black allergy lines.']},{h:'Bluetooth printer (tablet app)',p:['1. Switch the printer on. On the tablet open Settings \u203a Bluetooth and pair it (the PIN is often 0000 or 1234).','2. Open the CoverCharge Display app, go to Settings \u203a Advanced \u203a Printers and tap Add a printer, then choose Bluetooth.','3. Tap Choose a paired printer and pick it. Allow Nearby devices if the tablet asks.','4. Tap Test print. Keep the printer within a few metres of the tablet.']},{h:'If a ticket doesn\u2019t print',p:['An amber warning shows on screen with the order number. The order is never lost: it stays on the Display and in Orders.','Check the printer is on, has paper, the lid is shut, and it\u2019s on the same Wi-Fi. Then tap Try again.','Print on this screen opens the device\u2019s Print dialog. Done, kitchen has it clears the warning once someone has the order.','Reprint ticket on any order prints it again, marked REPRINT.']},{h:'Web browsers',p:['A web browser can\u2019t reach port 9100 printers or Bluetooth, and can only reach Epson or Star printers over HTTPS. That means switching on HTTPS on the printer and opening https:// once to accept its certificate. The Display tablet app and CoverCharge for Mac have none of these limits, so use one of them for automatic printing.']}]},1382,[827,34,236,402,102,794,874,1029,1383,821,1384,1386,25]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DEVICE_LABEL",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PRINTER_KIND_LABEL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEFAULT_PRINT",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"normPrint",{enumerable:!0,get:function(){return i}}),e.normPrinter=s,e.canDrive=function(t,n){const o='tablet'===t||'mac'===t;return'browser'===n.kind?{ok:!0}:'bluetooth'===n.kind?'tablet'===t?{ok:!0}:{ok:!1,why:'Bluetooth printers work from the Display tablet app (Android) only.'}:'escpos'===n.kind?o?{ok:!0}:{ok:!1,why:'A web browser cannot reach port 9100. Use the Display tablet app or CoverCharge for Mac.'}:o||n.https?{ok:!0}:{ok:!1,why:'A web browser can only reach Epson or Star printers over HTTPS (switch it on below and accept the printer\u2019s certificate once). The tablet app and the Mac app need no HTTPS.'}},Object.defineProperty(e,"IPV4",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"hostOk",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"printDelayMs",{enumerable:!0,get:function(){return d}}),e.dueForTicket=function(t,n,o){if(!n.auto)return[];const i=n.since?new Date(n.since).getTime():0,s=o.getTime()-216e5;return t.filter(t=>{if('takeaway'!==t.type&&('table'!==t.type||'table-qr'!==t.channel||t.held&&!t.accepted))return!1;if(['cancelled','collected','closed','served'].includes(t.status))return!1;const o=new Date(t.createdAt).getTime();return o>=i&&o>=s&&('accept'!==n.when||(!!t.accepted||'table'===t.type))})},Object.defineProperty(e,"printedOn",{enumerable:!0,get:function(){return l}});const t={tablet:'Display tablet app (Android)',mac:'CoverCharge for Mac',display:'Display in a web browser',owner:'Managers app in a web browser'},n={epson:'Epson (ePOS-Print, e.g. TM-m30, TM-T20, TM-T88)',star:'Star (WebPRNT, e.g. TSP143IV LAN, mC-Print3)',escpos:'Other receipt printer (ESC/POS on port 9100)',bluetooth:'Bluetooth receipt printer (ESC/POS)',browser:"This device's own Print (any printer it has)"},o={auto:!1,when:'arrival',printers:[]},i=t=>({...o,...t??{},printers:Array.isArray(t?.printers)?t.printers.filter(t=>t&&'string'==typeof t.id).map(s):[]});function s(t){const n=['epson','star','escpos','bluetooth','browser'].includes(t.kind)?t.kind:'escpos';return{id:String(t.id),name:(t.name||'Kitchen printer').slice(0,40),kind:n,host:t.host?.trim()||void 0,port:'escpos'===n?t.port&&t.port>0&&t.port<65536?t.port:9100:t.port,https:!!t.https,btAddress:t.btAddress,btName:t.btName,cols:32===t.cols||42===t.cols?t.cols:48,role:'foh'===t.role||'both'===t.role?t.role:'kitchen',from:Array.isArray(t.from)&&t.from.length?t.from.filter(t=>['tablet','mac','display','owner'].includes(t)):['tablet','mac'],copies:2===t.copies||3===t.copies?t.copies:1,on:!1!==t.on}}const c=/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/,p=t=>{const n=(t??'').trim();return!!n&&(/^[\d.]+$/.test(n)?c.test(n):/^[a-z0-9]([a-z0-9-]{0,62}\.)*[a-z0-9-]{1,63}$/i.test(n)&&!n.endsWith('-'))},d=(t,n)=>{const o=t.from.indexOf(n);return o<0?-1:8e3*o};const l=(t,n)=>!!t.printed&&(!t.printed.ids||t.printed.ids.includes(n))},1383,[]); +__d(function(g,_r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"usePrintStatus",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"printSettingsOf",{enumerable:!0,get:function(){return f}}),e.printOrder=y,e.reprintTargets=b,e.reprint=async function(t,r){const n=b(t);if(!n.length){const n=m(t,r,{id:'browser',name:'Print',kind:'browser',cols:42,role:'kitchen',from:[],copies:1,on:!0},'REPRINT')[0];return{...(0,c.browserPrint)(n),where:'this device\u2019s Print'}}let o={ok:!1};for(const s of n)if(o=await y(t,r,s,{reprint:!0}),o.ok)return{ok:!0,where:s.name};return{...o,where:n.map(t=>t.name).join(', ')}},e.checkDue=function(t,n=new Date){const s=f(t);if(!s.auto)return;const l=(0,c.thisDevice)(),p=r.useStore.getState().orders.filter(r=>r.restaurantId===t),h=S(t);for(const r of(0,o.dueForTicket)(p,s,n))for(const n of s.printers){if(!n.on)continue;const s=(0,o.printDelayMs)(n,l);if(s<0||!(0,o.canDrive)(l,n).ok)continue;const c=`${r.id}:${n.id}`;(0,o.printedOn)(r,n.id)||h.has(c)||k.has(c)||u.getState().busy[c]||u.getState().fails[c]||k.set(c,setTimeout(()=>{I(t,r.id,n.id,0)},s))}},e.retryFail=function(t,n){const o=`${n.orderId}:${n.printerId}`,s=k.get(o);s&&clearTimeout(s);k.delete(o);const c=r.useStore.getState().orders.find(t=>t.id===n.orderId),l=f(t).printers.find(t=>t.id===n.printerId);if(!c||!l)return void u.getState().set(o,null);y(t,c,l)},e.printHere=function(t,n){const o=r.useStore.getState().orders.find(t=>t.id===n.orderId);if(!o)return;v(t,n);const s=f(t).printers.find(t=>t.id===n.printerId);(0,c.browserPrint)(m(t,o,{...s??{id:'b',name:'Print',cols:42,role:'kitchen',from:[],copies:1,on:!0},kind:'browser'})[0])},e.dismissFail=v;var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u=(0,t.create)()(t=>({fails:{},busy:{},set:(r,n)=>t(t=>{const o={...t.fails};return n?o[r]=n:delete o[r],{fails:o}}),setBusy:(r,n)=>t(t=>({busy:{...t.busy,[r]:n}}))})),f=t=>(0,o.normPrint)(n.useFloor.getState().settings[t]?.printing),l=t=>`cc-printed:${t}`,p=()=>{try{return globalThis.localStorage}catch{return}};function S(t){try{return new Set(JSON.parse(p()?.getItem(l(t))??'[]'))}catch{return new Set}}function h(t,r){const n=S(t);n.add(r);try{p()?.setItem(l(t),JSON.stringify([...n].slice(-400)))}catch{}}function m(t,n,o,c){const u=r.useStore.getState(),f=u.restaurants.find(r=>r.id===t)?.name,l=t=>u.menu.find(r=>r.id===t)?.allergens,p='both'===o.role?['kitchen','foh']:['foh'===o.role?'foh':'kitchen'],S=[];for(const t of p)for(let r=1;r<=('kitchen'===t?o.copies:1);r++){const u=[c,'kitchen'===t&&o.copies>1?`COPY ${r} OF ${o.copies}`:''].filter(Boolean).join(' - ')||void 0;S.push((0,s.buildTicket)(n,{venue:f,kind:t,copyLabel:u,dishAllergens:l}))}return S}async function y(t,n,o,s={}){const f=`${n.id}:${o.id}`;u.getState().setBusy(f,!0);try{for(const r of m(t,n,o,s.reprint?'REPRINT':void 0)){const t=await(0,c.sendTicket)(o,r);if(!t.ok){const r=u.getState().fails[f];return u.getState().set(f,{orderId:n.id,ref:n.ref,name:n.customerName,printer:o.name,printerId:o.id,reason:t.error??'did not print',at:(new Date).toISOString(),tries:(r?.tries??0)+1}),t}}if(u.getState().set(f,null),!s.reprint){h(t,f);const s=(0,c.thisDevice)();r.useStore.setState(t=>({orders:t.orders.map(t=>t.id===n.id?{...t,printed:{at:t.printed?.at??(new Date).toISOString(),by:t.printed?.by??s,printer:t.printed?.printer??o.name,ids:[...new Set([...t.printed?.ids??[],o.id])]}}:t)}))}return{ok:!0}}finally{u.getState().setBusy(f,!1)}}function b(t){const r=(0,c.thisDevice)();return f(t).printers.filter(t=>t.on&&'foh'!==t.role&&(0,o.canDrive)(r,t).ok)}const k=new Map,w=[15e3,45e3];async function I(t,n,s,c){const l=`${n}:${s}`,p=r.useStore.getState().orders.find(t=>t.id===n),S=f(t).printers.find(t=>t.id===s);if(!p||!S||!S.on||0===c&&(0,o.printedOn)(p,S.id)||'cancelled'===p.status)return void k.delete(l);(await y(t,p,S)).ok||c>=w.length?k.delete(l):k.set(l,setTimeout(()=>{u.getState().set(l,{...u.getState().fails[l],tries:c+1}),I(t,n,s,c+1)},w[c]))}function v(t,r){const n=`${r.orderId}:${r.printerId}`;h(t,n);const o=k.get(n);o&&clearTimeout(o),k.delete(n),u.getState().set(n,null)}},1384,[846,874,1029,1383,1385,1386]); +__d(function(g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TICKET_ALLERGENS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"pounds",{enumerable:!0,get:function(){return p}}),e.collectTime=d,Object.defineProperty(e,"paidState",{enumerable:!0,get:function(){return h}}),e.buildTicket=function(s,a={}){const l=a.kind??'kitchen',f=[],b=a.now??new Date,$=d(s),x='table'===s.type?(0,t.tableNumbers)(s.tableNo)||'?':null;f.push({k:'text',t:x?'kitchen'===l?`KITCHEN - ${x}`:`${x} - FRONT OF HOUSE`:'kitchen'===l?'KITCHEN - TAKEAWAY':'TAKEAWAY - FRONT OF HOUSE',align:'c',bold:!0}),a.venue&&f.push({k:'text',t:a.venue,align:'c'});a.copyLabel&&f.push({k:'text',t:` ${a.copyLabel} `,align:'c',inv:!0,bold:!0});f.push({k:'text',t:`#${s.ref}`,size:3,bold:!0,align:'c'}),x?f.push({k:'text',t:x,size:3,bold:!0,align:'c'}):(f.push({k:'text',t:$.at?`COLLECT ${$.label}`:'COLLECT ASAP',size:2,bold:!0,align:'c'}),$.at&&f.push({k:'text',t:c($.at),align:'c'}));if(f.push({k:'rule'}),f.push({k:'text',t:s.customerName||'Guest',size:2,bold:!0}),f.push({k:'text',t:`Ordered ${r(new Date(s.createdAt))}${s.channel?` - ${u[s.channel]??s.channel}`:''}${s.accepted?` - accepted by ${s.accepted.by}`:''}`}),s.allergies?.length){f.push({k:'rule',heavy:!0}),f.push({k:'text',t:' ALLERGY ALERT ',inv:!0,bold:!0,size:2,align:'c'});for(const t of s.allergies)f.push({k:'text',t:` ${i(t.allergen).toUpperCase()} - ${o[t.severity]??t.severity} `,inv:!0,bold:!0});f.push({k:'text',t:'Check every dish below before it goes out.',bold:!0}),f.push({k:'rule',heavy:!0})}else f.push({k:'rule'});let k=0;for(const t of s.lines??[]){k+=t.qty,'foh'===l?f.push({k:'pair',l:`${t.qty} x ${t.name}`,r:p(t.unitPrice*t.qty),bold:!0}):f.push({k:'text',t:`${t.qty} x ${t.name}`,size:2,bold:!0,indent:4});for(const n of t.choices??[])f.push({k:'text',t:`+ ${n}`,indent:4});t.notes&&f.push({k:'text',t:`NOTE: ${t.notes}`,bold:!0,indent:4});const o=new Set([...t.contains??[],...t.may??[]]);for(const n of t.contains??[])f.push({k:'text',t:` !! CONTAINS ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});for(const n of t.may??[])f.push({k:'text',t:` !! MAY CONTAIN ${i(n).toUpperCase()} - CUSTOMER ALLERGY `,inv:!0,bold:!0,indent:4});t.overridden&&f.push({k:'text',t:'Allergy warning overridden when ordering: check with the manager',bold:!0,indent:4});const s=a.dishAllergens?.(t.itemId);if(s){const t=n.filter(t=>'contains'===s[t.id]&&!o.has(t.id)).map(t=>t.name),i=n.filter(t=>'may'===s[t.id]&&!o.has(t.id)).map(t=>t.name);t.length&&f.push({k:'text',t:`Allergens: ${t.join(', ')}`,indent:4}),i.length&&f.push({k:'text',t:`May contain: ${i.join(', ')}`,indent:4})}}s.notes&&(f.push({k:'rule'}),f.push({k:'text',t:`ORDER NOTE: ${s.notes}`,bold:!0}));f.push({k:'rule'});const y=h(s);'foh'===l&&(s.giftCardApplied&&f.push({k:'pair',l:'Gift card',r:`-${p(s.giftCardApplied)}`}),s.tip&&f.push({k:'pair',l:'Tip',r:p(s.tip)}),f.push({k:'pair',l:'Total',r:p(s.total??0),bold:!0,size:2}));x?'foh'===l&&f.push({k:'text',t:`Pay at the bar or till: ${p(Math.max(0,(s.total??0)-(s.paid??0)))}`,bold:!0,align:'c'}):y.paid?f.push({k:'text',t:y.label,size:2,bold:!0,align:'c'}):(f.push({k:'text',t:` ${y.label} `,size:2,bold:!0,inv:!0,align:'c'}),f.push({k:'text',t:`Take ${p(y.due)} on collection`,bold:!0,align:'c'}));return f.push({k:'pair',l:`${k} item${1===k?'':'s'}`,r:`Printed ${r(b)} ${c(b)}`}),f.push({k:'feed',n:3}),{lines:f,title:`${'kitchen'===l?'Kitchen':'Front of house'} ticket #${s.ref}`}},e.wrap=f,e.rows=$,Object.defineProperty(e,"ticketText",{enumerable:!0,get:function(){return x}}),e.cp437=A,e.escpos=function(t,n={}){const i=n.cols??42,o=[v,64,v,116,0];for(const n of $(t,i))o.push(v,97,'c'===n.align?1:'r'===n.align?2:0,v,69,n.bold?1:0,E,66,n.inv?1:0,E,33,3===n.size?34:2===n.size?17:0),o.push(...A(n.s),10);o.push(E,33,0,E,66,0,v,69,0,v,97,0),n.beep&&o.push(v,66,2,2);!1!==n.cut&&o.push(E,86,66,3);return Uint8Array.from(o)},e.eposXml=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i)){const t=n.size>1;o+=`${O(n.s)} `}return o+='',`${o}`},Object.defineProperty(e,"eposUrl",{enumerable:!0,get:function(){return S}}),e.eposResult=function(t){const n=(/]*>/i.exec(t)||[])[0];if(!n)return{ok:!1,code:'no reply from the printer'};const i=(/\bcode="([^"]*)"/i.exec(n)||[])[1];return/\bsuccess="true"/i.test(n)?{ok:!0}:{ok:!1,code:i||'printer said no'}},Object.defineProperty(e,"starEsc",{enumerable:!0,get:function(){return T}}),e.starRequest=function(t,n={}){const i=n.cols??48;let o='';for(const n of $(t,i))o+=`${T(n.s+'\n')}`;return o+='',o},Object.defineProperty(e,"starEnvelope",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"starUrl",{enumerable:!0,get:function(){return M}}),e.starResult=function(t,n=!0){return/\s*false/i.test(t)||/traderSuccess"?\s*[:=]\s*"?false/i.test(t)?{ok:!1,code:(/([^<]*)<\/code>/i.exec(t)||[])[1]||'Star printer reported an error'}:n?{ok:!0}:{ok:!1,code:'no reply from the printer'}},e.ticketHtml=function(t,n=42){const i=$(t,n).map(t=>`
${O(t.s)||' '}
`).join('');return`${O(t.title)}${i}`},e.friendlyError=function(t){const n=String(t||'');return/COVER_OPEN/i.test(n)?'the printer lid is open':/EMPTY|PAPER/i.test(n)?'the printer is out of paper':/OFFLINE|NOT_FOUND|ECONNREFUSED|EHOSTUNREACH|ENETUNREACH|refused|unreachable|could not reach|timeout|timed out|no reply/i.test(n)?'the printer did not answer (is it switched on and on the same Wi-Fi?)':/bluetooth/i.test(n)?'the Bluetooth printer did not connect (is it on and paired?)':n||'the printer did not answer'};var t=_r(_d[0]);const n=[{id:'gluten',name:'Gluten'},{id:'crustaceans',name:'Crustaceans'},{id:'molluscs',name:'Molluscs'},{id:'eggs',name:'Eggs'},{id:'fish',name:'Fish'},{id:'peanuts',name:'Peanuts'},{id:'treenuts',name:'Tree nuts'},{id:'soya',name:'Soya'},{id:'milk',name:'Milk'},{id:'celery',name:'Celery'},{id:'mustard',name:'Mustard'},{id:'sesame',name:'Sesame'},{id:'sulphites',name:'Sulphites'},{id:'lupin',name:'Lupin'}],i=t=>n.find(n=>n.id===t)?.name??String(t),o={intolerance:'intolerance',allergy:'allergy',coeliac:'coeliac',anaphylaxis:'ANAPHYLAXIS'},s=t=>String(t).padStart(2,'0'),r=t=>`${s(t.getHours())}:${s(t.getMinutes())}`,a=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],l=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],c=t=>`${a[t.getDay()]} ${t.getDate()} ${l[t.getMonth()]}`,p=t=>`\xa3${(Math.round(t)/100).toFixed(2)}`,u={app:'App',phone:'Phone','walk-in':'Walk-in','staff-table':'Staff','table-qr':'Table QR'};function d(t){const n=t.readyBy||t.slotTime;if(!n)return{label:'ASAP'};const i=new Date(n);return isNaN(i.getTime())?{label:'ASAP'}:{label:r(i),at:i}}const h=t=>{const n=Math.max(0,Math.round((t.total??0)-(t.paid??0)));return n<=0?{paid:!0,due:0,label:`PAID ${p(t.paid||t.total||0)}`}:{paid:!1,due:n,label:`NOT PAID ${p(n)}`}};function f(t,n,i=0){const o=[],s=' '.repeat(Math.min(i,Math.max(0,n-8)));let r='';const a=Math.max(4,n);for(const n of t.split(/(\s+)/)){if(!n)continue;let t=n;for(;(r+t).length>a;)if(r.trim()){if(o.push(r.replace(/\s+$/,'')),r=s,/^\s+$/.test(t)){t='';break}}else o.push((r+t).slice(0,a)),t=(r+t).slice(a),r=s;r+=t}return!r.trim()&&o.length||o.push(r.replace(/\s+$/,'')),o}const b=(t,n,i)=>{const o=i-n.length-1,s=f(t,Math.max(8,o)),r=s.pop()??'';return[...s,r+' '.repeat(Math.max(1,i-r.length-n.length))+n]};function $(t,n=42){const i=[];for(const o of t.lines)if('rule'===o.k)i.push({s:(o.heavy?'=':'-').repeat(n),size:1,bold:!1,inv:!1,align:'l'});else if('feed'===o.k)for(let t=0;t$(t,n).map(t=>{const i=Math.floor(n/t.size),o='c'===t.align?Math.max(0,Math.floor((i-t.s.length)/2)):'r'===t.align?Math.max(0,i-t.s.length):0;return' '.repeat(o)+t.s}).join('\n'),k={'\xc7':128,'\xfc':129,'\xe9':130,'\xe2':131,'\xe4':132,'\xe0':133,'\xe5':134,'\xe7':135,'\xea':136,'\xeb':137,'\xe8':138,'\xef':139,'\xee':140,'\xec':141,'\xc4':142,'\xc5':143,'\xc9':144,'\xe6':145,'\xc6':146,'\xf4':147,'\xf6':148,'\xf2':149,'\xfb':150,'\xf9':151,'\xff':152,'\xd6':153,'\xdc':154,'\xa2':155,'\xa3':156,'\xa5':157,'\xe1':160,'\xed':161,'\xf3':162,'\xfa':163,'\xf1':164,'\xd1':165,'\xbd':171,'\xbc':172,'\xb0':248,'\xb7':250},y={'\u20ac':'EUR','\u2018':"'",'\u2019':"'",'\u201c':'"','\u201d':'"','\u2013':'-','\u2014':'-','\u2026':'...','\xd7':'x','\u2022':'*','\u26a0':'!','\u0153':'oe','\xdf':'ss','\xf8':'o','\xd8':'O',' ':' '};function A(t){const n=[];for(const i of t.normalize('NFC')){const t=i.codePointAt(0)??63;if(t>=32&&t<127)n.push(t);else if(null!=k[i])n.push(k[i]);else if(null!=y[i])for(const t of y[i])n.push(t.charCodeAt(0));else{const t=i.normalize('NFD').replace(/[\u0300-\u036f]/g,'');if(t&&t!==i&&/^[\x20-\x7e]+$/.test(t))for(const i of t)n.push(i.charCodeAt(0));else n.push(63)}}return n}const v=27,E=29;const O=t=>t.replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"').replace(/'/g,''');const S=(t,n=!1,i="local_printer")=>`${n?'https':'http'}://${t}/cgi-bin/epos/service.cgi?devid=${encodeURIComponent(i)}&timeout=10000`;const T=t=>t.replace(/[\\\x00-\x20&<>\x7f]/g,t=>'\\'===t?'\\\\':`\\x${t.charCodeAt(0).toString(16).padStart(2,'0')}`);const w=t=>`${O(`${t}`)}`,M=(t,n=!1)=>`${n?'https':'http'}://${t}/StarWebPRNT/SendMessage`},1385,[860]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.thisDevice=function(){const e=t();if(e?.CcPrintNative||/CoverChargeTablet/.test(e?.navigator?.userAgent??''))return'tablet';if(e?.ccDesktop)return'mac';const r=String(e?.location?.pathname??'');return/\/display(-app)?\//.test(r)||r.startsWith('/display')?'display':'owner'},Object.defineProperty(_e,"hasNative",{enumerable:!0,get:function(){return l}}),_e.browserPrint=f,_e.sendTicket=async function(t,r){const o=(t.host??'').trim();let n;if('browser'===t.kind)n=f(r,t.cols);else if('escpos'===t.kind)n=o?await d(o,t.port??9100,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'no IP address set'};else if('bluetooth'===t.kind)n=t.btAddress?await p(t.btAddress,(0,e.escpos)(r,{cols:t.cols,beep:!0})):{ok:!1,error:'bluetooth: no printer chosen'};else if('epson'===t.kind)if(o){const s=await u((0,e.eposUrl)(o,!!t.https),(0,e.eposXml)(r,{cols:t.cols}),{'Content-Type':'text/xml; charset=utf-8',SOAPAction:'""','If-Modified-Since':'Thu, 01 Jan 1970 00:00:00 GMT'});n=s.error?{ok:!1,error:s.error}:(0,e.eposResult)(s.body??''),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};else if(o){const s=await u((0,e.starUrl)(o,!!t.https),(0,e.starEnvelope)((0,e.starRequest)(r,{cols:t.cols})),{'Content-Type':'text/xml; charset=UTF-8'});n=s.error?{ok:!1,error:s.error}:(0,e.starResult)(s.body??'',s.ok),!n.ok&&n.code&&(n.error=n.code)}else n={ok:!1,error:'no IP address set'};return n.ok?{ok:!0}:{ok:!1,error:(0,e.friendlyError)(n.error)}},_e.scanNetwork=async function(){const e=n()?await s('scan',[],4e4):i()?await i().scan():{ok:!1,error:'Scanning needs the Display tablet app or CoverCharge for Mac. In a web browser, type the printer\u2019s IP address instead.'};return{ok:!!e.ok,error:e.error,found:e.found??[]}},_e.pairedBluetooth=async function(){if(!n())return{ok:!1,error:'Bluetooth printers work from the Display tablet app only.',devices:[]};const e=await s('btList',[],2e4);return{ok:!!e.ok,error:e.error,devices:e.devices??[]}},Object.defineProperty(_e,"testTicket",{enumerable:!0,get:function(){return h}}),_r(_d[0]);var e=_r(_d[1]);const t=()=>'undefined'!=typeof window?window:void 0;let r=0;const o=new Map;function n(){return t()?.CcPrintNative}function s(e,s,i=15e3){const c=n();if(!c||'function'!=typeof c[e])return Promise.resolve({ok:!1,error:'This tablet app is too old to print. Install the latest Display tablet app.'});const l=t();l.__ccNativeDone||(l.__ccNativeDone=(e,t)=>{const r=o.get(e);if(r){o.delete(e);try{r(JSON.parse(t))}catch{r({ok:!1,error:'bad reply'})}}});const d=`p${Date.now().toString(36)}${(r++).toString(36)}`;return new Promise(t=>{const r=setTimeout(()=>{o.delete(d)&&t({ok:!1,error:'timed out'})},i);o.set(d,e=>{clearTimeout(r),t(e)});try{c[e](d,...s)}catch(e){o.delete(d),clearTimeout(r),t({ok:!1,error:String(e?.message??e)})}})}const i=()=>t()?.ccDesktop?.printer,c=e=>{let r='';for(let t=0;tglobalThis.Buffer.from(e,'binary').toString('base64')))(r)},l=()=>!!n()||!!i();async function d(e,t,r){return n()?s('tcp',[e,t,c(r)]):i()?i().tcp(e,t,c(r)):{ok:!1,error:'This device cannot reach port 9100.'}}async function u(e,t,r){if(n())return s('http',[e,t,JSON.stringify(r)]);if(i())return i().http(e,t,r);try{const o='undefined'!=typeof AbortController?new AbortController:null,n=setTimeout(()=>o?.abort(),12e3),s=await fetch(e,{method:'POST',headers:r,body:t,signal:o?.signal});return clearTimeout(n),{ok:s.ok,status:s.status,body:await s.text()}}catch(e){return{ok:!1,error:/abort/i.test(String(e))?'timed out':'could not reach the printer (for a web browser it needs HTTPS and its certificate accepted once)'}}}async function p(e,t){return n()?s('bt',[e,c(t)],25e3):{ok:!1,error:'bluetooth: only the Display tablet app can print over Bluetooth'}}function f(r,o=42){const n=t();if(!n?.document)return{ok:!1,error:'no Print on this device'};try{const t=n.document.createElement('iframe');t.setAttribute('aria-hidden','true'),t.style.cssText='position:fixed;right:0;bottom:0;width:0;height:0;border:0;',n.document.body.appendChild(t);const s=t.contentDocument;return s.open(),s.write((0,e.ticketHtml)(r,o)),s.close(),setTimeout(()=>{try{t.contentWindow.focus(),t.contentWindow.print()}catch{}setTimeout(()=>t.remove(),6e4)},250),{ok:!0}}catch(e){return{ok:!1,error:String(e?.message??e)}}}const h=(t,r)=>(0,e.buildTicket)({id:'test',ref:'TEST',restaurantId:'',customerId:'',customerName:'Test print',type:'takeaway',lines:[{itemId:'t1',name:'Fish supper',qty:2,unitPrice:1250,choices:['Mushy peas','Large'],notes:'No salt',contains:['fish'],may:[],overridden:!1,prepMins:12},{itemId:'t2',name:'Sticky toffee pudding',qty:1,unitPrice:750,choices:[],notes:'',contains:[],may:['treenuts'],overridden:!1,prepMins:3}],subtotal:3250,tip:0,giftCardApplied:0,total:3250,paid:3250,status:'new',createdAt:(new Date).toISOString(),allergies:[{allergen:'fish',severity:'allergy'},{allergen:'treenuts',severity:'anaphylaxis'}],readiness:{},slotTime:new Date(Date.now()+12e5).toISOString(),notes:'This is a test ticket. Nothing to cook.'},{venue:t,kind:'foh'===r.role?'foh':'kitchen',copyLabel:'TEST PRINT',dishAllergens:e=>'t1'===e?{fish:'contains',gluten:'contains'}:{milk:'contains',eggs:'contains',gluten:'contains'}})},1386,[236,1385]); +__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.BlockList=j,_e.BlockBookingsSheet=v,_e.BlocksBanner=function({rid:e,now:o,big:s,by:t="staff"}){const l=(0,i.useBlocks)(e=>e.blocks),n=(0,i.useBlocks)(e=>e.remove),a=(0,i.activeBlock)(l,e,(0,c.ymd)(o),(0,c.hm)(o));return a?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(M,{rid:e,now:o,big:s}),(0,f.jsxs)(r.default,{testID:"blocks-banner",accessibilityRole:"summary",style:{flexDirection:a.privateFunction?'column':'row',alignItems:a.privateFunction?'stretch':'center',gap:10,backgroundColor:u.colours.amberBg,borderColor:u.colours.amber,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!!a.privateFunction,colour:u.colours.amber,style:{flex:a.privateFunction?void 0:1,minWidth:0},children:(0,i.pausedLine)(a)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Undo",style:a.privateFunction?{width:'100%'}:void 0,testID:"blocks-undo",onPress:()=>{n(a.id,t),(0,m.pushBlocksToWix)(e,[a.id],'remove')}})]})]}):(0,f.jsx)(M,{rid:e,now:o,big:s})},_e.BlockBookingsButton=function({rid:e,r:o,now:a,by:d,wide:m,big:x,quiet:k,tile:p,display:j,day:y}){const[w,B]=(0,s.useState)(!1),C=(0,i.useBlocks)(e=>e.blocks),D=y??(0,c.ymd)(a),M=C.filter(o=>o.rid===e&&o.date===D&&!o.removedAt).length,P=M?`${M} block${1===M?'':'s'} that day`:'';return p?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(t.ActionTile,{testID:"block-bookings",icon:"pause",label:"Block bookings",sub:P||'Pause online times',count:M||void 0,onPress:()=>B(!0),accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings'}),w?(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(n.default,{testID:"block-bookings",accessibilityRole:"button",accessibilityLabel:P?`Block bookings, ${P}`:'Block bookings',onPress:()=>B(!0),style:({pressed:e})=>k?{...l.look.quiet(e),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:u.colours.gold,borderRadius:16,paddingVertical:x?14:10,paddingHorizontal:18,backgroundColor:e?u.colours.goldTint:'transparent'},children:[k?null:(0,f.jsx)(b.T,{size:x?22:17,colour:u.colours.gold,children:"\u23f8"}),(0,f.jsx)(b.T,{size:k?15:x?22:17,weight:"semibold",colour:k?u.colours.goldLight:u.colours.gold,children:"Block bookings"}),M?(0,f.jsx)(r.default,{style:{backgroundColor:u.colours.amber,borderRadius:10,minWidth:22,paddingHorizontal:6},children:(0,f.jsx)(b.T,{size:13,weight:"bold",colour:u.colours.onGold,center:!0,children:M})}):null]}),w?j?(0,f.jsx)(h.DisplayBlocksMenu,{rid:e,r:o,now:a,by:d,onClose:()=>B(!1)}):(0,f.jsx)(v,{rid:e,r:o,now:a,by:d,wide:m,onClose:()=>B(!1)}):null]})},_e.closeOutdoor=B,_e.useOutdoor=C,_e.CloseGardenButton=function({rid:e,r:o,now:s,by:r,big:a,quiet:d,short:c,tile:h}){const m=C(e,s);if(!m.outdoor.length)return null;const x=m.allClosed;return h?(0,f.jsx)(t.ActionTile,{testID:x?'reopen-garden':'close-garden',icon:x?'sun':'rain',tone:x?'blue':'gold',label:x?'Reopen garden':'Close garden',sub:x?'Closed for weather':'For weather',accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id)))}):(0,f.jsxs)(n.default,{testID:x?'reopen-garden':'close-garden',accessibilityRole:"button",accessibilityLabel:x?'Reopen garden':'Close garden for weather',onPress:()=>x?m.active.forEach(e=>i.useBlocks.getState().remove(e.id)):B(e,o,s,r,m.outdoor.filter(e=>!m.closed.has(e.id))),style:({pressed:e})=>d?{...l.look.quiet(e,x?'blue':'gold'),flexGrow:1}:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:8,borderWidth:2,borderColor:x?u.colours.blue:u.colours.gold,borderRadius:16,paddingVertical:a?14:10,paddingHorizontal:16,minHeight:48,backgroundColor:e?u.colours.goldTint:x?u.colours.blueBg:'transparent'},children:[d?null:(0,f.jsx)(b.T,{size:a?22:17,children:x?'\u2600\ufe0f':'\ud83c\udf27'}),(0,f.jsx)(b.T,{size:d?15:a?20:16,weight:"semibold",colour:x?u.colours.blue:d?u.colours.goldLight:u.colours.gold,children:x?'Reopen garden':c?'Close garden':'Close garden for weather'})]})},_e.GardenBanner=M;var o=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),r=e(_r(_d[5])),i=_r(_d[6]),a=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),h=_r(_d[12]),m=_r(_d[13]),f=_r(_d[14]);const x=e=>(0,c.fromMins)(15*Math.floor((60*e.getHours()+e.getMinutes())/15)),k=(e,o)=>e.date===o?'Today':(0,c.niceDate)((0,c.parseYmd)(e.date));function p({title:e,sub:o,onPress:s,testID:t,disabled:l}){return(0,f.jsxs)(n.default,{testID:t,accessibilityRole:"button",accessibilityLabel:e,disabled:l,onPress:s,style:({pressed:e})=>({borderWidth:1.5,borderColor:u.colours.gold,borderRadius:16,padding:16,backgroundColor:e?u.colours.goldTint:u.colours.surface2,opacity:l?.4:1}),children:[(0,f.jsx)(b.T,{size:20,weight:"semibold",colour:u.colours.gold,children:e}),o?(0,f.jsx)(b.Muted,{children:o}):null]})}function j({rid:e,now:t,by:l="staff"}){const n=(0,i.useBlocks)(e=>e.blocks),a=(0,i.useBlocks)(e=>e.remove),[d,h]=(0,s.useState)(null),x=(0,c.ymd)(t),p=(0,i.currentBlocks)(n,e,x,(0,c.hm)(t));return p.length?(0,f.jsxs)(r.default,{style:{gap:8},testID:"block-list",children:[p.map(e=>{const s=e.date===x&&(0,c.toMins)(e.from)<=(0,c.toMins)((0,c.hm)(t));return(0,f.jsxs)(b.Row,{style:{justifyContent:'space-between',borderWidth:1,borderColor:s?u.colours.amber:u.colours.border,borderRadius:12,padding:10},children:[(0,f.jsxs)(r.default,{style:{flex:1},children:[(0,f.jsxs)(b.T,{weight:"semibold",children:[e.areaId?`${e.areaName??'Area'} closed \xb7 `:'',e.tables?.length?`${e.tables.map(o.tableNumbers).join(', ')} \xb7 `:'',k(e,x)," \xb7 ",e.from,"\u2013",e.to,s?' \xb7 now':'']}),(0,f.jsxs)(b.Muted,{children:[e.reason??'No reason given'," \xb7 by ",e.by,e.areaId?' \xb7 the rest of the venue stays open':'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Remove",testID:`block-remove-${e.id}`,onPress:()=>h(e)})]},e.id)}),d?(0,f.jsxs)(b.Sheet,{visible:!0,onClose:()=>h(null),title:"Remove this block?",testID:"block-remove-confirm",children:[(0,f.jsx)(b.T,{children:`${k(d,x)}, ${d.from}\u2013${d.to}. Bookings open again for that time.`}),(0,f.jsx)(b.Button,{testID:"block-remove-yes",label:"Remove block",onPress:()=>{a(d.id,l),(0,m.pushBlocksToWix)(e,[d.id],'remove'),h(null)}}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Keep it",onPress:()=>h(null)})]}):null]}):(0,f.jsx)(b.Muted,{children:"No bookings paused. Online and staff bookings are open as normal."})}function y({value:e,onChange:o}){return(0,f.jsxs)(r.default,{style:{gap:6},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Reason (optional)"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:i.BLOCK_REASONS.map(s=>(0,f.jsx)(b.Chip,{label:s,selected:e===s,onPress:()=>o(e===s?void 0:s)},s))})]})}function w({label:e,value:o,onChange:s,min:t,max:l}){return(0,f.jsxs)(b.Row,{gap:8,children:[(0,f.jsx)(b.T,{style:{width:52},children:e}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"\u221230",accessibilityLabel:`${e} 30 minutes earlier`,onPress:()=>s(Math.max(t,o-30))}),(0,f.jsx)(b.T,{size:22,weight:"semibold",colour:u.colours.gold,style:{minWidth:70,textAlign:'center'},children:(0,c.fromMins)(o)}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"+30",accessibilityLabel:`${e} 30 minutes later`,onPress:()=>s(Math.min(l,o+30))})]})}function v({rid:e,r:o,now:t,by:l,onClose:n,wide:a}){const u=(0,i.useBlocks)(e=>e.add),[h,m]=(0,s.useState)('menu'),[k,v]=(0,s.useState)(),B=(0,c.ymd)(t),C=(0,d.hoursFor)(o,t),M=C?(0,c.hm)(C.close):null,P=x(t),T=!!C&&(0,c.toMins)(P)<(0,c.toMins)(M),I=(0,c.fromMins)((0,c.toMins)(P)+60),R=(0,s.useMemo)(()=>{const e=[];for(let s=1;s<=28;s++){const l=new Date(t);l.setHours(12,0,0,0),l.setDate(l.getDate()+s),(0,d.hoursFor)(o,l)&&e.push(l)}return e},[B,o.id]),[$,z]=(0,s.useState)(R[0]?(0,c.ymd)(R[0]):B),F=(0,d.hoursFor)(o,(0,c.parseYmd)($)),S=F?(0,c.toMins)((0,c.hm)(F.open)):720,W=F?(0,c.toMins)((0,c.hm)(F.close)):1260,[L,A]=(0,s.useState)(null),N=L??{from:S,to:W},H=(o,s,t)=>{u({rid:e,date:o,from:s,to:t,reason:k,by:l}),n()};return(0,f.jsx)(b.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:a?720:void 0,testID:"block-sheet",children:'menu'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.Muted,{children:"Pause new bookings for a while. The customer app stops offering those times, and staff get a warning."}),(0,f.jsx)(p,{testID:"block-today",title:"Today",sub:T?`Now until close (${M}) or for 1 hour`:'Closed for the rest of today',disabled:!T,onPress:()=>m('today')}),(0,f.jsx)(p,{testID:"block-future",title:"Future dates",sub:"Pick a date and a time window",onPress:()=>m('future')}),(0,f.jsx)(D,{rid:e,r:o,now:t,by:l,onDone:n}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Active and upcoming"}),(0,f.jsx)(j,{rid:e,now:t})]}):'today'===h?(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(p,{testID:"block-until-close",title:"From now until close",sub:`${P} to ${M} (kitchen close, from opening hours)`,onPress:()=>H(B,P,M)}),(0,f.jsx)(p,{testID:"block-one-hour",title:"From now for 1 hour",sub:`${P} to ${I}`,onPress:()=>H(B,P,I)}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]}):(0,f.jsxs)(r.default,{style:{gap:10},children:[(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Date"}),(0,f.jsx)(b.Row,{wrap:!0,gap:6,children:R.map(e=>(0,f.jsx)(b.Chip,{label:(0,c.niceDate)(e),selected:$===(0,c.ymd)(e),onPress:()=>{z((0,c.ymd)(e)),A(null)}},(0,c.ymd)(e)))}),(0,f.jsx)(b.T,{size:14,weight:"semibold",children:"Time window"}),(0,f.jsxs)(b.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(b.Chip,{label:"All day",selected:N.from===S&&N.to===W,onPress:()=>A({from:S,to:W})}),S<1020?(0,f.jsx)(b.Chip,{label:`Lunch ${(0,c.fromMins)(S)}\u201317:00`,selected:N.from===S&&1020===N.to,onPress:()=>A({from:S,to:Math.min(1020,W)})}):null,W>1020?(0,f.jsx)(b.Chip,{label:`Evening 17:00\u2013${(0,c.fromMins)(W)}`,selected:1020===N.from&&N.to===W,onPress:()=>A({from:Math.max(1020,S),to:W})}):null]}),(0,f.jsx)(w,{label:"From",value:N.from,min:S,max:N.to-30,onChange:e=>A({...N,from:e})}),(0,f.jsx)(w,{label:"To",value:N.to,min:N.from+30,max:W,onChange:e=>A({...N,to:e})}),(0,f.jsx)(y,{value:k,onChange:v}),(0,f.jsx)(b.Button,{testID:"block-save-future",label:`Block ${(0,c.niceDate)((0,c.parseYmd)($))} ${(0,c.fromMins)(N.from)}\u2013${(0,c.fromMins)(N.to)}`,disabled:!R.length,onPress:()=>H($,(0,c.fromMins)(N.from),(0,c.fromMins)(N.to))}),(0,f.jsx)(b.Button,{kind:"ghost",label:"Back",onPress:()=>m('menu')})]})})}function B(e,o,s,t,l){const n=(0,d.hoursFor)(o,s),r=x(s),a=n?(0,c.hm)(n.close):null,u=a&&(0,c.toMins)(a)>(0,c.toMins)(r)?a:'23:59';return l.map(o=>i.useBlocks.getState().add({rid:e,date:(0,c.ymd)(s),from:r,to:u,reason:'Weather',by:t,areaId:o.id,areaName:o.name}))}function C(e,o){const s=(0,a.usePlan)(e),t=(0,i.useBlocks)(e=>e.blocks),l=s.areas.filter(e=>e.outdoor),n=(0,i.closedAreasAt)(t,e,(0,c.ymd)(o),(0,c.hm)(o)),r=t.filter(s=>s.rid===e&&s.areaId&&s.date===(0,c.ymd)(o)&&(0,c.toMins)((0,c.hm)(o))>=(0,c.toMins)(s.from)&&(0,c.toMins)((0,c.hm)(o))<(0,c.toMins)(s.to));return{plan:s,outdoor:l,closed:n,active:r,allClosed:l.length>0&&l.every(e=>n.has(e.id))}}function D({rid:e,r:o,now:s,by:t,onDone:l}){const n=C(e,s);return!n.outdoor.length||n.allClosed?null:(0,f.jsx)(p,{testID:"block-garden",title:"Close garden for weather",sub:`${n.outdoor.map(e=>e.name).join(', ')} only \xb7 the rest of the venue stays bookable`,onPress:()=>{B(e,o,s,t,n.outdoor.filter(e=>!n.closed.has(e.id))),l()}})}function M({rid:e,now:o,big:s}){const t=C(e,o);if(!t.active.length)return null;const l=[...new Set(t.active.map(e=>e.areaName??'Garden'))].join(', '),n=t.active.map(e=>e.to).sort().slice(-1)[0],a=t.active.every(e=>'Weather'===e.reason),d=a?`${l} closed for weather until ${n}`:t.active.map(i.pausedLine).join('. '),c=t.plan.areas.filter(e=>e.dogs&&!t.closed.has(e.id)).map(e=>e.name);return(0,f.jsxs)(r.default,{testID:"garden-banner",accessibilityRole:"summary",style:{flexDirection:a?'row':'column',alignItems:a?'center':'stretch',gap:10,backgroundColor:u.colours.blueBg,borderColor:u.colours.blue,borderWidth:1.5,borderRadius:14,paddingVertical:s?10:8,paddingHorizontal:14},children:[a?(0,f.jsx)(b.T,{size:s?20:16,children:"\ud83c\udf27"}):null,(0,f.jsxs)(r.default,{style:{flex:a?1:void 0,minWidth:0},children:[(0,f.jsx)(b.T,{size:s?20:16,weight:"semibold",center:!a,colour:u.colours.blue,children:d}),(0,f.jsxs)(b.T,{size:13,colour:"#E2C489",children:["No bookings or walk-ins are offered there.",c.length?` Dogs can still sit in the ${c.join(' or ')}.`:'']})]}),(0,f.jsx)(b.Button,{small:!0,kind:"secondary",label:"Reopen",style:a?void 0:{width:'100%'},testID:"garden-reopen",onPress:()=>t.active.forEach(e=>i.useBlocks.getState().remove(e.id))})]})}},1387,[860,34,1200,1189,402,102,1026,1029,878,858,821,794,1388,1391,25]); +__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.BigText=C,_e.TimeGrid=S,_e.ScopePicker=T,_e.BlockNowSheet=M,_e.DatePicker=W,_e.AddBlockSheet=R,_e.PrivateFunctionSheet=L,_e.FutureBlocksList=F,_e.BlocksScreen=N,_e.DisplayBlocksScreen=E,_e.DisplayBlocksMenu=function({rid:e,r:t,now:s,by:o,onClose:n}){const[i,a]=(0,l.useState)('menu');return'now'===i?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'future'===i?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:!0,onClose:n}):'list'===i?(0,w.jsx)(E,{rid:e,r:t,now:s,by:o,onBack:n}):(0,w.jsxs)(p.Sheet,{visible:!0,onClose:n,title:"Block bookings",maxWidth:560,testID:"display-blocks-menu",children:[(0,w.jsx)(C,{wide:!0,testID:"dbm-now",label:"Block now",sub:"Pause bookings today",onPress:()=>a('now')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-future",label:"Block future",sub:"A future date, time or tables",onPress:()=>a('future')}),(0,w.jsx)(C,{wide:!0,testID:"dbm-list",label:"All blocked times",sub:"See, change or remove a block",onPress:()=>a('list')}),(0,w.jsx)(p.Muted,{children:"Tip: anyone on the Display can add, change or remove a block. Removing asks you to confirm, and every change is logged."})]})};var t=_r(_d[0]),s=_r(_d[1]),o=_r(_d[2]),l=_r(_d[3]),n=e(_r(_d[4])),i=e(_r(_d[5])),a=e(_r(_d[6])),r=e(_r(_d[7])),d=e(_r(_d[8])),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),g=_r(_d[13]),m=_r(_d[14]),x=_r(_d[15]),p=_r(_d[16]),f=_r(_d[17]),k=_r(_d[18]),y=_r(_d[19]),j=_r(_d[20]),w=_r(_d[21]);const v=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],D=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],I=e=>{try{n.default.announceForAccessibility?.(e)}catch{}};function C({label:e,sub:t,onPress:s,selected:o,disabled:l,testID:n,a11y:i,wide:r,accessibilityHint:d}){return(0,w.jsxs)(a.default,{testID:n,accessibilityRole:"button",accessibilityLabel:i??(t?`${e}, ${t}`:e),accessibilityHint:d,accessibilityState:{selected:!!o,disabled:!!l},disabled:l,onPress:s,style:({pressed:e})=>({minHeight:52,minWidth:r?void 0:84,flexGrow:r?1:0,paddingHorizontal:14,paddingVertical:8,borderRadius:14,borderWidth:1.5,borderColor:o?m.colours.gold:m.colours.border,backgroundColor:o?m.colours.gold:e?m.colours.goldTint:m.colours.surface2,opacity:l?.35:1,justifyContent:'center'}),children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:o?m.colours.onGold:m.colours.goldLight,center:!0,children:e}),t?(0,w.jsx)(p.T,{size:13,colour:o?m.colours.onGold:m.colours.muted,center:!0,children:t}):null]})}function S({from:e,to:t,min:s,max:o,onChange:n,testID:i="time-grid"}){const[a,r]=(0,l.useState)(e?'to':'from'),c=(0,b.quarterTimes)(s,o),u=t=>{if('from'===a||!e||(0,g.toMins)(t)<=(0,g.toMins)(e))return n(t,void 0),r('to'),void I(`From ${(0,b.rangeText)(t,t).split('\u2013')[0]}. Now pick the end time.`);n(e,t),r('from'),I(`Block ${(0,b.rangeText)(e,t)}`)};return c.length?(0,w.jsxs)(d.default,{testID:i,style:{gap:6},children:[(0,w.jsxs)(p.T,{size:15,weight:"semibold",colour:m.colours.gold,children:['from'!==a&&e?'Now tap the end time':'Tap the start time',e?` \xb7 ${(0,b.rangeText)(e,t??e)}`:'']}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:6},children:c.map(s=>{const o=!!e&&!!t&&(0,g.toMins)(s)>=(0,g.toMins)(e)&&(0,g.toMins)(s)<=(0,g.toMins)(t);return(0,w.jsx)(C,{testID:`${i}-${s.replace(':','')}`,label:(0,b.rangeText)(s,s).split('\u2013')[0],a11y:`${'from'===a?'From':'To'} ${(0,b.rangeText)(s,s).split('\u2013')[0]}`,selected:s===e||s===t||o,onPress:()=>u(s)},s)})})]}):(0,w.jsx)(p.Muted,{children:"No times left today."})}function T({rid:e,value:t,onChange:s}){const n=(0,h.usePlan)(e),[i,a]=(0,l.useState)(!!t.tables?.length);return(0,w.jsxs)(d.default,{style:{gap:6},testID:"block-scope",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Where (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"scope-all",label:"All areas",selected:!t.areaId&&!t.tables?.length&&!i,onPress:()=>{a(!1),s({})}}),n.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`scope-area-${e.id}`,label:e.name,selected:t.areaId===e.id,onPress:()=>{a(!1),s({areaId:e.id,areaName:e.name})}},e.id)),(0,w.jsx)(p.Chip,{testID:"scope-tables",label:"Some tables",selected:i,onPress:()=>{a(!0),s({tables:t.tables??[]})}})]}),i?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:n.tables.map(e=>{const l=!!t.tables?.includes(e.name);return(0,w.jsx)(p.Chip,{testID:`scope-table-${e.name}`,label:(0,o.tableNumbers)(e.name),selected:l,onPress:()=>s({tables:l?(t.tables??[]).filter(t=>t!==e.name):[...t.tables??[],e.name]})},e.id)})}):null]})}function B({value:e,note:t,onChange:s,onNote:o}){return(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Reason (optional)"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:u.BLOCK_REASONS.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e===t,onPress:()=>s(e===t?void 0:t)},t))}),(0,w.jsx)(p.Field,{label:"Note (optional)",value:t,onChangeText:e=>o(e.slice(0,120)),placeholder:"e.g. Christening party",testID:"block-note"})]})}function $({line:e,clashes:t,testID:s="block-confirm"}){return(0,l.useEffect)(()=>{I(`${e}. ${t?`${t} booking${1===t?' is':'s are'} already in this time and will be kept.`:''}`)},[e,t]),(0,w.jsxs)(d.default,{testID:s,accessibilityLiveRegion:"polite",style:{borderWidth:1.5,borderColor:m.colours.gold,borderRadius:14,padding:12,gap:6,backgroundColor:m.colours.goldTint},children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,children:e}),t?(0,w.jsx)(p.T,{size:15,colour:m.colours.amber,testID:"block-clash-warning",children:`${t} booking${1===t?' is':'s are'} already in this time. ${1===t?'It is':'They are'} kept: call the guest${1===t?'':'s'} if needed.`}):(0,w.jsx)(p.Muted,{children:"No bookings in this time yet."})]})}const P=e=>(0,b.roundUpQuarter)(60*e.getHours()+e.getMinutes())-(e.getMinutes()%15==0?0:15);function M({rid:e,r:t,now:s,by:o,onClose:n,wide:i}){const a=(0,g.ymd)(s),r=(0,h.useDisplaySettings)(e),x=(0,b.openWindow)(t,a),k=(0,b.servicesOn)(t,a,r.serviceWindows),y=Math.max(x?.from??0,P(s)),j=(0,c.useBookings)(e),v=(0,h.usePlan)(e),[D,M]=(0,l.useState)({}),[W,R]=(0,l.useState)(!1),[L,z]=(0,l.useState)({}),[F,N]=(0,l.useState)(),[E,H]=(0,l.useState)(''),[A,O]=(0,l.useState)('pick'),[_,G]=(0,l.useState)(''),Y=!!x&&ye&&e.to>y?{from:(0,g.fromMins)(Math.max(e.from,y)),to:(0,g.fromMins)(e.to)}:null,U=q(k.lunch),K=q(k.dinner),Q=Y?[{id:'rest',label:'Rest of today',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(x.to)}},{id:'hour',label:'Next hour',w:{from:(0,g.fromMins)(y),to:(0,g.fromMins)(Math.min(x.to,y+60))}},{id:'lunch',label:'Lunch',w:U},{id:'dinner',label:'Dinner',w:K}]:[],V=!!D.from&&!!D.to&&(0,g.toMins)(D.to)>(0,g.toMins)(D.from)&&!(L.tables&&!L.tables.length),J=V?(0,b.confirmLine)({dates:[a],from:D.from,to:D.to,today:a,...L}):'',X=V?(0,b.bookingsInWindow)(j,[a],D.from,D.to,L,e=>v.tables.find(t=>t.name===e)?.areaId).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:"Block now",maxWidth:i?760:void 0,testID:"block-now-sheet",children:'done'===A?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"block-now-done",children:_}),(0,w.jsx)(p.Muted,{children:"The customer app stops offering these times. Staff see the block on the plan and the timeline."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"block-now-close"})]}):'confirm'===A?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:J,clashes:X}),(0,w.jsx)(p.Button,{testID:"block-now-save",label:"Save block",onPress:()=>{const t=u.useBlocks.getState().add({rid:e,date:a,from:D.from,to:D.to,reason:F,note:E.trim()||void 0,by:o,...L});(0,f.pushBlocksToWix)(e,[t.id],'add'),G(`Saved. ${J.replace(/^Block/,'Blocked')}.`),I(`Saved. ${J}`),O('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>O('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: pick a time, then check the one-line summary before you save. Bookings already made are kept."}),Y?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},testID:"block-now-quick",children:[Q.map(e=>(0,w.jsx)(C,{wide:!0,testID:`block-now-${e.id}`,label:e.label,sub:e.w?(0,b.rangeText)(e.w.from,e.w.to):'Not today',disabled:!e.w,selected:!W&&D.label===e.id,onPress:()=>{R(!1),M({...e.w,label:e.id})}},e.id)),(0,w.jsx)(C,{wide:!0,testID:"block-now-custom",label:"From\u2013To",sub:"Pick the times",selected:W,onPress:()=>{R(!0),M({})}})]}):(0,w.jsx)(p.T,{colour:m.colours.amber,children:"Closed for the rest of today. Use Add a block for another day."}),Y&&W?(0,w.jsx)(S,{min:y,max:x.to,from:D.from,to:D.to,onChange:(e,t)=>M({from:e,to:t}),testID:"block-now-grid"}):null,Y?(0,w.jsx)(T,{rid:e,value:L,onChange:z}):null,Y?(0,w.jsx)(B,{value:F,note:E,onChange:N,onNote:H}):null,V?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"block-now-line",children:J}):null,(0,w.jsx)(p.Button,{testID:"block-now-next",label:"Check and save",disabled:!V,onPress:()=>O('confirm')})]})})}function W({value:e,end:t,range:s,min:o,onPick:n,testID:i="block-cal"}){const[r,c]=(0,l.useState)(()=>(e??o).slice(0,7)),u=(0,g.parseYmd)(`${r}-01`),h=(u.getDay()+6)%7,x=[...Array(h).fill(null)];for(let e=new Date(u);e.getMonth()===u.getMonth();e.setDate(e.getDate()+1))x.push((0,g.ymd)(e));const f=e=>{const t=(0,g.parseYmd)(`${r}-01`);t.setMonth(t.getMonth()+e),c((0,g.ymd)(t).slice(0,7))},k=o=>{if(!s||!e||t||of(-1)}),(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:(0,b.monthLabel)(`${r}-01`)}),(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Later \u203a",accessibilityLabel:"Next month",onPress:()=>f(1)})]}),(0,w.jsx)(d.default,{style:{flexDirection:'row'},children:['Mon','Tue','Wed','Thu','Fri','Sat','Sun'].map(e=>(0,w.jsx)(p.T,{size:13,colour:m.colours.muted,center:!0,style:{flex:1},children:e},e))}),(0,w.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap'},children:x.map((s,l)=>{if(!s)return(0,w.jsx)(d.default,{style:{width:"14.285714285714286%",height:48}},`e${l}`);const n=se&&sk(s),style:{height:46,borderRadius:10,alignItems:'center',justifyContent:'center',backgroundColor:r?m.colours.gold:m.colours.surface2,borderWidth:1,borderColor:r?m.colours.gold:m.colours.border,opacity:n?.3:1},children:(0,w.jsx)(p.T,{size:17,weight:"semibold",colour:r?m.colours.onGold:m.colours.text,children:String((0,g.parseYmd)(s).getDate())})})},s)})})]})}function R({rid:e,r:t,now:s,by:o,onClose:n,wide:i,edit:a,onEdit:r}){const x=(0,g.ymd)(s),k=(0,c.useBookings)(e),y=(0,h.usePlan)(e),[j,P]=(0,l.useState)(a?.date),[M,R]=(0,l.useState)(),[L,z]=(0,l.useState)(!1),[F,N]=(0,l.useState)(a?!!a.wholeDay:null),[E,H]=(0,l.useState)(a&&!a.wholeDay?a.from:void 0),[A,O]=(0,l.useState)(a&&!a.wholeDay?a.to:void 0),[_,G]=(0,l.useState)(a?{areaId:a.areaId,areaName:a.areaName,tables:a.tables}:{}),[Y,q]=(0,l.useState)(a?.reason),[U,K]=(0,l.useState)(a?.note??''),[Q,V]=(0,l.useState)('none'),[J,X]=(0,l.useState)([]),[Z,ee]=(0,l.useState)(),[te,se]=(0,l.useState)(!1),[oe,le]=(0,l.useState)('pick'),[ne,ie]=(0,l.useState)(''),ae=j?(0,b.openWindow)(t,j):null,re=ae?.from??540,de=ae?.to??1380,ce=j?(0,g.parseYmd)(j).getDay():0,ue='weekly'===Q?{kind:'weekly',days:J.length?J:[ce]}:'last'===Q?{kind:'last',weekday:ce}:{kind:'none'},he=j?a?[j]:(0,b.blockDates)(j,L?M:void 0,ue,Z):[],be=F?'00:00':E,ge=F?'23:59':A,me=!!j&&he.length>0&&null!=F&&!!be&&!!ge&&(0,g.toMins)(ge)>(0,g.toMins)(be)&&('none'===Q||!!Z)&&!(_.tables&&!_.tables.length),xe=(0,b.repeatText)(ue,Z),pe=me?(0,b.confirmLine)({dates:he,from:be,to:ge,wholeDay:!!F,today:x,repeat:xe,..._}):'',fe=me?(0,b.bookingsInWindow)(k,he,be,ge,_,e=>y.tables.find(t=>t.name===e)?.areaId).filter(e=>e.id!==a?.id).length:0;return(0,w.jsx)(p.Sheet,{visible:!0,onClose:n,title:a?'Edit block':'Add a block',maxWidth:i?760:void 0,testID:"add-block-sheet",children:'done'===oe?(0,w.jsxs)(d.default,{style:{gap:10},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{size:19,weight:"semibold",colour:m.colours.gold,testID:"add-block-done",children:ne}),(0,w.jsx)(p.Muted,{children:"It shows in Future blocks. The customer app won't offer these times."}),(0,w.jsx)(p.Button,{label:"Done",onPress:n,testID:"add-block-close"})]}):'confirm'===oe?(0,w.jsxs)(d.default,{style:{gap:10},children:[(0,w.jsx)($,{line:pe,clashes:fe,testID:"add-block-confirm"}),(0,w.jsx)(p.Button,{testID:"add-block-save",label:a?'Save changes':'Save block',onPress:()=>{const t={from:be,to:ge,wholeDay:!!F||void 0,reason:Y,note:U.trim()||void 0,areaId:_.areaId,areaName:_.areaName,tables:_.tables?.length?_.tables:void 0};if(a)return r?.({...t,date:j}),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),void le('done');const s=he.length>1?`s-${Date.now().toString(36)}`:void 0,l=u.useBlocks.getState().addMany(he.map(l=>({rid:e,date:l,by:o,...t,seriesId:s,repeatText:xe??(he.length>1?`${(0,b.longDate)(he[0])} to ${(0,b.longDate)(he[he.length-1])}`:void 0),until:'none'!==Q?Z:void 0})));(0,f.pushBlocksToWix)(e,l.map(e=>e.id),'add'),ie(`Saved. ${pe.replace(/^Block/,'Blocked')}.`),I(`Saved. ${pe}`),le('done')}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>le('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{children:"Tip: tap a date (or a first and last date for a range), choose Whole day or the times, then check the summary."}),a?null:(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"add-single",label:"One date",selected:!L,onPress:()=>{z(!1),R(void 0)}}),(0,w.jsx)(p.Chip,{testID:"add-range",label:"A range of dates",selected:L,onPress:()=>{z(!0),V('none')}})]}),(0,w.jsx)(W,{value:j,end:M,range:L&&!a,min:x,onPick:(e,t)=>{P(e),R(t)}}),j?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-dates",children:L&&M?`${(0,b.longDate)(j)} to ${(0,b.longDate)(M)}`:(0,b.longDate)(j)}):null,j?(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"add-whole-day",label:"Whole day",selected:!0===F,onPress:()=>N(!0)}),(0,w.jsx)(C,{wide:!0,testID:"add-times",label:"From\u2013To",sub:ae?`Open ${(0,b.rangeText)((0,g.fromMins)(ae.from),(0,g.fromMins)(ae.to))}`:'Closed that day',selected:!1===F,onPress:()=>N(!1)})]}):null,j&&!1===F?(0,w.jsx)(S,{min:re,max:de,from:E,to:A,onChange:(e,t)=>{H(e),O(t)},testID:"add-grid"}):null,j?(0,w.jsx)(T,{rid:e,value:_,onChange:G}):null,j?(0,w.jsx)(B,{value:Y,note:U,onChange:q,onNote:K}):null,!j||a||L?null:(0,w.jsxs)(d.default,{style:{gap:6},testID:"add-repeat",children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Repeat (optional)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[(0,w.jsx)(p.Chip,{testID:"repeat-none",label:"Does not repeat",selected:'none'===Q,onPress:()=>V('none')}),(0,w.jsx)(p.Chip,{testID:"repeat-weekly",label:"Every week",selected:'weekly'===Q,onPress:()=>{V('weekly'),J.length||X([ce])}}),(0,w.jsx)(p.Chip,{testID:"repeat-last",label:`Last ${v[ce]} of the month`,selected:'last'===Q,onPress:()=>V('last')})]}),'weekly'===Q?(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:D.map((e,t)=>(0,w.jsx)(p.Chip,{testID:`repeat-day-${t}`,label:e,selected:J.includes(t),onPress:()=>X(J.includes(t)?J.filter(e=>e!==t):[...J,t])},e))}):null,'none'!==Q?(0,w.jsxs)(d.default,{style:{gap:6},children:[(0,w.jsx)(p.T,{size:15,weight:"semibold",children:"Until (needed)"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[[1,3,6,12].map(e=>{const t=(0,g.parseYmd)(j);t.setMonth(t.getMonth()+e);const s=(0,g.ymd)(t);return(0,w.jsx)(p.Chip,{testID:`until-${e}`,label:12===e?'1 year':`${e} month${e>1?'s':''}`,selected:Z===s,onPress:()=>{ee(s),se(!1)}},e)}),(0,w.jsx)(p.Chip,{testID:"until-pick",label:"Pick a date",selected:te,onPress:()=>se(!0)})]}),te?(0,w.jsx)(W,{value:Z,min:(0,b.addDays)(j,1),onPick:e=>ee(e),testID:"until-cal"}):null,Z?(0,w.jsx)(p.Muted,{children:`${xe} \xb7 ${he.length} date${1===he.length?'':'s'}`}):null]}):null]}),me?(0,w.jsx)(p.T,{size:16,weight:"semibold",colour:m.colours.goldLight,testID:"add-line",children:pe}):null,(0,w.jsx)(p.Button,{testID:"add-block-next",label:"Check and save",disabled:!me,onPress:()=>le('confirm')})]})})}function L({rid:e,now:o,by:n,onClose:i}){const a=(0,h.usePlan)(e),r=(0,c.useBookings)(e),x=(0,g.ymd)(o),[f,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(x),[v,D]=(0,l.useState)('12:00'),[C,S]=(0,l.useState)('18:00'),[T,B]=(0,l.useState)(''),[P,M]=(0,l.useState)([]),[R,L]=(0,l.useState)('pick'),z={title:f,date:y,from:v,to:C,covers:T,areas:a.areas.filter(e=>P.includes(e.id))},F=(0,t.privateFunctionError)(z,x),N=z.areas.length?z.areas.map(e=>({areaId:e.id})):[{}],E=F?0:new Set(N.flatMap(e=>(0,b.bookingsInWindow)(r,[y],v,C,e,e=>a.tables.find(t=>t.name===e)?.areaId)).map(e=>e.id)).size;return(0,w.jsx)(p.Sheet,{visible:!0,title:"Private function",onClose:i,testID:"private-function-sheet",children:'done'===R?(0,w.jsxs)(d.default,{style:{gap:12},accessibilityLiveRegion:"polite",children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:"Private function saved"}),(0,w.jsxs)(p.T,{center:!0,children:[f.trim()," \xb7 ",T," Covers"]}),(0,w.jsx)(p.Muted,{center:!0,children:"Only new bookings are blocked. Existing bookings are kept. Other devices receive the function through venue sync."}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Chosen areas are blocked in CoverCharge only. Website bookings cannot mirror chosen-area blocks yet.':'Saved in CoverCharge. When venue sync is connected, the blocks list shows its Website bookings status.'}),(0,w.jsx)(p.Button,{label:"Done",onPress:i})]}):'check'===R?(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.T,{center:!0,size:22,weight:"bold",colour:m.colours.gold,children:f.trim()}),(0,w.jsxs)(p.T,{center:!0,children:[(0,b.longDate)(y)," \xb7 ",v,"\u2013",C," \xb7 ",T," Covers"]}),(0,w.jsx)(p.T,{center:!0,children:z.areas.length?z.areas.map(e=>e.name).join(', '):'Whole venue'}),(0,w.jsx)($,{line:"Block new bookings only. Existing bookings are kept.",clashes:E}),(0,w.jsx)(p.Muted,{center:!0,children:P.length?'Website bookings cannot mirror chosen-area blocks yet. Other areas remain bookable.':'When venue sync is connected, Website bookings receives this whole-venue booking block. Normal opening hours are unchanged.'}),(0,w.jsx)(p.Button,{testID:"private-function-save",label:"Save private function",onPress:()=>{F||(u.useBlocks.getState().addMany((0,t.privateFunctionBlocks)(z,e,n,(0,s.uuid)(),x)),L('done'),I('Private function saved. Existing bookings kept.'))},disabled:!!F}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Change",onPress:()=>L('pick')})]}):(0,w.jsxs)(d.default,{style:{gap:12},children:[(0,w.jsx)(p.Muted,{center:!0,children:"Whole venue or chosen areas, even on a normally closed day. Existing bookings are never changed."}),(0,w.jsx)(p.Field,{testID:"private-function-name",label:"Function name",accessibilityLabel:"Private function name",value:f,onChangeText:e=>k(e.slice(0,120))}),(0,w.jsx)(p.Field,{testID:"private-function-covers",label:"Expected Covers",accessibilityLabel:"Expected Covers for this private function",value:T,onChangeText:B,keyboardType:"number-pad"}),(0,w.jsx)(W,{min:x,value:y,onPick:j,testID:"private-function-date"}),(0,w.jsx)(p.Field,{testID:"private-function-from",label:"From (24-hour, HH:mm)",accessibilityLabel:"Private function start time, 24-hour HH colon mm",value:v,onChangeText:D}),(0,w.jsx)(p.Field,{testID:"private-function-to",label:"To (24-hour, HH:mm)",accessibilityLabel:"Private function end time, 24-hour HH colon mm",value:C,onChangeText:S}),(0,w.jsx)(p.T,{center:!0,weight:"semibold",children:"Where"}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',justifyContent:'center',gap:6},children:[(0,w.jsx)(p.Chip,{testID:"private-function-whole",label:"Whole venue",selected:!P.length,onPress:()=>M([])}),a.areas.map(e=>(0,w.jsx)(p.Chip,{testID:`private-function-area-${e.id}`,label:e.name,selected:P.includes(e.id),onPress:()=>M(P.includes(e.id)?P.filter(t=>t!==e.id):[...P,e.id])},e.id))]}),P.length?(0,w.jsx)(p.Muted,{center:!0,children:"Chosen areas: CoverCharge only. Website bookings cannot mirror chosen-area blocks yet."}):null,(0,w.jsx)(p.Muted,{center:!0,children:F??'Ready to check. Nothing is saved until you confirm.'}),(0,w.jsx)(p.Button,{testID:"private-function-check",label:"Check and save",disabled:!!F,onPress:()=>L('check')})]})})}function z({b:e,onEdit:t,onRemove:s,locked:o,hint:l}){const n=(0,b.whatText)(e);return(0,w.jsxs)(d.default,{testID:`fb-${e.id}`,style:{borderWidth:1,borderColor:m.colours.border,borderRadius:12,padding:12,gap:4,backgroundColor:m.colours.surface2},accessible:!1,children:[(0,w.jsxs)(p.T,{size:17,weight:"semibold",colour:m.colours.goldLight,children:[(0,b.longDate)(e.date)," \xb7 ",(0,b.rangeText)(e.from,e.to,e.wholeDay)]}),(0,w.jsxs)(p.T,{children:[n,e.reason?` \xb7 ${e.reason}`:'',e.note?` \xb7 ${e.note}`:'']}),e.privateFunction?(0,w.jsx)(p.Muted,{children:e.areaId?'Chosen-area block: CoverCharge only, not mirrored to Website bookings.':`Website bookings: ${(0,f.websiteBlockStatus)(e.wix?.state)}`}):null,e.repeatText?(0,w.jsx)(p.Muted,{children:e.repeatText}):null,(0,w.jsxs)(p.Muted,{size:13,children:["Added by ",e.by||'staff',e.editedBy?` \xb7 changed by ${e.editedBy}`:'']}),(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Edit",accessibilityLabel:`Edit the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-edit-${e.id}`,onPress:t}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Remove",accessibilityLabel:`Remove the block on ${(0,b.longDate)(e.date)}`,accessibilityHint:l,disabled:o,testID:`fb-remove-${e.id}`,onPress:s})]})]})}function F({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,u.useBlocks)(e=>e.blocks),r=(0,g.ymd)(s),c=(0,b.groupByMonth)(a,e,r,(0,g.hm)(s)),h=(0,l.useMemo)(()=>(0,b.ruleRows)(t,r),[t.id,r]),[x,v]=(0,l.useState)(null),[D,C]=(0,l.useState)(null),[S,T]=(0,l.useState)(''),B=(0,j.useBookingWrite)(),$=e=>e.seriesId?a.filter(t=>t.seriesId===e.seriesId&&t.date>=r):[e],P=t=>{const s=t.length>1?`${t.length} blocks removed`:`Block on ${(0,b.longDate)(t[0].date)} removed`;if(!n)return t.forEach(e=>u.useBlocks.getState().remove(e.id,o)),(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),void C(null);(async()=>{for(const e of t){if(!((0,y.isLive)()?await(0,k.displayBlockEdit)(e.id,'remove',{},o):{ok:!0}).ok)return void T('Could not remove it. Try again.');(0,y.isLive)()||u.useBlocks.getState().remove(e.id,o)}(0,f.pushBlocksToWix)(e,t.map(e=>e.id),'remove'),T(`${s}. Bookings are open again for that time.`),I(s),C(null)})()},M=(t,s)=>{if(!n)return u.useBlocks.getState().update(t.id,s,o),void(0,f.pushBlocksToWix)(e,[t.id],'edit');(async()=>{((0,y.isLive)()?await(0,k.displayBlockEdit)(t.id,'edit',s,o):{ok:!0}).ok?((0,y.isLive)()||u.useBlocks.getState().update(t.id,s,o),(0,f.pushBlocksToWix)(e,[t.id],'edit'),T(`Block on ${(0,b.longDate)(s.date??t.date)} changed.`)):T('Could not change it. Try again.')})()},W=[...new Set([...c.map(e=>e.month),...h.map(e=>(0,b.monthLabel)(e.date))])].sort((e,t)=>Date.parse(`1 ${e}`)-Date.parse(`1 ${t}`));return(0,w.jsxs)(d.default,{style:{gap:12},testID:"future-blocks",children:[S?(0,w.jsx)(d.default,{accessibilityLiveRegion:"polite",children:(0,w.jsx)(p.T,{colour:m.colours.goldLight,testID:"fb-msg",children:S})}):null,c.length?null:(0,w.jsx)(p.Muted,{testID:"fb-empty",children:"No blocks coming up. Online and staff bookings are open as normal."}),W.map(e=>{const t=c.find(t=>t.month===e)?.items??[],s=h.filter(t=>(0,b.monthLabel)(t.date)===e);return(0,w.jsxs)(d.default,{style:{gap:8},children:[(0,w.jsx)(p.T,{size:18,weight:"semibold",colour:m.colours.gold,accessibilityRole:"header",children:e}),t.map(e=>(0,w.jsx)(z,{b:e,locked:!B.ok,hint:B.hint,onEdit:()=>{B.ok&&v(e)},onRemove:()=>{B.ok&&C(e)}},e.id)),s.map(e=>(0,w.jsxs)(d.default,{testID:`fb-rule-${e.date}`,style:{borderWidth:1,borderStyle:'dashed',borderColor:m.colours.border,borderRadius:12,padding:10,gap:2},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[(0,b.longDate)(e.date)," \xb7 ",e.name]}),(0,w.jsxs)(p.Muted,{children:[e.text," \xb7 regular rule, set in Settings \u203a Advanced \u203a Regular events"]})]},`${e.name}-${e.date}`))]},e)}),x?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,edit:x,onClose:()=>v(null),onEdit:e=>M(x,e)}):null,D?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>C(null),title:"Remove this block?",testID:"fb-remove-confirm",children:[(0,w.jsx)(p.T,{size:17,children:`${(0,b.longDate)(D.date)}, ${(0,b.rangeText)(D.from,D.to,D.wholeDay)}, ${(0,b.whatText)(D).toLowerCase()}.`}),(0,w.jsx)(p.Muted,{children:"Bookings open again for that time. The removal is kept in the log."}),(0,w.jsx)(p.Button,{testID:"fb-remove-one",label:$(D).length>1?'Remove this date only':'Remove block',onPress:()=>P([D])}),$(D).length>1?(0,w.jsx)(p.Button,{testID:"fb-remove-series",kind:"secondary",label:`Remove all ${$(D).length} in this series`,onPress:()=>P($(D))}):null,(0,w.jsx)(p.Button,{kind:"ghost",label:"Keep it",onPress:()=>C(null)})]}):null]})}function N({rid:e,r:t,now:s,by:o,display:n,wide:i}){const a=(0,j.useBookingWrite)(),[r,c]=(0,l.useState)(null);return(0,w.jsxs)(d.default,{style:{gap:12},testID:"blocks-screen",children:[(0,w.jsx)(p.Muted,{children:"Tip: Block now pauses new bookings today. Add a block closes a future date, a time, an area or some tables, once or every week. Existing bookings are always kept."}),(0,w.jsxs)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[(0,w.jsx)(C,{wide:!0,testID:"blocks-now",label:"Block now",sub:"Today",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('now')}}),(0,w.jsx)(C,{wide:!0,testID:"blocks-add",label:"Add a block",sub:"Future dates",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('add')}})]}),n?null:(0,w.jsx)(C,{wide:!0,testID:"blocks-function",label:"Private function",sub:"Whole venue or chosen areas",disabled:!a.ok,accessibilityHint:a.hint,onPress:()=>{a.ok&&c('function')}}),(0,w.jsx)(p.T,{size:20,weight:"semibold",children:"Future blocks"}),(0,w.jsx)(F,{rid:e,r:t,now:s,by:o,display:n,wide:i}),'now'===r?(0,w.jsx)(M,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null,'function'===r?(0,w.jsx)(L,{rid:e,now:s,by:o,onClose:()=>c(null)}):null,'add'===r?(0,w.jsx)(R,{rid:e,r:t,now:s,by:o,wide:i,onClose:()=>c(null)}):null]})}function E({rid:e,r:t,now:s,by:o,onBack:l}){return(0,x.useBackLayer)(!0,l),(0,w.jsx)(i.default,{visible:!0,animationType:"fade",onRequestClose:l,children:(0,w.jsxs)(d.default,{style:{flex:1,backgroundColor:m.colours.bg,padding:16},testID:"display-blocks-screen",children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(x.BackButton,{onPress:l,testID:"display-blocks-back"}),(0,w.jsx)(p.T,{size:22,weight:"semibold",colour:m.colours.gold,children:"Block bookings"}),(0,w.jsx)(d.default,{style:{width:96}})]}),(0,w.jsx)(r.default,{contentContainerStyle:{paddingBottom:40,maxWidth:900,width:'100%',alignSelf:'center'},children:(0,w.jsx)(N,{rid:e,r:t,now:s,by:o,display:!0,wide:!0})})]})})}},1388,[1389,870,860,34,281,395,402,295,102,874,1026,1029,1390,858,821,1056,794,1391,1392,987,1343,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";function t(t,o){if(t.title.trim().length<2||t.title.trim().length>120)return'Enter a function name (2\u2013120 characters).';const n=new Date(`${t.date}T12:00:00Z`);if(!/^\d{4}-\d{2}-\d{2}$/.test(t.date)||t.date/^([01]\d|2[0-3]):[0-5]\d$/.test(t);return!a(t.from)||!a(t.to)||t.to<=t.from?'Use 24-hour times, with the end after the start.':!/^\d+$/.test(t.covers)||+t.covers<1||+t.covers>99999?'Enter the expected number of Covers.':null}Object.defineProperty(e,'__esModule',{value:!0}),e.privateFunctionError=t,e.privateFunctionBlocks=function(o,n,a,s,c){const d=t(o,c);if(d)throw new Error(d);const u={id:s,title:o.title.trim(),covers:Number(o.covers)};return(o.areas.length?o.areas:[void 0]).map(t=>({rid:n,by:a,date:o.date,from:o.from,to:o.to,reason:'Private event',note:`${u.title} \xb7 ${u.covers} Covers`,privateFunction:u,...t?{areaId:t.id,areaName:t.name}:{}}))}},1389,[]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STEP",{enumerable:!0,get:function(){return r}}),Object.defineProperty(_e,"addDays",{enumerable:!0,get:function(){return u}}),_e.fmt12=i,_e.rangeText=c,_e.openWindow=function(r,o){const a=(0,e.kitchenHoursOn)(r,(0,t.parseYmd)(o));if(!a)return null;let s=(0,t.toMins)(a[1]);for(const e of(0,n.regularEventsOf)(r))(0,n.occursOn)(e,o)&&e.time&&(s=Math.max(s,Math.min(1425,(0,t.toMins)(e.time)+180)));return{from:(0,t.toMins)(a[0]),to:s}},_e.servicesOn=l,_e.serviceOf=function(e,n,r,o){const a=l(e,n,o),s=(0,t.toMins)(r);return a.lunch&&s>=a.lunch.from&&s=a.dinner.from&&s=a.dinner.to?'dinner':a.lunch&&s=e?n:e);if('none'===r.kind||!o||o=h)break}return s},_e.repeatText=function(e,t){if('none'===e.kind)return;const n=t?` until ${p(t)}`:'';return'weekly'===e.kind?`Every ${[...e.days].sort().map(e=>a[e]).join(', ')}${n}`:`Last ${o[e.weekday]} of the month${n}`},Object.defineProperty(_e,"longDate",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"monthLabel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(_e,"scopeText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"whatText",{enumerable:!0,get:function(){return M}}),_e.confirmLine=function(e){const t=e.dates.length?1===e.dates.length?e.dates[0]===e.today?'today':p(e.dates[0]):e.repeat?`on ${e.dates.length} dates (${e.repeat})`:`${p(e.dates[0])} to ${p(e.dates[e.dates.length-1])}`:'no dates';return`Block ${c(e.from,e.to,e.wholeDay)} ${t}, ${y(e)}`},_e.bookingsInWindow=function(e,n,r,o,a,s){const u=new Set(n),i=(0,t.toMins)(r),c=(0,t.toMins)(o);return e.filter(e=>{if(!u.has(e.date)||!['confirmed','pending','seated'].includes(e.status))return!1;const n=(0,t.toMins)(e.time);if(n=c)return!1;const r=(e.table??'').split(/[^A-Za-z0-9]+/).filter(Boolean);return a.tables?.length?r.some(e=>a.tables.includes(e)):!a.areaId||r.some(e=>s?.(e)===a.areaId)})},_e.groupByMonth=function(e,n,r,o){const a=e.filter(e=>e.rid===n&&!e.removedAt&&(e.date>r||e.date===r&&(0,t.toMins)(e.to)>(0,t.toMins)(o))).sort((e,n)=>e.date===n.date?(0,t.toMins)(e.from)-(0,t.toMins)(n.from):e.date{const r=(0,t.parseYmd)(e);return r.setDate(r.getDate()+n),(0,t.ymd)(r)};function i(e){const n=(0,t.toMins)(e),r=Math.floor(n/60)%24;return`${r%12==0?12:r%12}:${String(n%60).padStart(2,'0')}${r<12?'am':'pm'}`}function c(e,t,n){if(n)return'all day';const r=i(e),o=i(t);return r.slice(-2)===o.slice(-2)?`${r.slice(0,-2)}\u2013${o}`:`${r}\u2013${o}`}function l(n,r,o){const a=(0,e.kitchenHoursOn)(n,(0,t.parseYmd)(r));if(!a)return{lunch:null,dinner:null};const s=(0,t.toMins)(a[0]),u=(0,t.toMins)(a[1]),i=1020,c=(e,n)=>{if(!e)return n;const r=Math.max(s,(0,t.toMins)(e[0])),o=Math.min(u,(0,t.toMins)(e[1]));return o>r?{from:r,to:o}:null};return{lunch:c(o?.lunch,si?{from:Math.max(i,s),to:u}:null)}}const d=e=>Math.ceil(e/r)*r;function f(e,t){const n=[];let r=e;for(;r<=t&&n.length<366;)n.push(r),r=u(r,1);return n}const m=(e,n)=>{const r=(0,t.parseYmd)(e);if(r.getDay()!==n)return!1;const o=new Date(r);return o.setDate(r.getDate()+7),o.getMonth()!==r.getMonth()},h=104;const p=e=>{const n=(0,t.parseYmd)(e);return`${o[n.getDay()]} ${n.getDate()} ${s[n.getMonth()]}`},g=e=>{const n=(0,t.parseYmd)(e);return`${s[n.getMonth()]} ${n.getFullYear()}`},y=e=>e.tables?.length?`table${e.tables.length>1?'s':''} ${e.tables.join(', ')}`:e.areaId?e.areaName??'one area':'all areas',M=e=>{const t=y(e);return t.charAt(0).toUpperCase()+t.slice(1)}},1390,[878,858,877]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"wixBlockPushOn",{enumerable:!0,get:function(){return o}}),e.pushBlocksToWix=function(t,n,c){if(!o(t)||!n.length)return;const l=u.useSync.getState();if(!l.venueId||'guest'===l.kind)return;setTimeout(()=>{(0,s.getSupabase)().functions.invoke('wix-blocks-push',{body:{venue_id:l.venueId,block_ids:n.slice(0,120),action:c}}).catch(()=>{})},4e3)},Object.defineProperty(e,"websiteBlockStatus",{enumerable:!0,get:function(){return c}});var t=r(d[0]),n=r(d[1]),s=r(d[2]),u=r(d[3]);const o=s=>!t.IS_ISOLATED_VENUE&&!['souters','kirkmichael','wildings'].includes(s)&&!!n.useFloor.getState().settings[s]?.wixBlockPushOn;const c=t=>(t??'awaiting venue sync').replace(/\bWix\b/gi,'Website bookings')},1391,[5,1029,933,987]); +__d(function(g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"pinProblem",{enumerable:!0,get:function(){return r.pinProblem}}),Object.defineProperty(_e,"ERROR_TEXT",{enumerable:!0,get:function(){return s}}),Object.defineProperty(_e,"errorText",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"useDisplayTiles",{enumerable:!0,get:function(){return u}}),_e.refreshTiles=async function(){const e=await l('display_staff_list',{});Array.isArray(e)&&u.setState({tiles:e,at:Date.now()});const t=await l('display_pin_lengths',{});t&&'object'==typeof t&&!('ok'in t)&&u.setState({lens:t})},_e.refreshManagers=async function(){const e=await l('display_managers',{});Array.isArray(e)&&u.setState({managers:e})},Object.defineProperty(_e,"displayClock",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"displayChangePin",{enumerable:!0,get:function(){return m}}),Object.defineProperty(_e,"displayAddTemp",{enumerable:!0,get:function(){return y}}),_e.setStaffPin=async function(e,n,a=4){const o=_();if(!o)return{ok:!1,error:'Sign in to the venue to set PINs (they are kept on the server only).'};const s=(0,r.pinProblem)(n,a);if(s)return{ok:!1,error:s};try{const{error:r}=await(0,t.getSupabase)().rpc('set_staff_pin',{p_venue:o,p_staff_ref:e,p_pin:n});return r?{ok:!1,error:r.message.replace(/^.*?:\s*(?=The PIN|Pick a PIN)/,'')}:{ok:!0}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},_e.addTempStaff=async function(e){const n=_();if(!n)return{ok:!1,error:'Sign in to the venue to add temp staff (the code is made and kept on the server).'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc('add_temp_staff',{p_venue:n,p_name:e.name,p_dept:e.dept??null,p_rate:e.rate??null,p_until:e.until||null});return a?{ok:!1,error:a.message}:{ok:!0,...r}}catch{return{ok:!1,error:'No connection. Try again in a moment.'}}},Object.defineProperty(_e,"usePinStatus",{enumerable:!0,get:function(){return k}}),_e.refreshPinStatus=async function(){const e=_();if(!e)return;try{const{data:n}=await(0,t.getSupabase)().rpc('staff_pin_status',{p_venue:e});Array.isArray(n)&&k.setState(Object.fromEntries(n.map(e=>[e.staff_ref,{hasPin:e.has_pin,locked:e.locked}])),!0)}catch{}},_e.localTiles=function(e,t){return e.filter(e=>e.active&&e.displayClock&&!(e.temp&&e.tempUntil&&e.tempUntil({ref:e.id,name:e.name,nickname:e.nickname,dept:e.dept,temp:!!e.temp})).sort((e,t)=>Number(!!e.temp)-Number(!!t.temp)||e.name.localeCompare(t.name))},Object.defineProperty(_e,"displayBlockChange",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"displayBlockEdit",{enumerable:!0,get:function(){return h}});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]);const s={wrong:'That PIN is not right. Try again.',locked:'Too many wrong tries. Locked for 15 minutes, or ask a manager to reset your PIN.',nopin:'No PIN set yet. Ask a manager to set one in Staff & roles.',notallowed:'This person can\u2019t clock in at the Display. A manager can turn it on in Staff & roles.',already:'Already clocked in.',notin:'Not clocked in yet.',onbreak:'Already on a break.',notmanager:'Only an owner or manager can add temp staff.',format:'The new PIN must be 4 to 8 digits (6 or more for managers and owners).',weak:'Pick a PIN that is harder to guess (not all the same digit or a run like 1234).',devicelocked:'Too many wrong PINs on this Display. Wait 15 minutes, then try again.',unpaired:'Pair this Display first (Settings \u203a Devices on the Managers app), then try again.',offline:'No connection. Try again in a moment.'},c=(e,t)=>'format'===e&&t?.min?`The new PIN must be ${t.min} to 8 digits.`:s[e??'']??(e||'Something went wrong. Try again.'),p=()=>'device'===n.useSync.getState().kind&&!!n.useSync.getState().venueId;async function l(e,n){if(a.PITCH)return(0,o.pitchClock)(e,n);if(!p())return{ok:!1,error:'unpaired'};try{const{data:r,error:a}=await(0,t.getSupabase)().rpc(e,n);return a?{ok:!1,error:/paired Display/.test(a.message)?'unpaired':a.message}:r}catch{return{ok:!1,error:'offline'}}}const u=(0,e.create)(()=>({tiles:null,managers:[],lens:{}}));const f=(e,t,n,r={})=>l('display_clock',{p_staff_ref:e,p_pin:t,p_action:n,p_break_mins:r.breakMins??null,p_off_rota:!!r.offRota}),m=(e,t,n)=>l('display_change_pin',{p_staff_ref:e,p_old:t,p_new:n}),y=(e,t,n)=>l('display_add_temp',{p_manager_ref:e,p_manager_pin:t,p_name:n.name,p_dept:n.dept??null,p_rate:n.rate??null,p_until:n.until||null}),_=()=>'staff'===n.useSync.getState().kind?n.useSync.getState().venueId:void 0;const k=(0,e.create)(()=>({}));const b=(e,t,n,r,a)=>l('display_block_change',{p_manager_ref:e,p_manager_pin:t,p_block_id:n,p_action:r,p_doc:a}),h=(e,t,n,r)=>l('display_block_edit',{p_block_id:e,p_action:t,p_doc:n,p_by:r})},1392,[846,933,987,1393,2,1394]); +__d(function(g,r,_i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WEAK",{enumerable:!0,get:function(){return t}}),e.pinProblem=function(n,i){if(!/^\d+$/.test(n)||n.length8)return`The PIN must be ${i} to 8 digits.`;if(/^(\d)\1+$/.test(n))return t;const u=t=>n.split('').every((i,u)=>0===u||Number(i)===(Number(n[u-1])+t+10)%10);return u(1)||u(-1)?t:null};const t='Pick a PIN that is harder to guess (not all the same digit or a run like 1234).'},1393,[]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.pitchClock=function(s,o){const c=(new Date).toISOString();switch(s){case'display_staff_list':return[...t.ROSTER.filter(t=>'st-tracy'!==t.id).map(t=>({ref:t.id,name:t.name,dept:t.dept,hasPin:!0,clockedIn:a.has(t.id)})),{ref:'tmp-casey',name:'Casey (temp)',dept:'Front of house',temp:!0,hasPin:!0,clockedIn:!1}];case'display_pin_lengths':return Object.fromEntries(t.ROSTER.map(t=>[t.id,'staff'===t.role?{len:4,min:4}:{len:6,min:6}]));case'display_managers':return t.ROSTER.filter(t=>'staff'!==t.role).map(t=>({ref:t.id,name:t.name}));case'display_add_temp':return{ok:!0,name:String(o.p_name??'Temp'),code:'4071',ref:'tmp-new',temp:!0};case'display_change_pin':return{ok:!0,name:n(o.p_staff_ref)};case'display_clock':{const t=String(o.p_staff_ref),s=String(o.p_action);return'in'===s&&a.add(t),'out'===s&&a.delete(t),{ok:!0,name:n(t),clockedIn:'out'!==s&&('status'!==s||a.has(t)),onBreak:'break_start'===s,hadBreak:!1,onRota:!0,since:c,at:c,ref:t}}default:return{ok:!0}}};var t=r(d[0]);const a=new Set(['st-gordon','st-bisto','st-agate','st-eilidh']),n=a=>t.ROSTER.find(t=>t.id===a)?.name??'Casey (temp)'},1394,[15]); +__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,"DAY_GRAPH_CHROME",{enumerable:!0,get:function(){return j}}),_e.DayGraph=function({todays:e,open:j,close:b,now:w,turnBase:v,blocks:M=[],height:T=150,forecastNote:$,emptyText:D,past:A,closed:k,compact:C=!1,dense:I=!1,bare:z=!1,fill:F=!1,fit:L=!1,tight:S=!1}){const[_,H]=(0,t.useState)(0),[O,B]=(0,t.useState)(0),P=j.getTime()-18e5,E=b.getTime()+36e5,N=(0,t.useMemo)(()=>(0,p.coverCurve)(e,new Date(P),new Date(E),v),[e,P,E,v]),R=60*j.getHours()+j.getMinutes(),X=60*b.getHours()+b.getMinutes(),U=(0,t.useMemo)(()=>(0,f.chartBands)(M,R,X),[M,R,X]),W=new Date(j);W.setHours(0,0,0,0);const G=e=>W.getTime()+6e4*e,V=Math.max(8,...N.map(e=>e.covers)),Y=N.reduce((e,t)=>!t.covers||(0,f.minuteInsideVenueBlock)(60*new Date(t.t).getHours()+new Date(t.t).getMinutes(),U)?e:!e||t.covers>e.covers?{t:t.t,covers:t.covers}:e,null),Z=L&&O?Math.max(24,Math.floor(O)):Math.max(48,T-m.AXIS_BAND),q=I?8:16,J=Math.max(10,_-28-8),K=Math.max(10,Z-q-6),Q=e=>28+(e-P)/(E-P)*J,ee=e=>q+K-e/(1.15*V)*K,te=[];for(let e=new Date(P);e.getTime()<=E;e=new Date(e.getTime()+36e5)){const t=new Date(e);t.setMinutes(0,0,0),t.getTime()>=P&&t.getTime()<=E&&te.push(t.getTime())}const se=_?(0,m.layoutChart)({width:_,height:Z,t0:P,t1:E,hours:te,busiest:k?null:Y}):{hours:[],busiest:null},ie=N.map((e,t)=>`${t?'L':'M'}${Q(e.t).toFixed(1)},${ee(e.covers).toFixed(1)}`).join(' '),ne=F&&ie&&N.length>1?`${ie} L${Q(N[N.length-1].t).toFixed(1)},${ee(0).toFixed(1)} L${Q(N[0].t).toFixed(1)},${ee(0).toFixed(1)} Z`:'',oe=(0,i.coversFour)(e,e[0]?.date??''),le=`Total ${oe.total} ${1===oe.total?'Cover':'Covers'}`,re=e.filter(e=>!['cancelled','noshow'].includes(e.status)).length,ae=se.busiest?.text??(Y&&!k?(0,m.busiestText)(Y.t,Y.covers):''),he=U.map(e=>e.spoken).join('. '),de=`Covers through the day. Open ${(0,u.hm)(j)}. Close ${(0,u.hm)(b)}.${ae?` ${ae}.`:''}${he?` ${he}.`:''}`,ue=s.default.useId().replace(/:/g,'');return(0,y.jsxs)(n.default,{testID:"day-graph",style:[d.look.panel,L?{flex:1,minHeight:0}:null,{overflow:'visible',paddingTop:z?4:I?2:10,paddingBottom:z?2:6,backgroundColor:c.colours.bg}],children:[z?null:C?(0,y.jsxs)(n.default,{style:{alignItems:'center',gap:4,paddingHorizontal:14},children:[(0,y.jsx)(h.T,{center:!0,size:18,weight:"semibold",children:"Covers through the day"}),(0,y.jsx)(h.T,{center:!0,size:14,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}):(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8},children:[(0,y.jsx)(h.T,{size:I?14:15,weight:"semibold",style:{flexShrink:1},children:"Covers through the day"}),(0,y.jsx)(h.T,{size:12,colour:c.colours.muted,testID:"day-graph-parties",children:le})]}),z||S?null:k?$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",center:!0,numberOfLines:2,children:$}):null:(0,y.jsxs)(h.Row,{style:{justifyContent:'space-between',alignItems:'center',paddingHorizontal:14,gap:8,paddingTop:2},children:[(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Open ",(0,u.hm)(j)]}),$?(0,y.jsx)(h.T,{size:11,colour:"#8C8477",numberOfLines:1,style:{flex:1,textAlign:'center'},children:$}):(0,y.jsx)(n.default,{style:{flex:1}}),(0,y.jsxs)(h.T,{size:12,colour:c.colours.goldLight,children:["Close ",(0,u.hm)(b)]})]}),(0,y.jsx)(n.default,{testID:"day-graph-plot",accessible:!0,accessibilityLabel:de,onLayout:e=>{H(e.nativeEvent.layout.width),L&&B(e.nativeEvent.layout.height)},style:L?{flexGrow:1,flexShrink:1,flexBasis:Math.max(48,T-m.AXIS_BAND),minHeight:24,overflow:'hidden'}:{height:Z,minHeight:Z},children:_?(0,y.jsxs)(l.default,{width:_,height:Z,children:[(0,y.jsxs)(o.Defs,{children:[(0,y.jsxs)(o.Pattern,{id:`${ue}-venue`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"1.4"})]}),(0,y.jsxs)(o.Pattern,{id:`${ue}-area`,patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,y.jsx)(o.Rect,{width:"8",height:"8",fill:"#2A2622",fillOpacity:"0.35"}),(0,y.jsx)(o.Line,{x1:"0",y1:"8",x2:"8",y2:"0",stroke:"#6A6258",strokeWidth:"0.8"})]})]}),U.map((e,t)=>(0,y.jsx)(o.Rect,{x:Q(G(e.fromMin)),y:q,width:Math.max(3,Q(G(e.toMin))-Q(G(e.fromMin))),height:K,fill:`url(#${ue}-${e.strength})`},`${e.fromMin}-${t}`)),ne?(0,y.jsx)(o.Path,{d:ne,fill:"#3A2F1E",stroke:"none"}):null,ie?(0,y.jsx)(o.Path,{d:ie,stroke:c.colours.gold,strokeWidth:2.5,fill:"none"}):null,k?null:[j,b].map((e,t)=>(0,y.jsx)(o.Line,{x1:Q(e.getTime()),x2:Q(e.getTime()),y1:q,y2:q+K,stroke:c.colours.goldLight,strokeWidth:1.5,strokeDasharray:"4,4"},`service-${t}`)),se.busiest?(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:se.busiest.x+se.busiest.w/2,y:se.busiest.y+se.busiest.h-2,fill:c.colours.gold,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:se.busiest.text}):null,re?null:(0,y.jsx)(o.Text,{fontFamily:"Poppins_500Medium",x:28+J/2,y:q+K/2,fill:c.colours.muted,fontSize:(0,x.soutersFont)(13),textAnchor:"middle",children:D??'No bookings yet today'})]}):null}),(0,y.jsxs)(n.default,{testID:"day-graph-axis",style:{minHeight:m.AXIS_BAND,flexShrink:0,position:'relative',justifyContent:'center',paddingBottom:2},children:[(0,y.jsx)(n.default,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{opacity:0,alignSelf:'flex-start'},children:(0,y.jsx)(h.T,{size:m.AXIS_FONT,numberOfLines:1,children:"20"})}),se.hours.map(e=>{const t=Math.min(Math.max(e.w,40),Math.max(e.w,_)),s=e.x+e.w/2-t/2,i=Math.max(0,Math.min(Math.max(0,_-t),s));return(0,y.jsx)(n.default,{pointerEvents:"none",style:{position:'absolute',left:i,width:t,top:0,bottom:0,alignItems:i>s+.5?'flex-start':it.fromMin-n.fromMin||t.toMin-n.toMin||(t.strength===n.strength?0:'area'===t.strength?-1:1));const u=[];for(const t of c){const n=u[u.length-1];n&&n.strength===t.strength&&t.fromMin<=n.toMin?(n.toMin=Math.max(n.toMin,t.toMin),n.spoken.includes(t.spoken)||(n.spoken=`${n.spoken}. ${t.spoken}`)):u.push({...t})}return u},e.blockedHours=function(t){const n=new Set;for(const o of t)if('venue'===o.strength)for(let t=Math.floor(o.fromMin/60);60*t=30&&n.add(t)}return[...n].sort((t,n)=>t-n)},e.minuteInsideVenueBlock=function(t,n){return n.some(n=>'venue'===n.strength&&t>=n.fromMin&&t{const n=/^(\d{1,2}):(\d{2})/.exec(t);return n?60*Number(n[1])+Number(n[2]):null},n=t=>`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`;function o(t,o,s){const a=`${n(o)} to ${n(s)}`,c=t.privateFunction?.title?.trim();if(!t.areaId&&!t.tables?.length){const t=`Bookings blocked ${a}`;return{strength:'venue',spoken:c?`${t}, ${c}`:t}}const u=`${t.areaName?.trim()||(t.tables?.length?'Tables':'Area')} blocked ${a}`;return{strength:'area',spoken:c?`${c}, ${u}`:u}}},1396,[]); +__d(function(g,r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.coverCurve=function(s,c,n,a){const u=s.filter(t=>!['cancelled','noshow'].includes(t.status)).map(o=>{const s=(0,t.startOf)(o).getTime();return{s:s,e:s+6e4*(0,t.durOf)(o,a),n:o.partySize}}),f=[];for(let t=c.getTime();t<=n.getTime();t+=o)f.push({t:t,covers:u.reduce((o,s)=>t>=s.s&&tt.covers));if(!o)return[];const s=[];return t.forEach((c,n)=>{const a=t.slice(Math.max(0,n-3),n+4);c.covers<.6*o||c.coverst.covers))||s.some(t=>Math.abs(t.from-c.t)<36e5)||s.push({from:c.t,to:c.t,covers:c.covers})}),s.slice(0,3)},e.quietOf=function(t,o,s){const c=Math.max(0,...t.map(t=>t.covers)),n=Math.max(2,.25*c),a=[];let u=null;const f=t.filter(t=>t.t>=o&&t.t<=s);return f.forEach((t,o)=>{const s=t.covers<=n;s&&null===u&&(u=t.t);const c=o===f.length-1;if((!s||c)&&null!==u){const o=t.t;o-u>=18e5&&a.push({from:u,to:o}),u=null}}),a.sort((t,o)=>o.to-o.from-(t.to-t.from)).slice(0,3).sort((t,o)=>t.from-o.from)};var t=r(d[0]);const o=9e5},1397,[1105]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANCEL_TINT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CANCEL_BORDER",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"CANCEL_INK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"CANCEL_MUTED",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"cancelWhen",{enumerable:!0,get:function(){return d}}),e.cancelledBy=u,e.cancelItem=b,e.cancellationsFor=function(n,t,o){return n.filter(n=>n.date===t&&('cancelled'===n.status||'noshow'===n.status)).sort((n,t)=>n.time.localeCompare(t.time)||n.name.localeCompare(t.name)).map(n=>b(n,o(n)))},Object.defineProperty(e,"cancellationsHeading",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"cancellationsEmpty",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"cancellationsCounts",{enumerable:!0,get:function(){return f}});var n=r(_d[0]),t=r(_d[1]);const o=n=>n?n.split('+').map(n=>n.trim()).filter(Boolean):[],i='#17140F',a='#6B5A35',l='#F3E7CC',c='#B8AA8A',s={online:'Website',phone:'Phone','in-person':'In person','walk-in':'Walk-in',email:'Email','third-party':'Third party'},d=(n,t)=>{if(!n)return null;const o=new Date(n);if(Number.isNaN(o.getTime()))return null;const i=o.toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'});return o.toLocaleDateString('en-CA',{timeZone:'Europe/London'})===t?i:`${o.toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short',timeZone:'Europe/London'})}, ${i}`};function u(n){const t=n;if('noshow'===n.status)return t.cancelled?.by?`Marked no-show by ${t.cancelled.by}`:'Marked no-show';if(t.cancelled?.by)return t.cancelled.by;const o=!!t.wix?.status&&/CANCEL|DECLIN/i.test(t.wix.status);return o&&t.wix?.archived?'Cancelled and archived in Website bookings':o?'Cancelled in Website bookings':(n.tags??[]).some(n=>n.endsWith(': deposit not paid'))||'PAYMENT_INFORMATION_PENDING'===t.wix?.status?'Website booking not finished (deposit not paid)':t.wix?.archived?'Archived in Website bookings':'Not recorded'}function b(i,a){const l=i,c=o(i.table??l.cancelled?.table??void 0),b=c.length?`Table ${(0,n.tableNumbers)(c.join('+'))}`:'No table',p=`${i.partySize} ${1===i.partySize?'person':'people'}`,h=d(l.cancelled?.at??(l.wix?l.wix.updatedDate:null),i.date),f=u(i),w=i.walkIn?'Walk-in':s[i.source??'']??(l.wix?'Website':'Not recorded'),y=(0,t.allergyLine)(i),C='noshow'===i.status,N=`${C?'No-show':'Cancelled'}: ${a}, ${y?`allergy noted: ${y}, `:''}${p}, was ${i.time}, ${b.toLowerCase()}. ${f}${h?` at ${h}`:''}.`;return{id:i.id,date:i.date,name:a,people:p,time:i.time,table:b,tables:c,walkIn:!!i.walkIn,by:f,when:h,source:w,notes:(i.notes??'').trim(),allergy:y,spoken:N,kind:C?'noshow':'cancelled'}}const p=n=>`Cancellations & no-shows ${n}`,h=(n="today")=>`No cancellations or no-shows ${n}.`,f=n=>{const t=n.filter(n=>'noshow'===n.kind).length,o=n.length-t;return`${o} ${1===o?'cancellation':'cancellations'} \xb7 ${t} ${1===t?'no-show':'no-shows'}`}},1398,[860,1375]); +__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.CancellationsSection=function({items:e,dayWord:b="today",testID:y="display-cancellations"}){const[p,C]=(0,l.useState)(null),j=(0,s.cancellationsHeading)(e.length);return(0,u.jsxs)(o.default,{testID:y,style:{marginTop:14,borderRadius:12,backgroundColor:s.CANCEL_TINT,borderWidth:1,borderColor:s.CANCEL_BORDER,padding:10,gap:6},children:[(0,u.jsxs)(o.default,{accessible:!0,accessibilityRole:"header",accessibilityLabel:e.length?`${j}: ${(0,s.cancellationsCounts)(e)}. Not counted in Covers.`:`Cancellations and no-shows: none ${b}.`,style:{alignItems:'center',gap:2},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:c.colours.gold,center:!0,testID:"cancellations-head",children:j}),e.length?(0,u.jsx)(n.T,{size:14,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-counts",children:(0,s.cancellationsCounts)(e)}):null]}),e.length?e.map(e=>(0,u.jsxs)(t.default,{testID:`cancel-row-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.spoken,accessibilityHint:"Opens the details. Read only.",onPress:()=>C(e),dataSet:{centreExempt:'list-row'},style:({pressed:e})=>({minHeight:56,paddingVertical:8,paddingHorizontal:8,borderRadius:8,borderTopWidth:1,borderColor:'rgba(214,180,106,0.18)',backgroundColor:e?'#241F16':'transparent'}),children:[(0,u.jsxs)(o.default,{style:{flexDirection:'row',gap:10,alignItems:'flex-start'},children:[(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{width:58,textDecorationLine:'line-through'},children:e.time}),(0,u.jsx)(n.T,{size:17,weight:"semibold",colour:s.CANCEL_INK,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:e.name}),(0,u.jsx)(o.default,{testID:`cancel-kind-${e.id}`,style:{paddingHorizontal:8,paddingVertical:2,borderRadius:999,borderWidth:1,borderColor:'noshow'===e.kind?c.colours.amber:s.CANCEL_BORDER},children:(0,u.jsx)(n.T,{size:13,weight:"semibold",colour:'noshow'===e.kind?c.colours.amber:s.CANCEL_MUTED,children:'noshow'===e.kind?'No-show':'Cancelled'})}),e.allergy?(0,u.jsx)(o.default,{style:{paddingTop:1},children:(0,u.jsx)(h.AllergyIcon,{text:e.allergy,size:20,colour:"#D6A23A",ink:"#17140F",testID:`cancel-allergy-${e.id}`})}):null]}),(0,u.jsxs)(n.T,{size:15,colour:s.CANCEL_MUTED,style:{marginLeft:68,marginTop:2,flexWrap:'wrap'},children:[e.people," \xb7 ",e.table," \xb7 ",e.by,e.when?` \xb7 ${e.when}`:'']})]},e.id)):(0,u.jsx)(n.T,{size:15,colour:s.CANCEL_MUTED,center:!0,testID:"cancellations-empty",children:(0,s.cancellationsEmpty)(b)}),p?(0,u.jsx)(x,{c:p,onClose:()=>C(null)}):null]})},_e.CancelDetail=x;var l=r(d[0]),t=e(r(d[1])),o=e(r(d[2])),n=r(d[3]),s=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]);function b({k:e,v:l}){return(0,u.jsxs)(o.default,{accessible:!0,accessibilityLabel:`${e}: ${l}`,style:{flexDirection:'row',gap:10,paddingVertical:6,borderBottomWidth:1,borderColor:c.colours.hairline},children:[(0,u.jsx)(n.T,{size:16,colour:c.colours.muted,style:{width:130},children:e}),(0,u.jsx)(n.T,{size:16,style:{flex:1,minWidth:0,flexWrap:'wrap'},children:l})]})}function x({c:e,onClose:l}){return(0,u.jsxs)(n.Sheet,{visible:!0,onClose:l,title:`${'noshow'===e.kind?'No-show':'Cancelled'} \xb7 ${e.name}`,maxWidth:560,testID:"cancel-detail",children:[(0,u.jsxs)(o.default,{testID:"cancel-detail-body",style:{gap:2},children:[(0,u.jsx)(b,{k:"Name",v:e.name}),(0,u.jsx)(b,{k:"Party",v:e.people}),e.allergy?(0,u.jsx)(b,{k:"Allergies",v:e.allergy}):null,(0,u.jsx)(b,{k:"Was booked for",v:`${e.date?`${new Date(`${e.date}T12:00:00`).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})}, `:''}${e.time}`}),(0,u.jsx)(b,{k:"Table",v:e.table}),(0,u.jsx)(b,{k:'noshow'===e.kind?'No-show':'Cancelled by',v:e.by}),(0,u.jsx)(b,{k:"When",v:e.when??'Not recorded'}),(0,u.jsx)(b,{k:"Booked by",v:e.source}),(0,u.jsx)(b,{k:"Notes",v:e.notes||'None'})]}),(0,u.jsx)(n.T,{size:14,colour:c.colours.muted,center:!0,children:"Read only. Not counted in Covers. Phone numbers stay in the Managers app."})]})}},1399,[34,402,102,794,1398,821,1356,25]); +__d(function(g,_r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DueToday=function({shifts:e,att:t,staff:h,today:p,now:x,compact:j}){const y=60*x.getHours()+x.getMinutes(),I=e.filter(e=>e.date===p&&e.published).sort((e,t)=>e.start-t.start),b=e=>t.filter(t=>t.staffId===e&&t.date===p&&t.in).sort((e,t)=>t.in.localeCompare(e.in))[0],w=I.filter(e=>!b(e.staffId)).map(e=>({s:e,late:y>60*e.start+10})),T=I.filter(e=>{const t=b(e.staffId);return t&&!t.out}).sort((e,t)=>e.end-t.end),z=t.filter(e=>e.date===p&&e.in&&!e.out&&!I.some(t=>t.staffId===e.staffId)),D=I.filter(e=>b(e.staffId)?.out).length,$=j?4:6,S=e=>c(h.find(t=>t.id===e)?.name),M=(e,t,n,r,f)=>(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',gap:8,paddingVertical:3},children:[(0,u.jsx)(s.StaffAvatar,{id:t,size:j?24:28,ring:!1}),(0,u.jsx)(o.T,{size:14,weight:"medium",numberOfLines:1,style:{flex:1},children:n}),(0,u.jsx)(o.T,{size:13,weight:"semibold",colour:'amber'===f?a.colours.amber:'ok'===f?a.colours.ok:a.colours.goldLight,children:r})]},e),_=(e,t,s,n,r,f)=>(0,u.jsxs)(l.default,{testID:r,style:{flex:1,minWidth:0,gap:2},children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'baseline',gap:6,marginBottom:2},children:[(0,u.jsx)(o.T,{size:11,weight:"semibold",colour:a.colours.gold,style:{letterSpacing:1.6},children:e}),t?(0,u.jsx)(o.T,{size:11,colour:a.colours.muted,children:t}):null,f?(0,u.jsxs)(o.T,{size:11,weight:"semibold",colour:a.colours.amber,children:["\xb7 ",f]}):null]}),s.length?s.slice(0,$):(0,u.jsx)(o.T,{size:13,colour:"#857D6E",children:n}),s.length>$?(0,u.jsxs)(o.T,{size:12,colour:a.colours.muted,children:["+",s.length-$," more"]}):null]});return(0,u.jsxs)(l.default,{testID:"due-today",style:[n.look.panel,{padding:12,paddingHorizontal:14,gap:8}],children:[(0,u.jsxs)(l.default,{style:{flexDirection:'row',alignItems:'center',justifyContent:'space-between'},children:[(0,u.jsx)(o.T,{size:15,weight:"semibold",children:"Team today"}),(0,u.jsx)(o.T,{size:12,colour:a.colours.muted,children:I.length?`${T.length+z.length} on now${D?` \xb7 ${D} finished`:''}`:''})]}),I.length||z.length?(0,u.jsxs)(l.default,{style:{flexDirection:'row',gap:16},children:[_('DUE IN',w.length,w.map(({s:e,late:t})=>M(`in-${e.id}`,e.staffId,S(e.staffId),f(e.start),t?'amber':'muted')),'Everyone is in','due-in',w.some(e=>e.late)?`${w.filter(e=>e.late).length} late`:void 0),_('DUE OUT',T.length+z.length,[...T.map(e=>M(`out-${e.id}`,e.staffId,S(e.staffId),f(e.end),y>=60*e.end?'amber':'ok')),...z.map(e=>M(`x-${e.id}`,e.staffId,S(e.staffId),`in ${(0,r.hm)(new Date(e.in))}`,'muted'))],'Nobody on yet','due-out')]}):(0,u.jsx)(o.T,{size:13,colour:a.colours.muted,children:"No published shifts for today. Build and publish the rota in Managers \u203a Rota to see who\u2019s due in and out here."})]})},_r(d[0]);var e,t=_r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=_r(d[2]),o=_r(d[3]),n=_r(d[4]),r=_r(d[5]),a=_r(d[6]),u=_r(d[7]);const f=e=>`${String(Math.floor(e)).padStart(2,'0')}:${String(Math.round(e%1*60)).padStart(2,'0')}`,c=e=>(e??'Staff').replace(' (example)','').split(' ')[0]},1400,[34,102,925,794,1189,858,821,25]); +__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,"ACTION_GOLD",{enumerable:!0,get:function(){return f}}),_e.BigAction=function({label:e,onPress:l,testID:u,size:x="l",block:h,premium:p,disabled:b,accessibilityHint:y}){const{width:w}=(0,s.default)(),j='l'===x&&w>=520,D='s'===x,I=h?{alignSelf:'stretch'}:p?{flexGrow:1,flexBasis:140,minWidth:140,maxWidth:'100%'}:{flexGrow:1,flexShrink:1,minWidth:0,flexBasis:j?200:150,maxWidth:j?300:260};return(0,c.jsx)(n.default,{testID:u,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:y,accessibilityState:{disabled:!!b},disabled:b,onPress:l,style:({pressed:e})=>p?{...I,minHeight:D?52:j?78:62,borderRadius:D?14:20,...D?{paddingVertical:4}:{},alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?12:8,paddingHorizontal:D?6:j?20:10,...t.look.primary(e)}:{...I,minHeight:j?76:62,borderRadius:18,backgroundColor:e?'#B8904F':f,borderWidth:2,borderColor:'#E8C98F',alignItems:'center',justifyContent:'center',flexDirection:'row',gap:j?10:6,paddingHorizontal:j?18:8,shadowColor:'#000',shadowOpacity:.35,shadowRadius:8,shadowOffset:{width:0,height:3}},children:(0,c.jsx)(o.T,{size:D?16:j?p?25:26:18,weight:p?'semibold':'bold',colour:t.look.onPrimary,center:D,numberOfLines:D?2:void 0,style:p?{flexShrink:1,letterSpacing:.2}:{flexShrink:1},children:e})})},_e.FrontDoorBar=function({primary:e,left:t,right:n,oneRow:s,testID:o="front-door-bar"}){const f=(e,t)=>e?(0,c.jsx)(l.default,{style:{flex:s?1:void 0,flexDirection:'row',flexWrap:'wrap',gap:8,alignItems:'center',justifyContent:s?t?'flex-end':'flex-start':'center'},children:e}):null,u=(0,c.jsx)(l.default,{testID:"primary-actions",style:{flexWrap:'wrap',flexDirection:'row',gap:12,justifyContent:'center',flexGrow:s?0:1,flexBasis:s?520:void 0,flexShrink:1,maxWidth:'100%'},children:e});return s?(0,c.jsxs)(l.default,{testID:o,style:{flexDirection:'row',alignItems:'center',gap:12},children:[f(t),u,f(n,!0)]}):(0,c.jsxs)(l.default,{testID:o,style:{gap:8},children:[u,t||n?(0,c.jsxs)(l.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:8,justifyContent:'center',alignItems:'center'},children:[t,n]}):null]})},r(d[0]);var t=r(d[1]),n=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),o=r(d[5]),c=r(d[6]);const f='#CFA45F'},1401,[34,1189,402,102,426,794,25]); +__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.DisplayClockButton=function(){const[e,t]=(0,l.useState)(!1);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(i.default,{testID:"display-clock-btn",accessibilityRole:"button",accessibilityLabel:"Clock in or out",onPress:()=>t(!0),style:({pressed:e})=>({...r.look.quiet(e),flexGrow:1}),children:(0,x.jsx)(u.T,{size:15,weight:"semibold",colour:h.colours.goldLight,children:"Clock in / out"})}),e?(0,x.jsx)(I,{onClose:()=>t(!1)}):null]})},_e.PinPad=w,_e.DisplayClockSheet=I,_e.TempCode=T,_e.AddTempForm=S;var t=_r(_d[0]),n=_r(_d[1]),o=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),l=_r(_d[5]),i=e(_r(_d[6])),d=e(_r(_d[7])),c=e(_r(_d[8])),u=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),m=_r(_d[12]),f=_r(_d[13]),b=_r(_d[14]),k=_r(_d[15]),y=_r(_d[16]),x=_r(_d[17]);const j=()=>(new Date).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),D={in:'clocked in',break_start:'started a break',break_end:'ended the break',out:'clocked out'};function w({title:e,sub:t,onDone:n,error:o,busy:s,length:r=4,min:c}){const[p,m]=(0,l.useState)('');(0,l.useEffect)(()=>{o&&m('')},[o]);const f=null!=c,b=f?8:r,k=e=>{if(s)return;const t=(p+e).slice(0,b);m(t),f||t.length!==r||(n(t),setTimeout(()=>m(''),300))},y=f?Math.max(c??4,p.length):r,j=(e,t,n)=>(0,x.jsx)(i.default,{testID:n,accessibilityRole:"button",accessibilityLabel:'\u232b'===e?'Delete':'OK'===e?'Done':e,onPress:t,style:({pressed:e})=>({width:84,height:72,borderRadius:14,alignItems:'center',justifyContent:'center',borderWidth:1,borderColor:'rgba(255,255,255,0.10)',backgroundColor:e?'rgba(201,162,74,0.25)':'#1B1A18'}),children:(0,x.jsx)(u.T,{size:28,weight:"semibold",children:e})},n);return(0,x.jsxs)(d.default,{testID:"pin-pad",style:{alignItems:'center',gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",children:e}),t?(0,x.jsx)(u.Muted,{children:t}):null,(0,x.jsx)(d.default,{testID:"pin-dots",style:{flexDirection:'row',gap:14},children:Array.from({length:y},(e,t)=>t).map(e=>(0,x.jsx)(d.default,{style:{width:18,height:18,borderRadius:9,borderWidth:2,borderColor:h.colours.gold,backgroundColor:e(0,x.jsx)(u.Row,{gap:10,children:e.map(e=>j(e,()=>k(e),`pin-key-${e}`))},e.join())),(0,x.jsxs)(u.Row,{gap:10,children:[f?j('OK',()=>{if(s||!f||p.length<(c??4))return;n(p),setTimeout(()=>m(''),300)},'pin-ok'):(0,x.jsx)(d.default,{style:{width:84}}),j('0',()=>k('0'),'pin-key-0'),j('\u232b',()=>m(p.slice(0,-1)),'pin-back')]})]})]})}function I({onClose:e,initial:t}){const{width:n}=(0,c.default)(),o=(0,p.useOwner)(e=>e.staff),r=(0,k.useDisplayTiles)(e=>e.tiles),I=(0,k.useDisplayTiles)(e=>e.managers),C=(0,k.useDisplayTiles)(e=>e.lens),P=e=>C[e]?.len??4,v=(0,y.useSync)(e=>'device'===e.kind)||s.PITCH,[B,M]=(0,l.useState)(t??{s:'tiles'}),[$,N]=(0,l.useState)(null),[A,L]=(0,l.useState)(!1),R=(0,l.useRef)(Date.now());(0,l.useEffect)(()=>{(0,k.refreshTiles)(),(0,k.refreshManagers)()},[]),(0,l.useEffect)(()=>{R.current=Date.now();const t=setInterval(()=>{Date.now()-R.current>6e4&&e()},5e3);return()=>clearInterval(t)},[B,e]),(0,l.useEffect)(()=>{if('done'!==B.s)return;const t=setTimeout(e,5e3);return()=>clearTimeout(t)},[B,e]);const Y=(0,l.useMemo)(()=>r??(0,k.localTiles)(o,j()),[r,o]),_=v?I:o.filter(e=>e.active&&('owner'===e.role||'manager'===e.role)&&!e.name.includes('(example)')).map(e=>({ref:e.id,name:e.name})),E=e=>{N(null),M(e)},F=async(e,t,n,o={})=>{L(!0);const s=await(0,k.displayClock)(e.ref,t,n,o);if(L(!1),!s.ok)return void N((0,k.errorText)(s.error));const r=s.at?(0,f.hm)(new Date(s.at)):'';(0,b.notify)({id:`display-clock-${e.ref}`,icon:'\ud83d\udd52',kicker:'VIA DISPLAY',title:`${e.name} ${D[n]}${r?` at ${r}`:''}`,body:'',tone:'normal',timeoutMs:6e3}),(0,k.refreshTiles)(),E({s:'done',text:`${e.name} ${D[n]}${r?` at ${r}`:''}. Logged via Display.`})},z=async(e,t)=>{L(!0);const n=await(0,k.displayClock)(e.ref,t,'status');L(!1),n.ok?E({s:'actions',t:e,pin:t,st:n}):N((0,k.errorText)(n.error))};let O='Clock in / out',K=null;if('tiles'===B.s){const e=n>=1100?4:n>=760?3:2;K=(0,x.jsxs)(d.default,{testID:"clock-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"Tap your name, then type your PIN. This tablet is at the venue, so no location check is needed."}),v?null:(0,x.jsx)(u.Banner,{kind:"info",title:"Pair this Display first",children:"The names show, but clocking in needs this Display paired to the venue (Managers app \u203a Settings \u203a Devices)."}),Y.length?null:(0,x.jsx)(u.Muted,{children:"Nobody is set up to clock in here yet. A manager can turn on \u201cCan clock in at the Display\u201d for a person in Staff & roles."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:12},children:Y.map(t=>(0,x.jsxs)(i.default,{testID:`clock-tile-${t.ref}`,accessibilityRole:"button",accessibilityLabel:`${t.name}${t.temp?', temp':''}`,onPress:()=>E({s:'pin',t:t}),style:({pressed:n})=>({width:100/e-2+"%",minHeight:110,borderRadius:16,padding:14,justifyContent:'center',gap:6,borderWidth:1,borderColor:t.clockedIn?h.colours.gold:'rgba(255,255,255,0.10)',backgroundColor:n?'rgba(201,162,74,0.20)':'#1B1A18'}),children:[(0,x.jsx)(u.T,{size:24,weight:"semibold",children:(0,p.staffLabel)({name:t.name,nickname:t.nickname??void 0})}),(0,x.jsxs)(u.Row,{gap:6,wrap:!0,children:[t.dept?(0,x.jsx)(u.Muted,{children:t.dept}):null,t.temp?(0,x.jsx)(u.Badge,{kind:"gold",label:"Temp"}):null,t.clockedIn?(0,x.jsx)(u.Badge,{kind:"neutral",label:"In"}):null]})]},t.ref))}),(0,x.jsx)(u.Button,{testID:"clock-add-temp",kind:"secondary",label:"Add temp staff (manager PIN)",onPress:()=>E({s:'mgr'})})]})}else if('pin'===B.s){const e=B.t;O=`Hello ${e.name}`,K=(0,x.jsx)(w,{length:P(e.ref),title:"Type your PIN",sub:e.temp?'Temp staff: use the 4-digit code your manager gave you.':'Forgotten it? A manager can reset it in Staff & roles.',error:$,busy:A,onDone:t=>{z(e,t)}})}else if('actions'===B.s){const{t:e,pin:t,st:n}=B;O=(0,p.staffLabel)({name:e.name,nickname:e.nickname??void 0});const o=n.since?Math.round((Date.now()-new Date(n.since).getTime())/6e4):0;K=(0,x.jsxs)(d.default,{testID:"clock-actions",style:{gap:12},children:[(0,x.jsxs)(u.Muted,{children:[n.clockedIn?`Clocked in since ${n.since?(0,f.hm)(new Date(n.since)):'\u2014'}${n.onBreak?' \xb7 on a break now':''}.`:'Not clocked in.'," Tip: this is logged as \u201cvia Display\u201d."]}),$?(0,x.jsx)(u.T,{colour:h.colours.amber,children:$}):null,n.clockedIn?null:(0,x.jsx)(u.Button,{testID:"clock-do-in",label:"Clock in",disabled:A,onPress:()=>n.onRota?void F(e,t,'in'):E({s:'offrota',t:e,pin:t})}),n.clockedIn&&!n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-start",kind:"secondary",label:"Start break",disabled:A,onPress:()=>{F(e,t,'break_start')}}):null,n.clockedIn&&n.onBreak?(0,x.jsx)(u.Button,{testID:"clock-do-break-end",kind:"secondary",label:"End break",disabled:A,onPress:()=>{F(e,t,'break_end')}}):null,n.clockedIn?(0,x.jsx)(u.Button,{testID:"clock-do-out",label:"Clock out",disabled:A,onPress:()=>n.hadBreak||n.onBreak?void F(e,t,'out'):E({s:'break',t:e,pin:t,worked:o})}):null,(0,x.jsx)(u.Button,{testID:"clock-change-pin",kind:"ghost",label:e.temp?'Change my code':'Change my PIN',onPress:()=>E({s:'newpin',t:e,pin:t})})]})}else if('offrota'===B.s){const{t:t,pin:n}=B;O='Do you want to sign in?',K=(0,x.jsxs)(d.default,{testID:"clock-offrota",style:{gap:12},children:[(0,x.jsx)(u.T,{size:18,children:"Should you be on the rota?"}),(0,x.jsx)(u.Muted,{children:"You\u2019re not on today\u2019s published rota. If you\u2019re working, clock in and your manager gets a note."}),(0,x.jsx)(u.Button,{testID:"clock-offrota-yes",label:"Yes, clock me in",disabled:A,onPress:()=>{F(t,n,'in',{offRota:!0})}}),(0,x.jsx)(u.Button,{testID:"clock-offrota-no",kind:"secondary",label:"No, just visiting",onPress:e})]})}else if('break'===B.s){const{t:e,pin:t,worked:n}=B;O='Did you take a break? If so, how long?',K=(0,x.jsxs)(d.default,{testID:"forgot-break-prompt",style:{gap:10},children:[(0,x.jsx)(u.Muted,{children:"No break was recorded on this shift. Pick how long it was, or No break. Your manager can change it later in Hours."}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:m.DEFAULT_BREAK_OPTIONS.map(o=>(0,x.jsx)(u.Chip,{testID:`forgot-break-${o}`,label:(0,m.breakLabel)(o),disabled:o>=n&&n>0,onPress:()=>{F(e,t,'out',{breakMins:o})}},o))}),(0,x.jsx)(u.Button,{testID:"forgot-break-none",kind:"secondary",label:"No break",onPress:()=>{F(e,t,'out',{breakMins:0})}}),n>360?(0,x.jsx)(u.Muted,{children:"UK workers are generally entitled to a 20-minute rest break when working more than 6 hours."}):null]})}else if('newpin'===B.s){const{t:e,pin:t,first:n}=B;O=e.temp?'Change my code':'Change my PIN';const o=e.temp?4:(W=e.ref,C[W]?.min??4);K=(0,x.jsx)(w,{min:o,title:n?'Type it again, then OK':`Type a new PIN (${o} to 8 digits), then OK`,sub:"Pick something that isn\u2019t 1234 or your birthday.",error:$,busy:A,onDone:async s=>{if(!n){const n=(0,k.pinProblem)(s,o);return n?void N(n):void E({s:'newpin',t:e,pin:t,first:s})}if(s!==n)return N('They didn\u2019t match. Start again.'),void M({s:'newpin',t:e,pin:t});L(!0);const r=await(0,k.displayChangePin)(e.ref,t,s);L(!1),r.ok?E({s:'done',text:`${e.name}, your ${e.temp?'code':'PIN'} is changed.`}):N((0,k.errorText)(r.error,r))}})}else if('done'===B.s)O='Done',K=(0,x.jsxs)(d.default,{testID:"clock-done",style:{gap:12},children:[(0,x.jsx)(u.T,{size:20,weight:"semibold",colour:h.colours.goldLight,children:B.text}),(0,x.jsx)(u.Button,{label:"Close",onPress:e})]});else if('mgr'===B.s)O='Add temp staff',K=(0,x.jsxs)(d.default,{testID:"clock-mgr-tiles",style:{gap:12},children:[(0,x.jsx)(u.Muted,{children:"A manager or owner taps their name and types their own PIN to add a temp."}),(0,x.jsx)(d.default,{style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:_.map(e=>(0,x.jsx)(u.Chip,{testID:`clock-mgr-${e.ref}`,label:e.name,onPress:()=>E({s:'mgrpin',m:e})},e.ref))}),_.length?null:(0,x.jsx)(u.Muted,{children:"No manager has a PIN yet. Set one in Staff & roles first."}),(0,x.jsx)(u.Button,{kind:"secondary",label:"Back",onPress:()=>E({s:'tiles'})})]});else if('mgrpin'===B.s){const e=B.m;O='Manager PIN',K=(0,x.jsx)(w,{length:P(e.ref),title:`${e.name}: type your PIN`,error:$,busy:A,onDone:t=>E({s:'temp',m:e,pin:t})})}else if('temp'===B.s){const{m:e,pin:t}=B;O='Add temp staff',K=(0,x.jsx)(S,{noPay:!0,busy:A,error:$,onSubmit:async n=>{L(!0);const o=await(0,k.displayAddTemp)(e.ref,t,n);if(L(!1),!o.ok)return N((0,k.errorText)(o.error)),void('wrong'!==o.error&&'locked'!==o.error||M({s:'mgrpin',m:e}));(0,k.refreshTiles)(),E({s:'code',name:o.name??n.name,code:o.code??''})}})}else'code'===B.s&&(O='Temp added',K=(0,x.jsx)(T,{name:B.name,code:B.code,onClose:e}));var W;return(0,x.jsx)(u.Sheet,{visible:!0,onClose:e,title:O,maxWidth:'tiles'===B.s?1100:560,testID:"display-clock-sheet",children:(0,x.jsx)(d.default,{onTouchStart:()=>{R.current=Date.now()},children:K})})}function T({name:e,code:t,onClose:n}){return(0,x.jsxs)(d.default,{testID:"temp-code",style:{gap:12,alignItems:'center'},children:[(0,x.jsxs)(u.T,{children:["Tell ",e," this code now. It won\u2019t be shown again."]}),(0,x.jsx)(u.T,{size:48,weight:"bold",colour:h.colours.goldLight,style:{letterSpacing:12},children:t}),(0,x.jsx)(u.Muted,{children:"They tap their name on the Display and type it to clock in, start and end breaks and clock out. It doesn\u2019t work in any phone app. Change it any time on the Display, or reset it in Staff & roles."}),(0,x.jsx)(u.Button,{label:"Done",onPress:n})]})}const C=['Kitchen','Front of house','Bar'],P=e=>{const t=new Date;return t.setDate(t.getDate()+e),t.toLocaleDateString('en-CA',{timeZone:'Europe/London'})};function S({onSubmit:e,busy:s,error:r,noPay:i}){const[c,p]=(0,l.useState)(''),[m,f]=(0,l.useState)(null),[b,k]=(0,l.useState)(''),[y,j]=(0,l.useState)(''),D=b.trim()?Number(b.replace(/[\xa3,\s]/g,'')):null,w=null!=D&&(!Number.isFinite(D)||D<0||D>200),I=!!y&&(!/^\d{4}-\d{2}-\d{2}$/.test(y)||y(0,x.jsx)(u.Chip,{testID:`temp-dept-${e}`,label:e,selected:m===e,onPress:()=>f(m===e?null:e)},e))}),i?null:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(u.T,{weight:"semibold",children:"Hourly rate (optional)"}),(0,x.jsx)(o.TextInput,{testID:"temp-rate",value:b,onChangeText:k,placeholder:"\xa3 per hour, e.g. 12.21",placeholderTextColor:"#777",keyboardType:"decimal-pad",style:T}),w?(0,x.jsx)(u.T,{colour:h.colours.amber,children:"Check the hourly rate."}):null]}),(0,x.jsx)(u.T,{weight:"semibold",children:"End date (optional)"}),(0,x.jsx)(u.Row,{wrap:!0,gap:6,children:[['No end date',''],['Today',P(0)],['In 1 week',P(7)],['In 2 weeks',P(14)]].map(([e,t])=>(0,x.jsx)(u.Chip,{testID:`temp-until-${e}`,label:e,selected:y===t,onPress:()=>j(t)},e))}),(0,x.jsx)(o.TextInput,{testID:"temp-until",accessibilityLabel:"Until (DD/MM/YYYY)",...(0,n.slashBox)(y,j),placeholder:"DD/MM/YYYY",keyboardType:"numbers-and-punctuation",maxLength:10,placeholderTextColor:"#777",style:T}),I?(0,x.jsxs)(u.T,{colour:h.colours.amber,children:["Use a date from today on, like ",P(7),"."]}):null,(0,x.jsx)(u.Muted,{children:"After the end date they are hidden from the Display and staff lists (kept, not deleted, so their hours stay)."}),r?(0,x.jsx)(d.default,{testID:"temp-error",children:(0,x.jsx)(u.T,{colour:h.colours.amber,children:r})}):null,(0,x.jsx)(u.Button,{testID:"temp-save",label:"Add and show the code",disabled:s||!c.trim()||w||I,onPress:()=>e({name:c.trim(),dept:m,rate:D,until:y||null})})]})}},1402,[828,1063,827,2,1189,34,402,102,426,794,821,891,998,858,1001,1392,987,25]); +__d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useDisplayNotices=function(d,D=!0){const y=(0,s.useNotifs)(t=>t.items.map(t=>`${t.id}:${t.updatedAt??''}`).join()),S=(0,f.useDisplayTiles)(t=>t.at??0);(0,t.useEffect)(()=>{if(!D)return;const t=()=>{const t=p(),D=new Date(t).toLocaleDateString('en-CA',{timeZone:'Europe/London'}),y=o.useOwner.getState().staff,S=f.useDisplayTiles.getState().tiles??(0,f.localTiles)(y,D),v=y.map(t=>({id:t.id,role:t.role,level:t.level,job:t.job,department:t.dept,active:t.active})),$=v.filter(s=>!1!==s.active&&(0,u.shiftNow)(s.id,t).on).map(t=>t.id),h=s.useNotifs.getState();for(const o of h.items)if(o.rid===d)for(const f of S){const u=`sched:${o.id}:${f.ref}`;if(o.removed||o.paused||!o.sendBy.inApp||!(0,c.isRecipient)(o,f.ref,v,$)){(0,l.dismissNotice)(u);continue}const{due:D,forDate:y}=(0,c.notifDue)(o,t),S=n.useReminders.getState().done.find(t=>t.reminderId===o.id&&t.forDate===y),I=`sched:${o.id}:${y}:${f.ref}`;!D||S||(h.snooze[I]??0)>t?(0,l.dismissNotice)(u):(0,l.notify)({id:u,icon:'\ud83d\udd14',kicker:`FOR ${f.name.toUpperCase()}`,title:`${f.name}: ${o.title}`,body:o.message,testID:'display-sched-notice',timeoutMs:null,actions:[{label:'Done',testID:'display-sched-done',onPress:()=>n.useReminders.getState().markDone({rid:d,reminderId:o.id,forDate:y,at:new Date(p()).toISOString(),staffRef:f.ref,staffName:`${f.name} (via Display)`})},{label:'Later',kind:'ghost',testID:'display-sched-later',onPress:()=>s.useNotifs.getState().setSnooze(I,p()+9e5)}]})}};t();const y=setInterval(t,2e4);return()=>clearInterval(y)},[d,y,S,D])};var t=r(_d[0]),s=r(_d[1]),o=r(_d[2]),n=r(_d[3]),d=r(_d[4]),c=r(_d[5]),l=r(_d[6]),f=r(_d[7]),u=r(_d[8]);const p=()=>{try{return(0,d.nowFrom)(d.useStore.getState().clock).getTime()}catch{return Date.now()}}},1403,[34,1036,891,1009,831,1037,1001,1392,1094]); +__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,"codeFromText",{enumerable:!0,get:function(){return x}}),_e.DisplayPairing=function(){const{height:e}=(0,u.default)(),_=(0,c.useSync)(e=>e.mode),m=(0,c.useSync)(e=>e.message),[T,E]=(0,o.useState)(!1),[R,y]=(0,o.useState)(!1),[j,D]=(0,o.useState)(''),[f,A]=(0,o.useState)(!1),[N,M]=(0,o.useState)(''),[z,P]=(0,o.useState)(''),k=async e=>{const t=x(e);if(t.length<6)return void M('Type the code exactly as shown in Managers \u2192 Displays.');A(!0),M('');const r=await(0,c.pairWithCode)(t);A(!1),r.ok?(P(`Paired with ${r.venueName}`),E(!1),D(''),setTimeout(()=>P(''),4e3)):M(r.error)};(0,o.useEffect)(()=>{I.START_PAIR&&(E(!0),D(I.START_PAIR),k(I.START_PAIR))},[]);const U=(0,S.useScreensaverAsleep)(e=>e.asleep),C=(0,S.useDisplayToolsH)(e=>e.h),O='unpaired'===_,v=T||O&&!R&&!I.START_PAIR;return(0,b.jsxs)(b.Fragment,{children:[z?(0,b.jsx)(l.default,{testID:"pair-ok",style:{position:'absolute',top:12,alignSelf:'center',zIndex:960,padding:10,borderRadius:10,backgroundColor:h.colours.okBg,borderWidth:1,borderColor:h.colours.ok},children:(0,b.jsx)(p.T,{size:14,children:z})}):null,!O||v||U?null:(0,b.jsx)(n.default,{testID:"pair-banner",accessibilityRole:t.IS_SOUTERS?'button':void 0,accessibilityLabel:t.IS_SOUTERS?'Not paired. Tap to pair this display.':void 0,onPress:()=>E(!0),style:{position:'absolute',bottom:Math.max(72,C+7),right:8,zIndex:900,paddingHorizontal:12,paddingVertical:6,borderRadius:999,backgroundColor:(0,r.soutersSurface)('#2A2114'),borderWidth:1,borderColor:h.colours.gold,...t.IS_SOUTERS?{minHeight:44,minWidth:44,justifyContent:'center'}:{}},children:(0,b.jsx)(p.T,{size:13,colour:h.colours.gold,children:"Not paired \xb7 tap to pair this display"})}),v?(0,b.jsx)(l.default,{testID:"pair-screen",style:{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:980,backgroundColor:t.IS_QUEUED_VENUE||t.IS_ABBOTSFORD||t.IS_KIRKTON?h.colours.bg:t.IS_GREENSIDE?'#1A1A1A':t.IS_WILDINGS?'#272A2F':(0,r.soutersSurface)('rgba(8,7,5,0.97)'),alignItems:'center',justifyContent:'center',padding:24},children:(0,b.jsxs)(l.default,{testID:"pair-panel",style:{width:'100%',maxWidth:460,gap:12,alignItems:'stretch'},children:[t.IS_QUEUED_VENUE?(0,b.jsx)(s.RestaurantHero,{rid:t.VENUE_RID,size:Math.min(220,Math.max(120,.25*e))}):t.IS_ABBOTSFORD?(0,b.jsx)(s.RestaurantHero,{rid:"abbotsford",size:Math.min(220,Math.max(120,.25*e))}):t.IS_KIRKTON?(0,b.jsx)(s.RestaurantHero,{rid:"kirkton",size:Math.min(220,Math.max(120,.25*e))}):t.IS_GREENSIDE?(0,b.jsx)(s.RestaurantHero,{rid:"greenside",size:Math.min(220,Math.max(120,.25*e))}):t.IS_WILDINGS?(0,b.jsx)(s.RestaurantHero,{rid:"wildings",size:Math.min(220,Math.max(120,.25*e))}):t.IS_ISOLATED_VENUE?(0,b.jsx)(s.RestaurantBrand,{rid:t.VENUE_RID,sub:"Display"}):null,(0,b.jsx)(p.T,{size:26,weight:"bold",center:!0,accessibilityRole:"header",children:"Pair this display"}),t.IS_ISOLATED_VENUE?(0,b.jsx)(p.Muted,{center:!0,children:"No table plan or bookings have been added. The venue\u2019s authorised manager must create a pairing code after setup."}):null,(0,b.jsx)(p.Muted,{center:!0,children:"In the Managers app, open Settings \u2192 Displays and make a pairing code. Type it here, or open the pairing link on this tablet. No login needed."}),m?(0,b.jsx)(p.T,{size:14,colour:h.colours.gold,center:!0,children:m}):null,(0,b.jsx)(p.Field,{testID:"pair-code",label:"Pairing code (or link)",value:j,onChangeText:D,autoCapitalize:"characters",autoCorrect:!1,placeholder:"e.g. ABCDE 23456",style:{textAlign:'center',letterSpacing:1}}),N?(0,b.jsx)(l.default,{testID:"pair-error",children:(0,b.jsx)(p.T,{size:14,colour:h.colours.red,center:!0,children:N})}):null,(0,b.jsx)(p.Button,{testID:"pair-go",label:f?'Pairing\u2026':'Pair',disabled:f||!j.trim(),onPress:()=>k(j)}),(0,b.jsx)(p.Button,{kind:"secondary",label:"Not now (use this tablet\u2019s own data)",onPress:()=>{E(!1),y(!0)}})]})}):null]})};var t=_r(d[0]),r=_r(d[1]),s=_r(d[2]),o=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),l=e(_r(d[6])),u=e(_r(d[7])),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),S=_r(d[11]),I=_r(d[12]),b=_r(d[13]);const x=e=>{const t=e.match(/[?&#]pair=([A-Za-z0-9 -]{6,})/);return(t?t[1]:e).toUpperCase().replace(/[^A-Z0-9]/g,'')}},1404,[5,828,873,34,236,402,102,426,987,821,794,1351,1405,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"START_PAIR",{enumerable:!0,get:function(){return t}});const t=(()=>{try{if('undefined'==typeof window||!window.location)return null;const t=new URL(window.location.href),n=new URLSearchParams(t.hash.replace(/^#/,'')),c=t.searchParams.get('pair')||n.get('pair');if(!c)return null;t.searchParams.delete('pair'),n.delete('pair');const o=n.toString();return window.history.replaceState(null,'',t.pathname+(t.search?t.search:'')+(o?`#${o}`:'')),c}catch{return null}})()},1405,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1406,[30,34,872,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1407,[30,34,872,25]); +__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 f}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]),c=r(d[4]);function f(){return'owner'!==u.APP_VARIANT?(0,c.jsx)(t.Redirect,{href:u.ENTRY[u.APP_VARIANT]}):(0,c.jsx)(n.OwnerApp,{})}},1408,[30,34,1409,872,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.OwnerApp=function(){return null}},1409,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),f=r(d[3]),u=r(d[4]);function c(){return(0,n.canShow)('staff')?(0,u.jsx)(f.StaffApp,{}):(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1410,[30,34,872,1411,25]); +__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.StaffApp=function(){return(0,ke.jsx)(Z.StaffAppCtx.Provider,{value:!0,children:(0,ke.jsx)(Te,{})})};var s=_r(d[0]),t=_r(d[1]),o=_r(d[2]),r=_r(d[3]),i=_r(d[4]),l=_r(d[5]),n=_r(d[6]),c=_r(d[7]),u=_r(d[8]),h=_r(d[9]),f=_r(d[10]),p=_r(d[11]),b=_r(d[12]),y=_r(d[13]),x=_r(d[14]),k=_r(d[15]),j=_r(d[16]),w=_r(d[17]),v=_r(d[18]),S=_r(d[19]),C=_r(d[20]),T=_r(d[21]),M=_r(d[22]),R=_r(d[23]),A=_r(d[24]),B=_r(d[25]),P=_r(d[26]),I=_r(d[27]),O=_r(d[28]),L=e(_r(d[29])),W=e(_r(d[30])),z=e(_r(d[31])),E=e(_r(d[32])),H=e(_r(d[33])),D=_r(d[34]),_=_r(d[35]),N=_r(d[36]),F=_r(d[37]),U=_r(d[38]),V=_r(d[39]),$=_r(d[40]),G=_r(d[41]),Y=_r(d[42]),Q=_r(d[43]),J=_r(d[44]),K=_r(d[45]),q=_r(d[46]),X=_r(d[47]),Z=_r(d[48]),ee=_r(d[49]),se=_r(d[50]),te=_r(d[51]),ae=_r(d[52]),oe=_r(d[53]),re=_r(d[54]);_r(d[55]);var ie=_r(d[56]),le=_r(d[57]),ne=_r(d[58]),de=_r(d[59]),ce=_r(d[60]),ue=_r(d[61]),he=_r(d[62]),fe=_r(d[63]),pe=_r(d[64]),ge=_r(d[65]),me=_r(d[66]),be=_r(d[67]),ye=_r(d[68]),xe=_r(d[69]),ke=_r(d[70]);const je=pe.ROSTER.find(e=>'chef'===e.app)?.id,we=[{id:'home',label:'Home',icon:'home'},{id:'clock',label:'Clock',icon:'clock'},{id:'rota',label:'Rota',icon:'bookings'},{id:'chat',label:'Chat',icon:'chat'},{id:'me',label:'Me',icon:'user'}],ve={home:'Today',clock:'Clock in / out',rota:'Rota, swaps & leave',chat:'Staff chat',me:'Me'},Se=[{id:'mytips',title:'Tips',sub:'The venue tip pot and today\u2019s tips'},{id:'reviews',title:'Reviews',sub:'Published reviews, newest first'},{id:'bookings',title:'Bookings',sub:'Any day, back or forward: tables, Covers, Unseat and Undo'},{id:'loyalty',title:'Stamp card',sub:'Find a guest, add a stamp or use a reward'},{id:'guests',title:'Guest profiles',sub:'Look a guest up: visits, Covers, allergies they told us, preferences'},{id:'giftcards',title:'Gift cards',sub:'Check a balance, take it off the bill, mark paid at the till'},{id:'tableorders',title:'Table orders',sub:'Orders from guests\u2019 phones at the table: accept, mark served or cancel'},{id:'soldout',title:'Sold out',sub:'What\u2019s run out today. Mark sold out or Back on; shows on the Display'},{id:'board',title:'Question board',sub:'Ask the team anything anonymously, and vote'},{id:'recipecards',title:'Recipe cards',sub:'Signed-off dishes: photo, ingredients, method and allergens (read-only)'},{id:'avatar',title:'My avatar',sub:'Your space-age avatar, or create one from a photo'},{id:'cashup',title:'Cash up',sub:'End-of-night takings: take a picture of the taking sheet or upload a spreadsheet (if a manager has switched it on for you)'},{id:'haccp',title:'Food safety checks',sub:'Record fridge, freezer, cooking and other checks (say or type)'},{id:'accidents',title:'Accident book',sub:'Report an accident or near miss; see your own entries'},{id:'mypay',title:'My hours & pay',sub:'Shifts, paid hours and estimated pay'},{id:'timesheets',title:'My timesheets',sub:'Your clock-ins, breaks and any changes'},{id:'orderlists',title:'Order lists',sub:'Add what\u2019s running low (Alsons drinks, Cash and carry)'},{id:'phone',title:'Turn on alerts',sub:'Get your reminders on this phone, even with the app closed'},{id:'suppliers',title:'Suppliers',sub:'Contacts and order days (if your manager allows)'},{id:'privacy',title:'Privacy & location',sub:'What CoverCharge for Staff stores about you'}],Ce=[{id:'mgr-plan',title:'Tables & areas',sub:'Edit the table plan, areas, seats and joined tables'},{id:'mgr-times',title:'Booking times',sub:'Kitchen hours, table times and Covers per booking slot'},{id:'mgr-bookings',title:'Bookings (manager)',sub:'New, edit and cancel bookings, walk-ins, seat, move and finish tables, deposit status'},{id:'mgr-clear',title:'Tables to clear',sub:'Tables waiting to be cleared; mark them cleared'},{id:'mgr-blocks',title:'Block bookings',sub:'Block now, add a block, close the garden'},{id:'mgr-allergy',title:'Allergy checks',sub:'Every allergy order\u2019s sign-offs and the allergen log'},{id:'mgr-stock',title:'Tracked stock',sub:'What\u2019s counted live through service; add or change items'},{id:'mgr-clock',title:'Who\u2019s clocked in',sub:'Today\u2019s clock-ins for the team (read only)'},{id:'mgr-swaps',title:'Shift swaps',sub:'Approve swaps and cover, or give a shift to someone else'}];function Te(){const{r:e,rid:i,me:n,meId:S,today:C,now:T}=(0,Z.useCtx)(3e4);(0,I.useReviewAlerts)(i),(0,ue.useStaffTipsNotice)(i,C);const M=(0,Z.useSignedIn)(),R=M?.ownerAccess&&'owner'!==M.role?'owner privileges':M?.managerAccess&&'staff'===M.role?'manager privileges':'',he=(0,Z.useShiftManager)(),fe=(0,xe.useSync)(e=>e.perms),pe=Ce.filter(e=>'mgr-swaps'===e.id?fe.includes('rota.swap'):'mgr-times'!==e.id||(fe.includes('bookings.settings')||fe.includes('*')));(0,y.useSoldOutLink)(!0,n);(0,U.useOwner)(e=>e.staff);const Te=(0,U.useOwner)(e=>e.staffCanViewSuppliers),[Ae,Be]=(0,A.useState)('home'),[Pe,Ie]=(0,A.useState)(null),[Oe,Le]=(0,A.useState)(!1),We=(0,A.useRef)(null);(0,A.useEffect)(()=>{(0,Z.ensureAttendance)(C,T),(0,$.ensureChat)(T)},[C]),globalThis.__ccNow=T.getTime();const ze=(0,$.useChatUnread)().total,Ee=(0,A.useRef)({t:'home',s:null});Ee.current={t:Ae,s:Pe};const He=(0,A.useRef)([]),De=(0,A.useCallback)((e,s=null)=>{const t=Ee.current;t.t===e&&t.s===s||(He.current=[...He.current,{...t,y:Ue.leave()}].slice(-30),Ue.restore(0)),Be(e),Ie(s)},[]),Ne=(0,A.useCallback)(()=>{if((0,u.runBackLayer)())return!0;const e=Ee.current;let s=He.current.pop();for(;s&&s.t===e.t&&s.s===e.s;)s=He.current.pop();if(!s&&'home'===e.t&&!e.s)return!1;const t=s??{t:'home',s:null};return Ue.leave(),Be(t.t),Ie(t.s),Ue.restore(t.y??0),!0},[]);(0,u.useWebBack)(Ne);const Fe=(0,u.useInnerBackShown)();(0,A.useEffect)(()=>{w.PITCH&&(globalThis.__pitchGo=De,globalThis.__pitchClock={setClockServer:j.setClockServer,markClockSent:j.markClockSent,markClockUnsent:j.markClockUnsent})},[De]),(0,A.useEffect)(()=>(0,k.startForegroundRefresh)(),[]),(0,Y.useShiftReminders)({rid:i,staffId:S,name:n,onStartBreak:()=>De('clock')}),(0,Q.useScheduledNotices)({rid:i,staffId:M?.id??'',name:n,onOpen:e=>{'orderlists'===e&&De('me','orderlists'),'chat'===e&&De('chat')}}),(0,J.useOffRotaPrompt)({rid:i,staffId:M?.id??''});const Ue=(0,c.useScrollMemory)(We),Ve=(0,A.useCallback)((e,s=null)=>'chat'===e?De('chat'):'clock'===s?De('clock'):'rota'===s?De('rota'):s&&Se.some(e=>e.id===s)?De('me',s):'blocks'===s&&he?De('me','mgr-blocks'):void De('home'===e?'home':'me'),[De,he]);(0,A.useEffect)(()=>{const e=L.default.addEventListener('hardwareBackPress',Ne);return()=>e.remove()},[Ne]);const $e='me'===Ae&&Pe?Se.find(e=>e.id===Pe)??(he?pe.find(e=>e.id===Pe):void 0):void 0,Ge=(0,X.useOrderLists)(e=>e.settings[i]?.allowStaff??!0),Ye=Se.filter(e=>('suppliers'!==e.id||Te)&&('orderlists'!==e.id||Ge||M&&'staff'!==M.role));(0,A.useEffect)(()=>{U.useOwner.getState().staffAs&&U.useOwner.setState({staffAs:void 0})},[]);(0,H.default)().width;return(0,ke.jsxs)(D.SafeAreaView,{style:{flex:1,backgroundColor:V.colours.bg},edges:['top','left','right','bottom'],children:[(0,ke.jsxs)(E.default,{style:{position:'relative',paddingHorizontal:14,paddingTop:6,paddingBottom:8,borderBottomWidth:1,borderColor:V.colours.border,gap:6},children:[(0,ke.jsx)(E.default,{style:{position:'absolute',top:4,right:6,zIndex:5,flexDirection:'row',alignItems:'center'},children:(0,ke.jsx)(F.VoiceSlot,{size:44})}),(0,ke.jsx)(E.default,{testID:"header-me-wrap",style:{alignItems:'flex-start',minHeight:44,justifyContent:'center',maxWidth:'70%'},children:(0,ke.jsx)(W.default,{testID:"header-me",accessibilityRole:"button",accessibilityLabel:`${(0,r.privateClockVenue)(i)?`Signed in as ${n}`:'Signed in as'}${R?`, ${R}`:''}`,onPress:()=>Le(!0),hitSlop:6,style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:22,paddingHorizontal:10,paddingVertical:4,maxWidth:'100%',minHeight:44,justifyContent:'center'},children:(0,ke.jsxs)(_.Row,{gap:6,style:{justifyContent:'flex-start'},children:[(0,ke.jsx)(be.StaffAvatar,{id:S,size:24,ring:!1}),(0,ke.jsxs)(E.default,{style:{flexShrink:1},children:[(0,ke.jsxs)(_.T,{size:13,weight:"semibold",colour:V.colours.gold,numberOfLines:1,style:{flexShrink:1},children:[n.replace(' (example)',''),M?'':' (preview)'," \u25be"]}),R?(0,ke.jsx)(_.Muted,{center:!1,size:10,numberOfLines:1,children:R}):null]})]})})}),(0,ke.jsx)(N.VenueHeaderBlock,{rid:e.id,name:e.name,badge:"STAFF",place:"Front of House"+(e.location?` \xb7 ${e.location.split(',').slice(0,2).join(',')}`:'')})]}),(0,ke.jsxs)(z.default,{ref:We,...Ue.props,contentContainerStyle:{padding:14,paddingBottom:16,gap:12,width:'100%',maxWidth:760,alignSelf:'center'},keyboardShouldPersistTaps:"handled",children:[(0,ke.jsx)(u.BackTitleRow,{back:!('home'===Ae&&!Pe||Fe),onBack:Ne,title:$e?$e.title:ve[Ae]}),'home'===Ae&&he?(0,ke.jsx)(ae.ManagerFeaturesNote,{}):null,'home'===Ae&&M&&'staff'!==M.role&&!he&&'undefined'!=typeof window?(0,ke.jsxs)(E.default,{testID:"manager-access-banner",style:{borderWidth:1,borderColor:V.colours.gold,borderRadius:12,padding:10,gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"You have manager access"}),(0,ke.jsx)(_.Muted,{children:"The Manager app has everything here plus bookings, the rota, staff and settings."}),(0,ke.jsx)(W.default,{accessibilityRole:"button",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)},style:{alignSelf:'flex-start',borderWidth:1,borderColor:V.colours.gold,borderRadius:14,paddingHorizontal:12,paddingVertical:5,minHeight:44,justifyContent:'center'},children:(0,ke.jsx)(_.T,{size:14,colour:V.colours.gold,children:"Open the Managers app \u203a"})})]}):null,'home'===Ae&&M?(0,ke.jsx)(v.MyTasksToday,{rid:i,staffId:M.id,name:M.name,onShift:(0,Y.shiftNow)(M.id,T.getTime()).on}):null,'home'===Ae?(0,ke.jsx)(Me,{go:Ve}):null,'clock'===Ae?(0,ke.jsx)(ce.ClockInOut,{}):null,'rota'===Ae?(0,ke.jsx)(ce.Rota,{}):null,'chat'===Ae?(0,ke.jsx)($.Chat,{go:Ve}):null,'me'!==Ae||$e?null:(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.border,backgroundColor:V.colours.surface,overflow:'hidden'},children:Ye.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),he?(0,ke.jsxs)(E.default,{testID:"manager-features",style:{gap:6},children:[(0,ke.jsx)(_.T,{weight:"semibold",colour:V.colours.gold,children:"Manager features"}),(0,ke.jsx)(E.default,{style:{borderRadius:14,borderWidth:1,borderColor:V.colours.gold,backgroundColor:V.colours.surface,overflow:'hidden'},children:pe.map((e,s)=>(0,ke.jsx)(W.default,{testID:`audit-page-${e.id}`,accessibilityRole:"button",accessibilityLabel:e.title,onPress:()=>De('me',e.id),style:({pressed:e})=>({padding:12,borderTopWidth:s?1:0,borderColor:V.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,ke.jsxs)(_.Row,{style:{justifyContent:'space-between'},children:[(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"medium",children:e.title}),(0,ke.jsx)(_.Muted,{children:e.sub})]}),(0,ke.jsx)(_.T,{colour:V.colours.muted,children:"\u203a"})]})},e.id))}),(0,ke.jsx)(ae.ManagerFeaturesAbout,{})]}):null,Te?null:(0,ke.jsx)(_.Muted,{children:"Suppliers are hidden: your manager hasn\u2019t shared them with staff."}),(0,ke.jsxs)(_.Muted,{center:!0,children:["Staff app \xb7 ",x.APP_VERSION," \xb7 ",'live'===xe.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]}),he&&$e?.id.startsWith('mgr-')?(0,ke.jsxs)(Z.ShiftMgrScope.Provider,{value:!0,children:['mgr-plan'===$e.id?(0,ke.jsx)(s.TablePlan,{}):null,'mgr-times'===$e.id?(0,ke.jsx)(t.StaffBookingTimes,{}):null,'mgr-bookings'===$e.id?(0,ke.jsx)(G.Bookings,{}):null,'mgr-clear'===$e.id?(0,ke.jsx)(ae.TablesToClear,{rid:i}):null,'mgr-blocks'===$e.id?(0,ke.jsx)(ee.BlocksPage,{}):null,'mgr-allergy'===$e.id?(0,ke.jsx)(se.AllergenSignOffLog,{}):null,'mgr-stock'===$e.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(te.TrackedStockPage,{}),(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')})]}):null,'mgr-clock'===$e.id?(0,ke.jsx)(ae.ClockOverview,{today:C,now:T}):null,'mgr-swaps'===$e.id?(0,ke.jsx)(ae.SwapApprovals,{today:C,me:n}):null]}):null,'loyalty'===$e?.id?(0,ke.jsx)(h.StaffLoyalty,{venue:e.name}):null,'guests'===$e?.id?(0,ke.jsx)(f.GuestProfiles,{me:n.replace(' (example)',''),manager:!1}):null,'bookings'===$e?.id?(0,ke.jsx)(G.Bookings,{}):null,'giftcards'===$e?.id?(0,ke.jsx)(p.GiftCardsPage,{me:n.replace(' (example)','')}):null,'tableorders'===$e?.id?(0,ke.jsx)(l.StaffTableOrders,{rid:i,me:n.replace(' (example)','')}):null,'soldout'===$e?.id?(0,ke.jsx)(b.SoldOutList,{rid:i,by:n.replace(' (example)','')}):null,'board'===$e?.id?(0,ke.jsx)(O.QuestionBoard,{rid:i,today:C,manager:!1,by:""}):null,'recipecards'===$e?.id?(0,ke.jsx)(B.RecipeCards,{rid:e.id,actor:{name:n,role:'staff'},mode:"read"}):null,'avatar'===$e?.id?(0,ke.jsx)(ye.AvatarMaker,{meId:S,me:n}):null,'cashup'===$e?.id?(0,ke.jsx)(Re,{rid:i,today:C,meId:S,me:n}):null,'haccp'===$e?.id?(0,ke.jsx)(me.HaccpLog,{mode:"staff",me:n,meId:S,now:T}):null,'accidents'===$e?.id?(0,ke.jsx)(ge.AccidentBook,{app:"staff",me:n,meId:S,now:T,seeAll:!1}):null,'mypay'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(le.MyHoursPay,{staffId:S})]}):null,'mytips'===$e?.id?(0,ke.jsx)(ue.MyTips,{}):null,'reviews'===$e?.id?(0,ke.jsx)(P.ReviewsSection,{rid:i,mode:"read",venueName:e.name}):null,'timesheets'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(ne.MyPeriods,{staffId:S}),(0,ke.jsx)(ce.Timesheets,{})]}):null,'orderlists'===$e?.id?(0,ke.jsx)(K.OrderListsScreen,{rid:i,today:C,editor:!!M&&'staff'!==M.role&&!he,who:{id:S,name:n.replace(' (example)','')}}):null,'phone'===$e?.id?(0,ke.jsx)(q.PhoneAlerts,{}):null,'suppliers'===$e?.id?Te?(0,ke.jsx)(de.Suppliers,{}):(0,ke.jsx)(_.Muted,{children:"Your manager hasn\u2019t shared suppliers with staff."}):null,'privacy'===$e?.id?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,r.privateClockVenue)(i)?(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(_.T,{size:14,children:"Location is checked only when you choose Clock in at the pub. Only a pass or fail is saved with the clock-in time, or an audited manager override."}),(0,ke.jsx)(_.T,{size:14,children:"Your position, accuracy and distance are never saved. There are no location trails, background/arrival checks, clock-out checks or break checks."})]}):(0,ke.jsxs)(ke.Fragment,{children:[" ",(0,ke.jsx)(_.T,{size:14,children:"\u2022 Location is checked when you tap Clock in, Clock out, Start break or End break, and (if you allowed location) while the app is open to ask if you want to clock in when you\u2019re at the venue but not on the rota. Never in the background."}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Each clock record keeps the location reading, how accurate it was, whether it was inside the venue area, and the time. Managers can see these."})]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 You see only your own hours, pay estimates and tips. Managers see the team\u2019s."}),(0,ke.jsxs)(_.T,{size:14,children:["\u2022 Chat messages stay within ",e.name,"\u2019s team."]}),(0,ke.jsx)(_.T,{size:14,children:"\u2022 Pay figures are estimates before tax and deductions; your payslip is the official record."})]}):null]}),(0,ke.jsx)(ie.BottomTabs,{background:(0,o.soutersSurface)('#0d0d0d'),active:Ae,onPress:e=>De(e),tabs:we.map(e=>({id:e.id,label:e.label,icon:e.icon,badge:'chat'===e.id&&ze?{text:String(ze),bg:V.colours.red}:null}))}),(0,ke.jsx)(_.Sheet,{visible:Oe,onClose:()=>Le(!1),title:"Signed in as",children:M?(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsxs)(_.Row,{gap:10,children:[(0,ke.jsx)(be.StaffAvatar,{id:M.id,size:48}),(0,ke.jsxs)(E.default,{style:{flex:1},children:[(0,ke.jsx)(_.T,{weight:"semibold",children:M.name}),(0,ke.jsx)(_.Muted,{children:(0,re.levelJob)(M.level??'Staff',M.job)})]})]}),(0,ke.jsx)(_.Muted,{children:"Signed in with your personal link. This phone remembers you."}),he?(0,ke.jsx)(_.Muted,{children:"Manager features are on for you in this app."}):null,'staff'===M.role||he?null:(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Managers",onPress:()=>{const e=(0,re.appUrl)('owner');e&&window.location.assign(e)}}),M.id===je?(0,ke.jsx)(_.Button,{kind:"secondary",label:"Back to CoverCharge for Head Chef",onPress:()=>{const e=(0,re.appUrl)('chef');e&&window.location.assign(e)}}):null]}):(0,ke.jsxs)(E.default,{style:{gap:8},children:[(0,ke.jsx)(_.Muted,{children:"Not signed in: this is a preview. Open your personal link, or paste it here, to sign in as yourself."}),(0,ke.jsx)(oe.SignInWithLink,{})]})})]})}function Me({go:e}){const{rid:s,today:t}=(0,Z.useCtx)(3e4),o=(0,fe.useTravelDay)('staff',t);return(0,ke.jsxs)(E.default,{style:{gap:10},children:[(0,ke.jsx)(n.WhoBar,{}),(0,ke.jsx)(fe.DayBar,{app:"staff",today:t}),o?null:(0,ke.jsx)(i.CoversToday,{rid:s}),o?(0,ke.jsx)(fe.DayView,{rid:s,day:o,today:t,app:"staff"}):(0,ke.jsx)(he.StaffHome,{go:e})]})}function Re({rid:e,today:s,meId:t,me:o}){const r=(0,T.useCashAccess)(e=>e.mine),i=(0,T.useCashAccess)(e=>e.takings),l=(0,T.useCashAccess)(e=>e.tradingDate),n=(0,xe.useSync)(e=>e.perms),c=!1===i||null==i&&!n.includes('*')&&!n.includes('takings.view'),u=l??(0,R.tradingDay)();return(0,A.useEffect)(()=>{c&&(0,M.forgetPastTakings)(e,u)},[c,e,u]),!0!==r?(0,ke.jsx)(C.NoCashUpAccess,{}):(0,ke.jsx)(S.CashUpScreen,{rid:e,today:c?u:s,canEdit:!0,closer:c,who:{id:t??'me',name:o.replace(' (example)','')}})}},1411,[1412,1416,828,997,1099,1417,1218,1055,1056,1418,1420,1423,1174,979,1016,1425,1013,2,1061,1062,1426,999,1039,1000,34,1176,1239,1243,1214,373,402,295,102,426,36,794,873,1157,891,821,1180,1427,1094,1112,1114,1108,1057,1040,1088,1435,1436,1437,1445,1446,1004,236,1245,1193,1199,1442,1213,1212,1455,1196,15,1219,1220,925,793,987,25]); +__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.TablePlan=function({startStep:e}){const{rid:s,r:n,now:w,me:f,role:S}=(0,b.useCtx)(6e4),T=(0,x.usePlan)(s),[P,C]=(0,t.useState)(null),[D,I]=(0,t.useState)(T.areas[0]?.id??''),[M,B]=(0,t.useState)(null),N=T.areas.find(e=>e.id===D)??T.areas[0],O=(0,x.planCounts)(T),A=(0,p.closedAreasAt)((0,p.useBlocks)(e=>e.blocks),s,(0,y.ymd)(w),`${String(w.getHours()).padStart(2,'0')}:${String(w.getMinutes()).padStart(2,'0')}`);return(0,k.jsxs)(a.default,{style:{gap:12},testID:"tableplan-page",children:[(0,k.jsxs)(h.Muted,{children:["The table plan for ",n.name,". Each venue has its own plan; it drives the Display floor view, walk-ins and which tables online bookings can use."]}),(0,k.jsxs)(h.Card,{children:[(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},wrap:!0,gap:8,children:[(0,k.jsxs)(a.default,{children:[(0,k.jsxs)(h.T,{size:20,weight:"bold",colour:j.colours.gold,children:[O.tables," tables \xb7 ",O.seats," seats"]}),(0,k.jsxs)(h.Muted,{children:[T.areas.length," areas \xb7 ",T.joins.length," joined ",1===T.joins.length?"pair":"pairs"]})]}),(0,k.jsx)(h.Button,{label:"Open table plan designer",testID:"open-designer",onPress:()=>C(e??'arrange')})]}),v.RELEASE.planPhoto?(0,k.jsx)(m.PlanPhoto,{rid:s}):null,(0,k.jsx)(a.default,{style:{gap:6},children:T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return(0,k.jsxs)(a.default,{testID:`area-summary-${e.id}`,style:{width:'100%',minWidth:0,gap:8,alignItems:'stretch',borderTopWidth:1,borderTopColor:j.colours.border,paddingTop:12,paddingBottom:6},children:[(0,k.jsx)(h.T,{center:!0,weight:"semibold",colour:(0,j.brandColour)(e.colour),children:e.name}),e.dogs||e.outdoor?(0,k.jsxs)(h.Row,{wrap:!0,gap:8,style:{justifyContent:'center'},children:[e.dogs?(0,k.jsx)(h.Badge,{kind:"gold",label:"\ud83d\udc3e Dogs allowed"}):null,e.outdoor?(0,k.jsx)(h.Badge,{kind:A.has(e.id)?'red':'neutral',label:A.has(e.id)?'\ud83c\udf27 Closed for weather':'\ud83c\udf26 Outdoor'}):null]}):null,e.label?(0,k.jsx)(h.Muted,{center:!0,size:14,children:e.label}):null,(0,k.jsxs)(h.Muted,{center:!0,children:[s.tables," tables \xb7 ",s.seats," seats"]})]},e.id)})}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Areas",onPress:()=>C('areas')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Tables",onPress:()=>C('tables')}),(0,k.jsx)(h.Button,{small:!0,kind:"secondary",label:"Arrange",onPress:()=>C('arrange')})]})]}),T.areas.some(e=>e.outdoor)?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(h.T,{weight:"semibold",children:"Weather"}),(0,k.jsx)(h.Muted,{children:"Closes the outdoor areas for the rest of today: no online bookings or walk-ins there, and the Display shows them as closed. Uses Block bookings, so you can reopen in one tap."}),(0,k.jsx)(c.CloseGardenButton,{rid:s,r:n,now:w,by:f})]}):null,N?(0,k.jsxs)(h.Card,{children:[(0,k.jsx)(o.AreaTabs,{plan:T,area:N.id,onPick:I,closed:A,counts:Object.fromEntries(T.areas.map(e=>{const s=(0,x.planCounts)(T,e.id);return[e.id,`${s.tables} \xb7 ${s.seats}`]}))}),(0,k.jsx)(a.default,{pointerEvents:"none",style:{borderRadius:12,overflow:'hidden'},children:(0,k.jsx)(r.FloorCanvas,{plan:T,areaId:N.id,mode:"live",fit:"width",maxH:360,sectionColours:!0})}),(0,k.jsx)(h.Muted,{children:"Preview only. Open the designer to change it."})]}):null,M?(0,k.jsx)(h.Banner,{kind:"success",title:M}):null,(0,k.jsx)(l.default,{visible:!!P,animationType:"slide",onRequestClose:()=>C(null),presentationStyle:"fullScreen",children:(0,k.jsx)(a.default,{style:{flex:1,backgroundColor:j.colours.bg},children:P?(0,k.jsx)(u.PlanDesigner,{initial:T,venue:n.name,mode:"managers",role:S,startStep:P,onSave:e=>{x.useFloor.getState().setPlan(s,e),C(null),B('Table plan saved. The Display uses it straight away.')},onLiveChange:e=>{x.useFloor.getState().setPlan(s,e),B('Live seating plan updated on every screen.')},onCancel:()=>C(null)}):null})})]})},_e.DisplaySettingsPage=function(){const{rid:e,role:s}=(0,b.useCtx)(6e4),t=(0,x.useDisplaySettings)(e),n=s=>x.useFloor.getState().setSettings(e,s);return(0,k.jsxs)(a.default,{style:{gap:14},children:[(0,k.jsxs)(a.default,{style:{gap:6},testID:"privacy-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Privacy on the Display"}),'owner'===s?(0,k.jsx)(h.Toggle,{label:"Privacy mode (recommended)",value:t.privacy,onChange:e=>n({privacy:e})}):(0,k.jsxs)(h.Row,{style:{justifyContent:'space-between'},children:[(0,k.jsx)(h.T,{children:"Privacy mode"}),(0,k.jsxs)(h.T,{weight:"semibold",children:[t.privacy?'On':'Off'," \xb7 owner only"]})]}),(0,k.jsx)(h.Muted,{children:"On: guest surnames show as initials (Campbell \u2192 C.), and no phone numbers, emails, notes or allergy details appear on the main screen (an icon only). Staff tap for details in a panel that closes after 20 seconds."})]}),(0,k.jsxs)(a.default,{style:{gap:6},children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Screensaver"}),(0,k.jsx)(h.T,{size:14,children:"Start after nobody touches the Display for"}),(0,k.jsx)(h.Row,{gap:6,children:[1,2,5,10].map(e=>(0,k.jsx)(a.default,{testID:`idle-${e}`,children:(0,k.jsx)(h.Chip,{label:`${e} min`,selected:t.idleMins===e,onPress:()=>n({idleMins:e})})},e))}),(0,k.jsx)(h.Toggle,{label:"Ask for a staff PIN on wake",value:t.pinOn,onChange:e=>n({pinOn:e})}),t.pinOn?(0,k.jsx)(S,{rid:e}):null,(0,k.jsx)(h.Muted,{children:"Used on this Display until a screensaver is saved in Settings \u203a Display screensaver (style, idle time and night dim for every Display, changed live). Any touch wakes it straight away and that first touch doesn\u2019t press anything. Where the browser allows, the Display also asks to keep the screen on."})]}),(0,k.jsx)(T,{}),(0,k.jsxs)(a.default,{style:{gap:6},testID:"wipe-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Shared tablet or phone"}),(0,k.jsx)(h.Muted,{children:"Selling or handing over this device, or it was used by someone who has left? Sign out and wipe it."}),(0,k.jsx)(f.WipeDevice,{})]}),(0,k.jsx)(h.Banner,{kind:"info",title:"Settings live on this device",children:"They\u2019re saved in this browser for the venue and picked up by the Display app on the same device."})]})};var s=_r(d[0]),t=_r(d[1]),n=_r(d[2]),l=e(_r(d[3])),a=e(_r(d[4])),o=_r(d[5]),r=_r(d[6]),u=_r(d[7]),c=_r(d[8]),h=_r(d[9]),p=_r(d[10]),x=_r(d[11]),y=_r(d[12]),j=_r(d[13]),b=_r(d[14]),w=_r(d[15]),f=_r(d[16]),m=_r(d[17]),v=_r(d[18]),k=_r(d[19]);function S({rid:e}){const n=(0,x.useDisplaySettings)(e),[l,o]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[c,p]=(0,t.useState)(null),y=l?(0,w.wakePinProblem)(l):null,b=[h.styles.input,{width:130}];return(0,k.jsxs)(a.default,{style:{gap:6},testID:"wake-pin-setting",children:[n.pinDefault?(0,k.jsx)(a.default,{testID:"wake-pin-default",children:(0,k.jsx)(h.Banner,{kind:"warn",title:"Change the wake PIN",children:"This Display still uses the starting PIN, 2580, which anyone could guess. Set a new 6 to 8 digit PIN below."})}):(0,k.jsxs)(h.Muted,{children:["A wake PIN of ",n.pinLen," digits is set. Type a new one to change it."]}),(0,k.jsxs)(h.Row,{gap:8,wrap:!0,children:[(0,k.jsx)(s.TextInput,{testID:"wake-pin-new",accessibilityLabel:"New wake PIN",value:l,onChangeText:e=>{o(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"New PIN (6\u20138 digits)",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(s.TextInput,{testID:"wake-pin-again",accessibilityLabel:"New wake PIN again",value:r,onChangeText:e=>{u(e.replace(/\D/g,'').slice(0,8)),p(null)},placeholder:"Type it again",placeholderTextColor:j.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",style:b}),(0,k.jsx)(h.Button,{small:!0,testID:"wake-pin-save",label:"Save PIN",disabled:!l||!r,onPress:()=>{const s=(0,w.wakePinProblem)(l);s?p(s):l===r?(x.useFloor.getState().setSettings(e,(0,w.makeWakePin)(l)),o(''),u(''),p('Wake PIN saved. Tell the team in person; it isn\u2019t shown again.')):p('The two PINs don\u2019t match.')}})]}),c||y?(0,k.jsx)(h.Muted,{children:c??y}):null]})}function T(){const[e,s]=(0,t.useState)((0,n.flapSoundOn)());return(0,k.jsxs)(a.default,{style:{gap:6},testID:"flap-sound-setting",children:[(0,k.jsx)(h.T,{weight:"semibold",colour:j.colours.gold,children:"Covers counter sound"}),(0,k.jsx)(h.Toggle,{label:"Soft flap click when the Covers change (Display only)",value:e,onChange:e=>{(0,n.setFlapSound)(e),s(e)}}),(0,k.jsx)(h.Muted,{children:"Off by default. Only this device clicks; phones never do."})]})}},1412,[827,34,1048,395,102,1134,1135,1358,1387,794,1026,1029,858,821,1088,1030,1413,1414,1050,25]); +__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.WipeDevice=function({compact:e}){const f=(0,u.useDisplaySettings)(p.VENUE_RID),[v,T]=(0,s.useState)(!1),[w,j]=(0,s.useState)(''),[D,C]=(0,s.useState)(!1),I='display'===h.APP_VARIANT&&f.pinOn,P=!I||(0,b.wakePinMatches)(f,w);return v?(0,x.jsxs)(o.default,{testID:"wipe-confirm-box",style:{gap:6,marginTop:6},children:[(0,x.jsx)(l.T,{size:e?12:14,children:"Sign out and remove everything CoverCharge keeps on this device: sign-ins, pairing, saved screens and any changes not sent yet. The venue\u2019s shared data is not touched. To use it again, open a personal link or pair the Display again."}),I?(0,x.jsx)(t.TextInput,{testID:"wipe-pin",value:w,onChangeText:j,placeholder:"Display wake PIN",placeholderTextColor:c.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display wake PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:c.colours.text}}):null,(0,x.jsxs)(o.default,{style:{flexDirection:'row',gap:8},children:[(0,x.jsx)(n.default,{testID:"wipe-confirm",accessibilityRole:"button",accessibilityLabel:"Yes, wipe this device",disabled:!P||D,onPress:()=>{C(!0),(0,y.wipeThisDevice)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:P?c.colours.red:'rgba(255,255,255,0.08)'},children:(0,x.jsx)(l.T,{size:12,weight:"semibold",children:D?'Wiping\u2026':'Yes, wipe this device'})}),(0,x.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"Cancel",onPress:()=>{T(!1),j('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,x.jsx)(l.T,{size:12,children:"Cancel"})})]})]}):(0,x.jsx)(n.default,{testID:"wipe-device",accessibilityRole:"button",accessibilityLabel:"Sign out and wipe this device",onPress:()=>T(!0),style:{alignSelf:'flex-start',marginTop:e?4:0,minHeight:44,justifyContent:'center'},children:(0,x.jsx)(l.T,{size:e?12:14,colour:c.colours.gold,children:"Sign out and wipe this device\u2026"})})};var t=r(d[0]),s=r(d[1]),n=e(r(d[2])),o=e(r(d[3])),l=r(d[4]),c=r(d[5]),u=r(d[6]),p=r(d[7]),b=r(d[8]),h=r(d[9]),y=r(d[10]),x=r(d[11])},1413,[827,34,402,102,794,821,1029,5,1030,872,987,25]); +__d(function(g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.PlanPhoto=function({rid:e}){const t=(0,n.usePlan)(e),b=(0,n.useFloor)(e=>e.setPlan),[y,f]=(0,a.useState)(null),[x,w]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,S]=(0,a.useState)(''),[P,T]=(0,a.useState)(!1),I=async e=>{let a;T(!0);try{const{data:t,error:l}=await(0,u.getSupabase)().functions.invoke('plan-photo-read',{body:{image:e}});a=l?{ok:!1,message:'The plan could not be read. The photo is still here.'}:{ok:!0,tables:(0,o.cleanFindings)(t)}}catch{a={ok:!1,message:'The plan could not be read. The photo is still here.'}}finally{T(!1)}const t=(0,o.planReadAfter)(e,a);w(t.photo),f(t.rows&&t.rows.length?t.rows:null),S(t.note)},L=async()=>{S('');const e=(await(0,c.pickPhotos)({source:'camera'}))[0];e?(w(e),await I(e)):S('No photo taken.')};return(0,p.jsxs)(l.default,{testID:"plan-photo",style:{width:'100%',alignItems:'center',gap:10},children:[(0,p.jsx)(s.Button,{testID:"plan-photo-camera",label:P?'Reading the plan\u2026':'Take a picture of the table plan',accessibilityLabel:"Take a picture of a hand-drawn table plan",disabled:P,onPress:()=>{L()}}),k?(0,p.jsx)(s.Muted,{center:!0,testID:"plan-photo-note",children:k}):null,x&&!P?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-retry",label:"Read this photo again",accessibilityLabel:"Read this photo again",onPress:()=>{I(x)}}):null,y?(0,p.jsx)(l.default,{testID:"plan-photo-review",style:{width:'100%'},children:(0,p.jsxs)(s.Card,{style:{alignItems:'center',width:'100%'},children:[(0,p.jsx)(s.T,{center:!0,weight:"bold",colour:h.colours.gold,children:"Check what was read"}),(0,p.jsx)(s.Muted,{center:!0,children:"Nothing is saved until you tap Save the plan."}),y.map((e,a)=>(0,p.jsxs)(l.default,{style:{width:'100%',gap:6},children:[(0,p.jsx)(s.Field,{label:"Area",accessibilityLabel:`Area ${a+1}`,value:e.area,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,area:e}:t))}),(0,p.jsx)(s.Field,{label:"Table",accessibilityLabel:`Table ${a+1}`,value:e.name,onChangeText:e=>f(y.map((t,l)=>l===a?{...t,name:e}:t))}),(0,p.jsx)(s.Field,{label:"Seats",accessibilityLabel:`Seats at table ${a+1}`,value:String(e.seats),keyboardType:"number-pad",onChangeText:e=>f(y.map((t,l)=>l===a?{...t,seats:Math.max(1,Math.min(30,Number(e.replace(/\D/g,''))||1))}:t))}),(0,p.jsx)(s.Button,{kind:"ghost",label:`Remove ${e.name||'table'}`,accessibilityLabel:`Remove ${e.name||'table'}`,onPress:()=>f(y.filter((e,t)=>t!==a))})]},`${e.area}-${e.name}-${a}`)),(0,p.jsx)(s.Button,{testID:"plan-photo-save",label:"Save the plan",accessibilityLabel:"Save the checked table plan",disabled:!y.length,onPress:()=>{if(!y?.length)return;j(t);const a=[...t.areas],l=[...t.tables];for(const e of y){let t=a.find(a=>a.name.toLowerCase()===e.area.toLowerCase());t||(t={id:(0,i.fid)('area'),name:e.area},a.push(t));const s=(0,i.sizeFor)(e.seats),n=l.filter(e=>e.areaId===t.id).length;l.push({id:(0,i.fid)('t'),name:e.name,areaId:t.id,shape:s.shape,minSeats:1,maxSeats:e.seats,x:40+n%6*140,y:40+120*Math.floor(n/6),w:s.w,h:s.h,rot:0,online:!0})}b(e,{...t,areas:a,tables:l}),f(null),S('Plan saved. Undo puts the previous plan back.')}})]})}):null,v?(0,p.jsx)(s.Button,{kind:"ghost",testID:"plan-photo-undo",label:"Undo table plan",accessibilityLabel:"Undo the table plan and restore the previous one",onPress:()=>{b(e,v),j(null),S('Previous plan restored.')}}):null]})};var e,a=r(d[0]),t=r(d[1]),l=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),n=r(d[3]),o=r(d[4]),i=r(d[5]),h=r(d[6]),c=r(d[7]),u=r(d[8]),p=r(d[9])},1414,[34,102,794,1029,1415,859,821,1075,933,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.planReadAfter=function(t,o){return o.ok?o.tables.length?{photo:t,rows:o.tables,note:''}:{photo:t,rows:[],note:'Nothing readable on that photo. The photo is still here.'}:{photo:t,rows:null,note:o.message}},e.cleanFindings=function(o){if(!o||'object'!=typeof o)return[];const n=o.tables;if(!Array.isArray(n))return[];const s=[];for(const o of n.slice(0,80)){if(!o||'object'!=typeof o)continue;const n=t(o.area,40),c=t(o.name,12),l=o.seats;!n||!c||'number'!=typeof l||!Number.isInteger(l)||l<1||l>30||s.push({area:n,name:c,seats:l})}return s};const t=(t,o)=>'string'==typeof t?t.trim().slice(0,o):''},1415,[]); +__d(function(g,_r,_i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffBookingTimes=function(){const{r:e,rid:s}=(0,o.useCtx)(),[u,c]=(0,t.useState)(()=>Object.fromEntries(d.map(([t])=>[t,e.kitchenHours?.[t]??null]))),[h,b]=(0,t.useState)(String(e.settings.turnMins??'')),[v,y]=(0,t.useState)(String(e.settings.bookingCoversPerSlot??'')),[x,j]=(0,t.useState)(''),[k,S]=(0,t.useState)(!1),f=(e,t,s)=>c(n=>({...n,[e]:0===t?[s,n[e]?.[1]??'']:[n[e]?.[0]??'',s]})),p=Object.values(u).every(e=>!e||e.every(e=>/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(e))&&e[0]=30&&Number(h)<=360&&Number(v)>=1&&Number(v)<=1e3;return(0,r.jsxs)(n.default,{style:{gap:12,width:'100%',minWidth:0},testID:"staff-booking-times",children:[(0,r.jsx)(i.T,{center:!0,weight:"bold",children:"Booking times"}),(0,r.jsx)(i.Muted,{center:!0,children:"Change kitchen hours, table time and the Covers offered in each booking slot. Table layout and blocks have their own screens."}),d.map(([e,t])=>(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.T,{center:!0,weight:"semibold",children:t}),(0,r.jsx)(i.Toggle,{label:`${t} open`,value:!!u[e],onChange:t=>c(s=>({...s,[e]:t?['','']:null}))}),u[e]?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Field,{label:`${t} opens (HH:MM)`,value:u[e][0],placeholder:"HH:MM",onChangeText:t=>f(e,0,t)}),(0,r.jsx)(i.Field,{label:`${t} closes (HH:MM)`,value:u[e][1],placeholder:"HH:MM",onChangeText:t=>f(e,1,t)})]}):(0,r.jsx)(i.Muted,{center:!0,children:"Closed"})]},e)),(0,r.jsxs)(i.Card,{children:[(0,r.jsx)(i.Field,{label:"Typical table time, minutes",value:h,onChangeText:b,keyboardType:"number-pad"}),(0,r.jsx)(i.Field,{label:"Covers per 30-minute booking slot",value:v,onChangeText:y,keyboardType:"number-pad"}),e.settings.bookingCoversPerStart||e.settings.bookingPartiesPerStart?(0,r.jsx)(i.Muted,{center:!0,children:"Online booking uses the covers and bookings caps at each start time (Settings \u203a Capacity & waitlist), not this half-hour figure."}):null]}),(0,r.jsx)(i.Button,{label:k?'Saving\u2026':'Save booking times',disabled:!p||k,accessibilityLabel:"Save booking times without changing other venue settings",onPress:async()=>{S(!0);try{await(0,l.saveStaffBookingTimes)(s,u,Number(h),Number(v)),j('Booking times saved.')}catch(e){j(e.message)}finally{S(!1)}}}),x?(0,r.jsx)(i.Muted,{center:!0,children:x}):null]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=(e=s)&&e.__esModule?e:{default:e},i=_r(_d[2]),o=_r(_d[3]),l=_r(_d[4]),r=_r(_d[5]);const d=[[1,'Monday'],[2,'Tuesday'],[3,'Wednesday'],[4,'Thursday'],[5,'Friday'],[6,'Saturday'],[0,'Sunday']]},1416,[34,102,794,1088,987,25]); +__d(function(g,_r,_i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.StaffTableOrders=function({rid:e,me:l}){const p=(0,c.useOrderAtTable)(e),x=(0,c.useNow)(15e3),f=(0,c.useStore)(e=>e.bookings),w=(0,c.useOrders)(e).filter(i.isTableQr).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)),S=w.filter(i.waitingForStaff),y=w.filter(e=>m(e)&&!(0,i.waitingForStaff)(e)),v=w.filter(e=>!m(e)).slice(0,8),[k,T]=(0,s.useState)(null),[$,B]=(0,s.useState)(null),M=e=>{c.repo.orders.accept(e.id,l),B(`${e.ref} accepted for table ${(0,t.tableNumbers)(e.tableNo)}: it's gone to the kitchen.`)},N=e=>{const t=(0,h.statusBlock)(e,'served',(0,h.linkedBooking)(e,f));if(t)return void B(`${e.ref}: ${t}`);const s=(new Date).toISOString();c.useStore.setState(t=>({orders:t.orders.map(t=>t.id===e.id?{...t,servedBy:{by:l,at:s}}:t)})),c.useStore.getState().setOrderStatus(e.id,'served',l),B(`${e.ref} marked served.`)},O=(e,t)=>{const s=(new Date).toISOString();c.useStore.setState(r=>({orders:r.orders.map(r=>r.id===e.id?{...r,cancelReason:t,cancelledBy:{by:l,at:s}}:r)})),c.useStore.getState().setOrderStatus(e.id,'cancelled',l),T(null),B(`${e.ref} cancelled (${t}). The guest's phone shows the reason.`)},A=({o:e,held:s})=>(0,b.jsxs)(a.Card,{highlight:s?u.colours.amber:e.allergies.length?u.colours.red:u.colours.gold,children:[(0,b.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,b.jsxs)(a.T,{weight:"semibold",children:["Table ",(0,t.tableNumbers)(e.tableNo)," \xb7 ",e.ref]}),(0,b.jsx)(a.Badge,{kind:s?'amber':'cancelled'===e.status?'neutral':'gold',label:s?'Waiting for you':'served'===e.status?'Served':'cancelled'===e.status?'Cancelled':'In the kitchen'})]}),(0,b.jsxs)(a.Muted,{children:[e.customerName," \xb7 ",j(e.createdAt,x),e.accepted?` \xb7 accepted by ${e.accepted.by}`:'']}),e.lines.map((e,t)=>(0,b.jsxs)(a.T,{children:[e.qty,"\xd7 ",e.name,e.notes?` (note: ${e.notes})`:'']},t)),e.allergies.length?(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:e.allergies.map(e=>(0,b.jsx)(a.Badge,{kind:"red",label:`${(0,n.allergenLabel)(e.allergen)}: ${(0,n.severityLabel)(e.severity)}`},e.allergen))}):(0,b.jsx)(a.Muted,{children:"No allergies declared."}),e.notes?(0,b.jsxs)(a.T,{size:13,children:["Note: ",e.notes]}):null,(0,b.jsxs)(a.T,{size:13,colour:u.colours.muted,children:[(0,o.gbp)(e.total)," to pay at the bar or with the server"]}),'cancelled'===e.status&&e.cancelReason?(0,b.jsxs)(a.Muted,{children:["Reason: ",e.cancelReason]}):null,m(e)?k===e.id?(0,b.jsxs)(r.default,{style:{gap:6},children:[(0,b.jsx)(a.T,{size:13,children:"Why are you cancelling? The guest sees this."}),(0,b.jsx)(a.Row,{wrap:!0,gap:6,children:i.CANCEL_REASONS.map(t=>(0,b.jsx)(a.Chip,{label:t,onPress:()=>O(e,t)},t))}),(0,b.jsx)(a.Button,{small:!0,kind:"ghost",label:"Don't cancel",onPress:()=>T(null)})]}):(0,b.jsxs)(a.Row,{gap:8,wrap:!0,children:[s?(0,b.jsx)(a.Button,{small:!0,label:"Accept",testID:`accept-${e.ref}`,onPress:()=>M(e)}):(0,b.jsx)(a.Button,{small:!0,label:"Mark served",testID:`served-${e.ref}`,onPress:()=>N(e)}),(0,b.jsx)(a.Button,{small:!0,kind:"secondary",label:"Cancel with a reason",onPress:()=>T(e.id)})]}):null]});return(0,b.jsxs)(r.default,{style:{gap:10},children:[(0,b.jsx)(a.Muted,{children:"Tip: orders from guests' phones land here within seconds. Accept the first one from a new phone, check allergies, then mark it served. Guests pay at the bar or with their server."}),p?null:(0,b.jsx)(a.Banner,{kind:"demo",title:"Order at the table is off",children:"Managers can switch it on in Settings \u203a Advanced \u203a Order at the table."}),$?(0,b.jsx)(a.Banner,{kind:"success",children:$}):null,(0,b.jsxs)(a.T,{weight:"semibold",children:["Waiting for you to accept (",S.length,")"]}),S.length?S.map(e=>(0,b.jsx)(A,{o:e,held:!0},e.id)):(0,b.jsx)(a.Muted,{children:"Nothing waiting."}),(0,b.jsxs)(a.T,{weight:"semibold",children:["In the kitchen (",y.length,")"]}),y.length?y.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id)):(0,b.jsx)(a.Muted,{children:"No table orders being made."}),v.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(a.T,{weight:"semibold",children:"Served or cancelled"}),v.map(e=>(0,b.jsx)(A,{o:e,held:!1},e.id))]}):null]})};var e,t=_r(d[0]),s=_r(d[1]),l=_r(d[2]),r=(e=l)&&e.__esModule?e:{default:e},a=_r(d[3]),n=_r(d[4]),o=_r(d[5]),i=_r(d[6]),c=_r(d[7]),h=_r(d[8]),u=_r(d[9]),b=_r(d[10]);const j=(e,t)=>{const s=Math.max(0,Math.round((t.getTime()-new Date(e).getTime())/6e4));return s<1?'just now':`${s} min ago`},m=e=>!['served','collected','closed','cancelled'].includes(e.status)},1417,[860,34,102,794,861,867,1175,874,869,821,25]); +__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.customerCodeLink=y,_e.StaffLoyalty=function({venue:e,canRemove:r=!1,onOpenSettings:u}){const[p,x]=(0,t.useState)(null),[y,b]=(0,t.useState)(''),[S,k]=(0,t.useState)(null),[v,C]=(0,t.useState)(null),[M,T]=(0,t.useState)(!1),[B,R]=(0,t.useState)(''),[P,O]=(0,t.useState)(null),$=(0,c.staffServer)(),L=(0,n.can)('venue.settings'),[N,E]=(0,t.useState)(!1),[D,A]=(0,t.useState)(''),F=async e=>{if(p){E(!0),A('');try{await(0,c.saveSettings)({...p,cardOn:e}),x({...p,cardOn:e,saved:!0});const n=e?'Stamp card switched on':'Stamp card switched off';A(n),s.default.announceForAccessibility?.(n)}catch(e){R((0,o.plainError)(e))}E(!1)}},I=(0,t.useCallback)(()=>{$&&(0,c.readSettings)().then(x).catch(()=>{})},[$]);(0,t.useEffect)(()=>(I(),(0,c.watchLoyalty)(()=>{I(),C(e=>(e&&(0,c.staffCard)(e.id).then(C).catch(()=>{}),e))})),[I]);const _=async(e=y)=>{R('');try{const n=await(0,c.staffFind)(e);k(n),1===n.length&&C(n[0])}catch(e){R((0,o.plainError)(e))}},z=(0,t.useCallback)(e=>{T(!1),b((0,o.prettyCardNo)(e)),_(e)},[]);return $?(0,m.jsxs)(l.default,{style:{gap:10},children:[!p||p.cardOn||L?null:(0,m.jsx)(i.Banner,{kind:"info",title:"The stamp card is off",children:"Ask a manager to switch it on."}),p&&L?(0,m.jsx)(i.Card,{children:(0,m.jsxs)(l.default,{style:{gap:8},testID:"loy-quick",children:[p.cardOn?null:(0,m.jsx)(i.T,{weight:"semibold",children:"The stamp card is off"}),(0,m.jsx)(i.Toggle,{testID:"loy-quick-on",label:"Stamp card on",a11y:"Stamp card on. "+(p.cardOn?'On':'Off'),value:p.cardOn,disabled:N,onChange:e=>{F(e)}}),D?(0,m.jsx)(l.default,{accessibilityLiveRegion:"polite",children:(0,m.jsx)(i.Muted,{children:D})}):null,u?(0,m.jsx)(i.Button,{kind:"ghost",label:"Change the stamp card",testID:"loy-open-settings",onPress:u}):null]})}):null,p&&p.saved?(0,m.jsxs)(i.Muted,{children:[p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,p&&!p.saved&&L?(0,m.jsxs)(i.Muted,{children:["Suggested settings, not saved yet: ",p.stampsNeeded," stamps = ",p.reward||'reward not set',". At most ",p.maxPerDay," a day",p.gapMinutes?`, ${p.gapMinutes} minutes apart`:'',"."]}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Find a guest"}),(0,m.jsx)(i.Field,{label:"Name, phone, email or card number",value:y,onChangeText:b,onSubmitEditing:()=>_(),autoCapitalize:"none",testID:"loyalty-search"}),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Find",disabled:y.trim().length<2,onPress:()=>_(),testID:"loyalty-find"}),(0,h.canScan)()?(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:M?'Scanning\u2026':'Scan their card',onPress:()=>T(!0)}):null]}),M?(0,m.jsx)(h.CardScanner,{onCard:z,onClose:()=>T(!1)}):null,B?(0,m.jsx)(i.Banner,{kind:"warn",children:B}):null,S&&!S.length?(0,m.jsx)(i.Muted,{children:"No one found. Check the spelling, or sign them up below."}):null,S&&S.length>1?S.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.name}),(0,m.jsxs)(i.Muted,{children:[(0,o.prettyCardNo)(e.cardNo)," \xb7 ",e.stamps," of ",e.needed,e.phone?` \xb7 ${e.phone}`:'']})]}),e.rewards.length?(0,m.jsx)(i.Badge,{kind:"gold",label:`${e.rewards.length} ready`}):null,(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Open",onPress:()=>C(e)})]},e.id)):null]}),v?(0,m.jsx)(f,{card:v,settings:p,canRemove:r,onChange:e=>{C(e),k(null)},onClose:()=>C(null)}):null,(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Stamp code"}),(0,m.jsx)(i.Muted,{children:"Busy? Make a one-time code and show it to the guest; they type it (or scan it) on their own phone for one stamp."}),P?(0,m.jsx)(j,{c:P,what:"One stamp."}):null,(0,m.jsx)(i.Button,{kind:"secondary",label:P?'Make another code':'Make a stamp code',disabled:!1===p?.cardOn,onPress:()=>{R(''),(0,c.staffCode)('stamp').then(O).catch(e=>R((0,o.plainError)(e)))}})]}),(0,m.jsx)(w,{venue:e,onJoined:e=>{C(e),k(null)}}),(0,m.jsx)(i.Muted,{children:"Tip: search by the last 4 digits of a phone number. Each reward can only be used once, and the card shows who used it and when."})]}):(0,m.jsxs)(l.default,{style:{gap:10},children:[(0,m.jsx)(i.Banner,{kind:"info",title:"Connect to your venue first",children:"The stamp card is saved on your venue's account. Open your invite link on this phone to connect, then you can find guests and add stamps here."}),(0,m.jsx)(i.Muted,{children:"Tip: stamps can only be added by staff of the venue, so a guest can't stamp their own card."})]})};var n=_r(d[0]),t=_r(d[1]),s=e(_r(d[2]));_r(d[3]);var l=e(_r(d[4])),r=_r(d[5]),i=_r(d[6]),o=_r(d[7]),c=_r(d[8]),u=_r(d[9]),h=_r(d[10]),m=_r(d[11]);const p=e=>{try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}},x=e=>{try{return new Date(e).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return''}};function y(e){if('undefined'==typeof window||!window.location)return e;const n=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/);return new URL(`${n?n[1]:''}/customer-app/index.html?loyalty=${e}`,window.location.origin).toString()}function j({c:e,what:n}){return(0,m.jsxs)(l.default,{style:{gap:4,alignItems:'center'},children:[(0,m.jsx)(i.T,{size:34,weight:"bold",colour:u.colours.gold,center:!0,children:e.code}),(0,m.jsx)(r.QR,{value:y(e.code),size:150}),(0,m.jsxs)(i.Muted,{center:!0,children:[n," Works once, until ",x(e.expiresAt),". The guest types it in Stamp card, or scans this with their phone camera."]})]})}function f({card:e,settings:n,canRemove:s,onChange:r,onClose:h}){const[x,y]=(0,t.useState)(null),[f,w]=(0,t.useState)(!1),[b,S]=(0,t.useState)(null),[k,v]=(0,t.useState)(null),C=async e=>{w(!0),y(null);try{await e()}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1),S(null)}};return(0,m.jsxs)(i.Card,{highlight:u.colours.gold,children:[(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.H2,{children:e.name}),(0,m.jsxs)(i.Muted,{children:["Card ",(0,o.prettyCardNo)(e.cardNo),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']})]}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Close",onPress:h})]}),(0,m.jsxs)(i.T,{size:20,weight:"semibold",children:[e.stamps," of ",e.needed," stamps"]}),(0,m.jsxs)(i.Muted,{children:["Next reward: ",e.reward]}),x?(0,m.jsx)(i.Banner,{kind:x.kind,children:x.text}):null,(0,m.jsx)(i.Button,{label:f?'Saving\u2026':'Add a stamp',disabled:f||!1===n?.cardOn,testID:"loyalty-add-stamp",onPress:()=>C(async()=>{const n=await(0,c.staffStamp)(e.id);r(n),y({kind:'success',text:n.newReward?`Stamp added. ${e.name} has earned: ${n.rewards[n.rewards.length-1]?.title??'a reward'}.`:`Stamp added: ${n.stamps} of ${n.needed}.`})})}),!1===n?.cardOn?(0,m.jsx)(i.Muted,{children:"The stamp card is switched off in Settings \u203a Advanced \u203a Loyalty, so no stamps can be added."}):null,e.rewards.length?(0,m.jsx)(i.T,{weight:"semibold",children:"Rewards ready"}):(0,m.jsx)(i.Muted,{children:"No rewards ready yet."}),e.rewards.map(e=>(0,m.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,m.jsxs)(l.default,{style:{flex:1},children:[(0,m.jsx)(i.T,{children:e.title}),e.expiresAt?(0,m.jsxs)(i.Muted,{children:["Use by ",p(e.expiresAt)]}):null]}),b===e.id?(0,m.jsxs)(i.Row,{gap:6,children:[(0,m.jsx)(i.Button,{small:!0,label:"Yes, used now",disabled:f,onPress:()=>C(async()=>{const n=await(0,c.staffRedeem)(e.id);r(n),y({kind:'success',text:`${n.redeemed} marked used.`})})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Not yet",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use reward",onPress:()=>S(e.id)})]},e.id)),(0,m.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,m.jsx)(i.Button,{small:!0,kind:"secondary",label:"Sign-in code for their phone",onPress:()=>C(async()=>v(await(0,c.staffCode)('link',e.id)))}),s?'remove'===b?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, remove their details",onPress:()=>C(async()=>{await(0,c.staffRemove)(e.id),r(null),h()})}),(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>S(null)})]}):(0,m.jsx)(i.Button,{small:!0,kind:"ghost",label:"Remove guest",onPress:()=>S('remove')}):null]}),k?(0,m.jsx)(j,{c:k,what:`Opens ${e.name}'s card on their phone.`}):null,'remove'===b?(0,m.jsx)(i.Muted,{children:"Removing wipes their name, phone and email and closes the card (for example if they ask you to delete their data). Counts in the summary stay."}):null,(0,m.jsx)(i.T,{weight:"semibold",children:"Recent"}),e.history.length?e.history.slice(0,8).map((e,n)=>(0,m.jsxs)(i.Muted,{children:[p(e.at)," \xb7 ",e.what]},n)):(0,m.jsx)(i.Muted,{children:"Nothing yet."})]})}function w({venue:e,onJoined:n}){const[s,l]=(0,t.useState)(''),[r,u]=(0,t.useState)(''),[h,p]=(0,t.useState)(''),[x,y]=(0,t.useState)(!1),[j,f]=(0,t.useState)(!1),[w,b]=(0,t.useState)('');return(0,m.jsxs)(i.Card,{children:[(0,m.jsx)(i.H2,{children:"Sign a guest up"}),(0,m.jsx)(i.Muted,{children:"Only a name is needed. Read the agreement to the guest and tick it only if they say yes."}),(0,m.jsx)(i.Field,{label:"Guest's name",value:s,onChangeText:l,maxLength:60}),(0,m.jsx)(i.Field,{label:"Phone (optional)",value:r,onChangeText:u,keyboardType:"phone-pad",maxLength:20}),(0,m.jsx)(i.Field,{label:"Email (optional)",value:h,onChangeText:p,keyboardType:"email-address",autoCapitalize:"none",maxLength:120}),(0,m.jsx)(i.Toggle,{label:`The guest agrees: \u201c${(0,o.consentText)(e)}\u201d`,value:x,onChange:y}),w?(0,m.jsx)(i.Banner,{kind:"warn",children:w}):null,(0,m.jsx)(i.Button,{label:j?'Saving\u2026':'Sign up',disabled:j||!x||!s.trim(),onPress:async()=>{f(!0),b('');try{n(await(0,c.staffJoin)({name:s,phone:r,email:h,consent:x,consentText:(0,o.consentText)(e)})),l(''),u(''),p(''),y(!1)}catch(e){b((0,o.plainError)(e))}finally{f(!1)}}})]})}},1418,[987,34,281,236,102,1285,794,1260,1263,821,1419,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"canScan",{enumerable:!0,get:function(){return l}}),_e.CardScanner=function({onCard:t,onClose:n}){const f=(0,e.useRef)(null),[h,w]=(0,e.useState)('');return(0,e.useEffect)(()=>{if(!l())return void w('This browser can\u2019t scan. Type the card number or search by name instead.');let e=!1,n=null,c=null;const o=document.createElement('video');return o.setAttribute('playsinline','true'),o.muted=!0,Object.assign(o.style,{width:'100%',maxWidth:'360px',borderRadius:'12px',border:'2px solid #CFA45F'}),(async()=>{try{if(n=await navigator.mediaDevices.getUserMedia({video:{facingMode:'environment'}}),e)return void n.getTracks().forEach(e=>e.stop());o.srcObject=n,await o.play();const u=f.current;u?.appendChild(o);const l=new(0,window.BarcodeDetector)({formats:['qr_code']}),h=async()=>{if(!e){try{const e=await l.detect(o);for(const n of e){const e=(0,s.readCardQr)(String(n.rawValue??''));if(e)return void t(e)}}catch{}c=setTimeout(h,300)}};h()}catch{w('The camera didn\u2019t start. Allow the camera, or type the card number instead.')}})(),()=>{e=!0,c&&clearTimeout(c),n?.getTracks().forEach(e=>e.stop()),o.remove()}},[t]),(0,u.jsxs)(c.default,{style:{gap:8,alignItems:'center'},children:[(0,u.jsx)(c.default,{ref:f,style:{width:'100%',alignItems:'center'}}),h?(0,u.jsx)(o.Banner,{kind:"warn",children:h}):(0,u.jsx)(o.Muted,{center:!0,children:"Point the camera at the QR on the guest\u2019s card screen."}),(0,u.jsx)(o.Button,{kind:"ghost",label:"Close camera",onPress:n})]})};var e=r(d[0]);r(d[1]);var t,n=r(d[2]),c=(t=n)&&t.__esModule?t:{default:t},o=r(d[3]),s=r(d[4]),u=r(d[5]);const l=()=>'undefined'!=typeof window&&'BarcodeDetector'in window&&!!navigator?.mediaDevices?.getUserMedia},1419,[34,236,102,794,1260,25]); +__d(function(_g,r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GuestProfiles=function({me:e,manager:t}){const[l,i]=(0,s.useState)(''),[h,p]=(0,s.useState)(null),[j,f]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(null);return(0,s.useEffect)(()=>{if(!(0,g.staffServer)()||l.trim().length<2)return void p(null);const e=setTimeout(()=>{(0,g.guestSearch)(l).then(p).catch(e=>f({kind:'warn',text:(0,o.plainError)(e)}))},300);return()=>clearTimeout(e)},[l]),(0,g.staffServer)()?b?(0,c.jsx)(w,{id:b,me:e,onClose:()=>v(null),onErased:()=>{v(null),i(''),f({kind:'success',text:'Erased. The audit trail keeps a record that it happened.'})}}):S?(0,c.jsx)(y,{seed:S,me:e,onCancel:()=>C(null),onMade:e=>{C(null),v(e.id)}}):(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profiles",children:[t?(0,c.jsx)(k,{onOpen:v}):null,(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Find a guest: name, phone or email",value:l,onChangeText:i,autoCapitalize:"none",testID:"guest-search"}),(0,c.jsx)(a.Muted,{size:12,children:"Visits and Covers come from real bookings. A profile is only kept with the guest\u2019s OK."})]})}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,h?(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-results",children:[h.profiles.map(e=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,0).split(' \xb7 ')[0]," \xb7 ",e.allergies.length?`Allergies: ${(0,u.allergyLine)(e.allergies)}`:'No allergies recorded']})]}),(0,c.jsx)(a.Button,{label:"Open",small:!0,testID:`guest-open-${e.name.replace(/\W+/g,'-').toLowerCase()}`,onPress:()=>v(e.id)})]})},e.id)),h.fromBookings.length?(0,c.jsx)(a.Muted,{weight:"medium",children:"From bookings (no profile yet)"}):null,h.fromBookings.map((e,s)=>(0,c.jsx)(a.Card,{children:(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{weight:"medium",children:e.name}),(0,c.jsxs)(a.Muted,{size:12,children:[(0,u.visitWords)(e.visits,e.covers),e.lastVisit?` \xb7 last ${x(e.lastVisit)}`:'']})]}),(0,c.jsx)(a.Button,{label:"Make profile",kind:"ghost",small:!0,testID:`guest-make-${s}`,onPress:()=>C({name:e.name,phone:e.phone??'',email:e.email??''})})]})},s)),h.profiles.length||h.fromBookings.length?null:(0,c.jsx)(a.Muted,{children:"No guest found."}),(0,c.jsx)(a.Button,{label:"New guest",kind:"ghost",small:!0,testID:"guest-new",onPress:()=>C({name:l.trim(),phone:'',email:''})})]}):null]}):(0,c.jsx)(a.Banner,{kind:"demo",title:"Guest profiles are saved on the server",children:"Sign this device in to your venue to look guests up. There are no example guests here."})};var e,s=r(d[0]),t=r(d[1]),l=r(d[2]),n=(e=l)&&e.__esModule?e:{default:e},a=r(d[3]),i=r(d[4]),o=r(d[5]),u=r(d[6]),g=r(d[7]),h=r(d[8]),c=r(d[9]);const x=e=>{if(!e)return'\u2013';try{return new Date(10===e.length?e+'T12:00:00Z':e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e}},p=e=>{if(!e)return'\u2013';try{return new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})}catch{return e}};function j({label:e,value:s}){return(0,c.jsxs)(n.default,{style:{minWidth:70,gap:2},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",colour:h.colours.gold,children:String(s)}),(0,c.jsx)(a.Muted,{size:12,children:e})]})}function y({seed:e,me:t,onMade:l,onCancel:i}){const[u,h]=(0,s.useState)(e),[x,p]=(0,s.useState)(!1),[j,y]=(0,s.useState)(null),[f,w]=(0,s.useState)(!1);return(0,c.jsx)(n.default,{testID:"guest-make",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Make a guest profile"}),(0,c.jsx)(a.Field,{label:"Name",value:u.name,onChangeText:e=>h({...u,name:e}),testID:"guest-make-name"}),(0,c.jsx)(a.Field,{label:"Phone",value:u.phone,onChangeText:e=>h({...u,phone:e}),keyboardType:"phone-pad",testID:"guest-make-phone"}),(0,c.jsx)(a.Field,{label:"Email",value:u.email,onChangeText:e=>h({...u,email:e}),keyboardType:"email-address",autoCapitalize:"none",testID:"guest-make-email"}),(0,c.jsx)(a.Toggle,{label:"The guest said yes to us keeping a profile (visits, preferences and allergies)",value:x,onChange:p,testID:"guest-make-consent"}),(0,c.jsx)(a.Muted,{size:12,children:"Ask first. They can ask to see it or have it erased at any time."}),j?(0,c.jsx)(a.Banner,{kind:j.kind,title:j.text}):null,(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:f?'Saving\u2026':'Make profile',disabled:f||!x,testID:"guest-make-save",onPress:async()=>{w(!0),y(null);try{l(await(0,g.guestMake)({...u,consent:x},t))}catch(e){y({kind:'warn',text:(0,o.plainError)(e)})}finally{w(!1)}}}),(0,c.jsx)(a.Button,{label:"Cancel",kind:"ghost",onPress:i})]})]})})})}function f({g:e,me:t,onSaved:l}){const[h,x]=(0,s.useState)(e.allergies),[p,j]=(0,s.useState)(t),[y,f]=(0,s.useState)(null),[w,k]=(0,s.useState)(!1);return(0,c.jsxs)(n.default,{style:{gap:8},testID:"guest-allergy-editor",children:[(0,c.jsx)(a.Muted,{children:"Ask the guest and tick what they tell you. Saving puts your name and the time on it."}),(0,c.jsx)(a.Row,{style:{flexWrap:'wrap',gap:6},children:i.ALLERGENS.map(e=>(0,c.jsx)(a.Chip,{label:e.short,selected:h.some(s=>s.allergen===e.id),testID:`guest-allergen-${e.id}`,onPress:()=>x((0,u.toggleAllergy)(h,e.id))},e.id))}),h.map(e=>(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6,alignItems:'center'},children:[(0,c.jsx)(a.T,{weight:"medium",children:i.ALLERGENS.find(s=>s.id===e.allergen)?.short}),i.SEVERITIES.map(s=>(0,c.jsx)(a.Chip,{label:s.label,selected:e.severity===s.id,onPress:()=>x(h.map(t=>t.allergen===e.allergen?{...t,severity:s.id}:t))},s.id))]},e.allergen)),(0,c.jsx)(a.Field,{label:"Checked with the guest by",value:p,onChangeText:j,testID:"guest-allergy-by"}),y?(0,c.jsx)(a.Banner,{kind:y.kind,title:y.text}):null,(0,c.jsx)(a.Button,{label:w?'Saving\u2026':h.length?'Save allergies (checked with the guest)':'Save: no allergies (checked with the guest)',disabled:w,testID:"guest-allergy-save",onPress:async()=>{k(!0),f(null);try{l(await(0,g.guestSignAllergies)(e.id,h,p))}catch(e){f({kind:'warn',text:(0,o.plainError)(e)})}finally{k(!1)}}})]})}function w({id:e,me:l,onClose:i,onErased:y}){const[w,k]=(0,s.useState)(null),[b,v]=(0,s.useState)(null),[S,C]=(0,s.useState)(!1),[D,I]=(0,s.useState)(!1),[T,B]=(0,s.useState)([]),[E,P]=(0,s.useState)(''),[M,A]=(0,s.useState)(''),[R,z]=(0,s.useState)(''),[N,O]=(0,s.useState)(null),F=(0,s.useCallback)(async()=>{try{const s=await(0,g.guestGet)(e);k(s),B(s.preferences),P(s.notes)}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}},[e]);(0,s.useEffect)(()=>{F()},[F]);const G=async e=>{C(!0),v(null);try{await e()}catch(e){v({kind:'warn',text:(0,o.plainError)(e)})}finally{C(!1),O(null)}};if(!w)return(0,c.jsx)(a.Card,{children:(0,c.jsx)(a.Muted,{children:b?b.text:'Opening the profile\u2026'})});const L=w.history,W=w.eraseRequest,$=!!w.erasedAt,_=JSON.stringify((0,u.tidyPrefs)(T))!==JSON.stringify(w.preferences)||E!==w.notes;return(0,c.jsxs)(n.default,{style:{gap:10},testID:"guest-profile",children:[(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between',alignItems:'flex-start'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{size:20,weight:"bold",children:w.name}),(0,c.jsx)(a.Muted,{children:[w.phone,w.email].filter(Boolean).join(' \xb7 ')||($?'Personal details erased':'')})]}),(0,c.jsx)(a.Button,{label:"Back",kind:"ghost",small:!0,onPress:i})]}),$?(0,c.jsx)(a.Banner,{kind:"warn",title:`Erased ${p(w.erasedAt)}`,children:"The profile\u2019s personal details were blanked. Bookings and any website bookings copy keep their own details."}):null,w.consentWithdrawnAt?(0,c.jsx)(a.Banner,{kind:"warn",title:"The guest withdrew consent",children:"Ask a manager to request erasing this profile."}):null,(0,c.jsx)(n.default,{testID:"guest-stats",children:(0,c.jsxs)(a.Row,{style:{flexWrap:"wrap",gap:14},children:[(0,c.jsx)(j,{label:"Visits",value:L.visits}),(0,c.jsx)(j,{label:"Covers",value:L.covers}),(0,c.jsx)(j,{label:"No-shows",value:L.noShows}),(0,c.jsx)(j,{label:"Upcoming",value:L.upcoming})]})}),(0,c.jsxs)(a.Muted,{size:12,children:["From real bookings matched by phone or email. First visit ",x(L.firstVisit)," \xb7 last visit ",x(L.lastVisit),"."]})]})}),(0,c.jsx)(n.default,{testID:"guest-allergies",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Allergies"}),$?null:(0,c.jsx)(a.Button,{label:D?'Close':'Check with the guest',kind:"ghost",small:!0,testID:"guest-allergy-edit",onPress:()=>I(!D)})]}),w.allergiesSignedAt?(0,c.jsxs)(n.default,{style:{gap:2},children:[(0,c.jsx)(a.T,{weight:"medium",colour:w.allergies.length?h.colours.amber:h.colours.text,children:(0,u.allergyLine)(w.allergies)}),(0,c.jsxs)(a.Muted,{size:12,children:["Checked with the guest by ",w.allergiesSignedBy,", ",p(w.allergiesSignedAt),". Check again at every visit."]})]}):(0,c.jsx)(a.Muted,{children:"Not checked yet. Nothing is assumed: ask the guest."}),D?(0,c.jsx)(f,{g:w,me:l,onSaved:e=>{k(e),I(!1),v({kind:'success',text:'Allergies saved with your name'})}}):null]})})}),$?null:(0,c.jsx)(n.default,{testID:"guest-prefs",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Preferences and notes"}),(0,c.jsxs)(a.Row,{style:{flexWrap:'wrap',gap:6},children:[T.map(e=>(0,c.jsxs)(n.default,{testID:"guest-pref",style:{flexDirection:'row',alignItems:'center',minHeight:44,paddingLeft:14,paddingRight:2,borderRadius:22,borderWidth:1.5,borderColor:h.colours.gold,backgroundColor:h.colours.goldTint},children:[(0,c.jsx)(a.T,{size:14,weight:"semibold",colour:h.colours.goldLight,children:e}),(0,c.jsx)(t.GoldClose,{size:"sm",label:`Remove ${e}`,onPress:()=>B(T.filter(s=>s!==e))})]},e)),u.PREFERENCE_IDEAS.filter(e=>!T.includes(e)).slice(0,6).map(e=>(0,c.jsx)(a.Chip,{label:`${e}`,onPress:()=>B((0,u.tidyPrefs)([...T,e]))},e))]}),(0,c.jsxs)(a.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,c.jsx)(n.default,{style:{flex:1},children:(0,c.jsx)(a.Field,{label:"Add a preference",value:M,onChangeText:A,testID:"guest-pref-new"})}),(0,c.jsx)(a.Button,{label:"Add",kind:"ghost",small:!0,onPress:()=>{B((0,u.tidyPrefs)([...T,M])),A('')}})]}),(0,c.jsx)(a.Field,{label:"Notes (the guest can ask to see these)",value:E,onChangeText:P,multiline:!0,testID:"guest-notes"}),_?(0,c.jsx)(a.Button,{label:S?'Saving\u2026':'Save preferences and notes',disabled:S,testID:"guest-prefs-save",onPress:()=>G(async()=>{const e=await(0,g.guestUpdate)(w.id,(0,u.tidyPrefs)(T),E,l);k(e),B(e.preferences),P(e.notes),v({kind:'success',text:'Saved'})})}):null]})})}),(0,c.jsx)(n.default,{testID:"guest-history",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:4},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Recent bookings"}),L.bookings.length?L.bookings.map((e,s)=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(a.T,{children:[x(e.date)," ",e.time]}),(0,c.jsxs)(a.Muted,{children:[e.covers," Covers \xb7 ",u.STATUS_WORDS[e.status]??e.status]})]},s)):(0,c.jsx)(a.Muted,{children:"No bookings match yet."}),w.loyalty?(0,c.jsxs)(a.Muted,{size:12,children:["Stamp card ",w.loyalty.cardNo,", joined ",x(w.loyalty.joined),"."]}):(0,c.jsx)(a.Muted,{size:12,children:"No stamp card linked."})]})})}),(0,c.jsx)(n.default,{testID:"guest-consent",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Consent (GDPR)"}),(0,c.jsxs)(a.Muted,{size:12,children:["\u201c",w.consentText,"\u201d Taken by ",w.consentBy,", ",p(w.consentAt),"."]}),$||w.consentWithdrawnAt?null:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a.Toggle,{label:"Happy to hear about offers (we still send nothing: messages are off)",value:w.marketingOk,onChange:e=>G(async()=>k(await(0,g.guestConsent)(w.id,e,!1,l))),testID:"guest-marketing"}),'withdraw'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, the guest withdrew consent",kind:"danger",small:!0,onPress:()=>G(async()=>k(await(0,g.guestConsent)(w.id,!1,!0,l)))}),(0,c.jsx)(a.Button,{label:"Keep",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Guest withdrew consent",kind:"ghost",small:!0,onPress:()=>O('withdraw')})]})]})})}),w.canManage?(0,c.jsx)(n.default,{testID:"guest-manager",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:8},children:[(0,c.jsx)(a.T,{weight:"semibold",children:"Manager"}),(0,c.jsx)(a.Button,{label:"Export everything we hold (file on this device)",kind:"ghost",testID:"guest-export",disabled:S,onPress:()=>G(async()=>{const e=await(0,g.guestExport)(w.id,l),s=(0,u.exportFileName)(w.name,new Date);v({kind:'success',text:(0,g.saveJsonFile)(s,e)?`Saved ${s}. Nothing was sent: hand it to the guest yourself.`:'Export made. Open the Managers app in a browser to save the file.'}),k(await(0,g.guestGet)(w.id))})}),!W||'waiting'!==W.status&&'approved'!==W.status?$?null:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsx)(a.Field,{label:"Ask to erase: reason",value:R,onChangeText:z,placeholder:"e.g. Guest asked by phone",testID:"guest-erase-reason"}),(0,c.jsx)(a.Button,{label:"Ask the owner to erase this profile",kind:"ghost",small:!0,disabled:S||R.trim().length<3,testID:"guest-erase-ask",onPress:()=>G(async()=>{await(0,g.guestEraseAsk)(w.id,R,l),z(''),k(await(0,g.guestGet)(w.id)),v({kind:'success',text:'Asked. It waits for the owner; nothing is erased yet.'})})})]}):(0,c.jsxs)(n.default,{style:{gap:6},testID:"guest-erase-status",children:[(0,c.jsx)(a.Badge,{kind:"amber",label:'waiting'===W.status?'Erase request waiting for the owner':'Owner approved erasing'}),(0,c.jsxs)(a.Muted,{size:12,children:["Asked by ",W.askedBy,", ",p(W.askedAt),": \u201c",W.reason,"\u201d"]}),w.isOwner&&'waiting'===W.status?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Approve erasing",kind:"danger",small:!0,testID:"guest-erase-approve",onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!0,l),k(await(0,g.guestGet)(w.id))})}),(0,c.jsx)(a.Button,{label:"Decline",kind:"ghost",small:!0,onPress:()=>G(async()=>{await(0,g.guestEraseDecide)(W.id,!1,l),k(await(0,g.guestGet)(w.id))})})]}):null,w.isOwner&&'approved'===W.status?'erase'===N?(0,c.jsxs)(a.Row,{style:{gap:8},children:[(0,c.jsx)(a.Button,{label:"Yes, erase now",kind:"danger",small:!0,testID:"guest-erase-now-yes",onPress:()=>G(async()=>{await(0,g.guestEraseApply)(W.id,l),y()})}),(0,c.jsx)(a.Button,{label:"Not now",kind:"ghost",small:!0,onPress:()=>O(null)})]}):(0,c.jsx)(a.Button,{label:"Erase now",kind:"danger",small:!0,testID:"guest-erase-now",onPress:()=>O('erase')}):null,w.isOwner?null:(0,c.jsx)(a.Muted,{size:12,children:"Only the owner can approve and erase. Nothing happens until they do."})]}),w.audit?.length?(0,c.jsxs)(n.default,{style:{gap:2},testID:"guest-audit",children:[(0,c.jsx)(a.Muted,{weight:"medium",children:"Audit trail"}),w.audit.slice(0,8).map((e,s)=>(0,c.jsxs)(a.Muted,{size:12,children:[p(e.at)," \xb7 ",u.AUDIT_WORDS[e.action]??e.action,e.detail?`: ${e.detail}`:''," \xb7 ",e.by]},s))]}):null]})})}):null,b?(0,c.jsx)(a.Banner,{kind:b.kind,title:b.text}):null]})}function k({onOpen:e}){const[t,l]=(0,s.useState)(null);return(0,s.useEffect)(()=>{(0,g.guestEraseList)().then(l).catch(()=>l([]))},[]),t?.length?(0,c.jsx)(n.default,{testID:"guest-erase-queue",children:(0,c.jsx)(a.Card,{children:(0,c.jsxs)(n.default,{style:{gap:6},children:[(0,c.jsxs)(a.T,{weight:"semibold",children:["Erase requests waiting (",t.length,")"]}),t.map(s=>(0,c.jsxs)(a.Row,{style:{justifyContent:'space-between'},children:[(0,c.jsxs)(n.default,{style:{flex:1},children:[(0,c.jsx)(a.T,{children:s.name}),(0,c.jsxs)(a.Muted,{size:12,children:['waiting'===s.status?'Waiting for the owner':'Approved, not erased yet'," \xb7 asked by ",s.askedBy]})]}),(0,c.jsx)(a.Button,{label:"Open",kind:"ghost",small:!0,onPress:()=>s.profileId&&e(s.profileId)})]},s.id))]})})}):null}},1420,[34,796,102,794,861,1260,1421,1422,821,25]); +__d(function(g,r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GUEST_CONSENT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"PREFERENCE_IDEAS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"AUDIT_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"STATUS_WORDS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"allergyLine",{enumerable:!0,get:function(){return l}}),e.tidyPrefs=function(t){const n=new Set,a=[];for(const o of t){const t=o.trim().slice(0,60),s=t.toLowerCase();t&&!n.has(s)&&(n.add(s),a.push(t))}return a.slice(0,20)},e.toggleAllergy=function(t,n,a="allergy"){return t.some(t=>t.allergen===n)?t.filter(t=>t.allergen!==n):[...t,{allergen:n,severity:a}]},e.exportFileName=function(t,n){const a=t.split(/\s+/).filter(Boolean).map(t=>t[0].toUpperCase()).join('').replace(/[^A-Z]/g,'').slice(0,3)||'G',o=n.toISOString().slice(0,10);return`guest-data-${a}-${o}.json`},e.visitWords=function(t,n){return t?`${t} visit${1===t?'':'s'} \xb7 ${n} Covers`:'No visits yet'};var t=r(_d[0]);const n='Guest agreed we can keep a profile with their visits, preferences and allergies, to look after them when they come back. They can ask to see it or have it erased at any time.',a=['Window table','Quiet corner','Booth','High chair','Step-free access','Dog with them','Still water','Sparkling water','Vegetarian','Vegan'],o={made:'Profile made',details:'Preferences or notes changed',allergies:'Allergies checked and saved',consent:'Consent changed',export:'Data exported','erase-asked':'Asked to erase','erase-approved':'Owner approved erasing','erase-declined':'Owner declined erasing',erased:'Erased'},s={finished:'Visited',seated:'Visited',confirmed:'Booked',pending:'Waiting to confirm',cancelled:'Cancelled',noshow:'No-show'},l=n=>n.length?n.map(n=>`${(0,t.allergenLabel)(n.allergen)} (${(0,t.severityLabel)(n.severity)})`).join(', '):'None'},1421,[861]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"staffServer",{enumerable:!0,get:function(){return u.staffServer}}),Object.defineProperty(e,"guestSearch",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"guestGet",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"guestMake",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"guestUpdate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"guestSignAllergies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"guestConsent",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"guestExport",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"guestEraseAsk",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"guestEraseDecide",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"guestEraseApply",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"guestEraseList",{enumerable:!0,get:function(){return j}}),e.saveJsonFile=function(t,n){if('undefined'==typeof document||'undefined'==typeof Blob)return!1;const u=new Blob([JSON.stringify(n,null,2)],{type:'application/json'}),p=URL.createObjectURL(u),o=document.createElement('a');return o.href=p,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(p),2e3),!0};var t=r(d[0]),n=r(d[1]),u=r(d[2]);const p=()=>{const n=t.useSync.getState().venueId;if(!n)throw new Error('Not connected to the venue yet.');return n},o=n=>(0,t.rpc)('guest_search',{p_venue:p(),p_q:n}),c=n=>(0,t.rpc)('guest_profile_get',{p_id:n}),s=(u,o)=>(0,t.rpc)('guest_profile_make',{p_venue:p(),p_name:u.name.trim(),p_phone:u.phone.trim()||null,p_email:u.email.trim()||null,p_consent:u.consent,p_consent_text:n.GUEST_CONSENT,p_by:o}),_=(n,u,p,o)=>(0,t.rpc)('guest_profile_update',{p_id:n,p_preferences:u,p_notes:p,p_by:o}),a=(n,u,p)=>(0,t.rpc)('guest_profile_sign_allergies',{p_id:n,p_allergies:u,p_by:p}),f=(n,u,p,o)=>(0,t.rpc)('guest_profile_consent',{p_id:n,p_marketing:u,p_withdraw:p,p_by:o}),l=(n,u)=>(0,t.rpc)('guest_profile_export',{p_id:n,p_by:u}),b=(n,u,p)=>(0,t.rpc)('guest_erase_request',{p_id:n,p_reason:u,p_by:p}),y=(n,u,p)=>(0,t.rpc)('guest_erase_decide',{p_req:n,p_ok:u,p_by:p}),O=(n,u)=>(0,t.rpc)('guest_erase_apply',{p_req:n,p_by:u}),j=()=>(0,t.rpc)('guest_erase_list',{p_venue:p()})},1422,[987,1421,1263]); +__d(function(_g,_r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GiftTill=b,_e.GiftTillManager=y,_e.GiftShopManager=w,_e.PaymentsTestMode=S,_e.GiftCardsPage=function({me:e}){return(0,p.staffServer)()?(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(b,{me:e}),(0,x.can)('orders.manage')?(0,j.jsx)(y,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(w,{me:e}):null,(0,x.can)('venue.settings')?(0,j.jsx)(S,{me:e}):null]}):(0,j.jsx)(r.Banner,{kind:"demo",title:"Gift cards are saved on the server",children:"Sign this device in to your venue to check and take gift cards. There are no example cards here."})};var e,t=_r(d[0]),s=_r(d[1]),n=_r(d[2]),a=_r(d[3]),l=(e=a)&&e.__esModule?e:{default:e},r=_r(d[4]),o=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),p=_r(d[10]),g=_r(d[11]),j=_r(d[12]);const f=e=>{if(!e)return'';try{return new Date(e).toLocaleDateString('en-GB',{day:'numeric',month:'short',year:'numeric',timeZone:'Europe/London'})}catch{return e.slice(0,10)}},m=({m:e})=>e?(0,j.jsx)(r.Banner,{kind:e.kind,title:e.text}):null;function b({me:e}){const[t,s]=(0,n.useState)(''),[a,x]=(0,n.useState)(null),[p,b]=(0,n.useState)(''),[y,w]=(0,n.useState)((0,u.redeemKey)()),[k,S]=(0,n.useState)(null),[T,C]=(0,n.useState)(!1),v=(0,u.poundsToPence)(p);return(0,j.jsx)(l.default,{testID:"gift-till",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Check a gift card or take it off the bill"}),(0,j.jsx)(r.Field,{label:"Gift card code",value:t,autoCapitalize:"characters",onChangeText:e=>{s(e),x(null),w((0,u.redeemKey)())},placeholder:"XXXX-XXXX-XXXX-XXXX",testID:"gift-code"}),(0,j.jsx)(r.Button,{label:T?'Checking\u2026':'Check balance',kind:"ghost",small:!0,disabled:T||t.replace(/\W/g,'').length<6,testID:"gift-check",onPress:async()=>{C(!0),S(null);try{const e=await(0,h.giftCheck)(t);x(e),e.found||S({kind:'warn',text:'No gift card with that code here.'})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}}),a?.found?(0,j.jsxs)(l.default,{style:{gap:4},testID:"gift-card-found",children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",children:(0,u.prettyGiftCode)(t)}),(0,j.jsx)(r.T,{size:20,weight:"bold",colour:g.colours.gold,children:(0,o.gbp)(a.balancePence)})]}),(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[a.status]??a.status," \xb7 of ",(0,o.gbp)(a.initialPence),a.expiresAt?` \xb7 use by ${f(a.expiresAt)}`:'','wix'===a.source?' \xb7 old website bookings card':'']}),'active'===a.status?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Amount to take off \xa3",value:p,onChangeText:b,keyboardType:"decimal-pad",testID:"gift-amount"}),(0,j.jsx)(r.Button,{label:T?'Taking it off\u2026':v?`Take ${(0,o.gbp)(v)} off the card`:'Take it off the card',disabled:T||!v||v>a.balancePence,testID:"gift-redeem",onPress:async()=>{C(!0),S(null);try{const s=await(0,h.giftRedeem)(t,v,y,e);x({...a,...s,found:!0}),b(''),w((0,u.redeemKey)()),S({kind:'success',text:`${s.already?'Already taken: ':'Taken '}${(0,o.gbp)(s.redeemedPence)}. ${(0,o.gbp)(s.balancePence)} left on the card.`})}catch(e){S({kind:'warn',text:(0,c.plainError)(e)})}finally{C(!1)}}})]}):null]}):null,(0,j.jsx)(m,{m:k})]})})})}function y({me:e}){const[t,s]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)(''),[k,S]=(0,n.useState)(''),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)(null),I=(0,n.useCallback)(()=>{(0,h.waitingCards)().then(s).catch(()=>{}),(0,h.shopOrders)().then(x).catch(()=>{})},[]);(0,n.useEffect)(()=>{I()},[I]);const D=async(e,t)=>{b(null);try{await e(),b({kind:'success',text:t}),I()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}},M=t.filter(e=>'waiting-payment'===e.status),_=a.filter(e=>!['collected','cancelled'].includes(e.status)),B=(0,u.poundsToPence)(y);return(0,j.jsxs)(l.default,{style:{gap:10},children:[(0,j.jsx)(l.default,{testID:"gift-waiting",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsxs)(r.T,{weight:"semibold",children:["Waiting for payment at the till (",M.length+_.filter(e=>'waiting-payment'===e.status).length,")"]}),(0,j.jsx)(r.Muted,{size:12,children:"Card payment in the app isn\u2019t on yet. Take the money at the till, then mark it paid here."}),M.map(t=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Gift card ",t.ref," \xb7 ",(0,o.gbp)(t.initial_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:["for ",t.recipient_name||'no name'," \xb7 ends ",t.last4]})]}),(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,testID:`gift-paid-${t.ref}`,onPress:()=>D(()=>(0,h.giftActivate)(t.id,e),`${t.ref} is ready to use`)})]},t.id)),_.map(t=>(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(l.default,{style:{flex:1},children:[(0,j.jsxs)(r.T,{children:["Shop ",t.ref," \xb7 ",t.guest_name," \xb7 ",(0,o.gbp)(t.total_pence)]}),(0,j.jsxs)(r.Muted,{size:12,children:[t.lines.map(e=>`${e.qty}\xd7 ${e.name}`).join(', ')," \xb7 ",u.STATUS_WORDS[t.status]]})]}),'waiting-payment'===t.status?(0,j.jsx)(r.Button,{label:"Paid at the till",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'paid','',e),`${t.ref} paid`)}):'paid'===t.status?(0,j.jsx)(r.Button,{label:"Ready",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'ready','',e),`${t.ref} ready`)}):(0,j.jsx)(r.Button,{label:"Collected",small:!0,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'collected','',e),`${t.ref} collected`)})]}),v&&v.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:v.reason,onChangeText:e=>P({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel order",kind:"danger",small:!0,disabled:v.reason.trim().length<3,onPress:()=>D(()=>(0,h.shopStatus)(t.id,'cancelled',v.reason,e),`${t.ref} cancelled, stock put back`).then(()=>P(null))})]}):(0,j.jsx)(r.Button,{label:"Cancel with a reason",kind:"ghost",small:!0,onPress:()=>P({id:t.id,reason:''})})]},t.id)),M.length||_.length?null:(0,j.jsx)(r.Muted,{children:"Nothing waiting."})]})})}),(0,j.jsx)(l.default,{testID:"gift-sell",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Sell a gift card at the till"}),(0,j.jsx)(r.Field,{label:"Amount \xa3",value:y,onChangeText:w,keyboardType:"decimal-pad",testID:"gift-sell-amount"}),(0,j.jsx)(r.Field,{label:"Who it\u2019s for (optional)",value:k,onChangeText:S}),(0,j.jsx)(r.Button,{label:B?`Paid ${(0,o.gbp)(B)} at the till: make the card`:'Make the card',small:!0,disabled:!B,testID:"gift-sell-btn",onPress:()=>D(async()=>{const t=await(0,h.giftIssue)(B,k,e);C(t),w(''),S('')},'Card made')}),T?.code?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{size:22,weight:"bold",colour:g.colours.gold,center:!0,children:T.code}),(0,j.jsxs)(r.Muted,{center:!0,size:12,children:["Shown once: write it on the card or receipt now. ",(0,o.gbp)(T.initialPence),", use by ",f(T.expiresAt),"."]})]}):null]})})}),(0,j.jsx)(m,{m:p})]})}function w({me:e}){const[t,s]=(0,n.useState)(null),[a,x]=(0,n.useState)(''),[p,b]=(0,n.useState)(null),[y,w]=(0,n.useState)([]),[k,S]=(0,n.useState)({name:'',price:'',details:''}),[T,C]=(0,n.useState)(null),[v,P]=(0,n.useState)({code:'',bal:''}),[I,D]=(0,n.useState)([]),[M,_]=(0,n.useState)(null),B=(0,n.useCallback)(()=>{(0,h.readShopSettings)().then(e=>{s(e),x(e.amounts.map(e=>String(e/100)).join(', '))}).catch(e=>C({kind:'warn',text:(0,c.plainError)(e)})),(0,h.readProducts)().then(w).catch(()=>{}),(0,h.giftSummary)().then(b).catch(()=>{}),(0,h.waitingCards)().then(D).catch(()=>{})},[]);(0,n.useEffect)(()=>{B()},[B]);const R=async(e,t)=>{C(null);try{await e(),C({kind:'success',text:t}),B()}catch(e){C({kind:'warn',text:(0,c.plainError)(e)})}};if(!t)return(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:T?.text??'Loading\u2026'})});const z=(0,u.amountsFromText)(a);return(0,j.jsxs)(l.default,{style:{gap:10},children:[p?(0,j.jsx)(l.default,{testID:"gift-summary",children:(0,j.jsxs)(r.Row,{style:{gap:8},children:[(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Sold (paid)"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.soldPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Still to spend"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:(0,o.gbp)(p.outstandingPence)})]}),(0,j.jsxs)(r.Card,{style:{flex:1},children:[(0,j.jsx)(r.Muted,{children:"Waiting"}),(0,j.jsx)(r.T,{size:20,weight:"bold",children:p.waiting})]})]})}):null,(0,j.jsx)(l.default,{testID:"gift-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Gift cards and shop settings"}),(0,j.jsx)(r.Toggle,{label:"Sell gift cards in the customer app",value:t.giftsOn,onChange:e=>s({...t,giftsOn:e}),testID:"gift-on"}),(0,j.jsx)(r.Toggle,{label:"Open the shop in the customer app",value:t.shopOn,onChange:e=>s({...t,shopOn:e}),testID:"shop-on"}),(0,j.jsxs)(r.T,{children:["Cards last ",(0,u.expiryWords)(t.expiryMonths)," from when they\u2019re paid"]}),(0,j.jsx)(r.Stepper,{value:t.expiryMonths,min:1,max:60,label:"Gift card expiry in months",onChange:e=>s({...t,expiryMonths:e})}),(0,j.jsx)(r.Field,{label:"Amounts guests can pick (\xa3, comma between)",value:a,onChangeText:x,testID:"gift-amounts"}),(0,j.jsx)(r.Field,{label:"Terms shown to guests (optional)",value:t.terms,onChangeText:e=>s({...t,terms:e}),multiline:!0}),(0,j.jsx)(r.Muted,{size:12,children:"Gift cards are sold through your website. Guests can also pay at the bar or till."}),(0,j.jsx)(r.Button,{label:"Save",disabled:!z,testID:"gift-settings-save",onPress:()=>R(()=>(0,h.saveShopSettings)({...t,amounts:z}),'Saved. The customer app shows it next time it opens.')})]})})}),(0,j.jsx)(l.default,{testID:"shop-products",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Shop products"}),y.map(e=>(0,j.jsxs)(l.default,{style:{gap:4,borderTopWidth:1,borderColor:g.colours.border,paddingTop:6},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(r.T,{weight:"medium",style:{flex:1},children:e.name}),(0,j.jsx)(r.T,{children:(0,o.gbp)(e.price_pence)})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Toggle,{label:e.is_live?'In the shop':'Hidden',a11y:`${e.name} in the shop`,value:e.is_live,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:e.stock,live:t}),'Saved')})}),(0,j.jsxs)(l.default,{style:{alignItems:'flex-end'},children:[(0,j.jsx)(r.Muted,{size:12,children:"Stock"}),(0,j.jsx)(r.Stepper,{value:e.stock,min:0,max:500,label:`${e.name} stock`,onChange:t=>R(()=>(0,h.saveProduct)({id:e.id,name:e.name,details:e.details,pricePence:e.price_pence,stock:t,live:e.is_live}),'Stock saved')})]})]}),0===e.stock?(0,j.jsx)(r.Badge,{kind:"amber",label:"Sold out"}):null]},e.id)),y.length?null:(0,j.jsx)(r.Muted,{children:"No products yet."}),(0,j.jsx)(r.Field,{label:"New product name",value:k.name,onChangeText:e=>S({...k,name:e}),testID:"shop-new-name"}),(0,j.jsx)(r.Field,{label:"Price \xa3",value:k.price,onChangeText:e=>S({...k,price:e}),keyboardType:"decimal-pad",testID:"shop-new-price"}),(0,j.jsx)(r.Field,{label:"Details (optional)",value:k.details,onChangeText:e=>S({...k,details:e})}),(0,j.jsx)(r.Button,{label:"Add product (hidden until you switch it on)",kind:"ghost",small:!0,disabled:k.name.trim().length<2||!(0,u.poundsToPence)(k.price),onPress:()=>R(async()=>{await(0,h.saveProduct)({name:k.name,details:k.details,pricePence:(0,u.poundsToPence)(k.price),stock:0,live:!1}),S({name:'',price:'',details:''})},'Product added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-wix",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:6},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Honour an old website bookings gift card"}),(0,j.jsx)(r.Muted,{size:12,children:"Check the balance in your website bookings dashboard first. Each website bookings code can be added once."}),(0,j.jsx)(r.Field,{label:"Website bookings code",value:v.code,autoCapitalize:"characters",onChangeText:e=>P({...v,code:e})}),(0,j.jsx)(r.Field,{label:"Balance you checked in website bookings \xa3",value:v.bal,keyboardType:"decimal-pad",onChangeText:e=>P({...v,bal:e})}),(0,j.jsx)(r.Button,{label:"Add to CoverCharge",kind:"ghost",small:!0,disabled:v.code.replace(/\W/g,'').length<6||!(0,u.poundsToPence)(v.bal),onPress:()=>R(async()=>{await(0,h.giftHonourWix)(v.code,(0,u.poundsToPence)(v.bal),e),P({code:'',bal:''})},'Website bookings card added')})]})})}),(0,j.jsx)(l.default,{testID:"gift-list",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:4},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Recent cards"}),I.map(t=>(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.T,{style:{flex:1},children:[t.ref," \xb7 ends ",t.last4," \xb7 ",'wix'===t.source?'Website bookings':'till'===t.source?'Till':'App']}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(t.balance_pence)," / ",(0,o.gbp)(t.initial_pence)]})]}),(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{size:12,children:[u.STATUS_WORDS[t.status]??t.status,t.expires_at?` \xb7 use by ${f(t.expires_at)}`:'']}),'void'!==t.status&&M?.id!==t.id?(0,j.jsx)(r.Button,{label:"Cancel card",kind:"ghost",small:!0,onPress:()=>_({id:t.id,reason:''})}):null]}),M&&M.id===t.id?(0,j.jsxs)(r.Row,{style:{gap:6,alignItems:'flex-end'},children:[(0,j.jsx)(l.default,{style:{flex:1},children:(0,j.jsx)(r.Field,{label:"Reason",value:M.reason,onChangeText:e=>_({id:t.id,reason:e})})}),(0,j.jsx)(r.Button,{label:"Cancel it",kind:"danger",small:!0,disabled:M.reason.trim().length<3,onPress:()=>R(()=>(0,h.giftVoid)(t.id,M.reason,e),'Card cancelled (kept on record)').then(()=>_(null))})]}):null]},t.id)),I.length?null:(0,j.jsx)(r.Muted,{children:"No cards yet."})]})})}),(0,j.jsx)(m,{m:T})]})}const k={none:'Pay at the till only',stripe:'Stripe (test mode)',wix:'Website bookings payments (coming)'};function S({me:e}){if(t.IS_GREENSIDE)return(0,j.jsx)(s.GreensideCashOnly,{});const[a,u]=(0,n.useState)(null),[x,p]=(0,n.useState)([]),[g,b]=(0,n.useState)(null),y=(0,n.useCallback)(()=>{(0,h.readPaySettings)().then(u).catch(e=>b({kind:'warn',text:(0,c.plainError)(e)})),(0,h.recentPayments)().then(p).catch(()=>{})},[]);return(0,n.useEffect)(()=>{y()},[y]),a?(0,j.jsx)(l.default,{testID:"pay-settings",children:(0,j.jsx)(r.Card,{children:(0,j.jsxs)(l.default,{style:{gap:8},children:[(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between',alignItems:'center'},children:[(0,j.jsx)(r.T,{weight:"semibold",children:"Card payments"}),(0,j.jsx)(r.Badge,{kind:"amber",label:"TEST MODE"})]}),(0,j.jsx)(r.Banner,{kind:"demo",title:"Test mode only: no real money",children:"This build can\u2019t take live payments. Guests pay at the bar or till unless you switch on Stripe test mode below."}),(0,j.jsx)(r.Row,{wrap:!0,children:['none','stripe','wix'].map(e=>(0,j.jsx)(r.Chip,{label:k[e],selected:a.provider===e,onPress:()=>u({...a,provider:e,cardOn:'stripe'===e&&a.cardOn})},e))}),'stripe'===a.provider?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(r.Field,{label:"Venue\u2019s Stripe account id (starts acct_)",value:a.account,autoCapitalize:"none",onChangeText:e=>u({...a,account:e.trim()}),placeholder:"acct_\u2026",testID:"pay-account"}),(0,j.jsx)(r.Muted,{size:12,children:"Money goes straight to the venue\u2019s own Stripe account. Never paste a key here."}),(0,j.jsx)(r.Toggle,{label:"Offer \u201cPay by card (test mode)\u201d in the customer app",value:a.cardOn,onChange:e=>u({...a,cardOn:e}),testID:"pay-card-on"}),(0,j.jsx)(r.Muted,{size:12,children:"Needs CoverCharge\u2019s Stripe sandbox to be set up first (Gordon\u2019s step). Until then guests see pay at the till."})]}):null,'wix'===a.provider?(0,j.jsx)(r.Banner,{kind:"demo",title:"Website bookings payments aren\u2019t linked yet",children:"Website bookings venues keep taking payments on their website. In the app, guests pay at the bar or till."}):null,(0,j.jsx)(r.Button,{label:"Save",testID:"pay-save",onPress:async()=>{b(null);try{await(0,h.savePaySettings)(a),b({kind:'success',text:'Saved'}),y()}catch(e){b({kind:'warn',text:(0,c.plainError)(e)})}}}),x.length?(0,j.jsxs)(l.default,{style:{gap:2},children:[(0,j.jsx)(r.T,{weight:"medium",children:"Recent test payments"}),x.map(e=>(0,j.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(r.Muted,{children:['gift'===e.kind?'Gift card':'Shop'," \xb7 ",f(e.created_at)]}),(0,j.jsxs)(r.T,{children:[(0,o.gbp)(e.amount_pence)," \xb7 ",e.status]})]},e.id))]}):null,(0,j.jsx)(m,{m:g})]})})}):(0,j.jsx)(r.Card,{children:(0,j.jsx)(r.Muted,{children:g?.text??'Loading\u2026'})})}},1423,[5,1424,34,102,794,867,1260,1261,1262,987,1263,821,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.GreensideCashOnly=function(){return(0,s.jsxs)(n.Card,{children:[(0,s.jsx)(n.T,{weight:"semibold",children:"Cash only"}),(0,s.jsx)(n.Muted,{children:"Card payments and online checkout are not enabled for The Greenside Restaurant. Deposits are off; the policy needs confirmation."})]})},r(d[0]);var n=r(d[1]),s=r(d[2])},1424,[34,794,25]); +__d(function(g,_r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.newerRelease=r,_e.startForegroundRefresh=function(n={}){if('undefined'==typeof document)return()=>{};let o='hidden'===document.visibilityState?Date.now():0,c=!1;const s=n.reload??(()=>location.reload()),u=async()=>{if(!c){c=!0;try{await Promise.race([e.mutationQueue.retryNow(),new Promise(e=>setTimeout(e,4e3))]),n.onWake?.();const t=await(navigator.serviceWorker?.getRegistration?.().catch(()=>{}));if(await(t?.update?.().catch(()=>{})),t?.waiting){try{t.waiting.postMessage({type:'SKIP_WAITING'})}catch{}return void setTimeout(s,3e3)}await r().catch(()=>!1)&&s()}finally{c=!1}}},l=()=>{if('hidden'===document.visibilityState)return void(o=Date.now());const n=o?Date.now()-o:0;o=0,e.mutationQueue.retryNow(),n>=t&&u()},f=()=>{e.mutationQueue.retryNow()};document.addEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.addEventListener(e,f);return()=>{document.removeEventListener('visibilitychange',l);for(const e of['focus','online','pageshow'])window.removeEventListener(e,f)}},_r(d[0]);var e=_r(d[1]);const t=3e4,n=e=>(e.match(/_expo\/static\/js\/web\/[A-Za-z0-9_.-]+\.js(\?v=[0-9a-f]+)?/)??[])[0]??null;function o(){try{const e=[...document.querySelectorAll('script[src]')].map(e=>e.src).find(e=>/_expo\/static\/js\/web\//.test(e));return e?n(e):null}catch{return null}}async function r(e=fetch){const t=o();if(!t)return!1;const r=location.pathname.replace(/[^/]*$/,''),c=await e(`${r}index.html?fresh=${Date.now()}`,{cache:'no-store'});if(!c.ok)return!1;const s=n(await c.text());return!!s&&s!==t}},1425,[236,1014]); +__d(function(g,_r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.CashUpAccessToggle=function({m:e}){const c=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]),l=(0,o.useCashAccess)(e=>e.loaded),b=(0,r.useSync)(e=>'staff'===e.kind&&!!e.venueId),[y,C]=(0,s.useState)(!1),[m,x]=(0,s.useState)(null);if((0,s.useEffect)(()=>{b&&!l&&(0,u.refreshCashAccess)()},[b,l]),p(e))return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},accessible:!0,accessibilityLabel:`${f(e)} can use cash up: always, as ${'owner'===e.role?'an owner':'a manager'}`,children:[(0,h.jsx)(n.T,{size:14,children:"Can use cash up"}),(0,h.jsxs)(n.Muted,{size:12,children:["Always on for ",'owner'===e.role?'owners':'managers',"."]})]});const j=async s=>{C(!0),x(null);const c=await(0,u.setStaffCashUp)(e.id,s);C(!1),x(c.ok?s?`${f(e)} can now open the cash up. The change is in the cash-up log.`:`${f(e)} can no longer open the cash up. The change is in the cash-up log.`:c.error??'Could not save.')};return(0,h.jsxs)(t.default,{testID:`cashup-access-${e.id}`,style:{gap:2},children:[(0,h.jsx)(n.Toggle,{testID:`cashup-toggle-${e.id}`,label:"Can use cash up",value:c,disabled:y||!b,onChange:e=>{j(e)}}),(0,h.jsx)(n.Muted,{size:12,children:b?c?'Can open the cash up, take a picture of the taking sheet and upload a spreadsheet.':'Off: the cash up is hidden from them and the server refuses it.':'Connect to the shared team to change this.'}),m?(0,h.jsx)(t.default,{accessibilityLiveRegion:"polite",children:(0,h.jsx)(n.Muted,{size:12,testID:`cashup-msg-${e.id}`,children:m})}):null]})},_e.CashUpAccessBadge=function({m:e}){const s=(0,o.useCashAccess)(s=>!0===s.byRef[e.id]);return p(e)||s?(0,h.jsx)(t.default,{accessible:!0,accessibilityLabel:`${f(e)} can use cash up`,testID:`cashup-badge-${e.id}`,children:(0,h.jsx)(n.Badge,{kind:"gold",label:"Cash up"})}):null},_e.NoCashUpAccess=function(){return(0,h.jsxs)(t.default,{testID:"cashup-no-access",accessible:!0,accessibilityRole:"text",accessibilityLabel:"You can't use the cash up yet. A manager can switch it on for you in Staff and roles.",style:{borderWidth:1,borderColor:l.colours.border,borderRadius:14,padding:16,gap:6,backgroundColor:l.colours.surface},children:[(0,h.jsx)(n.T,{size:18,weight:"semibold",children:"You can\u2019t use the cash up yet"}),(0,h.jsx)(n.T,{children:"A manager can switch it on for you in Staff & roles (\u201cCan use cash up\u201d)."})]})};var e,s=_r(d[0]),c=_r(d[1]),t=(e=c)&&e.__esModule?e:{default:e},n=_r(d[2]),l=_r(d[3]),o=_r(d[4]),u=_r(d[5]),r=_r(d[6]),h=_r(d[7]);const p=e=>'owner'===e.role||'manager'===e.role&&!e.managerAccess,f=e=>e.name.replace(' (example)','').split(' ')[0]},1426,[34,102,794,821,999,1052,987,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.Bookings=function({go:e,only:P}={}){const{rid:te,r:le,now:ne,today:ie,me:ae,role:oe}=(0,y.useCtx)(1e4),de=(0,E.useBookings)(te),re=(0,y.useInStaffApp)(),ue=(0,y.useShiftManager)(),ce=(0,E.useWaitlist)(te),[he,ge]=((0,E.useStore)(e=>e.alertAcks),(0,N.useState)(ie)),be=(0,U.useFrontDoor)(he),pe=(0,w.useBookingWrite)(),[ke,xe]=(0,N.useState)(''),[me,ye]=(0,N.useState)(!1),[we,je]=(0,N.useState)(2),fe=hee.date===he).sort((e,s)=>e.time.localeCompare(s.time)),Be=ce.filter(e=>'waiting'===e.status||'notified'===e.status).sort((e,s)=>e.number-s.number),De=Ie.filter(e=>'noshow'===e.status),Se=(0,J.useSync)(e=>!!e.venueId&&'guest'!==e.kind),$e=Ie.filter(e=>'cancelled'!==e.status).reduce((e,s)=>e+s.partySize,0),Te=(0,p.cancelledDayTally)(de,he),Ce=(0,p.cancelledTallyWords)(Te,he===ie?'today':'that day'),Le=Ie.filter(e=>!e.walkIn),ve=Ie.filter(e=>e.walkIn),Ne=de.filter(e=>'pending'===e.status&&e.date>=ie).sort((e,s)=>(e.date+e.time).localeCompare(s.date+s.time)),[Pe,Oe]=(0,N.useState)(null),We=(0,R.parseYmd)(he);We.setHours(12);const Me=(0,ee.hoursFor)(le,We),Ee=Me?.open??new Date(`${he}T12:00:00`),Ae=Me?.close??new Date(`${he}T21:00:00`),Re=Me||Ie.length?fe?'No one seated that day':he===ie?'No bookings yet today':'No bookings yet':he===ie?'Closed today':'Closed that day',ze=Be.length>0||me||'waitlist'===P?(0,se.jsxs)(O.default,{style:{gap:10},children:[(0,se.jsx)(G.SectionHead,{title:`Waitlist (${Be.length})`,sub:`New party waits about ${(0,z.estimateWait)(Be.length+1,le.settings.turnMins,1)} min (estimate)`}),Be.map((e,s)=>(0,se.jsxs)(O.default,{style:W.styles.card,children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:["#",e.number," ",e.name," \xb7 ",e.partySize]}),(0,se.jsxs)(W.Muted,{children:[(0,R.minsBetween)(new Date(e.joinedAt),ne)," min \xb7 est. ",(0,z.estimateWait)(s+1,le.settings.turnMins,1)," min"]})]}),'notified'===e.status?(0,se.jsx)(W.Badge,{kind:"ok",label:"Marked as told: table ready (no text is sent)"}):null,(0,se.jsxs)(W.Row,{gap:6,children:['waiting'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Notify",onPress:()=>E.repo.waitlist.setStatus(e.id,'notified')}):null,(0,se.jsx)(W.Button,{small:!0,label:"Seat",onPress:()=>E.repo.waitlist.setStatus(e.id,'seated')}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Remove",onPress:()=>E.repo.waitlist.setStatus(e.id,'removed')})]})]},e.id)),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(a.TextInput,{accessibilityLabel:"Waitlist name",placeholder:"Name for the waitlist",placeholderTextColor:"#7D776C",value:ke,onChangeText:xe,style:[W.styles.input,{flex:1}]}),(0,se.jsx)(W.Stepper,{value:we,onChange:je,min:1,max:12,label:"party"})]}),(0,se.jsx)(W.Button,{kind:"secondary",label:"Add to waitlist",disabled:ke.trim().length<2,onPress:()=>{E.repo.waitlist.join(te,ke.trim(),we),xe('')}})]}):(0,se.jsx)(W.Button,{kind:"ghost",label:"Open waitlist",onPress:()=>ye(!0),accessibilityLabel:"Open the empty waitlist to add a waiting party"});return'waitlist'===P?(0,se.jsx)(O.default,{style:{gap:12},testID:"bookings-waitlist-only",children:ze}):(0,se.jsxs)(O.default,{style:{gap:12},children:[(0,se.jsx)(l.BookingSaveBanner,{rid:te}),e&&!re&&'staff'!==oe?(0,se.jsx)(W.Button,{testID:"bookings-dashboard-top",label:"Bookings dashboard",accessibilityLabel:"Open Bookings dashboard: table plan, Timeline, today's guests and Covers",onPress:()=>e('more','serviceboard'),style:{width:'100%',minHeight:60}}):null,s.IS_WILDINGS||(s.IS_QUEUED_VENUE||s.IS_KIRKTON||s.IS_GREENSIDE||'abbotsford'===te)&&!re&&'staff'!==oe?(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"table"}):null,!s.IS_WILDINGS&&!le.settings.hotel?.enabled||re||'staff'===oe?null:(0,se.jsx)(i.VenueRequestList,{rid:te,kind:"room",hotel:le.settings.hotel??n.WILDINGS_HOTEL}),(0,se.jsx)(V.BookingsDayNav,{today:ie,date:he,onDate:ge,count:e=>de.filter(s=>s.date===e&&'cancelled'!==s.status).length,sub:e=>{const s=de.filter(s=>s.date===e&&'cancelled'!==s.status&&!s.walkIn),t=s.reduce((e,s)=>e+s.partySize,0);return`${s.length} ${1===s.length?'table':'tables'} \xb7 ${t} ${1===t?'Cover':'Covers'}`}}),(0,se.jsx)(O.default,{testID:"bookings-day-graph",style:{overflow:'visible'},children:(0,se.jsx)(Z.DayGraph,{bare:!0,fill:!0,todays:Ie,open:Ee,close:Ae,now:ne,turnBase:le.settings.turnMins,height:128,past:fe,closed:!Me,emptyText:Re})}),fe?(0,se.jsxs)(O.default,{testID:"bookings-past-totals",style:[W.styles.card,{gap:4}],accessible:!0,accessibilityLabel:`${(0,V.longDay)(he)}: ${Le.length} tables, ${$e} Covers, ${Ie.filter(e=>'finished'===e.status).length} finished, ${De.length} no-shows, ${Ie.filter(e=>'cancelled'===e.status).length} cancelled`,children:[(0,se.jsxs)(W.T,{size:17,weight:"semibold",children:["That day: ",Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']}),(0,se.jsxs)(W.T,{size:16,colour:H.colours.text,children:[Ie.filter(e=>'finished'===e.status).length," finished \xb7 ",De.length," no-show",1===De.length?'':'s'," \xb7 ",Ie.filter(e=>'cancelled'===e.status).length," cancelled"]}),(0,se.jsx)(W.Muted,{children:"Looking back: read-only. Undo is still there for a mistake made today."})]}):null,(0,se.jsx)(O.default,{testID:"bookings-summary",children:(0,se.jsxs)(W.T,{weight:"semibold",children:[Le.length," booking",1===Le.length?'':'s',ve.length?` \xb7 ${ve.length} walk-in${1===ve.length?'':'s'}`:''," \xb7 ",$e," ",1===$e?'Cover':'Covers']})}),re||'staff'===oe||fe?null:(0,se.jsx)(h.BookingsMatchStatus,{}),(0,se.jsx)(O.default,{testID:"cancelled-day-tally",accessible:!0,accessibilityLabel:Ce,style:{alignItems:'center'},children:(0,se.jsx)(W.T,{size:15,colour:H.colours.muted,center:!0,children:Ce})}),(0,se.jsxs)(O.default,{testID:"bookings-actions",style:{flexDirection:'row',flexWrap:'wrap',gap:8},children:[fe?null:(0,se.jsx)($.QuietButton,{label:"New booking",onPress:be.openBooking,testID:"add-booking",disabled:!pe.ok,accessibilityHint:pe.hint}),re&&ue&&he===ie?(0,se.jsx)($.QuietButton,{label:"Walk-in",onPress:be.openWalkIn,testID:"add-walkin",disabled:!pe.ok,accessibilityHint:pe.hint}):null,he===ie?(0,se.jsx)(T.CloseGardenButton,{quiet:!0,short:!0,rid:te,r:le,now:ne,by:ae}):null]}),Ne.length?(0,se.jsxs)(O.default,{testID:"pending-requests",style:[W.styles.card,{borderColor:H.colours.amber,gap:8}],children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:H.colours.amber,children:["Needs confirming (",Ne.length,")"]}),(0,se.jsx)(W.Muted,{children:"Online requests outside your auto-accept rules. Check the details before confirming."}),Ne.map(e=>(0,se.jsxs)(O.default,{style:{gap:6,paddingTop:6,borderTopWidth:1,borderColor:H.colours.border},children:[(0,se.jsxs)(W.T,{weight:"semibold",children:[e.name," \xb7 ",e.partySize," ",1===e.partySize?'Cover':'Covers']}),(0,se.jsxs)(W.Muted,{children:[(0,R.niceDate)((0,R.parseYmd)(e.date))," at ",e.time," \xb7 ",e.ref," \xb7 ",e.phone??'no phone']}),e.notes?(0,se.jsxs)(W.T,{size:16,children:["Notes: ",e.notes]}):null,e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,se.jsx)(C.NeedsPills,{b:e,r:le}),'staff'!==oe&&((0,L.needsHoldOk)(e)||e.date===ie&&e.holdOk&&(e.holds??[]).some(e=>!e.served)&&'seated'===e.status)?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,L.needsHoldOk)(e)?(0,se.jsx)(W.Button,{small:!0,kind:"success",label:"Platter OK",testID:`mgr-platter-ok-${e.ref}`,onPress:()=>(0,C.confirmHolds)(e.id,ae)}):null,e.holdOk&&'seated'===e.status?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Platter served",onPress:()=>(0,C.serveHolds)(e,ae,'owner')}):null]}):null,Pe===e.id?(0,se.jsxs)(O.default,{style:{gap:6},children:[(0,se.jsxs)(W.T,{size:14,children:["Are you sure? ",e.name.split(' ')[0]," will get a polite \u201csorry, we can\u2019t fit you in\u201d message."]}),(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,kind:"danger",label:"Yes, decline",onPress:()=>{E.repo.bookings.decide(e.id,'declined',ae),Oe(null)}}),(0,se.jsx)(W.Button,{small:!0,kind:"ghost",label:"Keep it",onPress:()=>Oe(null)})]})]}):pe.ok?(0,se.jsxs)(W.Row,{gap:6,children:[(0,se.jsx)(W.Button,{small:!0,label:"Confirm",testID:`confirm-${e.ref}`,onPress:()=>E.repo.bookings.decide(e.id,'confirmed',ae)}),(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Decline",onPress:()=>Oe(e.id)}),(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"change"})]}):(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),(0,se.jsx)(q.ConfirmTimeline,{refId:e.id})]},e.id))]}):null,0===Ie.length?(0,se.jsx)(W.Muted,{children:"No bookings for this day yet."}):null,Ie.map(e=>{const s='confirmed'===e.status&&he===ie&&(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)>15,t=(0,I.depositState)(e),n=(0,I.depositBadge)(e,A.gbp);return(0,se.jsxs)(O.default,{testID:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?`booking-seated-${e.id}`:`booking-row-${e.id}`,style:[W.styles.card,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,v.seatedHighlightStyle)({borderColor:(0,L.hasAllergens)(e)?H.colours.red:H.colours.goldLight}):{borderColor:(0,L.hasAllergens)(e)?H.colours.red:s?H.colours.amber:H.colours.hairline,opacity:['finished','cancelled'].includes(e.status)?.55:1}],children:[(0,se.jsx)(C.AllergenBar,{b:e}),(0,se.jsx)(l.BookingNotSavedLine,{b:e}),(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsxs)(W.Row,{gap:6,style:{flex:1,minWidth:0,alignItems:'center'},children:[(0,se.jsxs)(W.T,{weight:"semibold",colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?v.SEATED_FG:H.colours.text,style:{flexShrink:1},children:[e.time," \xb7 ",(0,U.walkInLabel)(e)]}),(0,L.hasAllergens)(e)?(0,se.jsx)(M.AllergyIcon,{text:(0,L.allergenText)(e),size:20,colour:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?'#7A4A00':H.colours.amber,ink:(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?H.colours.gold:H.colours.bg,testID:`booking-allergy-${e.id}`}):null]}),(0,se.jsx)(W.Badge,{kind:'seated'===(0,L.shownStatus)(e)?'ok':'noshow'===e.status?'red':'confirmed'===e.status?'gold':'pending'===e.status?'amber':'neutral',label:'noshow'===e.status?'No-show':'pending'===e.status?'Needs confirming':(0,L.shownStatus)(e)[0].toUpperCase()+(0,L.shownStatus)(e).slice(1)})]}),n?(0,se.jsx)(f.DepositChip,{b:e,money:!0,big:!0,testID:`deposit-chip-${e.id}`}):null,(0,v.isSeatedHighlight)((0,L.shownStatus)(e))?(0,se.jsxs)(W.T,{size:14,colour:v.SEATED_MUTED,children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}):(0,se.jsxs)(W.Muted,{children:[e.table?(0,F.tableCardLabel)(e.table):e.walkIn?'Table to assign':'Table TBC'," \xb7 ",e.ref]}),e.notes?(0,se.jsxs)(W.T,{size:16,testID:`booking-notes-${e.id}`,children:["Notes: ",e.notes]}):null,(0,b.bookingExtras)(e)?(0,se.jsx)(W.T,{size:15,testID:`booking-extras-${e.id}`,children:(0,b.bookingExtras)(e)}):null,(0,b.historyLines)(e)[0]?(0,se.jsxs)(W.Muted,{size:13,testID:`booking-last-change-${e.id}`,children:["Last change: ",(0,b.historyLines)(e)[0]]}):null,n?(0,se.jsxs)(W.Row,{wrap:!0,gap:6,style:{alignItems:'center'},children:[fe||!(0,I.canTickDeposit)(e)||['cancelled','finished'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Mark deposit paid",testID:`deposit-paid-${e.id}`,accessibilityLabel:`Mark deposit paid for ${(0,U.walkInLabel)(e)}`,onPress:()=>E.repo.bookings.update(e.id,{depositPaid:e.depositDue??0,depositPaidBy:ae,depositPaidAt:(new Date).toISOString()})}),fe?null:(0,se.jsx)(D.WixDepositLink,{b:e,rid:te}),!fe&&pe.ok?(0,se.jsx)(B.WaiveDepositButton,{b:e,who:ae,small:!0}):null,'waived'===t&&e.depositWaived?(0,se.jsx)(W.Muted,{size:13,testID:`deposit-waived-${e.id}`,children:(0,I.waiverText)(e.depositWaived)}):null,'paid'===t&&e.depositPaidBy?(0,se.jsx)(W.Muted,{size:13,children:'Wix deposit link'===e.depositPaidBy?'Paid through a website bookings deposit link':`Ticked by ${e.depositPaidBy}`}):null]}):null,e.walkIn?null:(0,se.jsxs)(W.Muted,{children:[(0,Q.bookingSource)(e),e.phone?` \xb7 ${e.phone}`:'',e.email?` \xb7 ${e.email}`:'']}),e.allergies.length?(0,se.jsx)(W.Row,{wrap:!0,gap:4,children:e.allergies.map(e=>(0,se.jsx)(W.Badge,{kind:"red",label:`${(0,_.allergenLabel)(e.allergen)} \xb7 ${(0,_.severityLabel)(e.severity)}`},e.allergen))}):null,(0,L.hasAllergens)(e)&&!['cancelled','noshow'].includes(e.status)?(0,se.jsx)(Y.BookingAllergyChain,{b:e,me:ae}):null,e.walkIn?null:(0,se.jsx)(q.ConfirmTimeline,{refId:e.id,noPhone:!!e.source&&!e.phone}),s?(0,se.jsxs)(W.T,{size:13,colour:H.colours.amber,children:["Running ",(0,R.minsBetween)(new Date(`${e.date}T${e.time}:00`),ne)," min late. Call them, then mark no-show if needed."]}):null,pe.ok?(0,se.jsx)(c.BookingEditButton,{rid:te,booking:e,who:ae,role:oe,inStaffApp:re,shiftManager:ue,big:!0,testID:`edit-booking-${e.id}`}):null,(0,se.jsxs)(W.Row,{wrap:!0,gap:6,children:[(0,se.jsx)(u.BookingTableButton,{rid:te,booking:e,readOnly:fe||!pe.ok,turnBase:le.settings.turnMins}),pe.ok?null:(0,se.jsx)(O.default,{accessible:!0,accessibilityLabel:j.BOOKING_VIEW_ONLY,children:(0,se.jsx)(W.T,{children:j.BOOKING_VIEW_ONLY})}),pe.ok?(0,se.jsxs)(se.Fragment,{children:[fe||e.table||!['seated','confirmed'].includes(e.status)?null:(0,se.jsx)(W.Button,{small:!e.walkIn,kind:e.walkIn?'primary':'secondary',label:"Assign table",onPress:()=>be.assignTable(e)}),!fe&&['seated','confirmed'].includes(e.status)?(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables',testID:`combine-${e.id}`,accessibilityLabel:`${(0,F.tablesOf)(e.table).length>1?'Change tables':'Combine tables'} for ${(0,U.walkInLabel)(e)}`,onPress:()=>be.combineTables(e)}):null,fe||'confirmed'!==e.status?null:(0,se.jsxs)(se.Fragment,{children:[e.date===ie?(0,se.jsx)(W.Button,{small:!0,label:"Seat",accessibilityLabel:`Seat ${(0,U.walkInLabel)(e)} now`,onPress:()=>(0,U.seatBookingNow)(te,e)}):null,(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"No-show",onPress:()=>E.repo.bookings.setStatus(e.id,'noshow')})]}),fe||e.walkIn?null:(0,se.jsx)(r.CancelBookingButton,{rid:te,b:e,name:(0,U.walkInLabel)(e),small:!0,onDone:()=>{}}),fe||e.walkIn?null:(0,se.jsx)(r.ReinstateBookingButton,{b:e,name:(0,U.walkInLabel)(e),today:ie}),fe||'seated'!==e.status?null:(0,se.jsx)(W.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${(0,U.walkInLabel)(e)}, table needs clearing`,onPress:()=>(0,U.finishBookingNow)(te,e)}),['confirmed','pending'].includes(e.status)&&e.date>=ie?(0,se.jsx)(X.WhatsAppGuest,{b:e,rid:te,kind:"auto"}):null,re?null:(0,se.jsx)(S.CopyReviewLink,{rid:te,bookingId:e.id}),!fe&&e.walkIn?(0,se.jsx)(d.CancelWalkInButton,{rid:te,b:e,small:!0}):null,!fe&&e.walkIn?(0,se.jsx)(d.ReinstateWalkInButton,{rid:te,b:e,today:ie,small:!0}):null,(0,se.jsx)(K.BookingUndo,{b:e,rid:te,today:ie,who:(0,U.walkInLabel)(e)})]}):null]}),'noshow'===e.status&&'paid'===t?(0,se.jsx)(W.Muted,{size:13,children:"A deposit was paid. Keep or refund it by your deposit terms (Settings \u203a Advanced \u203a Deposits). Deposits paid through website bookings are refunded in Website bookings \u203a Orders."}):null]},e.id)}),(0,se.jsx)(x.CancellationsSection,{testID:"bookings-cancellations",items:(0,k.cancellationsFor)(de,he,e=>e.walkIn?`Walk-in ${e.ref}`:(e.name??'').replace(' (example)','')),dayWord:he===ie?'today':'that day'}),(0,se.jsxs)(W.Card,{children:[(0,se.jsxs)(W.Row,{style:{justifyContent:'space-between'},children:[(0,se.jsx)(W.T,{weight:"semibold",children:"No-shows"}),(0,se.jsx)(W.Badge,{kind:De.length?'red':'ok',label:`${De.length} ${he===ie?'today':(0,R.niceDate)((0,R.parseYmd)(he)).slice(0,6)}${Se||o.LIVE_VENUE_BUILD?'':' \xb7 4.1% last 28 days (example)'}`})]}),(0,se.jsx)(W.Muted,{children:De.length?`Marked no-show today: ${De.slice(0,6).map(e=>`${e.time} ${(0,U.walkInLabel)(e)}`).join(', ')}${De.length>6?` and ${De.length-6} more`:''}. If they turn up, open the booking and tap Undo no-show.`:'No no-shows today. If a party doesn\u2019t arrive, call them first, then tap No-show on their booking.'})]}),s.IS_GREENSIDE?(0,se.jsx)(t.GreensideCashOnly,{}):(0,se.jsxs)(W.Card,{children:[(0,se.jsx)(W.T,{weight:"semibold",children:"Deposits"}),(0,se.jsx)(W.Muted,{testID:"deposits-card-text",children:(()=>{const e=(0,I.depositOf)(le.settings);return e.on&&e.perPersonPence>0?`Deposits: ${(0,A.gbp)(e.perPersonPence)} per adult for parties of ${e.fromParty} or more (children never pay; staff can waive one on the booking). Deposits are paid through website bookings. Website bookings show Deposit paid on website bookings by themselves once the guest has paid. For phone and walk-in bookings, tick Deposit paid once the guest has paid you${e.wixLinksOn?', or press Send deposit link':''}.`:'Deposits are off. Turn them on in Settings \u203a Advanced \u203a Deposits.'})()}),(0,se.jsx)(W.Muted,{size:13,children:"Tip: refunds are done in Website bookings \u203a Orders. Booking deposit amounts are visible in Managers, Display and Staff."})]}),ze,be.elements]})};var e,s=_r(_d[0]),t=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),r=_r(_d[8]),u=_r(_d[9]),c=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),p=_r(_d[13]),k=_r(_d[14]),x=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),j=_r(_d[18]),f=_r(_d[19]),I=_r(_d[20]),B=_r(_d[21]),D=_r(_d[22]),S=_r(_d[23]),$=_r(_d[24]),T=_r(_d[25]),C=_r(_d[26]),L=_r(_d[27]),v=_r(_d[28]),N=_r(_d[29]),P=_r(_d[30]),O=(e=P)&&e.__esModule?e:{default:e},W=_r(_d[31]),M=_r(_d[32]),E=_r(_d[33]),_=_r(_d[34]),A=_r(_d[35]),R=_r(_d[36]),z=_r(_d[37]),H=_r(_d[38]),G=_r(_d[39]),U=_r(_d[40]),F=_r(_d[41]),K=_r(_d[42]),V=_r(_d[43]),Y=_r(_d[44]),q=_r(_d[45]),Q=_r(_d[46]),J=_r(_d[47]),X=_r(_d[48]),Z=_r(_d[49]),ee=_r(_d[50]),se=_r(_d[51])},1427,[5,1424,1123,11,1428,827,837,1140,1141,1119,1143,1429,1138,1142,1398,1399,1088,1343,1027,1117,14,1144,1431,1239,1432,1387,1107,1101,1118,34,102,794,1356,874,861,867,858,1326,821,1195,1126,1029,1433,1087,1181,1434,1230,987,1197,1395,878,25]); +__d(function(g,_r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.VenueRequestList=function({rid:e,kind:n,hotel:c}){const y=(0,r.useSync)(),p='staff'===y.kind&&y.venueSlug===(0,s.queuedDatabaseSlug)(e)&&!!y.venueId&&(!['greenside','kirkton','abbotsford'].includes(e)&&!(0,s.isQueuedVenue)(e)||y.perms.includes('*')||y.perms.includes('venue.settings')),f=p&&(y.perms.includes('*')||y.perms.includes('room'===n||(0,s.isQueuedVenue)(e)||['greenside','kirkton','abbotsford'].includes(e)?'venue.settings':'bookings.manage')),[h,b]=(0,t.useState)([]),[j,q]=(0,t.useState)(''),[x,k]=(0,t.useState)(null),v=(0,t.useCallback)(async()=>{if(p)try{b(await(0,o.listVenueRequests)(y.venueId,n)),q('')}catch(e){q((0,o.requestMessage)(e))}},[p,n,y.venueId]);(0,t.useEffect)(()=>{const e=setTimeout(()=>{v()},0),s=setInterval(()=>{v()},15e3);return()=>{clearTimeout(e),clearInterval(s)}},[v]);const T=h.filter(e=>e.venue_id===y.venueId);if(!p)return null;const I=async(e,s)=>{if(!x){k(e);try{await(0,o.decideVenueRequest)(e,s),await v()}catch(e){q((0,o.requestMessage)(e))}finally{k(null)}}};return(0,u.jsxs)(d.default,{testID:`venue-${n}-requests`,style:{gap:12,alignItems:'stretch'},children:[(0,u.jsx)(l.H2,{children:'room'===n?'Room requests':'Table requests'}),(0,u.jsx)(l.T,{center:!0,children:"Requested bookings need a staff decision. No email or text is sent. Contact the guest to confirm arrangements."}),(0,u.jsx)(l.Button,{kind:"secondary",label:`Refresh ${n} requests`,onPress:()=>{v()}}),j?(0,u.jsx)(l.Banner,{kind:"warn",title:"Requests",children:j}):null,T.length||j?null:(0,u.jsxs)(l.T,{center:!0,children:["No ",n," requests yet."]}),T.map(e=>(0,u.jsx)(l.Card,{style:{alignItems:'stretch'},children:(0,u.jsxs)(d.default,{testID:`venue-request-${e.id}`,style:{gap:10},children:[(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.T,{weight:"semibold",children:e.payload.name}),(0,u.jsx)(l.Badge,{kind:'requested'===e.status?'amber':'confirmed'===e.status?'ok':'neutral',label:'requested'===e.status?'Requested':'confirmed'===e.status?'Confirmed':'Declined'})]}),(0,u.jsx)(l.T,{children:'table'===n?`${e.payload.date} \xb7 ${e.payload.service?e.payload.service+' \xb7 ':''}${e.payload.time} \xb7 ${e.payload.covers} Covers`:`${e.payload.checkIn} to ${e.payload.checkOut} \xb7 ${c?.roomTypes.find(s=>s.id===e.payload.roomType)?.name||e.payload.roomType} \xb7 ${e.payload.guests} guests`}),'room'===n?(0,u.jsxs)(l.T,{children:["Add dinner: ",e.payload.addDinner?'Yes \u2014 arrange with guest':'No']}):null,(0,u.jsxs)(l.T,{children:[e.payload.phone," \xb7 ",e.payload.email]}),e.payload.notes?(0,u.jsxs)(l.T,{children:["Notes: ",e.payload.notes]}):null,'requested'===e.status&&f?(0,u.jsxs)(l.Row,{wrap:!0,children:[(0,u.jsx)(l.Button,{label:x===e.id?'Saving\u2026':'Confirm',testID:`request-confirm-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'confirmed')}}),(0,u.jsx)(l.Button,{label:"Decline",kind:"secondary",testID:`request-decline-${e.id}`,disabled:!!x,onPress:()=>{I(e.id,'declined')}})]}):null,e.booking_id?(0,u.jsx)(l.T,{children:"Confirmed table booking is in the bookings list."}):null]})},e.id))]})};var e,s=_r(_d[0]),t=_r(_d[1]),n=_r(_d[2]),d=(e=n)&&e.__esModule?e:{default:e},l=_r(_d[3]),r=_r(_d[4]),o=_r(_d[5]),u=_r(_d[6])},1428,[6,34,102,794,987,1272,25]); +__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.BookingsMatchStatus=function(){const e=(0,l.useSync)(e=>'staff'===e.kind?e.venueId:void 0),[f,b]=(0,t.useState)(null),[x,y]=(0,t.useState)(!1);(0,t.useEffect)(()=>{if(!e)return;let t,n=!0;try{t=(0,o.getSupabase)()}catch{return}const s=()=>t.rpc('bookings_match_status',{p_venue:e}).then(({data:e,error:t})=>{n&&!t&&e&&b(e)},()=>{});s();const i=setInterval(s,6e4);return()=>{n=!1,clearInterval(i)}},[e]);const _=(0,i.matchLine)(f);if(!_)return null;const k=f?.items??[],v=(f?.need_look??0)>0||!1===f?.ok;return(0,h.jsxs)(s.default,{testID:"bookings-match",style:{alignItems:'center',gap:4},children:[(0,h.jsx)(n.default,{accessibilityRole:k.length?'button':'text',accessibilityLabel:k.length?`${_}. ${x?'Hide':'Show'} the list`:_,disabled:!k.length,onPress:()=>y(!x),style:{minHeight:44,justifyContent:'center',paddingHorizontal:12},children:(0,h.jsxs)(u.T,{size:16,center:!0,weight:"semibold",colour:v?c.colours.amber:c.colours.goldLight,children:[_,k.length?x?' \u25b2':' \u25bc':'']})}),x?(0,h.jsxs)(s.default,{testID:"bookings-match-list",style:{gap:4,maxWidth:720},children:[k.map((e,t)=>(0,h.jsx)(u.T,{size:15,center:!0,colour:c.colours.text,children:(0,i.itemLine)(e)},t)),(0,h.jsx)(u.Muted,{center:!0,children:f?.auto_fix?'Checked every night at midnight.':'Checked every night at midnight. Fixing is switched off.'})]}):null]})};var t=r(d[0]),n=e(r(d[1])),s=e(r(d[2])),i=r(d[3]),l=r(d[4]),o=r(d[5]),c=r(d[6]),u=r(d[7]),h=r(d[8])},1429,[34,402,102,1430,987,933,821,794,25]); +__d(function(g,r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"plainSite",{enumerable:!0,get:function(){return o}}),e.matchLine=function(t){if(!t||!t.ran)return null;if(!1===t.ok)return`${i}: couldn\u2019t check at ${n(t.last_run_at)}, trying again`;const o=t.need_look??0,s=t.fixed_today??0,l=[o?i:`${i} \u2713`];s&&l.push(`${s} fixed today`);o&&l.push(`${o} need${1===o?'s':''} a look`);return l.join(' \xb7 ')},e.itemLine=function(n){const i=(n.fields??[]).map(n=>t[n]??n).join(', '),s=[n.ref,n.name].filter(Boolean).join(' '),l=[n.date?n.date.split('-').reverse().join('/'):'',n.time].filter(Boolean).join(' '),c='wix'===n.winner?'Website is newer':'covercharge'===n.winner?'CoverCharge is newer':'';return[s,l,i&&`differs: ${i}`,c,o(n.note)].filter(Boolean).join(' \xb7 ')};const t={name:'name',phone:'phone',email:'email',date:'date',time:'time',covers:'covers',notes:'notes',table:'table',status:'status',dog:'dog',allergies:'allergies',create:'not on the website',import:'not in CoverCharge'},n=t=>t?new Date(t).toLocaleTimeString('en-GB',{timeZone:'Europe/London',hour:'2-digit',minute:'2-digit'}):'',i='Bookings match the website',o=t=>t?t.replace(/\bon Wix\b/g,'on the website').replace(/\bWix\b/g,'the website'):t},1430,[]); +__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,"untilWords",{enumerable:!0,get:function(){return w}}),_e.WixDepositLink=function({b:e,rid:x}){const f=(0,r.useRestaurant)(x),[S,j]=(0,s.useState)(!1),[C,D]=(0,s.useState)(!1),[L,I]=(0,s.useState)(null),[$,v]=(0,s.useState)(''),[P,T]=(0,s.useState)(''),[A,_]=(0,s.useState)(''),M=(0,c.depositOf)(f?.settings),O=e;if(n.IS_ISOLATED_VENUE||['souters','kirkmichael','wildings'].includes(x)||!f||!(0,c.canSendDepositLink)(O,M))return null;const B='open'===O.depositLink?.state,R=async()=>{j(!0),D(!0),T(''),I(null);try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-link',{body:{booking_id:e.id}});if(n||!t)return void T(y);if(!t.ok||!t.url)return void T(t.off?y:String(t.error??y));const s={url:t.url,amountPence:t.amountPence,expiresAt:t.expiresAt};I(s),v((0,c.depositLinkMessage)({name:e.name,venue:f.name,partySize:e.partySize,date:e.date,time:e.time,amountPence:s.amountPence,url:s.url,expiresAt:s.expiresAt,terms:(0,c.depositTerms)(M)}))}catch{T(y)}finally{D(!1)}},W=async()=>{_('Checking\u2026');try{const{data:t,error:n}=await(0,h.getSupabase)().functions.invoke('wix-deposit-check',{body:{booking_id:e.id}});_(n||!t||t.off?'Website bookings deposit links are switched off, so nothing was checked.':'Checked with website bookings. If the guest has paid, the badge shows Deposit paid on website bookings.')}catch{_('Could not reach website bookings. Try again in a minute.')}},z=L?(0,k.waMeLink)(e.phone,$):null,E=L&&e.phone?(0,p.smsLink)(e.phone,$):null,U=L&&e.email?`mailto:${encodeURIComponent(e.email)}?subject=${encodeURIComponent(`${f.name} deposit`)}&body=${encodeURIComponent($)}`:null,F='undefined'!=typeof navigator&&!!navigator.clipboard,G=e=>{e&&o.default.openURL(e).catch(()=>{})};return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:B?'Send deposit link again':'Send deposit link',testID:`deposit-link-${e.id}`,accessibilityLabel:`${B?'Send the deposit link again to':'Send a website bookings deposit link to'} ${e.name}`,onPress:()=>{R()}}),B?(0,g.jsx)(d.Button,{small:!0,kind:"secondary",label:"Check if paid",testID:`deposit-check-${e.id}`,accessibilityLabel:`Check with website bookings if ${e.name} has paid the deposit`,onPress:()=>{W()}}):null,A?(0,g.jsx)(d.Muted,{size:13,children:A}):null,(0,g.jsx)(d.Sheet,{visible:S,onClose:()=>j(!1),title:"Send deposit link",testID:`deposit-link-sheet-${e.id}`,children:(0,g.jsxs)(l.default,{style:{gap:10},children:[C?(0,g.jsx)(d.T,{children:"Asking website bookings for the link\u2026"}):null,P?(0,g.jsx)(d.T,{colour:b.colours.amber,testID:"deposit-link-error",children:P}):null,L?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(d.T,{weight:"semibold",children:`Deposit ${(0,u.gbp)(L.amountPence)} for ${e.partySize} guests.${L.expiresAt?` Link works until ${w(L.expiresAt)}.`:''}`}),(0,g.jsx)(d.T,{children:"Message to the guest (you can change it)"}),(0,g.jsx)(t.TextInput,{accessibilityLabel:"Message to the guest",testID:"deposit-link-message",value:$,multiline:!0,onChangeText:v,style:{minHeight:140,borderRadius:10,borderWidth:1,borderColor:b.colours.hairline,backgroundColor:b.colours.surface2,color:b.colours.text,padding:10,fontSize:15}}),(0,g.jsxs)(d.Row,{wrap:!0,gap:8,children:[E?(0,g.jsx)(d.Button,{label:"Text",testID:"deposit-link-sms",accessibilityLabel:`Open a text message to ${e.name} with the deposit link`,onPress:()=>G(E)}):null,z?(0,g.jsx)(d.Button,{kind:"secondary",label:"WhatsApp",testID:"deposit-link-wa",accessibilityLabel:`Open WhatsApp to ${e.name} with the deposit link`,onPress:()=>G(z)}):null,U?(0,g.jsx)(d.Button,{kind:"secondary",label:"Email",testID:"deposit-link-email",accessibilityLabel:`Open an email to ${e.name} with the deposit link`,onPress:()=>G(U)}):null,F?(0,g.jsx)(d.Button,{kind:"secondary",label:"Copy link",testID:"deposit-link-copy",accessibilityLabel:"Copy the deposit link",onPress:()=>{navigator.clipboard.writeText(L.url).catch(()=>{})}}):null]}),E||z||U?null:(0,g.jsx)(d.Muted,{children:"This booking has no phone number or email. Copy the link and send it another way."}),(0,g.jsx)(d.Muted,{size:13,children:"Tip: CoverCharge doesn't send anything. Each button opens your own messages app with the words filled in, and you press Send. Once the guest pays on website bookings, this booking shows Deposit paid on website bookings by itself. Refunds are done in Website bookings \u203a Orders."})]}):null,(0,g.jsx)(d.Button,{kind:"secondary",label:"Close",testID:"deposit-link-close",onPress:()=>j(!1)})]})})]})};var t=_r(_d[0]),n=_r(_d[1]),s=_r(_d[2]),o=e(_r(_d[3]));_r(_d[4]);var l=e(_r(_d[5])),d=_r(_d[6]),r=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),h=_r(_d[11]),b=_r(_d[12]),k=_r(_d[13]),g=_r(_d[14]);const y="Website bookings deposit links aren't switched on yet. Take the deposit by card or cash and tick Deposit paid.",w=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',weekday:'short',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',hourCycle:'h23'}):''},1431,[827,5,34,379,236,102,794,876,14,867,1032,933,821,1198,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QuietButton=function({icon:e,label:s,onPress:n,testID:b,a11y:y,disabled:f,accessibilityHint:h}){return(0,u.jsxs)(t.default,{accessibilityRole:"button",accessibilityLabel:y??s,accessibilityHint:h,accessibilityState:{disabled:!!f},disabled:f,testID:b,onPress:n,style:({pressed:e})=>({...l.look.quiet(e),flexGrow:1,opacity:f?.4:1}),children:[e?(0,u.jsx)(o.T,{size:15,colour:c.colours.goldLight,children:e}):null,(0,u.jsx)(o.T,{size:15,weight:"semibold",colour:c.colours.goldLight,children:s})]})},r(d[0]);var e,s=r(d[1]),t=(e=s)&&e.__esModule?e:{default:e},l=r(d[2]),o=r(d[3]),c=r(d[4]),u=r(d[5])},1432,[34,402,1189,794,821,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.undoKind=f,_e.BookingUndo=function({b:e,rid:t,today:h,who:k}){const[$,w]=(0,s.useState)(!1),y=f(e,h);if(!y)return null;const p=(0,l.tableCardLabel)(e.table),j=l.useFloor.getState().setLive;if('unseat'===y)return $?(0,b.jsxs)(o.default,{testID:`unseat-confirm-${e.id}`,accessibilityLiveRegion:"polite",style:{gap:6,width:'100%',borderWidth:1.5,borderColor:c.colours.gold,borderRadius:12,padding:10},children:[(0,b.jsxs)(u.T,{size:16,weight:"semibold",colour:c.colours.text,children:["Unseat ",k,"? ",e.walkIn?'The walk-in is removed':'They go back to Booked',p?` and ${p} ${(0,l.tablesOf)(e.table).length>1?'are':'is'} free again`:'',"."]}),(0,b.jsxs)(u.Row,{gap:8,wrap:!0,children:[(0,b.jsx)(u.Button,{small:!0,label:"Yes, unseat",testID:`unseat-yes-${e.id}`,accessibilityLabel:`Yes, unseat ${k}`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,e.walkIn?'cancelled':'confirmed'),(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:void 0,dirty:!1})),w(!1)}}),(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Keep seated",accessibilityLabel:`Keep ${k} seated`,onPress:()=>w(!1)})]})]}):(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Unseat",testID:`unseat-${e.id}`,accessibilityLabel:`Unseat ${k}: ${e.walkIn?'removes the walk-in':'back to booked'}${p?`, frees ${p}`:''}`,onPress:()=>w(!0)});const x='undo-finished'===y?'seated':'confirmed';return(0,b.jsx)(u.Button,{small:!0,kind:"ghost",label:"Undo",testID:`undo-status-${e.id}`,accessibilityLabel:'undo-finished'===y?`Undo finished: ${k} back to seated${p?` at ${p}`:''}`:`Undo no-show: ${k} back to booked`,onPress:async()=>{await n.repo.bookings.setStatus(e.id,x),'seated'===x&&(0,l.tablesOf)(e.table).forEach(e=>j(t,e,{stage:'seated',dirty:!1}))}})};var e,s=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},n=r(d[2]),l=r(d[3]),u=r(d[4]),c=r(d[5]),b=r(d[6]);function f(e,s){if('seated'===e.status)return'unseat';const t=e.date===s||!!e.finishedAt&&e.finishedAt.slice(0,10)===s;return'finished'===e.status&&t?'undo-finished':'noshow'===e.status&&t?'undo-noshow':null}},1433,[34,102,874,1029,794,821,25]); +__d(function(g,r,i,_a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ConfirmTimeline=function({refId:e,noPhone:o}){const m=(0,s.useStore)((0,n.useShallow)(o=>o.outbox.filter(o=>o.refId===e))).slice().sort((e,o)=>e.at.localeCompare(o.at));return m.length?(0,a.jsx)(t.default,{testID:"confirm-timeline",style:{borderLeftWidth:2,borderColor:u.colours.gold,paddingLeft:10,gap:3},children:m.map(e=>(0,a.jsxs)(t.default,{style:{flexDirection:'row',gap:6,alignItems:'center'},children:[(0,a.jsx)(t.default,{style:{width:7,height:7,borderRadius:4,marginLeft:-14.5,backgroundColor:'sent'===e.status?u.colours.ok:'failed'===e.status?u.colours.red:u.colours.amber}}),(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:e.at.slice(11,16)}),(0,a.jsxs)(c.T,{size:12,children:[f[e.kind],": ",(0,l.statusLabel)(e)]})]},e.id))}):o?(0,a.jsx)(c.T,{size:12,colour:u.colours.muted,children:"Confirmation: no phone number, so no text"}):null},r(d[0]);var e,o=r(d[1]),t=(e=o)&&e.__esModule?e:{default:e},n=r(d[2]),s=r(d[3]),l=r(d[4]),u=r(d[5]),c=r(d[6]),a=r(d[7]);const f={'booking-request':'Request received','booking-confirmation':'Confirmation','booking-declined':'Declined','order-confirmation':'Order confirmation',test:'Test'}},1434,[34,102,879,874,864,821,794,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.BlocksPage=function(){const{rid:o,r:t,now:s,me:u}=(0,n.useCtx)(3e4);return(0,c.jsx)(r.BlocksScreen,{rid:o,r:t,now:s,by:u.replace(' (example)','')})},_r(d[0]);var r=_r(d[1]),n=_r(d[2]),c=_r(d[3])},1435,[34,1388,1088,25]); +__d(function(g,r,i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AllergenSignOffLog=function(){const{rid:e,me:n}=(0,b.useCtx)(1e4),y=(0,c.useOrders)(e).filter(e=>e.allergies.length&&'cancelled'!==e.status),k=(0,c.useBookings)(e),v=(0,c.useAudit)(e).filter(e=>'allergy'===e.kind),[w,C]=(0,l.useState)('all'),A=y.map(e=>({o:e,bk:(0,u.linkedBooking)(e,k)})).map(e=>({...e,next:(0,u.nextStep)(e.o,e.bk)})).filter(e=>'all'===w||('open'===w?!!e.next:!e.next));return(0,j.jsxs)(s.default,{style:{gap:10},testID:"allergen-signoff-log",children:[(0,j.jsx)(o.Banner,{kind:"info",title:"Five sign-offs for every guest allergy",children:"1. Booked (allergy recorded) \xb7 2. Ordered (server confirms with the guest) \xb7 3. Kitchen (chef, before cooking) \xb7 4. Pass (before it leaves) \xb7 5. Table (when served). A ticket can\u2019t move on until the previous step is signed off."}),(0,j.jsx)(o.Row,{gap:6,children:['all','open','complete'].map(e=>(0,j.jsx)(o.Chip,{label:'all'===e?'All':'open'===e?'Waiting':'Complete',selected:w===e,onPress:()=>C(e)},e))}),A.length?A.map(({o:e,bk:l,next:s})=>{const c=(0,u.orderChain)(e,l);return(0,j.jsxs)(o.Card,{children:[(0,j.jsxs)(o.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(o.T,{weight:"semibold",children:[e.ref," \xb7 ",'table'===e.type?`${(0,t.tableNumbers)(e.tableNo)}`:'Takeaway',l?` \xb7 booking ${l.ref}`:'']}),(0,j.jsx)(o.Badge,{kind:s?'red':'ok',label:s?'Waiting':'Complete'})]}),(0,j.jsxs)(o.Muted,{children:[e.allergies.map(e=>`${(0,h.allergenLabel)(e.allergen)} (${(0,h.severityLabel)(e.severity)})`).join(', ')," \xb7 ",(0,f.niceDate)(new Date(e.createdAt))]}),(0,j.jsx)(a.AllergyChain,{o:e,me:n,readOnly:!0,compact:!0}),u.CHAIN_STEPS.map(e=>(0,j.jsxs)(o.Muted,{children:[e.n,". ",e.label,": ",c[e.id]?`${c[e.id].by.replace(' (example)','')} at ${(0,f.hm)(new Date(c[e.id].at))}`:'not signed yet']},e.id))]},e.id)}):(0,j.jsxs)(o.Muted,{children:["No allergy orders",'all'===w?'':' in this view',"."]}),(0,j.jsx)(x.SectionHead,{title:"Allergen audit log",sub:"Every sign-off with the person's name and the time"}),(0,j.jsx)(s.default,{testID:"allergen-audit-log",style:{gap:4},children:v.length?v.slice(0,40).map(e=>(0,j.jsxs)(o.Muted,{children:[(0,f.niceDate)(new Date(e.at))," ",(0,f.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,j.jsx)(o.Muted,{children:"No allergen events yet."})}),(0,j.jsx)(o.Muted,{children:"This device keeps the sign-off log shown here."}),void p.colours]})};var e,t=r(d[0]),l=r(d[1]),n=r(d[2]),s=(e=n)&&e.__esModule?e:{default:e},a=r(d[3]),o=r(d[4]),c=r(d[5]),h=r(d[6]),u=r(d[7]),f=r(d[8]),p=r(d[9]),x=r(d[10]),b=r(d[11]),j=r(d[12])},1436,[860,34,102,1181,794,874,861,869,858,821,1195,1088,25]); +__d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DisplaysPage=function(){const e=(0,p.useSync)(e=>e.venueId)??(w.PITCH?'pitch':void 0),s=(0,p.useSync)(e=>w.PITCH?'live':e.mode),a=(0,p.useSync)(e=>e.perms.includes('*')||e.perms.includes('devices.manage'))||w.PITCH,[l,r]=(0,n.useState)([]),[d,c]=(0,n.useState)('Reception screen'),[u,h]=(0,n.useState)(5),[y,j]=(0,n.useState)(!0),[S,_]=(0,n.useState)(null),[C,T]=(0,n.useState)(''),[P,I]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{if(e)try{r((await(0,p.rpc)('list_displays',{p_venue:e})??[]).sort((e,s)=>s.created_at.localeCompare(e.created_at))),T('')}catch(e){T(String(e?.message??e))}},[e]);if((0,n.useEffect)(()=>{R()},[R]),!e||'signin'===s||'local'===s)return(0,f.jsx)(i.Banner,{kind:"info",title:"Connect first",children:"Displays are paired through your venue\u2019s shared system. Open your personal invite link on this device once, then come back here."});if(!a)return(0,f.jsx)(i.Banner,{kind:"info",title:"Managers only",children:"Ask a manager to pair or switch off a display."});const D=async e=>{try{const s=(await(0,p.rpc)('new_code_for_display',{p_token_id:e.id,p_hours:0===u?null:24*u}))?.[0];s&&(I(!1),_({code:s.code,label:e.label,expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}},[B,M]=(0,n.useState)(null),[$,A]=(0,n.useState)(null),[N,F]=(0,n.useState)(!1),E=async e=>{try{await(0,p.rpc)('revoke_unused_display_codes',{p_token_id:e.id}),_(null),A(null),R()}catch(e){T(String(e?.message??e))}},U=async e=>{try{await(0,p.rpc)('revoke_display',{p_token_id:e.id}),R()}catch(e){T(String(e?.message??e))}};return(0,f.jsxs)(o.default,{style:{gap:10},testID:"displays-page",children:[(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Pair a display"}),(0,f.jsx)(i.Muted,{children:"Make a one-time code, then type it on the tablet (Display app \u2192 Pair this display) or open the pairing link on it. Each code works once."}),(0,f.jsx)(i.Field,{label:"Name",value:d,onChangeText:c,placeholder:"Reception screen"}),(0,f.jsx)(i.T,{size:14,children:"Code lasts"}),(0,f.jsx)(i.Row,{wrap:!0,gap:6,children:[5,30,0].map(e=>(0,f.jsx)(i.Chip,{label:0===e?'Forever':1===e?'1 day':`${e} days`,selected:u===e,onPress:()=>h(e)},e))}),(0,f.jsx)(i.Toggle,{label:"Can sell, count and seat (not just view)",value:y,onChange:j}),(0,f.jsx)(i.Button,{testID:"display-create",label:"Make a pairing code",onPress:async()=>{try{const s=(await(0,p.rpc)('create_display_code',{p_venue:e,p_label:d.trim()||'Reception screen',p_hours:0===u?null:24*u,p_can_write:y}))?.[0];s&&(I(!1),_({code:s.code,label:d.trim()||'Reception screen',expires:s.expires_at})),R()}catch(e){T(String(e?.message??e))}}}),S?(0,f.jsxs)(o.default,{testID:"display-code",style:{gap:4,padding:12,borderRadius:12,borderWidth:1,borderColor:x.colours.gold},children:[(0,f.jsxs)(i.T,{size:13,colour:x.colours.muted,children:[S.label," \xb7 ",'infinity'!==S.expires&&S.expires?`until ${k(S.expires)}`:'Forever (until used or revoked)']}),(0,f.jsx)(i.T,{size:28,weight:"bold",style:{letterSpacing:3},children:S.code.replace(/(.{5})/,'$1 ')}),(0,f.jsx)(i.Button,{kind:"secondary",label:P?"Pairing link copied":"Copy pairing link",onPress:async()=>{const e=await(0,t.copyText)(b(S.code));I(e),e||T('Copy is not available on this device. Use the pairing code shown above.')}}),(0,f.jsx)(i.Muted,{children:"Shown once. If it\u2019s lost, make a new code for this display below."})]}):null]}),C?(0,f.jsx)(i.Banner,{kind:"warn",title:"Couldn\u2019t update displays",children:C}):null,(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Your displays"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",onPress:R})]}),0===l.length?(0,f.jsx)(i.Muted,{children:"No displays yet."}):l.filter(e=>N||!e.revoked_at).map(e=>(0,f.jsxs)(o.default,{testID:`display-${e.label}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:4},children:[(0,f.jsxs)(o.default,{style:{gap:4},children:[(0,f.jsx)(i.T,{center:!0,weight:"semibold",children:e.label.replace(/\s*\(pilot\)\s*$/i,'')}),(0,f.jsx)(i.T,{center:!0,size:13,colour:e.revoked_at?x.colours.red:e.sessions?x.colours.ok:x.colours.muted,children:e.revoked_at?`Switched off ${k(e.revoked_at)}`:e.sessions?'Paired':e.open_codes?'Waiting for pairing':'Not paired'})]}),(0,f.jsxs)(i.Muted,{center:!0,children:[e.can_write?'Can sell, count and seat':'View only',e.last_seen_at?` \xb7 last seen ${k(e.last_seen_at)}`:'',e.open_codes?` \xb7 ${e.open_codes} unused code${1===e.open_codes?'':'s'}`:'']}),e.open_codes&&!e.revoked_at?$===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{center:!0,children:["Revoke unused codes for \u201c",e.label,"\u201d? Already paired screens stay connected."]}),(0,f.jsxs)(i.Row,{wrap:!0,children:[(0,f.jsx)(i.Button,{kind:"danger",label:"Revoke unused codes",onPress:()=>{E(e)}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Keep codes",onPress:()=>A(null)})]})]}):(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Revoke unused codes\u2026",onPress:()=>A(e.id)}):null,e.revoked_at?null:B===e.id?(0,f.jsxs)(o.default,{style:{gap:6},children:[(0,f.jsxs)(i.T,{size:13,children:["Switch off \u201c",e.label,"\u201d? It stops showing the venue\u2019s live data straight away and needs a new code to pair again."]}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Yes, switch off",testID:"display-off-yes",onPress:()=>{M(null),U(e)}}),(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:"Keep it on",onPress:()=>M(null)})]})]}):(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"New code",onPress:()=>D(e)}),(0,f.jsx)(i.Button,{small:!0,kind:"danger",label:"Switch off\u2026",onPress:()=>M(e.id)})]})]},e.id)),l.some(e=>!!e.revoked_at)?(0,f.jsx)(i.Button,{small:!0,kind:"ghost",label:N?"Hide switched-off displays":"Show switched-off displays",onPress:()=>F(!N)}):null,(0,f.jsx)(i.Muted,{center:!0,children:"Paired means signed in, not a live connection check. Switching a display off disconnects it straight away. It then shows its own data only, until it\u2019s paired again."})]}),(0,f.jsx)(v,{})]})},_e.DeviceSyncCard=v,_e.TrackedStockPage=function(){const t=(0,d.useOwner)(e=>e.site),a=(0,c.useShellStore)(e=>e.items[t])??[],l=(0,u.useOrderSheets)(e=>e.sheets[t])??[],[r,y]=(0,n.useState)(null),w=!(0,p.useSync)(e=>'live'===e.mode||'offline'===e.mode)||(0,p.can)('stock.manage');return(0,f.jsxs)(o.default,{style:{gap:10},testID:"tracked-stock",children:[(0,f.jsx)(i.Banner,{kind:"info",title:"Tracked stock",children:"Things you count live through service, like lobster and crab. Each item gets a counter in the Display, Staff and Head Chef apps, with sell, delivery, recount and undo, and a low-stock warning."}),a.map(e=>(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(i.T,{weight:"semibold",children:[e.icon," ",e.name,e.active?'':' (not tracked)']}),w?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Edit",testID:`stock-edit-${e.key}`,onPress:()=>y({...e})}):null]}),(0,f.jsxs)(i.Muted,{children:['roast'===e.group?'Sunday roast (Display, Sundays only) \xb7 ':'','kg'===e.unit?'Fish weight in stone':'half'===e.unit?'Sold in halves':'Whole units'," \xb7 low at ",'kg'===e.unit?(0,s.fishQtyText)(t,e,e.lowAt):e.lowAt," \xb7 ",l.find(s=>s.id===e.supplierId)?.name??'no supplier set']})]},e.key)),w&&!r?(0,f.jsx)(i.Button,{testID:"stock-add",label:"Add an item to track",onPress:()=>y(S())}):null,r?(0,f.jsxs)(i.Card,{highlight:x.colours.gold,children:[(0,f.jsx)(i.T,{weight:"semibold",children:r.key?`Edit ${r.name}`:'New tracked item'}),(0,f.jsx)(i.Field,{label:"Name",value:r.name,onChangeText:e=>y({...r,name:e}),placeholder:"e.g. Oysters",testID:"stock-name"}),(0,f.jsx)(i.Field,{label:"Plural (optional)",value:r.plural,onChangeText:e=>y({...r,plural:e}),placeholder:"e.g. Oysters"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"Whole units",selected:'whole'===r.unit,onPress:()=>y({...r,unit:'whole'})}),'roast'===r.group?null:(0,f.jsx)(i.Chip,{label:"Halves too",selected:'half'===r.unit,onPress:()=>y({...r,unit:'half'})}),'roast'!==r.group&&(0,e.isAnchorage)(t)&&(0,s.isFishName)(r.name)?(0,f.jsx)(i.Chip,{label:"Fish weight (stone)",selected:'kg'===r.unit,onPress:()=>y({...r,unit:'kg',lowAt:(0,s.fromStone)(.5)})}):null]}),(0,f.jsx)(i.Field,{label:'kg'===r.unit?"Warn at or below (stone)":"Warn when at or below",value:String('kg'===r.unit?(0,s.halfStone)((0,s.toStone)(r.lowAt)):r.lowAt),onChangeText:e=>{const t=Number(e.replace(/[^0-9.]/g,''))||0;y({...r,lowAt:'kg'===r.unit?(0,s.fromStone)((0,s.halfStone)(t)):t})},keyboardType:"decimal-pad"}),(0,f.jsx)(i.Field,{label:"Icon (an emoji)",value:r.icon,onChangeText:e=>y({...r,icon:e.slice(0,4)})}),(0,f.jsx)(i.T,{size:14,children:"Supplier"}),(0,f.jsxs)(i.Row,{wrap:!0,gap:6,children:[(0,f.jsx)(i.Chip,{label:"None",selected:!r.supplierId,onPress:()=>y({...r,supplierId:void 0})}),l.map(e=>(0,f.jsx)(i.Chip,{label:e.name,selected:r.supplierId===e.id,onPress:()=>y({...r,supplierId:e.id})},e.id))]}),(0,f.jsx)(i.Toggle,{label:"Show the counter",value:r.active,onChange:e=>y({...r,active:e})}),(0,f.jsx)(i.Toggle,{label:"Sunday roast (Display, Sundays only, whole numbers)",testID:"stock-roast",value:'roast'===r.group,onChange:e=>y(e?{...r,group:'roast',unit:'whole'}:(({group:e,...s})=>s)(r))}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{testID:"stock-save",label:"Save",disabled:!r.name.trim(),onPress:()=>{if(!r)return;const e=r.name.trim();if(!e)return;const s=r.key||(0,h.stockKey)(e);!r.key&&a.some(e=>e.key===s)||(c.useShellStore.getState().saveItem(t,{...r,key:s,name:e,plural:r.plural.trim()||`${e}s`,lowAt:Math.max(0,Number(r.lowAt)||0)}),y(null))}}),(0,f.jsx)(i.Button,{kind:"secondary",label:"Cancel",onPress:()=>y(null)})]}),(0,f.jsx)(i.Muted,{children:"To stop counting something, switch \u201cShow the counter\u201d off. Its history is kept."})]}):null]})},_e.BreakRoomSettings=function(){const e=(0,d.useOwner)(e=>e.site),s=(0,r.useStore)(s=>!1!==s.restaurants.find(s=>s.id===e)?.settings?.games),t=(0,r.useStore)(s=>s.restaurants.find(s=>s.id===e)?.settings?.gameUrl??''),[a,l]=(0,n.useState)(t),c=!a.trim()||!!(0,j.validGameUrl)(a);return(0,f.jsxs)(o.default,{style:{gap:10},children:[(0,f.jsx)(i.Card,{children:(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(o.default,{style:{flex:1},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Break room game"}),(0,f.jsx)(i.Muted,{children:"Lenny\u2019s Kitchen Chaos in the Staff app, with the team as characters and a shared leaderboard. Only playable on a break or when not clocked in."})]}),(0,f.jsx)(i.Toggle,{label:"Break room game",value:s,onChange:s=>r.useStore.getState().updateSettings(e,{games:s})})]})}),(0,f.jsxs)(i.Card,{children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Game address (advanced)"}),(0,f.jsxs)(i.Muted,{children:["The game loads from its own web address, so new levels and fixes arrive without updating CoverCharge. Leave blank to use the standard one (",j.LENNY_GAME_URL,")."]}),(0,f.jsx)(i.Field,{testID:"game-url",label:"Game address",value:a,onChangeText:l,autoCapitalize:"none",autoCorrect:!1,placeholder:j.LENNY_GAME_URL}),c?null:(0,f.jsx)(i.T,{size:13,colour:x.colours.red,children:"Use a full https:// address."}),(0,f.jsxs)(i.Row,{gap:6,children:[(0,f.jsx)(i.Button,{small:!0,label:"Save address",disabled:!c||a.trim()===t,onPress:()=>r.useStore.getState().updateSettings(e,{gameUrl:a.trim()?(0,j.validGameUrl)(a):void 0})}),t?(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Use the standard address",onPress:()=>{l(''),r.useStore.getState().updateSettings(e,{gameUrl:void 0})}}):null]})]})]})};var e=_r(_d[0]),s=_r(_d[1]),t=_r(_d[2]),n=_r(_d[3]);_r(_d[4]);var a,l=_r(_d[5]),o=(a=l)&&a.__esModule?a:{default:a},i=_r(_d[6]),r=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),h=_r(_d[11]),p=_r(_d[12]),y=_r(_d[13]),x=_r(_d[14]),w=_r(_d[15]),j=_r(_d[16]),f=_r(_d[17]);const k=e=>'infinity'===e?'Forever':e?new Date(e).toLocaleString('en-GB',{day:'numeric',month:'short',hour:'2-digit',minute:'2-digit'}):'',b=e=>'undefined'!=typeof window?`${window.location.origin}/display-app/index.html?pair=${e}`:`display-app/index.html?pair=${e}`;function v(){const[e,s]=(0,n.useState)([]),[t,a]=(0,n.useState)(''),[l,r]=(0,n.useState)(Date.now()),d=(0,n.useCallback)(async()=>{try{s(await(0,p.readSyncHeartbeats)()),a('')}catch(e){a(String(e?.message??e))}r(Date.now())},[]);return(0,n.useEffect)(()=>{d();const e=setInterval(()=>{d()},3e4);return()=>clearInterval(e)},[d]),(0,f.jsxs)(i.Card,{children:[(0,f.jsxs)(i.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsx)(i.T,{weight:"semibold",children:"Device sync"}),(0,f.jsx)(i.Button,{small:!0,kind:"secondary",label:"Refresh",testID:"device-sync-refresh",onPress:d})]}),(0,f.jsx)(i.Muted,{children:"Every Managers, Staff, Chef, Display and car app reports once a minute when it last heard from the shared system. Red means that device is out of sync or has not reported for over 3 minutes (switched off, asleep or no signal)."}),t?(0,f.jsx)(i.Muted,{children:`Couldn\u2019t read device sync: ${t}`}):null,t||0!==e.length?null:(0,f.jsx)(i.Muted,{children:"No device has reported yet. Devices report once they are on v0.3.12.131 or later."}),e.map(e=>{const s=(0,y.deviceSyncLine)(e,l);return(0,f.jsxs)(o.default,{testID:`device-sync-${e.app}`,style:{paddingVertical:8,borderTopWidth:1,borderTopColor:x.colours.border,gap:2},children:[(0,f.jsxs)(i.Row,{gap:8,style:{alignItems:'center'},children:[(0,f.jsx)(o.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:s.ok?x.colours.ok:x.colours.red}}),(0,f.jsx)(i.T,{weight:"semibold",children:s.title})]}),(0,f.jsx)(i.T,{size:13,colour:s.ok?x.colours.text:x.colours.red,children:s.state}),(0,f.jsx)(i.Muted,{children:s.detail})]},`${e.app}-${e.device_id}`)})]})}const S=()=>({key:'',name:'',plural:'',unit:'whole',lowAt:4,icon:'\ud83d\udce6',sort:50,active:!0})},1437,[835,984,1438,34,236,102,794,831,891,983,1031,985,987,1444,821,2,1182,25]); +__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.Insights=function({go:e}){const{rid:t,r:s,now:l}=(0,v.useCtx)(6e4),n=(0,j.useBookings)(t),i=(0,j.useOrders)(t),a=(0,j.useEvents)(t),r=(0,j.useRatings)(t),o=(0,d.useMemo)(()=>(0,O.insights)(s,n,i,a,r,l,64),[s.id,n.length,i.length,r.length]);return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Muted,{children:(0,B.useExamples)()?'Smart suggestions from your bookings, orders, forecast, stock and reviews. Example figures: invented for the demo.':'Suggestions from your own bookings, reviews and calendar. Nothing here is invented.'}),o.map((t,s)=>(0,E.jsx)(L.FadeIn,{delay:80*s,children:(0,E.jsxs)(x.Card,{highlight:z[t.tone],children:[(0,E.jsxs)(x.Row,{style:{alignItems:'flex-start'},children:[(0,E.jsx)(x.T,{size:22,children:t.icon}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:t.body})]})]}),t.action?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:t.action.label,onPress:()=>e(t.action.tab,t.action.sub??null)}):null]})},t.id))]})},_e.Analytics=function(){return(0,B.useExamples)()?(0,E.jsx)(_,{}):(0,E.jsx)(W,{})},_e.MenuEngineering=function(){const{rid:e,me:t}=(0,v.useCtx)(6e4),l=(0,B.useExamples)(),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,O.dishStats)(i),r=a.reduce((e,t)=>e+t.sold,0)/Math.max(1,a.length),o=a.reduce((e,t)=>e+t.margin,0)/Math.max(1,a.length),d={Star:k.colours.ok,'Plough horse':k.colours.amber,Puzzle:k.colours.blue,Dog:k.colours.red},c=a.map(e=>({...e,q:(0,O.quadrant)(e.sold,e.margin,r,o)}));return l?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example sales & food costs",children:"Margins use example food-cost percentages. Add your real costs in production."}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Margin vs popularity"}),(0,E.jsx)(L.Scatter,{width:Math.min(n,900)-60,points:c.map(e=>({x:e.sold,y:e.margin/100,colour:d[e.q],label:e.item.name.split(' ')[0]})),xMid:r,yMid:o/100}),(0,E.jsx)(x.Row,{wrap:!0,gap:8,children:Object.keys(d).map(e=>(0,E.jsxs)(x.Row,{gap:4,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:d[e]}}),(0,E.jsx)(x.Muted,{children:e})]},e))}),(0,E.jsx)(x.Muted,{children:"Across: sold (28 days). Up: \xa3 margin per dish."})]}),['Star','Plough horse','Puzzle','Dog'].map(e=>{const t=c.filter(t=>t.q===e);return t.length?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.Row,{style:{justifyContent:'space-between'},children:(0,E.jsxs)(x.T,{weight:"semibold",colour:d[e],children:[e,"s (",t.length,")"]})}),(0,E.jsx)(x.Muted,{children:O.QUADRANT_TIP[e]}),t.map(e=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.item.name}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",Math.round(100*e.costPct),"% cost \xb7 ",(0,f.gbp)(e.margin)]}),(0,E.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:e.item.soldOut?`Back on: ${e.item.name}`:`Mark sold out: ${e.item.name}`,onPress:()=>((0,s.setSoldOut)(e.item.id,!e.item.soldOut),(0,M.autoPost)(['kitchen','foh'],e.item.soldOut?`Back on: ${e.item.name}`:`Sold out: ${e.item.name}`)),style:{marginLeft:6,paddingHorizontal:8,paddingVertical:3,borderRadius:10,borderWidth:1,borderColor:e.item.soldOut?k.colours.amber:k.colours.border},children:(0,E.jsx)(x.T,{size:11,colour:e.item.soldOut?k.colours.amber:k.colours.muted,children:e.item.soldOut?'Sold out':'Mark sold out'})})]},e.item.id))]},e):null}),(0,E.jsxs)(x.Muted,{children:["Tap Mark sold out to remind staff a dish has run out (signed by ",t,"). It shows on the Display; it doesn't change your till."]})]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"menu-eng-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"Not enough data yet"}),(0,E.jsx)(x.Muted,{children:"Menu engineering needs how many of each dish you sell and what each costs. CoverCharge doesn't have a till link yet, so nothing is shown rather than a guess. Dish costs from recipe cards are in the Head Chef app under GP."})]})})},_e.PrepList=function({go:e}){const{rid:t,r:s,now:n,me:i,today:a}=(0,v.useCtx)(6e4),r=(0,y.useOwner)(e=>e.suppliers),o=(0,j.useBookings)(t),c=(0,j.useOrders)(t),u=(0,j.useEvents)(t),h=(0,y.useOwner)(e=>e.checks),m=(0,D.useRealHistory)(t,n),p=(0,d.useMemo)(()=>(0,l.forecastToday)(s,o,c,u,n,m??void 0),[s.id,o.length,c.length,n.getHours(),m]),b=p.restOfDay.high+2*p.restOfDay.takeaway,f=(0,O.stockList)();return(0,E.jsxs)(g.default,{style:{gap:10},children:[p.enough?(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Rest of today: about ",(0,l.coversRange)(p.restOfDay.low,p.restOfDay.high)," + about ",p.restOfDay.takeaway," takeaways"]}),(0,E.jsx)(x.Muted,{children:p.example?'Example figures. Prep uses the high end of the forecast. Stock levels are examples.':'Prep uses the high end of the forecast.'})]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:p.minWeeks,booked:p.hours.reduce((e,t)=>e+t.booked,0),what:"Prep forecasts",testID:"prep-not-enough"}),f.length?null:(0,E.jsx)(x.Card,{children:(0,E.jsx)(x.Muted,{children:"No stock levels yet. CoverCharge doesn't track stock on a real venue yet, so no shortfalls are guessed."})}),f.map(t=>{const s=Math.ceil(b*t.perCover*10)/10,l=s>t.onHand,o=(0,$.supplierForCat)(r,t.cat),d=`${a}:prep:${t.id}`,c=h[d];return(0,E.jsxs)(g.default,{style:[x.styles.card,{borderColor:l?k.colours.red:k.colours.border}],children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsx)(x.Badge,{kind:l?'red':'ok',label:l?`Short ${Math.ceil(10*(s-t.onHand))/10} ${t.unit}`:'OK'})]}),(0,E.jsxs)(x.Muted,{children:["Need about ",s," ",t.unit," \xb7 on hand ",t.onHand," \xb7 par ",t.par,l?' \xb7 order, or mark dishes sold out when it runs out':'']}),l&&o?(0,E.jsxs)(x.Muted,{children:["Supplier: ",o.name," \xb7 ",o.phones[0],o.cutoff?` \xb7 order by ${o.cutoff}`:'']}):null,l&&o?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:`Order from ${o.name}`,onPress:()=>e('more','suppliers')}):null,(0,E.jsx)(x.Chip,{label:c?`Prepped \u2713 ${c.by.split(' ')[0]} ${c.at}`:'Mark prepped',selected:!!c,onPress:()=>c?y.useOwner.getState().untick(d):y.useOwner.getState().tick(d,i,(0,w.hm)(n))})]},t.id)})]})},_e.Crm=function(){const e=(0,y.useOwner)(e=>e.customerTags),[s,l]=(0,d.useState)(''),[n,i]=(0,d.useState)('All'),[a,r]=(0,d.useState)(null),o=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),c={All:()=>!0,'Opted in':e=>e.optIn,Regulars:e=>e.visits>=6,Lapsed:e=>parseInt(e.lastVisit,10)>20,Allergies:e=>e.allergies.length>0,Birthdays:e=>!!e.birthday},u=o.filter(c[n]).filter(e=>!s||e.name.toLowerCase().includes(s.toLowerCase())),h=o.find(e=>e.id===a);return o.length?(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Search customers",placeholder:"Search customers",placeholderTextColor:"#7D776C",value:s,onChangeText:l,style:x.styles.input}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(c).map(e=>(0,E.jsx)(x.Chip,{label:`${e} (${o.filter(c[e]).length})`,selected:n===e,onPress:()=>i(e)},e))}),u.map(t=>(0,E.jsxs)(x.Card,{onPress:()=>r(t.id),children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.name}),(0,E.jsxs)(x.Muted,{children:[t.visits," visits"]})]}),(0,E.jsxs)(x.Muted,{children:["Last ",t.lastVisit," \xb7 ",(0,f.gbp)(t.spend)," lifetime \xb7 ",t.stamps," stamps",t.optIn?' \xb7 opted in':'']}),t.allergies.length||(e[t.id]??[]).length?(0,E.jsxs)(x.Row,{wrap:!0,gap:4,children:[t.allergies.map(e=>(0,E.jsx)(x.Badge,{kind:"red",label:e},e)),(e[t.id]??[]).map(e=>(0,E.jsx)(x.Badge,{kind:"gold",label:e},e))]}):null]},t.id)),(0,E.jsx)(x.Muted,{children:"Customer records come from your saved data. Marketing requires consent (UK GDPR / PECR)."}),h?(0,E.jsxs)(x.Sheet,{visible:!0,onClose:()=>r(null),title:h.name,children:[(0,E.jsxs)(x.Muted,{children:[h.phone," \xb7 ",h.visits," visits \xb7 last ",h.lastVisit," \xb7 prefers ",h.channel]}),(0,E.jsxs)(x.T,{children:["Lifetime spend ",(0,f.gbp)(h.spend)," \xb7 stamps ",h.stamps]}),h.allergies.length?(0,E.jsx)(x.Banner,{kind:"danger",title:"Allergies on file",children:h.allergies.join(', ')}):(0,E.jsx)(x.Muted,{children:"No allergies on file."}),h.birthday?(0,E.jsxs)(x.Muted,{children:["Birthday: ",h.birthday]}):null,(0,E.jsx)(x.Badge,{kind:h.optIn?'ok':'neutral',label:h.optIn?'Opted in to offers':'Not opted in: no marketing'}),(0,E.jsx)(x.T,{weight:"semibold",children:"Tags"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:U.map(t=>(0,E.jsx)(x.Chip,{label:t,selected:(e[h.id]??[]).includes(t),onPress:()=>y.useOwner.getState().toggleTag(h.id,t)},t))})]}):null]}):(0,E.jsx)(x.Card,{children:(0,E.jsxs)(g.default,{testID:"crm-live",style:{gap:6},children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.gold,children:"No customer list yet"}),(0,E.jsx)(x.Muted,{children:"Customer profiles build up from guests who sign in to order or book. None are invented."})]})})},_e.Marketing=function({go:e}){const{rid:t}=(0,v.useCtx)(6e4),s=(0,y.useOwner)(e=>e.campaigns),l=(0,j.useStore)((0,p.useShallow)(e=>e.giftCards.filter(e=>e.restaurantId===t))),n=(0,j.useEvents)(t).filter(e=>e.restaurantId===t),i=(0,y.useOwner)(e=>e.marketingDraft),[a,r]=(0,d.useState)(i?.title??''),[o,c]=(0,d.useState)(i?.body??''),[u,h]=(0,d.useState)('All opted-in'),[m,b]=(0,d.useState)('Now'),k=(0,B.useExamples)(),S=k?{'All opted-in':412,'Takeaway regulars':188,'Lapsed 30+ days':96,'Birthdays this month':23}:{'All opted-in':void 0,'Takeaway regulars':void 0,'Lapsed 30+ days':void 0,'Birthdays this month':void 0};return(0,E.jsxs)(g.default,{style:{gap:10},children:[i?(0,E.jsx)(x.Banner,{kind:"info",title:"Draft from the calendar",children:`"${i.title}" is ready in the composer below.`}):null,(0,E.jsx)(x.Banner,{kind:"info",title:"Campaign delivery is not connected",children:"Drafts stay on this device. No push, SMS or email is sent."}),(0,E.jsxs)(x.Row,{gap:8,children:[k?(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Referrals"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"27"}),(0,E.jsx)(x.Muted,{children:"sign-ups, 11 ordered (example)"})]}):null,(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Gift card sales"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:(0,f.gbp)(l.reduce((e,t)=>e+t.initial,0))}),(0,E.jsxs)(x.Muted,{children:[l.length," cards"]})]})]}),(0,E.jsx)(C.SectionHead,{title:"Post to social",sub:"Facebook + Instagram, TikTok + YouTube: not set up yet, nothing is posted"}),(0,E.jsx)(T.PostToSocialButtons,{onPick:t=>(0,T.shareToSocial)(e,{group:t})}),(0,E.jsx)(T.QuickLinksSection,{go:e,heading:e=>(0,E.jsx)(C.SectionHead,{title:e})}),(0,E.jsx)(C.SectionHead,{title:"Campaigns"}),s.map(e=>(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",style:{flex:1},children:e.title}),(0,E.jsx)(x.Badge,{kind:'scheduled'===e.status?'amber':'draft'===e.status?'neutral':'ok',label:e.status})]}),(0,E.jsx)(x.Muted,{children:e.body}),(0,E.jsxs)(x.Muted,{children:[e.segment,e.reach?` \xb7 ${e.reach} people`:''," \xb7 ",e.sendAt]}),'sent (demo)'!==e.status?(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Cancel",onPress:()=>y.useOwner.getState().setCampaign(e.id,{status:'draft'})}):k?(0,E.jsx)(x.Muted,{children:"Opened 46% \xb7 23 orders (example)"}):null]},e.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"New campaign"}),(0,E.jsx)(x.Field,{label:"Title",value:a,onChangeText:r}),(0,E.jsx)(x.Field,{label:"Message",value:o,onChangeText:c,multiline:!0}),(0,E.jsx)(x.Muted,{children:"Audience"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:Object.keys(S).map(e=>(0,E.jsx)(x.Chip,{label:e,sub:null==S[e]?void 0:`${S[e]}`,selected:u===e,onPress:()=>h(e)},e))}),(0,E.jsx)(x.Muted,{children:"When"}),(0,E.jsx)(x.Row,{wrap:!0,gap:6,children:['Now','Tomorrow 10:00','Friday 15:00','Next Monday 11:00'].map(e=>(0,E.jsx)(x.Chip,{label:e,selected:m===e,onPress:()=>b(e)},e))}),(0,E.jsx)(x.Button,{label:'Now'===m?'Save (nothing is sent: not set up yet)':'Save for later (nothing is sent)',disabled:a.trim().length<3||o.trim().length<5,onPress:()=>{y.useOwner.getState().addCampaign({title:a.trim(),body:o.trim(),segment:u,sendAt:m,status:'draft',reach:S[u]??0}),y.useOwner.getState().setOwner({marketingDraft:void 0}),r(''),c('')}})]}),(0,E.jsx)(C.SectionHead,{title:"Event promos"}),n.map(t=>(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.title}),(0,E.jsx)(x.Muted,{children:(0,w.niceDate)((0,w.parseYmd)(t.date))}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Draft a promo",onPress:()=>{r(t.title.replace(' (example)','')),c(`Join us on ${(0,w.niceDate)((0,w.parseYmd)(t.date))} at ${(0,I.venueInfo)().name}. Book in the app.`)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Share to social",accessibilityLabel:`Share ${t.title} to social`,onPress:()=>(0,T.shareToSocial)(e,(0,T.eventDraft)(t))})]})]},t.id))]})},_e.Reviews=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsx)(b.ReviewsSection,{rid:e,mode:"manage",venueName:t.name})},_e.ReviewEmailSettings=function(){const{rid:e,r:t}=(0,v.useCtx)(6e4);return(0,E.jsxs)(g.default,{style:{gap:12},children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:"Ask guests for a review after their visit"}),(0,E.jsx)(x.Muted,{center:!0,children:"Off until you switch it on. Turning it on does not send an email from this screen."}),(0,E.jsx)(x.Card,{children:(0,E.jsx)(b.ReviewAskCard,{rid:e,venueName:t.name})})]})},_e.Compliance=function(){const{rid:e,now:s,me:l,today:n}=(0,v.useCtx)(3e4),i=(0,y.useOwner)(e=>e.checks),a=(0,j.useAudit)(e).filter(e=>'allergy'===e.kind||'menu'===e.kind).slice(0,15),[r,o]=(0,d.useState)({}),c=q.filter(e=>i[`${n}:${e.id}`]).length;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["Daily checklist \xb7 ",(0,w.niceDate)(s)]}),(0,E.jsx)(x.Badge,{kind:c===q.length?'ok':'amber',label:`${c}/${q.length}`})]}),(0,E.jsx)(g.default,{style:{height:8,backgroundColor:k.colours.border,borderRadius:4},children:(0,E.jsx)(g.default,{style:{height:8,width:c/q.length*100+"%",backgroundColor:k.colours.ok,borderRadius:4}})}),q.map(e=>{const a=`${n}:${e.id}`,d=i[a],c=Number(r[e.id]),u=null!=d?.value&&('freezer'===e.id?Number(d.value)>-18:'hot'===e.id?Number(d.value)<63:Number(d.value)>5);return(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{size:14,children:e.label}),d?(0,E.jsxs)(x.Muted,{children:[null!=d.value?`${d.value}\xb0C \xb7 `:'',d.by," ",d.at,u?' \xb7 OUT OF RANGE':'']}):null]}),e.temp&&!d?(0,E.jsx)(t.TextInput,{accessibilityLabel:`${e.label} \xb0C`,placeholder:"\xb0C",placeholderTextColor:"#7D776C",keyboardType:"numbers-and-punctuation",value:r[e.id]??'',onChangeText:t=>o({...r,[e.id]:t}),style:[x.styles.input,{width:64,paddingVertical:4}]}):null,(0,E.jsx)(x.Chip,{label:d?u?'\u26a0':'\u2713':'Tick',selected:!!d,disabled:!d&&e.temp&&!Number.isFinite(c),onPress:()=>d?y.useOwner.getState().untick(a):y.useOwner.getState().tick(a,l,(0,w.hm)(s),e.temp?String(c):void 0)})]},e.id)}),(0,E.jsx)(x.Muted,{children:"Fridges \u22645\xb0C, freezer \u2264\u221218\xb0C, hot-hold \u226563\xb0C (FSS guidance). Records are kept on this device for now."})]}),(0,E.jsx)(C.SectionHead,{title:"Allergen audit log",sub:"Sign-offs and overrides (full chains: More \u203a Allergen sign-off log)"}),a.length?a.map(e=>(0,E.jsxs)(x.Muted,{children:[(0,w.niceDate)(new Date(e.at))," ",(0,w.hm)(new Date(e.at))," \xb7 ",e.text]},e.id)):(0,E.jsx)(x.Muted,{children:"No allergen events yet today."})]})},_e.LostProperty=function(){const{now:e,me:s}=(0,v.useCtx)(6e4),l=(0,y.useOwner)(e=>e.lost),n=(0,y.useOwner)(e=>e.lostReports),i=(0,y.useOwner)(e=>e.coats),[a,r]=(0,d.useState)(''),[o,c]=(0,d.useState)(''),[u,h]=(0,d.useState)(''),m=Math.max(0,...i.map(e=>e.ticket))+1;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(C.SectionHead,{title:`Coat check (${i.filter(e=>'in'===e.status).length} in)`}),i.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'collected'===e.status?.55:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{weight:"semibold",children:["#",e.ticket," \xb7 ",e.desc]}),(0,E.jsx)(x.Badge,{kind:'in'===e.status?'gold':'ok',label:'in'===e.status?`In since ${e.at}`:'Collected'})]}),'in'===e.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Collected",onPress:()=>y.useOwner.getState().setOwner({coats:i.map(t=>t.id===e.id?{...t,status:'collected'}:t)})}):null]},e.id)),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(t.TextInput,{accessibilityLabel:"Coat description",placeholder:`Ticket #${m}: describe item`,placeholderTextColor:"#7D776C",value:u,onChangeText:h,style:[x.styles.input,{flex:1}]}),(0,E.jsx)(x.Button,{small:!0,label:"Check in",disabled:u.trim().length<2,onPress:()=>{y.useOwner.getState().setOwner({coats:[...i,{id:`ct-${Date.now()}`,ticket:m,desc:u.trim(),at:(0,w.hm)(e),status:'in'}]}),h('')}})]}),n.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(C.SectionHead,{title:`Reports from guests (${n.filter(e=>'open'===e.status).length} open)`,sub:"Sent from the CoverCharge customer app"}),n.map(e=>(0,E.jsxs)(x.Card,{style:{opacity:'closed'===e.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:e.item}),(0,E.jsx)(x.Badge,{kind:'open'===e.status?'amber':'ok',label:'open'===e.status?'Open':'matched'===e.status?'Matched':'Closed'})]}),(0,E.jsxs)(x.Muted,{children:[e.when," \xb7 ",e.where," \xb7 contact: ",e.contact]}),'open'===e.status?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Found it",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'matched'}:t)})}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Close",onPress:()=>y.useOwner.getState().setOwner({lostReports:n.map(t=>t.id===e.id?{...t,status:'closed'}:t)})})]}):null]},e.id))]}):null,(0,E.jsx)(C.SectionHead,{title:"Lost property"}),0===l.length?(0,E.jsx)(x.Muted,{children:"Nothing logged yet."}):null,l.map(t=>(0,E.jsxs)(x.Card,{style:{opacity:'returned'===t.status?.6:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:"semibold",children:t.item}),(0,E.jsx)(x.Badge,{kind:'held'===t.status?'amber':'ok',label:'held'===t.status?'Held':'Returned'})]}),(0,E.jsxs)(x.Muted,{children:[t.where," \xb7 found ",F(t.foundAt)," by ",t.foundBy,t.contact?` \xb7 ${t.contact}`:'']}),'held'===t.status?(0,E.jsx)(x.Button,{small:!0,kind:"secondary",label:"Mark returned",onPress:()=>y.useOwner.getState().setLost(t.id,{status:'returned',contact:`Returned ${(0,w.niceDate)(e)} by ${s}`})}):null]},t.id)),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Log a found item"}),(0,E.jsx)(x.Field,{label:"Item",value:a,onChangeText:r,placeholder:"e.g. Black phone"}),(0,E.jsx)(x.Field,{label:"Where",value:o,onChangeText:c,placeholder:"e.g. 7"}),(0,E.jsx)(x.Button,{label:"Add",disabled:a.trim().length<2,onPress:()=>{y.useOwner.getState().addLost({item:a.trim(),where:o.trim()||'Not noted',foundAt:`${e.toISOString().slice(0,10)} ${(0,w.hm)(e)}`,foundBy:s}),r(''),c('')}})]})]})},_e.useNotifications=K,_e.Notifications=function({go:e}){const{rid:t,meId:s}=(0,v.useCtx)(3e4),{list:l,read:n}=K(),[m,p]=(0,d.useState)('all'),b=(0,o.useAlerts)(e=>e.history),f=(0,o.useAlerts)(e=>e.read),w=(0,o.useAlerts)(e=>e.readAllAt[t]??0),C=e=>(0,o.isUnread)({read:f,readAllAt:{[t]:w}},e),[S,T]=(0,d.useState)(''),M=(0,o.useAlerts)(e=>e.cleared),[$,R]=(0,d.useState)(!1),[O,B]=(0,d.useState)({}),[D,P]=(0,d.useState)(null),A=b.filter(e=>e.rid===t&&!(0,o.isCleared)({cleared:M},e)),N=A.filter(e=>'all'===m||e.kind===m),L=(0,j.useBookings)(t).filter(e=>'pending'===e.status).length;c.default.useEffect(()=>{(0,o.markNotificationsSeen)(t,l.map(e=>e.id))},[t,A.length,l.length]);const I=t=>{o.useAlerts.getState().markRead([t.id]),'takeaway'===t.kind?e('orders'):'booking'!==t.kind&&'pending'!==t.kind||e('bookings')};return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.T,{weight:"semibold",center:!0,accessibilityRole:"header",children:"Alerts"}),(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Mark all read",testID:"alerts-mark-all",style:{minHeight:44},accessibilityLabel:"Mark all alerts as read",onPress:async()=>{y.useOwner.getState().markRead(l.map(e=>e.id));const e=await(0,o.markAllAlertsRead)(t,l.map(e=>e.id),s)?'All alerts marked as read':'Marked as read on this device. We\u2019ll sync it when you\u2019re back online.';T(`${e} (${(new Date).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'})})`),u.default.announceForAccessibility?.(e)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:$?'Done':'Select',testID:"alerts-select",accessibilityLabel:$?'Finish selecting alerts':'Select alerts to clear',onPress:()=>{R(!$),B({}),P(null)},style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Clear all",testID:"alerts-clear-all",disabled:!N.length,accessibilityLabel:'all'===m?'Clear all alerts from my list':`Clear all ${V.find(e=>e.id===m)?.label??''} alerts from my list`,onPress:()=>P({ids:Object.fromEntries(N.map(e=>[e.id,e.at])),all:'all'===m}),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Settings",onPress:()=>e('more','alerts'),style:{minHeight:44}})]}),$?(0,E.jsx)(g.default,{testID:"alerts-select-bar",children:(0,E.jsxs)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:[(0,E.jsx)(x.Button,{small:!0,kind:"secondary",testID:"alerts-select-all",label:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all (${N.length})`,accessibilityLabel:N.length&&N.every(e=>void 0!==O[e.id])?'Select none':`Select all ${N.length} alerts shown`,onPress:()=>B(N.length&&N.every(e=>void 0!==O[e.id])?{}:Object.fromEntries(N.map(e=>[e.id,e.at]))),style:{minHeight:44}}),(0,E.jsx)(x.Button,{small:!0,kind:"primary",testID:"alerts-clear-selected",label:`Clear selected (${Object.keys(O).length})`,accessibilityLabel:`Clear ${Object.keys(O).length} selected alerts from my list`,disabled:!Object.keys(O).length,onPress:()=>P({ids:O,all:!1}),style:{minHeight:44}})]})}):null,D?(0,E.jsx)(g.default,{testID:"alerts-clear-confirm",children:(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{center:!0,weight:"semibold",accessibilityRole:"header",children:`Clear ${Object.keys(D.ids).length} ${1===Object.keys(D.ids).length?'alert':'alerts'}?`}),(0,E.jsx)(x.Muted,{center:!0,children:"They leave your Alerts list on all your phones. Bookings, orders, reviews and emails are not deleted, and nobody else\u2019s alerts change. New alerts still come in."}),(0,E.jsxs)(x.Row,{gap:8,style:{justifyContent:'center',marginTop:8},children:[(0,E.jsx)(x.Button,{kind:"primary",testID:"alerts-clear-yes",label:"Clear",accessibilityLabel:`Yes, clear ${Object.keys(D.ids).length} alerts`,onPress:async()=>{const e=Object.keys(D.ids).length,s=`${e} ${1===e?'alert':'alerts'} cleared${await(0,o.clearAlertsSynced)(t,D.ids,D.all?Math.max(Date.now(),...Object.values(D.ids)):void 0)?'':' on this phone. We\u2019ll sync it when you\u2019re back online'}`;P(null),B({}),R(!1),T(s),u.default.announceForAccessibility?.(s)},style:{minHeight:44,minWidth:110}}),(0,E.jsx)(x.Button,{kind:"secondary",testID:"alerts-clear-cancel",label:"Cancel",accessibilityLabel:"Cancel, keep the alerts",onPress:()=>P(null),style:{minHeight:44,minWidth:110}})]})]})}):null,S?(0,E.jsx)(g.default,{testID:"alerts-mark-all-done",accessibilityLiveRegion:"polite",children:(0,E.jsx)(x.Muted,{children:S})}):null,L?(0,E.jsxs)(x.Banner,{kind:"warn",children:[L," booking ",1===L?'request needs':'requests need'," confirming. We\u2019ll keep reminding you every few minutes until ",1===L?'it\u2019s':'they\u2019re'," handled."]}):null,(0,E.jsx)(x.Row,{wrap:!0,gap:6,style:{justifyContent:'center',width:'100%'},children:V.map(e=>{const t='all'===e.id?A.filter(C).length:(s=e.id,A.filter(e=>e.kind===s&&C(e)).length);var s;return(0,E.jsxs)(h.default,{testID:`alert-filter-${e.id}`,accessibilityRole:"button",accessibilityState:{selected:m===e.id},accessibilityLabel:`Show ${e.label}${t?`, ${t} new`:''}`,onPress:()=>{p(e.id),B({}),P(null)},style:{flexDirection:'row',alignItems:'center',justifyContent:'center',gap:6,paddingHorizontal:12,paddingVertical:7,minHeight:44,borderRadius:999,borderWidth:1,borderColor:m===e.id?'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour:k.colours.border,backgroundColor:m===e.id?'#1d1a14':'transparent'},children:['all'!==e.id?(0,E.jsx)(r.KindIcon,{kind:e.id,size:15}):null,(0,E.jsx)(x.T,{size:13,colour:m===e.id?k.colours.text:k.colours.muted,children:e.label}),t?(0,E.jsx)(g.default,{style:{minWidth:16,height:16,borderRadius:8,paddingHorizontal:4,backgroundColor:'all'===e.id?k.colours.gold:o.KIND_META[e.id].colour,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(x.T,{size:10,weight:"bold",colour:"#0B0B0B",children:t})}):null]},e.id)})}),'email'!==m||o.CONNECTED_INBOX?null:(0,E.jsx)(x.Card,{children:(0,E.jsxs)(x.Row,{gap:10,children:[(0,E.jsx)(r.KindIcon,{kind:"email"}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsx)(x.T,{weight:"semibold",children:o.INBOX_EMPTY}),(0,E.jsx)(x.Muted,{children:"When your venue inbox is connected, new emails pop up here and on the Display. For now, you can send a test alert from Alerts and sounds."})]})]})}),N.map(e=>{const t=o.KIND_META[e.kind],s=C(e);return(0,E.jsx)(x.Card,{highlight:s?t.colour:void 0,onPress:()=>$?B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}):I(e),children:(0,E.jsxs)(x.Row,{gap:10,children:[$?(0,E.jsx)(h.default,{testID:`alert-check-${e.id}`,accessibilityRole:"checkbox",accessibilityState:{checked:void 0!==O[e.id]},"aria-checked":void 0!==O[e.id],accessibilityLabel:`Select alert: ${(0,o.alertText)(e).title}`,onPress:()=>B(t=>{const s={...t};return void 0!==s[e.id]?delete s[e.id]:s[e.id]=e.at,s}),style:{width:44,height:44,alignItems:'center',justifyContent:'center'},children:(0,E.jsx)(g.default,{style:{width:24,height:24,borderRadius:6,borderWidth:2,borderColor:k.colours.gold,backgroundColor:void 0!==O[e.id]?k.colours.gold:'transparent',alignItems:'center',justifyContent:'center'},children:void 0!==O[e.id]?(0,E.jsx)(a.default,{width:16,height:16,viewBox:"0 0 24 24",children:(0,E.jsx)(i.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:"#0B0B0B",strokeWidth:3,fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})}):null})}):null,(0,E.jsx)(r.KindChip,{kind:e.kind,size:34}),(0,E.jsxs)(g.default,{style:{flex:1},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:11,weight:"bold",colour:t.colour,style:{letterSpacing:1.6},children:[t.kicker,e.test?' \xb7 TEST':'']}),(0,E.jsx)(x.Muted,{children:G(e.at)})]}),(0,E.jsx)(x.T,{weight:s?'semibold':'regular',children:(0,o.alertText)(e).title.replace(/^[^:]*:\s*/,'')}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:(0,o.alertText)(e).body})]}),s?(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.colour}}):null]})},e.id+e.at)}),N.length||'email'===m&&!o.CONNECTED_INBOX?null:(0,E.jsx)(x.Muted,{children:"No alerts here yet. New bookings, requests and takeaway orders will appear as they come in."}),(0,E.jsx)(x.T,{weight:"semibold",style:{marginTop:8},children:"To do"}),l.map(t=>(0,E.jsxs)(x.Card,{highlight:n[t.id]?void 0:t.tone,onPress:()=>{y.useOwner.getState().markRead([t.id]);const[s,l]=t.tab.split(':');e(s,l??null)},children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{weight:n[t.id]?'regular':'semibold',style:{flex:1},children:t.title}),n[t.id]?null:(0,E.jsx)(g.default,{style:{width:8,height:8,borderRadius:4,backgroundColor:t.tone}})]}),(0,E.jsx)(x.Muted,{numberOfLines:2,children:t.body})]},t.id)),l.length?null:(0,E.jsx)(x.Muted,{children:"All caught up."})]})},_e.Search=function({go:e}){const{rid:s,role:l}=(0,v.useCtx)(6e4),[n,i]=(0,d.useState)(''),a=(0,j.useAllMenu)(s),r=(0,j.useOrders)(s),o=(0,j.useBookings)(s),c=(0,y.useOwner)(e=>e.staff),u=(0,d.useMemo)(()=>(0,O.crmCustomers)(),[]),h=n.trim().toLowerCase(),m=h.length<2?[]:[...R.PAGES.filter(e=>(!e.can||e.can(l))&&(e.title+e.sub).toLowerCase().includes(h)).map(t=>({k:`p${t.id}`,kind:'Screen',t:t.title,sub:t.sub,on:()=>e('more',t.id)})),...a.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Dish',t:t.name,sub:`${null!=t.price?(0,f.gbp)(t.price):'Board'}${t.soldOut?' \xb7 sold out':''}`,on:()=>e('more','menu')})),...r.filter(e=>(e.ref+e.customerName).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Order',t:`${t.ref} ${t.customerName}`,sub:t.status,on:()=>e('orders')})),...o.filter(e=>(e.name+e.ref).toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Booking',t:`${t.name} \xb7 ${t.partySize}`,sub:`${t.date} ${t.time}`,on:()=>e('bookings')})),...y.CAN.manage(l)?u.filter(e=>e.name.toLowerCase().includes(h)).map(t=>({k:t.id,kind:'Customer',t:t.name,sub:`${t.visits} visits`,on:()=>e('more','crm')})):[],...c.filter(e=>(0,y.staffMatches)(e,h)).map(t=>({k:t.id,kind:'Staff',t:(0,y.staffLabel)(t),sub:t.job,on:()=>e('more','staff')}))].slice(0,30);return(0,E.jsxs)(g.default,{style:{gap:8},children:[(0,E.jsx)(t.TextInput,{autoFocus:!0,accessibilityLabel:"Search everything",placeholder:"Search dishes, orders, bookings, customers, staff, screens",placeholderTextColor:"#7D776C",value:n,onChangeText:i,style:x.styles.input}),m.map(e=>(0,E.jsxs)(x.Card,{onPress:e.on,children:[(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsx)(x.T,{style:{flex:1},children:e.t}),(0,E.jsx)(x.Badge,{kind:"neutral",label:e.kind})]}),(0,E.jsx)(x.Muted,{children:e.sub})]},e.k)),h.length>=2&&!m.length?(0,E.jsx)(x.Muted,{children:"No matches."}):null,h.length<2?(0,E.jsx)(x.Muted,{children:"Try \u201chaddock\u201d, \u201cReid\u201d, \u201crota\u201d or \u201cT-10\u201d."}):null]})},_e.DemoTools=function(){(0,j.useStore)(e=>e.clock.mode);const[e,t]=(0,d.useState)(!1);return(0,n.useSync)(e=>!!e.venueId&&e.kind!=='guest')?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Live venue"}),(0,E.jsx)(x.Muted,{children:"This device is connected to your venue, so it uses the real date and time and only real bookings. Example data is for previews only."})]}):(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsxs)(x.Card,{children:[null,(0,E.jsx)(x.Muted,{children:"On: the example data shows a busy Friday evening. Off: real time."})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Reset example data"}),e?(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Button,{small:!0,kind:"danger",label:"Yes, reset this device",onPress:()=>{j.useStore.getState().resetDemo(),y.useOwner.getState().resetOwner(),t(!1)}}),(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Keep",onPress:()=>t(!1)})]}):(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:"Reset all example data\u2026",onPress:()=>t(!0)}),(0,E.jsx)(x.Muted,{children:"Only affects example data stored on this phone."})]})]})},_e.appUrl=Q,_e.copyText=X,_e.YourApps=function(){const[e,s]=(0,d.useState)(null);return(0,E.jsxs)(g.default,{style:{gap:8},testID:"your-apps",children:[(0,E.jsx)(x.Muted,{children:"Each one opens in a new tab. Share the right app with each person; add it to the Home screen from the browser menu."}),Y.map(l=>{const n={...l,name:(0,I.venueInfo)().name+l.name},i=Q(n.path);return(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:n.name}),(0,E.jsx)(x.Muted,{children:n.who}),(0,E.jsx)(x.Row,{gap:10,children:(0,E.jsxs)(t.Text,{role:"link",href:i,hrefAttrs:{target:'_blank',rel:'noopener noreferrer'},onPress:void 0,style:{fontFamily:k.fonts.medium,fontSize:14,lineHeight:20,color:k.colours.gold,textDecorationLine:'underline',flexShrink:1},children:["Open ",n.name," \u2197"]})}),(0,E.jsx)(x.Row,{gap:6,children:(0,E.jsx)(x.Button,{small:!0,kind:"ghost",label:e===n.path?'Copied \u2713':'Copy link',onPress:async()=>{const e=await X(Q(n.path));s(e?n.path:null),e&&setTimeout(()=>s(e=>e===n.path?null:e),2e3)}})})]},n.path)})]})};var t=_r(_d[0]),s=_r(_d[1]),l=_r(_d[2]),n=_r(_d[3]),i=_r(_d[4]),a=e(i),r=_r(_d[5]),o=_r(_d[6]),d=_r(_d[7]),c=e(d),u=e(_r(_d[8]));_r(_d[9]),_r(_d[10]);var h=e(_r(_d[11])),g=e(_r(_d[12])),m=e(_r(_d[13])),p=_r(_d[14]),x=_r(_d[15]),j=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),f=_r(_d[19]),w=_r(_d[20]),k=_r(_d[21]),C=_r(_d[22]),v=_r(_d[23]),S=_r(_d[24]),T=_r(_d[25]),M=_r(_d[26]),$=_r(_d[27]),R=_r(_d[28]),O=_r(_d[29]),B=_r(_d[30]),D=_r(_d[31]),P=_r(_d[32]),A=_r(_d[33]),N=_r(_d[34]),L=_r(_d[35]),I=_r(_d[36]),E=_r(_d[37]);const H={'Dine-in':k.colours.gold,Takeaway:k.colours.blue,'Table QR':k.colours.ok},z={gold:k.colours.gold,red:k.colours.red,amber:k.colours.amber,ok:k.colours.ok,blue:k.colours.blue},F=e=>{const t=/^(\d{4})-(\d{2})-(\d{2})(.*)$/.exec(e);return t?`${t[3]}/${t[2]}/${t[1]}${t[4]}`:e};function W(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useBookings)(e),a=(0,P.useCashUp)(e=>e.cashUps),[r,o]=(0,d.useState)(28),c=Math.min(n,900)-60,u=(0,w.ymd)(new Date(s.getTime()-864e5*r)),h=a.filter(t=>t.rid===e&&t.date>=u&&t.date({date:e.date,t:(0,A.takings)(e.vals)})).filter(e=>'number'==typeof e.t).sort((e,t)=>e.date.localeCompare(t.date)),p=h.reduce((e,t)=>e+t.t,0),b=i.filter(e=>e.date>=u&&e.date'noshow'===e.status).length,f=(0,N.clampWeeks)(t.settings.forecastMinWeeks);return(0,E.jsxs)(g.default,{style:{gap:10},testID:"analytics-live",children:[(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),h.length?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["Takings from your cash-ups (",h.length," day",1===h.length?'':'s',")"]}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:["\xa3",Math.round(p).toLocaleString('en-GB')]})]}),h.length>1?(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily takings (cash-ups)"}),(0,E.jsx)(L.LineChart,{width:c,series:[h.map(e=>e.t)],labels:h.map(e=>(0,w.niceDate)((0,w.parseYmd)(e.date)).slice(0,6))})]}):null]}):(0,E.jsx)(D.NotEnoughHistory,{weeks:f,what:"Sales figures",testID:"analytics-not-enough"}),(0,E.jsxs)(x.Card,{children:[(0,E.jsxs)(x.Muted,{children:["No-show rate (",r," days)"]}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:b.length?Math.round(y/b.length*1e3)/10+"%":'\u2014'}),(0,E.jsx)(x.Muted,{children:b.length?`${y} of ${b.length} bookings`:'No past bookings yet'})]}),(0,E.jsx)(x.Muted,{children:"Takings come from the nightly cash up; no-shows from your bookings. Dish sales and channels need a till link, which CoverCharge doesn't have yet, so they aren't shown."})]})}function _(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(6e4),{width:n}=(0,m.default)(),i=(0,j.useAllMenu)(e),a=(0,j.useBookings)(e),[r,o]=(0,d.useState)(28),c=(0,d.useMemo)(()=>(0,O.revenueHistory)(t,s,r),[t.id,r,s.toDateString()]),u=c.reduce((e,t)=>e+t.total,0),h=c.reduce((e,t)=>e+t.covers,0),p=O.CHANNELS.map(e=>({c:e,v:c.reduce((t,s)=>t+s.byChannel[e],0)})),b=(0,O.dishStats)(i).sort((e,t)=>t.sold-e.sold).slice(0,5),y=p.find(e=>'Takeaway'===e.c).v+p.find(e=>'Table QR'===e.c).v,w=Math.min(n,900)-60;return(0,E.jsxs)(g.default,{style:{gap:10},children:[(0,E.jsx)(x.Banner,{kind:"example",title:"Example figures",children:"Sales history is invented for the demo. In production it comes from your orders and till."}),(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(x.Chip,{label:"7 days",selected:7===r,onPress:()=>o(7)}),(0,E.jsx)(x.Chip,{label:"28 days",selected:28===r,onPress:()=>o(28)})]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Revenue"}),(0,E.jsx)(L.CountUp,{value:u/100,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:20})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Avg spend per Cover"}),(0,E.jsx)(L.CountUp,{value:h?u/h/100:0,format:e=>`\xa3${e.toFixed(2)}`,size:20})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Daily revenue"}),(0,E.jsx)(L.LineChart,{width:w,series:[c.map(e=>e.total/100)],labels:c.map(e=>e.label)})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Revenue by channel"}),(0,E.jsxs)(x.Row,{gap:14,children:[(0,E.jsx)(L.Donut,{parts:p.map(e=>({value:e.v,colour:H[e.c]})),centre:`\xa3${Math.round(u/1e5)}k`}),(0,E.jsx)(g.default,{style:{gap:4,flex:1},children:p.map(e=>(0,E.jsxs)(x.Row,{gap:6,children:[(0,E.jsx)(g.default,{style:{width:10,height:10,borderRadius:5,backgroundColor:H[e.c]}}),(0,E.jsx)(x.T,{size:14,style:{flex:1},children:e.c}),(0,E.jsxs)(x.T,{size:14,children:[Math.round(e.v/u*100),"%"]})]},e.c))})]})]}),(0,E.jsxs)(x.Card,{children:[(0,E.jsx)(x.T,{weight:"semibold",children:"Top dishes"}),b.map((e,t)=>(0,E.jsxs)(x.Row,{style:{justifyContent:'space-between'},children:[(0,E.jsxs)(x.T,{size:14,style:{flex:1},children:[t+1,". ",e.item.name]}),(0,E.jsxs)(x.Muted,{children:[e.sold," sold \xb7 ",(0,f.gbp)(e.revenue)]})]},e.item.id))]}),(0,E.jsxs)(x.Row,{gap:8,children:[(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"Repeat customers"}),(0,E.jsx)(x.T,{size:20,weight:"bold",children:"38%"}),(0,E.jsx)(x.Muted,{children:"2+ visits in 90 days (example)"})]}),(0,E.jsxs)(x.Card,{style:{flex:1},children:[(0,E.jsx)(x.Muted,{children:"No-show rate"}),(0,E.jsxs)(x.T,{size:20,weight:"bold",children:[4.1,"%"]}),(0,E.jsxs)(x.Muted,{children:[a.filter(e=>e.date===l&&'noshow'===e.status).length," today"]})]})]}),(0,E.jsxs)(x.Card,{highlight:k.colours.ok,children:[(0,E.jsx)(x.T,{weight:"semibold",colour:k.colours.ok,children:"Commission saved vs delivery apps"}),(0,E.jsx)(L.CountUp,{value:.3*y/100*1,format:e=>`\xa3${Math.round(e).toLocaleString('en-GB')}`,size:26,colour:k.colours.ok}),(0,E.jsxs)(x.Muted,{children:[(0,f.gbp)(y)," of direct takeaway & QR orders in ",r," days. At a typical 30% delivery-app commission, that\u2019s what you kept."]})]})]})}const U=['Regular','VIP','Local','Tourist','Birthday soon','Allergy'];const q=[{id:'fridge1',label:'Walk-in fridge temp',temp:!0},{id:'fridge2',label:'Line fridge temp',temp:!0},{id:'freezer',label:'Freezer temp',temp:!0},{id:'hot',label:'Hot-hold check (\u226563\xb0C)',temp:!0},{id:'open-clean',label:'Opening clean & sanitise surfaces'},{id:'allergen-brief',label:'Allergen briefing with front of house'},{id:'specials-allergens',label:'Specials allergens recorded & signed off'},{id:'probe',label:'Probe thermometer calibrated'},{id:'close',label:'Closing checks: fryers off, doors locked'}];function K(){const{rid:e,r:t,now:s,today:l}=(0,v.useCtx)(1e4),n=(0,j.useOrders)(e),i=(0,j.useBookings)(e),a=(0,j.useRatings)(e),r=(0,j.useWaitlist)(e),o=(0,y.useOwner)(e=>e.leave),d=(0,y.useOwner)(e=>e.swaps),c=(0,y.useOwner)(e=>e.readNotes),u=[...n.filter(e=>(0,C.LIVE)(e)&&'new'===e.status).map(e=>({id:`o-${e.id}`,tab:'orders',title:`New order ${e.ref}`,body:`${e.customerName} \xb7 ${(0,f.gbp)(e.total)}`,tone:k.colours.amber})),...n.filter(e=>(0,C.LIVE)(e)&&(0,S.chainNeedsAction)(e,i)).map(e=>({id:`oa-${e.id}`,tab:'orders',title:`Allergy on ${e.ref}`,body:'Allergen sign-off needed before it moves on',tone:k.colours.red})),...i.filter(e=>e.date===l&&'confirmed'===e.status&&(0,S.bookingNeedsAction)(e,n.filter(C.LIVE))).map(e=>({id:`ba-${e.id}`,tab:'bookings',title:`Allergy: ${e.name} at ${e.time}`,body:'Booked: allergy needs signing off',tone:k.colours.red})),...a.filter(e=>e.stars<=2).map(e=>({id:`r-${e.id}`,tab:'more:reviews',title:`${e.stars}\u2605 rating from ${e.customerName}`,body:e.comment,tone:k.colours.red})),...o.filter(e=>'pending'===e.status).map(e=>({id:`l-${e.id}`,tab:'more:rota',title:'Leave request',body:`${e.from} \u2013 ${e.to}: ${e.reason}`,tone:k.colours.blue})),...d.filter(e=>'open'===e.status).map(e=>({id:`s-${e.id}`,tab:'more:rota',title:'swap'===e.kind?'Shift swap request':'Cover needed',body:e.note,tone:k.colours.blue})),...r.filter(e=>'waiting'===e.status).length?[{id:`wl-${r.length}`,tab:'bookings',title:`${r.filter(e=>'waiting'===e.status).length} parties on the waitlist`,body:'Notify when a table frees up',tone:k.colours.gold}]:[]];return{list:u,unread:u.filter(e=>!c[e.id]).length,read:c}}const V=[{id:'all',label:'All'},{id:'booking',label:'New bookings'},{id:'pending',label:'Needs confirming'},{id:'takeaway',label:'Takeaway orders'},{id:'email',label:'Emails'},{id:'review',label:'Reviews'},{id:'test',label:'Tests'}],G=e=>{const t=Math.round((Date.now()-e)/6e4);return t<1?'just now':t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} hr ago`:`${Math.round(t/1440)} days ago`};const Y=[{name:'',who:'Customer app: what guests use',path:'/customer-app/index.html'},{name:' \xb7 Staff',who:'Staff phones',path:'/staff-app/index.html'},{name:' \xb7 Display',who:'Restaurant tablet, held sideways',path:'/display-app/index.html'},{name:' \xb7 Head Chef',who:'Kitchen: stock, costing, prep',path:'/chef-app/index.html'},{name:' \xb7 Managers',who:'This app',path:'/owner-app/index.html'}];function Q(e){if('undefined'==typeof window||!window.location)return e;const t=window.location.pathname.match(/^(.*?)\/(owner|staff|customer|display|chef)-app(\/|$)/),s=t?t[1]:'';return new URL(s+e,window.location.origin).toString()}async function X(e){try{const t='undefined'!=typeof navigator?navigator:null;if(t?.clipboard?.writeText)return await t.clipboard.writeText(e),!0;if('undefined'!=typeof document){const t=document.createElement('textarea');t.value=e,t.setAttribute('readonly',''),t.style.position='fixed',t.style.opacity='0',document.body.appendChild(t),t.select();const s=document.execCommand('copy');return document.body.removeChild(t),s}}catch{}return!1}},1438,[827,979,1161,987,797,1228,1230,34,281,379,236,402,102,426,879,794,874,1239,891,867,858,821,1195,1088,869,1439,1180,1442,1443,1160,1167,1166,1039,13,1164,1170,1224,25]); +__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,"PLATFORM",{enumerable:!0,get:function(){return v}}),_e.Mark=F,_e.shareToSocial=function(e,t){b.useOwner.getState().setOwner({socialDraft:t}),e?.('more','social')},_e.PostToSocialButtons=O,_e.validate=D,Object.defineProperty(_e,"gmailWebUrl",{enumerable:!0,get:function(){return U}}),Object.defineProperty(_e,"linkUrl",{enumerable:!0,get:function(){return G}}),_e.openQuickLink=H,Object.defineProperty(_e,"visibleLinks",{enumerable:!0,get:function(){return K}}),_e.QuickLinksSection=function({go:e,heading:t}){const{role:i}=(0,k.useCtx)(6e4),l=(0,b.useOwner)(e=>e.quickLinks);return K(l,i).length?(0,w.jsxs)(m.default,{testID:"quick-links",style:{gap:6},children:[t('Quick links'),(0,w.jsx)(X,{go:e,compact:!0})]}):null},_e.QuickLinksRow=X,_e.QuickLinksSettings=function(){const{rid:e}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.quickLinks),s=(0,t.useSiteSetup)(e).email,[o,n]=(0,r.useState)(()=>i.map(e=>({...e}))),[a,d]=(0,r.useState)(s),[u,c]=(0,r.useState)({label:'',url:'',icon:'\ud83c\udf10'}),[g,x]=(0,r.useState)(null),j=o.filter(e=>!e.builtIn).length,y=(e,t)=>{x(null),n(i=>i.map(i=>i.id===e?{...i,...t}:i))},v=(e,t)=>{const i=[...o],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],n(i),x(null))};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Shortcuts only",children:"Quick links just open another app or website. CoverCharge never reads or sends your email and never signs in for you."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Work email (Gmail)"}),(0,w.jsx)(p.Field,{label:"Work email address",value:a,onChangeText:e=>{d(e),x(null)},placeholder:"e.g. hello@yourrestaurant.co.uk",keyboardType:"email-address",autoCapitalize:"none",autoCorrect:!1}),(0,w.jsxs)(p.Muted,{children:["Opens the Gmail app if it\u2019s on this phone, otherwise Gmail on the web",a.trim()?` for ${a.trim()}`:'',"."]})]}),(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Links (in tile order)"}),o.map((e,t)=>(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsxs)(p.T,{weight:"semibold",style:{flex:1},children:[e.icon," ",e.group?`${e.group}: `:'',e.label||'New link']}),(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} up`,disabled:0===t,onPress:()=>v(t,-1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25b2"})}),(0,w.jsx)(h.default,{accessibilityLabel:`Move ${e.label} down`,disabled:t===o.length-1,onPress:()=>v(t,1),hitSlop:8,children:(0,w.jsx)(p.T,{colour:t===o.length-1?'#555':f.colours.gold,children:"\u25bc"})})]})]}),(0,w.jsx)(p.Field,{label:"Label",value:e.label,onChangeText:t=>y(e.id,{label:t})}),'gmail'===e.kind?(0,w.jsxs)(p.Muted,{children:["Email: ",a]}):(0,w.jsx)(p.Field,{label:"Web address",value:e.url,onChangeText:t=>y(e.id,{url:t}),autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),e.builtIn?null:(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(t=>(0,w.jsx)(p.Chip,{label:t,selected:e.icon===t,onPress:()=>y(e.id,{icon:t})},t))}),(0,b.isWixLink)(e)||'gmail'===e.kind?(0,w.jsx)(p.Muted,{children:"Owners and managers only. Never shown in CoverCharge for Staff or Head Chef."}):(0,w.jsx)(p.Toggle,{label:"Staff can see this link",value:e.staff,onChange:t=>y(e.id,{staff:t})}),e.builtIn?null:(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:`Remove ${e.label||'link'}`,onPress:()=>{n(t=>t.filter(t=>t.id!==e.id)),x(null)}})]},e.id)),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.T,{weight:"semibold",children:["Add your own link (",j," / ",b.MAX_CUSTOM_LINKS,")"]}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:J.map(e=>(0,w.jsx)(p.Chip,{label:e.label,onPress:()=>c({label:e.label,url:e.url,icon:e.icon})},e.label))}),(0,w.jsx)(p.Field,{label:"New link label",value:u.label,onChangeText:e=>c({...u,label:e}),placeholder:"e.g. Google Business Profile"}),(0,w.jsx)(p.Field,{label:"New link web address",value:u.url,onChangeText:e=>c({...u,url:e}),placeholder:"https://",autoCapitalize:"none",autoCorrect:!1,keyboardType:"url"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Z.map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.icon===e,onPress:()=>c({...u,icon:e})},e))}),(0,w.jsx)(p.Button,{kind:"secondary",label:"Add link",disabled:j>=b.MAX_CUSTOM_LINKS,onPress:()=>{const e=ee(u.url);u.label.trim()&&te(e)?(n(t=>[...t,{id:P('ql'),label:u.label.trim(),url:e,icon:u.icon,kind:'link',staff:!1}]),c({label:'',url:'',icon:'\ud83c\udf10'}),x({ok:!0,text:'Link added. Tap Save quick links to keep it.'})):x({ok:!1,text:'Give the new link a label and a full web address, e.g. https://example.co.uk'})}})]}),g?(0,w.jsx)(p.Banner,{kind:g.ok?'success':'danger',title:g.ok?'Done':'Check these',children:g.text}):null,(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{label:"Save quick links",onPress:()=>{const t=[];ie(a)||t.push('The work email doesn\'t look like an email address.');const i=o.map(e=>({...e,label:e.label.trim(),url:'gmail'===e.kind?'':ee(e.url)}));i.forEach(e=>{e.label||t.push('Every link needs a label.'),'gmail'===e.kind||te(e.url)||t.push(`"${e.label||'Link'}" needs a full web address, e.g. https://example.co.uk`)}),t.length?x({ok:!1,text:[...new Set(t)].join('\n')}):(b.useOwner.getState().setOwner({quickLinks:i}),l.useStore.getState().updateRestaurant(e,{contactEmail:a.trim()}),n(i),x({ok:!0,text:'Quick links saved on this device.'}))},style:{flex:1}}),(0,w.jsx)(p.Button,{kind:"ghost",label:"Restore defaults",onPress:()=>{n(b.DEFAULT_QUICK_LINKS.map(e=>({...e}))),x({ok:!0,text:'Defaults restored. Tap Save quick links to keep them.'})}})]})]})},Object.defineProperty(_e,"eventDraft",{enumerable:!0,get:function(){return le}}),Object.defineProperty(_e,"specialDraft",{enumerable:!0,get:function(){return se}}),_e.SocialPage=function(e){return o.LIVE_VENUE_BUILD?(0,w.jsxs)(m.default,{style:{gap:12},children:[(0,w.jsx)(p.Banner,{kind:"info",title:"Social publishing is not connected",children:"Nothing is published from this app. Saved drafts are kept on this device."}),(0,w.jsx)(p.Muted,{children:"Open your social account directly to publish."})]}):(0,w.jsx)(_,{...e})},_e.SocialAccounts=function(){return o.LIVE_VENUE_BUILD?(0,w.jsx)(p.Banner,{kind:"info",title:"No social publishing connection",children:"No social accounts are connected through this app."}):(0,w.jsx)(q,{})};var t=_r(_d[0]),i=_r(_d[1]),l=_r(_d[2]),s=_r(_d[3]),o=_r(_d[4]),n=_r(_d[5]),a=(function(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach(function(i){if('default'!==i){var l=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,l.get?l:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,t})(_r(_d[6]));_r(_d[7]);var r=_r(_d[8]),d=_r(_d[9]),u=e(_r(_d[10])),c=e(_r(_d[11]));_r(_d[12]);var h=e(_r(_d[13])),m=e(_r(_d[14])),p=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),x=_r(_d[18]),f=_r(_d[19]),j=_r(_d[20]),k=_r(_d[21]),y=_r(_d[22]),w=_r(_d[23]);const v={facebook:{name:'Facebook',account:'Facebook Page',colour:'#2A2722',mark:'f',limit:63206,limitLabel:'63,206'},instagram:{name:'Instagram',account:'Instagram Business',colour:'#E1306C',mark:'\u25ce',limit:2200,limitLabel:'2,200'},tiktok:{name:'TikTok',account:'TikTok',colour:'#F5F1E8',mark:'\u266a',limit:2200,limitLabel:'2,200'},youtube:{name:'YouTube',account:'YouTube channel',colour:'#FF0000',mark:'\u25b6',limit:5e3,limitLabel:'5,000'}},T=()=>(0,y.venueInfo)().name,C=100,S=()=>{const e=(0,y.venueInfo)(),t=e.place.split(',').map(e=>e.trim()).filter(e=>e&&!/fictional/i.test(e)).slice(0,2).map(e=>'#'+e.replace(/[^A-Za-z0-9]/g,''));return[...new Set([e.tag,...t,'#FoodScotland','#EatLocal','#SupportLocal'])]},$=['#2A2722','#4A3A22','#40362A','#3E2A2A','#2A2722'],P=e=>`${e}-${Math.random().toString(36).slice(2,8)}`,R=e=>e.toLocaleString('en-GB');function F({p:e,size:t=22}){const i=v[e];return(0,w.jsx)(m.default,{accessibilityLabel:i.name,style:{width:t,height:t,borderRadius:'instagram'===e?.3*t:t/2,backgroundColor:'tiktok'===e?'#000':i.colour,borderWidth:'tiktok'===e?1.5:0,borderColor:'#FE2C55',alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.T,{size:.55*t,weight:"bold",colour:'tiktok'===e?'#F5F1E8':'#fff',style:{lineHeight:.75*t},children:i.mark})})}function O({onPick:e}){const t=(0,b.useOwner)(e=>e.socialAccounts),i=({g:i,title:l,sub:s,marks:o})=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:l,onPress:()=>e(i),style:({pressed:e})=>({flexGrow:1,flexBasis:240,minHeight:104,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:e?f.colours.goldTint:f.colours.surface,padding:14,gap:6}),children:[(0,w.jsxs)(p.Row,{gap:6,children:[o.map(e=>(0,w.jsx)(F,{p:e,size:26},e)),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.T,{colour:f.colours.gold,size:20,children:"\u203a"})]}),(0,w.jsx)(p.T,{weight:"bold",size:18,children:l}),(0,w.jsx)(p.Muted,{children:s}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:o.map(e=>(0,w.jsx)(p.Badge,{kind:t[e]?'ok':'neutral',label:`${v[e].name}: ${t[e]?'connected':'not connected'}`},e))})]});return(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(0,w.jsx)(i,{g:"meta",title:"Facebook + Instagram",sub:"Meta, linked accounts \xb7 photos, carousel, Reel or Story",marks:['facebook','instagram']}),(0,w.jsx)(i,{g:"video",title:"TikTok + YouTube",sub:"Video \xb7 TikTok and YouTube Shorts or a YouTube video",marks:['tiktok','youtube']})]})}const I=(e,t)=>({group:e,fb:t?.platforms?t.platforms.includes('facebook'):'meta'===e,ig:t?.platforms?t.platforms.includes('instagram'):'meta'===e,tt:t?.platforms?t.platforms.includes('tiktok'):'video'===e,yt:t?.platforms?t.platforms.includes('youtube'):'video'===e,igFormat:t?.igFormat??'feed',ytFormat:t?.ytFormat??'short',ytTitle:t?.ytTitle??'',ytVisibility:t?.ytVisibility??'public',text:t?.text??'',media:(t?.media??[]).map(e=>({...e,id:P('md')})),when:'now',day:0,time:'17:00',source:t?.source}),L=e=>('meta'===e.group?[e.fb&&'facebook',e.ig&&'instagram']:[e.tt&&'tiktok',e.yt&&'youtube']).filter(Boolean),M=(e,t)=>{const i=new Date(t);i.setDate(i.getDate()+e.day);const[l,s]=e.time.split(':').map(Number);return i.setHours(l,s,0,0),i},B={feed:'Feed',reel:'Reel',story:'Story'},A={short:'YouTube Shorts',video:'YouTube video'};function D(e,t,i){const l=[],s=L(e),o=e.media.filter(e=>'image'===e.kind).length,n=e.media.filter(e=>'video'===e.kind).length;return s.length||l.push('meta'===e.group?'Choose Facebook, Instagram or both.':'Choose TikTok, YouTube or both.'),'meta'===e.group?(e.ig&&!e.media.length&&l.push('Instagram needs at least one photo or video. Add one from your gallery.'),e.ig&&'reel'===e.igFormat&&!n&&l.push('An Instagram Reel needs a video.'),e.ig&&'reel'===e.igFormat&&e.media.length>1&&l.push('A Reel is one video. Remove the extra items or choose Feed for a carousel.'),e.ig&&'story'===e.igFormat&&e.media.length>1&&l.push('A Story posts one photo or video at a time. Keep one item.'),e.media.length>10&&l.push('A carousel takes up to 10 photos or videos.'),!e.fb||e.ig||e.text.trim()||e.media.length||l.push('Add some text or a photo for Facebook.')):(n||l.push('TikTok and YouTube need a video. Add one from your gallery.'),o&&l.push('TikTok and YouTube take a video only. Remove the photos.'),e.yt&&!e.ytTitle.trim()&&l.push('Add a YouTube title.'),e.yt&&e.ytTitle.length>C&&l.push(`The YouTube title is too long (${e.ytTitle.length} / ${C}).`),e.tt&&!e.text.trim()&&l.push('Add a caption for TikTok.')),s.forEach(t=>{e.text.length>v[t].limit&&l.push(`The text is too long for ${v[t].name} (${R(e.text.length)} / ${v[t].limitLabel}).`)}),s.forEach(e=>{t[e]||l.push(`${v[e].account} isn't connected. Connect it in Connected accounts, or untick it.`)}),'later'===e.when&&M(e,i).getTime()<=i.getTime()+3e5&&l.push('Pick a time at least 5 minutes from now.'),l}function E({m:e,size:t=84}){const[i,l]=(0,r.useState)(!1);return(0,w.jsxs)(m.default,{style:{width:t,height:t,borderRadius:10,overflow:'hidden',backgroundColor:e.tone??'#222',alignItems:'center',justifyContent:'center'},children:[e.uri&&'image'===e.kind&&!i?(0,w.jsx)(u.default,{source:{uri:e.uri},onError:()=>l(!0),style:{position:'absolute',width:t,height:t},resizeMode:"cover"}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:.32*t,colour:"#fff",children:"\u25b6"}):!e.uri||i?(0,w.jsx)(p.T,{size:11,colour:"#fff",center:!0,numberOfLines:3,style:{padding:4},children:i?'Photo (preview unavailable)':e.name}):null,'video'===e.kind?(0,w.jsx)(p.T,{size:10,colour:"#fff",style:{position:'absolute',bottom:3,right:5},children:e.duration?`${Math.round(e.duration)}s`:'video'}):null]})}function z({p:e,n:t,title:i}){const l='yt-title'===e?C:v[e].limit,s=t>l,o=t>.9*l,n='yt-title'===e?'YouTube title':'youtube'===e?'YouTube description':v[e].name;return(0,w.jsx)(p.Badge,{kind:s?'red':o?'amber':'neutral',label:`${n} ${R(t)} / ${'yt-title'===e?C:v[e].limitLabel}`})}function Y({p:e,d:t}){const i=t.media[0],l=t.text.trim()||'Your text appears here.',o=(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(F,{p:e,size:20}),(0,w.jsx)(p.T,{weight:"semibold",size:14,children:T()}),(0,w.jsx)(m.default,{style:{flex:1}}),(0,w.jsx)(p.Muted,{children:'instagram'===e?B[t.igFormat]:'youtube'===e?A[t.ytFormat]:v[e].name})]}),n=(e,l="100%")=>i?(0,w.jsxs)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,overflow:'hidden',backgroundColor:i.tone??'#222',alignItems:'center',justifyContent:'center'},children:[i.uri&&'image'===i.kind?(0,w.jsx)(u.default,{source:{uri:i.uri},style:{position:'absolute',width:'100%',height:'100%'},resizeMode:"cover"}):null,'video'===i.kind?(0,w.jsx)(p.T,{size:30,colour:"#fff",children:"\u25b6"}):i.uri?null:(0,w.jsx)(p.T,{size:12,colour:"#fff",children:i.name}),t.media.length>1?(0,w.jsx)(m.default,{style:{position:'absolute',top:6,right:6,backgroundColor:'#000a',borderRadius:10,paddingHorizontal:6},children:(0,w.jsxs)(p.T,{size:11,colour:"#fff",children:["1/",t.media.length]})}):null]}):(0,w.jsx)(m.default,{style:{width:l,aspectRatio:e,borderRadius:8,borderWidth:1,borderStyle:'dashed',borderColor:f.colours.border,alignItems:'center',justifyContent:'center'},children:(0,w.jsx)(p.Muted,{children:"No media yet"})});return(0,w.jsxs)(m.default,{accessibilityLabel:`${v[e].name} preview`,style:{flexGrow:1,flexBasis:230,maxWidth:360,backgroundColor:(0,s.soutersSurface)('#101010'),borderRadius:14,borderWidth:1,borderColor:f.colours.border,padding:10,gap:8},children:[o,'facebook'===e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.T,{size:14,numberOfLines:5,children:l}),t.media.length?n(1.25):null,(0,w.jsx)(p.Muted,{children:"\ud83d\udc4d Like \xb7 \ud83d\udcac Comment \xb7 \u2197 Share"})]}):null,'instagram'===e?(0,w.jsxs)(w.Fragment,{children:[n('feed'===t.igFormat?1:.5625,'feed'===t.igFormat?'100%':'60%'),t.media.length>1&&'feed'===t.igFormat?(0,w.jsx)(p.Row,{gap:4,style:{justifyContent:'center'},children:t.media.slice(0,10).map((e,t)=>(0,w.jsx)(m.default,{style:{width:6,height:6,borderRadius:3,backgroundColor:t?'#555':'#3897F0'}},e.id))}):null,'story'!==t.igFormat?(0,w.jsxs)(p.T,{size:13,numberOfLines:3,children:[(0,w.jsx)(p.T,{size:13,weight:"semibold",children:"theanchoragedunure "}),l]}):(0,w.jsx)(p.Muted,{children:"Stories show the photo or video only."})]}):null,'tiktok'===e?(0,w.jsxs)(m.default,{style:{alignSelf:'center',width:'62%'},children:[n(.5625),(0,w.jsx)(p.T,{size:12,numberOfLines:3,style:{marginTop:4},children:l})]}):null,'youtube'===e?(0,w.jsxs)(w.Fragment,{children:['short'===t.ytFormat?(0,w.jsx)(m.default,{style:{alignSelf:'center',width:'62%'},children:n(.5625)}):n(1.7777777777777777),(0,w.jsx)(p.T,{weight:"semibold",size:14,numberOfLines:2,children:t.ytTitle.trim()||'Your YouTube title'}),(0,w.jsxs)(p.Muted,{children:[T()," \xb7 ",'public'===t.ytVisibility?'Public':'unlisted'===t.ytVisibility?'Unlisted':'Private']})]}):null]})}function N({onInsert:e,onClose:t}){const{rid:i,r:l,now:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.offers),a=(0,b.useOwner)(e=>e.quickLinks),r=(0,g.useEvents)(i).filter(e=>e.restaurantId===i&&e.date>=(0,x.ymd)(s)).sort((e,t)=>e.date.localeCompare(t.date)).slice(0,5),d=a.find(e=>'ql-wix-view'===e.id)?.url||(l.website?`https://${l.website}`:''),u=o.find(e=>'special'===e.kind&&e.live),c=(0,n.kitchenHoursOn)(l,s),m=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],j=[1,2,3,4,5,6,0].map(e=>{const t=(0,n.kitchenHoursOn)(l,new Date(s.getFullYear(),s.getMonth(),s.getDate()+(e-s.getDay()+7)%7));return t?`${m[e]} ${t[0]}\u2013${t[1]}`:null}).filter(Boolean).join(', '),v=[{label:'Book link',sub:d||'Set your website in Quick links',text:`Book a table: ${d}`,disabled:!d},{label:"Today's special",sub:u?u.title:'No live special',text:u?`Today's special: ${u.title}. ${u.body}`:'',disabled:!u},{label:'Opening hours',sub:c?`Kitchen today ${c[0]}\u2013${c[1]}`:'Kitchen closed today',text:`Kitchen hours: ${j}.`},...r.map(e=>({label:`What's on: ${e.title.replace(' (example)','')}`,sub:(0,x.niceDate)((0,x.parseYmd)(e.date)),text:`${e.title.replace(' (example)','')}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().name}.${e.description?` ${e.description}`:''}`}))];return(0,w.jsx)(p.Sheet,{visible:!0,onClose:t,title:"Insert",children:v.map(i=>(0,w.jsxs)(h.default,{accessibilityRole:"button",accessibilityLabel:`Insert ${i.label}`,disabled:i.disabled,onPress:()=>{e(i.text),t()},style:({pressed:e})=>({padding:12,borderRadius:12,borderWidth:1,borderColor:f.colours.border,backgroundColor:e?f.colours.goldTint:f.colours.surface,opacity:i.disabled?.4:1}),children:[(0,w.jsx)(p.T,{weight:"medium",children:i.label}),(0,w.jsx)(p.Muted,{children:i.sub})]},i.label))})}function W({initial:e,onClose:t,onDone:l}){const{now:s,role:o,me:n}=(0,k.useCtx)(3e4),d=(0,b.useOwner)(e=>e.socialAccounts),[u,c]=(0,r.useState)(e),[g,C]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),[W,V]=(0,r.useState)(!1),[_,q]=(0,r.useState)(!1),[U,G]=(0,r.useState)(null),H=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{H.current&&clearInterval(H.current)},[]);const Q=e=>c(t=>({...t,...e})),K=L(u),X=D(u,d,s),Z=b.CAN.publishSocial(o),J='meta'===u.group,ee=e=>{const t=u.media.length,i={id:P('md'),kind:e,name:'video'===e?'Example video':`Example photo ${t+1}`,tone:$[t%$.length],duration:'video'===e?24:void 0};Q({media:J?[...u.media,i].slice(0,10):[i]})},te=(e,t)=>{const i=[...u.media],l=e+t;l<0||l>=i.length||([i[e],i[l]]=[i[l],i[e]],Q({media:i}))},ie=e=>Q({text:u.text.includes(e)?u.text.replace(new RegExp(`\\s?${e}\\b`),''):`${u.text.trimEnd()}${u.text.trim()?' ':''}${e}`}),le=(e,t)=>{const i='later'===u.when;b.useOwner.getState().addSocialPost({group:u.group,platforms:K,igFormat:u.igFormat,ytFormat:u.ytFormat,ytTitle:u.ytTitle.trim(),ytVisibility:u.ytVisibility,text:u.text.trim(),media:u.media,scheduleAt:i?M(u,s).toISOString():void 0,createdAt:s.toISOString(),by:n,byRole:o,status:t,results:e})};return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"\u2039 Post to social",onPress:t}),(0,w.jsx)(p.Row,{gap:6,children:(J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(F,{p:e},e))})]}),(0,w.jsx)(p.T,{weight:"bold",size:20,children:J?'Facebook + Instagram':'TikTok + YouTube'}),(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Publishing is simulated. Nothing goes to Facebook, Instagram, TikTok or YouTube, and no account is contacted."}),u.source?(0,w.jsx)(p.Banner,{kind:"info",title:"Prefilled",children:`From ${u.source}. Edit anything before publishing.`}):null,Z?null:(0,w.jsx)(p.Banner,{kind:"info",title:"Staff draft",children:"You can prepare the post. A manager or the owner approves it before it goes out."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"Where to post"}),J?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"Facebook Page",value:u.fb,onChange:e=>Q({fb:e})}),(0,w.jsx)(p.Toggle,{label:"Instagram",value:u.ig,onChange:e=>Q({ig:e})}),(0,w.jsx)(p.Muted,{children:u.fb&&u.ig?'Both':u.fb?'Facebook only':u.ig?'Instagram only':'Nothing selected'}),u.ig?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Muted,{children:"Instagram as"}),(0,w.jsx)(p.Row,{gap:6,children:['feed','reel','story'].map(e=>(0,w.jsx)(p.Chip,{label:B[e],selected:u.igFormat===e,onPress:()=>Q({igFormat:e})},e))})]}):null]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Toggle,{label:"TikTok",value:u.tt,onChange:e=>Q({tt:e})}),(0,w.jsx)(p.Toggle,{label:"YouTube",value:u.yt,onChange:e=>Q({yt:e})}),u.yt?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{gap:6,children:['short','video'].map(e=>(0,w.jsx)(p.Chip,{label:A[e],selected:u.ytFormat===e,onPress:()=>Q({ytFormat:e})},e))}),(0,w.jsx)(p.Field,{label:"YouTube title",value:u.ytTitle,onChangeText:e=>Q({ytTitle:e}),placeholder:`e.g. Fish supper night at ${(0,y.venueInfo)().name}`}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(0,w.jsx)(z,{p:"yt-title",n:u.ytTitle.length})}),(0,w.jsx)(p.Muted,{children:"Visibility"}),(0,w.jsx)(p.Row,{gap:6,children:['public','unlisted','private'].map(e=>(0,w.jsx)(p.Chip,{label:e[0].toUpperCase()+e.slice(1),selected:u.ytVisibility===e,onPress:()=>Q({ytVisibility:e})},e))})]}):null]})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Photos and videos':'Video'}),(0,w.jsx)(p.Muted,{children:J?`${u.media.length} / 10`:u.media.length?'1 video':'none'})]}),(0,w.jsx)(p.Button,{kind:"secondary",label:J?'Choose from gallery':'Choose a video from gallery',onPress:async()=>{const e=await a.launchImageLibraryAsync({mediaTypes:J?['images','videos']:['videos'],allowsMultipleSelection:J,selectionLimit:J?10:1,quality:.8});if(e.canceled)return;const t=e.assets.map((e,t)=>({id:P('md'),kind:'video'===e.type?'video':'image',uri:e.uri,name:e.fileName??`${'video'===e.type?'Video':'Photo'} ${u.media.length+t+1}`,duration:e.duration?e.duration/1e3:void 0}));Q({media:J?[...u.media,...t].slice(0,10):t.slice(0,1)})}}),(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:[J?(0,w.jsx)(p.Chip,{label:"Example photo",onPress:()=>ee('image')}):null,(0,w.jsx)(p.Chip,{label:"Example video",onPress:()=>ee('video')})]}),u.media.length?(0,w.jsx)(p.Row,{wrap:!0,gap:8,children:u.media.map((e,t)=>(0,w.jsxs)(m.default,{accessibilityLabel:`Media ${t+1}`,style:{gap:4,alignItems:'center'},children:[(0,w.jsx)(E,{m:e}),(0,w.jsxs)(p.Row,{gap:4,children:[J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} left`,disabled:0===t,onPress:()=>te(t,-1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:0===t?'#555':f.colours.gold,children:"\u25c0"})}):null,(0,w.jsx)(i.GoldClose,{size:"sm",label:`Remove item ${t+1}`,onPress:()=>Q({media:u.media.filter(t=>t.id!==e.id)})}),J?(0,w.jsx)(h.default,{accessibilityLabel:`Move item ${t+1} right`,disabled:t===u.media.length-1,onPress:()=>te(t,1),hitSlop:6,children:(0,w.jsx)(p.T,{colour:t===u.media.length-1?'#555':f.colours.gold,children:"\u25b6"})}):null]})]},e.id))}):(0,w.jsx)(p.Muted,{children:J?'Add up to 10 photos or videos. Two or more make a carousel.':'Add one video (vertical works best for TikTok and Shorts).'})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.T,{weight:"semibold",children:J?'Post text':'Caption / description'}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Insert \u25be",onPress:()=>I(!0)})]}),(0,w.jsx)(p.Field,{label:"Text",value:u.text,onChangeText:e=>Q({text:e}),multiline:!0,placeholder:`What\u2019s happening at ${(0,y.venueInfo)().name}?`,style:{minHeight:110}}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:(K.length?K:J?['facebook','instagram']:['tiktok','youtube']).map(e=>(0,w.jsx)(z,{p:e,n:u.text.length},e))}),(0,w.jsx)(p.Muted,{children:"Hashtags"}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:S().map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.text.includes(e),onPress:()=>ie(e)},e))})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"When"}),(0,w.jsxs)(p.Row,{gap:6,children:[(0,w.jsx)(p.Chip,{label:"Post now",selected:'now'===u.when,onPress:()=>Q({when:'now'})}),(0,w.jsx)(p.Chip,{label:"Schedule",selected:'later'===u.when,onPress:()=>Q({when:'later',day:u.day||1})})]}),'later'===u.when?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:Array.from({length:7},(e,t)=>{const i=new Date(s);return i.setDate(i.getDate()+t),(0,w.jsx)(p.Chip,{label:0===t?'Today':1===t?'Tomorrow':(0,x.niceDate)(i),selected:u.day===t,onPress:()=>Q({day:t})},t)})}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:['09:00','11:00','12:00','15:00','17:00','19:00','21:00'].map(e=>(0,w.jsx)(p.Chip,{label:e,selected:u.time===e,onPress:()=>Q({time:e})},e))}),(0,w.jsxs)(p.Muted,{children:["Goes out ",(0,x.niceDate)(M(u,s))," at ",u.time," (publishing is not set up yet, so nothing goes out)."]})]}):null]}),(0,w.jsx)(j.SectionHead,{title:"Live preview",sub:"Roughly how it will look on each platform"}),(0,w.jsxs)(p.Row,{wrap:!0,gap:10,children:[(K.length?K:[]).map(e=>(0,w.jsx)(Y,{p:e,d:u},e)),K.length?null:(0,w.jsx)(p.Muted,{children:"Choose at least one platform to see a preview."})]}),g&&X.length?(0,w.jsx)(p.Banner,{kind:"danger",title:"Before you publish",children:X.map(e=>`\u2022 ${e}`).join('\n')}):null,(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Review & schedule':'Review & publish':'Review & send for approval',onPress:()=>{C(!0),X.length||V(!0)}}),O?(0,w.jsx)(N,{onClose:()=>I(!1),onInsert:e=>Q({text:`${u.text.trimEnd()}${u.text.trim()?'\n':''}${e}`})}):null,W?(0,w.jsxs)(p.Sheet,{visible:!0,onClose:()=>null==U?V(!1):null,title:Z?'Ready to publish?':'Send for approval?',children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"This is a simulation. No platform is contacted."}),(0,w.jsx)(p.T,{weight:"semibold",children:Z?'This will go to:':'When approved, this will go to:'}),K.map(e=>(0,w.jsxs)(p.Row,{gap:10,style:{alignItems:'flex-start'},children:[(0,w.jsx)(F,{p:e}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"medium",children:[v[e].account," \xb7 ",T()]}),(0,w.jsx)(p.Muted,{children:'instagram'===e?`${B[u.igFormat]}${'feed'===u.igFormat&&u.media.length>1?` (carousel of ${u.media.length})`:''}`:'youtube'===e?`${A[u.ytFormat]} \xb7 "${u.ytTitle.trim()}" \xb7 ${u.ytVisibility}`:'facebook'===e?"Page post"+(u.media.length?` with ${u.media.length} item${u.media.length>1?'s':''}`:''):'Video post'}),null!=U?(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,backgroundColor:f.colours.border,marginTop:4},children:(0,w.jsx)(m.default,{style:{height:6,borderRadius:3,width:`${Math.min(100,U)}%`,backgroundColor:f.colours.gold}})}):null]})]},e)),(0,w.jsxs)(p.Muted,{children:['later'===u.when?`Scheduled for ${(0,x.niceDate)(M(u,s))} at ${u.time}.`:'Posts now.'," ",u.media.length," media item",1===u.media.length?'':'s'," \xb7 ",R(u.text.length)," characters."]}),Z?(0,w.jsx)(p.Toggle,{label:"Simulate a failure on the last platform (demo)",value:_,onChange:q}):null,null!=U?(0,w.jsxs)(p.T,{colour:f.colours.gold,children:["Saving\u2026 ",Math.min(100,Math.round(U)),"%"]}):(0,w.jsxs)(p.Row,{gap:8,children:[(0,w.jsx)(p.Button,{kind:"ghost",label:"Back to edit",onPress:()=>V(!1),style:{flex:1}}),(0,w.jsx)(p.Button,{label:Z?'later'===u.when?'Schedule':'Publish':'Send for approval',onPress:()=>{if(!Z)return le({},'awaiting approval'),V(!1),void l('Sent for approval. A manager or the owner can approve it. Publishing: not set up yet.');G(0),H.current=setInterval(()=>G(e=>{const t=(e??0)+12.5;if(t>=100){H.current&&clearInterval(H.current);const e='later'===u.when,t=Object.fromEntries(K.map((t,i)=>[t,_&&i===K.length-1?'Failed (demo)':e?'Scheduled':'Posted']));return le(t,'done'),setTimeout(()=>{V(!1),G(null),l(e?`Saved for later (publishing is not set up yet, nothing goes out) for ${(0,x.niceDate)(M(u,s))} ${u.time}.`:_?'Posted (demo, nothing was actually published). One platform shows a demo failure.':'Posted (demo, nothing was actually published).')},250),100}return t}),150)},style:{flex:1}})]})]}):null]})}function V({onDuplicate:e}){const{role:t,me:i,now:l}=(0,k.useCtx)(3e4),s=(0,b.useOwner)(e=>e.socialPosts),o=(0,b.useOwner)(e=>e.setSocialPost),n=b.CAN.publishSocial(t);return s.length?(0,w.jsx)(m.default,{style:{gap:8},children:s.map(t=>{const s=new Date(t.scheduleAt??t.createdAt);return(0,w.jsxs)(p.Card,{highlight:'awaiting approval'===t.status?f.colours.amber:void 0,children:[(0,w.jsxs)(p.Row,{style:{justifyContent:'space-between'},children:[(0,w.jsx)(p.Row,{gap:4,children:t.platforms.map(e=>(0,w.jsx)(F,{p:e,size:18},e))}),(0,w.jsxs)(p.Muted,{children:[t.scheduleAt?'For ':'',(0,x.niceDate)(s)," ",s.toTimeString().slice(0,5)," \xb7 by ",t.by]})]}),'video'===t.group&&t.ytTitle?(0,w.jsx)(p.T,{weight:"semibold",children:t.ytTitle}):null,(0,w.jsx)(p.T,{size:14,numberOfLines:3,children:t.text||'(no text)'}),(0,w.jsxs)(p.Muted,{children:[t.media.length," media item",1===t.media.length?'':'s',t.platforms.includes('instagram')?` \xb7 Instagram ${B[t.igFormat]}`:'',t.platforms.includes('youtube')?` \xb7 ${A[t.ytFormat]} (${t.ytVisibility})`:'']}),(0,w.jsx)(p.Row,{wrap:!0,gap:6,children:'awaiting approval'===t.status?(0,w.jsx)(p.Badge,{kind:"amber",label:"Awaiting approval"}):'declined'===t.status?(0,w.jsx)(p.Badge,{kind:"neutral",label:"Declined"}):t.platforms.map(e=>{const i=t.results[e];return(0,w.jsx)(p.Badge,{kind:'Posted'===i?'ok':'Scheduled'===i?'blue':'red',label:`${v[e].name}: ${i??'\u2014'}`},e)})}),'done'===t.status?(0,w.jsx)(p.Muted,{children:"Reach, likes and comments: not set up yet"}):null,(0,w.jsxs)(p.Row,{wrap:!0,gap:6,children:['awaiting approval'===t.status&&n?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(p.Button,{small:!0,label:"Approve & publish",onPress:()=>{const e=t.scheduleAt&&new Date(t.scheduleAt)>l;o(t.id,{status:'done',approvedBy:i,results:Object.fromEntries(t.platforms.map(t=>[t,e?'Scheduled':'Posted']))})}}),(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o(t.id,{status:'declined',approvedBy:i})})]}):null,'done'===t.status&&n&&Object.values(t.results).includes('Failed (demo)')?(0,w.jsx)(p.Button,{small:!0,kind:"secondary",label:"Retry failed (demo)",onPress:()=>o(t.id,{results:Object.fromEntries(Object.entries(t.results).map(([e,t])=>[e,'Failed (demo)'===t?'Posted':t]))})}):null,(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Duplicate as new",onPress:()=>e(t)})]}),t.approvedBy?(0,w.jsxs)(p.Muted,{children:['declined'===t.status?'Declined':'Approved'," by ",t.approvedBy]}):null]},t.id)})}):(0,w.jsx)(p.Muted,{children:"No posts yet. Your demo posts appear here with a status per platform."})}function _({go:e}){const{role:t}=(0,k.useCtx)(6e4),i=(0,b.useOwner)(e=>e.socialDraft),l=(0,b.useOwner)(e=>e.socialPosts),[s,o]=(0,r.useState)(null),[n,a]=(0,r.useState)(null),[d,u]=(0,r.useState)(0);(0,r.useEffect)(()=>{i&&(o(I(i.group,i)),a(null),b.useOwner.getState().setOwner({socialDraft:void 0}))},[i]);const c=l.filter(e=>'awaiting approval'===e.status).length,h=b.CAN.publishSocial(t);return s?(0,w.jsx)(W,{initial:s,onClose:()=>o(null),onDone:e=>{o(null),a(e)}},d):(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is posted",children:"Compose and preview posts for Facebook, Instagram, TikTok and YouTube. Publishing is simulated on this device only."}),n?(0,w.jsx)(p.Banner,{kind:"success",title:n.split('.')[0],children:n.includes('.')&&n.slice(n.indexOf('.')+1).trim()||'Logged in Post history below.'}):null,c&&h?(0,w.jsx)(p.Banner,{kind:"warn",title:`${c} post${c>1?'s':''} awaiting approval`,children:"Drafted by staff. Approve or decline in Post history below."}):null,h?null:(0,w.jsx)(p.Muted,{children:"Staff can draft posts. A manager or the owner approves them before anything goes out."}),(0,w.jsx)(j.SectionHead,{title:"Post to social"}),(0,w.jsx)(O,{onPick:e=>{a(null),u(e=>e+1),o(I(e))}}),h?(0,w.jsx)(p.Button,{kind:"ghost",label:"Connected accounts \u203a",onPress:()=>e('more','socialaccounts')}):null,(0,w.jsx)(j.SectionHead,{title:"Post history",sub:"Status per platform. Duplicate a post to reuse it."}),(0,w.jsx)(V,{onDuplicate:e=>{a(null),u(e=>e+1),o(I(e.group,{...e,source:'a previous post'}))}})]})}function q(){const e=(0,b.useOwner)(e=>e.socialAccounts),t=(e,t)=>b.useOwner.getState().setOwner({socialAccounts:{...b.useOwner.getState().socialAccounts,[e]:t}}),i=({p:i,via:l})=>(0,w.jsxs)(p.Row,{gap:10,children:[(0,w.jsx)(F,{p:i,size:30}),(0,w.jsxs)(m.default,{style:{flex:1},children:[(0,w.jsxs)(p.T,{weight:"semibold",children:[v[i].account,l?` (${l})`:'']}),(0,w.jsx)(p.Muted,{children:e[i]?`Connected as ${T()} (mock)`:'Not connected'})]}),(0,w.jsx)(p.Button,{small:!0,kind:e[i]?'ghost':'primary',label:e[i]?'Disconnect':'Connect',accessibilityLabel:`${e[i]?'Disconnect':'Connect'} ${v[i].name}`,onPress:()=>t(i,!e[i])})]});return(0,w.jsxs)(m.default,{style:{gap:10},children:[(0,w.jsx)(p.Banner,{kind:"demo",title:"Demo, nothing is connected",children:"These are mock connections. No login happens and no platform is contacted."}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Meta"}),(0,w.jsx)(i,{p:"facebook",via:"via Meta"}),(0,w.jsx)(i,{p:"instagram",via:"via Meta"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",colour:f.colours.gold,children:"Video"}),(0,w.jsx)(i,{p:"tiktok"}),(0,w.jsx)(i,{p:"youtube"})]}),(0,w.jsxs)(p.Card,{children:[(0,w.jsx)(p.T,{weight:"semibold",children:"For real posting"}),(0,w.jsx)(p.Muted,{children:"Each platform needs its business API approval before CoverCharge can publish for you: the Meta Graph API for Facebook Page and Instagram content publishing (Instagram Business or Creator account linked to the Page), the TikTok Content Posting API, and the YouTube Data API for uploads. Until then, this screen is a mock."})]})]})}const U=e=>e.trim()?`https://mail.google.com/mail/u/?authuser=${encodeURIComponent(e.trim())}`:'https://mail.google.com/mail/',G=(e,t)=>'gmail'===e.kind?U(t):e.url;async function H(e,t){return e.kind,await c.default.openURL(G(e,t)),'web'}const Q=e=>{try{return new URL(e).host.replace(/^www\./,'')}catch{return e}},K=(e,t)=>'chef'!==t||(0,d.can)('chef','quick-links')?e.filter(e=>'staff'!==t||e.staff&&!(0,b.isWixLink)(e)&&'gmail'!==e.kind):[];function X({go:e,compact:i}){const{role:l,rid:s}=(0,k.useCtx)(6e4),o=(0,b.useOwner)(e=>e.quickLinks),n=(0,t.useSiteSetup)(s).email,[a,d]=(0,r.useState)(null),u=K(o,l),c=[];u.forEach(e=>{const t=e.group??e.id,i=c.find(e=>e.key===t);i?i.items.push(e):c.push({key:t,title:e.group??e.label,icon:e.icon,items:[e]})});const g=async e=>{const t=await H(e,n).catch(()=>null);d(t?`Opened ${'gmail'===e.kind&&'app'===t?'the Gmail app':Q(G(e,n))}`:`Couldn't open ${e.label}`)};return c.length?(0,w.jsxs)(m.default,{style:{gap:6},children:[(0,w.jsx)(p.Row,{wrap:!0,gap:10,children:c.map(e=>{const t=1===e.items.length?e.items[0]:null,l='gmail'===t?.kind,s='Website bookings'===e.key?'\ud83c\udf10':e.icon,o=(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(m.default,{style:{gap:6,alignItems:'center',width:'100%',minWidth:0},children:[(0,w.jsxs)(p.Row,{wrap:!0,style:{justifyContent:'center'},children:[(0,w.jsx)(p.T,{size:22,children:s}),t?(0,w.jsx)(p.T,{colour:f.colours.gold,size:18,children:"\u2197"}):null]}),(0,w.jsx)(p.T,{center:!0,weight:"bold",size:16,style:{width:'100%'},children:e.title})]}),(0,w.jsx)(p.Muted,{numberOfLines:1,children:l?n||'Opens Gmail \xb7 set your work email in Quick links':Q(t?t.url:e.items[0].url)}),t?null:(0,w.jsx)(m.default,{style:{gap:6,width:'100%',minWidth:0},children:e.items.map(t=>(0,w.jsx)(p.Button,{small:!0,kind:t.label.startsWith('Edit')?'ghost':'secondary',label:t.label,accessibilityLabel:`${e.title}: ${t.label}`,onPress:()=>g(t),style:{width:'100%',minWidth:0,maxWidth:'100%'}},t.id))})]}),a={flexGrow:1,flexBasis:i?150:200,minHeight:84,borderRadius:16,borderWidth:1.5,borderColor:f.colours.gold,backgroundColor:f.colours.surface,padding:12,gap:6};return t?(0,w.jsx)(h.default,{accessibilityRole:"link",accessibilityLabel:e.title,onPress:()=>g(t),style:({pressed:e})=>[a,e&&{backgroundColor:f.colours.goldTint}],children:o},e.key):(0,w.jsx)(m.default,{style:a,children:o},e.key)})}),a?(0,w.jsx)(p.Muted,{children:a}):null,e&&b.CAN.manage(l)?(0,w.jsx)(p.Button,{small:!0,kind:"ghost",label:"Edit quick links \u203a",onPress:()=>e('more','quicklinks'),style:{alignSelf:'flex-start'}}):null]}):null}const Z=['\u2709\ufe0f','\ud83c\udf10','\ud83d\udd8a\ufe0f','\ud83d\udcc5','\u2b50','\ud83d\udccd','\ud83d\udcc8','\ud83d\uded2','\ud83d\udcde','\ud83d\udd8b\ufe0f'],J=[{label:'Outlook',url:'https://outlook.office.com/mail/',icon:'\u2709\ufe0f'},{label:'Squarespace',url:'https://account.squarespace.com',icon:'\ud83d\udd8a\ufe0f'},{label:'Google Business Profile',url:'https://business.google.com',icon:'\ud83d\udccd'}],ee=e=>{const t=e.trim();return t?/^(https?:|mailto:|tel:)/i.test(t)?t:`https://${t}`:t},te=e=>/^(https?:\/\/[^\s/$.?#][^\s]*\.[^\s]+|mailto:[^\s@]+@[^\s@]+|tel:\+?[\d\s]{6,})$/i.test(e),ie=e=>!e.trim()||/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim());const le=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`What's on: ${t}`,text:`${t}, ${(0,x.niceDate)((0,x.parseYmd)(e.date))} at ${(0,y.venueInfo)().address}.${e.description?`\n${e.description}`:''}\nBook your table now. ${(0,y.venueInfo)().tag}`,ytTitle:`${t} at ${(0,y.venueInfo)().name}`.slice(0,C)}},se=e=>{const t=e.title.replace(' (example)','');return{group:'meta',source:`Specials: ${t}`,text:`${t}\n${e.body}\n${(0,y.venueInfo)().tag}`,ytTitle:t.slice(0,C)}}},1439,[927,796,831,828,837,878,1076,1440,34,994,336,379,236,402,102,794,874,891,858,821,1195,1088,1224,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ActivityAction",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"ResultCode",{enumerable:!0,get:function(){return N}}),_e.startActivityAsync=async function(T,S={}){if(!_.default.startActivity)throw new E.UnavailabilityError('IntentLauncher','startActivityAsync');if(!T||'string'!=typeof T)throw new TypeError("'activityAction' argument must be a non-empty string!");return _.default.startActivity(T,S)},_e.openApplication=function(T){if(!_.default.openApplication)throw new E.UnavailabilityError('IntentLauncher','openApplication');return _.default.openApplication(T)},_e.getApplicationIconAsync=async function(T){if(!_.default.getApplicationIcon)throw new E.UnavailabilityError('IntentLauncher','getApplicationIconAsync');return _.default.getApplicationIcon(T)};var T,E=r(d[0]),S=r(d[1]),_=(T=S)&&T.__esModule?T:{default:T},I=(function(T){return T.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS="android.settings.ACCESSIBILITY_COLOR_CONTRAST_SETTINGS",T.ACCESSIBILITY_COLOR_MOTION_SETTINGS="android.settings.ACCESSIBILITY_COLOR_MOTION_SETTINGS",T.ACCESSIBILITY_COLOR_SPACE_SETTINGS="com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS",T.ACCESSIBILITY_DETAILS_SETTINGS="android.settings.ACCESSIBILITY_DETAILS_SETTINGS",T.ACCESSIBILITY_SETTINGS="android.settings.ACCESSIBILITY_SETTINGS",T.ACCESSIBILITY_SETTINGS_FOR_SUW="android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW",T.ACCESSIBILITY_SHORTCUT_SETTINGS="android.settings.ACCESSIBILITY_SHORTCUT_SETTINGS",T.ACCOUNT_SYNC_SETTINGS="android.settings.ACCOUNT_SYNC_SETTINGS",T.ADAPTIVE_BRIGHTNESS_SETTINGS="android.settings.ADAPTIVE_BRIGHTNESS_SETTINGS",T.ADD_ACCOUNT_SETTINGS="android.settings.ADD_ACCOUNT_SETTINGS",T.ADVANCED_CONNECTED_DEVICE_SETTINGS="com.android.settings.ADVANCED_CONNECTED_DEVICE_SETTINGS",T.ADVANCED_MEMORY_PROTECTION_SETTINGS="android.settings.ADVANCED_MEMORY_PROTECTION_SETTINGS",T.AIRPLANE_MODE_SETTINGS="android.settings.AIRPLANE_MODE_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS="android.settings.ALL_APPS_NOTIFICATION_SETTINGS",T.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW="android.settings.ALL_APPS_NOTIFICATION_SETTINGS_FOR_REVIEW",T.APN_SETTINGS="android.settings.APN_SETTINGS",T.APP_LOCALE_SETTINGS="android.settings.APP_LOCALE_SETTINGS",T.APP_MEMORY_USAGE="android.settings.APP_MEMORY_USAGE",T.APP_NOTIFICATION_BUBBLE_SETTINGS="android.settings.APP_NOTIFICATION_BUBBLE_SETTINGS",T.APP_NOTIFICATION_REDACTION="android.settings.ACTION_APP_NOTIFICATION_REDACTION",T.APP_NOTIFICATION_SETTINGS="android.settings.APP_NOTIFICATION_SETTINGS",T.APP_OPEN_BY_DEFAULT_SETTINGS="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS",T.APP_STORAGE_SETTINGS="com.android.settings.APP_STORAGE_SETTINGS",T.APPLICATION_DETAILS_SETTINGS="android.settings.APPLICATION_DETAILS_SETTINGS",T.APPLICATION_DEVELOPMENT_SETTINGS="android.settings.APPLICATION_DEVELOPMENT_SETTINGS",T.APPLICATION_SETTINGS="android.settings.APPLICATION_SETTINGS",T.AUDIO_STREAM_DIALOG="android.settings.AUDIO_STREAM_DIALOG",T.AUTO_ROTATE_SETTINGS="android.settings.AUTO_ROTATE_SETTINGS",T.AUTOMATIC_ZEN_RULE_SETTINGS="android.settings.AUTOMATIC_ZEN_RULE_SETTINGS",T.BACKUP_SETTINGS="com.android.settings.BACKUP_SETTINGS",T.BATTERY_POWER_USAGE_ADVANCED="com.android.settings.battery.action.POWER_USAGE_ADVANCED",T.BATTERY_SAVER_SCHEDULE_SETTINGS="com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS",T.BATTERY_SAVER_SETTINGS="android.settings.BATTERY_SAVER_SETTINGS",T.BIOMETRIC_ENROLL="android.settings.BIOMETRIC_ENROLL",T.BIOMETRIC_SETTINGS_PROVIDER="com.android.settings.biometrics.BIOMETRIC_SETTINGS_PROVIDER",T.BLUETOOTH_AUDIO_SHARING_SETTINGS="com.android.settings.BLUETOOTH_AUDIO_SHARING_SETTINGS",T.BLUETOOTH_DASHBOARD_SETTINGS="android.settings.BLUETOOTH_DASHBOARD_SETTINGS",T.BLUETOOTH_DEVICE_DETAIL_SETTINGS="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS",T.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER="android.settings.BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER",T.BLUETOOTH_PAIRING_SETTINGS="android.settings.BLUETOOTH_PAIRING_SETTINGS",T.BLUETOOTH_SETTINGS="android.settings.BLUETOOTH_SETTINGS",T.BLUTOOTH_FIND_BROADCASTS_ACTIVITY="android.settings.BLUTOOTH_FIND_BROADCASTS_ACTIVITY",T.BUGREPORT_HANDLER_SETTINGS="android.settings.BUGREPORT_HANDLER_SETTINGS",T.BUTTON_NAVIGATION_SETTINGS="com.android.settings.BUTTON_NAVIGATION_SETTINGS",T.CAPTIONING_SETTINGS="android.settings.CAPTIONING_SETTINGS",T.CAST_SETTINGS="android.settings.CAST_SETTINGS",T.CELLULAR_NETWORK_SECURITY="android.settings.CELLULAR_NETWORK_SECURITY",T.CHANNEL_NOTIFICATION_SETTINGS="android.settings.CHANNEL_NOTIFICATION_SETTINGS",T.COLOR_INVERSION_SETTINGS="android.settings.COLOR_INVERSION_SETTINGS",T.COMBINED_BIOMETRICS_SETTINGS="android.settings.COMBINED_BIOMETRICS_SETTINGS",T.COMMUNAL_SETTINGS="android.settings.COMMUNAL_SETTINGS",T.CONDITION_PROVIDER_SETTINGS="android.settings.ACTION_CONDITION_PROVIDER_SETTINGS",T.CONVERSATION_SETTINGS="android.settings.CONVERSATION_SETTINGS",T.CREDENTIAL_PROVIDER="android.settings.CREDENTIAL_PROVIDER",T.DARK_THEME_SETTINGS="android.settings.DARK_THEME_SETTINGS",T.DATA_ROAMING_SETTINGS="android.settings.DATA_ROAMING_SETTINGS",T.DATA_SAVER_SETTINGS="android.settings.DATA_SAVER_SETTINGS",T.DATA_USAGE_SETTINGS="android.settings.DATA_USAGE_SETTINGS",T.DATE_SETTINGS="android.settings.DATE_SETTINGS",T.DEVELOPMENT_START_DSU_LOADER="android.settings.development.START_DSU_LOADER",T.DEVICE_INFO_SETTINGS="android.settings.DEVICE_INFO_SETTINGS",T.DEVICE_NAME="android.settings.DEVICE_NAME",T.DISPLAY_SETTINGS="android.settings.DISPLAY_SETTINGS",T.DREAM_SETTINGS="android.settings.DREAM_SETTINGS",T.ENTERPRISE_PRIVACY_SETTINGS="android.settings.ENTERPRISE_PRIVACY_SETTINGS",T.FACE_ENROLL="android.settings.FACE_ENROLL",T.FACE_SETTINGS="android.settings.FACE_SETTINGS",T.FACTORY_RESET="com.android.settings.action.FACTORY_RESET",T.FINGERPRINT_ENROLL="android.settings.FINGERPRINT_ENROLL",T.FINGERPRINT_SETTINGS="android.settings.FINGERPRINT_SETTINGS",T.FINGERPRINT_SETTINGS_V2="android.settings.FINGERPRINT_SETTINGS_V2",T.FINGERPRINT_SETUP="android.settings.FINGERPRINT_SETUP",T.FIRST_DAY_OF_WEEK_SETTINGS="android.settings.FIRST_DAY_OF_WEEK_SETTINGS",T.GESTURE_NAVIGATION_SETTINGS="com.android.settings.GESTURE_NAVIGATION_SETTINGS",T.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS="android.settings.HARD_KEYBOARD_LAYOUT_PICKER_SETTINGS",T.HARD_KEYBOARD_SETTINGS="android.settings.HARD_KEYBOARD_SETTINGS",T.HEARING_DEVICES_PAIRING_SETTINGS="android.settings.HEARING_DEVICES_PAIRING_SETTINGS",T.HEARING_DEVICES_SETTINGS="android.settings.HEARING_DEVICES_SETTINGS",T.HOME_SETTINGS="android.settings.HOME_SETTINGS",T.IA_SETTINGS="com.android.settings.action.IA_SETTINGS",T.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS",T.IGNORE_BATTERY_OPTIMIZATION_SETTINGS="android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS",T.INPUT_METHOD_SETTINGS="android.settings.INPUT_METHOD_SETTINGS",T.INPUT_METHOD_SUBTYPE_SETTINGS="android.settings.INPUT_METHOD_SUBTYPE_SETTINGS",T.INTERNAL_STORAGE_SETTINGS="android.settings.INTERNAL_STORAGE_SETTINGS",T.LANGUAGE_SETTINGS="android.settings.LANGUAGE_SETTINGS",T.LICENSE="android.settings.LICENSE",T.LOCALE_SETTINGS="android.settings.LOCALE_SETTINGS",T.LOCATION_SCANNING_SETTINGS="android.settings.LOCATION_SCANNING_SETTINGS",T.LOCATION_SOURCE_SETTINGS="android.settings.LOCATION_SOURCE_SETTINGS",T.LOCK_SCREEN_SETTINGS="android.settings.LOCK_SCREEN_SETTINGS",T.MANAGE_ADAPTIVE_NOTIFICATIONS="android.settings.MANAGE_ADAPTIVE_NOTIFICATIONS",T.MANAGE_ALL_APPLICATIONS_SETTINGS="android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS",T.MANAGE_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_ALL_SIM_PROFILES_SETTINGS="android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS",T.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION="android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION",T.MANAGE_APP_LONG_RUNNING_JOBS="android.settings.MANAGE_APP_LONG_RUNNING_JOBS",T.MANAGE_APP_OVERLAY_PERMISSION="android.settings.MANAGE_APP_OVERLAY_PERMISSION",T.MANAGE_APP_USE_FULL_SCREEN_INTENT="android.settings.MANAGE_APP_USE_FULL_SCREEN_INTENT",T.MANAGE_APPLICATIONS_SETTINGS="android.settings.MANAGE_APPLICATIONS_SETTINGS",T.MANAGE_CLONED_APPS_SETTINGS="android.settings.MANAGE_CLONED_APPS_SETTINGS",T.MANAGE_CROSS_PROFILE_ACCESS="android.settings.MANAGE_CROSS_PROFILE_ACCESS",T.MANAGE_DEFAULT_APPS_SETTINGS="android.settings.MANAGE_DEFAULT_APPS_SETTINGS",T.MANAGE_DOMAIN_URLS="android.settings.MANAGE_DOMAIN_URLS",T.MANAGE_OVERLAY_PERMISSION="android.settings.action.MANAGE_OVERLAY_PERMISSION",T.MANAGE_UNKNOWN_APP_SOURCES="android.settings.MANAGE_UNKNOWN_APP_SOURCES",T.MANAGE_USER_ASPECT_RATIO_SETTINGS="android.settings.MANAGE_USER_ASPECT_RATIO_SETTINGS",T.MANAGE_WRITE_SETTINGS="android.settings.action.MANAGE_WRITE_SETTINGS",T.MANAGED_PROFILE_SETTINGS="android.settings.MANAGED_PROFILE_SETTINGS",T.MEDIA_BROADCAST_DIALOG="android.settings.MEDIA_BROADCAST_DIALOG",T.MEDIA_CONTROLS_SETTINGS="android.settings.ACTION_MEDIA_CONTROLS_SETTINGS",T.MEMORY_CARD_SETTINGS="android.settings.MEMORY_CARD_SETTINGS",T.MMS_MESSAGE_SETTING="android.settings.MMS_MESSAGE_SETTING",T.MOBILE_DATA_USAGE="android.settings.MOBILE_DATA_USAGE",T.MOBILE_NETWORK_LIST="android.settings.MOBILE_NETWORK_LIST",T.MODULE_LICENSES="android.settings.MODULE_LICENSES",T.MONITORING_CERT_INFO="com.android.settings.MONITORING_CERT_INFO",T.MORE_SECURITY_PRIVACY_SETTINGS="com.android.settings.MORE_SECURITY_PRIVACY_SETTINGS",T.NAVIGATION_MODE_SETTINGS="com.android.settings.NAVIGATION_MODE_SETTINGS",T.NETWORK_OPERATOR_SETTINGS="android.settings.NETWORK_OPERATOR_SETTINGS",T.NETWORK_PROVIDER_SETTINGS="android.settings.NETWORK_PROVIDER_SETTINGS",T.NFC_SETTINGS="android.settings.NFC_SETTINGS",T.NIGHT_DISPLAY_SETTINGS="android.settings.NIGHT_DISPLAY_SETTINGS",T.NOTIFICATION_ASSISTANT_SETTINGS="android.settings.NOTIFICATION_ASSISTANT_SETTINGS",T.NOTIFICATION_HISTORY="android.settings.NOTIFICATION_HISTORY",T.NOTIFICATION_LISTENER_DETAIL_SETTINGS="android.settings.NOTIFICATION_LISTENER_DETAIL_SETTINGS",T.NOTIFICATION_LISTENER_SETTINGS="android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_DETAIL_SETTINGS",T.NOTIFICATION_POLICY_ACCESS_SETTINGS="android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS",T.NOTIFICATION_SETTINGS="android.settings.NOTIFICATION_SETTINGS",T.ONE_HANDED_SETTINGS="android.settings.action.ONE_HANDED_SETTINGS",T.OPEN_PRIVATE_SPACE_SETTINGS="com.android.settings.action.OPEN_PRIVATE_SPACE_SETTINGS",T.OTHER_SOUND_SETTINGS="android.settings.ACTION_OTHER_SOUND_SETTINGS",T.PANEL_INTERNET_CONNECTIVITY="android.settings.panel.action.INTERNET_CONNECTIVITY",T.PANEL_NFC="android.settings.panel.action.NFC",T.PANEL_VOLUME="android.settings.panel.action.VOLUME",T.PANEL_WIFI="android.settings.panel.action.WIFI",T.PICTURE_IN_PICTURE_SETTINGS="android.settings.PICTURE_IN_PICTURE_SETTINGS",T.POWER_MENU_SETTINGS="android.settings.ACTION_POWER_MENU_SETTINGS",T.PREMIUM_SMS_SETTINGS="android.settings.PREMIUM_SMS_SETTINGS",T.PREVIOUSLY_CONNECTED_DEVICE="com.android.settings.PREVIOUSLY_CONNECTED_DEVICE",T.PRINT_SETTINGS="android.settings.ACTION_PRINT_SETTINGS",T.PRIVACY_ADVANCED_SETTINGS="android.settings.PRIVACY_ADVANCED_SETTINGS",T.PRIVACY_CONTROLS="android.settings.PRIVACY_CONTROLS",T.PRIVACY_SETTINGS="android.settings.PRIVACY_SETTINGS",T.PROCESS_WIFI_EASY_CONNECT_URI="android.settings.PROCESS_WIFI_EASY_CONNECT_URI",T.REDUCE_BRIGHT_COLORS_SETTINGS="android.settings.REDUCE_BRIGHT_COLORS_SETTINGS",T.REGIONAL_PREFERENCES_SETTINGS="android.settings.REGIONAL_PREFERENCES_SETTINGS",T.REMOTE_AUTHENTICATOR_ENROLL="android.settings.REMOTE_AUTHENTICATOR_ENROLL",T.REQUEST_ENABLE_CONTENT_CAPTURE="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE",T.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS="android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS",T.REQUEST_MANAGE_MEDIA="android.settings.REQUEST_MANAGE_MEDIA",T.REQUEST_MEDIA_ROUTING_CONTROL="android.settings.REQUEST_MEDIA_ROUTING_CONTROL",T.REQUEST_SCHEDULE_EXACT_ALARM="android.settings.REQUEST_SCHEDULE_EXACT_ALARM",T.REQUEST_SET_AUTOFILL_SERVICE="android.settings.REQUEST_SET_AUTOFILL_SERVICE",T.SATELLITE_SETTING="android.settings.SATELLITE_SETTING",T.SCREEN_TIMEOUT_SETTINGS="android.settings.SCREEN_TIMEOUT_SETTINGS",T.SEARCH_RESULT_TRAMPOLINE="com.android.settings.SEARCH_RESULT_TRAMPOLINE",T.SECURITY_ADVANCED_SETTINGS="com.android.settings.security.SECURITY_ADVANCED_SETTINGS",T.SECURITY_SETTINGS="android.settings.SECURITY_SETTINGS",T.SETTINGS="android.settings.SETTINGS",T.SETTINGS_EMBED_DEEP_LINK_ACTIVITY="android.settings.SETTINGS_EMBED_DEEP_LINK_ACTIVITY",T.SETUP_LOCK_SCREEN="com.android.settings.SETUP_LOCK_SCREEN",T.SHOW_ADMIN_SUPPORT_DETAILS="android.settings.SHOW_ADMIN_SUPPORT_DETAILS",T.SHOW_MANUAL="android.settings.SHOW_MANUAL",T.SHOW_REGULATORY_INFO="android.settings.SHOW_REGULATORY_INFO",T.SHOW_REMOTE_BUGREPORT_DIALOG="android.settings.SHOW_REMOTE_BUGREPORT_DIALOG",T.SHOW_RESTRICTED_SETTING_DIALOG="android.settings.SHOW_RESTRICTED_SETTING_DIALOG",T.SIM_PREFERENCE_SETTINGS="android.settings.SIM_PREFERENCE_SETTINGS",T.SIM_SUB_INFO_SETTINGS="com.android.settings.sim.SIM_SUB_INFO_SETTINGS",T.SOUND_SETTINGS="android.settings.SOUND_SETTINGS",T.SPA_SEARCH_LANDING="android.settings.SPA_SEARCH_LANDING",T.STORAGE_MANAGER_SETTINGS="android.settings.STORAGE_MANAGER_SETTINGS",T.STYLUS_USI_DETAILS_SETTINGS="com.android.settings.STYLUS_USI_DETAILS_SETTINGS",T.SUGGESTION_STATE_PROVIDER="com.android.settings.action.SUGGESTION_STATE_PROVIDER",T.SUPPORT_SETTINGS="com.android.settings.action.SUPPORT_SETTINGS",T.SYNC_SETTINGS="android.settings.SYNC_SETTINGS",T.TEMPERATURE_UNIT_SETTINGS="android.settings.TEMPERATURE_UNIT_SETTINGS",T.TETHER_PROVISIONING_UI="android.settings.TETHER_PROVISIONING_UI",T.TETHER_SETTINGS="android.settings.TETHER_SETTINGS",T.TETHER_UNSUPPORTED_CARRIER_UI="android.settings.TETHER_UNSUPPORTED_CARRIER_UI",T.TEXT_READING_SETTINGS="android.settings.TEXT_READING_SETTINGS",T.TRUSTED_CREDENTIALS="com.android.settings.TRUSTED_CREDENTIALS",T.TRUSTED_CREDENTIALS_USER="com.android.settings.TRUSTED_CREDENTIALS_USER",T.TTS_SETTINGS="com.android.settings.TTS_SETTINGS",T.TURN_SCREEN_ON_SETTINGS="android.settings.TURN_SCREEN_ON_SETTINGS",T.USAGE_ACCESS_SETTINGS="android.settings.USAGE_ACCESS_SETTINGS",T.USER_DICTIONARY_INSERT="android.settings.USER_DICTIONARY_INSERT",T.USER_DICTIONARY_SETTINGS="android.settings.USER_DICTIONARY_SETTINGS",T.USER_SETTINGS="android.settings.USER_SETTINGS",T.VIEW_ADVANCED_POWER_USAGE_DETAIL="android.settings.VIEW_ADVANCED_POWER_USAGE_DETAIL",T.VOICE_CONTROL_AIRPLANE_MODE="android.settings.VOICE_CONTROL_AIRPLANE_MODE",T.VOICE_CONTROL_BATTERY_SAVER_MODE="android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE",T.VOICE_CONTROL_DO_NOT_DISTURB_MODE="android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE",T.VOICE_INPUT_SETTINGS="android.settings.VOICE_INPUT_SETTINGS",T.VPN_SETTINGS="android.settings.VPN_SETTINGS",T.VR_LISTENER_SETTINGS="android.settings.VR_LISTENER_SETTINGS",T.WALLPAPER_SETTINGS="android.settings.WALLPAPER_SETTINGS",T.WEBVIEW_SETTINGS="android.settings.WEBVIEW_SETTINGS",T.WIFI_ADD_NETWORKS="android.settings.WIFI_ADD_NETWORKS",T.WIFI_CALLING_SETTINGS="android.settings.WIFI_CALLING_SETTINGS",T.WIFI_DETAILS_SETTINGS="android.settings.WIFI_DETAILS_SETTINGS",T.WIFI_DIALOG="com.android.settings.WIFI_DIALOG",T.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_AUTH_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR",T.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER",T.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER="android.settings.WIFI_DPP_ENROLLEE_QR_CODE_SCANNER",T.WIFI_IP_SETTINGS="android.settings.WIFI_IP_SETTINGS",T.WIFI_NETWORK_REQUEST="com.android.settings.wifi.action.NETWORK_REQUEST",T.WIFI_SAVED_NETWORK_SETTINGS="android.settings.WIFI_SAVED_NETWORK_SETTINGS",T.WIFI_SCANNING_SETTINGS="android.settings.WIFI_SCANNING_SETTINGS",T.WIFI_SETTINGS="android.settings.WIFI_SETTINGS",T.WIFI_TETHER_SETTINGS="com.android.settings.WIFI_TETHER_SETTINGS",T.WIRELESS_SETTINGS="android.settings.WIRELESS_SETTINGS",T.ZEN_MODE_AUTOMATION_SETTINGS="android.settings.ZEN_MODE_AUTOMATION_SETTINGS",T.ZEN_MODE_EVENT_RULE_SETTINGS="android.settings.ZEN_MODE_EVENT_RULE_SETTINGS",T.ZEN_MODE_PRIORITY_SETTINGS="android.settings.ZEN_MODE_PRIORITY_SETTINGS",T.ZEN_MODE_SCHEDULE_RULE_SETTINGS="android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS",T.ZEN_MODE_SETTINGS="android.settings.ZEN_MODE_SETTINGS",T})({}),N=(function(T){return T[T.Success=-1]="Success",T[T.Canceled=0]="Canceled",T[T.FirstUser=1]="FirstUser",T})({})},1440,[499,1441]); +__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 t={}},1441,[]); +__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.useOrdersDue=C,Object.defineProperty(_e,"supplierForCat",{enumerable:!0,get:function(){return S}}),_e.Suppliers=function(){const{now:e,today:o,role:S,me:O}=(0,x.useCtx)(6e4),M='owner'===S,P='staff'!==S,$=(0,c.useOwner)(e=>e.suppliers),R=(0,c.useOwner)(e=>e.supplierOrders),k=(0,c.useOwner)(e=>e.staffCanViewSuppliers),[B,D]=(0,l.useState)(''),[F,L]=(0,l.useState)('all'),[A,N]=(0,l.useState)(!1),[I,_]=(0,l.useState)(null),[E,z]=(0,l.useState)(null);(0,n.useBackLayer)(!!I,()=>_(null));const[H,U]=(0,l.useState)(null),V=C();if('staff'===S&&!k)return(0,j.jsx)(u.Banner,{kind:"info",title:"Suppliers are hidden",children:"The owner hasn\u2019t turned on supplier access for staff."});const W=$.filter(e=>e.archived===A&&('all'===F||('fav'===F?e.fav:e.category===F))&&(!B.trim()||`${e.name} ${e.category} ${e.contact} ${e.notes}`.toLowerCase().includes(B.trim().toLowerCase()))).sort((e,s)=>Number(s.fav)-Number(e.fav)||e.name.localeCompare(s.name)),Y=$.find(e=>e.id===I),q=e=>c.useOwner.getState().saveSupplier(e),G=e=>e.length?e.map(e=>x.DAY3[e]).join(', '):'\u2013';if(Y){const s=R.filter(e=>e.supplierId===Y.id);return(0,j.jsxs)(d.default,{style:{gap:10},children:[(0,j.jsx)(n.BackButton,{onPress:()=>_(null),testID:"supplier-back"}),(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{size:18,weight:"bold",style:{flex:1},children:Y.name}),(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:Y.fav?'Unfavourite':'Favourite',disabled:!P,onPress:()=>q({...Y,fav:!Y.fav}),children:(0,j.jsx)(u.T,{size:22,colour:m.colours.gold,children:Y.fav?'\u2605':'\u2606'})})]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Badge,{kind:"gold",label:Y.category}),Y.archived?(0,j.jsx)(u.Badge,{kind:"neutral",label:"Archived"}):null]}),(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"Saved on this device only (not connected to your venue)."}),[['Contact',Y.contact],['Account no.',Y.account],['Order cut-off',Y.cutoff?`${Y.cutoff} on ${G(Y.orderDays)}`:'Call when needed'],['Delivery days',G(Y.deliveryDays)],['Minimum order',Y.minOrder?(0,h.gbp)(Y.minOrder):'None'],['Payment terms',Y.terms||'\u2013']].map(([e,s])=>(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.Muted,{children:e}),(0,j.jsx)(u.T,{size:14,style:{flex:1,textAlign:'right'},children:s})]},e)),Y.notes?(0,j.jsxs)(u.T,{size:14,children:["\ud83d\udd8b\ufe0f ",Y.notes]}):null]}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[Y.phones.filter(Boolean).map(e=>(0,j.jsx)(u.Button,{small:!0,label:`\ud83d\udcde Call ${e}`,onPress:()=>v(w(e))},e)),Y.email?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\u2709\ufe0f Email",onPress:()=>v(`mailto:${Y.email}?subject=${encodeURIComponent(`Order from ${(0,b.venueInfo)().name} (acct ${Y.account})`)}`)}):null,Y.website?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"\ud83c\udf10 Ordering website",onPress:()=>v(Y.website)}):null]}),(0,j.jsx)(u.Muted,{children:"Call opens your phone\u2019s dialler and you place the call yourself. Email opens a draft in your mail app; the app sends nothing."}),P?(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Log an order",onPress:()=>U({items:'',amount:''})}),M?(0,j.jsx)(u.Button,{small:!0,kind:"secondary",label:"Edit",onPress:()=>z({...Y,phones:[...Y.phones]})}):null,M?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:Y.archived?'Restore':'Archive',onPress:()=>q({...Y,archived:!Y.archived,fav:!!Y.archived&&Y.fav})}):null]}):null,(0,j.jsx)(f.SectionHead,{title:"Order history",sub:"Manual log"}),s.map(e=>(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(u.T,{weight:"semibold",children:e.date?(0,p.niceDate)(new Date(e.date+'T12:00:00')):'Last week (example)'}),(0,j.jsx)(u.T,{children:(0,h.gbp)(e.amount)})]}),(0,j.jsxs)(u.Muted,{children:[e.items," \xb7 ",e.by,e.at?` at ${e.at}`:'']})]},e.id)),s.length?null:(0,j.jsx)(u.Muted,{children:"No orders logged yet."}),(0,j.jsxs)(u.Sheet,{visible:!!H,onClose:()=>U(null),title:`Log an order: ${Y.name}`,children:[(0,j.jsx)(u.Field,{label:"What was ordered",value:H?.items??'',onChangeText:e=>U({items:e,amount:H?.amount??''}),placeholder:"e.g. Haddock 40 portions"}),(0,j.jsx)(u.Field,{label:"Approx. value \xa3",value:H?.amount??'',onChangeText:e=>U({items:H?.items??'',amount:e}),keyboardType:"decimal-pad"}),H&&Y.minOrder&&100*Number(H.amount){c.useOwner.getState().setOwner({supplierOrders:[{id:(0,a.uuid)(),supplierId:Y.id,date:o,items:H.items.trim(),amount:Math.round(100*(Number(H.amount)||0)),by:O,at:(0,p.hm)(e)},...R]}),U(null)}}),(0,j.jsx)(u.Muted,{children:"Records an order you placed by phone, email or website. Nothing is sent."})]}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null)}}):null]})}return(0,j.jsxs)(d.default,{style:{gap:10},children:[P&&V.length&&!A?(0,j.jsxs)(u.Card,{highlight:m.colours.amber,children:[(0,j.jsx)(u.T,{weight:"semibold",children:"Orders due today"}),V.map(({s:e,left:s})=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Order due ${e.name}`,onPress:()=>_(e.id),style:{minHeight:44,justifyContent:'center'},children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between',flexWrap:'wrap'},children:[(0,j.jsx)(u.T,{size:14,children:e.name}),(0,j.jsx)(u.T,{size:13,colour:s<0?m.colours.red:s<120?m.colours.amber:m.colours.muted,children:s<0?`cut-off ${e.cutoff} passed`:`by ${e.cutoff} (${Math.floor(s/60)}h ${s%60}m left)`})]})},e.id)),(0,j.jsx)(u.Muted,{children:"Clears when you log an order for that supplier today."})]}):null,(0,j.jsx)(s.TextInput,{accessibilityLabel:"Search suppliers",placeholder:"Search suppliers",placeholderTextColor:"#7D776C",value:B,onChangeText:D,style:u.styles.input}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[(0,j.jsx)(u.Chip,{label:"All",selected:'all'===F,onPress:()=>L('all')}),(0,j.jsx)(u.Chip,{label:"\u2605 Favourites",selected:'fav'===F,onPress:()=>L('fav')}),c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:F===e,onPress:()=>L(e)},e))]}),W.map(e=>(0,j.jsx)(i.default,{accessibilityRole:"button",accessibilityLabel:`Supplier ${e.name}`,onPress:()=>_(e.id),children:(0,j.jsxs)(u.Card,{children:[(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(u.T,{weight:"semibold",style:{flex:1},children:[e.fav?'\u2605 ':'',e.name]}),(0,j.jsx)(u.Muted,{children:e.category})]}),(0,j.jsxs)(u.Muted,{children:[e.contact," \xb7 ",e.phones[0],e.cutoff?` \xb7 order by ${e.cutoff} ${G(e.orderDays)}`:'']})]})},e.id)),W.length?null:(0,j.jsx)(u.Muted,{children:"No suppliers match."}),(0,j.jsxs)(u.Row,{wrap:!0,gap:6,children:[M?(0,j.jsx)(u.Button,{small:!0,label:"Add supplier",onPress:()=>z(y())}):null,P?(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:A?'Show active':'Show archived',onPress:()=>N(!A)}):null]}),M?(0,j.jsx)(u.Card,{children:(0,j.jsxs)(u.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsxs)(d.default,{style:{flex:1},children:[(0,j.jsx)(u.T,{children:"Staff can view suppliers"}),(0,j.jsx)(u.Muted,{children:"Role permission. Staff get read-only access (call, email, website)."})]}),(0,j.jsx)(u.Toggle,{label:"Staff can view suppliers",value:k,onChange:e=>c.useOwner.getState().setOwner({staffCanViewSuppliers:e})})]})}):null,(0,t.isLiveVenue)()?null:(0,j.jsx)(u.Muted,{children:"These suppliers are saved on this device only (not connected to your venue)."}),E?(0,j.jsx)(T,{sup:E,onClose:()=>z(null),onSave:e=>{q(e),z(null),_(e.id)}}):null]})};var s=r(_d[0]),l=r(_d[1]),t=r(_d[2]),n=r(_d[3]),a=r(_d[4]),o=e(r(_d[5])),i=e(r(_d[6])),d=e(r(_d[7])),u=r(_d[8]),c=r(_d[9]),h=r(_d[10]),p=r(_d[11]),m=r(_d[12]),f=r(_d[13]),x=r(_d[14]),b=r(_d[15]),j=r(_d[16]);const y=()=>({id:(0,a.uuid)(),name:'',category:'Dry goods',contact:'',phones:[''],email:'',website:'',account:'',cutoff:'',orderDays:[],deliveryDays:[],minOrder:0,terms:'',notes:'',fav:!1,archived:!1}),w=e=>`tel:${e.replace(/[^\d+]/g,'')}`,v=e=>{o.default.openURL(e).catch(()=>{})};function C(){const{now:e,today:s}=(0,x.useCtx)(6e4),t=(0,c.useOwner)(e=>e.suppliers),n=(0,c.useOwner)(e=>e.supplierOrders);return(0,l.useMemo)(()=>{const l=(0,x.weekday)(e),a=60*e.getHours()+e.getMinutes();return t.filter(e=>!e.archived&&e.cutoff&&e.orderDays.includes(l)&&!n.some(l=>l.supplierId===e.id&&l.date===s)).map(e=>{const[s,l]=e.cutoff.split(':').map(Number);return{s:e,left:60*s+l-a}}).sort((e,s)=>e.left-s.left)},[t,n,s,Math.floor(e.getTime()/6e4)])}const S=(e,s)=>e.filter(e=>!e.archived&&e.category===s).sort((e,s)=>Number(s.fav)-Number(e.fav))[0];function T({sup:e,onClose:s,onSave:t}){const[n,a]=(0,l.useState)(e),[o,i]=(0,l.useState)(e.minOrder?(e.minOrder/100).toFixed(2):''),d=e=>s=>a({...n,[e]:s}),h=e=>(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:x.DAY3.map((s,l)=>(0,j.jsx)(u.Chip,{label:s,selected:n[e].includes(l),onPress:()=>a({...n,[e]:n[e].includes(l)?n[e].filter(e=>e!==l):[...n[e],l].sort()})},s))}),p=!n.cutoff||/^([01]\d|2[0-3]):[0-5]\d$/.test(n.cutoff);return(0,j.jsxs)(u.Sheet,{visible:!0,onClose:s,title:e.name?`Edit ${e.name}`:'Add supplier',children:[(0,j.jsx)(u.Field,{label:"Name",value:n.name,onChangeText:d('name')}),(0,j.jsx)(u.Muted,{children:"Category"}),(0,j.jsx)(u.Row,{wrap:!0,gap:4,children:c.SUPPLIER_CATS.map(e=>(0,j.jsx)(u.Chip,{label:e,selected:n.category===e,onPress:()=>a({...n,category:e})},e))}),(0,j.jsx)(u.Field,{label:"Contact name",value:n.contact,onChangeText:d('contact')}),n.phones.map((e,s)=>(0,j.jsx)(u.Field,{label:`Phone ${s+1}`,value:e,keyboardType:"phone-pad",onChangeText:e=>a({...n,phones:n.phones.map((l,t)=>t===s?e:l)})},s)),(0,j.jsx)(u.Button,{small:!0,kind:"ghost",label:"Another phone number",onPress:()=>a({...n,phones:[...n.phones,'']})}),(0,j.jsx)(u.Field,{label:"Email",value:n.email,onChangeText:d('email'),keyboardType:"email-address"}),(0,j.jsx)(u.Field,{label:"Ordering website",value:n.website,onChangeText:d('website'),placeholder:"https://"}),(0,j.jsx)(u.Field,{label:"Account number",value:n.account,onChangeText:d('account')}),(0,j.jsx)(u.Field,{label:"Order cut-off (HH:MM)",value:n.cutoff,onChangeText:d('cutoff'),placeholder:"14:00"}),p?null:(0,j.jsx)(u.Muted,{children:"Use 24-hour time, e.g. 14:00."}),(0,j.jsx)(u.Muted,{children:"Order days (cut-off applies)"}),h('orderDays'),(0,j.jsx)(u.Muted,{children:"Delivery days"}),h('deliveryDays'),(0,j.jsx)(u.Field,{label:"Minimum order \xa3",value:o,onChangeText:i,keyboardType:"decimal-pad"}),(0,j.jsx)(u.Field,{label:"Payment terms",value:n.terms,onChangeText:d('terms'),placeholder:"e.g. 30 days"}),(0,j.jsx)(u.Field,{label:"Notes",value:n.notes,onChangeText:d('notes'),multiline:!0}),(0,j.jsx)(u.Button,{label:"Save supplier",disabled:n.name.trim().length<2||!p,onPress:()=>t({...n,name:n.name.trim(),phones:n.phones.map(e=>e.trim()).filter(Boolean),minOrder:Math.round(100*(Number(o)||0)),website:n.website&&!/^https?:\/\//.test(n.website)?`https://${n.website}`:n.website})})]})}},1442,[827,34,1253,1056,870,379,402,102,794,891,867,858,821,1195,1088,1224,25]); +__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,"PAGES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"register",{enumerable:!0,get:function(){return p}}),_e.MoreMenu=function({go:e}){const{role:l}=(0,u.useCtx)(6e4);return(0,f.jsxs)(n.default,{style:{gap:14},children:[g.map(t=>{const u=b.filter(e=>e.group===t&&(!e.can||e.can(l)));return u.length?(0,f.jsxs)(n.default,{style:{gap:6},children:[(0,f.jsx)(s.T,{size:12,weight:"semibold",colour:i.colours.gold,children:t.toUpperCase()}),(0,f.jsx)(n.default,{style:{borderRadius:14,borderWidth:1,borderColor:i.colours.border,backgroundColor:i.colours.surface,overflow:'hidden'},children:u.map((t,l)=>(0,f.jsx)(o.default,{testID:`more-page-${t.id}`,accessibilityRole:"button",accessibilityLabel:t.title,onPress:()=>e('more',t.id),style:({pressed:e})=>({padding:12,borderTopWidth:l?1:0,borderColor:i.colours.border,backgroundColor:e?'#1d1a14':'transparent'}),children:(0,f.jsxs)(s.Row,{style:{justifyContent:'space-between'},children:[(0,f.jsxs)(n.default,{style:{flex:1},children:[(0,f.jsx)(s.T,{weight:"medium",children:t.title}),(0,f.jsx)(s.Muted,{children:t.sub})]}),t.badge?(0,f.jsx)(s.Badge,{kind:"gold",label:t.badge}):null,(0,f.jsx)(s.T,{colour:i.colours.muted,children:"\u203a"})]})},t.id))})]},t):null}),(0,f.jsxs)(s.Muted,{center:!0,children:['staff'===l?'Staff app preview':'Managers app'," \xb7 ",t.APP_VERSION," \xb7 ",'live'===c.useSync.getState().mode?'shared with your team':'saved on this device until it connects']})]})},Object.defineProperty(_e,"pageFor",{enumerable:!0,get:function(){return h}}),Object.defineProperty(_e,"CAN",{enumerable:!0,get:function(){return l.CAN}});var t=r(d[0]);r(d[1]);var o=e(r(d[2])),n=e(r(d[3])),s=r(d[4]),l=r(d[5]),i=r(d[6]),u=r(d[7]),c=r(d[8]),f=r(d[9]);const b=[],p=e=>{e.forEach(e=>{b.some(t=>t.id===e.id)||b.push(e)})},g=['Start here','Settings','Run the day','Team','Manage app','Grow','Compliance','Account'];const h=e=>b.find(t=>t.id===e)},1443,[1016,34,402,102,794,891,821,1088,987,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.deviceKind=o,e.deviceSyncLine=function(r,c){const l=Date.parse(r.seen_at),u=r.last_synced_at?Date.parse(r.last_synced_at):0,$=c-l>18e4,h=!u||l-u>6e4,p=!$&&!h,_=`${t[r.app]??r.app}${r.who?` \xb7 ${r.who}`:''} \xb7 ${o(r.user_agent)}`,f=$?`Not reporting since ${n(r.seen_at)} (${s(c-l)})${u?`, last synced ${n(r.last_synced_at)}`:''}`:h?`Out of sync${u?` since ${n(r.last_synced_at)}`:''}, reconnecting`:`In sync \xb7 last synced ${n(r.last_synced_at)} (${s(c-u)})`,y=[r.version??'','SUBSCRIBED'===r.realtime?'live channel on':`live channel ${String(r.realtime??'off').toLowerCase()}`];r.pending&&y.push(`${r.pending} change${1===r.pending?'':'s'} waiting`);r.failed&&y.push(`${r.failed} not saved`);return{ok:p,title:_,state:f,detail:y.filter(Boolean).join(' \xb7 ')}};const t={owner:'Managers',staff:'Staff',chef:'Chef',display:'Display',car:'Car'},n=t=>new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit',timeZone:'Europe/London'}),s=t=>t<9e4?`${Math.max(0,Math.round(t/1e3))} s ago`:t<54e5?`${Math.round(t/6e4)} min ago`:`${Math.round(t/36e5)} h ago`;function o(t){const n=t??'';return/CoverChargeTablet|TB\d|Tablet/i.test(n)?'tablet':/iPhone/i.test(n)?'iPhone':/iPad/i.test(n)?'iPad':/Android/i.test(n)?'Android':/Tesla/i.test(n)?'car':/Mac OS X|Windows|Linux/i.test(n)?'computer':'device'}},1444,[]); +__d(function(g,_r,i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ManagerFeaturesNote=function(){return(0,j.jsxs)(a.default,{testID:"manager-features-banner",style:{borderWidth:1,borderColor:b.colours.gold,borderRadius:12,padding:10,gap:4},children:[(0,j.jsx)(d.T,{weight:"semibold",colour:b.colours.gold,children:"Manager features are on"}),(0,j.jsx)(d.Muted,{children:"Open Me \u203a Manager features for bookings, tables, blocks, allergy checks, stock, who\u2019s clocked in and shift swaps."})]})},_e.ManagerFeaturesAbout=function(){return(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"semibold",children:"What manager features include"}),c.SHIFT_MANAGER_FEATURES.map(e=>(0,j.jsxs)(d.T,{size:14,children:["\u2022 ",e]},e)),(0,j.jsxs)(d.Muted,{children:["Not included: ",c.SHIFT_MANAGER_EXCLUDED_WORDS,". Those stay in the Managers app."]})]})},_e.ClockOverview=function({today:e,now:t}){const s=(0,o.useOwner)(e=>e.staff),n=(0,o.useOwner)(e=>e.attendance).filter(t=>t.date===e&&t.in),r=e=>x(s.find(t=>t.id===e)?.name)||'Team member',h=n.filter(e=>!e.out).sort((e,t)=>(e.in??'').localeCompare(t.in??'')),c=n.filter(e=>e.out).sort((e,t)=>(e.out??'').localeCompare(t.out??'')),u=e=>(e.breaks??[]).some(e=>!e.end);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"clock-overview",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Clocked in now (",h.length,")"]}),h.length?h.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:["In at ",(0,l.hm)(new Date(e.in)),u(e)?' \xb7 on a break':'',!1===e.inSite?' \xb7 clocked in away from the venue':'']})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody is clocked in right now."}),(0,j.jsxs)(d.T,{weight:"semibold",children:["Finished today (",c.length,")"]}),c.length?c.map(e=>(0,j.jsxs)(d.Card,{children:[(0,j.jsx)(d.T,{weight:"medium",children:r(e.staffId)}),(0,j.jsxs)(d.Muted,{children:[(0,l.hm)(new Date(e.in))," to ",(0,l.hm)(new Date(e.out))]})]},e.id)):(0,j.jsx)(d.Muted,{children:"Nobody has clocked out yet today."}),(0,j.jsxs)(d.Muted,{children:["Read only. To change someone\u2019s clock record, ask a manager in the Managers app. Checked at ",(0,l.hm)(t),"."]})]})},_e.TablesToClear=function({rid:e}){const s=(0,r.useFloor)(t=>t.live[e])??{},n=Object.entries(s).filter(([,e])=>e?.dirty).map(([e])=>e).sort((e,t)=>e.localeCompare(t,'en',{numeric:!0}));return(0,j.jsx)(a.default,{style:{gap:8},testID:"tables-to-clear",children:n.length?n.map(s=>(0,j.jsx)(d.Card,{children:(0,j.jsxs)(d.Row,{style:{justifyContent:'space-between'},children:[(0,j.jsx)(d.T,{weight:"semibold",children:(0,t.tableNumbers)(s)}),(0,j.jsx)(d.Button,{small:!0,kind:"success",label:"Mark cleared",accessibilityLabel:`Mark table ${s} cleared, table free`,testID:`clear-${s}`,onPress:()=>{r.useFloor.getState().setLive(e,s,{dirty:!1,stage:void 0}),(0,w.notify)({id:`clear-${s}`,title:`${(0,t.tableNumbers)(s)} is free`,timeoutMs:4e3})}})]})},s)):(0,j.jsx)(d.Muted,{children:"No tables need clearing."})})},_e.SwapApprovals=function({today:e,me:t}){const n=(0,o.useOwner)(e=>e.staff),r=(0,o.useOwner)(e=>e.shifts),y=(0,o.useOwner)(e=>e.swaps),[M,k]=(0,s.useState)(null),[I,v]=(0,s.useState)(null),[T,S]=(0,s.useState)(!1),C=e=>x(n.find(t=>t.id===e)?.name)||'Team member',D=(()=>{const t=(0,l.parseYmd)(e);return t.setDate(t.getDate()+13),t})(),N=r.filter(t=>{return!1!==t.published&&t.date>=e&&(0,l.parseYmd)(t.date)<=D&&(s=t.staffId,!('owner'===n.find(e=>e.id===s)?.role));var s}).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),O=e=>`${(0,l.niceDate)((0,l.parseYmd)(e.date))}, ${(0,h.fmtH)(e.start)} to ${(0,h.fmtH)(e.end)}`,R=async(e,s,n,a)=>{S(!0);const d=await(0,u.approveShiftSwap)(e.id,s,n);S(!1),d.ok?(o.useOwner.setState(t=>({shifts:t.shifts.map(t=>t.id===e.id?{...t,staffId:s}:t)})),a&&o.useOwner.getState().setSwap(a,'approved'),(0,w.notify)({id:'swap-ok',title:'Shift changed',body:`${C(e.staffId)}\u2019s shift on ${O(e)} is now ${C(s)}\u2019s. Approved by ${x(t)}.`,timeoutMs:6e3}),k(null),v(null)):(0,w.notify)({id:'swap-fail',title:'Not changed',body:d.message,timeoutMs:6e3})},$=y.filter(e=>'open'===e.status);return(0,j.jsxs)(a.default,{style:{gap:10},testID:"swap-approvals",children:[(0,j.jsxs)(d.T,{weight:"semibold",children:["Requests (",$.length,")"]}),$.length?$.map(e=>{const t=r.find(t=>t.id===e.shiftId);return(0,j.jsxs)(d.Card,{children:[(0,j.jsxs)(d.T,{weight:"medium",children:[C(e.fromId)," \xb7 ",'cover'===e.kind?'needs cover':'swap']}),(0,j.jsxs)(d.Muted,{children:[t?O(t):'Shift not found',e.toId?` \xb7 to ${C(e.toId)}`:'',e.note?` \xb7 ${e.note}`:'']}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{small:!0,label:"Approve",disabled:!t||!e.toId||T||!(0,p.canSwapWith)(n.find(t=>t.id===e.fromId),n.find(t=>t.id===e.toId),f.VENUE_RID),onPress:()=>t&&e.toId&&R(t,e.toId,e.kind,e.id)}),(0,j.jsx)(d.Button,{small:!0,kind:"ghost",label:"Decline",onPress:()=>o.useOwner.getState().setSwap(e.id,'declined')})]})]},e.id)}):(0,j.jsx)(d.Muted,{children:"No open requests on this phone. Swap requests made on other phones aren\u2019t shared yet, so if someone asks you in person, use Give a shift to someone else below."}),(0,j.jsx)(d.T,{weight:"semibold",children:"Give a shift to someone else"}),M?(0,j.jsxs)(d.Card,{highlight:b.colours.gold,children:[(0,j.jsxs)(d.T,{weight:"semibold",children:[C(M.staffId)," \xb7 ",O(M)]}),(0,j.jsx)(d.Muted,{children:"Who takes it? Only someone they are allowed to swap with."}),(0,j.jsx)(d.Row,{wrap:!0,gap:6,children:(0,c.swapTargets)(n,M.staffId,f.VENUE_RID).map(e=>(0,j.jsx)(d.Chip,{label:x(e.name),selected:I===e.id,onPress:()=>v(e.id)},e.id))}),(0,j.jsxs)(d.Row,{gap:6,children:[(0,j.jsx)(d.Button,{label:"Approve",disabled:!I||T,onPress:()=>I&&R(M,I,'swap'),testID:"swap-give"}),(0,j.jsx)(d.Button,{kind:"secondary",label:"Cancel",onPress:()=>{k(null),v(null)}})]})]}):N.length?N.map(e=>(0,j.jsxs)(d.Card,{onPress:()=>{k(e),v(null)},children:[(0,j.jsx)(d.T,{weight:"medium",children:C(e.staffId)}),(0,j.jsx)(d.Muted,{children:O(e)})]},e.id)):(0,j.jsx)(d.Muted,{children:"No published shifts in the next two weeks."}),(0,j.jsx)(d.Banner,{kind:"info",children:"Approving moves the shift on the rota for everyone and records who approved it. Writing or publishing the rota stays in the Managers app."})]})};var e,t=_r(_d[0]),s=_r(_d[1]),n=_r(_d[2]),a=(e=n)&&e.__esModule?e:{default:e},d=_r(_d[3]),o=_r(_d[4]),r=_r(_d[5]),l=_r(_d[6]),h=_r(_d[7]),c=_r(_d[8]),u=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),w=_r(_d[12]),b=_r(_d[13]),j=_r(_d[14]);const x=e=>(e??'').replace(' (example)','')},1445,[860,34,102,794,891,1029,858,1091,1089,987,1090,5,1001,821,25]); +__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,"APP_USED_TEXT",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"APP_NOT_SET_UP_TEXT",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"allowedHere",{enumerable:!0,get:function(){return C}}),Object.defineProperty(_e,"movedMessage",{enumerable:!0,get:function(){return R}}),_e.personFromStaff=N,_e.signInWithText=z,_e.SignInWithLink=V,_e.signInWithHandover=M,_e.useSignedOutGate=function(){const e=(0,m.useSession)(e=>e.meId),n=(0,T.useSync)(e=>'device'===e.kind&&!!e.venueId);return h.IS_CAR?!y.PITCH&&!n:_.includes(h.APP_VARIANT)&&!y.PITCH&&!e&&!W()},_e.InviteGate=function(){const[e,E]=(0,u.useState)(m.useSession.persist.hasHydrated()),[N,z]=(0,u.useState)(m.START_INVITE||m.START_HANDOVER?'checking':'done'),[K,L]=(0,u.useState)(null),[U,G]=(0,u.useState)(0),[Y,$]=(0,u.useState)(!1),[B,X]=(0,u.useState)(null),Q=(0,m.useSession)(e=>e.meId),q=(0,m.useSession)(e=>!Q||!!e.welcomed[Q]);if((0,u.useEffect)(()=>{const e=m.useSession.persist.onFinishHydration(()=>E(!0));return m.useSession.persist.hasHydrated()&&E(!0),e},[]),(0,u.useEffect)(()=>{if(!e||!_.includes(h.APP_VARIANT))return;let n,t=!0;return(async()=>{const e=m.useSession.getState().meId;if(m.START_HANDOVER&&!m.START_INVITE&&!F){F=!0;const n=await(0,T.claimChromeHandover)(m.START_HANDOVER);if(!t)return;if('ok'===n.status&&n.id.staffRef)D(n.id);else if('refused'===n.status&&!e)return L(n.message),void z('done')}if(m.START_INVITE&&!(e&&await(0,T.signedInHereAs)(e)&&await(0,T.rememberedInviteHere)(m.START_INVITE))){const e=await O(m.START_INVITE,e=>{t&&L(e)});if(!t)return;if('refused'===e.kind)return L(e.message),void z('done');if('offline'===e.kind)return $(!0),void(n=setTimeout(()=>{t&&G(e=>e+1)},1e4));if($(!1),'bad'===e.kind)return void z('bad')}const o=H(m.useSession.getState().meId),s=o&&!1!==w.useOwner.getState().staff.find(e=>e.id===o.id)?.active;if(o&&!s)m.useSession.getState().signOut();else if(o&&!C(o)&&!m.START_INVITE&&await(0,T.signedInHereAs)(o.id)){if(await(0,T.forgetSignInHere)(),!t)return;m.useSession.getState().signOut(),X(R(o.app))}else if(o&&!C(o)){const e=(0,m.appUrl)(o.app,m.START_INVITE);if(e)return void window.location.replace(e)}z('done')})(),()=>{t=!1,n&&clearTimeout(n)}},[e,U]),!_.includes(h.APP_VARIANT))return null;if(n.IS_QUEUED_VENUE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t.QueuedVenueWelcome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_GREENSIDE&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(s.GreensideStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Greenside app\u2026'})});if(n.IS_ABBOTSFORD&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(r.AbbotsfordStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?'This link cannot be used here. Ask your authorised manager.':Y?'Waiting for a connection.':void 0})});if(n.IS_KIRKTON&&!Q)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(l.KirktonStaffHome,{app:m.APP_NAME[h.APP_VARIANT]??'Team',message:K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Ask the authorised manager for access after setup.':void 0:'Opening your Kirkton app\u2026'})});if(o.IsolatedStaffHome&&(n.IS_WILDINGS||n.IS_KIRKMICHAEL||n.IS_SOUTERS)&&!Q){const t=o.IsolatedStaffHome,s=m.APP_NAME[h.APP_VARIANT]??'Team',r=n.IS_WILDINGS?'Wildings':n.IS_KIRKMICHAEL?'Kirkmichael':'Souter\u2019s',l=K?`This link can\u2019t be used here. ${K}`:Y?'Waiting for a connection. Your personal app signs you in automatically when it returns.':e&&'checking'!==N?'bad'===N?'This link is not recognised. Open the complete private link your manager gave you.':void 0:`Opening your personal ${r} app\u2026`;return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(t,{app:s,message:l})})}if(Y)return j('Waiting for a connection. Your app will sign you in automatically.','invite-waiting');if(!e||'checking'===N)return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}]});if(h.IS_OWNER_DESKTOP&&!Q&&!y.PITCH&&!W())return(0,x.jsx)(c.default,{style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3}],children:(0,x.jsx)(p.DesktopSignIn,{onCode:M,refused:K})});if((0,S.inPhoneApp)()&&!Q&&!y.PITCH)return K&&/already been used/i.test(K)?j(P,'invite-app-used'):K&&(0,A.isPhoneLinked)(K)?j(A.PHONE_LINKED_TEXT,'invite-phone-linked'):K?j(K,'invite-app-refused'):j(v,'invite-app-notsetup');if('bad'===N)return(0,x.jsxs)(c.default,{testID:"invite-bad",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link isn\u2019t recognised"}),(0,x.jsx)(b.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 CoverCharge link."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>z('done')}),(0,x.jsx)(b.Muted,{center:!0,children:"Offline, CoverCharge uses made-up data, and nothing you do there is shared with the team."})]});if(K&&!Q&&(0,A.isPhoneLinked)(K))return(0,x.jsxs)(c.default,{testID:"invite-phone-linked",accessible:!0,accessibilityLabel:`This link is linked to another phone. ${A.PHONE_LINKED_TEXT}`,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:14,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:24,weight:"bold",center:!0,colour:k.colours.gold,accessibilityRole:"header",children:"This link is linked to another phone"}),(0,x.jsx)(b.T,{size:18,center:!0,style:{maxWidth:420},children:"Ask a manager to reset it or send you a new link."}),(0,x.jsx)(b.Muted,{center:!0,style:{maxWidth:420},children:"Each personal link works on the first phone that opens it. Once your manager has reset it, open the same link again here."})]});if(K&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-refused",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This link can\u2019t be used here"}),(0,x.jsx)(b.Muted,{center:!0,children:K}),(0,x.jsx)(b.Muted,{center:!0,children:"Your personal link works for good on the first phone you open it on."}),(0,x.jsx)(b.Button,{label:"Try CoverCharge offline instead",kind:"secondary",onPress:()=>L(null)})]});if(B&&!Q)return(0,x.jsxs)(c.default,{testID:"invite-moved",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:"This app is signed out"}),(0,x.jsx)(b.Muted,{center:!0,children:B}),(0,x.jsx)(V,{})]});if(!Q&&!y.PITCH&&!W())return(0,x.jsxs)(c.default,{testID:"invite-signin",style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12}],children:[(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:K?'This link can\u2019t be used here':'Sign in to CoverCharge'}),K?(0,x.jsx)(b.Muted,{center:!0,children:K}):null,(0,x.jsx)(b.Muted,{center:!0,children:"Open the personal link your manager shared with you. It works for good on the first phone you open it on."}),(0,x.jsx)(V,{})]});const J=(0,m.rosterPerson)(Q);return J&&!q&&C(J)?(0,x.jsx)(I.LaunchWelcome,{p:J,onDone:()=>m.useSession.getState().markWelcomed(J.id)}):null};var n=_r(d[0]),t=_r(d[1]),o=_r(d[2]),s=_r(d[3]),r=_r(d[4]),l=_r(d[5]),u=_r(d[6]);_r(d[7]);var f=e(_r(d[8])),c=e(_r(d[9])),h=_r(d[10]),p=_r(d[11]),m=_r(d[12]),k=_r(d[13]),I=_r(d[14]),b=_r(d[15]),T=_r(d[16]),y=_r(d[17]),S=_r(d[18]),A=_r(d[19]),w=_r(d[20]),x=_r(d[21]);const P='This app copy has already been set up on another phone. Ask your manager for a new link.',v='This app copy isn\u2019t set up for anyone yet. Ask your manager for your link, and download the app from it.',j=(e,n)=>(0,x.jsx)(c.default,{testID:n,style:[f.default.absoluteFill,{backgroundColor:k.colours.bg,zIndex:1e3,padding:24,justifyContent:'center',gap:12,alignItems:'center'}],children:(0,x.jsx)(b.T,{size:22,weight:"bold",center:!0,children:e})}),_=['owner','staff','chef'],C=e=>'staff'===h.APP_VARIANT||e.app===h.APP_VARIANT,R=e=>`You now use ${m.APP_NAME[e]??'another CoverCharge app'}. This app is signed out on this phone. Open the new personal link your manager sent you.`;function E(e){m.useSession.getState().signIn(e.id);const n=w.useOwner.getState();w.useOwner.setState({staffAs:e.id,previewRole:'staff'===e.role?n.previewRole:e.role})}function N(e){const n='owner'===e.role?'Owner':'manager'===e.role?'Manager':'Head Chef'===e.level?'Head Chef':'Staff';return{id:e.id,name:e.name,level:n,role:e.role,job:e.job,nickname:e.nickname,dept:e.dept??'',app:'staff'===e.role?'Head Chef'===n?'chef':'staff':'owner',tokenHash:'',hourlyPence:null,salaried:!!e.salaried,noTax:!!e.noTax,avatar:void 0}}const H=e=>{const n=(0,m.rosterPerson)(e);if(n)return n;const t=e?w.useOwner.getState().staff.find(n=>n.id===e):void 0;return t?N(t):void 0};async function O(e,n){const t=await(0,m.personForInvite)(e);if(t)return E(t),C(t)?((0,T.claimInvite)(e).then(e=>{if('refused'===e.status&&m.useSession.getState().meId===t.id&&(m.useSession.getState().signOut(),n(e.message)),'ok'===e.status&&e.id.staffRef&&e.id.staffRef!==m.useSession.getState().meId){const n=H(e.id.staffRef);n&&E(n)}}),{kind:'ok',p:t}):{kind:'ok',p:t};const o=await(0,T.claimInvite)(e);if('refused'===o.status)return{kind:'refused',message:o.message};if('offline'===o.status)return{kind:'offline'};if('ok'!==o.status||!o.id.staffRef)return{kind:'bad'};const s=H(o.id.staffRef)??N({id:o.id.staffRef,name:o.id.displayName||o.id.staffRef,role:'owner'===o.id.role?'owner':'manager'===o.id.role?'manager':'staff',level:'head_chef'===o.id.role?'Head Chef':void 0,job:'',active:!0});return E(s),{kind:'ok',p:s}}async function z(e,n=()=>{}){const t=(0,m.inviteFromText)(e);if(!t)return'bad';const o=await O(t,n);if('refused'===o.kind)return{refused:o.message};if('bad'===o.kind||'offline'===o.kind)return'bad';const s=o.p;if(!C(s)){const e=(0,m.appUrl)(s.app,t);if(e)return window.location.replace(e),'moved'}return'ok'}function V(){const[e,n]=(0,u.useState)(''),[t,o]=(0,u.useState)('');return(0,x.jsxs)(c.default,{style:{gap:6},children:[(0,x.jsx)(b.Field,{label:"Your personal link (paste it here)",value:e,onChangeText:n,placeholder:"Your complete Android or iPhone link",autoCapitalize:"none",autoCorrect:!1}),(0,x.jsx)(b.Button,{label:"Sign in",disabled:!e.trim(),onPress:async()=>{const t=await z(e,o);o('bad'===t?'That link was not recognised. Check you copied all of it, or ask your manager for a new one.':'object'==typeof t?t.refused:''),'ok'===t&&n('')}}),t?(0,x.jsx)(b.T,{size:13,colour:k.colours.red,children:t}):null]})}function D(e){if(!e.staffRef)return;E(H(e.staffRef)??N({id:e.staffRef,name:e.displayName||e.staffRef,role:'owner'===e.role?'owner':'manager'===e.role?'manager':'staff',level:'head_chef'===e.role?'Head Chef':void 0,job:'',active:!0}))}async function M(e){const n=await(0,T.claimChromeHandover)(e);return'ok'===n.status?n.id.staffRef?(D(n.id),'ok'):'bad':'refused'===n.status?{refused:n.message}:'offline'===n.status?'offline':'bad'}let F=!1;const W=()=>'undefined'!=typeof window&&('localhost'===window.location.hostname||'127.0.0.1'===window.location.hostname)&&['tips','home'].includes(new URLSearchParams(window.location.search).get('demo')||'')},1446,[5,1447,1448,1449,1450,1451,34,236,41,102,872,1452,1004,821,1454,794,987,2,1097,1003,891,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.QueuedVenueWelcome=function({app:e,message:n}){const h=c.queuedVenues[u.VENUE_RID];return(0,l.jsxs)(t.default,{testID:"queued-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:u.VENUE_RID,size:220}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,children:e}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:n||'No manager or staff access has been set up. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"Table requests need a venue manager to confirm. Deposits, payments, ordering and loyalty are off."}),(0,l.jsxs)(o.Muted,{center:!0,children:["To confirm: ",h.gatesToConfirm.join(', '),"."]})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),u=r(d[4]),c=r(d[5]),l=r(d[6])},1447,[34,102,873,794,5,6,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IsolatedStaffHome",{enumerable:!0,get:function(){return t}});const t=null},1448,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.GreensideStaffHome=function({app:e,message:n}){return(0,o.jsxs)(t.default,{testID:"greenside-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,o.jsx)(s.RestaurantHero,{rid:"greenside",size:240}),(0,o.jsx)(l.T,{size:24,weight:"bold",center:!0,children:e}),(0,o.jsxs)(l.Card,{children:[(0,o.jsx)(l.T,{weight:"bold",children:"Manager setup needed"}),(0,o.jsx)(l.Muted,{children:n||'No manager or staff access has been set up yet. The authorised manager must be added before the team can sign in. No personal links have been created.'})]}),(0,o.jsx)(l.Muted,{center:!0,children:"Cash only. Table requests need a Greenside manager to confirm. Deposits and payments are off."}),(0,o.jsx)(l.Muted,{center:!0,children:"Still needed: authorised manager, staff list, table plan and Covers, menu and allergen sign-off, deposit policy and public email confirmation."})]})},r(d[0]);var e,n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),o=r(d[4])},1449,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.AbbotsfordStaffHome=function({app:e,message:t}){return(0,l.jsxs)(n.default,{testID:"abbotsford-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,l.jsx)(s.RestaurantHero,{rid:"abbotsford",size:240}),(0,l.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,l.jsxs)(o.Card,{children:[(0,l.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,l.jsx)(o.Muted,{children:t||'An authorised manager must be added first. No staff or personal links have been created.'})]}),(0,l.jsx)(o.Muted,{center:!0,children:"To confirm: first manager, staff, Covers and table plan, deposit, Copper Bar hours, dog policy and allergens. Dining and room requests need a manager decision. No payment is taken."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),l=r(d[4])},1450,[34,102,873,794,25]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.KirktonStaffHome=function({app:e,message:t}){return(0,c.jsxs)(n.default,{testID:"kirkton-setup-home",style:{flex:1,padding:24,justifyContent:'center',gap:16,maxWidth:680,width:'100%',alignSelf:'center'},children:[(0,c.jsx)(s.RestaurantHero,{rid:"kirkton",size:240}),(0,c.jsx)(o.T,{size:24,weight:"bold",center:!0,style:{width:'100%',flexShrink:1},children:e.replace('CoverCharge for ','')}),(0,c.jsxs)(o.Card,{children:[(0,c.jsx)(o.T,{weight:"bold",children:"Manager setup needed"}),(0,c.jsx)(o.Muted,{children:t||'No manager or staff access has been set up. An authorised manager must be added first. No personal links have been created.'})]}),(0,c.jsx)(o.Muted,{center:!0,children:"To confirm: phone, current opening and kitchen hours, table plan, capacity, takeaway, deposits and current menus. Archived 2019 menus are provisional, not current stock."})]})},r(d[0]);var e,t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[2]),o=r(d[3]),c=r(d[4])},1451,[34,102,873,794,25]); +__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.DesktopSignIn=function({onCode:e,refused:h}){const[p,f]=(0,n.useState)(''),[k,x]=(0,n.useState)(h?(0,c.desktopRefusal)(h):''),[j,y]=(0,n.useState)(!1),b=async()=>{const n=(0,c.handoverCodeFrom)(p);if(!n)return void x('That doesn\u2019t look like a sign-in link or code. Copy the whole link from your phone, or type the code.');y(!0),x('Signing in\u2026');const o=await e(n);y(!1),x('ok'===o?'':'offline'===o?'No connection. Check this computer is online and try again.':'bad'===o?'That code wasn\u2019t recognised. Make a new one on your phone.':(0,c.desktopRefusal)(o.refused)),'ok'===o&&f('')};return(0,u.jsx)(o.default,{testID:"desk-signin",style:{flex:1,backgroundColor:l.colours.bg},contentContainerStyle:{flexGrow:1,alignItems:'center',justifyContent:'center',padding:32},children:(0,u.jsxs)(t.default,{role:"main",style:{width:'100%',maxWidth:560,gap:16,alignItems:'center'},children:[(0,u.jsx)(s.RestaurantLogo,{size:96}),(0,u.jsx)(t.default,{role:"heading",'aria-level':1,children:(0,u.jsx)(r.T,{size:28,weight:"bold",center:!0,children:"CoverCharge for desktop"})}),(0,u.jsx)(r.Muted,{center:!0,children:"For owners, on a Mac or PC. The same account, bookings and permissions as your phone."}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8,padding:18,borderRadius:14,borderWidth:1,borderColor:l.colours.border,backgroundColor:l.colours.surface},children:[(0,u.jsx)(r.T,{weight:"semibold",center:!0,children:"To sign in on this computer"}),(0,u.jsx)(r.T,{size:14,center:!0,children:"1. On your phone, open CoverCharge Managers."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"2. Tap More, then Use on a computer, then Make a sign-in link."}),(0,u.jsx)(r.T,{size:14,center:!0,children:"3. Send the link to yourself (or read out the code), then open it here or paste it below."}),(0,u.jsx)(r.Muted,{center:!0,children:"The link works once, for 10 minutes. Your phone stays signed in."})]}),(0,u.jsxs)(t.default,{style:{alignSelf:'stretch',gap:8},children:[(0,u.jsx)(r.Field,{label:"Sign-in link or code",value:p,onChangeText:f,placeholder:"Paste the link, or type the code",autoCapitalize:"none",autoCorrect:!1,testID:"desk-signin-code",onSubmitEditing:b}),(0,u.jsx)(r.Button,{label:j?'Signing in\u2026':'Sign in',disabled:j||!p.trim(),onPress:b,testID:"desk-signin-go"}),(0,u.jsx)(t.default,{accessibilityLiveRegion:"polite",'aria-live':'polite',children:k?(0,u.jsx)(r.T,{size:14,colour:'Signing in\u2026'===k?l.colours.muted:l.colours.red,center:!0,children:k}):null})]})]})})};var n=_r(d[0]),o=e(_r(d[1])),t=e(_r(d[2])),r=_r(d[3]),s=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7])},1452,[34,295,102,794,873,821,1453,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DESKTOP_EXPIRED",{enumerable:!0,get:function(){return n}}),e.handoverCodeFrom=function(n){const t=(n||'').trim();if(!t)return null;const o=t.match(/[#&]ccchrome=([A-Za-z0-9_-]{24,64})(?:&|\s|$)/);if(o)return o[1];if(/[/#?=]/.test(t))return null;const c=t.replace(/\s+/g,'');return/^[A-Za-z0-9_-]{24,64}$/.test(c)?c:null},e.desktopLinkFor=function(n,t){try{const o=new URL(n),c=o.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer|car)-app\/|^(.*?\/)owner-desktop\//),s=c?c[1]??c[2]:o.pathname.replace(/[^/]*$/,'');return`${o.origin}${s}owner-desktop/index.html#ccchrome=${t}`}catch{return null}},Object.defineProperty(e,"codeGroups",{enumerable:!0,get:function(){return t}}),e.desktopRefusal=function(t){return/no longer active/i.test(t)?'This person is no longer active in CoverCharge. Ask the other owner.':/expired|Chrome link|already been used/i.test(t)?n:t};const n='That sign-in link has run out or has already been used. On your phone, open More, then Use on a computer, and make a new one.';const t=n=>(n.match(/.{1,4}/g)??[]).join(' ')},1453,[]); +__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.LaunchWelcome=function({p:e,onDone:t}){(0,r.useEffect)(()=>{if(!O||document.getElementById('cc-launch-css'))return;const e=document.createElement('style');e.id='cc-launch-css',e.textContent=I,document.head.appendChild(e)},[]),(0,r.useEffect)(()=>{if(O)return document.documentElement.classList.add('cc-welcome'),()=>document.documentElement.classList.remove('cc-welcome')},[]);const[o,k]=(0,r.useState)(P()?0:3),[E,_]=(0,r.useState)('main'),[Y,F]=(0,r.useState)(''),[H,M]=(0,r.useState)(0);(0,r.useEffect)(()=>{if(o<=0)return;const e=setTimeout(()=>k(e=>e-1),300);return()=>clearTimeout(e)},[o]);const B=(0,f.useAvatars)(t=>!!t.photos[e.id]),K=(0,b.useStore)(e=>e.restaurants[0]?.name??'Your venue').toUpperCase(),V=(0,x.useOwner)(t=>t.hourly[e.id]),G=(0,x.useOwner)(t=>t.staff.find(t=>t.id===e.id)),$=(0,y.useSync)(e=>e.mode),q='live'===$||'offline'===$,J=G?.salaried||e.salaried?'Salaried':null!=V?`\xa3${(V/100).toFixed(2)} an hour${G?.noTax?' \xb7 no-tax code':''}`:'connecting'===$?'Loading\u2026':'Ask your manager',Q='staff'!==e.app&&'staff'!==p.APP_VARIANT?(0,v.appUrl)('staff'):null,X=`AN-${String(j.ROSTER.findIndex(t=>t.id===e.id)+1).padStart(2,'0')}`,Z=p.IS_OWNER_DESKTOP?'CoverCharge for desktop':v.APP_NAME['staff'===p.APP_VARIANT?'staff':e.app],ee=L['staff'===p.APP_VARIANT&&'staff'!==e.app?'Staff':e.level]??L.Staff;return(0,C.jsxs)(h.default,{testID:"invite-welcome",style:[u.default.absoluteFill,{backgroundColor:(0,n.soutersSurface)('#000'),zIndex:1e3}],children:[(0,C.jsxs)(h.default,{...R('space'),pointerEvents:"none",children:[(0,C.jsx)(h.default,{...R('stars1')}),(0,C.jsx)(h.default,{...R('stars2')})]}),o>0?(0,C.jsxs)(l.default,{testID:"invite-countdown",accessibilityLabel:"Skip intro",onPress:()=>k(0),style:{flex:1,alignItems:'center',justifyContent:'center',gap:10},children:[(0,C.jsxs)(D,{colour:w.colours.muted,children:[K," \xb7 COVER CHARGE"]}),(0,C.jsx)(h.default,{...R('count'),children:(0,C.jsx)(T.T,{size:120,weight:"bold",colour:A,children:o})},o),(0,C.jsx)(D,{children:"GETTING YOU ON BOARD"})]}):'selfie'===E?(0,C.jsx)(W,{p:e,onClose:e=>{_('main'),e?(F('Avatar saved. Looking good!'),M(e=>e+1)):F('')}}):(0,C.jsxs)(c.default,{contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsxs)(h.default,{...R('rise1'),style:{alignItems:'center',gap:2},children:[(0,C.jsxs)(D,{children:[K," \xb7 ",Z.toUpperCase()]}),(0,C.jsx)(T.T,{size:20,colour:w.colours.muted,center:!0,style:{marginTop:10},children:"Welcome aboard,"}),(0,C.jsx)(T.T,{size:42,weight:"bold",center:!0,style:{lineHeight:50},children:e.name})]}),(0,C.jsxs)(h.default,{...R('reveal'),style:{marginVertical:8},children:[(0,C.jsx)(h.default,{...R('orbit'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:156})})]},H),Y?(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:w.colours.ok,center:!0,children:Y}):null,(0,C.jsx)(h.default,{...R('rise2'),style:{alignSelf:'stretch'},children:(0,C.jsxs)(h.default,{testID:"invite-crew-card",...R('card'),style:{borderRadius:20,borderWidth:1,borderColor:'rgba(207,164,95,0.55)',overflow:'hidden',padding:18,gap:12},children:[(0,C.jsx)(h.default,{...R('sheen'),pointerEvents:"none"}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',justifyContent:'space-between',alignItems:'center'},children:[(0,C.jsx)(D,{children:"CREW ID"}),(0,C.jsx)(T.T,{size:15,weight:"semibold",colour:w.colours.muted,style:{letterSpacing:1.5},children:X})]}),(0,C.jsx)(h.default,{style:{height:2,backgroundColor:A,opacity:.7,borderRadius:1}}),(0,C.jsx)(N,{k:"NAME",v:e.name}),(0,C.jsx)(N,{k:"ROLE",v:(0,v.levelJob)(e.level,e.job)}),(0,C.jsx)(N,{k:"APP",v:Z}),'owner'!==e.role?(0,C.jsx)(h.default,{testID:"invite-pay",children:(0,C.jsx)(N,{k:"PAY",v:J})}):null,(0,C.jsx)(N,{k:"ACCESS",v:'Owner'===e.level?'Everything':'Manager'===e.level?'Manager':'Supervisor'===e.level?'Supervisor':'Head Chef'===e.level?'Kitchen lead':'Team member'}),(0,C.jsxs)(h.default,{style:{flexDirection:'row',alignItems:'center',gap:8},children:[(0,C.jsx)(h.default,{...R('blink'),style:{width:10,height:10,borderRadius:5,backgroundColor:w.colours.ok}}),(0,C.jsx)(T.T,{size:15,colour:w.colours.ok,children:p.IS_OWNER_DESKTOP?'Signed in on this computer':'Signed in on this phone'})]})]})}),(0,C.jsxs)(h.default,{...R('rise3'),style:{alignSelf:'stretch',gap:10},children:[(0,C.jsx)(D,{children:"WHAT YOU CAN DO"}),ee.map(e=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'flex-start'},children:[(0,C.jsx)(T.T,{size:16,colour:A,children:"\u25c6"}),(0,C.jsx)(T.T,{size:16,style:{flex:1},children:e})]},e))]}),O?(0,C.jsxs)(h.default,{testID:"invite-avatar-offer",...R('rise4'),style:{alignSelf:'stretch',gap:12,borderRadius:20,padding:18,borderWidth:1,borderColor:'rgba(255,255,255,0.14)',backgroundColor:'rgba(255,255,255,0.03)'},children:[(0,C.jsx)(D,{children:"YOUR AVATAR \xb7 OPTIONAL"}),(0,C.jsx)(T.T,{size:16,children:B?'You made your own avatar from a photo.':'Keep this one, choose an original icon, or make your own from a photo.'}),(0,C.jsx)(z,{kind:"ghost",label:B?'Choose another avatar':'Choose my avatar',testID:"invite-avatar-make",onPress:()=>{F(''),_('selfie')}}),(0,C.jsxs)(T.T,{size:15,colour:w.colours.muted,children:["Your photo stays on this ",p.IS_OWNER_DESKTOP?'computer':'phone',". It\u2019s turned into your avatar here; only the finished avatar is shared with your team."]})]}):null,(0,C.jsx)(h.default,{style:{alignSelf:'stretch',gap:10,marginTop:4},children:(0,C.jsx)(z,{label:B?'Get started':'Skip, keep this one and get started',testID:"invite-get-started",onPress:t})}),(0,s.inPhoneApp)()?null:(0,C.jsxs)(h.default,{style:{alignSelf:'stretch',gap:6,borderRadius:16,padding:16,borderWidth:1,borderColor:'rgba(255,255,255,0.12)'},children:[(0,C.jsx)(T.T,{size:16,weight:"semibold",colour:A,children:"Tip: add it to your Home screen"}),(0,C.jsxs)(T.T,{size:15,children:[U()," It then opens like a normal app and remembers you."]})]}),Q?(0,C.jsx)(l.default,{accessibilityRole:"link",onPress:()=>{O&&window.location.assign(Q)},children:(0,C.jsx)(T.T,{size:15,colour:A,center:!0,children:"Also open CoverCharge for Staff (your clock-in, rota and pay) \u203a"})}):null,(0,C.jsx)(T.T,{size:14,colour:w.colours.muted,center:!0,children:q?'Connected: bookings, orders and stock are shared live with the rest of the team. Your pay is only visible to you and your managers.':'Connecting\u2026 if there\u2019s no signal, what you enter is kept on this phone and shared once you\u2019re back online.'})]})]})};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),s=_r(d[3]),o=e(_r(d[4]));_r(d[5]);var l=e(_r(d[6])),c=e(_r(d[7])),u=e(_r(d[8])),h=e(_r(d[9])),p=_r(d[10]),f=_r(d[11]),x=_r(d[12]),b=_r(d[13]),y=_r(d[14]),v=_r(d[15]),j=_r(d[16]),k=_r(d[17]),w=_r(d[18]),S=_r(d[19]),T=_r(d[20]),C=_r(d[21]);const A=w.colours.gold,I="\n[data-cc=\"space\"]{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;background:radial-gradient(ellipse at 50% 115%,#2a1f0c 0%,#0a0805 38%,#000 70%)}\n[data-cc=\"stars1\"],[data-cc=\"stars2\"]{position:absolute;top:-50%;left:-50%;width:200%;height:200%;will-change:transform}\n[data-cc=\"stars1\"]{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.2px 1.2px at 183px 77px,#fff8,transparent);background-size:211px 199px;animation:cc-drift 90s linear infinite;opacity:.75}\n[data-cc=\"stars2\"]{background-image:radial-gradient(2px 2px at 40px 60px,#CFA45F,transparent),radial-gradient(1.6px 1.6px at 250px 210px,#fff,transparent),radial-gradient(1.8px 1.8px at 330px 40px,#fffc,transparent);background-size:397px 367px;animation:cc-drift2 60s linear infinite,cc-twinkle 3.2s ease-in-out infinite alternate;opacity:.8}\n@keyframes cc-drift{to{transform:translate3d(-211px,199px,0)}}\n@keyframes cc-drift2{to{transform:translate3d(-397px,367px,0)}}\n@keyframes cc-twinkle{from{opacity:.45}to{opacity:.95}}\n[data-cc=\"count\"]{animation:cc-count .32s cubic-bezier(.2,.8,.2,1) both}\n@keyframes cc-count{from{opacity:0;transform:scale(1.9)}to{opacity:1;transform:scale(1)}}\n[data-cc=\"reveal\"]{animation:cc-reveal .75s cubic-bezier(.2,.9,.25,1.25) both}\n@keyframes cc-reveal{0%{opacity:0;transform:scale(.35) rotate(-12deg)}100%{opacity:1;transform:scale(1) rotate(0)}}\n[data-cc=\"halo\"]{border-radius:999px;box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 38px 6px rgba(207,164,95,.35);animation:cc-glow 2.6s ease-in-out infinite}\n@keyframes cc-glow{0%,100%{box-shadow:0 0 0 2px rgba(207,164,95,.85),0 0 30px 4px rgba(207,164,95,.28)}50%{box-shadow:0 0 0 2px rgba(207,164,95,1),0 0 52px 10px rgba(207,164,95,.5)}}\n[data-cc=\"orbit\"]{position:absolute;top:-14px;left:-14px;right:-14px;bottom:-14px;border-radius:999px;border:1px dashed rgba(207,164,95,.45);animation:cc-spin 14s linear infinite}\n@keyframes cc-spin{to{transform:rotate(360deg)}}\n[data-cc=\"rise1\"],[data-cc=\"rise2\"],[data-cc=\"rise3\"],[data-cc=\"rise4\"]{animation:cc-rise .5s cubic-bezier(.2,.8,.2,1) both}\n[data-cc=\"rise2\"]{animation-delay:.12s}[data-cc=\"rise3\"]{animation-delay:.24s}[data-cc=\"rise4\"]{animation-delay:.36s}\n@keyframes cc-rise{from{opacity:0;transform:translate3d(0,18px,0)}to{opacity:1;transform:none}}\n[data-cc=\"btn\"]{transition:transform .12s ease,box-shadow .2s ease,filter .2s ease;cursor:pointer}\n[data-cc=\"btn\"]:hover{filter:brightness(1.08)}\n[data-cc=\"btnp\"]{transition:transform .12s ease,box-shadow .2s ease;cursor:pointer;box-shadow:0 0 0 1px rgba(207,164,95,.9),0 8px 30px rgba(207,164,95,.35)}\n[data-cc=\"btnp\"]:hover{box-shadow:0 0 0 1px #CFA45F,0 8px 44px rgba(207,164,95,.6)}\n[data-cc=\"card\"]{background:linear-gradient(135deg,rgba(255,255,255,.07),rgba(255,255,255,.02));backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px)}\n[data-cc=\"sheen\"]{position:absolute;top:0;bottom:0;width:40%;left:-60%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.10),transparent);animation:cc-sheen 3.8s ease-in-out 1s infinite}\n@keyframes cc-sheen{0%{left:-60%}35%,100%{left:130%}}\n[data-cc=\"scan\"]{position:absolute;left:0;right:0;height:4px;background:linear-gradient(90deg,transparent,#CFA45F,#fff,#CFA45F,transparent);box-shadow:0 0 18px 4px rgba(207,164,95,.75);animation:cc-scan .9s ease-in-out infinite alternate}\n@keyframes cc-scan{from{top:2%}to{top:96%}}\n[data-cc=\"grid\"]{position:absolute;top:0;left:0;right:0;bottom:0;background-image:linear-gradient(rgba(207,164,95,.18) 1px,transparent 1px),linear-gradient(90deg,rgba(207,164,95,.18) 1px,transparent 1px);background-size:22px 22px}\n[data-cc=\"blink\"]{animation:cc-blink 1s steps(2,start) infinite}\n@keyframes cc-blink{to{visibility:hidden}}\nhtml.cc-welcome #cc-install-hint{display:none !important}\n@media (prefers-reduced-motion: reduce){[data-cc]{animation:none !important;transition:none !important}}\n",R=e=>({dataSet:{cc:e}}),O='undefined'!=typeof document,P=()=>O&&'function'==typeof window.matchMedia&&window.matchMedia('(prefers-reduced-motion: reduce)').matches,E=()=>{try{O&&navigator.vibrate?.(12)}catch{}};function z({label:e,onPress:t,kind:n="primary",testID:r,disabled:s}){const o='primary'===n;return(0,C.jsx)(l.default,{testID:r,accessibilityRole:"button",accessibilityLabel:e,disabled:s,onPress:()=>{E(),t()},...R(o&&!s?'btnp':'btn'),style:({pressed:e})=>[{alignSelf:'stretch',minHeight:56,borderRadius:28,alignItems:'center',justifyContent:'center',paddingHorizontal:20,backgroundColor:o?A:'rgba(255,255,255,0.04)',borderWidth:o?0:1.5,borderColor:A,opacity:s?.45:1,transform:[{scale:e?.96:1}]}],children:(0,C.jsx)(T.T,{size:18,weight:"semibold",colour:o?'#0B0B0B':A,center:!0,children:e})})}const D=({children:e,colour:t=A})=>(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:t,style:{letterSpacing:2.2},children:e}),L={Owner:['Takings, sales, labour cost and payroll','Bookings (Tables and Covers), orders, the rota and team chat','Every setting, plus the Assistant for quick answers'],Manager:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],Supervisor:['Run service: orders, bookings (Tables and Covers) and the waitlist','The rota, timesheets and team pay rates','Your own clock-in and pay in the Staff app'],'Head Chef':['Stock, costings, prep, ordering and the specials board','Food safety checks, allergens and live tickets','Your own clock-in, rota and pay in the Staff app'],Staff:['Clock in and out, see your rota, swap shifts, ask for time off','Team chat, food safety checks and the accident book','Your own hours, pay and tips (only yours)']};function U(){const e=O?navigator.userAgent:'';return/iPhone|iPad|iPod/.test(e)?'In Safari, tap Share (the square with an arrow), then Add to Home Screen.':/SamsungBrowser/.test(e)?'Tap the menu, then Add page to, then Home screen.':'In Chrome, tap \u22ee then Add to Home screen (or Install app).'}const N=({k:e,v:t})=>(0,C.jsxs)(h.default,{style:{flexDirection:'row',gap:12,alignItems:'baseline'},children:[(0,C.jsx)(T.T,{size:14,weight:"semibold",colour:w.colours.muted,numberOfLines:1,style:{width:74,letterSpacing:1.2},children:e}),(0,C.jsx)(T.T,{size:18,weight:"semibold",style:{flex:1},children:t})]});function W({p:e,onClose:s}){const[u,x]=(0,r.useState)('choose'),[b,y]=(0,r.useState)(null),[v,j]=(0,r.useState)(null),[I,O]=(0,r.useState)(!1),[L,U]=(0,r.useState)(''),N=(0,r.useRef)(null);(0,r.useEffect)(()=>()=>{N.current&&URL.revokeObjectURL(N.current)},[]);const W=async e=>{U('');const t=await(0,k.pickPhoto)(e);if(!t)return;N.current&&URL.revokeObjectURL(N.current);const n=URL.createObjectURL(t);N.current=n,y(n),O(!1),x('scan');const r=Date.now();try{const e=await(0,k.styliseOnDevice)(t),n=P()?0:Math.max(0,1300-(Date.now()-r));setTimeout(()=>{j(e),x('reveal'),E()},n)}catch{U("That photo couldn't be opened. Try another one (JPEG or PNG)."),x('choose')}},_=({children:e})=>(0,C.jsx)(h.default,{style:{width:236,height:236,borderRadius:118,overflow:'hidden',borderWidth:2,borderColor:A,alignItems:'center',justifyContent:'center',backgroundColor:(0,n.soutersSurface)('#050505')},children:e});return(0,C.jsxs)(c.default,{testID:"invite-avatar-step",contentContainerStyle:{padding:22,paddingTop:34,gap:18,alignItems:'center',maxWidth:520,width:'100%',alignSelf:'center',paddingBottom:56},children:[(0,C.jsx)(D,{children:"MAKE YOUR AVATAR"}),(0,C.jsx)(T.T,{size:28,weight:"bold",center:!0,children:'choose'===u?'Choose your look':'scan'===u?'Scanning\u2026':`Looking good, ${e.name}`}),'choose'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[(0,C.jsx)(h.default,{style:{opacity:.55},children:(0,C.jsx)(S.StaffAvatar,{id:e.id,size:200,ring:!1})}),(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"})]})})}),(0,C.jsxs)(T.T,{size:16,center:!0,colour:w.colours.muted,children:["Take a selfie or pick a photo. ",p.IS_OWNER_DESKTOP?'This computer turns it into a space-age avatar. The photo never leaves this computer and isn\u2019t kept.':'Your phone turns it into a space-age avatar. The photo never leaves this phone and isn\u2019t kept.']}),(0,C.jsx)(z,{label:"Take a selfie",testID:"avatar-selfie",onPress:()=>W(!0)}),(0,C.jsx)(z,{kind:"ghost",label:"Upload a photo",testID:"avatar-upload",onPress:()=>W(!1)}),(0,C.jsx)(h.default,{style:{width:'100%',minWidth:0},children:(0,C.jsx)(t.AvatarOptions,{onSelect:t=>{f.useAvatars.getState().setOwn(e.id,e.id,t.dataUrl,e.name)?s(!0):U('Could not save your avatar. Try again.')}})})]}):'scan'===u?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('halo'),children:(0,C.jsxs)(_,{children:[b?(0,C.jsx)(o.default,{source:{uri:b},style:{width:236,height:236},accessibilityLabel:"Your photo"}):null,(0,C.jsx)(h.default,{...R('grid'),pointerEvents:"none"}),(0,C.jsx)(h.default,{...R('scan'),pointerEvents:"none"})]})}),(0,C.jsx)(D,{colour:w.colours.muted,children:"MAKING YOUR AVATAR ON THIS PHONE"})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h.default,{...R('reveal'),children:(0,C.jsx)(h.default,{...R('halo'),children:v?(0,C.jsx)(o.default,{testID:"avatar-result",source:{uri:v},style:{width:220,height:220,borderRadius:110},accessibilityLabel:"Your new avatar"}):null})}),(0,C.jsxs)(l.default,{accessibilityRole:"checkbox",accessibilityState:{checked:I},accessibilityLabel:"I agree to use this avatar",testID:"avatar-consent",onPress:()=>{E(),O(!I)},style:{alignSelf:'stretch',flexDirection:'row',gap:12,alignItems:'flex-start',padding:14,borderRadius:16,borderWidth:1.5,borderColor:I?A:'rgba(255,255,255,0.2)'},children:[(0,C.jsx)(h.default,{style:{width:28,height:28,borderRadius:8,borderWidth:2,borderColor:A,backgroundColor:I?A:'transparent',alignItems:'center',justifyContent:'center'},children:I?(0,C.jsx)(T.T,{size:17,weight:"bold",colour:"#111",children:"\u2713"}):null}),(0,C.jsx)(T.T,{size:15,style:{flex:1},children:"I\u2019m happy for this avatar, made from my photo, to be shown to my team in CoverCharge. Only the finished avatar is shared; my photo isn\u2019t uploaded or kept, and a manager can reset my avatar."})]}),(0,C.jsx)(z,{label:"Use this avatar",testID:"avatar-save",disabled:!I,onPress:()=>{if(!v)return;f.useAvatars.getState().setOwn(e.id,e.id,v,e.name)?(N.current&&URL.revokeObjectURL(N.current),N.current=null,s(!0)):U("Couldn't save the avatar. Please try again.")}}),(0,C.jsx)(z,{kind:"ghost",label:"Try another photo",onPress:()=>{j(null),x('choose')}})]}),L?(0,C.jsx)(T.T,{size:15,colour:w.colours.red,center:!0,children:L}):null,'scan'!==u?(0,C.jsx)(l.default,{testID:"invite-avatar-done",accessibilityRole:"button",onPress:()=>{E(),s(!1)},style:({pressed:e})=>({padding:12,transform:[{scale:e?.96:1}]}),children:(0,C.jsx)(T.T,{size:17,weight:"semibold",colour:w.colours.text,children:"Skip, keep this one"})}):null]})}},1454,[929,828,34,1097,336,236,402,295,41,102,872,926,891,831,987,1004,15,793,821,925,794,25]); +__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.StaffHome=function({go:e}){const A=(0,m.useInStaffApp)(),{now:N,meId:O,me:R,r:z,today:H}=(0,m.useCtx)(3e4),P=(0,s.useTravelDay)('staff',H),F=(0,h.useOwner)(e=>e.shifts),_=(0,h.useOwner)(e=>(0,h.liveAttendance)(e.attendance)),E=(0,h.useOwner)(e=>e.staffCanViewSuppliers),W=(0,h.useOwner)(e=>e.quickLinks),q=(0,h.useOwner)(e=>e.chat),V=(0,h.useOwner)(e=>e.swaps),G=(0,h.useOwner)(e=>e.leave),U=(0,v.workingShifts)(F,G).filter(e=>e.staffId===O&&e.published&&e.date>=H).sort((e,s)=>e.date.localeCompare(s.date)||e.start-s.start),Y=U.find(e=>e.date===H),Q=_.filter(e=>e.staffId===O&&e.in&&!e.out&&N.getTime()-new Date(e.in).getTime()<72e6).sort((e,s)=>s.in.localeCompare(e.in))[0],K=(0,x.usePay)(O,0),J=(0,b.useOrders)(z.id),X=(0,b.useBookings)(z.id),Z=J.filter(e=>(0,T.LIVE)(e)&&e.allergies.length&&(0,k.nextStep)(e,(0,k.linkedBooking)(e,X))),ee=X.filter(e=>e.date===H&&['confirmed','seated'].includes(e.status)&&(0,k.bookingNeedsAction)(e,J.filter(T.LIVE))),se=X.filter(e=>(0,C.undoKind)(e,H)||e.walkIn&&'cancelled'===e.status&&e.date===H).sort((e,s)=>e.time.localeCompare(s.time)).slice(0,12),te=q.filter(e=>'all'===e.ch&&e.pinned&&!e.removed).slice(-1)[0],ie=V.filter(e=>e.fromId===O&&'open'===e.status).length+G.filter(e=>e.staffId===O&&'pending'===e.status).length,ae=[['Clock in / out',()=>e('more','clock')],['My rota, swaps & time off',()=>e('more','rota')],['Staff chat',()=>e('chat')],['Recipe cards',()=>e('more','recipecards')],['My hours & pay',()=>e('more','mypay')],['My tips',()=>e('more','mytips')],['Post to social (draft)',()=>e('more','social')],...E?[['Suppliers',()=>e('more','suppliers')]]:[]];return!A&&P?(0,L.jsxs)(o.default,{style:{gap:10},children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(s.DayView,{rid:z.id,day:P,today:H,app:"staff"})]}):(0,L.jsxs)(o.default,{style:{gap:10},children:[A?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(s.DayBar,{app:"staff",today:H}),(0,L.jsx)(t.CoversToday,{rid:z.id})]}),(0,L.jsxs)(r.Card,{highlight:u.colours.accentBorder,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.Row,{gap:10,style:{flex:1},children:[(0,L.jsx)(n.default,{accessibilityRole:"button",accessibilityLabel:"My avatar",onPress:()=>e('more','avatar'),children:(0,L.jsx)(S.StaffAvatar,{id:O,size:52})}),(0,L.jsxs)(r.T,{size:18,weight:"bold",children:["Hi ",R.replace(' (example)','').split(' ')[0]]})]}),(0,L.jsx)(r.Badge,{kind:"gold",label:A?z.name:'Staff app preview'})]}),(0,L.jsx)(r.Muted,{children:A?`${N.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})}`:'This is what staff will see in the separate Staff app.'})]}),(0,L.jsx)(M.StaffTipsTile,{rid:z.id,today:H,onPress:()=>e('more','mytips')}),(0,L.jsxs)(r.Card,{highlight:Q?u.colours.ok:void 0,children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{weight:"semibold",children:Q?`On shift since ${(0,c.hm)(new Date(Q.in))}`:'Not clocked in'}),Q?(0,L.jsx)(r.Badge,{kind:"ok",label:(0,m.hmDur)(Math.max(0,Math.round((N.getTime()-new Date(Q.in).getTime())/6e4)))}):null]}),Y?(0,L.jsxs)(r.Muted,{children:["Today on the rota: ",(0,m.fmtH)(Y.start),"\u2013",(0,m.fmtH)(Y.end)]}):U[0]?(0,L.jsxs)(r.Muted,{children:["Next on the rota: ",m.DAY3[U[0].day]," ",Number(U[0].date.slice(8))," ",(0,m.fmtH)(U[0].start),"\u2013",(0,m.fmtH)(U[0].end)]}):(0,L.jsx)(r.Muted,{children:"No shifts on the rota this week."}),(0,L.jsx)(r.Button,{small:!0,kind:Q?'secondary':'success',label:Q?'Clock out':'Clock in',onPress:()=>e('more','clock')})]}),O?(0,L.jsx)($.RequestTimeOff,{meId:O,me:R,testID:"staff-home-time-off"}):null,(0,L.jsx)(p.ShellfishTile,{rid:z.id,by:R.replace(' (example)',''),app:"staff"}),se.length?(0,L.jsx)(r.Card,{children:(0,L.jsxs)(o.default,{testID:"staff-seated-today",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Seated and finished today (",se.length,")"]}),(0,L.jsx)(r.Muted,{children:"Seated someone by mistake? Tap Unseat: they go back to Booked and their tables are freed. Finished or No-show by mistake? Tap Undo."}),se.map(e=>{const s=e.walkIn?`Walk-in \xb7 ${e.partySize}`:`${e.name} \xb7 ${e.partySize}`;return(0,L.jsxs)(o.default,{testID:(0,f.isSeatedHighlight)(e.status)?`staff-seated-row-${e.id}`:`staff-done-row-${e.id}`,style:(0,f.isSeatedHighlight)(e.status)?{gap:6,padding:10,borderRadius:12,marginTop:4,...(0,f.seatedHighlightStyle)()}:{gap:6,borderTopWidth:1,borderTopColor:u.colours.hairline,paddingTop:8,opacity:'finished'===e.status||'noshow'===e.status?.7:1},children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsxs)(r.T,{size:17,weight:"semibold",colour:(0,f.isSeatedHighlight)(e.status)?f.SEATED_FG:u.colours.text,children:[e.time," \xb7 ",s]}),(0,L.jsx)(r.Badge,{kind:'noshow'===e.status?'red':'seated'===e.status?'ok':'neutral',label:'noshow'===e.status?'No-show':'seated'===e.status?'Seated':'Finished'})]}),(0,L.jsxs)(r.Muted,{children:[e.table?(0,I.tableCardLabel)(e.table):'No table'," \xb7 ",e.ref]}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsxs)(r.Row,{wrap:!0,gap:6,children:['seated'===e.status?(0,L.jsx)(r.Button,{small:!0,kind:"secondary",label:"Finished",accessibilityLabel:`Finished: ${s}`,onPress:()=>(0,B.finishBookingNow)(z.id,e)}):null,e.walkIn?(0,L.jsx)(a.CancelWalkInButton,{rid:z.id,b:e,small:!0}):null,e.walkIn?(0,L.jsx)(a.ReinstateWalkInButton,{rid:z.id,b:e,today:H,small:!0}):null,(0,L.jsx)(C.BookingUndo,{b:e,rid:z.id,today:H,who:s})]})]},e.id)})]})}):null,Z.length+ee.length?(0,L.jsxs)(o.default,{testID:"staff-allergy-signoffs",style:{gap:8},children:[(0,L.jsxs)(r.T,{weight:"semibold",children:["Allergy sign-offs (",Z.length+ee.length,")"]}),(0,L.jsx)(r.Muted,{children:"Tap Sign off for your step. Your name and the time are recorded."}),Z.map(e=>(0,L.jsx)(j.AllergyChain,{o:e,me:R},e.id)),ee.map(e=>(0,L.jsxs)(o.default,{accessible:!0,accessibilityLabel:`Booking ${e.time}, ${e.name}, ${e.partySize}${e.table?`, ${(0,D.tableNumbersA11y)(e.table)}`:''}`,style:{gap:4},children:[(0,L.jsxs)(r.Muted,{children:["Booking ",e.time," \xb7 ",e.name," (",e.partySize,")",e.table?` \xb7 ${(0,I.tablesLabel)(e.table)}`:'']}),(0,L.jsx)(l.DepositChip,{b:e,money:!0,testID:`staff-deposit-${e.id}`}),(0,L.jsx)(j.BookingAllergyChain,{b:e,me:R}),(0,L.jsx)(o.default,{style:{flexDirection:'row'},children:(0,L.jsx)(w.WhatsAppGuest,{b:e,rid:z.id,kind:"auto"})})]},e.id))]}):null,te?(0,L.jsxs)(r.Card,{onPress:()=>e('chat'),children:[(0,L.jsxs)(r.Row,{style:{justifyContent:'space-between'},children:[(0,L.jsx)(r.T,{size:12,weight:"semibold",colour:u.colours.gold,children:"\ud83d\udccc PINNED IN ALL STAFF"}),(0,L.jsx)(r.Muted,{children:"Open chat \u203a"})]}),(0,L.jsx)(r.T,{size:14,children:te.text})]}):null,(0,L.jsxs)(r.Card,{children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Hours this pay period"}),(0,L.jsxs)(r.T,{size:18,weight:"semibold",colour:u.colours.goldLight,children:[(0,m.hmDur)(K.paid)," paid hours"]})]}),ie?(0,L.jsx)(r.Card,{onPress:()=>e('more','rota'),children:(0,L.jsxs)(r.T,{size:14,children:["You have ",ie," request",ie>1?'s':''," waiting for a manager \u203a"]})}):null,(0,y.visibleLinks)(W,'staff').length?(0,L.jsxs)(o.default,{testID:"quick-links",style:{gap:6},children:[(0,L.jsx)(r.T,{weight:"semibold",children:"Quick links"}),(0,L.jsx)(y.QuickLinksRow,{compact:!0})]}):null,A?null:(0,L.jsx)(o.default,{style:{gap:6},children:ae.map(([e,s])=>(0,L.jsx)(r.Button,{kind:"secondary",label:e,onPress:s},e))})]})};var s=_r(d[0]),t=_r(d[1]),a=_r(d[2]),l=_r(d[3]);_r(d[4]);var n=e(_r(d[5])),o=e(_r(d[6])),r=_r(d[7]),h=_r(d[8]),c=_r(d[9]),u=_r(d[10]),f=_r(d[11]),p=_r(d[12]),m=_r(d[13]),x=_r(d[14]),y=_r(d[15]),j=_r(d[16]),b=_r(d[17]),w=_r(d[18]),k=_r(d[19]),T=_r(d[20]),S=_r(d[21]),C=_r(d[22]),I=_r(d[23]),D=_r(d[24]),B=_r(d[25]),M=_r(d[26]),$=_r(d[27]),v=_r(d[28]),L=_r(d[29])},1455,[1196,1099,1140,1117,34,402,102,794,891,858,821,1118,1188,1088,1193,1439,1181,876,1197,869,1195,925,1433,1029,860,1126,1212,1216,1098,25]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1456,[30,34,872,25]); +__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 D}});var s=r(_d[0]),t=r(_d[1]);r(_d[2]),r(_d[3]);var n=r(_d[4]),o=r(_d[5]),u=r(_d[6]),l=(function(e){if(e&&e.__esModule)return e;var s={};return e&&Object.keys(e).forEach(function(t){if('default'!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),s.default=e,s})(r(_d[7])),c=r(_d[8]),d=r(_d[9]),f=e(r(_d[10])),p=e(r(_d[11]));r(_d[12]);var y=e(r(_d[13])),h=e(r(_d[14])),S=r(_d[15]),_=r(_d[16]),O=r(_d[17]),P=r(_d[18]),j=r(_d[19]),v=r(_d[20]),A=r(_d[21]),b=r(_d[22]),x=r(_d[23]),w=r(_d[24]),E=r(_d[25]),C=r(_d[26]);r(_d[27]);var I=r(_d[28]),k=r(_d[29]),R=r(_d[30]),H=r(_d[31]),T=r(_d[32]),F=r(_d[33]),B=r(_d[34]),V=r(_d[35]),N=r(_d[36]),G=r(_d[37]);const L=r(_d[38]),M=r(_d[39]),U=r(_d[40]),q=r(_d[41]);function D(){const[e]=(0,n.useFonts)({Poppins_400Regular:L,Poppins_500Medium:M,Poppins_600SemiBold:U,Poppins_700Bold:q}),[s,E]=(0,d.useState)(v.useStore.persist.hasHydrated()),[T,F]=(0,d.useState)(b.useOwner.persist.hasHydrated()),B=s&&T;(0,d.useEffect)(()=>{const e=v.useStore.persist.onFinishHydration(()=>E(!0)),s=b.useOwner.persist.onFinishHydration(()=>F(!0));return v.useStore.persist.hasHydrated()&&E(!0),b.useOwner.persist.hasHydrated()&&F(!0),()=>{e(),s()}},[]),(0,d.useEffect)(()=>{if('undefined'==typeof window)return;const e=e=>{e.key===(0,S.venueKey)(v.useStore.persist.getOptions().name??'')&&(0,C.quietly)(()=>v.useStore.persist.rehydrate()),e.key===(0,S.venueKey)(A.useFloor.persist.getOptions().name??'')&&(0,C.quietly)(()=>A.useFloor.persist.rehydrate()),e.key===(0,S.venueKey)(o.useBlocks.persist.getOptions().name??'')&&(0,C.quietly)(()=>o.useBlocks.persist.rehydrate())};return window.addEventListener('storage',e),()=>window.removeEventListener('storage',e)},[]),(0,d.useEffect)(()=>{B&&b.useOwner.getState().syncRoster()},[B]),(0,d.useEffect)(()=>{B&&(0,t.startAppSync)()},[B]);const V=e&&B,N=(0,w.useSignedOutGate)(),D=(0,u.usePathname)(),K=V&&!(0,O.isAllowedPath)(D||'/');return(0,d.useEffect)(()=>{if(!K)return;const e=setTimeout(()=>u.router.replace(O.ENTRY[O.APP_VARIANT]),0);return()=>clearTimeout(e)},[K,D]),(0,d.useEffect)(()=>{V&&l.hideAsync().catch(()=>{})},[V]),V?(0,G.jsxs)(j.SafeAreaProvider,{children:[(0,G.jsx)(c.StatusBar,{style:"light"}),N?(0,G.jsx)(h.default,{style:{flex:1,backgroundColor:x.colours.bg}}):(0,G.jsx)(h.default,{style:{flex:1},children:(0,G.jsx)(u.Stack,{screenOptions:{headerShown:!1,contentStyle:{backgroundColor:x.colours.bg}}})}),K&&!N?(0,G.jsx)(h.default,{style:[y.default.absoluteFill,{backgroundColor:x.colours.bg}]}):null,K||N||O.IS_CAR?null:(0,G.jsx)(R.VoiceHost,{}),N?null:(0,G.jsx)(I.SyncBadge,{}),K||N||O.IS_CAR?null:(0,G.jsx)(k.PushPrompt,{}),O.IS_CAR?(0,G.jsx)(P.CarGate,{}):(0,G.jsx)(w.InviteGate,{}),K||N?null:(0,G.jsx)(H.SliderHost,{})]}):(0,G.jsxs)(h.default,{style:{flex:1,backgroundColor:x.colours.bg,alignItems:'center',justifyContent:'center',gap:18},children:[_.HERO_LOGOS[S.VENUE_RID]?(0,G.jsx)(p.default,{source:_.HERO_LOGOS[S.VENUE_RID],accessibilityLabel:"Venue logo",style:{width:180,height:180},resizeMode:"contain"}):null,(0,G.jsx)(f.default,{color:x.colours.gold})]})}T.PITCH&&(globalThis.__pitch={useSaverCfg:N.useSaverCfg,useSync:t.useSync,seedInvitePairsForQA:s.seedInvitePairsForQA,appVariant:O.APP_VARIANT,useStore:v.useStore,useOwner:b.useOwner,useFloor:A.useFloor,useBlocks:o.useBlocks,useSession:E.useSession,useCashUp:F.useCashUp,useCashAccess:B.useCashAccess,seedPitch:V.seedPitch},setTimeout(()=>{try{(0,V.seedPitch)()}catch(e){console.warn('pitch seed',e)}},1500)),E.START_INVITE,l.preventAutoHideAsync().catch(()=>{})},1457,[1458,987,795,1405,1460,1026,30,1487,496,34,385,336,236,41,102,5,873,872,1489,36,874,1029,891,821,1446,1004,1024,1492,1493,1058,1494,1130,2,1039,999,1512,1373,25,1514,1515,1516,1517]); +__d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"inviteCache",{enumerable:!0,get:function(){return S}}),_e.refreshLinkPhones=P,_e.linkedSinceText=L,_e.refreshInvites=A,_e.useInviteStatus=function(){const[,e]=(0,t.useState)(0);return(0,t.useEffect)(()=>{const n=()=>e(e=>e+1);return $.add(n),A(),()=>{$.delete(n)}},[]),j},Object.defineProperty(_e,"when",{enumerable:!0,get:function(){return C}}),_e.inviteStateText=function(e,n=Date.now()){return'used'===e?.state?'Previous link used. Make a new link only if they need one.':e?.devices?`Signed in on ${e.devices} device${1===e.devices?'':'s'}`:'Personal Android and iPhone links'},_e.seedInvitePairsForQA=function(n,t,s){if(!e.PITCH)throw new Error('QA only');w.set(`${n}:${t}`,{working:[s.android,s.iphone].filter(Boolean).length,...s}),x()},Object.defineProperty(_e,"installSteps",{enumerable:!0,get:function(){return B}}),Object.defineProperty(_e,"installMessage",{enumerable:!0,get:function(){return R}}),_e.InviteLinkControls=function({m:e,actorRole:s}){const o=(0,h.useSync)(e=>e.venueId),x=(0,h.useSync)(e=>'staff'===e.kind&&!!e.venueId),j=(0,h.useSync)(e=>e.perms.includes('*')||e.perms.includes('roles.manage')),S=x&&e.active&&!e.name.includes('(example)')&&('owner'===s||j||'manager'===s&&'owner'!==e.role&&!e.ownerAccess),A=`${o}:${e.id}`,O=(0,k.useSession)(e=>e.meId),E=(0,y.useOwner)(e=>O?e.staff.find(e=>e.id===O):void 0),W=!O||!!E&&(0,f.ownJobManagesLinks)(E),[,_]=(0,t.useState)(0),[F,Y]=(0,t.useState)(''),[Z,N]=(0,t.useState)(null),[U,G]=(0,t.useState)(!1),[Q,q]=(0,t.useState)(null),[J,K]=(0,t.useState)(null),[V,X]=(0,t.useState)(!1);if((0,t.useEffect)(()=>{if(!S)return;const n=()=>_(e=>e+1);return $.add(n),P(),M(A,e.id),()=>{$.delete(n)}},[S,A,e.id]),!S)return null;const ee=w.get(A),ne=e.name.split(' ')[0],te=['android','iphone'].filter(e=>T(ee?.[e])),ie=ee?.working??te.length,se=!0===ee?.oldLinksSwitchOff?'Their old link switches off once they open this one.':'Their other links keep working.',ae=async n=>{try{await(0,h.revokeStaffAppLink)(n),K(null),Y('Link switched off. Phones already signed in stay signed in.'),b.delete(A),await M(A,e.id),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}},re=async n=>{if(!Z){N(n);try{await D(A,e.id,n),G(!1),Y(`New ${'android'===n?'Android':'iPhone'} link made for ${ne}. ${se} Copy or Share it below.`),Q&&q(await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}finally{N(null)}}};return(0,m.jsxs)(l.default,{testID:`invite-${e.id}`,style:{gap:10},children:[(()=>{const n=L(I[e.id]);return n?(0,m.jsxs)(l.default,{testID:`invite-phone-${e.id}`,style:{gap:8,padding:12,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",colour:u.colours.goldLight,testID:`invite-phone-since-${e.id}`,children:n}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Another phone that opens ",e.name,"\u2019s link is asked to see a manager."]}),W?V?(0,m.jsxs)(l.default,{style:{gap:8,alignItems:'center',width:'100%'},children:[(0,m.jsxs)(d.T,{center:!0,size:15,children:["Reset ",e.name,"\u2019s phone? Their link will link to the next phone that opens it. Phones already signed in stay signed in."]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Yes, reset phone",testID:`invite-reset-yes-${e.id}`,style:{minHeight:44},accessibilityLabel:`Yes, reset ${e.name}'s phone`,onPress:async()=>{try{await(0,h.resetStaffLinkPhone)(e.id),await P(),Y(`Phone reset. ${e.name}\u2019s link will link to the next phone that opens it.`)}catch(e){Y(String(e.message))}finally{X(!1)}}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},testID:`invite-reset-no-${e.id}`,onPress:()=>X(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Reset phone",kind:"secondary",testID:`invite-reset-${e.id}`,style:{minHeight:44},accessibilityLabel:`Reset phone for ${e.name}. Asks to confirm.`,onPress:()=>X(!0)}):(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-reset-managers-only-${e.id}`,children:"Only a manager or owner can reset a phone or switch a link off."})]}):null})(),ee?null:(0,m.jsx)(d.Muted,{center:!0,testID:`invite-loading-${e.id}`,children:v.has(A)?'Cannot load the links right now. Close and open again to retry.':'Loading current links\u2026'}),ee&&0===ie?(0,m.jsxs)(l.default,{testID:`invite-none-${e.id}`,style:{gap:6,padding:12,borderRadius:10,borderWidth:2,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",size:17,accessibilityRole:"header",children:"No link yet - tap Make a new link"}),(0,m.jsxs)(d.Muted,{center:!0,size:13,children:[ne," has no working link. Make one for the phone they use, then Share it privately."]})]}):null,ee&&ie>0&&0===te.length?(0,m.jsxs)(d.Muted,{center:!0,testID:`invite-hidden-${e.id}`,children:[ne," has ",1===ie?'a working link':`${ie} working links`," sent earlier. For safety it can\u2019t be shown again here. Tap Make a new link only if ",ne," needs a new one."]}):null,te.map(t=>{const s=H(t),o=ee[t],h=(0,c.personalAppUrl)(t,o);return(0,m.jsxs)(l.default,{testID:`invite-${t}-${e.id}`,style:{gap:6,padding:10,borderRadius:10,borderWidth:1,borderColor:u.colours.gold,backgroundColor:u.colours.bg,alignItems:'center'},children:[(0,m.jsx)(d.T,{center:!0,weight:"semibold",children:s}),(0,m.jsx)(n.Text,{selectable:!0,accessibilityLabel:`${e.name}, ${s} personal link`,testID:`invite-link-${t}-${e.id}`,style:{color:u.colours.goldLight,fontSize:14,textAlign:'center',width:'100%'},children:o.shortCode?`Short link: ${o.shortCode}`:"Secure personal link \u2014 Copy or Share"}),o.linked?(0,m.jsxs)(d.Muted,{center:!0,size:13,testID:`invite-linked-${t}-${e.id}`,children:["Already linked to ",ne,"\u2019s phone. Another phone that opens it is asked to see a manager."]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(d.Muted,{center:!0,size:13,children:B(t)}),(0,m.jsx)(d.Muted,{center:!0,size:13,children:"Works for good on the first phone that opens it."})]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Copy",kind:"secondary",style:{minHeight:44,minWidth:44},accessibilityLabel:`Copy ${e.name}'s ${s} link`,testID:`invite-copy-${t}-${e.id}`,onPress:async()=>Y(await(0,p.copyText)(R(h,e.name,t))?'Link and install steps copied':'Select and copy the link.')}),(0,m.jsx)(d.Button,{label:"Share",style:{minHeight:44,minWidth:44},accessibilityLabel:`Share ${e.name}'s ${s} link`,testID:`invite-share-${t}-${e.id}`,onPress:async()=>Y(await z(h,e.name,t))}),W?(0,m.jsx)(d.Button,{label:"Revoke link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${s} link`,onPress:()=>K(o.id)}):null]})]},t)}),J&&W?(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:"Confirm revoke link",accessibilityLabel:`Confirm revoke link for ${e.name}`,style:{minHeight:44},onPress:()=>{ae(J)}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",style:{minHeight:44},onPress:()=>K(null)})]}):null,F?(0,m.jsx)(d.T,{center:!0,size:14,children:F}):null,ee&&W?(0,m.jsx)(l.default,{testID:`invite-make-${e.id}`,style:{gap:8,alignItems:'center',width:'100%'},children:U?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(d.T,{center:!0,size:15,testID:`invite-make-ask-${e.id}`,children:["Make a new link for ",ne,"? Which phone do they use? ",se]}),(0,m.jsxs)(d.Row,{gap:8,wrap:!0,style:{justifyContent:'center'},children:[(0,m.jsx)(d.Button,{label:'android'===Z?'Making\u2026':'Android phone',testID:`invite-make-android-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new Android link for ${e.name}`,onPress:()=>{re('android')}}),(0,m.jsx)(d.Button,{label:'iphone'===Z?'Making\u2026':'iPhone',testID:`invite-make-iphone-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:`Yes, make a new iPhone link for ${e.name}`,onPress:()=>{re('iphone')}}),(0,m.jsx)(d.Button,{label:"Cancel",kind:"ghost",testID:`invite-make-cancel-${e.id}`,disabled:!!Z,style:{minHeight:48},accessibilityLabel:"Cancel, make no link",onPress:()=>G(!1)})]})]}):(0,m.jsx)(d.Button,{label:"Make a new link",kind:0===ie?'primary':'secondary',testID:`invite-new-${e.id}`,style:{minHeight:52,alignSelf:'center'},accessibilityLabel:`Make a new link for ${e.name}. Asks which phone first.`,onPress:()=>{Y(''),G(!0)}})}):null,ee&&!W?(0,m.jsx)(d.Muted,{center:!0,size:13,testID:`invite-make-managers-only-${e.id}`,children:"Only a manager or owner can make a new link."}):null,(0,m.jsxs)(d.Muted,{center:!0,size:13,children:["Share privately with ",e.name,". Links never expire. Opening this page never makes a link. Each link works on the first phone that opens it; Reset phone lets it link to a new one."]}),(0,m.jsx)(d.Button,{label:Q?'Hide previous links':'Manage previous links',kind:"ghost",style:{minHeight:44},accessibilityLabel:`Manage all previous app links for ${e.name}`,onPress:async()=>{try{q(Q?null:await(0,h.staffAppLinkHistory)(e.id))}catch(e){Y(String(e.message))}}}),Q?.map(n=>(0,m.jsxs)(l.default,{style:{gap:4},children:[(0,m.jsxs)(d.Muted,{center:!0,size:13,children:['legacy'===n.platform?'Previous app link':'android'===n.platform?'Android app':'iPhone'," \xb7 ",C(n.createdAt)," \xb7 ",n.revokedAt?'Revoked':n.usedAt?'Used for sign-in':'Unused']}),!n.revokedAt&&W?(0,m.jsx)(d.Button,{label:"Revoke this link",kind:"ghost",style:{minHeight:44},accessibilityLabel:`Revoke ${e.name}'s ${n.platform} link from ${C(n.createdAt)}`,onPress:()=>K(n.id)}):null]},n.id))]})};var e=r(_d[0]),n=r(_d[1]),t=r(_d[2]);r(_d[3]),r(_d[4]);var s,o=r(_d[5]),l=(s=o)&&s.__esModule?s:{default:s},d=r(_d[6]),c=r(_d[7]),h=r(_d[8]),u=r(_d[9]),p=r(_d[10]),k=r(_d[11]),y=r(_d[12]),f=r(_d[13]),m=r(_d[14]);const w=new Map,b=new Map,$=new Set,v=new Map,x=()=>$.forEach(e=>e());let j=null;const S=()=>j;let I={};async function P(){return I=await(0,h.staffLinkPhones)(),x(),I}function L(e){if(!e||!e.phones)return null;const n=new Date(e.since).toLocaleDateString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',year:'numeric'});return e.phones>1?`Linked to ${e.phones} phones, the first since ${n}`:`Linked to a phone since ${n}`}async function A(){return j=await(0,h.readInviteStatus)(),x(),j}const C=e=>e?new Date(e).toLocaleString('en-GB',{timeZone:'Europe/London',day:'numeric',month:'short',hour:'2-digit',minute:'2-digit',timeZoneName:'short'}):'';async function M(n,t){if(e.PITCH)return void(w.has(n)||(w.set(n,{working:0}),x()));if(b.has(n))return b.get(n);const s=(async()=>{try{w.set(n,await(0,h.currentStaffAppLinks)(t)),v.delete(n)}catch(e){v.set(n,String(e.message||e))}finally{b.delete(n),x()}})();return b.set(n,s),s}async function D(n,t,s){if(e.PITCH){const e=w.get(n)??{},o=(e.working??0)+1,l={id:`qa-${s}-${t}-${o}`,token:('android'===s?'A':'B').repeat(32),device:'iphone'===s?'D'.repeat(32):null,app:'staff',expiresAt:'infinity',shortCode:('android'===s?'A':'I')+String(o).padStart(9,'0')},d={...e,[s]:l,working:o};return w.set(n,d),x(),d}const o=await(0,h.makeStaffAppLink)(t,s);return w.set(n,o),v.delete(n),x(),o}const H=e=>'android'===e?'Android app':'iPhone web app',T=e=>!!e&&('infinity'===e.expiresAt?/^[A-Za-z0-9_-]{16,64}$/.test(e.token):(0,c.currentAppLink)(e)),B=e=>'android'===e?'Tap the link, download the app, allow installation, then open it. It signs you in.':'Open in Safari and tap Open app. In the app, tap Share, Add to Home Screen, then open it from your Home Screen.',R=(e,n,t)=>`${n} \u2014 ${'android'===t?'Android app':'iPhone web app'}\n${e}\n${B(t)}`;async function z(e,n,t){const s=R(e,n,t);try{if('undefined'!=typeof navigator&&navigator.share)return await navigator.share({title:`CoverCharge for ${n}`,text:s,url:e}),'Share opened'}catch(e){if('AbortError'===e.name)return'Share cancelled'}return await(0,p.copyText)(s)?'Link and install steps copied. Paste them into a private message.':'Select and copy the link.'}},1458,[2,827,34,236,383,102,794,1459,987,821,1199,1004,891,994,25]); +__d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IOS_WEB",{enumerable:!0,get:function(){return t}}),e.getPageSlug=n,e.personalGetUrl=o,e.siteRootFromLocation=s,e.mintPersonalUrl=function(t,c,h){const p=s();if(p)return o({origin:p.origin,basePath:p.basePath,staffId:t,name:c,token:h});return`get/${n(c)||n(t)}.html?v=2#i=${encodeURIComponent(h)}`},e.currentAppLink=function(t,n=Date.now()){return!!t&&/^[A-Za-z0-9_-]{16,64}$/.test(t.token)&&Date.parse(t.expiresAt)>n},e.personalAppUrl=function(t,n){if(n.shortCode&&/^[A-Za-z0-9_-]{10}$/.test(n.shortCode)){const t=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'};return`${t.origin}${t.basePath}s.html#${n.shortCode}`}if(n.url)try{const t=new URL(n.url);if('https:'===t.protocol&&'covercharge-apps.static.hf.space'===t.hostname&&/^\/(?:(?:kirkmichael|wildings)\/)?get\/[a-z0-9-]+\.html$/.test(t.pathname))return t.href}catch{}const o=s()??{origin:'https://covercharge-apps.static.hf.space',basePath:'/'},c=['owner','chef'].includes(n.app)?n.app:'staff',h=`i=${encodeURIComponent(n.token)}${'iphone'===t?`&d=${encodeURIComponent(n.device||'')}`:''}`;return`${o.origin}${o.basePath}get/${t}.html?a=${c}${'android'===t?'&v=2':'&v=61'}#${h}`};const t=new Set(['st-jack','st-agate','st-lenny','st-james','st-lillie','st-bisto','st-gordon','st-cameron','st-mia','st-emily','st-gabrielle','st-harvey','st-tracy','st-eilidh','st-finn']);function n(t){return(t.startsWith('st-')||t.startsWith('ow-')||t.startsWith('ch-')?t.replace(/^(st|ow|ch)-/,''):t.replace(/\s*\(.*?\)\s*/g,' ').trim().split(/\s+/)[0]||t).toLowerCase().replace(/[^a-z0-9]+/g,'-').replace(/^-|-$/g,'')||'staff'}function o(t){const o=t.origin.replace(/\/$/,'');let s=(t.basePath||'/').replace(/\/?$/,'/');s.startsWith('/')||(s='/'+s);return`${o}${s}get/${n(t.name)||n(t.staffId)}.html?v=2#i=${encodeURIComponent(t.token)}`}function s(t){try{if(!(t||'undefined'!=typeof window&&window.location))return null;const n=new URL(t||window.location.href),o=n.pathname.match(/^(.*?\/)(?:owner|staff|chef|display|customer)-app(?:\/|$)/);return{origin:n.origin,basePath:o?o[1]:'/'}}catch{return null}}},1459,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return o.useFonts}});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 o=r(d[2])},1460,[1461,1484,1486]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"FontDisplay",{enumerable:!0,get:function(){return y.FontDisplay}}),_e.isLoaded=F,_e.getLoadedFonts=function(){return t.default.getLoadedFonts()},_e.isLoading=function(e){return e in c.loadPromises},_e.loadAsync=function(e,n){const t='undefined'==typeof window;if(Array.isArray(e)){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e;if(t){(0,l.assertValidFontFamilyDefinitions)(s);for(const{fontFamily:e,fontDefinitions:o}of s){(0,l.assertValidFontFaces)(e,o);for(const n of o)(0,u.registerStaticFont)(e,(0,f.fontSourceFromFace)(n))}return Promise.resolve()}try{(0,l.assertValidFontFamilyDefinitions)(s)}catch(e){return Promise.reject(e)}return Promise.all(s.map(w)).then(()=>{})}if('object'==typeof e){if(n)return Promise.reject(new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided source: ${n}. The second argument of \`loadAsync()\` can only be used with a \`string\` value as the first argument.`));const s=e,l=Object.keys(s);return t?(l.map(e=>(0,u.registerStaticFont)(e,s[e])),Promise.resolve()):Promise.all(l.map(e=>h(e,s[e]))).then(()=>{})}if(t)return(0,u.registerStaticFont)(e,n),Promise.resolve();return h(e,n)},_e.unloadAllAsync=async function(){if(!t.default.unloadAllAsync)throw new o.UnavailabilityError('expo-font','unloadAllAsync');if(Object.keys(c.loadPromises).length)throw new o.CodedError("ERR_UNLOAD",`Cannot unload fonts while they're still loading: ${Object.keys(c.loadPromises).join(', ')}`);(0,c.purgeCache)(),await t.default.unloadAllAsync()},_e.unloadAsync=async function(e,n){if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');if('object'==typeof e){if(n)throw new o.CodedError("ERR_FONT_API",`No fontFamily can be used for the provided options: ${n}. The second argument of \`unloadAsync()\` can only be used with a \`string\` value as the first argument.`);const t=e,s=Object.keys(t);return void await Promise.all(s.map(e=>p(e,t[e])))}return await p(e,n)};var e,o=r(d[0]),n=r(d[1]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[2]),l=r(d[3]),f=r(d[4]),c=r(d[5]),u=r(d[6]),y=r(d[7]);function F(e){if('function'!=typeof t.default.isLoaded)throw new Error("expected ExpoFontLoader.isLoaded to be a function, was "+typeof t.default.isLoaded);return(0,c.isLoadedInCache)(e)||t.default.isLoaded(e)}async function w(e){const{fontFamily:o,fontDefinitions:n}=e;if((0,l.assertValidFontFaces)(o,n),c.loadPromises.hasOwnProperty(o))return c.loadPromises[o];F(o)||(c.loadPromises[o]=(async()=>{try{await(0,s.loadFontFamilyAsync)(o,n),(0,c.markLoaded)(o)}finally{delete c.loadPromises[o]}})(),await c.loadPromises[o])}async function h(e,n){if(!n)throw new o.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${n} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);if(c.loadPromises.hasOwnProperty(e))return c.loadPromises[e];if(F(e))return;const t=(0,s.getAssetForSource)(n);c.loadPromises[e]=(async()=>{try{await(0,s.loadSingleFontAsync)(e,t),(0,c.markLoaded)(e)}finally{delete c.loadPromises[e]}})(),await c.loadPromises[e]}async function p(e,n){if(F(e)){if((0,c.purgeFontFamilyFromCache)(e),!e)throw new o.CodedError("ERR_FONT_FAMILY","Cannot unload an empty name");if(!t.default.unloadAsync)throw new o.UnavailabilityError('expo-font','unloadAsync');await t.default.unloadAsync(e,n)}}},1461,[215,1462,1465,1479,1480,1481,1482,1483]); +__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 p}}),e._matchesFontFaceOptions=l,e._fontFaceRuleSrcMatches=f,e._createWebFontTemplate=R;var t=r(d[0]),n=r(d[1]);function s(){if('undefined'==typeof window)return null;const t=S();return t.sheet?t.sheet:null}function o(){const t=s();if(t){const n=[...t.cssRules],s=[];for(let t=0;t=2&&('"'===s||"'"===s)&&n.endsWith(s)?n.slice(1,-1).replace(/\\(.)/g,'$1'):n}function u(t){if(null==t||''===t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const s=Number(n);return Number.isFinite(s)?s:n}function l(t,n,s){return i(t.style.fontFamily)===n&&((!s?.display||s.display===t.style.fontDisplay)&&((null==s?.weight||u(s.weight)===u(t.style.fontWeight))&&(null==s?.style||s.style===t.style.fontStyle)))}function c(t,n){return o().filter(({rule:s})=>l(s,t,n))}function f(t,n){const s=t.style.getPropertyValue('src').match(/url\((['"]?)([^'")]*)\1\)/);if(!s)return!0;let o=s[2]??'';try{o=decodeURIComponent(o)}catch{}return o===String(n)}const a={async unloadAllAsync(){if('undefined'==typeof window)return;const t=document.getElementById(w);t&&t instanceof HTMLStyleElement&&document.removeChild(t)},async unloadAsync(t,n){const o=s();if(!o)return;const i=[...c(t,n)].sort((t,n)=>n.index-t.index);for(const t of i)o.deleteRule(t.index)},getServerResources:()=>(0,n.getServerResourceDescriptors)().map(t=>{switch(t.type){case'style':return``;case'link':return``;default:return''}}).filter(Boolean),getServerResourceDescriptors:()=>(0,n.getServerResourceDescriptors)(),getLoadedFonts(){if('undefined'==typeof window)return(0,n.getLoadedServerFonts)();const t=new Set,s=[];for(const{rule:n}of o()){const o=i(n.style.fontFamily);t.has(o)||(t.add(o),s.push(o))}return s},isLoaded:(t,s={})=>'undefined'==typeof window?(0,n.isServerFontLoaded)(t):c(t,s)?.length>0,loadAsync(s,o){if('undefined'==typeof window)return(0,n.addServerFont)({name:s,css:R(s,o),resourceId:o.uri}),Promise.resolve();if(!(document.head&&'function'==typeof document.head.appendChild))throw new t.CodedError('ERR_WEB_ENVIRONMENT',"The browser's `document.head` element doesn't support injecting fonts.");const i=S();i.isConnected||document.head.appendChild(i);if(c(s,o).some(({rule:t})=>f(t,o.uri))||b(s,o),'function'!=typeof document.fonts?.load)return Promise.resolve();let u='';return'string'==typeof o.style&&$.test(o.style)&&(u+=`${o.style} `),('number'==typeof o.weight&&Number.isFinite(o.weight)||'string'==typeof o.weight&&($.test(o.weight)||F.test(o.weight)&&!o.weight.includes(' ')))&&(u+=`${o.weight} `),h(document.fonts.load(`${u}1em ${JSON.stringify(s)}`),s)}},y=12e3;function h(n,s){let o;const i=new Promise((n,i)=>{o=setTimeout(()=>{i(new t.CodedError('ERR_DOWNLOAD',`Fetching the font family "${s}" timed out after ${y}ms. Check that the font URL is reachable and served with CORS headers.`))},y)});return Promise.race([n,i]).finally(()=>clearTimeout(o)).then(()=>{})}var p='undefined'==typeof window?a:(0,t.registerWebModule)(function(){return a},'ExpoFontLoader');const w='expo-generated-fonts';function S(){const t=document.getElementById(w);if(t&&t instanceof HTMLStyleElement)return t;const n=document.createElement('style');return n.id=w,n}const $=/^[a-zA-Z_-][\w-]*$/,F=/^(1000|[1-9]\d{0,2})( (1000|[1-9]\d{0,2}))?$/;function R(t,n){const s=[`font-family:${JSON.stringify(t)}`,`src:url(${JSON.stringify(n.uri)})`];return'string'==typeof n.display&&$.test(n.display)&&s.push(`font-display:${n.display}`),('number'==typeof n.weight&&Number.isFinite(n.weight)||'string'==typeof n.weight&&($.test(n.weight)||F.test(n.weight)))&&s.push(`font-weight:${n.weight}`),'string'==typeof n.style&&$.test(n.style)&&s.push(`font-style:${n.style}`),`@font-face{${s.join(';')}}`}function b(t,n){const s=R(t,n),o=S();if(o.styleSheet){const t=o;t.styleSheet.cssText=t.styleSheet.cssText?t.styleSheet.cssText+s:s}else if(o.sheet)o.sheet.insertRule(s,o.sheet.cssRules.length);else{const t=document.createTextNode(s);o.appendChild(t)}return o}},1462,[215,1463]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.withServerContext=function(n){if('undefined'!=typeof window)return n();return s().run(new Map,n)},e.addServerFont=function(n){const t=u();t.has(n.css)||t.set(n.css,n)},e.getServerResourceDescriptors=function(){const n=[...u().values()];if(!n.length)return[];const o=n.map(({css:n})=>n).join('\n'),s=[...new Set(n.map(({resourceId:n})=>n))];return[{css:o,id:t,type:'style'},...s.map(n=>({as:'font',crossOrigin:'',href:n,rel:'preload',type:'link'}))]},e.getLoadedServerFonts=function(){const n=s().getStore();if(!n)return[];return[...new Set([...n.values()].map(({name:n})=>n))]},e.isServerFontLoaded=function(n){const t=s().getStore();if(!t)return!1;for(const o of t.values())if(o.name===n)return!0;return!1};var n=r(d[0]);const t='expo-generated-fonts';let o=null;function s(){if('undefined'!=typeof window)throw new Error('expo-font server context is server-only and cannot be used in the browser.');return o||(o=new n.AsyncLocalStorage),o}function u(){const n=s().getStore();if(!n)throw new Error("expo-font server context accessed outside of withServerContext(). Wrap your server-side font usage in withServerContext(() => /* server code */).");return n}},1463,[1464]); +__d(function(g,r,i,a,m,e,d){},1464,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAssetForSource=p,_e.loadFontFamilyAsync=async function(t,e){await Promise.all(e.map(e=>{const o=p((0,f.fontSourceFromFace)(e));return j(t,o)}))},_e.loadSingleFontAsync=j;var t,e=r(d[0]),o=r(d[1]),n=r(d[2]),u=(t=n)&&t.__esModule?t:{default:t};r(d[3]);var f=r(d[4]);function s(t){return'string'==typeof t?t||null:'number'==typeof t?s(e.Asset.fromModule(t)):'object'==typeof t&&'number'==typeof t.uri?s(t.uri):'object'==typeof t&&(t.uri||t.localUri||t.default)||null}function c(t){if('object'==typeof t&&'display'in t)return t.display??void 0}function l(t){if('object'==typeof t&&'weight'in t)return t.weight??void 0}function y(t){if('object'==typeof t&&'style'in t)return t.style??void 0}function p(t){const e=s(t),o=c(t),n=l(t),u=y(t);return e&&'string'==typeof e||b(e),{uri:e,display:o,weight:n,style:u}}function b(t){let e=typeof t;throw'object'===e&&(e=JSON.stringify(t,null,2)),new o.CodedError("ERR_FONT_SOURCE",`Expected font asset of type \`string | FontResource | Asset\` instead got: ${e}`)}function j(t,e){return('object'!=typeof e||'string'!=typeof e.uri||e.downloadAsync)&&b(e),u.default.loadAsync(t,e)}},1465,[1466,215,1462,1479,1480]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),r(d[0]);var t=r(d[1]);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[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]}})})},1466,[1467,1468,1478]); +__d(function(g,r,i,a,m,_e,d){"use strict";var e,t=r(d[0]),s=r(d[1]),u=r(d[2]),o=(e=u)&&e.__esModule?e:{default:e};if(s.IS_ENV_WITH_LOCAL_ASSETS){(o.default.setCustomSourceTransformer||u.setCustomSourceTransformer)(function(e){try{if('fileHashes'in e.asset&&e.asset.fileHashes){const s=t.Asset.fromMetadata(e.asset);return s.uri.startsWith(t.ANDROID_EMBEDDED_URL_BASE_RESOURCE)?e.resourceIdentifierWithoutScale():e.fromSource(s.downloaded?s.localUri:s.uri)}return e.defaultAsset()}catch{return e.defaultAsset()}})}},1467,[1468,1472,1477]); +__d(function(g,r,i,a,m,_e,_d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}function e(t){if(t&&t.__esModule)return t;var e={};return t&&Object.keys(t).forEach(function(s){if('default'!==s){var n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,n.get?n:{enumerable:!0,get:function(){return t[s]}})}}),e.default=t,e}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ANDROID_EMBEDDED_URL_BASE_RESOURCE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(_e,"Asset",{enumerable:!0,get:function(){return w}}),r(_d[0]);var s=t(r(_d[1])),n=r(_d[2]),h=e(r(_d[3])),o=r(_d[4]),l=e(r(_d[5])),u=r(_d[6]),d=r(_d[7]),c=t(r(_d[8]));function f(t){return!!t&&'object'==typeof t&&'uri'in t&&'string'==typeof t.uri}const y='file:///android_res/';class w{static byHash={};static byUri={};hash=null;localUri=null;width=null;height=null;downloading=!1;downloaded=!1;_downloadCallbacks=[];constructor({name:t,type:e,hash:s=null,uri:n,width:o,height:l}){this.name=t,this.type=e,this.hash=s,this.uri=n,'number'==typeof o&&(this.width=o),'number'==typeof l&&(this.height=l),s&&(this.localUri=(0,u.getLocalAssetUri)(s,e),this.localUri?.startsWith(y)?(this.uri=this.localUri,this.localUri=null):this.localUri&&(this.downloaded=!0)),t||(this.name=h.getFilename(n)),e||(this.type=h.getFileExtension(n))}static loadAsync(t){const e=Array.isArray(t)?t:[t];return Promise.all(e.map(t=>w.fromModule(t).downloadAsync()))}static fromModule(t){if('string'==typeof t)return w.fromURI(t);if(f(t)){const e=h.getFileExtension(t.uri);return new w({name:'',type:e.startsWith('.')?e.substring(1):e,hash:null,uri:t.uri,width:t.width,height:t.height})}const e=s.default.getAssetByID(t);if(!e)throw new Error(`Module "${t}" is missing from the asset registry`);if(!d.IS_ENV_WITH_LOCAL_ASSETS){const{uri:s}=(0,c.default)(t),n=new w({name:e.name,type:e.type,hash:e.hash,uri:s,width:e.width,height:e.height});return w.byHash[e.hash]=n,n}return w.fromMetadata(e)}static fromMetadata(t){const e=t.hash,s=w.byHash[e];if(s)return s;const{uri:h,hash:o}=(0,n.selectAssetSource)(t),l=new w({name:t.name,type:t.type,hash:o,uri:h,width:t.width,height:t.height});return w.byHash[e]=l,l}static fromURI(t){if(w.byUri[t])return w.byUri[t];let e='';if(t.indexOf(';base64')>-1)e=t.split(';')[0]?.split('/')[1]??'';else{const s=h.getFileExtension(t);e=s.startsWith('.')?s.substring(1):s}const s=new w({name:'',type:e,hash:null,uri:t});return w.byUri[t]=s,s}async downloadAsync(){if(this.downloaded)return this;if(this.downloading)return await new Promise((t,e)=>{this._downloadCallbacks.push({resolve:t,reject:e})}),this;this.downloading=!0;try{if(l.isImageType(this.type)){const{width:t,height:e,name:s}=await l.getImageInfoAsync(this.uri);this.width=t,this.height=e,this.name=s}else this.name=h.getFilename(this.uri);this.localUri=await(0,o.downloadAsync)(this.uri,this.hash,this.type),this.downloaded=!0,this._downloadCallbacks.forEach(({resolve:t})=>t())}catch(t){throw this._downloadCallbacks.forEach(({reject:e})=>e(t)),t}finally{this.downloading=!1,this._downloadCallbacks=[]}return this}}},1468,[215,372,1469,1473,1474,1475,1476,1472,1477]); +__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.selectAssetSource=function(e){const t=o.default.pickScale(e.scales,s.default.get()),f=e.scales.findIndex(e=>e===t),l=e.fileHashes?.[f]??e.fileHashes?.[0]??e.hash,p=e.fileUris?e.fileUris[f]??e.fileUris[0]:e.uri;if(p)return{uri:c(p),hash:l};const U=1===t?'':`@${t}x`,v=e.type?`.${encodeURIComponent(e.type)}`:'',x=`/${encodeURIComponent(e.name)}${U}${v}`,L=new URLSearchParams({platform:"web",hash:e.hash});if(/^https?:\/\//.test(e.httpServerLocation)){return{uri:e.httpServerLocation+x+'?'+L,hash:l}}const R=(0,h.getManifest2)(),S=R?.extra?.expoGo?.developer?u(R):null;if(S){const t=new URL(e.httpServerLocation+x,S);return t.searchParams.set('platform',"web"),t.searchParams.set('hash',e.hash),{uri:t.href,hash:l}}if(n.default.ExponentKernel)return{uri:`https://classic-assets.eascdn.net/~assets/${encodeURIComponent(l)}`,hash:l};return{uri:'',hash:l}},_e.resolveUri=c,r(d[0]);var t=r(d[1]),s=e(r(d[2])),n=e(r(d[3])),o=e(r(d[4])),h=r(d[5]);function u(e){const s=(0,t.getBundleOrigin)();if(s)return s;const n=e.extra?.expoGo?.debuggerHost;if(!n)return null;return(h.manifestBaseUrl?.startsWith('https://')?'https://':'http://')+n}function c(e){return h.manifestBaseUrl?new URL(e,h.manifestBaseUrl).href:e}},1469,[215,1470,339,280,1471,1472]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"getBundleUrl",{enumerable:!0,get:function(){return t.getBundleUrl}}),e.getBundleOrigin=function(n=(0,t.getBundleUrl)()){if(!n)return null;try{const{protocol:t,origin:u}=new URL(n);return'http:'===t||'https:'===t?u:null}catch{return null}};var t=r(d[0])},1470,[504]); +__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}}),r(d[0]);var e,t=r(d[1]),s=(e=t)&&e.__esModule?e:{default:e};function c(e){const t=n.pickScale(e.scales,s.default.get()),c=1===t?'':'@'+t+'x',o=e.type?`.${e.type}`:'';return e.httpServerLocation.replace(/\.\.\//g,'_')+'/'+e.name+c+o}class n{constructor(e,t,s){this.serverUrl=e||'https://expo.dev',this.jsbundleUrl=null,this.asset=s}isLoadedFromServer(){return!0}isLoadedFromFileSystem(){return!1}defaultAsset(){return this.assetServerURL()}assetServerURL(){const e=new URL(c(this.asset),this.serverUrl);return e.searchParams.set('platform',"web"),e.searchParams.set('hash',this.asset.hash),this.fromSource(e.toString().replace(e.origin,''))}fromSource(e){return{__packager_asset:!0,width:this.asset.width??void 0,height:this.asset.height??void 0,uri:e,scale:n.pickScale(this.asset.scales,s.default.get())}}static pickScale(e,t){for(const s of e)if(s>=t)return s;return e[e.length-1]||1}}},1471,[215,339]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"IS_ENV_WITH_LOCAL_ASSETS",{enumerable:!0,get:function(){return t}}),e.getLocalAssets=function(){return{}},e.getManifest2=function(){return{}},Object.defineProperty(e,"manifestBaseUrl",{enumerable:!0,get:function(){return n}});const t=!1;const n=null},1472,[]); +__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const{pathname:s,searchParams:o}=new URL(t,'https://e');return n(s)}function n(t){return t.substring(t.lastIndexOf('/')+1)}Object.defineProperty(e,'__esModule',{value:!0}),e.getFilename=t,e.getFileExtension=function(n){const s=t(n),o=s.lastIndexOf('.');return o>0?s.substring(o):''},e.getManifestBaseUrl=function(t){const n=new URL(t);let s=n.protocol;'exp:'===s?s='http:':'exps:'===s&&(s='https:');n.protocol=s;const o=n.pathname.substring(0,n.pathname.lastIndexOf('/')+1);return n.pathname=o,n.search='',n.hash='',n.protocol!==s?n.href.replace(n.protocol,s):n.href}},1473,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.downloadAsync=async function(n,t,c){return n}},1474,[]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isImageType=function(n){return/^(jpeg|jpg|gif|png|bmp|webp|heic)$/i.test(n)},e.getImageInfoAsync=function(t){if('undefined'==typeof window)return Promise.resolve({name:(0,n.getFilename)(t),width:0,height:0});return new Promise((o,u)=>{const s=new Image;s.onerror=u,s.onload=()=>{o({name:(0,n.getFilename)(t),width:s.naturalWidth,height:s.naturalHeight})},s.src=t})};var n=r(d[0])},1475,[1473]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.getLocalAssetUri=function(t,n){return null}},1476,[]); +__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}}),_e.setCustomSourceTransformer=o,Object.defineProperty(_e,"pickScale",{enumerable:!0,get:function(){return l}});var t=e(r(d[0])),n=e(r(d[1]));let u;function o(e){u=e}function c(e){if('object'==typeof e)return e;const o=t.default.getAssetByID(e);if(!o)return null;const c=new n.default('https://expo.dev',null,o);return u?u(c):c.defaultAsset()}Object.defineProperty(c,'setCustomSourceTransformer',{get:()=>o});var f=c;const{pickScale:l}=n.default},1477,[372,1471]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAssets=function(u){const[c,n]=(0,t.useState)(),[o,f]=(0,t.useState)();return(0,t.useEffect)(()=>{s.Asset.loadAsync(u).then(n).catch(f)},[]),[c,o]};var t=r(d[0]),s=r(d[1])},1478,[34,1468]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.normalizeWeight=o,e.normalizeStyle=f,e.resolveFaceWeight=l,e.resolveFaceStyle=c,e.assertValidFontFaces=function(t,s){if('string'!=typeof t||0===t.length)throw new n.CodedError("ERR_FONT_API",`Expected a non-empty string for \`fontFamily\`, instead got ${JSON.stringify(t)}. Set \`fontFamily\` to the name to use as the \`fontFamily\` style prop.`);if(!Array.isArray(s)||0===s.length)throw new n.CodedError("ERR_FONT_API",`No font faces were provided for font family "${t}". Set \`fontDefinitions\` to a non-empty array of \`FontFaceDefinition\`s.`);const y=new Set;for(const u of s){if('object'!=typeof u||null===u||null==u.path)throw new n.CodedError("ERR_FONT_API",`A face of font family "${t}" has no \`path\`. Set the face's \`path\` to a \`FontSource\`.`);const s=o(l(u)),h=f(c(u));if(void 0===s||void 0===h)continue;const F=`${s}/${h}`;if(y.has(F))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" declares two faces with weight ${s} and style "${h}". Give each face a distinct weight or style so the correct face is selected at render time.`);y.add(F)}},e.assertValidFontFamilyDefinitions=function(t){const o=new Set;for(const f of t){if('object'!=typeof f||null===f||Array.isArray(f)||!('fontFamily'in f)||!('fontDefinitions'in f))throw new n.CodedError("ERR_FONT_API",`Expected an object with \`fontFamily\` and \`fontDefinitions\`, instead got ${JSON.stringify(f)}. Set each array element to \`{ fontFamily, fontDefinitions }\`.`);const{fontFamily:t}=f;if(o.has(t))throw new n.CodedError("ERR_FONT_API",`Font family "${t}" is declared more than once in this \`loadAsync\` call. Declare each \`fontFamily\` once, with all of its faces in one \`fontDefinitions\` array.`);o.add(t)}};var t=r(d[0]),n=r(d[1]);function o(t){if(null==t)return;if('number'==typeof t)return Number.isFinite(t)?t:void 0;const n=t.trim().toLowerCase();if('normal'===n)return 400;if('bold'===n)return 700;const o=Number(n);return Number.isFinite(o)?o:void 0}function f(t){if(null==t)return;const n=t.trim().toLowerCase();return'italic'===n||'oblique'===n?'italic':'normal'}function s(n){if(!(n instanceof t.Asset||'string'==typeof n||'number'==typeof n))return n}function l(t){return t.weight??s(t.path)?.weight}function c(t){return t.style??s(t.path)?.style}},1479,[1466,215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fontSourceFromFace=function(n){const{path:o,display:s}=n,u=(0,l.resolveFaceWeight)(n),c=(0,l.resolveFaceStyle)(n);if(o instanceof t.Asset)return{uri:o.uri,...void 0!==u?{weight:u}:null,...void 0!==c?{style:c}:null,...void 0!==s?{display:s}:null};const y='string'==typeof o||'number'==typeof o?{uri:o}:o;return{...y,weight:u,style:c,display:s??y.display}};var t=r(d[0]),l=r(d[1])},1480,[1466,1479]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"loadPromises",{enumerable:!0,get:function(){return o}}),_e.markLoaded=function(e){u[e]=!0},_e.isLoadedInCache=c,_e.isLoadedNative=function(e){if(c(e))return!0;{const n=t.default.getLoadedFonts();return!!n?.length&&(n.forEach(e=>{u[e]=!0}),e in u)}},_e.purgeFontFamilyFromCache=function(e){delete u[e]},_e.purgeCache=function(){u={}};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e};const o={};let u={};function c(e){return e in u}},1481,[1462]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"withServerContext",{enumerable:!0,get:function(){return u.withServerContext}}),_e.getServerResources=function(){if(!n.default.getServerResources)throw new t.UnavailabilityError('expo-font','getServerResources');return n.default.getServerResources()},_e.getServerResourceDescriptors=function(){if(!n.default.getServerResourceDescriptors)throw new t.UnavailabilityError('expo-font','getServerResourceDescriptors');return n.default.getServerResourceDescriptors()},_e.registerStaticFont=function(e,o){if(!o)throw new t.CodedError("ERR_FONT_SOURCE",`Cannot load null or undefined font source: { "${e}": ${o} }. Expected asset of type \`FontSource\` for fontFamily of name: "${e}"`);const n=(0,s.getAssetForSource)(o);(0,s.loadSingleFontAsync)(e,n)};var e,t=r(d[0]),o=r(d[1]),n=(e=o)&&e.__esModule?e:{default:e},s=r(d[2]),u=r(d[3])},1482,[215,1462,1465,1463]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"FontDisplay",{enumerable:!0,get:function(){return t}});var t=(function(t){return t.AUTO="auto",t.SWAP="swap",t.BLOCK="block",t.FALLBACK="fallback",t.OPTIONAL="optional",t})({})},1483,[]); +__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.renderToImageAsync=async function(e,l){if(!t.default)throw new o.UnavailabilityError('expo-font','ExpoFontUtils.renderToImageAsync');return await t.default.renderToImageAsync(e,{...l,color:l?.color?(0,n.default)(l.color):void 0})};var o=r(d[0]),n=e(r(d[1])),t=e(r(d[2]))},1484,[215,54,1485]); +__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}});var t=r(d[0]);class n extends t.NativeModule{async renderToImageAsync(n,o){throw new t.UnavailabilityError('expo-font','renderToImageAsync')}}var o=(0,t.registerWebModule)(n,'ExpoFontUtils')},1485,[215]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useFonts",{enumerable:!0,get:function(){return u}});var t=r(d[0]),n=r(d[1]);function o(t){return'string'==typeof t?(0,n.isLoaded)(t):Array.isArray(t)?t.every(t=>{const o=t?.fontFamily;return'string'==typeof o&&(0,n.isLoaded)(o)}):Object.keys(t).every(t=>(0,n.isLoaded)(t))}const u='undefined'==typeof window?function(t){return(0,n.loadAsync)(t),[!0,null]}:function(u){const[s,c]=(0,t.useState)(o(u)),[f,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{let t=!0;return(0,n.loadAsync)(u).then(()=>{t&&c(!0)}).catch(n=>{t&&y(n)}),()=>{t=!1}},[]),[s,f]}},1486,[34,1461]); +__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]}})})},1487,[1488]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.preventAutoHideAsync=async function(){return!1},e.setOptions=function(n){},e.hide=function(){},e.hideAsync=async function(){}},1488,[]); +__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.CarGate=function(){const e=(0,u.useSync)(e=>'device'===e.kind&&!!e.venueId),s=(0,u.useSync)(e=>e.mode),[o,l]=(0,t.useState)(c.useSession.persist.hasHydrated()),[x,b]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{h.PITCH&&(globalThis.__pitchCarBoot=e=>b(!!e))},[]),(0,t.useEffect)(()=>{const e=c.useSession.persist.onFinishHydration(()=>l(!0));return c.useSession.persist.hasHydrated()&&l(!0),e},[]),o?h.PITCH&&x?(0,p.jsx)(T,{}):h.PITCH||e?null:s&&'connecting'!==s?(0,p.jsx)(I,{}):(0,p.jsx)(T,{}):(0,p.jsx)(r.default,{style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3}]})};var t=_r(d[0]),n=e(_r(d[1])),r=e(_r(d[2])),s=e(_r(d[3])),o=_r(d[4]),l=_r(d[5]),c=_r(d[6]),u=_r(d[7]),h=_r(d[8]),x=_r(d[9]),y=_r(d[10]),b=_r(d[11]),f=_r(d[12]),p=_r(d[13]);let j=null,w=null;async function C(e){return!e&&w&&Date.now()-w.at<6e4&&new Date(w.r.expiresAt).getTime()-Date.now()>12e4?w.r:j||(j=(0,u.carPairStart)().then(e=>(e.ok&&(w={r:e,at:Date.now()}),e)).finally(()=>{j=null}),j)}function I(){const{width:e,height:c}=(0,s.default)(),[h,j]=(0,t.useState)(null),[w,I]=(0,t.useState)('starting'),[T,k]=(0,t.useState)(''),[D,M]=(0,t.useState)(0),S=(0,t.useRef)(!1),z=(0,t.useCallback)(async(e=!0)=>{if(S.current)return;S.current=!0,I('starting'),k('');const t=await C(e);if(S.current=!1,!t.ok)return I('error'),void k(t.error);j({id:t.requestId,code:t.code,until:new Date(t.expiresAt).getTime()}),I('waiting')},[]);(0,t.useEffect)(()=>{z(!1)},[]),(0,t.useEffect)(()=>{if(!h||'waiting'!==w)return;const e=setInterval(async()=>{M(Math.max(0,Math.round((h.until-Date.now())/1e3)));('expired'===await(0,u.carPairPoll)(h.id)||Date.now()>h.until)&&I('expired')},3e3);return()=>clearInterval(e)},[h,w]);const P=Math.min(120,Math.max(64,Math.round(Math.min(e/9,c/7)))),R=h?.code??'',H=R?`${R.slice(0,3)} ${R.slice(3)}`:'\xb7\xb7\xb7 \xb7\xb7\xb7';return(0,p.jsx)(r.default,{testID:"car-pairing",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24}],children:(0,p.jsxs)(r.default,{style:{width:'100%',maxWidth:880,alignItems:'center',gap:c<820?10:16},children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:c<820?64:88}),(0,p.jsx)(o.T,{center:!0,size:28,weight:"semibold",accessibilityRole:"header",children:"The Anchorage \xb7 car screen"}),(0,p.jsx)(f.ParkedOnly,{}),'waiting'===w||'starting'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:18,colour:y.colours.muted,children:"Pair this car from your phone"}),(0,p.jsx)(r.default,{testID:"car-code",accessible:!0,accessibilityLabel:R?`Car code ${(0,b.spokenCode)(R)}`:'Making a code',accessibilityLiveRegion:"polite",style:{paddingHorizontal:32,paddingVertical:10,borderRadius:20,borderWidth:1.5,borderColor:y.colours.gold,backgroundColor:'rgba(201,162,74,0.10)'},children:(0,p.jsx)(o.T,{center:!0,size:P,weight:"bold",colour:y.colours.goldLight,style:{letterSpacing:P/8,lineHeight:1.2*P},children:H})}),R?(0,p.jsx)(o.Muted,{center:!0,children:`This code works for ${Math.max(1,Math.ceil((D||600)/60))} more minute${1===Math.ceil((D||600)/60)?'':'s'}.`}):null,(0,p.jsxs)(r.default,{testID:"car-steps",style:{gap:4,alignItems:'center'},children:[(0,p.jsx)(o.T,{center:!0,size:18,children:"1. On your phone, open CoverCharge for Managers."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"2. Go to More, then Car screen."}),(0,p.jsx)(o.T,{center:!0,size:18,children:"3. Type these 6 numbers and tap Approve. Only an owner can do this."})]}),(0,p.jsx)(r.default,{style:{flexDirection:'row',gap:12,flexWrap:'wrap',justifyContent:'center'},children:(0,p.jsx)(o.Button,{testID:"car-new-code",kind:"secondary",label:"New code",onPress:()=>{z()},style:{minHeight:64,minWidth:200}})})]}):'expired'===w?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:22,weight:"semibold",colour:y.colours.goldLight,children:"That code has run out"}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Make a new code",onPress:()=>{z()},style:{minHeight:64,minWidth:280}})]}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(o.T,{center:!0,size:20,weight:"semibold",colour:y.colours.amber,children:"Couldn\u2019t make a code"}),(0,p.jsx)(o.Muted,{center:!0,children:T}),(0,p.jsx)(o.Button,{testID:"car-new-code",label:"Try again",onPress:()=>{z()},style:{minHeight:64,minWidth:240}})]}),T&&'error'!==w?(0,p.jsx)(o.T,{center:!0,colour:y.colours.amber,children:T}):null,(0,p.jsx)(o.Muted,{center:!0,style:{maxWidth:640},children:"Don\u2019t open your personal app link in the car: it stays on your phone. Use this screen only when the car is in Park."})]})})}function T(){const[e,s]=(0,t.useState)(!1);return(0,t.useEffect)(()=>{const e=setTimeout(()=>s(!0),15e3);return()=>clearTimeout(e)},[]),(0,p.jsxs)(r.default,{testID:"car-boot",style:[n.default.absoluteFill,{backgroundColor:y.colours.bg,zIndex:1e3,alignItems:'center',justifyContent:'center',padding:24,gap:16}],children:[(0,p.jsx)(l.RestaurantLogo,{rid:x.VENUE_RID,size:72}),(0,p.jsxs)(r.default,{accessible:!0,accessibilityRole:'alert',accessibilityLiveRegion:"polite",accessibilityLabel:e?'Still connecting. Check the car has mobile data or Wi-Fi, or tap Reload.':'The Anchorage car screen. Connecting\u2026',children:[(0,p.jsx)(o.T,{center:!0,size:24,weight:"semibold",children:e?'Still connecting\u2026':'Connecting\u2026'}),e?(0,p.jsx)(o.Muted,{center:!0,children:"Check the car has mobile data or Wi-Fi, or tap Reload."}):null]}),e?(0,p.jsx)(o.Button,{testID:"car-boot-reload",label:"Reload",onPress:()=>{try{location.reload()}catch{}},style:{minHeight:64,minWidth:220}}):null]})}},1489,[34,41,102,426,794,873,1004,987,2,5,821,1490,1491,25]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CAR_BUTTONS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"MENU_BUTTON",{enumerable:!0,get:function(){return o}}),e.menuSizes=function(s,o){const l=Math.round(Math.max(300,Math.min(s-24,s>=1600?520:s>=1200?460:420))),t=Math.floor((l-40-2)/3),n=Math.floor(Math.max(84,(o-72-40)/4)),c=o>=1e3?15:13,b=Math.round(1.4*c),h=Math.max(52,Math.min(76,n-b-18,t-28));return{panelW:l,colW:t,per:n,circle:h,label:c,lineH:b,icon:Math.round(.44*h),cols:3,rows:4,head:72,pad:20}},Object.defineProperty(e,"spokenCode",{enumerable:!0,get:function(){return l}});const s=[{id:'rota',label:'Rota',short:'Rota',icon:'rota',pages:[{id:'rota',label:'Rota'}]},{id:'signoff',label:'Sign off hours',short:'Sign off',icon:'signoff',pages:[{id:'signoff',label:'Sign off hours'},{id:'timesheets',label:'Timesheets'}]},{id:'menu',label:'Menu & sold out',short:'Menu',icon:'menu',pages:[{id:'soldout',label:'Sold out'},{id:'menu',label:'Menu & allergens'},{id:'tableqr',label:'Table QR codes'}]},{id:'bookings',label:'Bookings',short:'Bookings',icon:'bookings',pages:[{id:'@bookings',label:'Bookings'},{id:'lookback',label:'Look back'}]},{id:'noshows',label:'No-shows',short:'No-shows',icon:'noshow',pages:[{id:'@noshows',label:'No-shows'}]},{id:'chat',label:'Staff chat',short:'Chat',icon:'chat',pages:[{id:'@chat',label:'Staff chat'}]},{id:'stock',label:'Stock & suppliers',short:'Stock',icon:'stock',pages:[{id:'kitchencosts',label:'Deliveries & GP'},{id:'trackedstock',label:'Tracked stock'},{id:'orderlists',label:'Order lists'},{id:'suppliers',label:'Suppliers'}]},{id:'loyalty',label:'Loyalty',short:'Loyalty',icon:'loyalty',pages:[{id:'loyalty',label:'Stamp card'}]},{id:'takings',label:'Takings & tips',short:'Takings',icon:'takings',pages:[{id:'cashup',label:'Cash up & sales'},{id:'tips',label:'Tips'},{id:'spendhead',label:'Spend per head'}]},{id:'safety',label:'Food safety',short:'Safety',icon:'safety',pages:[{id:'haccp',label:'Food safety log'},{id:'compliance',label:'Daily checks'}]},{id:'reviews',label:'Reviews',short:'Reviews',icon:'reviews',pages:[{id:'reviews',label:'Reviews'}]},{id:'assistant',label:'Assistant',short:'Assistant',icon:'assistant',pages:[{id:'assistant',label:'Assistant'}]}],o=56;const l=s=>s.split('').join(' ')},1490,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.ParkedOnly=function({small:e}){return(0,s.jsx)(n.default,{testID:"parked-only",accessible:!0,accessibilityLabel:"Parked only. Use this screen only when the car is in Park.",style:{minHeight:e?28:36,paddingHorizontal:e?8:12,borderRadius:999,borderWidth:1,borderColor:t.colours.amber,backgroundColor:'rgba(232,168,56,0.12)',alignItems:'center',justifyContent:'center',flexShrink:0},children:(0,s.jsx)(o.T,{size:e?11:13,weight:"semibold",colour:t.colours.amber,center:!0,children:"PARKED ONLY"})})},r(d[0]);var e,l=r(d[1]),n=(e=l)&&e.__esModule?e:{default:e},o=r(d[2]),t=r(d[3]),s=r(d[4])},1491,[34,102,794,821,25]); +__d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"sharedRecipeCards",{enumerable:!0,get:function(){return l}});var c=_r(d[0]),r=_r(d[1]),s=_r(d[2]),n=_r(d[3]);const o=()=>{const c=n.useSync.getState();return'live'===c.mode&&'guest'!==c.kind&&!!c.venueId};function t(c){if(o()&&!(0,n.can)(c))throw new Error('recipes.signoff'===c?'Only the Head Chef, an owner or a manager can sign off a recipe card.':'Only the head chef, managers and owners can change recipe cards.')}const l={mode:'shared',list:c=>r.localRecipeCards.list(c),get:c=>r.localRecipeCards.get(c),byMenuItem:c=>r.localRecipeCards.byMenuItem(c),subscribe:c=>r.localRecipeCards.subscribe(c),create:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.create(c,s,n)),update:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.update(c,s,n)),signOff:async(c,s)=>(t('recipes.signoff'),r.localRecipeCards.signOff(c,s)),remove:async(s,n)=>{t('recipes.edit');const o=await r.localRecipeCards.remove(s,n);return c.useGpCalc.getState().removeCardCost(s),o},savePhoto:async(c,s,n)=>(t('recipes.edit'),r.localRecipeCards.savePhoto(c,s,n)),photoSource:c=>r.localRecipeCards.photoSource(c)};function p(){const c=o()?l:r.localRecipeCards;(0,s.recipeCards)()!==c&&(0,s.setRecipeCardRepository)(c)}p(),n.useSync.subscribe((c,r)=>{c.mode===r.mode&&c.kind===r.kind&&c.venueId===r.venueId||p()})},1492,[990,883,882,987]); +__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,"STRIP",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"SYNC_CONNECTED_GREEN",{enumerable:!0,get:function(){return P}}),_e.syncTone=k,Object.defineProperty(_e,"syncToneColour",{enumerable:!0,get:function(){return z}}),Object.defineProperty(_e,"syncToneSpoken",{enumerable:!0,get:function(){return A}}),_e.SyncBadge=function(){const e=(0,p.useSync)(),[P,L]=(0,o.useState)(!1),[N,W]=(0,o.useState)(e.refused?.at??''),$=e.refused&&e.refused.at!==N?e.refused:void 0,[O,H]=(0,o.useState)(!1),[E,_]=(0,o.useState)(''),V=(0,v.useDisplaySettings)(x.VENUE_RID),M=(0,D.useScreensaverAsleep)(e=>e.asleep),[Y,U]=(0,o.useState)(()=>Date.now());(0,o.useEffect)(()=>{const e=setInterval(()=>U(Date.now()),5e3);return()=>clearInterval(e)},[]);const B='off'===e.mode&&(I.PITCH||!(0,w.isSupabaseConfigured)());if('customer'===b.APP_VARIANT||'off'===e.mode&&!B)return null;if(M)return(0,C.jsx)(y.default,{testID:"sync-strip-asleep",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:{height:S,backgroundColor:T.colours.bg}});const G=!B&&!!e.venueId&&('live'===e.mode||'offline'===e.mode)&&(e.lastServerAt?(0,l.syncStale)(e.lastServerAt,Y):'offline'===e.mode),K=e.lastServerAt?new Date(e.lastServerAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'}):'',F='live'===e.mode&&!G,Q='display'===b.APP_VARIANT,q=e.waiting??0,J=`${q} change${1===q?'':'s'} waiting to save`,X=G?'Out of sync':B?I.PITCH?'Demo \xb7 this device only':'This device only':F?q?J:e.pending?`Live \xb7 sending ${e.pending}`:'Live':'offline'===e.mode?"Offline"+(e.pending?` \xb7 ${e.pending} waiting`:''):'connecting'===e.mode?'Connecting\u2026':'unpaired'===e.mode?'Not paired':'On this device',Z=G?'disconnected':k(e.mode,B,q),ee=z(Z),te=G?`Out of sync: nothing from the shared system since ${K||'this app opened'}. Reconnecting by itself; changes made here are kept and sent when it is back.`:B?I.PITCH?'Demo mode. Nothing is shared or sent: everything you do stays in this browser.':'This copy isn\u2019t connected to a shared system. Everything stays on this device.':F?`Shared live with ${e.venueName??'your venue'}${e.lastSyncAt?`. Last update ${new Date(e.lastSyncAt).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}`:''}.`:'offline'===e.mode?'No connection. Changes are saved on this device and sent when you\u2019re back online.':'signin'===e.mode?'Not connected to the shared system. Open your personal invite link once on this device to connect.':'unpaired'===e.mode?'This display isn\u2019t paired. Use a pairing code from Managers \u2192 Displays.':'connecting'===e.mode?'Connecting to the shared system\u2026':'The shared system can\u2019t be reached, so this device is using its own data.';return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(y.default,{testID:"sync-strip",style:{height:S,paddingHorizontal:10,flexDirection:'row',gap:10,alignItems:'center',justifyContent:'flex-start',backgroundColor:T.colours.bg,borderTopWidth:1,borderTopColor:'rgba(255,255,255,0.06)'},children:[(0,C.jsxs)(h.default,{testID:"sync-badge",accessibilityRole:"button",accessibilityLabel:q&&F?`${J}, ${A(Z)}. Kept on this device and tried again by itself. Tap for details.`:`${X}, ${A(Z)}. Tap for details.`,accessibilityLiveRegion:"polite",onPress:()=>L(e=>!e),style:{flexDirection:'row',alignItems:'center',gap:6,paddingHorizontal:14,minHeight:44,borderRadius:999,backgroundColor:(0,t.soutersSurface)('rgba(16,14,11,0.92)'),borderWidth:1,borderColor:`${ee}80`,maxWidth:320},children:[(0,C.jsx)(y.default,{testID:"sync-dot",style:{width:10,height:10,borderRadius:5,backgroundColor:ee}}),(0,C.jsx)(j.T,{size:12,weight:"semibold",children:X})]}),G?(0,C.jsx)(y.default,{testID:"sync-out-banner",accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{flexShrink:1,flexDirection:'row',alignItems:'center',gap:8,paddingHorizontal:14,minHeight:40,borderRadius:10,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red},children:(0,C.jsx)(j.T,{size:13,weight:"semibold",numberOfLines:1,children:"Out of sync, reconnecting\u2026"+(K?` Last synced ${K}`:'')})}):null]}),P?(0,C.jsxs)(y.default,{testID:"sync-detail",style:{position:'absolute',left:10,bottom:52,zIndex:900,maxWidth:320,padding:12,borderRadius:12,backgroundColor:(0,t.soutersSurface)('#15120E'),borderWidth:1,borderColor:'rgba(255,255,255,0.14)',gap:4},children:[(0,C.jsx)(j.T,{size:13,children:te}),q?(0,C.jsxs)(y.default,{testID:"sync-waiting",style:{gap:4},children:[(0,C.jsxs)(j.T,{size:12,colour:T.colours.gold,children:[J,". ",1===q?'It is':'They are'," kept on this device and tried again by ",1===q?'itself':'themselves'," until the shared system takes ",1===q?'it':'them',".",e.waitingWhat?` Waiting: ${e.waitingWhat}.`:'']}),(0,C.jsx)(h.default,{testID:"sync-retry",accessibilityRole:"button",accessibilityLabel:"Try saving again now",onPress:()=>{f.mutationQueue.retryNow()},style:{minHeight:44,justifyContent:'center',alignSelf:'flex-start',paddingHorizontal:12,borderRadius:8,borderWidth:1,borderColor:T.colours.gold},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:"Try again now"})})]}):null,e.refused?(0,C.jsxs)(j.T,{size:12,colour:T.colours.red,children:["Last change not saved: ",e.refused.what,". ",e.refused.why,"."]}):null,e.message?(0,C.jsx)(j.T,{size:12,colour:T.colours.muted,children:e.message}):null,e.venueId&&(F||'offline'===e.mode)?O?(0,C.jsxs)(y.default,{style:{gap:6,marginTop:6},children:[(0,C.jsx)(j.T,{size:12,children:Q?'Unpair this display? It goes back to the pairing screen and needs a new code from Managers \u2192 Displays.':'Disconnect this device? Your changes stay on it; open your personal invite link to connect again.'}),Q&&V.pinOn?(0,C.jsx)(s.TextInput,{testID:"unpair-pin",value:E,onChangeText:_,placeholder:"Display PIN",placeholderTextColor:T.colours.muted,secureTextEntry:!0,keyboardType:"number-pad",accessibilityLabel:"Display PIN",style:{borderWidth:1,borderColor:'rgba(255,255,255,0.2)',borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:T.colours.text}}):null,(0,C.jsxs)(y.default,{style:{flexDirection:'row',gap:8},children:[(0,C.jsx)(h.default,{testID:"unpair-confirm",accessibilityRole:"button",accessibilityLabel:Q?'Yes, unpair':'Yes, disconnect',disabled:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E),onPress:()=>{H(!1),L(!1),_(''),Q?(0,p.unpairDisplay)():(0,p.disconnectStaff)()},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,backgroundColor:Q&&V.pinOn&&!(0,u.wakePinMatches)(V,E)?'rgba(255,255,255,0.08)':T.colours.red},children:(0,C.jsx)(j.T,{size:12,weight:"semibold",children:Q?'Yes, unpair':'Yes, disconnect'})}),(0,C.jsx)(h.default,{accessibilityRole:"button",accessibilityLabel:"Keep connected",onPress:()=>{H(!1),_('')},style:{paddingHorizontal:12,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:'rgba(255,255,255,0.2)'},children:(0,C.jsx)(j.T,{size:12,children:"Keep"})})]})]}):(0,C.jsx)(h.default,{testID:"unpair",accessibilityRole:"button",accessibilityLabel:Q?'Unpair this display':'Disconnect this device',onPress:()=>H(!0),style:{marginTop:6,alignSelf:'flex-start'},children:(0,C.jsx)(j.T,{size:12,colour:T.colours.gold,children:Q?'Unpair this display\u2026':'Disconnect this device\u2026'})}):null,(0,C.jsx)(c.WipeDevice,{compact:!0})]}):null,$?(0,C.jsx)(y.default,{testID:"sync-toast",style:{position:'absolute',left:16,right:16,bottom:S+R+8,zIndex:950,alignItems:'center'},pointerEvents:"box-none",children:(0,C.jsxs)(y.default,{accessibilityRole:"alert",accessibilityLiveRegion:"assertive",style:{padding:12,borderRadius:12,backgroundColor:'#3A1712',borderWidth:1,borderColor:T.colours.red,maxWidth:460,gap:8},children:[(0,C.jsx)(j.T,{size:13,children:`Not saved: ${$.what}. Why: ${$.why}. This device now shows what the shared system has, so please make the change again if it is still needed.`}),(0,C.jsx)(n.ToastClose,{testID:"sync-toast-ok",label:"Close this message",onPress:()=>W($.at),style:{minHeight:44,minWidth:44,alignSelf:'flex-end'}})]})}):null]})};var t=r(d[0]),n=r(d[1]),s=r(d[2]),o=r(d[3]),l=r(d[4]),c=r(d[5]),u=r(d[6]),h=e(r(d[7])),y=e(r(d[8])),b=r(d[9]),p=r(d[10]),f=r(d[11]),v=r(d[12]),x=r(d[13]),T=r(d[14]),j=r(d[15]),D=r(d[16]),w=r(d[17]),I=r(d[18]),C=r(d[19]);const S=48,R='display'===b.APP_VARIANT?0:57,P='#3DD68C';function k(e,t,n){return t?'disconnected':'live'===e?n?'pending':'connected':'connecting'===e?'pending':'disconnected'}const z=e=>'connected'===e?P:'pending'===e?T.colours.amber:T.colours.red,A=e=>'connected'===e?'connected':'pending'===e?'not connected yet':'not connected'},1493,[828,796,827,34,1012,1413,1030,402,102,872,987,1014,1029,5,821,794,1351,976,2,25]); +__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.VoiceHost=function(){const e=(0,g.useVoiceTarget)(),t=(0,g.useVoiceSlot)(e=>e.rect);y.PITCH&&(globalThis.__voiceExpect={app:e?.app??null,on:!!e?.on,slot:!!t});if(!e?.on||!t)return null;const n=(0,A.jsx)(U,{app:e.actions,ui:e.app},e.actions);if('undefined'!=typeof document){const{createPortal:e}=_r(d[34]);return e(n,document.body)}return n};var t=_r(d[0]),n=_r(d[1]),o=_r(d[2]),r=_r(d[3]),s=e(_r(d[4])),i=e(_r(d[5])),a=e(_r(d[6])),l=e(_r(d[7]));_r(d[8]);var c=e(_r(d[9])),u=e(_r(d[10])),h=e(_r(d[11])),p=e(_r(d[12])),f=_r(d[13]),g=_r(d[14]),y=_r(d[15]),m=_r(d[16]),w=e(m),x=_r(d[17]),b=_r(d[18]),v=_r(d[19]),k=_r(d[20]),j=_r(d[21]),T=_r(d[22]),R=_r(d[23]),C=_r(d[24]),S=_r(d[25]),I=_r(d[26]),M=_r(d[27]),E=_r(d[28]),H=_r(d[29]),z=_r(d[30]),D=_r(d[31]),P=_r(d[32]),A=_r(d[33]);const $='How many people?',W=['covers','partySize'],_=200,B=16e3,O=31e3,V='That took too long, so I stopped waiting. Hold the button and try again, or tap Type instead.',F='Something went wrong there. Hold the button and try again, or tap Type instead.',L='The microphone is blocked. Allow it in the browser\u2019s site settings, or tap the button to type instead.';function N(e,t){return'cap'===e?t?.message||H.REACHED_TEXT:'identity'===e||'app'===e?'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.':'not-allowed'===e?L:'audio-capture'===e?'I couldn\u2019t use the microphone on this device. Check nothing else is using it, then hold the button again, or tap Type instead.':'busy'===e?'Speech to text is busy just now. Hold the button and try again in a moment, or tap Type instead.':'soon'===e?'Speech to text is switching on soon. For now, tap the button to type instead.':'long'===e?'That was longer than 30 seconds. Hold the button and say it more briefly, or tap Type instead.':'I couldn\u2019t turn that into text just now. Hold the button and try again, or tap Type instead.'}function G({colour:e,size:t=34}){return(0,A.jsxs)(w.default,{width:t,height:t,viewBox:"0 0 24 24",children:[(0,A.jsx)(m.Rect,{x:"9",y:"3",width:"6",height:"11",rx:"3",fill:e}),(0,A.jsx)(m.Path,{d:"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21M8.5 21h7",stroke:e,strokeWidth:2,strokeLinecap:"round",fill:"none"})]})}const X={owner:['\u201cWalk-in fridge 3 degrees\u201d','\u201cMark the lobster sold out\u201d','\u201cHow many Covers tonight?\u201d','\u201cAdd blue roll to the Booker list\u201d'],staff:['\u201cMessage the team: running 10 minutes late\u201d','\u201cRead my messages\u201d','\u201cWhen\u2019s my next shift?\u201d','\u201cWhat are today\u2019s specials?\u201d','\u201cDoes the fish supper contain gluten?\u201d'],chef:['\u201cFreezer minus 19\u201d','\u201cMark the soup sold out\u201d','\u201cRead the orders\u201d','\u201cAdd onions to the Bidfood list\u201d'],display:['\u201cWalk-in fridge 3 degrees\u201d','\u201cRead the orders\u201d','\u201cAny room for 6 at 8?\u201d','\u201cRead the shift notes\u201d']};function U({app:e,ui:y}){const m=(0,x.useCtx)(6e4),w=(0,v.useOwner)(e=>e.staff),U=(0,M.useVoiceNav)(e=>e.go),{height:q}=(0,h.default)(),K=(0,g.useVoiceSlot)(e=>e.rect),Y=K.size,J=b.ROSTER.find(e=>'chef'===e.app),Q='display'===e?'Main Display':'chef'===e?w.find(e=>e.id===J?.id)?.name??'Head Chef':m.me,Z='display'===e?'display':'chef'===e?J?.id??'chef':m.meId,ee={rid:m.rid,today:m.today,go:(e,t)=>U?.(e,t),app:e,who:Q.replace(' (example)',''),whoId:Z,role:'owner'===y?m.role:e};(0,r.useEffect)(()=>{try{(0,R.setVenueWords)((0,C.venueKeyterms)(m.rid))}catch{}},[m.rid,w]);const[te,ne]=(0,r.useState)('idle'),[oe,re]=(0,r.useState)(''),[se,ie]=(0,r.useState)(0),[ae,le]=(0,r.useState)(null),[de,ce]=(0,r.useState)(!1),[ue,he]=(0,r.useState)(''),[pe,fe]=(0,r.useState)(!1),ge=(0,r.useRef)(null),ye=(0,r.useRef)(0),me=(0,r.useRef)(null),we=(0,r.useRef)(ee);we.current=ee;const xe=(0,r.useRef)(ae);xe.current=ae;const be=(0,r.useRef)(m.now);be.current=m.now;const ve=e=>{le(e),ne('answer')},ke=ve,je=async e=>{const t=++ye.current;let n;ne('working');try{n=await(0,T.runAction)(e.id,e.params,we.current,!0)}catch{n={status:'error',message:F}}t===ye.current&&((0,z.buzz)([20,40,20]),ke({text:'needs_confirmation'===n.status?n.preview:n.message,tone:'error'===n.status?'warn':'ok'}))},Te=()=>ke({text:'Cancelled. Nothing was changed.',tone:'info'}),Re=async(e,t,n)=>{const o=++ye.current,r={...e.params,[e.field]:t};let s;ne('working');try{s=await(0,T.runAction)(e.id,r,we.current,!1)}catch{s={status:'error',message:F}}o===ye.current&&('needs_confirmation'===s.status?ke({heard:n,text:s.preview,pending:{id:e.id,params:r,preview:s.preview}}):ke({heard:n,text:s.message,tone:'error'===s.status?'warn':'ok'}))},Ce=async(e,t)=>{const n=ye.current,o=e=>{n===ye.current&&ve(e)};try{await Se(e,o,t)}catch{o({heard:e.trim()||void 0,text:F,tone:'warn'})}},Se=async(t,n,o)=>{const r=t.trim(),s=we.current;if(!r)return void n({text:'I didn\u2019t catch that. Hold the button while you speak, then let go.',tone:'info'});const i=xe.current?.pending;if(i){const e=(0,z.yesNo)(r);if('yes'===e)return void await je(i);if('no'===e)return void Te()}const a=xe.current?.ask;if(a){const e=(0,P.coversAnswer)(r);if(e&&e<=30)return void await Re(a,e,r)}ne('working');const l=(0,T.matchIntent)(r,s.today,{app:e,rid:s.rid,whoId:s.whoId}),c=be.current;if(!H.voiceUsage.allowed(s.rid,'action'===l.kind?l.action.id:null,c))return void n({heard:r,text:H.REACHED_TEXT,tone:'info'});H.voiceUsage.record(s.rid,c);const u=H.voiceUsage.get(s.rid,c),h=u.reached?H.REACHED_TEXT:u.warn?(0,H.WARN_TEXT)(u):void 0,p=e=>n({...e,note:h});if('action'===l.kind){const e=l.action,t=e.params.filter(e=>e.required&&(void 0===l.params[e.name]||''===l.params[e.name]||'[]'===l.params[e.name]));if(1===t.length&&W.includes(t[0].name))return void p({heard:r,text:$,ask:{id:e.id,params:l.params,field:t[0].name},tone:'info'});if(t.length)return void p({heard:r,text:e.preview(l.params,s)+(/\?$/.test(e.preview(l.params,s))||/couldn|didn/.test(e.preview(l.params,s))?'':` I still need: ${t.map(e=>e.description.toLowerCase()).join('; ')}.`)+' Hold the button and try again.',tone:'warn'});const n=await(0,T.runAction)(e.id,l.params,s,!1);return void('needs_confirmation'===n.status?p({heard:r,text:n.preview,pending:{id:e.id,params:l.params,preview:n.preview}}):p({heard:r,text:n.message,tone:'error'===n.status?'warn':'ok'}))}const f=` ${r.toLowerCase()} `,g=e=>{const t=(0,T.actionById)(e);if(!t)return 0;try{return t.match?t.match(f):t.keywords.filter(e=>f.includes(e)).length}catch{return 0}},y=()=>(0,T.toolSpecs)().filter(t=>{const n=(0,T.actionById)(t.function.name);return!!n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))}).map((e,t)=>({t:e,i:t,s:g(e.function.name)})).sort((e,t)=>t.s-e.s||e.i-t.i).slice(0,60).map(e=>e.t),m=async t=>{if('call'===t.kind){const n=(0,T.actionById)(t.name);if(n&&(!n.apps||n.apps.includes(e))&&('staff'!==e||(0,T.staffMay)(n))){const e=n.params.filter(e=>e.required&&(void 0===t.args[e.name]||''===t.args[e.name]));if(1===e.length&&W.includes(e[0].name))return p({heard:r,text:$,ask:{id:n.id,params:t.args,field:e[0].name},tone:'info'}),!0;const o=await(0,T.runAction)(n.id,t.args,s,!1);return'needs_confirmation'===o.status?p({heard:r,text:o.preview,pending:{id:n.id,params:t.args,preview:o.preview}}):p({heard:r,text:o.message,tone:'error'===o.status?'warn':'ok'}),!0}}return'text'===t.kind&&(p({heard:r,text:(0,T.moneySafe)(e,s.role)?(0,T.noMoney)(t.text):t.text,tone:'info'}),!0)};if('help'===l.kind){const t=l.ids.map(S.helpById).filter(Boolean)[0];if(!(((0,I.searchHelp)(S.HELP,r,1)[0]?.score??0)>=2.5)){const n=await(0,R.askServer)(e,r,y(),o);if(await m(n))return;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(`${t.title}. ${t.body}`)?void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}.`,tone:'info'}):void p({heard:r,text:`${R.SOON_TEXT} ${X[e].slice(0,2).join(' or ')}. This guide might help: ${t.title}.`,help:l.ids,tone:'info'})}const n=`${t.title}. ${t.body}`;return(0,T.moneySafe)(e,s.role)&&(0,T.hasMoney)(n)?void p({heard:r,text:'That isn\u2019t shown here. Ask a manager in the Managers app.',tone:'info'}):void p({heard:r,text:n,help:l.ids,tone:'info'})}await m(await(0,R.askServer)(e,r,y(),o))||p({heard:r,text:R.SOON_TEXT+' '+X[e].slice(0,2).join(' or ')+'.',tone:'info'})},Ie=()=>{ge.current?.abort(),ge.current=null,me.current?.(),me.current=null,ie(0)};(0,r.useEffect)(()=>()=>{ge.current?.abort(),me.current?.()},[]);const Me=async()=>{if(!(0,z.canListen)())return ce(!0),void ke({text:(0,z.tabletWithoutMic)()?'This Display tablet app needs an update before it can use the microphone. For now, type below.':'This browser can\u2019t record speech. Type instead below.',tone:'info'});if((0,z.desktopStt)()){if(!(0,E.micExplainedFor)(y))return void fe(!0)}else{const e=await(0,z.micPermission)();if('granted'===e)(0,E.setMicExplainedFor)(y);else{if('denied'===e)return ce(!0),void ke({text:L,tone:'warn'});if(!(0,E.micExplainedFor)(y))return void fe(!0)}}if(!ze.current.holding&&!He.current)return;const t=++ye.current;(0,z.buzz)(35),re(''),le(null),ce(!1),ne('listening');if(ge.current=(0,z.listen)(re,(e,n,o)=>{if(me.current?.(),me.current=null,ie(0),ge.current=null,t===ye.current){if('not-allowed'!==n&&'service-not-allowed'!==n)return'stt-failed'===n?(ke({text:'Speech to text didn\u2019t start on this Mac. Type instead below; restarting the app usually fixes it.',tone:'warn'}),void ce(!0)):void(n?ke({text:N(n,o),tone:'cap'===n?'info':'warn'}):Ce(e,o?.receipt));ke({text:(0,z.desktopStt)()?'The microphone is blocked for CoverCharge. Open System Settings \u203a Privacy & Security \u203a Microphone, switch on CoverCharge for Mac, then try again. Or type instead.':L,tone:'warn'})}},e,ie),!ge.current)return ne('idle'),void ce(!0);if((0,z.desktopStt)()){const e=await(0,z.levelMeter)(ie);ge.current?me.current=e:e()}},Ee=()=>{ge.current&&(ne('working'),ge.current.stop(),me.current?.(),me.current=null,ie(0))},He=(0,r.useRef)(!1),ze=(0,r.useRef)({timer:0,holding:!1}),De=(0,r.useRef)(Me);De.current=Me;const Pe=(0,r.useRef)(Ee);Pe.current=Ee;const Ae=(0,r.useMemo)(()=>l.default.create({onStartShouldSetPanResponder:()=>!0,onMoveShouldSetPanResponder:()=>!0,onPanResponderTerminationRequest:()=>!1,onPanResponderGrant:()=>{const e=ze.current;e.holding=!1,(0,E.micExplainedFor)(y)&&(0,z.warmMic)(),e.timer=setTimeout(()=>{e.holding=!0,De.current()},_)},onPanResponderRelease:()=>{const e=ze.current;if(clearTimeout(e.timer),e.holding)return e.holding=!1,void Pe.current();(0,z.disarmMic)(),ce(!0),ne(e=>'idle'===e?'answer':e)},onPanResponderTerminate:()=>{const e=ze.current;clearTimeout(e.timer),e.holding&&(e.holding=!1,Pe.current())}}),[e]);(0,r.useRef)(te).current=te,(0,r.useEffect)(()=>D.useVoiceKeys.subscribe((e,t)=>{const n=e.last;if(!n||n.n===t.last?.n)return;const o=!!ge.current;'start'!==n.cmd||o?'stop'===n.cmd?(He.current=!1,o&&Pe.current()):'toggle'===n.cmd?o?(He.current=!1,Pe.current()):(He.current=!0,De.current()):'type'===n.cmd&&(ce(!0),ne(e=>'idle'===e?'answer':e)):(He.current=!0,De.current())}),[]);const $e=Y>=64,We=(0,r.useRef)(new i.default.Value(0)).current;(0,r.useEffect)(()=>{if('listening'!==te)return We.stopAnimation(),void We.setValue(0);const e=i.default.loop(i.default.timing(We,{toValue:1,duration:1100,easing:a.default.out(a.default.quad),useNativeDriver:!1}));return e.start(),()=>e.stop()},[te]);const Be='listening'===te,Oe='answer'===te&&(ae||de)||'working'===te||Be,Ve=()=>{ye.current++,Ie(),le(null),ce(!1),he(''),ne('idle')};(0,r.useEffect)(()=>{if('working'!==te&&'listening'!==te)return;const e=ye.current,t=setTimeout(()=>{e===ye.current&&('listening'!==te?(ye.current++,Ie(),ce(!0),ve({heard:oe&&!/\u2026$/.test(oe)?oe:void 0,text:V,tone:'warn'})):Pe.current())},'working'===te?B:O);return()=>clearTimeout(t)},[te]);const Fe=()=>{const e=ue.trim();e&&(he(''),re(e),ye.current++,Ce(e))},Le='fixed',Ne={top:K.y+Y+8},Ge=We.interpolate({inputRange:[0,1],outputRange:[1,1.7]}),Xe=We.interpolate({inputRange:[0,1],outputRange:[.6,0]}),Ue='warn'===ae?.tone?j.colours.amber:ae?.pending?j.colours.gold:j.colours.border;return(0,A.jsxs)(A.Fragment,{children:[Oe?(0,A.jsx)(p.default,{testID:"voice-panel",style:[{position:Le,left:12,right:12,alignItems:'flex-end',zIndex:60},Ne],pointerEvents:"box-none",children:(0,A.jsxs)(p.default,{style:{width:'100%',maxWidth:$e?720:520,backgroundColor:j.colours.surface,borderRadius:16,borderWidth:2,borderColor:Ue,padding:$e?20:14,gap:10,maxHeight:q*($e?.78:.6)},children:[(0,A.jsxs)(k.Row,{style:{justifyContent:'space-between'},children:[(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.gold,accessibilityRole:"header",children:Be?$e?'Listening\u2026 let go (or press \u2318\u21e7G) to send':'Listening\u2026 let go to send':'working'===te?'Working on it\u2026':ae?.pending?'Please confirm':'Voice assistant'}),(0,A.jsx)(n.GoldClose,{testID:"voice-close",label:"Close voice assistant",onPress:Ve,style:{marginRight:-6}})]}),(0,A.jsx)(k.T,{testID:"voice-reply-mode",size:14,colour:j.colours.muted,children:"Text replies only"}),Be?(0,A.jsxs)(p.default,{style:{gap:8},children:[(0,A.jsx)(p.default,{style:{height:10,borderRadius:5,backgroundColor:j.colours.surface2,overflow:'hidden'},children:(0,A.jsx)(p.default,{testID:"voice-level",style:{width:`${Math.round(8+92*se)}%`,height:10,backgroundColor:j.colours.ok}})}),(0,A.jsx)(k.T,{size:16,children:oe||'Say it now\u2026'})]}):null,'working'===te?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(s.default,{color:j.colours.gold}),(0,A.jsx)(k.T,{size:15,colour:j.colours.muted,children:oe?/\u2026$/.test(oe)?oe:`\u201c${oe}\u201d`:''})]}):null,'working'===te||Be?(0,A.jsx)(k.Button,{testID:"voice-stop",kind:"secondary",label:"Cancel",onPress:()=>{ye.current++,Ie(),ce(!1),ve({text:'Stopped. Nothing was changed.',tone:'info'})},style:{minHeight:48}}):null,'answer'===te&&ae?(0,A.jsxs)(u.default,{style:{maxHeight:q*($e?.55:.36)},contentContainerStyle:{gap:8},children:[ae.heard?(0,A.jsx)(p.default,{testID:"voice-heard",accessible:!0,accessibilityLabel:`I heard: ${ae.heard}`,children:(0,A.jsxs)(k.T,{size:$e?16:14,colour:j.colours.muted,children:["I heard: \u201c",ae.heard,"\u201d"]})}):null,ae.note?(0,A.jsx)(p.default,{testID:"voice-usage-note",children:(0,A.jsx)(k.T,{size:13,colour:j.colours.amber,children:ae.note})}):null,(0,A.jsx)(p.default,{testID:"voice-answer",children:(0,A.jsx)(k.T,{size:$e?24:18,weight:ae.pending?'semibold':'regular',children:ae.text})}),ae.help&&'owner'===e&&U?ae.help.slice(0,3).map(e=>{const t=(0,S.helpById)(e);return t?(0,A.jsx)(k.Button,{small:!0,kind:"secondary",label:`Open help: ${t.title}`,onPress:()=>{U('more','help'),Ve()}},e):null}):null]}):null,'answer'===te&&ae?.ask?(0,A.jsx)(p.default,{testID:"voice-how-many",style:{flexDirection:'row',flexWrap:'wrap',gap:10},children:[1,2,3,4,5,6,7,8].map(e=>(0,A.jsx)(c.default,{testID:`voice-covers-${e}`,accessibilityRole:"button",accessibilityLabel:1===e?'1 person':`${e} people`,onPress:()=>{Re(ae.ask,e)},style:{width:$e?96:72,height:$e?96:72,borderRadius:14,backgroundColor:j.colours.gold,alignItems:'center',justifyContent:'center'},children:(0,A.jsx)(k.T,{size:$e?40:32,weight:"semibold",colour:j.colours.onGold,children:e})},e))}):null,'answer'===te&&ae?.pending?(0,A.jsxs)(k.Row,{gap:10,children:[(0,A.jsx)(k.Button,{testID:"voice-confirm",kind:"success",label:"Confirm",onPress:()=>{je(ae.pending)},style:{flex:1,minHeight:56}}),(0,A.jsx)(k.Button,{testID:"voice-cancel",kind:"secondary",label:"Cancel",onPress:Te,style:{flex:1,minHeight:56}})]}):null,'answer'!==te||ae?.pending?null:(0,A.jsxs)(p.default,{style:{gap:6},children:[de||!(0,z.canListen)()?(0,A.jsxs)(k.Row,{gap:8,children:[(0,A.jsx)(o.TextInput,{testID:"voice-type",value:ue,onChangeText:he,onSubmitEditing:Fe,placeholder:"Type instead\u2026",placeholderTextColor:j.colours.muted,autoFocus:!0,returnKeyType:"send",style:{flex:1,minWidth:0,width:0,minHeight:48,borderRadius:10,borderWidth:1,borderColor:j.colours.border,backgroundColor:j.colours.surface2,color:j.colours.text,paddingHorizontal:12,fontFamily:j.fonts.regular,fontSize:16}}),(0,A.jsx)(k.Button,{testID:"voice-send",kind:"success",label:"Ask",onPress:Fe,disabled:!ue.trim()})]}):(0,A.jsx)(c.default,{accessibilityRole:"button",onPress:()=>ce(!0),children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"Type instead"})}),ae?null:(0,A.jsxs)(k.T,{size:$e?15:13,colour:j.colours.muted,children:[$e?'Hold Space (or the gold button) and speak, or press \u2318\u21e7G to start and again to send. ':'Hold the gold button and speak, for example ',$e?`For example ${X[e].join(', ')}.`:`${X[e].join(', ')}.`]}),'owner'===y&&'owner'===e?(0,A.jsx)(c.default,{testID:"voice-open-assistant",accessibilityRole:"button",onPress:()=>{Ve(),f.useAssistantUi.getState().setOpen(!0)},style:{minHeight:44,justifyContent:'center'},children:(0,A.jsx)(k.T,{size:14,colour:j.colours.gold,children:"\u2726 Open the Assistant (ideas, history and longer requests) \u203a"})}):null]})]})}):null,(0,A.jsxs)(p.default,{style:{position:Le,left:`clamp(0px, ${K.x}px, calc(100vw - ${Y}px))`,top:K.y,width:Y,height:Y,zIndex:61},pointerEvents:"box-none",children:[Be?(0,A.jsx)(i.default.View,{pointerEvents:"none",style:{position:'absolute',left:0,top:0,width:Y,height:Y,borderRadius:Y/2,borderWidth:4,borderColor:j.colours.ok,opacity:Xe,transform:[{scale:Ge}]}}):null,Be?(0,A.jsx)(p.default,{pointerEvents:"none",style:{position:'absolute',left:-6,top:-6,width:Y+12,height:Y+12,borderRadius:(Y+12)/2,borderWidth:3+Math.round(7*se),borderColor:j.colours.ok}}):null,(0,A.jsx)(p.default,{testID:"voice-button",accessible:!0,accessibilityRole:"button",accessibilityLabel:'owner'===y&&'owner'===e?'Voice assistant and Assistant. Hold to talk, let go to send. Tap to type or open the Assistant.':'Voice assistant. Hold to talk, let go to send. Tap to type instead.',...Ae.panHandlers,style:[{width:Y,height:Y,borderRadius:Y/2,alignItems:'center',justifyContent:'center',backgroundColor:Be?j.colours.ok:j.colours.gold,borderWidth:2,borderColor:j.colours.bg},{userSelect:'none',WebkitUserSelect:'none',WebkitTouchCallout:'none',touchAction:'none',cursor:'pointer'}],children:['kirkton','abbotsford'].includes(t.VENUE_RID)?(0,A.jsx)(k.T,{size:16,weight:"semibold",colour:j.colours.onGold,children:'working'===te?'Wait':'Talk'}):'working'===te?(0,A.jsx)(s.default,{color:j.colours.onGold,size:"large"}):(0,A.jsx)(G,{colour:j.colours.onGold,size:Math.round(.5*Y)})})]}),(0,A.jsx)(k.Sheet,{visible:pe,onClose:()=>{(0,E.setMicExplainedFor)(y),fe(!1)},title:"Talk to CoverCharge",testID:"voice-explain",children:(0,A.jsxs)(p.default,{style:{gap:10},children:[(0,A.jsxs)(k.T,{children:["Hold the gold button, say what you need, then let go. For example ",X[e].slice(0,3).join(', '),"."]}),(0,A.jsx)(k.T,{children:(0,z.desktopStt)()?'Your Mac will now ask once to let CoverCharge use the microphone. It only listens while you hold the button.':'Your device will now ask once to use the microphone. It only listens while you hold the button, for up to 30 seconds.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:(0,z.desktopStt)()?'On this Mac, speech is turned into text on the Mac itself, so what you say isn\u2019t sent anywhere. CoverCharge doesn\u2019t keep the audio.':'What you say while holding is sent to Grok (xAI) to be turned into text. CoverCharge doesn\u2019t keep the audio.'}),(0,A.jsx)(k.T,{size:14,colour:j.colours.muted,children:"The helper replies in text only, never aloud. Any change is shown in text first, with Confirm and Cancel buttons; you can also say \u201cyes\u201d. Orders to suppliers, messages and payments are only ever saved as drafts for the owner."}),(0,A.jsx)(k.Button,{testID:"voice-allow",kind:"success",label:"Allow microphone",onPress:async()=>{(0,E.setMicExplainedFor)(y),fe(!1);const e=!!(0,z.desktopStt)()||await(0,z.askMic)();if((0,z.desktopStt)()){(await(0,z.levelMeter)(()=>{}))()}ke(e?{text:'Ready. Now hold the button and speak.',tone:'ok'}:{text:L,tone:'warn'})}}),(0,A.jsx)(k.Button,{kind:"secondary",label:"Type instead",onPress:()=>{(0,E.setMicExplainedFor)(y),fe(!1),ce(!0),ne('answer')}})]})})]})}},1494,[5,796,827,34,385,283,364,380,236,402,295,426,102,1495,1157,2,797,1088,15,891,794,821,1496,932,1508,1504,1505,1509,1158,1510,931,1511,1507,25,277]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ASSISTANT_AVAILABLE",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"useAssistantUi",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AssistantFab",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"AssistantSheet",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"AssistantPage",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"AssistantSettings",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"AssistantPlanCard",{enumerable:!0,get:function(){return c}});const t=!1,n={getState:()=>({open:!1,setOpen:t=>{}})},u=()=>null,s=()=>null,l=()=>null,o=()=>null,c=()=>null},1495,[]); +__d(function(g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"staffMay",{enumerable:!0,get:function(){return w}}),_e.noMoney=k,Object.defineProperty(_e,"hasMoney",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_e,"moneySafe",{enumerable:!0,get:function(){return S}}),Object.defineProperty(_e,"RISK_LABEL",{enumerable:!0,get:function(){return $}}),Object.defineProperty(_e,"needsConfirm",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"demoOnly",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"PAGES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(_e,"tableName",{enumerable:!0,get:function(){return T}}),Object.defineProperty(_e,"ACTIONS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(_e,"actionById",{enumerable:!0,get:function(){return D}}),_e.toolSpecs=function(){const e=e=>({type:'integer'===e.type?'integer':'string',description:e.description,...e.enum?{enum:e.enum}:{}});return j.map(t=>({type:'function',function:{name:t.id,description:`${t.description} [${$[t.risk]}${O(t.risk)?'; the app asks the manager to confirm':''}]`,parameters:{type:'object',properties:Object.fromEntries(t.params.map(t=>[t.name,e(t)])),required:t.params.filter(e=>e.required).map(e=>e.name)}}}))},_e.runAction=async function(e,t,a,s=!1){const r=D(e);if(!r)return{status:'error',message:`Unknown action ${e}`};if(m.BOOKING_CHANGE_ACTIONS.has(e)&&!(0,b.currentCanChangeBookings)())return{status:'error',message:m.BOOKING_VIEW_ONLY};if(('staff'===a.app||'staff'===a.role)&&!w(r))return{status:'error',message:'That isn\u2019t available in the Staff app. Ask a manager.'};if(r.apps&&a.app&&!r.apps.includes(a.app))return{status:'error',message:'That isn\u2019t available in this app.'};const n=r.params.filter(e=>e.required&&(void 0===t[e.name]||''===t[e.name])).map(e=>e.name);if(n.length)return{status:'error',message:`Missing ${n.join(', ')}`};if(O(r.risk)&&!s)return{status:'needs_confirmation',preview:r.preview(t,a),risk:r.risk};if(I(r.risk)){const e=String(await r.run(t,a));return'send'===r.risk||'pay'===r.risk?(u.useDrafts.getState().add({rid:a.rid,kind:'pay'===r.risk?'payment':'message',title:r.title,lines:[r.preview(t,a)],by:a.who??'Assistant',app:a.app??'owner'}),{status:'demo_only',message:`${e} Saved as a draft for the owner to approve.`}):{status:'demo_only',message:e}}try{const e=String(await r.run(t,a));return{status:'done',message:S(a.app,a.role)?k(e):e}}catch(e){return{status:'error',message:e.message}}},_e.extract=Y,_e.matchIntent=function(e,t,a={}){const s=` ${(e=(0,h.normaliseHeard)(e)).toLowerCase()} `,r=(0,l.tokens)(e),n=/\b(how|where|what|why|can i|help)\b/.test(s);let i=null;const o=a.app??'owner';for(const e of j){if('show_me'===e.id||'open_screen'===e.id)continue;if(e.apps&&!e.apps.includes(o))continue;if('staff'===o&&!w(e))continue;let t=0;if(e.match)t=e.match(s);else for(const a of e.keywords)s.includes(a)&&(t+=a.includes(' ')?2:1);'add_rota_shift'!==e.id||s.includes('shift')||s.includes('rota')||(t=0),'add_walkin'!==e.id||/walk|seat|arriv/.test(s)||(t=0),t>(i?.s??0)&&(i={a:e,s:t})}if(i&&i.s>=1&&(!n||'look'===i.a.risk||i.s>=3))return{kind:'action',action:i.a,params:i.a.parse?i.a.parse(e,{rid:a.rid??'',today:t,app:o,whoId:a.whoId}):Y(e,t),score:i.s};if('owner'!==o){const t=(0,l.searchHelp)(p.HELP,e,3);return t.length?{kind:'help',ids:t.map(e=>e.a.id)}:{kind:'none'}}const d=s.match(/\b(?:open|show|go to|take me to)\s+(.+?)\s*$/);if(d){const e=P.find(e=>e.words.some(e=>d[1].includes(e)));if(e)return{kind:'action',action:D('open_screen'),params:{screen:e.title},score:2}}const u=(0,l.searchHelp)(p.HELP,e,3);return u.length?{kind:'help',ids:u.map(e=>e.a.id)}:(r.length,{kind:'none'})};var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),s=_r(_d[3]),r=_r(_d[4]),n=_r(_d[5]),i=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),p=_r(_d[9]),l=_r(_d[10]),u=_r(_d[11]),c=_r(_d[12]),f=_r(_d[13]),h=_r(_d[14]),m=_r(_d[15]),b=_r(_d[16]);const w=e=>!e.apps||e.apps.includes('staff'),y=/\xa3|\btips?\b|\btronc\b|\btakings\b|\bwages?\b|\bsalar(y|ies)\b|\bpay(slip|roll)?\b|\bsales\b|\brevenue\b|\bdisciplinar|\bsick(ness)? (leave|pay)\b/i;function k(e){const t=e.split(/(?<=[.!?])\s+/).filter(e=>!y.test(e));return t.length?t.join(' '):'That isn\u2019t shown here. Ask a manager in the Managers app.'}const v=e=>y.test(e),S=(e,t)=>'display'===e||'staff'===e||'staff'===t,$={look:'Looks something up',navigate:'Opens a screen',change:'Changes something in the app',draft:'Saves a DRAFT for the owner to approve (nothing is sent or bought)',send:'SENDS to someone',pay:'PAYS money',delete:'DELETES something'},O=e=>'change'===e||'draft'===e||'send'===e||'pay'===e||'delete'===e,I=e=>'send'===e||'pay'===e||'delete'===e,_=e=>(n.useOwner.getState().staff.find(t=>t.id===e)?.name??'someone').replace(' (example)',''),N=e=>{const[t,a,s]=e.split('-').map(Number);return new Date(t,a-1,s).toLocaleDateString('en-GB',{weekday:'short',day:'numeric',month:'short'})},C=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return`${String(Math.floor(t/60)).padStart(2,'0')}:${String(t%60).padStart(2,'0')}`},P=[{page:'lookback',tab:'more',title:'Look back',words:['look back','booking history']},{page:'serviceboard',tab:'more',title:'Restaurant dashboard',words:['restaurant dashboard','dashboard']},{page:'',tab:'bookings',title:'Bookings',words:['bookings','reservations','diary']},{page:'',tab:'orders',title:'Orders',words:['orders','takeaway','tickets']},{page:'rota',tab:'more',title:'Rota',words:['rota','shifts','schedule']},{page:'signoff',tab:'more',title:'Sign off hours',words:['sign off','signoff','approve hours']},{page:'hours',tab:'more',title:'Payroll hours',words:['payroll hours','payroll','hours export']},{page:'tipsday',tab:'more',title:'Tips day',words:['tips day','tips','tronc']},{page:'tableplan',tab:'more',title:'Table plan',words:['table plan','floor plan','layout']},{page:'suppliers',tab:'more',title:'Suppliers',words:['suppliers','supplier']},{page:'recipecards',tab:'more',title:'Recipe cards',words:['recipe cards','recipes']},{page:'displays',tab:'more',title:'Displays',words:['displays','tablets','pairing']},{page:'paysettings',tab:'more',title:'Pay & tips settings',words:['pay settings','pay dates','payday']},{page:'connections',tab:'more',title:'Connected accounts',words:['connected accounts','connections','accounts']},{page:'help',tab:'more',title:'Help & tutorials',words:['help','tutorials']}],A=['owner'],M=['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'],T=e=>{const t=String(e??'').replace(/^table\s+/i,'').trim(),a=M.indexOf(t.toLowerCase());return a>0?String(a):t};function E(e,t){if(!e||null==t||''===t)return'';const s=T(t),r=o.useFloor.getState().live[e]??{},n=Object.keys(r).find(e=>e.toLowerCase()===s.toLowerCase()||e.toLowerCase()===`t${s}`.toLowerCase()),i=n?r[n]:void 0;return i?i.blocked?`. ${(0,a.tableNumbers)(s)} is marked blocked`:i.dirty?`. ${(0,a.tableNumbers)(s)} still needs clearing`:i.stage?`. ${(0,a.tableNumbers)(s)} already has people seated`:'':''}const j=[...e.HISTORY_VOICE_ACTIONS,{id:'open_screen',apps:A,title:'Open a screen',description:'Navigate to a screen of the Managers app.',risk:'navigate',params:[{name:'screen',type:'string',required:!0,description:'Screen to open',enum:P.map(e=>e.title)}],keywords:['open','go to','take me','show','where is'],preview:e=>`Open ${e.screen}`,run:(e,t)=>{const a=P.find(t=>t.title===e.screen);return a?(t.go(a.tab,a.page||null),`Opened ${a.title}.`):'I couldn\u2019t find that screen.'}},{id:'show_me',apps:A,title:'Show me how',description:'Open the screen for a help guide and highlight the control to tap.',risk:'navigate',params:[{name:'guide',type:'string',required:!0,description:'Help article id',enum:p.HELP.filter(e=>e.showMe).map(e=>e.id)}],keywords:['how do i','how to','show me','where do i','help'],preview:e=>`Show me: ${(0,p.helpById)(String(e.guide))?.title??''}`,run:(e,t)=>{const a=(0,p.helpById)(String(e.guide));return a?.showMe?(t.go(a.showMe.tab,a.showMe.page??null),setTimeout(()=>d.useCoach.getState().show(a.showMe.target,a.showMe.hint),250),`Here\u2019s where: ${a.showMe.hint}`):'No guide for that.'}},{id:'add_walkin',title:'Add a walk-in',description:'Seat a walk-in party now, optionally at a table.',risk:'change',form:!0,params:[{name:'covers',type:'integer',required:!0,description:'Number of covers (1\u2013100)'},{name:'table',type:'string',description:'Table name, if known'}],keywords:['walk-in','walkin','walk in','seat','just arrived','no booking'],match:e=>/\bwalk-in\b/.test(e)&&!/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus|how long|wait|waiting|waitlist|how many|undo|remove|cancel)\b/.test(e)||/\b(seat|sit)\b/.test(e)&&/\b(just arrived|no booking)\b/.test(e)?9:/\b(just arrived|no booking)\b/.test(e)?3:/\b(seat|sit)\b/.test(e)?1:0,parse:e=>{const t={},a=(0,h.walkInCovers)(e);a&&(t.covers=a);const s=(0,h.tableSaid)(e);return s&&(t.table=s),t},preview:(e,t)=>`Seat a walk-in of ${e.covers} cover${1===Number(e.covers)?'':'s'}${e.table?` at table ${T(e.table)}`:' (table to assign)'}${E(t?.rid,e.table)}`,run:async(e,a)=>{const s=Number(e.covers);return(0,t.validParty)(s)?(await i.repo.bookings.seatWalkIn(a.rid,s,e.table?T(e.table):void 0,'Added by Assistant'),`Done: walk-in of ${s} seated${e.table?` at table ${T(e.table)}`:''}. It\u2019s in Bookings now.`):`${t.PARTY_RULE} Say for example \u201cwalk-in of 2 at table 4\u201d.`}},{id:'add_rota_shift',apps:A,title:'Add a rota shift',description:'Add a DRAFT shift for one person (staff see it only after the week is published).',risk:'change',form:!0,params:[{name:'staffId',type:'string',required:!0,description:'Staff member id'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'start',type:'time',required:!0,description:'Start hour, e.g. 17 or 17.5'},{name:'end',type:'time',required:!0,description:'End hour, e.g. 23'}],keywords:['shift','rota','put','add','schedule','on'],preview:e=>`Add a draft shift: ${_(e.staffId)}, ${e.date?N(String(e.date)):'?'}, ${C(Number(e.start))}\u2013${C(Number(e.end))}`,run:e=>{const t=Number(e.start),a=Number(e.end);if(!(e.staffId&&e.date&&a>t))return'That shift isn\u2019t complete.';const s=(0,n.leaveOn)(n.useOwner.getState().leave,String(e.staffId),String(e.date));return s?`${_(e.staffId)} has time off then (${N(s.from)} to ${N(s.to)}). Add the shift on the Rota yourself if they\u2019ve agreed to work.`:(n.useOwner.getState().addShift({staffId:String(e.staffId),date:String(e.date),start:t,end:a}),`Done: draft shift for ${_(e.staffId)} on ${N(String(e.date))} (${(0,n.weekdayOf)(String(e.date))>=0?'publish the week when ready':''}).`)}},{id:'publish_rota',apps:A,title:'Publish the rota',description:'Make the week\u2019s draft shifts visible to staff (they\u2019re told in the app).',risk:'send',params:[],keywords:['publish','send rota','release rota'],preview:()=>'Publish this week\u2019s rota so staff are notified in the Staff app',run:()=>'Nothing was published or sent. Open the Rota and tap Publish yourself when you\u2019re ready.'},{id:'message_staff',apps:A,title:'Message the team',description:'Post a message to staff chat.',risk:'send',params:[{name:'text',type:'string',required:!0,description:'Message'}],keywords:['message','tell the team','text staff','announce'],preview:e=>`Send to All staff: \u201c${e.text??''}\u201d`,run:()=>'Nothing was sent.'},{id:'pay_tips',apps:A,title:'Pay out tips',description:'Pay each person their tips share.',risk:'pay',params:[],keywords:['pay tips','pay out','transfer','pay staff'],preview:()=>'Pay out this fortnight\u2019s tips',run:()=>'CoverCharge never moves money. Use Tips day to work out the split, then pay through your payroll.'},{id:'remove_shift',apps:A,title:'Remove a shift',description:'Delete a rota shift.',risk:'delete',params:[{name:'staffId',type:'string',description:'Staff member id'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['remove shift','delete shift','cancel shift','take off'],preview:e=>`Delete ${_(e.staffId)}\u2019s shift${e.date?` on ${N(String(e.date))}`:''}`,run:()=>'Nothing was deleted. Open the Rota and tap the shift to remove it yourself.'},...c.VOICE_ACTIONS,...f.STAFF_VOICE_ACTIONS,...s.OPS_VOICE_ACTIONS,...r.GAP_VOICE_ACTIONS],D=e=>j.find(t=>t.id===e);const L={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function R(e){const t=e.match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/);if(!t)return null;let a=Number(t[1]);const s=Number(t[2]??0);return'pm'===t[3]&&a<12&&(a+=12),'am'===t[3]&&12===a&&(a=0),!t[3]&&a>=1&&a<=7&&(a+=12),a>24||s>59?null:a+s/60}function Y(e,t){const a=` ${e.toLowerCase().replace(/\u2019/g,"'")} `,s={},r=a.match(/(?:for|of|party of|x)\s+(\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/)??a.match(/\b(\d{1,2})\s*(?:covers|people|guests|pax|persons)\b/);r&&(s.covers=L[r[1]]??Number(r[1]));const i=a.match(/\btable\s+([a-z]?\d{1,3}[a-z]?)\b/);i&&(s.table=i[1].toUpperCase()),/\btomorrow\b/.test(a)?s.date=(0,n.addDays)(t,1):/\btoday\b|\btonight\b/.test(a)&&(s.date=t);const o=a.match(/\b(\d{1,2})\/(\d{1,2})(?:\/(\d{2,4}))?\b/);if(o){const e=o[3]?2===o[3].length?2e3+Number(o[3]):Number(o[3]):Number(t.slice(0,4));s.date=`${e}-${o[2].padStart(2,'0')}-${o[1].padStart(2,'0')}`}const d=x.findIndex(e=>a.includes(` ${e}`)||a.includes(` ${e.slice(0,3)} `));if(!s.date&&d>=0){const e=(0,n.weekdayOf)(t);s.date=(0,n.addDays)(t,(d-e+7)%7||7)}const p=a.match(/(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)\s*(?:-|\u2013|to|till|until)\s*(\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/);if(p){const e=R(p[1].trim()),t=R(p[2].trim());null!==e&&null!==t&&(s.start=e,s.end=t<=e?t+12:t)}const l=n.useOwner.getState().staff.filter(e=>e.active).find(e=>(0,n.staffCalls)(e).some(e=>e.length>2&&/^[a-z' -]+$/.test(e)&&new RegExp(`\\b${e}\\b`).test(a)));return l&&(s.staffId=l.id),s}},1496,[1497,1128,860,1498,1499,891,874,1029,1503,1504,1505,1501,1500,1506,1507,1027,1028]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HISTORY_VOICE_ACTIONS",{enumerable:!0,get:function(){return t}});var o=r(d[0]);const t=[{id:'look_back_bookings',title:'Look back at bookings',apps:['owner'],risk:'look',description:'Read booking times, party sizes, recorded tables and Booked covers for one exact past date. Incomplete supplementary previous booking system history; text only.',params:[{name:'date',type:'date',required:!0,description:'Exact past date YYYY-MM-DD, with explicitly supplied four-digit year'}],keywords:['look back','booked covers','historical bookings'],match:o=>/\b(open|go to)\s+(?:the\s+)?look back\b/.test(o)&&!/\b\d{4}\b/.test(o)?0:/\b(look back|booked covers|historical bookings)\b/.test(o)||/\b(bookings|reservations|covers)\b/.test(o)&&/\b\d{4}\b/.test(o)&&!/\b(add|create|new|book a|reserve|move|change|cancel)\b/.test(o)?10:0,parse:(t,s)=>({date:(0,o.exactHistoryDate)(t,s.today)}),preview:o=>`Look up Booked covers and bookings for ${o.date??'an exact past date'}`,run:async(t,s)=>{const n=(0,o.exactHistoryDate)(String(t.date??''),s.today);if(!n)return'Give an exact past date with day, month and four-digit year, for example 5 November 2025.';const{lookupBookingDay:c}=await r(d[2])(d[1],d.paths);return(0,o.bookingDayText)(await c(s.rid,n))}}]},1497,[1093,1092,1053]); +__d(function(g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"niceDay",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"appNow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"num",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"tableIn",{enumerable:!0,get:function(){return L}}),e.resolveTable=q,Object.defineProperty(e,"tokensOf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"hm",{enumerable:!0,get:function(){return x}}),e.findBooking=A,Object.defineProperty(e,"staffOf",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"findCard",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"allergenList",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"OPS_VOICE_ACTIONS",{enumerable:!0,get:function(){return ye}});var t=_r(_d[0]),n=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),o=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),d=_r(_d[7]),l=_r(_d[8]),c=_r(_d[9]),u=_r(_d[10]),b=_r(_d[11]),p=_r(_d[12]),h=_r(_d[13]),m=_r(_d[14]);const f=t=>{const[n,r,a]=t.split('-').map(Number);return new Date(n,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},y=()=>{try{return(0,i.nowFrom)(i.useStore.getState().clock)}catch{return new Date}},k=(t,n)=>n.test(t),w=t=>t.who??('display'===t.app?'Main Display':'Assistant'),v={a:1,an:1,one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,fifteen:15,twenty:20,half:.5},S=t=>null==t||''===t?void 0:'number'==typeof t?t:v[String(t).toLowerCase()]??(Number.isFinite(Number(t))?Number(t):void 0),$=['owner','staff','display'],C=['owner','staff','chef','display'],I=['staff'],N=/\btables?\s+([a-z]?\d{1,3}[a-z]?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\b/i,L=t=>{const n=t.match(N);return n?String(S(n[1])??n[1]).toUpperCase():void 0};function q(t,n){const r=String(n??'').replace(/^tables?\s+/i,'').trim();if(!r)return;const a=String(S(r)??r).toLowerCase(),o=(0,s.planOf)(t),i=[...new Set([...(o?.tables??[]).map(t=>t.name),...Object.keys(s.useFloor.getState().live[t]??{})])];return i.find(t=>t.toLowerCase()===a)??(o?.tables??[]).find(t=>(t.label??'').toLowerCase()===a)?.name??i.find(t=>t.toLowerCase().replace(/[^0-9a-z]/g,'').replace(/^t(?=\d)/,'')===a.replace(/[^0-9a-z]/g,''))}const O=(t,n)=>s.useFloor.getState().live[t]?.[n]??{},_=new Set(['the','and','for','table','booking','party','seat','seated','cancel','move','mark','finished','show','arrived','here','has','have','they','them','who','with','from','tonight','today','please','change','confirm','decline','request','people','covers','guests','their','into','onto','done','left','gone']),D=t=>t.toLowerCase().replace(/[^a-z0-9: ]/g,' ').split(/\s+/).filter(t=>t.length>2&&!_.has(t)),x=t=>{const n=t.match(/\b(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/i);if(!n)return null;let r=Number(n[1]);return'pm'===n[3]?.toLowerCase()&&r<12&&(r+=12),!n[3]&&r>=1&&r<=11&&(r+=12),`${String(r).padStart(2,'0')}:${n[2]??'00'}`};function A(t,n,r,a,o){const d=String(r??'').toLowerCase(),l=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status)&&!/walk-?in/i.test(r.name??'')),c=i.useStore.getState().bookings.filter(r=>r.restaurantId===t&&r.date===n&&a.includes(r.status));if(!d&&!o)return;const u=c.find(t=>t.ref&&d.includes(t.ref.toLowerCase()));if(u)return u;const b=D(d),p=l.filter(t=>D(t.name).some(t=>b.includes(t)));if(1===p.length)return p[0];if(o){const t=c.filter(t=>(0,s.tablesOf)(t.table).some(t=>t.toLowerCase()===o.toLowerCase())),n=p.length?t.filter(t=>p.includes(t)):t;if(n.length)return n.sort((t,n)=>('seated'===t.status?-1:1)-('seated'===n.status?-1:1))[0]}const h=/\d/.test(d.replace(N,''))?x(d.replace(N,'')):null;if(h){const t=(p.length?p:l).filter(t=>t.time===h);if(1===t.length)return t[0]}return p.length?p.sort((t,n)=>t.time.localeCompare(n.time))[0]:void 0}const j=t=>`${t.name}, ${t.partySize} at ${t.time}${t.table?`, table ${t.table}`:''}`,M=[{name:'booking',type:'string',required:!0,description:'Guest name, booking reference or time, as said'},{name:'table',type:'string',description:'Table, if said'}],T=t=>({booking:t,table:L(t)}),P='I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.';function z(t,n,r,a,i,s,d,l=""){return{id:t,apps:$,title:n,risk:'change',params:M,keywords:[],description:`${n}: today\u2019s booking by guest name, reference, table or time.${l}`,match:t=>k(t,i)?7:0,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return r?`${s}: ${j(r)}?${l}`:P},run:async(t,n)=>{const i=A(n.rid,n.today,t.booking,a,q(n.rid,t.table)??(t.table?String(t.table):void 0));return i?(await o.repo.bookings.setStatus(i.id,r),d&&await d(i,n,t),`Done: ${i.name} ${'noshow'===r?'marked as a no-show':'cancelled'===r?'cancelled':'finished'===r?'finished':r}.`):"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d."}}}const F=(t,n)=>(0,s.tablesOf)(n).forEach(n=>s.useFloor.getState().setLive(t,n,{stage:'seated',dirty:!1})),B={id:'seat_booking',apps:$,title:'Seat a booking',risk:'change',params:M,keywords:[],description:'Seat a guest with a booking today (at their booked table, or the table said). Walk-ins use add_walkin.',match:t=>!k(t,/\b(seat|sit)\b/)||k(t,/\b(walk.?in|walkin|no booking)\b/)||k(t,/\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten) (people|covers|guests)\b/)?k(t,/\b(have|has|are|is) (arrived|here)\b/)?7:0:7,parse:T,preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']),o=q(n.rid,t.table)??r?.table;if(!r)return P;const i=o?O(n.rid,(0,s.tablesOf)(o)[0]):{};return`Seat ${r.name}, ${r.partySize} at ${r.time}${o?`, at table ${o}`:' (no table yet)'}?${i.blocked?` ${(0,a.tableNumbers)(o)} is marked blocked.`:i.dirty?` ${(0,a.tableNumbers)(o)} still needs clearing.`:i.stage?` ${(0,a.tableNumbers)(o)} already has people seated.`:''}`},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const a=q(n.rid,t.table);return t.table&&!a?`Nothing changed: there\u2019s no table ${t.table} on the plan.`:(a&&a!==r.table&&await o.repo.bookings.update(r.id,{table:a}),await o.repo.bookings.setStatus(r.id,'seated'),F(n.rid,a??r.table),`Done: ${r.name} seated${a??r.table?` at table ${a??r.table}`:''}.`)}},E=z('finish_booking','Finish a table (party left)','finished',['seated'],/\b(finished|have left|has left|left|gone|paid and gone|party left|they'?re done)\b/,'Mark finished',(t,n)=>{(0,s.tablesOf)(t.table).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0}))},' The table is then marked as needing clearing.'),R=z('no_show','Mark a no-show','noshow',['confirmed','pending'],/\b(no.?show|didn'?t (turn up|show|come)|not (turned|turning) up)\b/,'Mark as a no-show'),H=z('cancel_booking','Cancel a booking','cancelled',['confirmed','pending'],/^(?!.*\b(shifts?|orders?|rota)\b).*(\bcancel+(ed)?\b.*\b(booking|reservation|table for|party)\b|\bcancel\s+(?!that\b|it\b|this\b|now\b|please\b)[a-z]{3,})/,'Cancel the booking',void 0,' The guest is not messaged from here.'),W={id:'move_booking',apps:$,title:'Move a booking to another table',risk:'change',params:[M[0],{name:'table',type:'string',required:!0,description:'New table'}],keywords:[],description:'Give a booking today a different table (seated parties move too).',match:t=>k(t,/\b(move|put|switch|change)\b/)&&k(t,/\btables?\b/)&&!k(t,/\b(shift|rota)\b/)?7:0,parse:t=>{const n=[...t.matchAll(new RegExp(N.source,'gi'))],r=n[n.length-1];return{booking:t,table:r?String(S(r[1])??r[1]).toUpperCase():void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),o=q(n.rid,t.table);return r?o?`Move ${j(r)} to table ${o}?${O(n.rid,o).stage||O(n.rid,o).blocked?` ${(0,a.tableNumbers)(o)} is not free.`:''}`:`There\u2019s no table ${t.table??''} on the plan.`:P},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending','seated']),a=q(n.rid,t.table);if(!r)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";if(!a)return'Nothing changed: I couldn\u2019t find that table on the plan.';const i=r.table;return await o.repo.bookings.update(r.id,{table:a,tableSetHere:!0}),'seated'===r.status&&((0,s.tablesOf)(i).forEach(t=>s.useFloor.getState().setLive(n.rid,t,{stage:void 0,dirty:!0})),F(n.rid,a)),`Done: ${r.name} moved to table ${a}.`}},G={id:'change_booking',apps:['owner','staff'],title:'Change a booking\u2019s time or party size',risk:'change',params:[M[0],{name:'time',type:'time',description:'New time HH:mm'},{name:'covers',type:'integer',description:'New party size'}],keywords:[],description:'Change the time or the number of people on a booking today. The guest is not messaged from here.',match:t=>k(t,/\b(change|make it|now|instead|update|actually)\b/)&&k(t,/\b(booking|reservation|party)\b/)&&k(t,/\b(\d|one|two|three|four|five|six|seven|eight|nine|ten)\b/)?6:0,parse:t=>{const n=t.toLowerCase(),r=n.match(/\b(?:to|for|now|of)\s+(\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\s*(?:people|covers|guests|pax)?\b(?!\s*[:.]\d)(?!\s*(?:am|pm|o'?clock))/),a=n.match(/\b(?:to|at)\s+(\d{1,2}(?::\d{2})?\s*(?:am|pm)|\d{1,2}:\d{2}|\d{1,2}\s*o'?clock)/);return{booking:t,covers:r&&/people|covers|guests|pax|party|for/.test(n)&&!a?.[1]?.startsWith(r[1])?S(r[1]):void 0,time:a?x(a[1].replace(/o'?clock/,''))??void 0:void 0}},preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['confirmed','pending']);return r?t.time||t.covers?`Change ${j(r)} to ${[t.covers?`${t.covers} people`:'',t.time?`${t.time}`:''].filter(Boolean).join(' at ')}? The guest is not messaged from here.`:`What should change on ${r.name}\u2019s booking? Say the new time or number of people.`:P},run:async(t,r)=>{const a=A(r.rid,r.today,t.booking,['confirmed','pending']);if(!a)return"Nothing changed. I couldn\u2019t find that booking today. Say the guest\u2019s name, for example \u201cSmith at 7\u201d.";const i=S(t.covers);if(!(null==t.covers||i&&(0,n.validParty)(i)))return`Nothing changed: ${n.PARTY_RULE}`;const s=t.time?x(String(t.time)):null;return i||s?(await o.repo.bookings.update(a.id,{...i?{partySize:i}:{},...s?{time:s}:{}}),`Done: ${a.name} is now ${i??a.partySize} at ${s??a.time}.`):'Nothing changed.'}},U={id:'decide_booking',apps:['owner'],title:'Accept or decline a booking request',risk:'change',params:[M[0],{name:'outcome',type:'string',required:!0,description:'confirmed or declined',enum:['confirmed','declined']}],keywords:[],description:'Accept or decline a booking request that is waiting (the same as the Accept / Decline buttons).',match:t=>k(t,/\b(accept|approve|confirm|decline|reject|turn down)\b/)&&k(t,/\b(booking|request|reservation)\b/)?7:0,parse:t=>({booking:t,outcome:/\b(decline|reject|turn down)\b/i.test(t)?'declined':'confirmed'}),preview:(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?`${'declined'===t.outcome?'Decline':'Accept'} the request from ${r.name}, ${r.partySize} on ${f(r.date)} at ${r.time}?`:'I couldn\u2019t find a waiting request with that name.'},run:async(t,n)=>{const r=A(n.rid,n.today,t.booking,['pending'])??i.useStore.getState().bookings.find(r=>r.restaurantId===n.rid&&'pending'===r.status&&D(r.name).some(n=>D(String(t.booking)).includes(n)));return r?(await o.repo.bookings.decide(r.id,'declined'===t.outcome?'declined':'confirmed',w(n)),`Done: ${r.name}\u2019s request ${'declined'===t.outcome?'declined':'accepted'}.`):'Nothing changed: I couldn\u2019t find a waiting request with that name.'}},V=[{name:'table',type:'string',required:!0,description:'Table name or number'}],Y={id:'table_cleared',apps:$,title:'Mark a table cleared',risk:'change',params:V,keywords:[],description:'Mark a table cleared and free (after clearing it down).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(cleared|clear(ed)? down|is clean|wiped|reset|is free|is ready|ready again)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} cleared and free?${O(n.rid,r).stage?' People are still marked as seated there.':''}`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!1,stage:void 0}),`Done: table ${r} is free.`):'Nothing changed: I couldn\u2019t find that table.'}},J={id:'table_needs_clearing',apps:$,title:'Mark a table as needing clearing',risk:'change',params:V,keywords:[],description:'Mark a table as needing clearing (dirty).',match:t=>k(t,/\btables?\b/)&&k(t,/\b(needs? (clearing|clearing down|a clean|wiping)|dirty|to be cleared)\b/)?8:0,parse:t=>({table:L(t)}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Mark table ${r} as needing clearing?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{dirty:!0,stage:void 0}),`Done: table ${r} needs clearing.`):'Nothing changed: I couldn\u2019t find that table.'}},K={id:'block_table',apps:$,title:'Block or unblock a table',risk:'change',params:[...V,{name:'blocked',type:'string',required:!0,description:'yes to block, no to unblock',enum:['yes','no']}],keywords:[],description:'Block a table (not used tonight) or unblock it.',match:t=>k(t,/\b(un.?block|block|out of use|not in use|close)\b/)&&k(t,/\btables?\b/)&&!k(t,/\barea\b/)?8:0,parse:t=>({table:L(t),blocked:/\b(un.?block|back in use|open)\b/i.test(t)?'no':'yes'}),preview:(t,n)=>{const r=q(n.rid,t.table);return r?`${'no'===t.blocked?'Unblock':'Block'} table ${r}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table);return r?(s.useFloor.getState().setLive(n.rid,r,{blocked:'no'!==t.blocked}),`Done: table ${r} ${'no'===t.blocked?'unblocked':'blocked'}.`):'Nothing changed: I couldn\u2019t find that table.'}},Q={mains:'mains',main:'mains',dessert:'dessert',desserts:'dessert',pudding:'dessert',bill:'bill',check:'bill',seated:'seated',starters:'seated'},X={id:'table_stage',apps:$,title:'Set a table\u2019s course',risk:'change',params:[...V,{name:'stage',type:'string',required:!0,description:'seated, mains, dessert or bill',enum:['seated','mains','dessert','bill']}],keywords:[],description:'Set where a seated table is: seated (starters), mains, dessert or bill.',match:t=>k(t,/\btables?\b/)&&k(t,/\b(on|at|having|wants?|asked for|ready for|onto)\b.*\b(mains?|desserts?|pudding|bill|check)\b/)?8:0,parse:t=>{const n=t.toLowerCase().match(/\b(mains?|desserts?|pudding|bill|check|starters)\b/);return{table:L(t),stage:n?Q[n[1]]:void 0}},preview:(t,n)=>{const r=q(n.rid,t.table);return r?`Set table ${r} to ${t.stage}?`:`There\u2019s no table ${t.table??''} on the plan.`},run:(t,n)=>{const r=q(n.rid,t.table),a=Q[String(t.stage??'').toLowerCase()];return r&&a?(s.useFloor.getState().setLive(n.rid,r,{stage:a,dirty:!1}),`Done: table ${r} is on ${a}.`):'Nothing changed: say the table and mains, dessert or bill.'}},Z=t=>/\b(how many|how much|what'?s|what is|what are|any|have we got|do we have|are there|is there)\b|\?\s*$/.test(t),ee=t=>/\b(roast|chickens?|beef)\b/.test(t)&&!/\b(sold out|86|off the menu|menu|dish|special|allerg)/.test(t)&&Object.values(d.useShellStore.getState().items).some(t=>t.some(t=>t.active&&(0,l.isRoastItem)(t))),te=t=>(d.useShellStore.getState().items[t]??[]).filter(t=>t.active),ne=(t,n)=>{const r=String(n??'').toLowerCase();return te(t).find(t=>[t.name,t.plural,t.key].some(t=>t&&new RegExp(`\\b${t.toLowerCase().replace(/[^a-z0-9 ]/g,'')}`).test(r)))},re={id:'shellfish_count',apps:C,title:'Shellfish count: sold, delivery or recount',risk:'change',params:[{name:'item',type:'string',required:!0,description:'Item, e.g. lobster'},{name:'qty',type:'string',required:!0,description:'How many (\xbd allowed for half items)'},{name:'mode',type:'string',required:!0,description:'sold, delivery or count',enum:['sold','delivery','count']}],keywords:[],description:'Record shellfish (or other counted stock) sold, a delivery in, or a recount (sets the count).',match:t=>!k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)&&!ee(t)||k(t,/\b(allerg|contain|chat|message|tell|text|post)/)||Z(t)||!k(t,/\b(\d+|\xbd|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|sold|deliver(ed|y)?|came in|arrived|got in|count(ed)?|recount)\b/)?0:7,parse:(n,r)=>{const a=n.toLowerCase(),o=a.match(/\b(\d+(?:\.5)?|\xbd|a half|half|an?|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|fifteen|twenty)\b/),i=/\b(deliver(ed|y)?|came in|arrived|got in|received)\b/.test(a)?'delivery':/\b(count|we have|we'?ve got|there are|recount|left in)\b/.test(a)?'count':'sold',s=ne(r.rid,a);return s&&(0,t.fishInStone)(r.rid,s)?{item:s.name,qty:(0,t.parseStoneAmount)(n),mode:i}:{item:s?.name??n,qty:o?'\xbd'===o[1]||/half/.test(o[1])?.5:S(o[1]):1,mode:i}},preview:(n,a)=>{const o=ne(a.rid,n.item);if(!o||'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'I couldn\u2019t find that item in the shellfish counts.';if((0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||!Number.isInteger(2*r))return'Use stone in half-stone steps, for example one and a half stone.';const i=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,s=(0,t.fromStone)(r,o.unit),l='count'===n.mode?s:'delivery'===n.mode?i+s:i-s;return`${o.name}: ${n.mode} ${(0,t.stoneSpeech)(r)}, after ${(0,t.stoneSpeech)((0,t.toStone)(Math.max(0,l),o.unit))}?`}const i=S(n.qty)??0,s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c='count'===n.mode?i:'delivery'===n.mode?s+i:s-i;return`${'count'===n.mode?`Set ${o.plural||o.name} to ${(0,l.fmtCount)(i)}`:'delivery'===n.mode?`Add a delivery of ${(0,l.fmtCount)(i)} ${o.plural||o.name}`:`Record ${(0,l.fmtCount)(i)} ${1===i?o.name:o.plural||o.name} sold`} (now ${(0,l.fmtCount)(s)}, after ${(0,l.fmtCount)(Math.max(0,c))})?`},run:(n,a)=>{const o=ne(a.rid,n.item);if(o&&'chef'===a.app&&!(0,r.chefCanSee)(a.rid,o))return'Nothing changed: that item is not in Head Chef stock.';if(o&&(0,t.fishInStone)(a.rid,o)){const r=(0,t.parseStoneAmount)(n.qty??'');if(null==r||r<0||r>500||!Number.isInteger(2*r))return'Nothing changed: use stone in half-stone steps.';const i=(0,t.fromStone)(r,o.unit),s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,l='count'===n.mode?i-s:'delivery'===n.mode?i:-i;return s+l<0?`Nothing changed: only ${(0,t.stoneSpeech)((0,t.toStone)(s,o.unit))} left.`:(l&&d.shellfish.append({rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner',delta:l,reason:'count'===n.mode?'count':'delivery'===n.mode?'delivery':'sold'}),`Done: ${o.name}, ${(0,t.stoneSpeech)((0,t.toStone)(s+l,o.unit))} left.`)}const i=S(n.qty);if(!o||null==i||!(i>=0)||i>500)return'Nothing changed: say the item and how many.';if('half'!==o.unit&&i%1)return`Nothing changed: ${o.plural||o.name} are counted whole.`;const s=(0,d.venueCounts)(d.useShellStore.getState(),a.rid)[o.key]??0,c={rid:a.rid,kind:o.key,by:w(a),app:a.app??'owner'};return'count'===n.mode?(i!==s&&d.shellfish.append({...c,delta:i-s,reason:'count'}),`Done: ${o.plural||o.name} counted at ${(0,l.fmtCount)(i)}.`):'delivery'===n.mode?i<=0?'Nothing changed.':(d.shellfish.append({...c,delta:i,reason:'delivery'}),`Done: ${(0,l.fmtCount)(i)} in. ${(0,l.fmtCount)(s+i)} now.`):s(k(t,/\b(lobsters?|crabs?|langoustines?|oysters?|scallops?|mussels?|shellfish|haddock|salmon|cod|hake|fish)\b/)||ee(t))&&Z(t)&&!k(t,/\b(allerg|contain)/)?8:0,parse:(t,n)=>({item:ne(n.rid,t)?.name}),preview:()=>'Shellfish left',run:(n,a)=>{const o=(0,d.venueCounts)(d.useShellStore.getState(),a.rid),i=ne(a.rid,n.item),s=(i?[i]:te(a.rid).filter(t=>!(0,l.isRoastItem)(t)||(0,l.isSundayIn)(new Date))).filter(t=>'chef'!==a.app||(0,r.chefCanSee)(a.rid,t));return s.length?s.map(n=>`${n.plural||n.name}: ${(0,t.fishInStone)(a.rid,n)?(0,t.stoneSpeech)((0,t.toStone)(o[n.key]??0,n.unit)):(0,l.fmtCount)(o[n.key]??0)} left`).join('. ')+'.':'No shellfish counts are set up here.'}},oe={accept:'acknowledged',preparing:'preparing',ready:'ready',collected:'collected'},ie=(t,n)=>{const r=String(n??'').toLowerCase(),a=i.useStore.getState().orders.filter(n=>n.restaurantId===t&&!['closed','cancelled','collected','served'].includes(n.status));return a.find(t=>t.ref&&r.includes(t.ref.toLowerCase()))??a.find(t=>{const n=r.match(/\b(?:number|no\.?|order)\s*(\d{1,4})\b/);return!!n&&t.ref.replace(/\D/g,'').endsWith(n[1])})??(()=>{const t=a.filter(t=>D(t.customerName??'').some(t=>D(r).includes(t)));return 1===t.length?t[0]:void 0})()},se={id:'order_status',apps:C,title:'Move an order on: accept, preparing, ready or collected',risk:'change',params:[{name:'order',type:'string',required:!0,description:'Order reference, number or customer name'},{name:'status',type:'string',required:!0,description:'accept, preparing, ready or collected',enum:['accept','preparing','ready','collected']}],keywords:[],description:'Accept a takeaway or table order, or mark it preparing, ready or collected (the same as the order buttons).',match:t=>k(t,/\b(orders?|takeaways?|collection|ticket)\b/)&&k(t,/\b(accept|ready|collected|picked up|preparing|start(ed)?|on it)\b/)&&!k(t,/\b(read|any|list|what)\b/)?7:0,parse:t=>{const n=t.toLowerCase();return{order:t,status:/\baccept/.test(n)?'accept':/\b(collected|picked up)\b/.test(n)?'collected':/\bready\b/.test(n)?'ready':'preparing'}},preview:(t,n)=>{const r=ie(n.rid,t.order);return r?`Mark order ${r.ref} for ${r.customerName} as ${'accept'===t.status?'accepted':t.status}?`:'I couldn\u2019t find that order. Say the order number or the name.'},run:async(t,n)=>{const r=ie(n.rid,t.order),a=oe[String(t.status)];if(!r||!a)return'Nothing changed: I couldn\u2019t find that order.';if('acknowledged'===a){return await o.repo.orders.accept(r.id,w(n))?`Done: order ${r.ref} accepted.`:`Order ${r.ref} was already accepted.`}return await o.repo.orders.setStatus(r.id,a,w(n)),`Done: order ${r.ref} is ${a}.`}},de={id:'order_list_add',apps:C,title:'Add to an order list',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What we need'},{name:'qty',type:'integer',description:'How many (default 1)'},{name:'list',type:'string',description:'Which list (supplier), if said'}],keywords:[],description:'Add an item to an order list (or add to the quantity if it is already on it). Nothing is ordered from the supplier.',match:t=>k(t,/\b(add|put)\b.*\b(to|on)\b.*\b(order|shopping|cash and carry|list)\b|\bwe need (more )?\w+/)&&!k(t,/\b(chat|message|tell|text|post|shift|rota)\b/)?6:0,parse:t=>{const n=t.toLowerCase().replace(/[.?!]+$/,'').match(/\b(?:add|put|need(?: more)?)\s+(?:(\d+|an?|one|two|three|four|five|six|seven|eight|nine|ten|twelve|twenty)\s+)?(.+?)(?:\s+(?:to|on)\s+(?:the\s+)?(.+?)(?:\s+(?:order|list|order list))*)?$/);return n?{qty:S(n[1])??1,item:n[2].replace(/^(?:some|more)\s+/,'').trim(),list:n[3]?.replace(/\b(order|list|shopping)\b/g,'').trim()||void 0}:{item:t}},preview:(t,n)=>{const r=c.useOrderLists.getState().lists.filter(t=>t.rid===n.rid),a=String(t.list??'').toLowerCase(),o=a&&r.find(t=>t.name.toLowerCase().includes(a))||r[0];return o?`Add ${t.qty??1} ${t.item} to ${o.name}? Nothing is ordered from the supplier.`:'There are no order lists yet. Set one up in Order lists.'},run:(t,n)=>{const r=c.useOrderLists.getState(),a=r.lists.filter(t=>t.rid===n.rid),o=String(t.list??'').toLowerCase(),i=o&&a.find(t=>t.name.toLowerCase().includes(o))||a[0],s=String(t.item??'').trim().slice(0,60),d=Math.max(1,Math.min(99,Math.round(S(t.qty)??1)));if(!i||s.length<2)return'Nothing changed: say what we need.';const l={id:n.whoId??'assistant',name:w(n)},u=r.items.find(t=>t.rid===n.rid&&t.listId===i.id&&'open'===t.status&&t.name.toLowerCase()===s.toLowerCase());return u?(r.bump(u.id,d,l),`Done: added ${d} more ${s} on ${i.name}.`):(r.addItem(n.rid,{listId:i.id,name:s,qty:d,unit:'',addedBy:l.id,addedByName:l.name}),`Done: ${d} ${s} added to ${i.name}.`)}},le={in:'Clock you in',out:'Clock you out',break_start:'Start your break',break_end:'End your break'};function ce(t,n,r){return{id:t,apps:I,title:le[n].replace('you','me').replace('your','my'),risk:'change',params:[],keywords:[],description:`${le[n]} now (only for the person signed in; the same location check as the Clock tab).`,match:t=>k(t,r)?8:0,preview:()=>`${le[n]} now?`,run:async(t,r)=>{if(!r.whoId)return'Sign in to the Staff app first.';const a=y().toISOString(),o=await(0,b.clockAction)(n,{rid:r.rid,staffId:r.whoId,date:r.today,at:a});return o.ok?'Done: '+{in:'clocked in',out:'clocked out',break_start:'break started',break_end:'break ended'}[n]+` at ${new Date(a).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})}.`+(o.warn?' '+o.warn:''):'Nothing changed: '+o.message}}}const ue=ce('clock_in','in',/\bclock (me )?in\b|\bclocking in\b|\bstart(ing)? my shift\b/),be=ce('clock_out','out',/\bclock (me )?out\b|\bclocking out\b|\b(finish|end)(ing)? my shift\b/),pe=ce('break_start','break_start',/\b(start|starting|taking|take|going on|begin)( my| a)? break\b|\bon (my )?break now\b/),he=ce('break_end','break_end',/\b(end|ending|finish|finished|back from)( my| a| the)? break\b|\bback from break\b/),me=t=>{const n=u.useOwner.getState().staff,r=String(t??'').toLowerCase();return n.find(n=>n.id===t)?.id??n.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>D(r).includes(t)))?.id},ge=(t,n)=>{if(!(0,p.hasRecipeCards)())return;const r=D(String(n??''));let a;for(const n of(0,p.recipeCards)().list(t)){const t=D(n.dish).filter(t=>r.includes(t)).length;t&&t>(a?.s??0)&&(a={c:n,s:t})}return a?.c},fe=t=>{const n=m.ALLERGENS.filter(n=>t[n.id]).map(n=>('may'===t[n.id]?'may contain ':'')+n.label.toLowerCase());return n.length?n.join(', '):'none of the 14 allergens'},ye=[B,E,R,H,W,G,U,Y,J,K,X,re,ae,se,de,ue,be,pe,he,{id:'decide_leave',apps:['owner'],title:'Approve or decline a holiday request',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff member id or first name'},{name:'outcome',type:'string',required:!0,description:'approved or declined',enum:['approved','declined']}],keywords:[],description:'Approve or decline someone\u2019s waiting holiday (leave) request.',match:t=>k(t,/\b(approve|accept|decline|reject|ok|okay)\b/)&&k(t,/\b(holiday|leave|time off|day off|days off)\b/)?7:0,parse:t=>{const n=t.toLowerCase(),r=u.useOwner.getState().staff.find(t=>t.active&&D(t.name.replace(' (example)','')).some(t=>new RegExp(`\\b${t}\\b`).test(n)));return{staffId:r?.id,outcome:/\b(decline|reject|refuse)\b/.test(n)?'declined':'approved'}},preview:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status),o=n.staff.find(t=>t.id===r)?.name.replace(' (example)','');return a?`${'declined'===t.outcome?'Decline':'Approve'} ${o}\u2019s holiday, ${f(a.from)}${a.to!==a.from?` to ${f(a.to)}`:''}?`:`There\u2019s no waiting holiday request${o?` from ${o}`:''}.`},run:t=>{const n=u.useOwner.getState(),r=me(t.staffId),a=n.leave.find(t=>t.staffId===r&&'pending'===t.status);return a?(n.setLeave(a.id,'declined'===t.outcome?'declined':'approved'),`Done: holiday ${'declined'===t.outcome?'declined':'approved'}.`):'Nothing changed: no waiting request found.'}},{id:'allergen_signoff',apps:['chef'],title:'Sign off a dish\u2019s allergens',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'}],keywords:[],description:'Head chef signs off a recipe card (its allergens). The allergens are read back first.',match:t=>k(t,/\bsign(ed)?.?off\b|\bapprove\b.*\b(card|recipe|allergens?)\b/)?8:0,parse:t=>({dish:t}),preview:(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?`${r.dish} can\u2019t be signed off yet: ${a}`:`Sign off ${r.dish}? Allergens: ${fe(r.allergens)}.`},run:async(t,n)=>{const r=ge(n.rid,t.dish);if(!r)return'Nothing changed: I couldn\u2019t find that recipe card.';const a=(0,h.signOffBlock)(r);return a?'Nothing changed: '+a:(await(0,p.recipeCards)().signOff(r.id,{name:w(n),role:'head-chef'}),`Done: ${r.dish} signed off.`)}}]},1498,[984,1128,835,860,874,831,1029,983,985,1040,891,1095,882,863,861]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.spokenDate=j,Object.defineProperty(_e,"GAP_VOICE_ACTIONS",{enumerable:!0,get:function(){return be}});var e=_r(_d[0]),t=_r(_d[1]),a=_r(_d[2]),r=_r(_d[3]),n=_r(_d[4]),i=_r(_d[5]),s=_r(_d[6]),o=_r(_d[7]),d=_r(_d[8]),c=_r(_d[9]),h=_r(_d[10]),p=_r(_d[11]),l=_r(_d[12]),f=_r(_d[13]),u=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),y=_r(_d[17]),b=_r(_d[18]),w=_r(_d[19]),k=_r(_d[20]),S=_r(_d[21]),$=_r(_d[22]);const v=(e,t)=>t.test(e),I=e=>e.who??('display'===e.app?'Main Display':'Assistant'),N=e=>(e??'').replace(' (example)',''),A=e=>String(e).padStart(2,'0'),D=()=>{const e=(0,$.appNow)();return`${A(e.getHours())}:${A(e.getMinutes())}`},C=['owner','staff','display'],T=['owner'],q=['staff','owner'],O=['owner','chef'],_=e=>`\u201c${e}\u201d`,x=(e,t)=>n.useOwner.getState().sys(e,t,(0,$.appNow)().toISOString()),M=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'],R=e=>`${A(Math.floor(e))}:${A(Math.round(e%1*60))}`,L=['january','february','march','april','may','june','july','august','september','october','november','december'];function j(e,t){const a=e.toLowerCase(),r=a.match(new RegExp(`\\b(\\d{1,2})(?:st|nd|rd|th)?(?:\\s+of)?\\s+(${L.join('|')})\\b`))??a.match(new RegExp(`\\b(${L.join('|')})\\s+(\\d{1,2})(?:st|nd|rd|th)?\\b`));if(r){const e=Number(/\d/.test(r[1])?r[1]:r[2]),a=L.indexOf(/\d/.test(r[1])?r[2]:r[1]);let n=Number(t.slice(0,4));return`${n}-${A(a+1)}-${A(e)}`e.active)){const r=[N(e.name).split(' ')[0],e.nickname].filter(Boolean).map(e=>e.toLowerCase()),n=Math.min(...r.map(e=>{const a=t.match(new RegExp(`\\b${e.replace(/[^a-z']/g,'')}\\b`));return a?.index??1/0}));n<1/0&&a.push({s:e,at:n})}return a.sort((e,t)=>e.at-t.at).map(e=>e.s)}const F=e=>n.useOwner.getState().staff.find(t=>t.id===e),E=e=>F(e)??W(String(e??''))[0],U=e=>a.useStore.getState().waitlist.filter(t=>t.restaurantId===e&&('waiting'===t.status||'notified'===t.status)).sort((e,t)=>e.number-t.number);function z(e,t){const a=String(t??'').toLowerCase(),r=U(e);if(!r.length)return;const n=a.match(/(?:#|number|no\.?)\s*(\d{1,3})\b/);if(n)return r.find(e=>e.number===Number(n[1]));const i=(0,$.tokensOf)(a).filter(e=>!['waitlist','wait','list','off','remove','told','ready','next'].includes(e)),s=r.filter(e=>(0,$.tokensOf)(e.name).some(e=>i.includes(e)));return s.length?s[0]:/\b(next|first)\b/.test(a)||1===r.length?r[0]:void 0}const Y=e=>`waitlist number ${e.number}, ${e.name}, party of ${e.partySize}`;function B(e,t){const n=a.useStore.getState(),i=n.restaurants.find(t=>t.id===e);if(!i)return;const s=(0,$.appNow)(),o=(0,l.ymdOf)(s),d=r.useFloor.getState(),c=d.plans[e]??(0,r.seedPlan)(e),h=n.bookings.filter(t=>t.restaurantId===e),p=(0,w.closedAreasAt)(w.useBlocks.getState().blocks,e,o,D()),f=(0,b.floorView)(c,h,n.orders.filter(t=>t.restaurantId===e),d.live[e]??{},s,i.settings.turnMins,p);return(0,b.suggestTable)(c,h.filter(e=>e.date===o),f,t,s,(0,b.turnFor)(t,i.settings.turnMins))?.table}const P=/\bwait ?(ing )?list\b|\bwaiting\b/,H=[{name:'who',type:'string',required:!0,description:'Waitlist number or name, as said (or "next")'}],K={id:'waitlist_seat',apps:C,title:'Seat someone from the waitlist',risk:'change',params:[...H,{name:'table',type:'string',required:!1,description:'Table (else the best free table)'}],keywords:[],description:'Seat a waiting party from the waitlist at a table (the suggested table unless one is said), like the Seat button.',match:e=>v(e,P)&&v(e,/\bseat\b|\bsit\b/)?9:0,parse:e=>({who:e,table:(0,$.tableIn)(e)}),preview:(e,t)=>{const a=z(t.rid,e.who);if(!a)return'I couldn\u2019t find that party on the waitlist. Say their number or name.';const r=(0,$.resolveTable)(t.rid,e.table)??B(t.rid,a.partySize);return r?`Seat ${Y(a)}, at table ${r}?`:`There\u2019s no free table for ${a.partySize} right now. Say a table to seat them anyway.`},run:async(e,a)=>{const n=z(a.rid,e.who);if(!n)return'Nothing changed: I couldn\u2019t find that party on the waitlist.';const i=(0,$.resolveTable)(a.rid,e.table)??B(a.rid,n.partySize);return i?(await t.repo.waitlist.setStatus(n.id,'seated'),await t.repo.bookings.seatWalkIn(a.rid,n.partySize,i,`From waitlist #${n.number}`),(0,r.tablesOf)(i).forEach(e=>r.useFloor.getState().setLive(a.rid,e,{stage:'seated',dirty:!1})),`Done: waitlist number ${n.number} seated at table ${i}.`):'Nothing changed: there\u2019s no free table for them. Say a table.'}};function V(e,t){if(!e.whoId)return;const a=n.useOwner.getState().shifts.filter(t=>t.staffId===e.whoId&&!1!==t.published&&t.date>=e.today).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start),r=j(String(t??''),e.today);return r?a.find(e=>e.date===r):a[0]}const G=e=>`${(0,$.niceDay)(e.date)}, ${R(e.start)} to ${R(e.end)}`,Q=/\b(approve|accept|decline|reject|okay|ok)\b/,Z='I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d.';function J(e,t){const a=e.toLowerCase(),r=a.match(/\bfrom\s+(.+?)\s+(?:to|until|till)\s+(.+)$/);if(r){const e=j(r[1],t),a=j(r[2],t)??e;return{from:e,to:a&&e&&a'open'===e.status&&(!r||e.kind===r)),s=W(String(e??'')).map(e=>e.id);return s.length?i.find(e=>s.includes(e.fromId)&&(!e.toId||1===s.length||s.includes(e.toId)))??i.find(e=>s.includes(e.fromId)||e.toId&&s.includes(e.toId)):1===i.length?i[0]:void 0}const ee=(t,a)=>'chef'!==a?.app||(0,e.chefCanSee)(a.rid,t)&&(0,e.chefCanSee)(a.rid,i.useSafety.getState().points.find(e=>e.id===t.pointId)),te=(e,t)=>{const a=i.useSafety.getState().entries.filter(a=>(0,l.ymdOf)(new Date(a.at))===e&&ee(a,t));return{n:a.length,bad:a.filter(e=>!e.ok).length,fixed:a.filter(e=>!e.ok&&e.corrective).length}},ae=/\b(food safety|safety diary|diary|haccp|safe methods|sfbb)\b/;function re(e,t){const a=(0,m.weekStart)(new Date(e+'T12:00:00')),r=new Date(a+'T00:00:00').getTime(),n=r+6048e5,s=i.useSafety.getState().entries.filter(e=>{const a=new Date(e.at).getTime();return a>=r&&a!e.ok).length,actions:s.filter(e=>!e.ok&&e.corrective).length,daysSigned:o.filter(e=>{const t=new Date(e.date+'T00:00:00').getTime();return t>=r&&te.test(t))?.[1]??'Other',location:s?s[1].replace(/^the /,''):'Not said',firstAid:o?o[1]:'',what:e.trim().replace(/^(?:please\s+)?(?:record|log|report|add|write up|put in the accident book)\s+(?:an?\s+)?(?:accident|near miss|injury)?\s*(?:in the accident book)?\s*[:,-]?\s*/i,'').replace(/^\w/,e=>e.toUpperCase())||e.trim()}}function se(e,t){const a=(0,d.ukClock)((0,$.appNow)()),r=new Date(`${a.ymd}T12:00:00Z`).getUTCDay(),n=(0,$.tokensOf)(String(t??'')).filter(e=>!['tick','ticked','task','off','mark','done','did','finished','completed','ive','i\u2019ve','list'].includes(e)),i=e=>(0,$.tokensOf)(e).filter(e=>n.some(t=>t===e||t.length>3&&e.startsWith(t.slice(0,4)))).length,h=e.whoId?(0,o.tasksFor)((0,s.tasksOf)(e.rid,e.whoId),r):[];let p=h.map(e=>({t:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.t;const l='chef'===e.app?['all','kitchen']:'staff'===e.app?['all','foh']:['all','foh','kitchen'],f=p?void 0:c.useReminders.getState().reminders.filter(t=>t.rid===e.rid&&!t.removed&&!t.paused&&t.days.includes(a.dow)&&l.includes(t.audience)).map(e=>({r:e,s:i(e.text)})).filter(e=>e.s).sort((e,t)=>t.s-e.s)[0]?.r;return{ymd:a.ymd,task:p,rem:f}}const oe=e=>a.useStore.getState().menu.filter(t=>t.restaurantId===e);function de(e,t){const a=(0,$.tokensOf)(String(t??''));let r;for(const t of oe(e)){const e=(0,$.tokensOf)(t.name).filter(e=>a.includes(e)).length;e&&e>(r?.s??0)&&(r={m:t,s:e})}return r?.m}const ce=e=>{const t=e.match(/\xa3\s?(\d+(?:\.\d{1,2})?)|\b(\d+(?:\.\d{2}))\b|\b(\d+)\s*(?:pounds|quid)(?:\s*(\d{1,2}))?/i);if(t)return t[1]?Number(t[1]):t[2]?Number(t[2]):Number(t[3])+(t[4]?Number(t[4])/100:0)},he={gram:'g',grams:'g',g:'g',kilo:'kg',kilos:'kg',kg:'kg',ml:'ml',millilitres:'ml',litre:'l',litres:'l',l:'l',tablespoon:'tbsp',tablespoons:'tbsp',tbsp:'tbsp',teaspoon:'tsp',teaspoons:'tsp',tsp:'tsp',pinch:'pinch',slice:'slice',slices:'slices',whole:'whole'};function pe(e){const t=e.match(/\badd\s+(\d+(?:\.\d+)?|a|an|one|two|three|four|five|six|half)\s*(grams?|g|kilos?|kg|ml|millilitres|litres?|l|tablespoons?|tbsp|teaspoons?|tsp|pinch|slices?|whole)?\s+(?:of\s+)?(.+?)\s+(?:to|into|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*$/i);if(t)return{qty:String((0,$.num)(t[1])??t[1]),unit:t[2]?he[t[2].toLowerCase()]??t[2]:'',name:t[3].trim(),dish:t[4]}}const le={in:'Clock {n} in',out:'Clock {n} out',break_start:'Start a break for {n}',break_end:'End {n}\u2019s break'},fe=e=>null==e?'not entered':`\xa3${e.toLocaleString('en-GB',{minimumFractionDigits:2,maximumFractionDigits:2})}`,ue=e=>'owner'===e.app&&'staff'!==e.role,me=['sunday','monday','tuesday','wednesday','thursday','friday','saturday'];function ge(e){if(/\bweekdays?\b/.test(e))return[1,2,3,4,5];if(/\bweekends?\b/.test(e))return[0,6];const t=me.map((t,a)=>new RegExp(`\\b${t}s?\\b`).test(e)?a:-1).filter(e=>e>=0);return t.length?t:[0,1,2,3,4,5,6]}const ye={all:'everyone on shift',foh:'front of house',kitchen:'the kitchen'},be=[K,{id:'waitlist_remove',apps:C,title:'Take someone off the waitlist',risk:'change',params:H,keywords:[],description:'Take a party off the waitlist (they left or no longer need a table), like the Remove button. It stays in the records.',match:e=>v(e,P)&&v(e,/\b(remove|take .*off|cross .*off|strike .*off|gave up|have left|has left|left|gone)\b/)&&!v(e,/\b(seat|told|ready)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Take ${Y(a)}, off the waitlist?`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,a)=>{const r=z(a.rid,e.who);return r?(await t.repo.waitlist.setStatus(r.id,'removed'),`Done: number ${r.number} is off the waitlist.`):'Nothing changed: I couldn\u2019t find that party.'}},{id:'waitlist_told',apps:C,title:'Mark a waiting party as told their table is ready',risk:'change',params:H,keywords:[],description:'Record that a waiting party has been told their table is ready, like the Mark as told button. No text is sent.',match:e=>v(e,P)&&v(e,/\b(told|tell|let .* know|notif|ready|called)\b/)&&!v(e,/\b(seat|remove)\b/)?9:0,parse:e=>({who:e}),preview:(e,t)=>{const a=z(t.rid,e.who);return a?`Mark ${Y(a)}, as told their table is ready? No text is sent from here.`:'I couldn\u2019t find that party on the waitlist.'},run:async(e,n)=>{const i=z(n.rid,e.who);if(!i)return'Nothing changed: I couldn\u2019t find that party.';const s=a.useStore.getState().restaurants.find(e=>e.id===n.rid);return r.useFloor.getState().logSms(n.rid,(0,$.appNow)().toISOString(),`#${i.number} ${i.partySize}: Your table at ${s?.name??'the restaurant'} is ready.`),await t.repo.waitlist.setStatus(i.id,'notified'),`Done: number ${i.number} marked as told. No text was sent.`}},{id:'request_cover',apps:q,title:'Ask for cover for my shift',risk:'change',params:[{name:'day',type:'string',required:!1,description:'Day or date of your shift (else your next shift)'}],keywords:[],description:'Ask the team to cover one of your own shifts, like the Ask for cover button. A \u201cCover needed\u201d note goes in the team chat.',match:e=>v(e,/\bcover\b/)&&v(e,/\b(my|me)\b/)&&v(e,/\b(shift|ask|need|someone|anyone|can)\b/)&&!v(e,Q)?9:0,parse:e=>({day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day);return a?`Ask for cover for your shift on ${G(a)}? A \u201cCover needed\u201d note goes in the team chat.`:Z},run:(e,t)=>{const a=V(t,e.day);return a&&t.whoId?n.useOwner.getState().swaps.some(e=>e.shiftId===a.id&&'open'===e.status)?'There\u2019s already an open request for that shift.':(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,kind:'cover',note:'Can anyone cover?'}),x('all',`Cover needed: ${M[a.day]} ${R(a.start)}\u2013${R(a.end)} (${N(F(t.whoId)?.name??t.who)})`),`Done: cover asked for ${G(a)}. A manager approves it once someone takes it.`):"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_swap',apps:q,title:'Ask to swap my shift with someone',risk:'change',params:[{name:'with',type:'string',required:!0,description:'Who you agreed to swap with (first name)'},{name:'day',type:'string',required:!1,description:'Day or date of your shift'}],keywords:[],description:'Ask a manager to approve swapping one of your shifts with a colleague you agreed it with, like the Swap with button.',match:e=>v(e,/\bswap\b/)&&!v(e,Q)?9:0,parse:(e,t)=>({with:W(e).find(e=>e.id!==t?.whoId)?.id,day:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I know whose shift it is.';const a=V(t,e.day),r=E(e.with);return r&&r.id!==t.whoId?a?`Ask to swap your shift on ${G(a)} with ${N(r.name)}? A manager still approves it.`:Z:'Who are you swapping with? Say their first name.'},run:(e,t)=>{const a=V(t,e.day),r=E(e.with);return a&&t.whoId?r&&r.id!==t.whoId?(n.useOwner.getState().addSwap({shiftId:a.id,fromId:t.whoId,toId:r.id,kind:'swap',note:'Agreed between us'}),`Done: swap with ${N(r.name)} asked for. A manager approves it.`):'Nothing changed: say who you\u2019re swapping with.':"Nothing changed: I couldn\u2019t find a published shift of yours on that day. Say the day, for example \u201cFriday\u201d."}},{id:'request_holiday',apps:q,title:'Ask for holiday',risk:'change',params:[{name:'from',type:'string',required:!0,description:'First day off, YYYY-MM-DD'},{name:'to',type:'string',required:!0,description:'Last day off, YYYY-MM-DD'},{name:'reason',type:'string',required:!1,description:'Reason (default Holiday)'}],keywords:[],description:'Send your own holiday (time off) request to a manager, like the Send request button.',match:e=>v(e,/\b(holiday|time off|day off|days off|annual leave|leave)\b/)&&v(e,/\b(request|book|ask|want|need|like|have|put in|take|off)\b/)&&!v(e,Q)&&!v(e,/\b(who|how many|when is)\b/)?8:0,parse:(e,t)=>{const a=J(e,t?.today??(0,l.ymdOf)((0,$.appNow)())),r=e.match(/\b(?:for|because)\s+(?:a |an |my )?([a-z][a-z ]{2,40}?)\s*$/i);return{...a,reason:r&&!/\b(from|to|monday|tuesday|wednesday|thursday|friday|saturday|sunday|tomorrow|\d)/i.test(r[1])?r[1]:void 0}},preview:(e,t)=>t.whoId?`Ask for ${e.reason??'holiday'} from ${(0,$.niceDay)(String(e.from))}${e.to!==e.from?` to ${(0,$.niceDay)(String(e.to))}`:''}? A manager approves it.`:'Sign in first so I know who\u2019s asking.',run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const a=e=>/^\d{4}-\d{2}-\d{2}$/.test(String(e));return!a(e.from)||!a(e.to)||String(e.to)v(e,Q)&&v(e,/\b(swap|cover|swaps)\b/)?9:0,parse:e=>({who:e,outcome:/\b(decline|reject|refuse|no)\b/i.test(e)?'declined':'approved'}),preview:e=>{const t=X(e.who);if(!t)return'I couldn\u2019t find that open swap or cover request. Say the name on it.';const a=n.useOwner.getState().shifts.find(e=>e.id===t.shiftId),r=N(F(t.fromId)?.name),i=N(F(t.toId)?.name),s='swap'===t.kind?`${r}\u2019s swap with ${i}`:t.toId?`${i} covering ${r}`:`${r}\u2019s cover request`;return'declined'===e.outcome||t.toId?`${'declined'===e.outcome?'Decline':'Approve'} ${s}${a?` for ${G(a)}`:''}?${'declined'===e.outcome?'':' The shift moves and a note goes in the team chat.'}`:`Nobody has taken ${r}\u2019s cover yet, so it can\u2019t be approved. You can decline it.`},run:e=>{const t=X(e.who);if(!t)return'Nothing changed: no open request found.';if('declined'!==e.outcome&&!t.toId)return'Nothing changed: nobody has taken that cover yet.';const a=n.useOwner.getState(),r=a.shifts.find(e=>e.id===t.shiftId);if(a.setSwap(t.id,'declined'===e.outcome?'declined':'approved'),'declined'===e.outcome)return'Done: request declined.';const i=e=>N(F(e)?.name);return x('all','swap'===t.kind?`Shift swap: ${i(t.fromId)} \u2194 ${i(t.toId)} approved`:`Cover approved: ${i(t.toId)} covers ${i(t.fromId)}${r?` (${M[r.day]} ${R(r.start)}\u2013${R(r.end)})`:''}`),'Done: approved and posted in the team chat.'}},{id:'sign_safety_day',apps:O,title:'Sign today\u2019s food safety diary',risk:'change',params:[],keywords:[],description:'Sign today\u2019s food safety diary: the opening and closing checks were done and the safe methods were followed, like the diary Sign button. Today only.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,ae)&&!v(e,/\bweek(ly)?\b/)?9:0,preview:(e,t)=>{const a=(i.useSafety.getState().daySigns??[]).find(e=>e.date===t.today);if(a)return`Today\u2019s diary is already signed by ${a.by}.`;const r=te(t.today,t);return`Sign today\u2019s food safety diary as ${I(t)}: the opening and closing checks were done and the safe methods were followed today? Today: ${r.n} checks, ${r.bad} out of range${r.bad?`, ${r.fixed} with an action`:''}.`},run:(e,t)=>'staff'===t.role?'Nothing changed: only a manager or the head chef signs the diary.':(i.useSafety.getState().daySigns??[]).some(e=>e.date===t.today)?'It\u2019s already signed today.':(i.useSafety.getState().signDay({date:t.today,by:N(I(t)),byId:t.whoId??'',at:(0,$.appNow)().toISOString()}),'Done: today\u2019s diary signed.')},{id:'sign_safety_week',apps:O,title:'Sign off this week\u2019s food safety review',risk:'change',params:[],keywords:[],description:'Weekly food safety review: reads the six statements back; Confirm means yes to all six. If any reading is out of range without an action, it must be done on screen with a note.',match:e=>v(e,/\bsign(ed|ing)?\b/)&&v(e,/\bweek(ly)?\b/)&&(v(e,ae)||v(e,/\b(review|safety|checks)\b/))?9:0,preview:(e,t)=>{const{week:a,summary:r}=re(t.today,t),n=(i.useSafety.getState().weekly??[]).find(e=>e.week===a);if(n)return`This week is already signed off by ${n.by}.`;const s=`Week of ${(0,$.niceDay)(a)}: ${r.entries} checks, ${r.outOfRange} out of range, ${r.actions} with an action, diary signed ${r.daysSigned} of 7 days.`;return r.actions`${t+1}. ${e}.`).join(' ')} Sign off the week?`},run:(e,t)=>{if('staff'===t.role)return'Nothing changed: only a manager or the head chef signs off the week.';const{week:a,summary:r}=re(t.today,t);return(i.useSafety.getState().weekly??[]).some(e=>e.week===a)?'This week is already signed off.':r.actions!0),note:'Signed by voice: yes to all.',summary:r}),'Done: week signed off.')}},{id:'record_accident',title:'Record an accident or near miss',risk:'change',params:[{name:'what',type:'string',required:!0,description:'What happened, in the speaker\u2019s words'},{name:'person',type:'string',required:!1,description:'Who was hurt'},{name:'location',type:'string',required:!1,description:'Where'},{name:'injury',type:'string',required:!1,description:'The injury'},{name:'firstAid',type:'string',required:!1,description:'First aid given'}],keywords:[],description:'Add an entry to the accident book (accident or near miss) with what was said; every field is read back first.',match:e=>v(e,/\baccident book\b/)?10:v(e,/\b(accident|injur(y|ed)|near miss|hurt|cut (him|her|them|my)self|burn(ed|t)? (him|her|them|my)self|slipped|tripped|fell over|scalded)\b/)&&v(e,/\b(record|log|report|write|add|book|had|there was|has|have|just)\b/)&&!v(e,/\b(how many|show|read)\b/)?8:0,parse:e=>{const t=ie(e);return{what:t.what,person:t.person,location:t.location,firstAid:t.firstAid}},preview:e=>{const t=ie(String(e.what)),a=String(e.person??t.person),r=String(e.location??t.location);return`Add to the accident book: when, today at ${D()}; who, ${a} (${t.personType}); where, ${r}; type, ${t.category}; what happened, ${_(t.what)}; injury, ${e.injury?String(e.injury):'Near miss'===t.category?'none (near miss)':'not recorded'}; first aid, ${e.firstAid||t.firstAid||'none recorded'}; reported by you. Check it before you confirm; you can add more in the Accident book.`},run:(e,t)=>{const a=ie(String(e.what)),r='Near miss'===a.category,n=(0,$.appNow)();return i.useSafety.getState().addAccident({when:`${(0,l.ymdOf)(n)}T${D()}`,location:String(e.location??a.location),person:String(e.person??a.person),personType:a.personType,category:a.category,what:a.what,injury:String(e.injury??'')||(r?'None (near miss)':'Not recorded'),firstAid:String(e.firstAid||a.firstAid||'')||'None recorded',witnesses:'None',reportedBy:N(I(t)),reportedById:t.whoId??'',app:'staff'===t.app?'staff':'chef'===t.app?'chef':'managers'}),'Done: added to the accident book.'+(/(hospital|fracture|broke|unconscious|ambulance)/i.test(a.what)?' This may need reporting under RIDDOR; check the Accident book.':'')}},{id:'tick_task',apps:['staff','chef','owner'],title:'Tick off one of my tasks',risk:'change',params:[{name:'task',type:'string',required:!0,description:'The task or reminder, as said'}],keywords:[],description:'Tick off one of today\u2019s daily tasks (yours), or mark a venue reminder like \u201cchairs up\u201d as done, like the tick and Done buttons.',match:e=>v(e,/\btick(ed)?( off)?\b|\bmark .* (as )?done\b|\b(i'?ve|i have|we'?ve) (done|finished|completed)\b|\b(task|reminder) (is )?done\b|\bdone the\b/)&&!v(e,/\b(shift|break|order|table|booking|clock)\b/)?7:0,parse:e=>({task:e}),preview:(e,t)=>{if(!t.whoId)return'Sign in first so I tick your tasks.';const{ymd:a,task:r,rem:n}=se(t,e.task);return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?`${_(r.text)} is already ticked today.`:`Tick off today\u2019s task ${_(r.text)}?`:n?`Mark the reminder ${_(n.text)} as done for today?`:'I couldn\u2019t find that in today\u2019s tasks. Say a word from the task.'},run:(e,t)=>{if(!t.whoId)return'Nothing changed: sign in first.';const{ymd:a,task:r,rem:n}=se(t,e.task),i={id:t.whoId,name:N(I(t))};return r?s.useDailyTasks.getState().ticks.some(e=>e.id===(0,s.tickId)(t.rid,t.whoId,r.id,a))?'Already ticked today.':(s.useDailyTasks.getState().toggleTick(t.rid,t.whoId,r.id,a,i),`Done: ${_(r.text)} ticked.`):n?(c.useReminders.getState().markDone({rid:t.rid,reminderId:n.id,forDate:a,at:(0,$.appNow)().toISOString(),staffRef:t.whoId,staffName:i.name}),`Done: ${_(n.text)} marked done.`):'Nothing changed: I couldn\u2019t find that task.'}},{id:'add_dish',apps:T,title:'Add a dish to the menu',risk:'change',params:[{name:'name',type:'string',required:!0,description:'Dish name'},{name:'section',type:'string',required:!1,description:'Menu section'},{name:'price',type:'string',required:!0,description:'Price in pounds'},{name:'description',type:'string',required:!1,description:'Short description'}],keywords:[],description:'Add a new dish to the menu, like Manage \u203a Add dish. It stays off the menu until the head chef signs off its recipe card.',match:e=>v(e,/\b(add|new|put)\b/)&&v(e,/\b(dish|menu item|to the menu|on the menu|onto the menu)\b/)&&!v(e,/\b(special|specials|sold out|order list)\b/)?8:0,parse:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t?.rid),n=e.toLowerCase(),i=e.match(/\b(?:called|named)\s+(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i)??e.match(/\b(?:add|put)\s+(?:a |an |the )?(?:new )?(?:dish\s+)?(.+?)(?=\s+(?:to|in|on|under|at|for|priced|\xa3)\b|[,.]|$)/i),s=r?.sections.find(e=>n.includes(e.toLowerCase())||n.includes(e.toLowerCase().replace(/s$/,''))),o=ce(e);return{name:i?.[1]?.replace(/^(?:a |an )?(?:new )?dish\s*/i,'').trim(),section:s,price:null!=o?String(o):void 0}},preview:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=String(e.section??r?.sections[0]??'Mains');return`Add ${_(String(e.name))} to ${n} at \xa3${Number(e.price).toFixed(2)}${e.description?`, described as ${_(String(e.description))}`:''}? It stays off the menu until the head chef signs off its recipe card.`},run:(e,t)=>{const r=a.useStore.getState().restaurants.find(e=>e.id===t.rid),n=Number(e.price),i=String(e.name??'').trim();return i.length<2||!Number.isFinite(n)||n<=0?'Nothing changed: I need a dish name and a price.':de(t.rid,i)?.name.toLowerCase()===i.toLowerCase()?'That dish is already on the menu.':(a.useStore.getState().addMenuItem({restaurantId:t.rid,section:String(e.section??r?.sections[0]??'Mains'),name:i,description:String(e.description??''),price:n,dietary:[],allergens:{},prepMins:10,soldOut:!1,signOff:null}),`Done: ${i} added. The head chef needs to add its recipe card and sign off the allergens before it shows.`)}},{id:'edit_dish',apps:T,title:'Rename a dish or change its description',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name now'},{name:'field',type:'string',required:!0,description:'name or description',enum:['name','description']},{name:'value',type:'string',required:!0,description:'The new name or description'}],keywords:[],description:'Rename a dish or change its menu description, like Manage \u203a Save dish. Renaming changes its recipe card, so the head chef signs it off again.',match:e=>v(e,/\brename\b|\b(change|update|set|edit)\b.*\b(description|name)\b|\bdescri(be|ption)\b.*\bas\b/)&&!v(e,/\b(price|booking|special|my name)\b/)?8:0,parse:e=>{const t=e.match(/\brename\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i);if(t)return{dish:t[1],field:'name',value:t[2].trim()};const a=e.match(/\bname of\s+(?:the\s+)?(.+?)\s+to\s+(.+)$/i);if(a)return{dish:a[1],field:'name',value:a[2].trim()};const r=e.match(/\bdescription (?:of|for)\s+(?:the\s+)?(.+?)\s+(?:to|as)\s+(.+)$/i)??e.match(/\b(?:describe|change|update|set)\s+(?:the\s+)?(.+?)(?:'s|\u2019s)?\s+(?:description\s+)?(?:to|as)\s+(.+)$/i);return r?{dish:r[1],field:'description',value:r[2].trim()}:{dish:e}},preview:(e,t)=>{const a=de(t.rid,e.dish);return a?'name'===e.field?`Rename ${_(a.name)} to ${_(String(e.value))}? Its recipe card changes too, so the head chef signs it off again.`:`Change the description of ${a.name} to ${_(String(e.value))}?`:'I couldn\u2019t find that dish on the menu.'},run:(e,t)=>{const r=de(t.rid,e.dish),n=String(e.value??'').trim();return r?n.length<2?'Nothing changed: say the new wording.':(a.useStore.getState().updateMenuItem(r.id,'name'===e.field?{name:n}:{description:n}),'name'===e.field?`Done: renamed to ${n}.`:`Done: description of ${r.name} changed.`):'Nothing changed: I couldn\u2019t find that dish.'}},{id:'add_recipe_ingredient',apps:['chef'],title:'Add an ingredient to a recipe card',risk:'change',params:[{name:'text',type:'string',required:!0,description:'e.g. add 50 grams of butter to the haggis'}],keywords:[],description:'Add an ingredient line to a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\badd\b/)&&v(e,/\b(ingredient|recipe|card)\b|\badd\s+\d+\s*(g|grams?|kg|ml|tbsp|tsp)\b/)&&!v(e,/\b(step|method|order list|special)\b/)?8:0,parse:e=>({text:e}),preview:(e,t)=>{const a=pe(String(e.text));if(!a)return'Say it like \u201cadd 50 grams of butter to the haggis\u201d.';const r=(0,$.findCard)(t.rid,a.dish);return r?`Add ${[a.qty,a.unit].filter(Boolean).join(' ')} ${a.name} to ${r.dish}\u2019s recipe card?${r.signOff?' It\u2019s signed off now, so it will need signing off again.':''} Check its allergens on the card.`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=pe(String(e.text)),r=a&&(0,$.findCard)(t.rid,a.dish);return a&&r?(await(0,y.recipeCards)().update(r.id,{ingredients:[...r.ingredients,{id:(0,k.uuid)(),name:a.name,qty:a.qty,unit:a.unit}]},{name:N(I(t)),role:'head-chef'}),`Done: ${a.name} added to ${r.dish}.${r.signOff?' It needs signing off again.':''}`):'Nothing changed: I couldn\u2019t find that recipe card.'}},{id:'add_recipe_step',apps:['chef'],title:'Add a method step to a recipe card',risk:'change',params:[{name:'dish',type:'string',required:!0,description:'Dish name'},{name:'step',type:'string',required:!0,description:'The step wording'}],keywords:[],description:'Add a method step to the end of a recipe card. Changing a signed-off card means it must be signed off again.',match:e=>v(e,/\b(add|new)\b/)&&v(e,/\b(step|method)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:to|for)\s+(?:the\s+)?(.+?)(?:\s+(?:recipe|card|recipe card))?\s*[:,]\s*(.+)$/i)??e.match(/\bstep\s+(?:to|for)\s+(?:the\s+)?(.+?)\s+(?:saying|that says|reading)\s+(.+)$/i);return t?{dish:t[1],step:t[2].trim()}:{dish:e}},preview:(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0;return a?`Add step ${a.steps.length+1} to ${a.dish}: ${_(String(e.step))}?${a.signOff?' It will need signing off again.':''}`:'I couldn\u2019t find that recipe card.'},run:async(e,t)=>{const a=(0,y.hasRecipeCards)()?(0,$.findCard)(t.rid,e.dish):void 0,r=String(e.step??'').trim();return!a||r.length<3?'Nothing changed: I need the dish and the step.':(await(0,y.recipeCards)().update(a.id,{steps:[...a.steps,r]},{name:N(I(t)),role:'head-chef'}),`Done: step added to ${a.dish}.`)}},{id:'manager_clock',apps:T,title:'Clock someone in or out (manager correction)',risk:'change',params:[{name:'staffId',type:'string',required:!0,description:'Staff first name or id'},{name:'action',type:'string',required:!0,description:'in, out, break_start or break_end',enum:['in','out','break_start','break_end']},{name:'reason',type:'string',required:!0,description:'Why (at least 3 letters)'}],keywords:[],description:'A manager clocks a member of staff in or out, or starts or ends their break, now, with a reason, like the Clock tab\u2019s manager buttons. It is marked as a manager correction.',match:e=>v(e,/\bclock\s+\w+\s+(in|out)\b|\bclock (in|out)\s+[a-z]+\b|\b(start|end)\s+(a |the )?break for\b|\b(end|finish)\s+\w+'?s break\b/)&&!v(e,/\b(me|myself|my|who|is|are|has)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=W(e)[0],r=e.match(/\b(?:reason|because|as)\b[:,]?\s*(.+)$/i),n=/\bbreak\b/.test(t)?/\b(end|finish|back)\b/.test(t)?'break_end':'break_start':/\bout\b/.test(t)?'out':'in';return{staffId:a?.id,action:n,reason:r?.[1]?.trim()}},preview:e=>{const t=E(e.staffId);return t?`${le[e.action??'in'].replace('{n}',N(t.name))} now, at ${D()}? Reason: ${_(String(e.reason))}. It\u2019s marked as a manager correction.`:'Who? Say their first name.'},run:(e,t)=>{const a=E(e.staffId);if(!a)return'Nothing changed: I couldn\u2019t tell who.';const r=e.action??'in',n=(0,g.managerClockAction)(r,{rid:t.rid,staffId:a.id,date:t.today,at:(0,$.appNow)().toISOString()},{id:t.whoId??'manager',name:N(I(t))},String(e.reason??''));return n.ok?`Done: ${N(a.name)} ${{in:'clocked in',out:'clocked out',break_start:'on a break',break_end:'back from break'}[r]} at ${D()}.${n.warn?' '+n.warn:''}`:'Nothing changed: '+n.message}},{id:'tips_pot',apps:T,title:'What\u2019s in the tips pot',risk:'look',params:[],keywords:[],description:'Managers only: the confirmed tips held for the team since the last payout (the Tips pot card).',match:e=>v(e,/\btips? (pot|jar|so far|held|this (period|fortnight|month|week))\b|\bin the tips\b|\bhow much (have we got |is there )?in tips\b|\bwhat are the tips\b|\bhow much (are|is) (the )?tips\b/)&&!v(e,/\b(pay|payout|split|share out)\b/)?8:0,preview:()=>'Tips pot',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const r=h.useCashUp.getState(),n=a.useStore.getState().restaurants.find(e=>e.id===t.rid),i=(0,f.payFor)(t.rid,n?.settings.pay,u.useOnboard.getState().answers).pay,s=(0,p.tipsPot)(r.tips.filter(e=>e.rid===t.rid),r.pot.filter(e=>e.rid===t.rid),(0,l.tipsPeriod)(i,t.today).start,t.today);return`The tips pot holds ${fe(s.total)} from ${(0,$.niceDay)(s.from)} to today, from ${s.days.length} confirmed cash-up${1===s.days.length?'':'s'}.${s.lastPayout?` Last paid out through ${(0,$.niceDay)(s.lastPayout.throughDate)}.`:''}`}},{id:'cash_up_summary',apps:T,title:'Read the latest cash-up',risk:'look',params:[{name:'day',type:'string',required:!1,description:'Day (else the latest)'}],keywords:[],description:'Managers only: the latest (or a named day\u2019s) cash-up: gross takings, tips and who confirmed it.',match:e=>v(e,/\bcash.?up\b|\btakings\b|\bhow much did we take\b/)&&!v(e,/\b(add|enter|start|do the|unlock|edit)\b/)?8:0,parse:(e,t)=>({day:j(e.replace(/\btonight\b/i,'today'),t?.today??(0,l.ymdOf)((0,$.appNow)()))??(/\b(last night|yesterday)\b/i.test(e)?'yesterday':void 0)}),preview:()=>'Cash-up read-out',run:(e,t)=>{if(!ue(t))return'That isn\u2019t shown here. Ask a manager in the Managers app.';const a=new Date(t.today+'T12:00:00');a.setDate(a.getDate()-1);const r='yesterday'===e.day?(0,l.ymdOf)(a):e.day,n=h.useCashUp.getState().cashUps.filter(e=>e.rid===t.rid&&(!r||e.date===r)).sort((e,t)=>t.date.localeCompare(e.date)),i=n[0];return i?`Cash-up for ${(0,$.niceDay)(i.date)}: gross takings ${fe((0,p.grossOf)(i.vals))}, tips ${fe((0,p.combinedTips)(i.vals))} (cash and card). ${i.confirmedAt?`Confirmed${i.confirmedBy?` by ${i.confirmedBy}`:''}.`:'Not confirmed yet.'}`:r?`There\u2019s no cash-up for ${(0,$.niceDay)(r)}.`:'There\u2019s no cash-up yet.'}},{id:'table_note',apps:C,title:'Add a note to a table',risk:'change',params:[{name:'table',type:'string',required:!0,description:'Table'},{name:'note',type:'string',required:!0,description:'The note (say \u201cclear\u201d to remove it)'}],keywords:[],description:'Put a short note on a table on the floor plan (e.g. \u201chigh chair\u201d, \u201cbirthday\u201d), like the table sheet\u2019s Note.',match:e=>v(e,/\btables?\s+\w+/)&&v(e,/\bnote\b/)&&!v(e,/\bshift note\b/)?9:0,parse:e=>{const t=e.match(/\bnote\b(?:\s+(?:on|for|to)\s+tables?\s+\w+)?\s*(?:[:,-]|saying|that says|that|says|reading)?\s*(.+)$/i),a=/\b(clear|remove|delete) (the )?note\b/i.test(e);return{table:(0,$.tableIn)(e),note:a?'clear':t?.[1]?.replace(/^(?:on|for|to)?\s*tables?\s+\w+\s*[:,-]?\s*/i,'').trim()}},preview:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);return a?'clear'===e.note?`Clear the note on table ${a}?`:`Note on table ${a}: ${_(String(e.note))}?`:'Which table?'},run:(e,t)=>{const a=(0,$.resolveTable)(t.rid,e.table);if(!a)return'Nothing changed: I couldn\u2019t find that table.';const n='clear'===e.note?'':String(e.note??'').trim().slice(0,80);return(0,r.tablesOf)(a).forEach(e=>r.useFloor.getState().setLive(t.rid,e,{note:n||void 0})),n?`Done: note on table ${a}.`:`Done: note cleared on table ${a}.`}},{id:'log_lost_property',apps:T,title:'Log lost property',risk:'change',params:[{name:'item',type:'string',required:!0,description:'What was found'},{name:'where',type:'string',required:!1,description:'Where it was found'}],keywords:[],description:'Add an item to the lost property log (held), like Extras \u203a Lost property \u203a Add.',match:e=>v(e,/\blost property\b|\b(found|someone left|left behind|handed in)\b\s+(a|an|some|their|his|her)\b|\b(a|an)\s+\w+(\s+\w+)?\s+(was )?(left behind|handed in)\b/)&&!v(e,/\b(how many|what'?s in|list|read|returned)\b/)?8:0,parse:e=>{const t=e.match(/\b(?:found|left(?: behind)?|handed in|log|add)\s+(?:a |an |some |their |his |her )?(.+?)(?=\s+(?:at|on|in|under|by|near|from)\s|[,.]|$)/i)??e.match(/\b(?:a|an)\s+(.+?)\s+(?:was )?(?:left behind|handed in)/i),a=e.match(/\s(?:at|on|in|under|by|near)\s+(?:the\s+)?(table\s+\w+|bar|toilets?|coat ?rack|cloakroom|door|entrance|terrace|garden|car park|dining room|booth\s+\w+|[a-z]+ table)\b/i);return{item:t?.[1]?.replace(/^(?:lost property|to lost property)\s*:?\s*/i,'').trim(),where:a?.[1]}},preview:e=>`Log lost property: ${_(String(e.item))}, found ${e.where?`at ${e.where}`:'(place not noted)'}, today at ${D()}? It\u2019s marked as held.`,run:(e,t)=>{const a=String(e.item??'').trim();if(a.length<2)return'Nothing changed: say what was found.';const r=(0,$.appNow)();return n.useOwner.getState().addLost({item:a,where:String(e.where??'').trim()||'Not noted',foundAt:`${(0,l.ymdOf)(r)} ${D()}`,foundBy:N(I(t))}),`Done: ${a} logged as held.`}},{id:'add_reminder',apps:T,title:'Add a venue reminder for staff',risk:'change',params:[{name:'text',type:'string',required:!0,description:'What it says'},{name:'time',type:'string',required:!0,description:'HH:MM, UK time'},{name:'days',type:'string',required:!1,description:'Days (default every day)'},{name:'audience',type:'string',required:!1,description:'all, foh or kitchen',enum:['all','foh','kitchen']}],keywords:[],description:'Add a venue reminder shown to staff on shift at a time on chosen days, like Settings \u203a Advanced \u203a Reminders \u203a Add.',match:e=>v(e,/\b(remind|reminder)\b/)&&v(e,/\b(add|set|new|create|every|daily|weekdays?|weekends?|at \d)\b/)&&!v(e,/\b(me|my)\b/)?8:0,parse:e=>{const t=e.toLowerCase(),a=/\b(kitchen|chefs?)\b/.test(t)?'kitchen':/\b(front of house|foh|floor|waiters?|servers?)\b/.test(t)?'foh':'all',r=e.match(/\bremind(?:er)?\s+(?:for\s+)?(?:everyone|all staff|staff|the team|the kitchen|kitchen|front of house|foh|the floor|chefs?)?\s*(?:to|that|:)\s+(.+?)(?=\s+(?:at\s+\d|every\b|on\s+(?:mon|tue|wed|thu|fri|sat|sun)|daily|weekdays?|weekends?)|$)/i)??e.match(/\breminder\s*(?:saying|that says|:)\s*(.+?)(?=\s+(?:at\s+\d|every\b|daily)|$)/i),n=e.match(/\bat\s+(\d{1,2}(?:[:.]\d{2})?\s*(?:am|pm)?)/i);return{text:r?.[1]?.trim(),time:n?(0,$.hm)(n[1])??void 0:void 0,days:ge(t).join(','),audience:a}},preview:e=>{const t=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number),a=String(e.text??''),r=a.charAt(0).toUpperCase()+a.slice(1);return`Add a reminder for ${ye[e.audience??'all']}: ${_(r)}, ${7===t.length?'every day':'every '+t.map(e=>me[e].replace(/^\w/,e=>e.toUpperCase())).join(', ')} at ${e.time} (UK time)?`},run:(e,t)=>{const a=String(e.text??'').trim(),r=String(e.time??'');if(a.length<2||!/^\d{2}:\d{2}$/.test(r))return'Nothing changed: I need the wording and a time like 21:00.';const n=String(e.days??'0,1,2,3,4,5,6').split(',').map(Number).filter(e=>e>=0&&e<=6).sort();return c.useReminders.getState().ensure(t.rid),c.useReminders.getState().add(t.rid,{text:a.charAt(0).toUpperCase()+a.slice(1),days:n,time:r,audience:e.audience??'all'}),'Done: reminder added.'}}]},1499,[835,874,831,1029,891,1034,1044,1045,1010,1009,1039,13,1064,1065,1066,1035,1095,882,1105,1026,870,1500,1498]); +__d(function(_g,_r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.dishesFor=_,_e.findDish=F,_e.allergensSaid=q,_e.timeFrom=G,_e.coversFrom=P,_e.dateFrom=U,_e.nameFrom=J,Object.defineProperty(_e,"VOICE_ACTIONS",{enumerable:!0,get:function(){return ee}});var e=_r(_d[0]),t=_r(_d[1]),r=_r(_d[2]),a=_r(_d[3]),n=_r(_d[4]),o=_r(_d[5]),i=_r(_d[6]),s=_r(_d[7]),d=_r(_d[8]),l=_r(_d[9]),c=_r(_d[10]),p=_r(_d[11]),h=_r(_d[12]),u=_r(_d[13]),f=_r(_d[14]),m=_r(_d[15]),g=_r(_d[16]),b=_r(_d[17]),y=_r(_d[18]),w=_r(_d[19]);const v=()=>{try{return(0,s.nowFrom)(s.useStore.getState().clock)}catch{return new Date}},k=e=>String(e).padStart(2,'0'),S=e=>e.getFullYear()+'-'+k(e.getMonth()+1)+'-'+k(e.getDate()),N=e=>{const[t,r,a]=e.split('-').map(Number);return new Date(t,r-1,a).toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},I=(e,t)=>t.test(e),A=(e,t)=>e+' '+t+(1===e?'':'s'),T={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},x=e=>null==e?void 0:T[e.toLowerCase()]??(Number.isFinite(Number(e))?Number(e):void 0),D=e=>e.who??('display'===e.app?'Main Display':'Assistant'),C={owner:'Managers',staff:'Staff',chef:'Head Chef',display:'Main Display'},O=e=>C[e.app??'owner'],L=new Set(['the','and','with','our','for']),R=e=>e.toLowerCase().replace(/[^a-z0-9 ]/g,' ').split(/\s+/).filter(e=>e.length>2&&!L.has(e));function _(e){const t=s.useStore.getState(),r=(0,p.resolveMenu)(t.menu.filter(t=>t.restaurantId===e&&!t.hidden)).map(e=>({kind:'menu',id:e.id,name:e.name,allergens:e.allergens,soldOut:e.soldOut,price:e.price,signedOff:!!e.signOff})),a=c.useSpecials.getState().current[e];return[...r,...(a?.items??[]).map(e=>({kind:'special',id:e.id,name:e.name,allergens:e.allergens,price:e.price,signedOff:!!a?.allergenCheck}))]}const E=e=>e.replace(/s$/,'');function F(e,t){const r=new Set(R(e).map(E)),a=e.toLowerCase();let n;for(const e of _(t)){const t=R(e.name);if(!t.length)continue;const o=t.filter(e=>r.has(E(e))).length;if(!o)continue;const i=o/t.length+.25*o+(a.includes(e.name.toLowerCase())?2:0);(o>=Math.min(2,t.length)||t.length<=3)&&(!n||i>n.s)&&(n={d:e,s:i})}return n?.d}const M=[[/\b(gluten|wheat|coeliac|celiac|barley|rye)\b/,['gluten']],[/\bpeanuts?\b/,['peanuts']],[/\b(tree ?nuts?|almonds?|walnuts?|hazelnuts?|cashews?|pecans?|pistachios?)\b/,['treenuts']],[/\bnuts?\b/,['peanuts','treenuts']],[/\b(dairy|milk|lactose|cheese|cream|butter)\b/,['milk']],[/\beggs?\b/,['eggs']],[/\b(shellfish|crustaceans?|prawns?|crab|langoustines?)\b/,['crustaceans']],[/\b(molluscs?|mussels?|oysters?|squid|scallops?|clams?)\b/,['molluscs']],[/\bfish\b/,['fish']],[/\b(soya|soy)\b/,['soya']],[/\bcelery\b/,['celery']],[/\bmustard\b/,['mustard']],[/\bsesame\b/,['sesame']],[/\b(sulphites?|sulfites?|sulphur)\b/,['sulphites']],[/\blupin\b/,['lupin']]];function q(e){const t=new Set;for(const[r,a]of M)r.test(e)&&a.forEach(e=>t.add(e));return[...t]}const z=e=>h.ALLERGENS.find(t=>t.id===e)?.short??e,B='Always check the signed-off recipe card and tell the kitchen about any allergy.';function j(t,r){if('chef'===r?.app&&(0,e.isAnchorage)(r.rid)&&(0,e.isBarFridge)(t))return[];const a=l.useSafety.getState().points.filter(t=>'chef'!==r?.app||(0,e.chefCanSee)(r.rid,t)),n=/\b(done|complete|completed|finished|ok|okay|checked)\b/i.test(t);return(0,g.parseQuick)(t,a).filter(e=>e.point).map(e=>{const t=(0,g.isTempKind)(e.point.kind);return{pointId:e.point.id,value:t?e.value:null,done:t?void 0:n}})}const H=e=>{try{return JSON.parse(String(e.readings??'[]'))}catch{return[]}};function Y(e){const t=l.useSafety.getState().points.find(t=>t.id===e.pointId);return t?(0,g.isTempKind)(t.kind)?null==e.value?t.name+': no temperature heard':t.name+': '+e.value+'\xb0C '+((0,g.inRange)(t,e.value)?'(safe)':'OUT OF RANGE (safe: '+(0,g.limitText)(t)+')'):t.name+': '+(e.done?'done':'NOT done'):'?'}function G(e){const t=e.match(/\b(?:at|around|about)\s+(\d{1,2})(?:[:.](\d{2}))?\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})[:.](\d{2})\s*(am|pm)?\b/)??e.match(/\b(\d{1,2})()\s*(am|pm)\b/);if(!t){const t=e.match(new RegExp("\\bhalf (?:past )?(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b"));if(!t)return;let r=x(t[1])??0;return r>=1&&r<=10&&(r+=12),k(r)+':30'}let r=Number(t[1]);const a=Number(t[2]||0),n=t[3];return'pm'===n&&r<12&&(r+=12),'am'===n&&12===r&&(r=0),!n&&r>=1&&r<=10&&(r+=12),r>23||a>59?void 0:k(r)+':'+k(a)}function P(e){const t=e.match(new RegExp("\\b(?:table for|party of|for|of)\\s+(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))"))??e.match(new RegExp("\\b(\\d{1,3}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)\\s*(?:covers|people|guests|adults|of us)\\b")),a=x(t?.[1]);return a&&(0,r.validParty)(a)?a:void 0}const Z=['monday','tuesday','wednesday','thursday','friday','saturday','sunday'];function U(e,t){const r=new Date(t+'T12:00:00');if(/\btomorrow\b/.test(e))return r.setDate(r.getDate()+1),S(r);const a=Z.findIndex(t=>e.includes(t));if(a>=0){const t=(r.getDay()+6)%7;return r.setDate(r.getDate()+((a-t+7)%7||(/\bnext\b/.test(e)?7:0))),S(r)}return t}function K(e,t,r,a){const n=s.useStore.getState(),o=n.restaurants.find(t=>t.id===e),i=d.useFloor.getState().plans[e]??(0,d.seedPlan)(e),l=o?.settings.turnMins??90,c=n.bookings.filter(r=>r.restaurantId===e&&r.date===t);return(0,u.freeTablesAt)(i,c,a,new Date(t+'T'+r+':00'),(0,u.turnFor)(a,l),l)}const W=(e,t)=>{const[r,a]=e.split(':').map(Number),n=60*r+a+t;return k(Math.floor(n/60))+':'+k(n%60)},$=e=>e.replace(/^\w/,e=>e.toUpperCase());function J(e){const t=e.match(/\b(?:under|name of|named|called)\s+([A-Za-z][A-Za-z'\u2019-]+(?:\s+[A-Z][A-Za-z'\u2019-]+)?)/i)??e.match(/\bname(?:'s| is)?\s+([A-Za-z][A-Za-z'\u2019-]+)/i);return t?$(t[1]):void 0}const V=e=>!/\b(how do i|how do you|where do i|how to)\b/.test(e),Q=e=>!['collected','served','closed','cancelled'].includes(e.status),X=e=>e.toUpperCase().replace(/[\s-]/g,''),ee=[{id:'next_table_free',title:'When is the next table free?',risk:'look',description:'Estimate when the next table frees up, and how long a walk-in for 2 or 4 would wait.',params:[],keywords:['next table','table free'],match:e=>I(e,/\b(next|soonest|first)\b.*\btables?\b.*\b(free|ready|available|clear)\b|\bhow long\b.*\b(wait|walk)|\bwait(ing)? (time|for a table)\b|\bwhen\b.*\btable\b.*\b(free|ready)\b/)?4:0,preview:()=>'Next table free',run:(e,t)=>{const r=s.useStore.getState(),a=v(),n=S(a),o=r.restaurants.find(e=>e.id===t.rid);if(!o)return'I can\u2019t see this venue\u2019s tables yet.';const i=d.useFloor.getState(),l=i.plans[t.rid]??(0,d.seedPlan)(t.rid),c=r.bookings.filter(e=>e.restaurantId===t.rid),p=(0,m.closedAreasAt)(m.useBlocks.getState().blocks,t.rid,n,k(a.getHours())+':'+k(a.getMinutes())),h=(0,u.floorView)(l,c,r.orders.filter(e=>e.restaurantId===t.rid),i.live[t.rid]??{},a,o.settings.turnMins,p);return(0,f.nextFreeSentence)((0,f.nextTablesFree)(o,h,c.filter(e=>e.date===n),a,c),a)+' It\u2019s an estimate.'}},{id:'log_check',title:'Log a temperature or kitchen check',risk:'change',description:'Record fridge, freezer, cooking, cooling, hot-hold or delivery temperatures, or a cleaning or kitchen check, in the food safety log. Out-of-range readings are flagged.',params:[{name:'readings',type:'string',required:!0,description:'JSON list of {pointId, value in \xb0C or null, done for non-temperature checks}'}],keywords:['fridge','freezer','temperature','probe'],match:e=>V(e)&&I(e,/\b(fridges?|freezers?|temps?|temperatures?|degrees|probe|core temp|hot hold|cooling|cleaning|clean down|deep clean)\b/)&&(!I(e,/\b(seat|seated|party|covers?|people|guests?|table \w+|walk.?ins? (of|for)|just arrived)\b/)||I(e,/\b(fridges?|freezers?|cold room|degrees|temps?|temperatures?|probe|minus)\b/))?3:0,parse:(e,t)=>({readings:JSON.stringify(j(e,t))}),preview:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));return n.length?'Log in the food safety log: '+n.map(Y).join('; ')+'?':'I didn\u2019t catch which fridge, freezer or check. Try \u201cprep fridge 3 degrees\u201d.'},run:(t,r)=>{const a=l.useSafety.getState().points.filter(t=>'chef'!==r.app||(0,e.chefCanSee)(r.rid,t)),n=H(t).filter(e=>a.some(t=>t.id===e.pointId));if(!n.length)return'Nothing logged: I didn\u2019t catch which unit or check.';if(n.some(e=>{const t=a.find(t=>t.id===e.pointId);return!!t&&(0,g.isTempKind)(t.kind)&&null==e.value}))return'Nothing logged: a temperature was missing. Say the number, for example \u201cfreezer minus 19\u201d.';const o=v().toISOString(),i='chef'===r.app?'chef':'owner'===r.app?'managers':'staff',s=n.filter(e=>a.some(t=>t.id===e.pointId)).map(e=>{const t=a.find(t=>t.id===e.pointId),n=(0,g.isTempKind)(t.kind),s=n?(0,g.inRange)(t,e.value):!!e.done,d=['display'===r.app?'Logged on the Main Display.':'',s?'':'Out of range: add the corrective action.'].filter(Boolean).join(' ');return{pointId:t.id,name:t.name,kind:t.kind,at:o,by:D(r),byId:r.whoId??'voice-'+(r.app??'owner'),app:i,value:n?e.value:void 0,done:n?void 0:!!e.done,ok:s,source:'voice',note:d||void 0}});l.useSafety.getState().addEntries(s);const d=s.filter(e=>!e.ok);return d.length?'Logged. '+d.map(e=>e.name+' is OUT OF RANGE').join(', ')+'. Check it now and add what you did in the food safety log.':'Logged: '+s.map(e=>e.name+' '+(null!=e.value?e.value+'\xb0C':'done')).join(', ')+'. All fine.'}},{id:'allergen_info',title:'Allergen question',risk:'look',description:'Answer allergen questions from the recipe cards and the menu: what a dish contains or may contain, or which dishes are free of an allergen.',params:[{name:'dish',type:'string',description:'Dish name'},{name:'allergens',type:'string',description:'Comma-separated allergen ids'}],keywords:['allergen','allergy','contain'],match:e=>!I(e,/(allergens?|allerg(y|ic|ies)|contains?|coeliac|celiac|safe for|free from|.free\b|intoleran)/)||I(e,/\b(sold out|price|draft)\b/)||I(e,/\btables?\b.*\bfree\b|\bfree\b.*\btables?\b/)?0:3,parse:(e,t)=>{const r=F(e,t.rid);let a=e.toLowerCase();if(r)for(const e of R(r.name))a=a.replace(new RegExp('\\b'+e+'\\b','g'),' ');return{dish:r?.name,allergens:q(a).join(',')}},preview:e=>'Allergens'+(e.dish?' in '+e.dish:''),run:(e,t)=>{const r=_(t.rid),a=e.dish?r.find(t=>t.name===e.dish):void 0,n=String(e.allergens??'').split(',').filter(Boolean);if(a){const e=h.ALLERGENS.filter(e=>'contains'===a.allergens[e.id]).map(e=>e.short),t=h.ALLERGENS.filter(e=>'may'===a.allergens[e.id]).map(e=>e.short);return(n.length?n.map(e=>'contains'===a.allergens[e]?a.name+' CONTAINS '+z(e)+'.':'may'===a.allergens[e]?a.name+' MAY CONTAIN '+z(e)+'.':'No '+z(e)+' is listed for '+a.name+'.').join(' '):a.name+' contains '+(e.length?e.join(', '):'none of the 14 allergens')+(t.length?', and may contain '+t.join(', '):'')+'.')+(a.signedOff?'':' Its allergens are NOT signed off yet.')+' '+B}if(n.length){const e=r.filter(e=>!e.soldOut&&n.every(t=>!e.allergens[t])),t=r.filter(e=>n.some(t=>'contains'===e.allergens[t]));return e.length+(1===e.length?' dish has':' dishes have')+' no '+n.map(z).join(' or ')+' listed'+(e.length?', for example '+e.slice(0,5).map(e=>e.name).join(', '):'')+'. '+t.length+' contain it. '+B}return'Which dish, or which allergen? For example \u201cdoes the fish supper contain gluten?\u201d.'}},{id:'set_sold_out',title:'Mark a dish sold out or back on',risk:'change',description:'Mark a menu dish sold out or back on. A reminder for staff: it shows on the Display and in the Sold out list.',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'soldOut',type:'string',required:!0,description:'yes = sold out, no = back on',enum:['yes','no']}],keywords:['sold out','back on','86'],match:e=>I(e,/\b(sold out|run out|ran out|out of stock|86|eighty.?six|back on|available again|back in stock|un.?86|none left)\b/)?4:0,parse:(e,t)=>{const r=F(e,t.rid),a=/\b(back on|available again|back in stock|un.?86)\b/i.test(e);return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,soldOut:a?'no':'yes'}},preview:e=>e.itemId?'Mark '+e.name+' '+('no'===e.soldOut?'back on':'sold out')+'?':e.name?e.name+' is on the Specials board; change it there.':'I couldn\u2019t find that dish on the menu.',run:async e=>e.itemId?((0,t.setSoldOut)(String(e.itemId),'no'!==e.soldOut),'Done: '+e.name+' is '+('no'===e.soldOut?'back on':'sold out')+'.'):'Nothing changed: I couldn\u2019t find that dish on the menu.'},{id:'change_price',apps:['owner'],title:'Change a menu price',risk:'change',description:'Change the price of a menu dish (managers only).',params:[{name:'itemId',type:'string',required:!0,description:'Menu item id'},{name:'name',type:'string',description:'Dish name'},{name:'pence',type:'integer',required:!0,description:'New price in pence'}],keywords:['price'],match:e=>I(e,/\b(price|charge|cost)\b/)&&I(e,/(\xa3|\d|pound)/)&&!I(e,/\b(special|offer)\b/)?3:0,parse:(e,t)=>{const r=F(e,t.rid),a=e.match(/\b(?:to|at)\s*\xa3?\s*(\d{1,3})(?:[.:](\d{1,2}))?/i)??e.match(/\xa3\s*(\d{1,3})(?:\.(\d{1,2}))?/)??e.match(/(\d{1,3})\s*pounds?(?:\s*(\d{1,2}))?/i),n=a?100*Number(a[1])+Number((a[2]??'0').padEnd(2,'0')):void 0;return{itemId:'menu'===r?.kind?r.id:void 0,name:r?.name,pence:n,old:r?.price??void 0}},preview:e=>e.itemId?'Change '+e.name+' from '+(null!=e.old?(0,b.gbp)(Number(e.old)):'its current price')+' to '+(null!=e.pence?(0,b.gbp)(Number(e.pence)):'?')+'?':'I couldn\u2019t find that dish on the menu.',run:async(e,t)=>{if(t.role&&!['owner','manager'].includes(t.role))return'Only managers can change prices.';const r=Number(e.pence);return e.itemId&&r>0&&r<1e5?(await i.repo.menu.updateItem(String(e.itemId),{price:r}),'Done: '+e.name+' is now '+(0,b.gbp)(r)+'.'):'Nothing changed: I need the dish and a price.'}},{id:'draft_special',apps:['owner','chef'],title:'Draft a special',risk:'draft',description:'Save a special as a draft for the owner to approve. It goes on the Specials board only after its allergens are checked.',params:[{name:'text',type:'string',required:!0,description:'The special, e.g. \u201cHake with mussels, \xa318\u201d'}],keywords:['special'],match:e=>I(e,/\bspecials?\b/)&&I(e,/\b(add|new|put|draft|today'?s|tonight'?s|change|set)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\bspecials?\b(?:\s*(?:board|is|are|to|:))?\s*/i,'').trim()||e}),preview:e=>'Save a draft special: \u201c'+e.text+'\u201d. Its allergens get checked before it goes on the board.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'special',title:'New special',lines:[String(e.text),'Add its allergens and post it on the Specials board when approved.'],by:D(t),app:O(t)}),'Saved as a draft special for the owner to approve. It isn\u2019t on the board yet.')},{id:'check_availability',title:'Check table availability',risk:'look',description:'Check whether a table is free for a party at a date and time, and suggest nearby times if not.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'}],keywords:['availability','table for','free table'],match:e=>I(e,/\b(availability|available|space|room for|any room|got room|any tables?|got a table|free table|have we got|is there a table|can we fit|fit in)\b/)&&!I(e,/\b(sold|back on|allerg)/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r)}},preview:e=>'Check a table for '+(e.covers??'?')+' at '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'today'),run:(e,t)=>{const r=Number(e.covers),a=String(e.time),n=String(e.date??t.today),o=K(t.rid,n,a,r);if(o.length)return'Yes, there\u2019s room for '+r+' at '+a+' on '+N(n)+'. Best fit: table '+o[0].table+(o[0].area?' ('+o[0].area+')':'')+'.';const i=[];for(const e of[-30,30,-60,60,-90,90]){const o=W(a,e);if(K(t.rid,n,o,r).length&&i.push(o),i.length>=3)break}return'No table for '+r+' at '+a+' on '+N(n)+'.'+(i.length?' Free nearby: '+i.sort().join(', ')+'.':' Nothing free within 90 minutes either.')}},{id:'draft_booking',title:'Take a booking (draft)',risk:'draft',description:'Take a booking as a DRAFT for the owner to confirm in Bookings. The guest confirmation is only sent from there.',params:[{name:'covers',type:'integer',required:!0,description:'Party size'},{name:'date',type:'date',required:!0,description:'YYYY-MM-DD'},{name:'time',type:'time',required:!0,description:'HH:mm'},{name:'name',type:'string',description:'Guest name'}],keywords:['book','booking','reserve'],match:e=>I(e,/\b(book|booking|reserve|reservation)\b/)&&!I(e,/\b(availability|any tables?|have we got|is there|how many|move|cancel|booker)\b/)?3:0,parse:(e,t)=>{const r=e.toLowerCase();return{covers:P(r),date:U(r,t.today),time:G(r),name:J(e)}},preview:(e,t)=>{const r=e.covers&&e.time?K(t.rid,String(e.date??t.today),String(e.time),Number(e.covers)):[],a=e.covers&&e.time?r.length?' Table '+r[0].table+' is free.':' NO table is free then.':'';return'Draft booking: '+(e.name??'guest')+', '+(e.covers??'?')+' covers, '+(e.time??'?')+' on '+(e.date?N(String(e.date)):'?')+'.'+a+' The owner confirms it in Bookings; nothing is sent to the guest now.'},run:(e,t)=>(0,r.validParty)(Number(e.covers))?(y.useDrafts.getState().add({rid:t.rid,kind:'booking',title:'Booking: '+(e.name??'guest')+', '+e.covers+' covers',lines:[N(String(e.date))+' at '+e.time,'Take their phone number when you confirm it in Bookings.'],data:{covers:e.covers,date:e.date,time:e.time,name:e.name},by:D(t),app:O(t)}),'Saved as a draft booking for the owner to confirm. No confirmation has been sent.'):`Nothing saved. ${r.PARTY_RULE} How many people?`},{id:'add_waitlist',title:'Add to the waitlist',risk:'change',description:'Add a party to the waitlist. Nobody is messaged.',params:[{name:'name',type:'string',description:'Name'},{name:'covers',type:'integer',required:!0,description:'Party size'}],keywords:['waitlist','waiting list'],match:e=>I(e,/\b(wait ?list|waiting list|queue)\b/)?4:0,parse:e=>({name:J(e)??e.match(/\badd\s+([A-Z][a-z'\u2019-]+)\b/)?.[1],covers:P(e.toLowerCase())}),preview:e=>'Add '+(e.name??'a guest')+', '+(e.covers??'?')+' covers, to the waitlist?',run:async(e,t)=>{const a=Number(e.covers);if(!(0,r.validParty)(a))return`Nothing added: how many people? ${r.PARTY_RULE}`;return'Done: '+(await i.repo.waitlist.join(t.rid,String(e.name??'Guest'),a)).name+' is on the waitlist. Nobody has been messaged.'}},{id:'read_orders',title:'Read out orders',risk:'look',description:'Read out the live orders and takeaways.',params:[],keywords:['orders'],match:e=>I(e,/\b(orders?|takeaways?|tickets?|collections?)\b/)&&I(e,/\b(read|what|any|list|how many|open|live|waiting|outstanding|pending|due|next)\b/)&&!I(e,/\b(shopping|booker|bidfood|supplier)\b/)?3:0,preview:()=>'Read out the live orders',run:(e,t)=>{const r=s.useStore.getState().orders.filter(e=>e.restaurantId===t.rid&&Q(e)).sort((e,t)=>(e.slotTime??e.createdAt).localeCompare(t.slotTime??t.createdAt));if(!r.length)return'No live orders right now.';const n=r.filter(e=>'takeaway'===e.type).length;return A(r.length,'live order')+' ('+n+' takeaway). '+r.slice(0,6).map(e=>{return('takeaway'===e.type?'Takeaway ':(0,a.tableNumbers)(e.tableNo)+' ')+e.ref+' for '+e.customerName+', '+A(e.lines.reduce((e,t)=>e+t.qty,0),'item')+', '+e.status+(e.slotTime?', due '+(t=e.slotTime,new Date(t).toLocaleTimeString('en-GB',{hour:'2-digit',minute:'2-digit'})):'')+(e.allergies.length?', HAS ALLERGIES':'');var t}).join('. ')+(r.length>6?'. And '+(r.length-6)+' more.':'.')}},{id:'day_numbers',title:'Covers, sales and forecast',risk:'look',description:'How many covers are booked today and tomorrow, sales through CoverCharge so far today, and the forecast for the rest of today.',params:[],keywords:['covers','sales','forecast'],match:e=>I(e,/\b(covers|sales|takings|revenue|forecast|how busy|busy tonight|expected|how many (people|guests|bookings))\b/)&&!I(e,/\b(walk|seat|wait ?list|add|book (a|for|in))\b/)?3:0,preview:()=>'Today\u2019s covers, sales and forecast',run:(e,t)=>{const r=s.useStore.getState(),a=v(),o=S(a),i=r.restaurants.find(e=>e.id===t.rid),d=r.bookings.filter(e=>e.restaurantId===t.rid),l=d.filter(e=>e.date===o&&['confirmed','seated','finished'].includes(e.status)),c=l.reduce((e,t)=>e+t.partySize,0),p=l.filter(e=>e.walkIn).reduce((e,t)=>e+t.partySize,0),h=new Date(a);h.setDate(h.getDate()+1);const u=S(h),f=d.filter(e=>e.date===u&&['confirmed','pending'].includes(e.status)).reduce((e,t)=>e+t.partySize,0),m=r.orders.filter(e=>e.restaurantId===t.rid),g=m.filter(e=>e.createdAt.slice(0,10)===o&&'cancelled'!==e.status),y=g.reduce((e,t)=>e+t.subtotal,0);let w='';if(i){const e=(0,n.forecastToday)(i,d,m,r.events,a);w=e.open?e.enough?' Forecast for the rest of today: about '+e.restOfDay.covers+' covers ('+(0,n.coversRange)(e.restOfDay.low,e.restOfDay.high,!1)+')'+(e.example?', example figures.':'.'):' No forecast yet: not enough history ('+e.restOfDay.booked+' covers booked for the rest of today).':''}return'Today: '+c+' covers booked or seated'+(p?', including '+p+' walk-in':'')+'. '+A(g.length,'order')+' through CoverCharge so far'+('display'===t.app||'staff'===t.app||'staff'===t.role?'.':', '+(0,b.gbp)(y)+' before tips (till sales aren\u2019t included).')+w+' Tomorrow: '+f+' covers booked so far.'}},{id:'supplier_list',title:'Add to a Booker or Bidfood shopping list',risk:'draft',description:'Add items to a DRAFT shopping list for Booker or Bidfood for the owner to check and order on the supplier\u2019s site. Never places an order.',params:[{name:'supplier',type:'string',required:!0,description:'Supplier',enum:['booker','bidfood']},{name:'items',type:'string',required:!0,description:'Items separated by semicolons'}],keywords:['booker','bidfood','shopping list'],match:e=>I(e,/\b(booker|bidfood|bid food)\b/)?4:I(e,/\b(shopping list|order list|we need more|we'?re low on|running low)\b/)?3:0,parse:e=>({supplier:/\bbid ?food\b/i.test(e)?'bidfood':'booker',items:e.replace(/\b(to|on|onto)\s+(the\s+)?(booker|bidfood|bid food)?\s*(shopping\s+|order\s+)?list\b.*$/i,'').replace(/\b(from|at)\s+(booker|bidfood|bid food)\b/i,'').replace(/[,.]?\s*\b(put|add|stick)\s+(it|them|that|those)\b.*$/i,'').replace(/^.*?\b(add|need|order|get|put|low on)\b\s*/i,'').trim().split(/\s*(?:,|\band\b)\s*/i).map(e=>e.trim()).filter(Boolean).join('; ')}),preview:e=>'Add to the draft '+('bidfood'===e.supplier?'Bidfood':'Booker')+' list: '+String(e.items??'').split('; ').join(', ')+'. Nothing is ordered; the owner checks it and orders on the supplier\u2019s site.',run:(e,t)=>{const r=String(e.items??'').split('; ').filter(Boolean);if(!r.length)return'Nothing added: which items?';const a=y.useDrafts.getState().addToList(t.rid,'bidfood'===e.supplier?'bidfood':'booker',r,D(t),O(t));return'Added to the draft '+a.title+' ('+A(a.lines.length,'item')+'). Nothing has been ordered.'}},{id:'draft_offer',title:'Draft an offer',risk:'draft',description:'Save an offer or promotion as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The offer'}],keywords:['offer','promotion'],match:e=>I(e,/\b(offer|promotion|promo|deal|discount|happy hour|two for one|2 for 1)\b/)&&I(e,/\b(draft|create|make|set up|new|add|run|do)\b/)?3:0,parse:e=>({text:e.replace(/^.*?\b(?:offer|promotion|promo|deal)\b\s*(?:for|of|:)?\s*/i,'').trim()||e}),preview:e=>'Save a draft offer for the owner to approve: \u201c'+e.text+'\u201d. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'offer',title:'New offer',lines:[String(e.text)],by:D(t),app:O(t)}),'Saved as a draft offer for the owner to approve. Nothing was published or sent.')},{id:'draft_event',title:'Draft an event',risk:'draft',description:'Save an event (quiz, live music, tasting night) as a draft for the owner to approve. Nothing is published or sent.',params:[{name:'text',type:'string',required:!0,description:'The event'},{name:'date',type:'date',description:'YYYY-MM-DD'}],keywords:['event'],match:e=>I(e,/\b(event|quiz|live music|tasting|gig|party night|music night|open mic|ceilidh)\b/)&&I(e,/\b(draft|create|make|plan|set up|new|add|put on|run)\b/)?3:0,parse:(e,t)=>({text:e.replace(/^.*?\b(?:draft|create|make|plan|set up|add|put on|run)\b\s*(?:an?|the)?\s*(?:new\s+)?(?:event)?\s*(?:for|:)?\s*/i,'').trim()||e,date:/\b(tomorrow|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i.test(e)?U(e.toLowerCase(),t.today):void 0}),preview:e=>'Save a draft event for the owner to approve: \u201c'+e.text+'\u201d'+(e.date?' on '+N(String(e.date)):'')+'. Nothing is published or sent.',run:(e,t)=>(y.useDrafts.getState().add({rid:t.rid,kind:'event',title:'New event',lines:[String(e.text),...e.date?[N(String(e.date))]:[]],data:{date:e.date},by:D(t),app:O(t)}),'Saved as a draft event for the owner to approve. Nothing was published or sent.')},{id:'card_balance',apps:['owner','chef'],title:'Gift card or stamp card balance',risk:'look',description:'Look up a gift card balance by its code, or a summary of stamp cards.',params:[{name:'code',type:'string',description:'Gift card code'},{name:'kind',type:'string',description:'gift or stamp',enum:['gift','stamp']}],keywords:['gift card','voucher','stamp card'],match:e=>I(e,/\b(gift ?cards?|gift vouchers?|vouchers?|stamp ?cards?|stamps|loyalty)\b/)?3:0,parse:e=>{const t=e.toUpperCase().replace(/\b(GIFT|CARDS?|VOUCHERS?|BALANCE|CHECK|WHAT'?S|WHAT|THE|ON|IS|CODE|FOR|OF|HOW|MUCH|LEFT|STAMPS?|A)\b/g,' ').match(/[A-Z0-9][A-Z0-9 -]{3,}[A-Z0-9]/);return{kind:/stamp|loyalty/i.test(e)?'stamp':'gift',code:t?X(t[0]):void 0}},preview:e=>'stamp'===e.kind?'Stamp cards':'Gift card '+(e.code??''),run:(e,t)=>{const r=s.useStore.getState();if('stamp'===e.kind&&(0,o.staffServer)())return(0,o.loyaltySummary)().then(e=>A(e.members,'guest')+' have stamp cards here; '+A(e.rewardsReady,'reward')+' ready to use. To check one guest, open Stamp card and find or scan them.',()=>'I couldn\u2019t reach the stamp cards just now. Try again in a moment.');if('stamp'===e.kind){const e=r.stampCards.filter(e=>e.restaurantId===t.rid),a=e.reduce((e,t)=>e+t.rewardsAvailable,0);return A(e.length,'guest')+' have stamp cards here; '+A(a,'reward')+' ready to claim. To check one guest, scan their card in Stamp cards.'}if(!e.code)return'Read me the code on the gift card, letter by letter.';const a=String(e.code),n=r.giftCards.filter(e=>e.restaurantId===t.rid).find(e=>X(e.code)===a||a.length>=4&&X(e.code).includes(a));return n?'Gift card '+n.code+': '+(0,b.gbp)(n.balance)+' left of '+(0,b.gbp)(n.initial)+'.':'I couldn\u2019t find a gift card with that code. Check it and try again.'}},{id:'feedback_summary',title:'Summarise feedback',risk:'look',description:'Summarise the last 7 days of guest ratings and comments.',params:[],keywords:['feedback','reviews'],match:e=>I(e,/\b(feedback|reviews?|ratings?|complaints?|comments?|what are (guests|people) saying)\b/)?3:0,preview:()=>'Summarise this week\u2019s feedback',run:(e,t)=>{const r=v().getTime()-6048e5,a=s.useStore.getState().ratings.filter(e=>e.restaurantId===t.rid&&new Date(e.createdAt).getTime()>=r);if(!a.length)return'No guest feedback in the last 7 days.';const n=a.reduce((e,t)=>e+t.stars,0)/a.length,o=a.filter(e=>e.stars<=3&&e.comment).slice(0,2),i=a.filter(e=>e.stars>=5&&e.comment).slice(0,1);return A(a.length,'rating')+' in the last 7 days, averaging '+n.toFixed(1)+' stars.'+(i.length?' Best: \u201c'+i[0].comment+'\u201d.':'')+(o.length?' To look at: '+o.map(e=>'\u201c'+e.comment+'\u201d ('+e.stars+' stars)').join('; ')+'.':' No low scores.')}},{id:'shift_note',title:'Leave a shift note',risk:'change',description:'Leave a note for the next shift.',params:[{name:'text',type:'string',required:!0,description:'The note'}],keywords:['shift note','handover'],match:e=>I(e,/\b(shift note|leave a note|note for|handover|tell the next shift|let the next shift know|note that)\b/)&&!I(e,/\b(read|any notes|what notes)\b/)?4:0,parse:e=>({text:e.replace(/^.*?\b(?:shift note|leave a note|note for (?:the )?(?:next shift|tomorrow|tonight|morning|evening)|handover note|handover|tell the next shift|let the next shift know|note that)\b\s*(?:that|:|,|for the next shift)?\s*/i,'').trim()||e}),preview:e=>'Leave a shift note: \u201c'+e.text+'\u201d?',run:(e,t)=>(w.useShiftNotes.getState().add({rid:t.rid,text:String(e.text),by:D(t),app:O(t)}),'Shift note saved. It shows on the Shift notes screen.')},{id:'read_shift_notes',title:'Read shift notes',risk:'look',description:'Read out the latest open shift notes.',params:[],keywords:['notes'],match:e=>I(e,/\b(read|any|what|latest)\b.*\b(shift notes?|notes|handover)\b/)?5:0,preview:()=>'Read the latest shift notes',run:(e,t)=>{const r=w.useShiftNotes.getState().notes.filter(e=>e.rid===t.rid&&!e.done).slice(0,5);return r.length?r.map(e=>e.by+', '+new Date(e.at).toLocaleString('en-GB',{weekday:'short',hour:'2-digit',minute:'2-digit'})+': '+e.text).join('. '):'No open shift notes.'}}]},1500,[835,979,1128,860,1161,1263,874,831,1029,1034,995,862,861,1105,1106,1026,1035,867,1501,1502]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"DRAFT_LABEL",{enumerable:!0,get:function(){return o}}),Object.defineProperty(_e,"useDrafts",{enumerable:!0,get:function(){return f}});var e,t=r(_d[0]),s=(e=t)&&e.__esModule?e:{default:e},d=r(_d[1]),n=r(_d[2]);const o={booking:'Booking',shopping:'Shopping list',offer:'Offer',event:'Event',special:'Special',message:'Message',payment:'Payment',other:'Request'},f=(0,d.create)()((0,n.persist)((e,t)=>({drafts:[],add:t=>{const s={...t,id:`dr-${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`,at:(new Date).toISOString(),status:'draft'};return e(e=>({drafts:[s,...e.drafts].slice(0,300)})),s},addToList:(s,d,n,o,f)=>{const p=t().drafts.find(e=>e.rid===s&&'shopping'===e.kind&&e.supplier===d&&'draft'===e.status);if(p){const t={...p,lines:[...p.lines,...n]};return e(e=>({drafts:e.drafts.map(e=>e.id===p.id?t:e)})),t}return t().add({rid:s,kind:'shopping',supplier:d,title:('bidfood'===d?'Bidfood':'Booker')+" shopping list",lines:n,by:o,app:f})},decide:(t,s,d)=>e(e=>({drafts:e.drafts.map(e=>e.id===t?{...e,status:s,decidedBy:d,decidedAt:(new Date).toISOString()}:e)}))}),{name:'covercharge-drafts-v1',version:1,storage:(0,n.createJSONStorage)(()=>s.default)}))},1501,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useShiftNotes",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=(e=t)&&e.__esModule?e:{default:e},s=r(d[1]),o=r(d[2]);const c=(0,s.create)()((0,o.persist)(e=>({notes:[],add:t=>e(e=>({notes:[Object.assign({},t,{id:'sn-'+Date.now().toString(36),at:(new Date).toISOString()}),...e.notes].slice(0,300)})),setDone:(t,n)=>e(e=>({notes:e.notes.map(e=>e.id===t?Object.assign({},e,{done:n}):e)}))}),{name:'covercharge-shiftnotes-v1',version:1,storage:(0,o.createJSONStorage)(()=>n.default)}))},1502,[839,846,849]); +__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,"useCoach",{enumerable:!0,get:function(){return p}}),_e.findTarget=b,_e.CoachHost=function(){const{target:e,hint:s,nonce:x}=p(),[y,w]=(0,o.useState)(null),v=(0,o.useRef)(new n.default.Value(0)).current;if((0,o.useEffect)(()=>{n.default.loop(n.default.timing(v,{toValue:1,duration:1300,easing:l.default.out(l.default.quad),useNativeDriver:!1})).start()},[]),(0,o.useEffect)(()=>{if(w(null),!s||!e)return;let t=0,o=null,n=!1;const l=()=>{if(o=o&&o.isConnected?o:b(e),o){n||(o.scrollIntoView?.({block:'center',behavior:'smooth'}),n=!0);const e=o.getBoundingClientRect();w({x:e.left,y:e.top,w:e.width,h:e.height,vw:window.innerWidth,vh:window.innerHeight})}else++t>40&&w(null)},r=setInterval(l,150);l();const u=setTimeout(()=>p.getState().clear(),2e4);return()=>{clearInterval(r),clearTimeout(u)}},[x]),!s)return null;const C='fixed',R=!y||y.y+y.h+110p.getState().clear(),style:{alignSelf:'flex-end',backgroundColor:(0,t.soutersSurface)('#1A1408'),borderRadius:10,paddingHorizontal:14,paddingVertical:6},children:(0,h.jsx)(c.T,{colour:f.colours.gold,weight:"semibold",children:"Got it"})})]})})]})};var t=_r(d[0]),o=_r(d[1]),n=e(_r(d[2])),l=e(_r(d[3]));_r(d[4]);var r=e(_r(d[5])),u=e(_r(d[6])),s=_r(d[7]),c=_r(d[8]),f=_r(d[9]),h=_r(d[10]);const p=(0,s.create)(e=>({target:null,hint:null,nonce:0,show:(t,o)=>e(e=>({target:t??null,hint:o,nonce:e.nonce+1})),clear:()=>e({target:null,hint:null})}));function b(e){if('undefined'==typeof document)return null;const t=e=>e&&e.getClientRects().length?e:null;if(e.testID){const o=Array.from(document.querySelectorAll(`[data-testid="${e.testID}"]`)).map(t).find(Boolean);if(o)return o}if(e.label){const o=Array.from(document.querySelectorAll(`[aria-label="${e.label}"]`)).map(t).find(Boolean);if(o)return o}if(e.text){const o=e.text.toLowerCase(),n=Array.from(document.querySelectorAll('[role="button"], button, a')).filter(e=>(e.textContent??'').trim().toLowerCase().includes(o)).map(t).find(Boolean);if(n)return n}return null}},1503,[828,34,283,364,236,402,102,846,794,821,25]); +__d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"HELP_TOPICS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"HELP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"helpById",{enumerable:!0,get:function(){return a}});const t=['Bookings','Walk-ins','Table plan','Rota','Hours & pay','Tips','Team','Suppliers','Stock','Recipe cards','Displays','Settings','Accounts'],o=[{id:'new-booking',kind:'guide',topic:'Bookings',title:'Take a phone booking',keywords:['booking','reservation','book','table','phone','covers','reserve'],body:'Add a booking for a guest who calls or walks up to ask. The app only offers times that are really free.',steps:['Open Bookings (or tap New booking on Today).','Pick the date, time and number of covers.','Add the guest\u2019s name and phone, plus any allergies or notes.','Tap Save. The booking appears on the timeline and the floor plan.'],showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Tap New booking to start a booking.'}},{id:'move-booking',kind:'faq',topic:'Bookings',title:'How do I move a booking to another table or time?',keywords:['move','change','reschedule','table','booking','swap'],body:'Open the booking from Bookings or the timeline and tap Edit, or drag it to another table on the Display. Guests are not messaged unless you choose to.',showMe:{tab:'bookings',target:{testID:'add-booking'},hint:'Your bookings list is here. Tap a booking to change it.'}},{id:'walk-in',kind:'guide',topic:'Walk-ins',title:'Seat a walk-in',keywords:['walk-in','walkin','walk in','seat','no booking','covers','party'],body:'Record guests who arrive without a booking so the floor plan and covers stay right.',steps:['On the Display (the venue tablet), tap Walk-in. On a phone, say \u201cadd a walk-in for 2\u201d to the Assistant.','Choose the number of covers.','Pick a free table (the best fit is suggested).','Tap Seat. The table shows as seated.'],actions:['add_walkin']},{id:'table-plan',kind:'guide',topic:'Table plan',title:'Edit the table plan',keywords:['table plan','floor plan','layout','tables','move tables','designer','areas','seats'],body:'Drag tables into place, set seats, join tables and add areas such as Terrace or Garden.',steps:['Go to More \u203a Table plan.','Tap Open the designer.','Drag tables, or tap one to change its name and seats.','Tap Save. Displays and bookings use the new plan straight away.'],showMe:{tab:'more',page:'tableplan',target:{testID:'open-designer'},hint:'Open the designer to move tables.'}},{id:'rota',kind:'guide',topic:'Rota',title:'Build and publish the rota',keywords:['rota','shift','schedule','week','publish','staff hours','add shift'],body:'Plan the week, then publish it so staff see their shifts in the Staff app.',steps:['Go to More \u203a Rota.','Tap a person\u2019s day to add a shift (presets: lunch, dinner, double).','New shifts are drafts with a dashed amber border.','Tap Publish when the week is ready. Staff see only published shifts.'],showMe:{tab:'more',page:'rota',target:{testID:'rota-publish'},hint:'Tap a day to add a shift, then Publish here.'},actions:['add_rota_shift','publish_rota']},{id:'rota-copy',kind:'faq',topic:'Rota',title:'Can I copy last week\u2019s rota?',keywords:['copy','last week','repeat','rota','duplicate'],body:'Yes. On the Rota tap Copy last week. The shifts come over as drafts so you can tweak them before publishing.',showMe:{tab:'more',page:'rota',target:{testID:'rota-copy'},hint:'Copy last week\u2019s shifts as drafts.'}},{id:'sign-off',kind:'guide',topic:'Hours & pay',title:'Sign off hours',keywords:['sign off','signoff','confirm hours','approve','timesheet','clock','pending'],body:'Only confirmed hours count for pay and tips. Check clocked times against the rota and confirm them.',steps:['Go to More \u203a Sign off hours.','Flagged days (late, missing clock-out, long breaks) are at the top.','Tap a row to fix a time; give a short reason.','Tap Confirm all unflagged, then deal with the rest.'],showMe:{tab:'more',page:'signoff',target:{testID:'confirm-unflagged'},hint:'Confirm all the days that look right in one tap.'}},{id:'payroll-hours',kind:'guide',topic:'Hours & pay',title:'Export hours for payroll',keywords:['payroll','export','hours','spreadsheet','csv','excel','accountant','copy','print'],body:'Get each person\u2019s confirmed hours for a pay period into your spreadsheet or to your accountant.',steps:['Go to More \u203a Payroll hours.','Pick the pay period (or a tips fortnight, or a custom range).','Check the pending banner: sign those off first if you can.','Tap Copy for spreadsheet and paste into Excel or Google Sheets, or download a CSV, or print.'],showMe:{tab:'more',page:'hours',target:{testID:'copy-tsv'},hint:'Copy, then paste straight into your spreadsheet.'}},{id:'pay-dates',kind:'faq',topic:'Hours & pay',title:'How do I set our pay dates?',keywords:['pay day','payday','pay dates','cut-off','wages','monthly','fortnightly'],body:'Settings \u203a Pay & tips: set when tips are paid and how often, the wage pay day and the cut-off. Payroll hours and Tips day use these dates.',showMe:{tab:'more',page:'paysettings',target:{testID:'save-pay'},hint:'Change the dates above, then Save.'}},{id:'tips-day',kind:'guide',topic:'Tips',title:'Share out tips on tips day',keywords:['tips','tronc','gratuity','share','split','tips day','service charge'],body:'Enter the tips total and it\u2019s shared by confirmed hours for the fortnight, to the penny.',steps:['Go to More \u203a Tips day (the right fortnight is picked for you).','Type the total tips.','Check anyone with pending hours; sign them off first if you can.','Copy or download the split for payroll.'],showMe:{tab:'more',page:'tipsday',target:{testID:'tips-total'},hint:'Type the tips total here.'}},{id:'invites',kind:'guide',topic:'Team',title:'Invite staff to the app',keywords:['invite','link','staff app','new starter','sign in','add staff','team member'],body:'Each person gets their own sign-in link. You choose when and how to share it.',steps:['Go to Settings \u203a Invite links.','Tap Make invite link next to the person.','Share the link yourself (text or WhatsApp). The app never sends it for you.','They tap it once and the Staff app remembers them.'],showMe:{tab:'more',page:'setup-invites',target:{text:'Make invite link'},hint:'Make a personal link, then share it yourself.'}},{id:'suppliers',kind:'guide',topic:'Suppliers',title:'Suppliers and order sheets',keywords:['supplier','order','order sheet','delivery','cut-off','fish','veg','dairy'],body:'Keep supplier contacts, order days and cut-offs together, and log what you ordered.',steps:['Go to More \u203a Suppliers to add or edit a supplier.','Use Supplier order sheets for the items you usually order.','Tap Log an order after you place it by phone or email.'],showMe:{tab:'more',page:'ordersheets',target:{testID:'sheet-add'},hint:'Add an order sheet for a supplier.'}},{id:'display-glance',kind:'guide',topic:'Display',title:'Today at a glance (Display)',keywords:['glance','today','covers by hour','breaks','on now','next','cut-off','cutoff','order times','display bar'],body:'The bar under the Display header shows today in one line: covers by hour (booked in solid gold, the walk-in estimate dashed), quiet times for breaks, who is on now and next, today\u2019s supplier order cut-offs with a countdown (amber under 30 minutes) and one tip. Cut-offs come from Scheduled notifications.'},{id:'sold-out',kind:'guide',topic:'Menu',title:'Sold out dishes',keywords:['sold out','run out','ran out','none left','back on','86','eighty six','display strip'],body:'When a dish runs out, mark it sold out so every member of staff knows. It\u2019s a reminder for staff: CoverCharge doesn\u2019t link up to your till, so it doesn\u2019t change the till. Sold out dishes show in a slim strip along the bottom of the Display within seconds, and in the Sold out list in Front of House, Managers and Head Chef. They clear by themselves when the kitchen closes (or the next morning, or only when you tap Back on: Settings \u203a Advanced \u203a Sold out reminders).',steps:['Open the Sold out list (Managers: More \u203a Sold out; Front of House: Me \u203a Sold out; Head Chef: Kitchen \u203a Live tickets \u203a Sold out).','Tap Mark sold out next to the dish.','When it\u2019s back, tap Back on.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-search'},hint:'Find the dish, then tap Mark sold out.'}},{id:'shellfish',kind:'guide',topic:'Stock',title:'Live shellfish (and other) counts',keywords:['shellfish','lobster','crab','oysters','count','stock','tracked','sold out','86'],body:'Counters for things you sell by the unit, like lobster or crab. They show on the Display and warn when low.',steps:['Go to Settings \u203a Tracked stock.','Tap Add an item to track; set the name, icon and low warning.','Staff update the count from the small lobster and crab chip at the top of the Display, or in the app.'],showMe:{tab:'more',page:'trackedstock',target:{text:'Add an item to track'},hint:'Add something to count, like lobster.'}},{id:'recipe-cards',kind:'guide',topic:'Recipe cards',title:'Recipe cards',keywords:['recipe','card','dish','ingredients','method','allergens','spec'],body:'Photo, ingredients, method and allergens for each dish; the head chef signs them off and staff can read them.',steps:['Go to More \u203a Recipe cards.','Search for a dish or add a new one.','Fill in ingredients (allergens are suggested) and the method.','Send for head chef sign-off.'],showMe:{tab:'more',page:'recipecards',target:{testID:'card-search'},hint:'Search your recipe cards here.'}},{id:'display-pair',kind:'guide',topic:'Displays',title:'Pair a display or tablet',keywords:['display','tablet','pair','screen','code','front of house','kitchen screen'],body:'Connect a tablet to your venue with a one-time code. You can switch any display off from here.',steps:['Open the Display app on the tablet.','In Managers go to Settings \u203a Displays and tap Make a pairing code.','Type the code on the tablet. It joins your venue straight away.'],showMe:{tab:'more',page:'displays',target:{text:'Make a pairing code'},hint:'Make a one-time code for the tablet.'}},{id:'settings-hours',kind:'faq',topic:'Settings',title:'How do I change our opening hours?',keywords:['opening hours','hours','closed','open','kitchen hours','times'],body:'Settings \u203a Opening hours. Guests see these on your booking and order pages; bookings outside them are turned away.',showMe:{tab:'more',page:'setup-hours',hint:'Set each day\u2019s opening and closing time here.'}},{id:'replay-setup',kind:'faq',topic:'Settings',title:'Can I see the welcome walkthrough again?',keywords:['welcome','setup','walkthrough','onboarding','checklist','questionnaire'],body:'Yes: Settings \u203a Setup checklist \u203a Replay welcome. Everything is pre-filled from your questionnaire.',showMe:{tab:'more',page:'setupchecklist',target:{testID:'replay-welcome'},hint:'Replay the welcome walkthrough.'}},{id:'connected-accounts',kind:'guide',topic:'Accounts',title:'Connect your email, website and socials',keywords:['connect','account','gmail','outlook','wix','facebook','instagram','square','xero','quickbooks','login'],body:'Settings \u203a Connected accounts: tap a logo, save the account to your list, and use Connect with\u2026 to sign in on that service\u2019s own page (rolling out service by service; it shows Coming soon until then). CoverCharge never sees your password that way, and you can remove an account any time.',steps:['Go to Settings \u203a Connected accounts.','Tap the service\u2019s logo.','Tap Connect with\u2026 and sign in on their page.','To stop, tap Remove.'],showMe:{tab:'more',page:'connections',target:{testID:'conn-tile-gmail'},hint:'Tap a logo to connect that account.'}},{id:'supplier-portals',kind:'guide',topic:'Suppliers',title:'Order from Bidfood or Booker',keywords:['bidfood','booker','wholesale','cash and carry','order online','supplier login','account number','customer number'],body:'Settings \u203a Connected accounts \u203a Suppliers. Add Bidfood or Booker for this venue, with your account number if you like. Open ordering and Log in open the supplier\u2019s own website, where you sign in; CoverCharge never keeps the password.',steps:['Go to Settings \u203a Connected accounts.','Scroll to Suppliers.','Tap Add Bidfood or Add Booker (account number optional).','Tap Open ordering or Log in whenever you need them.','To stop, tap Remove and confirm.'],showMe:{tab:'more',page:'connections',target:{testID:'portal-bidfood'},hint:'Your supplier ordering websites live here.'}},{id:'support',kind:'faq',topic:'Settings',title:'How do I get help from a person?',keywords:['support','help','contact','person','problem','broken','stuck'],body:'Support is free for life. Message the CoverCharge team from Settings \u203a Help, or email us, and we\u2019ll reply. We help by message and email.'},{id:'assistant-safe',kind:'faq',topic:'Settings',title:'Can the Assistant send or pay for things by itself?',keywords:['assistant','safe','confirm','send','pay','delete','ai'],body:'No. The Assistant and the voice helper show you exactly what they will do and wait for you to tap Confirm (or say yes). Anything that would send a message, order from a supplier or pay is only saved as a draft in Drafts for approval; nothing goes out by itself.'},{id:'restaurant-dashboard',kind:'guide',topic:'Bookings',title:'Restaurant dashboard',keywords:['restaurant dashboard','tables','timeline','guests','covers','joined tables'],body:'In Managers, tap Restaurant dashboard on Home, or More > Run the day > Restaurant dashboard. It is the same live table plan, Timeline, guest list, deposits, dogs, joined tables, Covers, covers-through-the-day chart and block bookings as the Display. Use the day arrows and Back to today. Assign or join tables on any day; seat, finish, no-show and cancel walk-in actions apply today. You can also say \u201copen Restaurant dashboard\u201d. The helper replies in text only.',showMe:{tab:'more',page:'serviceboard',target:{testID:'restaurant-dashboard-close'},hint:'Restaurant dashboard is open. Pick a day, or tap Back to Managers to close.'}},{id:'voice-helper',kind:'guide',topic:'Settings',title:'Use the hold-to-talk voice button',keywords:['voice','talk','speak','microphone','mic','hold','walkie','button','hands free','gloves'],body:'Hold the big gold button, say what you need, then let go. It logs fridge and freezer temperatures, answers allergen questions, marks dishes sold out, checks tables, adds to the waitlist, reads orders and covers, and drafts bookings, offers, events and Booker or Bidfood lists. The helper replies in text only, never aloud. Changes are shown in text first with Confirm and Cancel buttons: tap Confirm or say yes. Tap the button to type instead (in Managers this also opens the Assistant). It sits at the top right of the header in Managers, Head Chef, the Staff app (the full voice assistant, with no money, tips or HR) and on the Display (no money, tips or HR). Until the voice assistant\u2019s server is switched on, anything new says \u201cVoice assistant is switching on soon\u201d. Fair usage: 1,000 voice tasks a month per venue.',steps:['Hold the gold microphone button (the first time, allow the microphone).','Speak, for example \u201cprep fridge 3 degrees\u201d.','Let go to send.','If it reads something back, tap Confirm or hold again and say \u201cyes\u201d.','The button stays at the top right so it never covers the screen.'],showMe:{tab:'more',page:'voice',hint:'Turn the voice button on or off for each role here.'}},{id:'voice-drafts',kind:'faq',topic:'Settings',title:'Where do voice bookings and shopping lists go?',keywords:['drafts','approve','approval','shopping list','booker list','bidfood list','draft booking','offer','event'],body:'To Settings \u203a Drafts for approval. Bookings, Booker and Bidfood shopping lists, offers, events and specials made by voice wait there for an owner or manager. Approving marks it approved and opens the right screen; you still place the order or confirm the booking yourself.',showMe:{tab:'more',page:'drafts',hint:'Drafts from the voice helper wait here.'}},{id:'voice-temps',kind:'guide',topic:'Settings',title:'Log fridge and freezer temperatures by voice',keywords:['temperature','fridge','freezer','haccp','food safety','eho','log temps','probe'],body:'Hold the voice button and say the unit and the number, for example \u201cprep fridge 3, freezer minus 19\u201d. Fridges should be 5\xb0C or colder and freezers -18\xb0C or colder; anything outside is flagged. Everything is in the Food safety log with who and when, ready to export or print for the EHO.',showMe:{tab:'more',page:'haccp',hint:'Every voice reading appears in the food safety log.'}},{id:'voice-fair-usage',kind:'faq',topic:'Settings',title:'Is there a limit on voice tasks?',keywords:['voice','limit','allowance','fair usage','fair use','how many','tasks','month','plan'],body:'Fair usage: 1,000 voice tasks a month per venue. It is one allowance shared by all of the venue\u2019s apps and devices, and it resets on the 1st. Each request counts once, spoken or typed; saying \u201cyes\u201d to confirm does not count again. You will see a note at 80%. If the venue reaches 1,000, the voice helper pauses until the 1st, except food safety and temperature logging, which always works. The owner can contact CoverCharge if you need more. See the count in Plan & billing or Settings \u203a Voice helper.',showMe:{tab:'more',page:'voice',hint:'This month\u2019s voice task count is shown here.'}},{id:'adv-bookings',kind:'guide',topic:'Settings',title:'Booking questions: allergies, dogs, access, vegan',keywords:['advanced','allergen','dog','dogs','cap','wheelchair','access','vegan','vegetarian','table request','settings'],body:'Choose what guests are asked when they book. Allergies are always asked first, in red, and staff tick \u201cAllergens seen\u201d. The others can be switched off.',steps:['Open More \u203a Settings \u203a Advanced.','In Bookings, tick or untick each question.','Use the dog stepper to cap dogs per booking time (No limit = only the dog-friendly tables).','Mark dog-friendly and step-free tables on the Table plan.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-bookings'},hint:'Booking questions are here.'}},{id:'adv-table-times',kind:'guide',topic:'Settings',title:'How long tables stay (table times)',keywords:['advanced','dwell','table time','turn','how long','next table free','minutes'],body:'Usual table times by party size: 90 min for 1\u20132 covers, 105 for 3\u20135, 2 hours for 6\u201319 and 3 hours for 20 or more. The app fine-tunes them from how long your tables really stay, and uses them for \u201cNext table free\u201d.',steps:['Open More \u203a Settings \u203a Advanced \u203a Table times.','Tap \u2212 or + to change a band by 5 minutes.','Untick \u201cFine-tune\u201d to use your numbers exactly.','Reset to default puts the four bands back.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-times'},hint:'Table times are here.'}},{id:'adv-reservable',kind:'guide',topic:'Settings',title:'Seafood platter, crab and lobster reservations',keywords:['advanced','platter','seafood','crab','lobster','reserve','price'],body:'Guests can reserve the Seafood Platter (1 crab + 1 lobster, \xa3160) or a crab or lobster with their booking. Reserved ones come off the Display count with a \u201cReserved\u201d line, the kitchen is told, and the Head Chef taps OK.',steps:['Open More \u203a Settings \u203a Advanced \u203a Reservable items.','Tick what guests can reserve and set the price.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-reserve'},hint:'Reservable items are here.'}},{id:'adv-events',kind:'guide',topic:'Settings',title:'Regular events like Open Mic Night',keywords:['advanced','open mic night','music night','event','regular','monthly','promote','busier','last food'],body:'Add events that repeat, e.g. Open Mic Night on the last Sunday of every month from 8pm with last food orders at 7pm. They show in Forecast key dates with a Promote button and on Today, and \u201cExpect busier\u201d raises the forecast.',steps:['Open More \u203a Settings \u203a Advanced \u203a Regular events.','Tap Add a regular event (or Edit).','Pick how it repeats and the day, add a start time and last food orders if needed.','Tap Save event.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-events'},hint:'Regular events are here.'}},{id:'adv-hours',kind:'guide',topic:'Settings',title:'Kitchen hours, seasons and special days',keywords:['advanced','hours','kitchen','season','winter','summer','special day','closed','last food orders','cutoff'],body:'Kitchen (food) hours decide which booking times are offered; the closing time is last food orders. Keep Winter and Summer hours, each with the date it starts every year, and the app switches by itself. Add special days for one-off changes.',steps:['Open More \u203a Settings \u203a Advanced \u203a Kitchen hours.','Tap Set Summer hours, fill in each day and the start date (e.g. 04-01 for 1 April).','Set the Winter start date too.','Use Add a special day for closures or late nights.'],showMe:{tab:'more',page:'advanced',target:{testID:'adv-hours'},hint:'Kitchen hours and seasons are here.'}},{id:'adv-home',kind:'faq',topic:'Settings',title:'Covers counter, Next table free and takeaway on home screens',keywords:['advanced','covers counter','takeaway','next table free','home','display','flip'],body:'Turn the COVERS counter and the \u201cNext table free\u201d card on or off, and choose whether takeaway figures show on home screens (off at the Anchorage). Takeaway order alerts always work. The flap click sound is set on each Display.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-home'},hint:'Display and home options are here.'}},{id:'adv-holidays',kind:'faq',topic:'Settings',title:'Why don\u2019t bank holidays say \u201c(substitute day)\u201d?',keywords:['advanced','holiday','substitute','bank holiday'],body:'The date already shows when a holiday moves, so the extra words are hidden. Tick \u201cShow full gov.uk names\u201d in Settings \u203a Advanced \u203a Holiday names to bring them back.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-holidays'},hint:'Holiday names are here.'}},{id:'adv-blocks',kind:'guide',topic:'Settings',title:'Lunch and dinner times for Block now',keywords:['block','lunch','dinner','service','wix','advanced','pause'],body:'Settings \u203a Advanced \u203a Block bookings sets when Lunch and Dinner run, for the Block now buttons and Spend per head. At The Anchorage, blocks also close those times on website bookings, and blocks made on the website show in CoverCharge. Website bookings can only close the whole venue, not one area or some tables.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-blocks'},hint:'Block bookings settings are here.'}},{id:'blocks-screen',kind:'guide',topic:'Bookings',title:'Block bookings: today, a future date, an area or some tables',keywords:['block','blocks','pause','close','closed','stop bookings','private','repeat','future'],body:'Tap Block bookings on the home screen. Block now pauses bookings today (Rest of today, Next hour, Lunch, Dinner, or a From\u2013To). Add a block closes a future date or range, the whole day or set times, the whole venue, one area or some tables, once or every week or on the last weekday of the month. Every future block is listed by month with Edit and Remove; removing asks first and is logged. Bookings already made are kept, and you are told how many.',showMe:{tab:'more',page:'blocks',target:{testID:'blocks-screen'},hint:'Block bookings is here.'}},{id:'spend-per-head',kind:'guide',topic:'Money',title:'Spend per head',keywords:['spend per head','sph','average spend','takings','covers','gross'],body:'Spend per head is Gross takings \xf7 Covers, by day, by week and for lunch and dinner. Enter the gross on the cash up (Take a picture of the taking sheet, Upload a spreadsheet, or Enter takings). Covers are seated and finished bookings and walk-ins; no-shows and cancellations are left out. A day with no takings shows \u201cNo takings entered\u201d, never \xa30.',showMe:{tab:'more',page:'spendhead',target:{testID:'sph-screen'},hint:'Spend per head is here.'}},{id:'cashup-photo',kind:'guide',topic:'Money',title:'Take a picture of the taking sheet, or upload a spreadsheet',keywords:['cash up','photo','spreadsheet','csv','excel','xlsx','camera','sheet','gross','card','cash','tips','takings'],body:'In Cash up & sales tap Take a picture of the taking sheet: the camera opens and the figures are filled in from the photo. Check every figure beside the photo (gross, card, cash, tips, food and drink), change anything that is wrong, then tap Confirm and save. Bigger venues can tap Upload a spreadsheet (CSV or Excel): match the columns, check the preview (dates already saved are flagged), then confirm. Nothing is saved before you confirm, and every save is logged. If the photo can\u2019t be read, type the figures in.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'The taking sheet buttons are here.'}},{id:'adv-giftqr',kind:'guide',topic:'Settings',title:'Buy a gift card on the Display',keywords:['gift','gift card','voucher','qr','display','wix','advanced'],body:'Switch on \u201cShow Buy a gift card on the Display\u201d in Settings \u203a Advanced \u203a Gift cards on the Display, and save your gift card page address. The Display has a Gift vouchers button: it opens the list of website vouchers (search, use by dates, Mark as used), with Show the buy QR code at the bottom. Guests buy on your website.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-giftqr'},hint:'Gift cards on the Display are here.'}},{id:'adv-whatsapp',kind:'guide',topic:'Settings',title:'WhatsApp buttons (tap to chat)',keywords:['whatsapp','wa.me','message','chat','guest','mobile','number','advanced'],body:'Put the venue\u2019s WhatsApp number in Settings \u203a Advanced \u203a WhatsApp, e.g. 01292 500123 or +44 7700 900123. Guests then see \u201cMessage us on WhatsApp\u201d on their booking confirmation, with their booking details typed in. Staff and managers see \u201cWhatsApp guest\u201d on bookings with a mobile number, with a confirmation typed in that you can change. Nothing is ever sent for you: WhatsApp opens and you tap Send yourself. Leave the number blank and every WhatsApp button stays hidden. Reset to default clears the number.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-whatsapp'},hint:'The WhatsApp number is here.'}},{id:'adv-reminders',kind:'guide',topic:'Settings',title:'Staff reminders: breaks and \u201cchairs up\u201d',keywords:['reminder','reminders','break','breaks','chairs','closing','6 hours','law','snooze','later','done','advanced'],body:'Reminders slide up for staff who are on shift right now (clocked in, or on the rota at that time) in the Staff and Head Chef apps, while the app is open. Break reminders: if the rota shift has a break time, the reminder comes at that time; if not, it comes 4 hours after they clock in (or after the shift starts). If they still haven\u2019t started a break it comes once more 30 minutes later, and again at 6 hours, because UK law says a shift over 6 hours needs a 20-minute break. \u201cStart break\u201d starts their break; \u201cLater\u201d hides it for 15 minutes. You can change these times. Venue reminders, such as \u201cTime to put the chairs up on the tables\u201d (Friday and Sunday, 21:00), have wording, days, a time (UK) and who sees them: everyone on shift, front of house or kitchen. Pause, edit or delete any of them, or add your own. Once anyone taps Done it goes for everyone that day, and the Reminders screen shows who did it. Reset to default brings back the standard break times and \u201cchairs up\u201d; your own reminders stay. Phones with the app closed don\u2019t get reminders yet.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-reminders'},hint:'Reminders are here.'}},{id:'adv-notifications',kind:'guide',topic:'Settings',title:'Scheduled notifications (e.g. the Mills milk order)',keywords:['notification','notifications','push','phone','milk','mills','pieroni','pieronis','veg','olsen','rota upload','scheduled','advanced'],body:'Settings \u203a Advanced \u203a Notifications lists reminders that go to named people at a set UK time, such as \u201cMills milk order\u201d for the Head Chef and Gordon. Each has a title, a message, the days, a time (you can set a different time on some days, e.g. 20:55 on Fridays), who gets it (tick people or pick a group like Everyone on shift) and how it is sent. In the app it is the gold slider with Done and Later; Done is logged with the name and time, and Later hides it for 15 minutes. Urgent notices (like the 6-hour break) always come first and only one shows at a time. Phone notifications: each person taps \u201cTurn on phone notifications\u201d on their own phone (iPhone: add the app to the Home Screen first, iOS 16.4 or later). Nothing goes to phones until an owner or manager switches \u201cSend to phones\u201d on. The Display never gets these. Reset to default restores the configured rules.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-notifications'},hint:'Notifications are here.'}},{id:'adv-order-lists',kind:'guide',topic:'Settings',title:'Order lists (Alsons, Cash and carry)',keywords:['order list','orders','alsons','drinks','cash and carry','trip','shopping','logo','carry over','advanced'],body:'Order lists collect what you need from a supplier. A running list (Alsons drinks) fills up until you order; a trip list (Cash and carry) is for a shopping day, Friday by default, which you can change for each trip. Add an item with a quantity and unit and an optional note; the app records who added it and when. Adding something already on the list offers to add to the quantity instead. On the day, tick Got or Ordered, or mark Missing / not in stock. Finish order saves it to History (date and who) and asks whether to carry over anything not got. Removing an item can be undone. Settings \u203a Advanced \u203a Order lists: add, rename or archive lists, the default trip day, and \u201cLet all staff add items\u201d (on: staff can add and see lists; only managers and the Head Chef tick, remove or finish). Each list can have a logo (take a photo or choose one) or shows its initials, and a phone number to tap to call (never called for you).',showMe:{tab:'more',page:'advanced',target:{testID:'adv-orderlists'},hint:'Order list settings are here.'}},{id:'adv-clock-area',kind:'guide',topic:'Settings',title:'Clock-in area, forgotten breaks and off-rota arrivals',keywords:['clock','clock in','geofence','location','area','radius','break','forgot','rota','visiting','override','advanced'],body:'Clock in, clock out, start break and end break only work at the venue once the centre is set. Stand in the middle of the venue and tap \u201cUse my current location\u201d, then choose how far (at least 50 m, 100 m to start). Phones are not exact, so up to 50 m of the phone\u2019s own accuracy is allowed on top. Each clock record keeps the reading, its accuracy and whether it was inside. If location is off or blocked, the app says how to allow it. Managers can record it for someone from Clock in / out \u203a Record it for someone, with a reason that is logged. Until the centre is set nobody is blocked and managers see a warning. Rota and pay screens are never blocked. Forgotten breaks: if no break was recorded, Clock out asks \u201cDid you take a break? If so, how long?\u201d; a length you pick is saved as a break marked \u201cadded at clock-out\u201d, which managers see and can edit in Hours. Not on the rota: if someone is at the venue, not clocked in and not on the rota, the Staff and Head Chef apps ask \u201cDo you want to sign in?\u201d. Yes clocks them in, marked off-rota, and managers get a notice; \u201cNo, just visiting\u201d stops asking for the day. This only checks while the app is open; web apps can\u2019t watch location in the background.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-clockarea'},hint:'Clock-in area settings are here.'}},{id:'adv-tablegrid',kind:'guide',topic:'Table plan',title:'Table plan grid and Tidy up (Advanced)',keywords:['grid','snap','line up','align','tidy','guides','spacing','restore','table plan','option','alt'],body:'Tables snap to the grid when you drag them, and gold guides show when an edge or centre lines up with another table. A small number shows when the gaps either side are even. Hold Alt (Option on a Mac) to move freely. Tidy up lines every table up on the grid and evens out the rows; only positions change. The old positions are kept, so one tap puts them back.',steps:['Go to Settings \u203a Advanced.','Find Table plan grid.','Turn snapping on or off, pick a grid size, or tap Tidy up the whole plan.','Changed your mind? Tap Put the tables back where they were.']},{id:'adv-printers',kind:'guide',topic:'Orders',title:'Kitchen ticket printers (Advanced)',keywords:['print','printer','printing','ticket','kitchen ticket','docket','receipt','epson','star','bluetooth','reprint','takeaway'],body:'Print a kitchen ticket by itself for every takeaway order, as soon as it comes in or when it is accepted. The ticket has the order number, collection time, name, every dish with its options and notes, allergies in white-on-black, and paid or not paid. Works with Epson (TM-m30, TM-T20, TM-T88), Star WebPRNT, most other network receipt printers (port 9100) and Bluetooth printers from the tablet app. If a ticket does not print, an amber warning shows and the order stays on screen.',steps:['Go to Settings \u203a Advanced.','Find Printers.','Tap Add a printer by IP address or Find printers on this Wi-Fi, choose the type and tap Test print.','Turn on Print a kitchen ticket for every takeaway order.']},{id:'adv-deposits',kind:'guide',topic:'Bookings',title:'Deposits (Advanced)',keywords:['deposit','deposits','per person','per adult','children','waive','waived','regular','party size','refund','refundable','cut off','policy','paid','due'],body:'Ask bigger tables for a deposit: set the amount per adult (children never pay: a table of 8 with 3 children pays for 5), the smallest party that pays one, whether it is refundable and up to how many hours before, and the words guests see. No card is saved in CoverCharge. Deposits are paid through website bookings: website bookings show Deposit paid on website bookings, Part paid on website bookings or Deposit not paid by themselves. For phone and walk-in bookings, staff tick Deposit paid once the guest has paid you, or (once switched on) press Send deposit link to send a website bookings pay link by text, WhatsApp or email. Refunds are done in Website bookings \u203a Orders. Deposit amounts are shown on bookings in Managers, Display and Staff. Other financial and HR information remains restricted.',steps:['Go to Settings \u203a Advanced.','Find Deposits.','Turn deposits on or off, and set the amount, party size, refund terms and the words guests see.','On a booking, tap Mark deposit paid once the guest has paid.','To let a regular off, tap Waive deposit on the booking (or in Edit booking), add why if you like, and tap Yes, waive it. Your name is saved with it.']},{id:'adv-loyalty',kind:'guide',topic:'Guests',title:'Loyalty: stamp card, offers & bring a friend (Advanced)',keywords:['loyalty','stamp','stamps','card','reward','offer','offers','referral','friend','expiry'],body:'The stamp card, offers and bring-a-friend are saved on the server, so every phone and tablet shows the same card. Set how many stamps earn a reward, what the reward is, when stamps or rewards run out, and how often one guest can get a stamp. Stamps only come from staff, or from a code or QR staff make, and each reward can be used once. Guests join with their agreement recorded, and a manager can remove a guest and their details.',steps:['Go to Settings \u203a Advanced.','Find Loyalty.','Turn the stamp card on, write the reward and tap Save loyalty settings.','Add offers with their dates, and turn bring-a-friend on if you want it.']},{id:'adv-table-order',kind:'guide',topic:'Guests',title:'Order at the table (Advanced)',keywords:['order at table','qr','qr code','scan','table','phone','accept','last orders','print','pdf','pay at bar'],body:'Guests scan the small QR card on their table (Managers \u203a Table QR codes prints them, 20 to a page), see your menu with allergens, and send an order. It lands in Front of House and on the kitchen screen within seconds. Prices, sold-out dishes and hours are checked on the server, so a phone can\u2019t change them. Staff accept the first order from each new phone (you can turn this off). Guests pay at the bar or with their server; paying by card from the phone is coming later.',steps:['Go to Settings \u203a Advanced.','Find Order at the table.','Turn it on, pick the areas or tables, set the hours and tap Save order at the table.','Tap Make codes, pick Stickers 50 \xd7 50 mm or Stand cards 50 \xd7 70 mm, then Print all QR cards (PDF) and put each code on its table.']},{id:'adv-soldout',kind:'guide',topic:'Menu',title:'Sold out reminders (Advanced)',keywords:['sold out','86','clear','end of service','next morning','back on','advanced','display strip','automatic','counts','lobster','crab'],body:'Choose when sold out dishes go back on by themselves: when the kitchen closes (from your Kitchen hours), the next morning (pick the time), or only when someone taps Back on. \u201cMark dishes sold out from the counts\u201d (on unless you turn it off) marks every dish that uses a counted item, like lobster or crab, when the count runs out, and puts it back on when the count is back up. Sold out is a reminder for staff on the Display and in the staff apps; it doesn\u2019t change your till.',steps:['Go to Settings \u203a Advanced.','Find Sold out reminders.','Pick when they clear, and turn marking from the counts on or off.']},{id:'sold-out-auto',kind:'guide',topic:'Menu',title:'Sold out from the counts (lobster, crab\u2026)',keywords:['sold out','automatic','auto','counts','shellfish','lobster','crab','platter','link','uses','none left'],body:'When a counted item runs out, or drops below what a dish needs, every dish that uses it is marked sold out by itself, with the reason: \u201cDeluxe Seafood Platter (no lobster or crab)\u201d. When the count is back up (a delivery or a recount), those dishes go back on by themselves. Dishes marked by hand are left alone. CoverCharge works out what each dish uses from its recipe card, its description (\u201cone whole lobster\u201d) or its name; you can change it for any dish. If you tap Back on while the count is still short, the dish stays on until the count changes.',steps:['Open the Sold out list.','Under Dishes linked to the counts, tap Change next to a dish.','Set how many of each item one portion uses (0 = not linked), then tap Save. Back to automatic undoes it.'],showMe:{tab:'more',page:'soldout',target:{testID:'soldout-links'},hint:'Tap Change next to a dish to set what it uses.'}},{id:'adv-forecast',kind:'guide',topic:'Forecasts',title:'Forecast history and "Not enough history yet"',keywords:['forecast','not enough history','history','estimate','example figures','labour','sales','walk-ins','advanced'],body:'Forecasts are built only from your own bookings, seated walk-ins, takeaway orders and cash-ups. Until CoverCharge has enough of your history (2 weeks to start with; change it in Settings \u203a Advanced \u203a Forecast history) you see \u2018Not enough history yet\u2019, what is already booked and your real labour cost from the rota, with no sales forecast or labour %. No history is invented for a live venue.',steps:['Go to Settings \u203a Advanced.','Find Forecast history.','Pick how many weeks are needed.']},{id:'adv-checkout',kind:'guide',topic:'Team',title:'Shift check-out, question board and team morale',keywords:['check out','checkout','morale','mood','staffing','overstaffed','survey','anonymous','question board','vote','shout out','wellbeing','advanced'],body:'When someone clocks out, they get a quick card: team morale from Low to High, and whether there was enough staff for the customers. They can also post a question for the board or shout out a teammate, or tap Skip. Nothing shows at clock in. Answers are anonymous: no name or staff number is saved, and each phone can answer a shift once. Team morale (Managers app \u203a More \u203a Team morale) shows a day only once 3 or more people have answered, next to that day\u2019s covers. Change the wording or switch parts off here.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-checkout'},hint:'Check-out and board settings are here.'}},{id:'hr-board',kind:'guide',topic:'Team',title:'The anonymous question board',keywords:['question board','board','anonymous','vote','yes no','reply','hide','moderation','log'],body:'Anyone on the team can post a question and vote it up, or vote Yes or No. No names are shown or saved. Owners and managers can reply (shown as \u201cReply from the managers\u201d) and hide offensive posts with a reason. Every hide, unhide and reply is in the Moderation log.',showMe:{tab:'more',page:'board',hint:'The question board.'}},{id:'adv-tasks',kind:'guide',topic:'Team',title:'Daily tasks',keywords:['tasks','daily tasks','checklist','duties','jobs','to do','my tasks','library','head chef'],body:'Give each person a short list of daily tasks: open Staff & roles, tap Daily tasks on their card, then pick from the venue\u2019s task library or type a new one. Use the arrows to reorder, \u2715 to remove (with Undo) and Days to limit a task to certain days. They see \u201cMy tasks today\u201d on their home screen and tick each one off while on shift; each tick records who and when, and you see \u201c2 of 5 done today\u201d on their card. Lists start fresh every day. Owners and managers can change anyone\u2019s list, including the Head Chef\u2019s. The Head Chef can change the lists of kitchen staff (chefs, commis and KPs) from Kitchen \u203a Kitchen team tasks, but not their own and not front of house. The task library is in Settings \u203a Advanced \u203a Tasks.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tasks'},hint:'The task library is here.'}},{id:'adv-cashup',kind:'guide',topic:'Money',title:'Cash up and weekly sales',keywords:['cash up','cashup','takings','float','till','sales report','weekly sales','pos','printout','photo','graphs','charts'],body:'At the end of the night open Cash up & sales and tap Upload cash up sheet. Your phone camera opens; take a photo of the paper sheet (you can add several). The review screen shows the photo beside the figures. Automatic reading isn\u2019t switched on yet, so type each figure from the photo; boxes left blank stay blank (never counted as zero) and are highlighted in amber. Nothing is saved until you tap Confirm and save. Do the same with the weekly sales report from the till (several pages is fine). The graphs show daily takings, tips, weekly net sales against the week before and sales by category. Owners and managers can enter and change cash ups; the Head Chef can see the graphs. Change the boxes to match your sheet in Settings \u203a Advanced \u203a Cash up; Cash tips total and Card tips total are always kept.',showMe:{tab:'more',page:'cashup',target:{testID:'upload-cashup'},hint:'Start the cash up here.'}},{id:'adv-tips',kind:'guide',topic:'Money',title:'Today\u2019s tips and the Tips pot',keywords:['tips','today tips','tips pot','pot','payout','tip pay','correction','coins'],body:'When a cash up with Cash tips total and Card tips total is confirmed, the team\u2019s combined tips for that day show as Today\u2019s tips in every staff app and on the Display, with a short notice. The Tips pot adds up confirmed daily tips since the last payout (fortnightly tip pay). After paying the tips, an owner or manager taps Mark payout done on the Tips pot card: the pot goes back to \xa30.00 and the old pot is kept in Past pots. Use Correct an entry to add or take off an amount for a day; a reason is required and every correction is logged with your name. Only the team total is ever shown, never anyone\u2019s share. Hide either card in Settings \u203a Advanced \u203a Tips.',showMe:{tab:'more',page:'advanced',target:{testID:'adv-tips'},hint:'Show or hide the tips cards here.'}},{id:'manager-access',kind:'guide',topic:'Team',title:'Manager access',keywords:['manager access','manager','access','role','promote','front of house','head chef','owner'],body:'In Staff & roles each person has a Manager access switch. On: they use the Manager app (rota, bookings, staff, hours, settings, plus their own clock in, rota and pay). Off: they use the Front of House app, or the Head Chef app for the Head Chef. Owners can switch anyone except owners; managers can switch anyone except themselves and owners. The last owner can never be removed. You confirm each change; it is logged with who and when (Access changes). Job titles are free text and don\u2019t change.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'Manager access switches are on each person.'}},{id:'next-table-free',kind:'faq',topic:'Walk-ins',title:'When is the next table free?',keywords:['next table','free','wait','walk-in','quote','full'],body:'When you\u2019re full, Today and the Display show \u201cNext table free about 19:40 (T6, 4 seats)\u201d with \u201clikely\u201d or \u201cmaybe\u201d, and how long a walk-in for 2 or 4 would wait. Tap Bill requested or Table finished on the plan and it updates. You can also ask the Assistant \u201cwhen\u2019s the next table free?\u201d.'},{id:'time-travel',kind:'faq',topic:'Today',title:'Look at another day (time travel)',keywords:['yesterday','tomorrow','next week','past','future','day','time travel'],body:'On Today, tap \u2039 or \u203a beside the date to step a day back or forward. You\u2019ll see that day\u2019s kitchen hours, events, covers (booked, or how it went), platters and each booking\u2019s allergens and needs. It\u2019s read-only and nothing changes live service. Tap Today to come back. The Display goes back to today by itself after 2 minutes. Staff can look 7 days back and 14 days ahead.'},{id:'sign-in-links',kind:'guide',topic:'Team',title:'Personal sign-in links',keywords:['link','invite','sign in','new link','expired','already used','phone','login'],body:'Each personal link works on one phone only and lasts 5 days, so nobody else can sign in as that person. The same phone can open it again, in any of the apps. If someone gets a new phone, or their link has expired, open Staff & roles, tap New sign-in link on their entry, then Copy link and send it to them yourself. The app never sends it. Owners can make links for anyone; managers for anyone except owners. Their old unused link stops working; phones already signed in stay signed in.',showMe:{tab:'more',page:'staff',target:{testID:'access-tip'},hint:'New sign-in link is on each person.'}},{id:'pins-security',kind:'faq',topic:'Team',title:'PINs for the Display',keywords:['pin','display pin','clock in','wake pin','2580','manager pin','locked'],body:'Staff PINs for clocking in at the Display are 4 to 8 digits. Managers and owners need 6 to 8 digits, because their PIN can add temp staff. Easy PINs such as 1111 or 1234 are refused. Five wrong tries locks that person for 15 minutes; 20 wrong tries on one Display stops it for 15 minutes. The Display wake PIN (Settings \u203a Display) is 6 to 8 digits and is kept only as a scrambled hash. If it still says 2580, change it.'},{id:'cash-up-lock',kind:'faq',topic:'Money',title:'Correcting a signed-off cash up',keywords:['cash up','locked','unlock','correct','mistake','history','audit','sales report'],body:'Once a cash up or weekly sales report is confirmed and saved, it is locked so the figures can\u2019t change quietly. An owner taps Unlock to correct on it, says why, and has 30 minutes to fix it. History on each one shows who signed it off, changed or unlocked it, and when.'},{id:'wipe-device',kind:'faq',topic:'Settings',title:'Sign out and wipe a shared tablet or phone',keywords:['wipe','sign out','shared','tablet','leaver','lost','reset device'],body:'Tap the sync badge (bottom left), or go to Settings \u203a Display, and choose Sign out and wipe this device. It signs out and removes everything CoverCharge keeps on that device: sign-ins, pairing, saved screens and changes not sent yet. The venue\u2019s shared data is not touched. On the Display you type the wake PIN first.'}],a=t=>o.find(o=>o.id===t)},1504,[]); +__d(function(g,r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"tokens",{enumerable:!0,get:function(){return o}}),e.lev=l,e.searchHelp=function(n,l,i=8){const h=o(l);if(!h.length)return[];const a=t(l);return n.map(n=>{const l=o(n.title),i=o(n.keywords.join(' ')),c=o(`${n.body} ${(n.steps??[]).join(' ')}`);let f=3*s(h,l)+2.5*s(h,i)+.8*s(h,c);return n.keywords.some(n=>a.includes(t(n))&&t(n).length>3)&&(f+=2),t(n.title).includes(a)&&a.length>3&&(f+=3),{a:n,score:f/Math.sqrt(h.length)}}).filter(t=>t.score>=1.2).sort((t,n)=>n.score-t.score).slice(0,i)};const t=t=>t.toLowerCase().replace(/[\u2019']/g,'').replace(/[^a-z0-9\xa3 ]+/g,' ').replace(/\s+/g,' ').trim(),n=new Set(['how','do','i','a','an','the','to','can','my','our','we','is','it','of','for','in','on','and','what','where','please','me','you','with']),o=o=>t(o).split(' ').filter(t=>t&&!n.has(t));function l(t,n,o=2){if(Math.abs(t.length-n.length)>o)return o+1;let l=Array.from({length:n.length+1},(t,n)=>n);for(let i=1;i<=t.length;i++){const s=[i];let h=i;for(let o=1;o<=n.length;o++)s[o]=Math.min(l[o]+1,s[o-1]+1,l[o-1]+(t[i-1]===n[o-1]?0:1)),h=Math.min(h,s[o]);if(h>o)return o+1;l=s}return l[n.length]}function i(t,n){if(t===n)return 1;if(t.length>=3&&n.startsWith(t))return.8;if(n.length>=4&&t.startsWith(n))return.7;if(t.length>=4){if(l(t,n,t.length>=7?2:1)<=(t.length>=7?2:1))return.6}return 0}function s(t,n){let o=0;for(const l of t){let t=0;for(const o of n)if(t=Math.max(t,i(l,o)),1===t)break;o+=t}return o}},1505,[]); +__d(function(g,r,_i,_a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"STAFF_VOICE_ACTIONS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(_e,"STAFF_ALLOWED",{enumerable:!0,get:function(){return C}});var e=r(_d[0]),t=r(_d[1]),a=r(_d[2]),s=r(_d[3]),o=r(_d[4]),n=r(_d[5]),i=r(_d[6]);const h=()=>{try{return(0,e.nowFrom)(e.useStore.getState().clock)}catch{return new Date}},c=e=>String(e).padStart(2,'0'),d=e=>e.getFullYear()+'-'+c(e.getMonth()+1)+'-'+c(e.getDate()),l=e=>{const t=new Date(e);return c(t.getHours())+':'+c(t.getMinutes())},u=e=>{const t=(Math.round(60*e)%1440+1440)%1440;return c(Math.floor(t/60))+':'+c(t%60)},m=(e,t)=>{if(e===t)return'today';const[a,s,o]=e.split('-').map(Number),n=new Date(a,s-1,o),i=new Date(h());return i.setDate(i.getDate()+1),e===d(i)?'tomorrow':n.toLocaleDateString('en-GB',{weekday:'long',day:'numeric',month:'long'})},p=(e,t)=>t.test(e),f=e=>(e??'').replace(' (example)',''),b=e=>t.useOwner.getState().staff.find(t=>t.id===e.whoId),k=['staff'],w=[['kitchen',/\bkitchen\b/],['foh',/\b(front of house|foh|floor|bar)\b/],['managers',/\bmanagers?\b/],['all',/\b(all staff|everyone|whole team|team|group)\b/]],y={all:'the Team chat',kitchen:'Kitchen',foh:'Front of house',managers:'Managers'};function S(e,t){return'all'===e||(0,n.inChannel)(e,t)}function v(e,a){const s=e.toLowerCase().match(/\b(?:message|pm|private message|dm|text|tell)\s+([a-z' -]+?)(?:\s*[:,]|\s+(?:that|saying|to say)\b)/),o=(s?.[1]??'').trim();if(o&&!/^(the )?(team|everyone|kitchen|front of house|managers|group|all staff)$/.test(o))return t.useOwner.getState().staff.filter(e=>e.active&&e.id!==a.whoId).find(e=>(0,t.staffCalled)({name:f(e.name),nickname:e.nickname},o))}const x=[{id:'post_kitchen_chat',apps:['owner','chef'],title:'Post in the Kitchen chat',risk:'change',description:'Post a message in the pinned Kitchen chat (owners, managers, head chefs and kitchen staff).',params:[{name:'text',type:'string',required:!0,description:'The message'}],keywords:['kitchen chat'],match:e=>p(e,/\bkitchen (chat|group|channel)\b/)&&!p(e,/\b(read|any|unread|latest)\b/)?7:0,parse:e=>{const t=e.replace(/^.*?\bkitchen (?:chat|group|channel)\b\s*(?:[:,-]|\bthat\b|\bsaying\b)?\s*/i,'').trim();return{text:t.charAt(0).toUpperCase()+t.slice(1)}},preview:e=>'Post in the Kitchen chat: \u201c'+e.text+'\u201d?',run:(e,a)=>!e.text||String(e.text).length<2?'What should the message say?':(t.useOwner.getState().chatSend({ch:'kitchen',from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),'Posted in the Kitchen chat.')},{id:'post_team_chat',apps:k,title:'Post to the team chat or message one person',risk:'change',description:'Post a message in the team chat (All staff, Kitchen or Front of house), or a private message to one person. Read back first; posted only after Confirm.',params:[{name:'text',type:'string',required:!0,description:'The message'},{name:'ch',type:'string',required:!0,description:'Channel id or dm id'},{name:'to',type:'string',description:'Name of the person, for a private message'}],keywords:['team chat','group chat','message'],match:e=>p(e,/\b(message|pm|dm|text|tell|post|send|let)\b/)&&p(e,/\b(chat|team|everyone|group|kitchen|front of house|managers|know|:)|\b(message|pm|dm|text)\s+[a-z]+\s*[:,]/)&&!p(e,/\b(read|any|unread|what did|latest|last)\b.*\b(messages?|chat)\b/)?5:0,parse:(e,t)=>{const a=t,s=e.toLowerCase(),o=v(e,a),n=e.replace(/^.*?(?:[:]|\b(?:saying|that|to say)\b)\s*/i,'').replace(/^\s*(?:(?:post|send|put|write)\s+(?:in|on|to)\s+(?:the\s+)?(?:team|group|kitchen|front of house|all staff)?\s*chat\s*)/i,'').trim(),i=n&&n!==e?n:e.replace(/^\s*(?:tell|message|post to|let)\s+(?:the\s+)?(?:team|everyone|group chat|team chat|kitchen|front of house)\s*(?:know\s*)?(?:that\s*)?/i,'').trim();if(o)return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:'dm:'+[String(a.whoId),o.id].sort().join(':'),to:f(o.name)};const h=w.find(([,e])=>e.test(s))?.[0]??'all';return{text:i.charAt(0).toUpperCase()+i.slice(1),ch:h}},preview:e=>e.to?'Private message to '+e.to+': \u201c'+e.text+'\u201d. Send it?':'Post in '+(y[String(e.ch)]??'the team chat')+': \u201c'+e.text+'\u201d?',run:(e,a)=>{const s=String(e.ch),o=b(a);return!e.text||String(e.text).length<2?'What should the message say?':s.startsWith('dm:')||S(s,o)?(t.useOwner.getState().chatSend({ch:s,from:String(a.whoId??'system'),text:String(e.text),at:h().toISOString()}),e.to?'Sent to '+e.to+'.':'Posted in '+(y[s]??'the team chat')+'.'):'You can\u2019t post in '+(y[s]??s)+'. Try the Team chat.'}},{id:'read_chat',apps:k,title:'Read out chat messages',risk:'look',description:'Read out unread messages (team chat and private messages), or the latest ones.',params:[],keywords:['messages','chat'],match:e=>p(e,/\b(read|any|unread|new|what did|latest|last|check)\b.*\b(messages?|chats?|pms?)\b|\bwhat.?s (been said|in the chat)\b/)?6:0,preview:()=>'Read out chat messages',run:(e,a)=>{const s=t.useOwner.getState(),o=b(a),n=String(a.whoId??''),i=s.chat.filter(e=>{return!e.removed&&e.text&&((t=e.ch).startsWith('dm:')?t.split(':').slice(1).includes(n):o?'all'===t||S(t,o):'all'===t);var t}).sort((e,t)=>e.at.localeCompare(t.at)),h=i.filter(e=>e.from!==n&&!e.seenBy.includes(n)),c=(h.length?h:i.filter(e=>'system'!==e.from)).slice(-5),d=e=>'system'===e.from?'CoverCharge':f(s.staff.find(t=>t.id===e.from)?.name??'Someone');return c.length?(h.length?h.length+' unread. ':'No unread messages. The latest: ')+c.map(e=>{return d(e)+' '+(((t=e.ch).startsWith('dm:')?'privately':'in '+(y[t]??t))+' at ')+l(e.at)+': '+e.text;var t}).join('. '):'No messages yet.'}},{id:'my_shift',apps:k,title:'My next shift or rota',risk:'look',description:'Your next published shift, or your shifts this week.',params:[],keywords:['shift','rota'],match:e=>p(e,/\b(my|next|when am i|am i (on|working|in)|when do i (start|work|finish))\b/)&&p(e,/\b(shifts?|rota|working|on|in|start|finish)\b/)&&!p(e,/\b(break|clock)/)?5:0,preview:()=>'Your shifts',run:(e,a)=>{const s=a.today,o=t.useOwner.getState().shifts.filter(e=>e.staffId===a.whoId&&e.published&&e.date>=s).sort((e,t)=>e.date.localeCompare(t.date)||e.start-t.start);if(!o.length)return'You have no published shifts coming up. Your manager publishes the rota in the app.';const n=h(),i=n.getHours()+n.getMinutes()/60,c=o.find(e=>e.date>s||e.end>i)??o[0],d=o.filter(e=>e!==c).slice(0,4);return'Your next shift: '+m(c.date,s)+', '+u(c.start)+' to '+u(c.end)+(c.note?' ('+c.note+')':'')+'.'+(d.length?' Then '+d.map(e=>m(e.date,s)+' '+u(e.start)+'\u2013'+u(e.end)).join(', ')+'.':'')}},{id:'clock_status',apps:k,title:'Am I clocked in?',risk:'look',description:'Whether you are clocked in, since when, and a reminder to clock in or out on the Clock tab.',params:[],keywords:['clock'],match:e=>p(e,/\b(clock(ed)?|clocking)\b/)?6:0,preview:()=>'Clock status',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o),c=a.today,d=o.getHours()+o.getMinutes()/60,m=(0,i.workingShifts)(s.shifts,s.leave).find(e=>e.staffId===a.whoId&&e.published&&e.date===c);return n?'You\u2019re clocked in since '+l(n.in)+'.'+(m?' Your shift ends at '+u(m.end)+'.':'')+' Remember to clock out on the Clock tab when you finish.':m&&m.end>d?'You\u2019re not clocked in. Your shift today is '+u(m.start)+' to '+u(m.end)+'. Clock in on the Clock tab when you start.':'You\u2019re not clocked in.'+(m?'':' You have no shift today.')+' Use the Clock tab to clock in or out.'}},{id:'my_break',apps:k,title:'My break',risk:'look',description:'Whether you are on a break, and how long your breaks have been today.',params:[],keywords:['break'],match:e=>p(e,/\bbreaks?\b/)?6:0,preview:()=>'Your break',run:(e,a)=>{const s=t.useOwner.getState(),o=h(),n=(0,t.openShiftOf)(s.attendance,String(a.whoId),o);if(!n)return'You\u2019re not clocked in, so there\u2019s no break to show. Breaks are started and ended on the Clock tab.';const i=(0,t.loggedBreakMins)(n,o);if((0,t.isOnBreak)(n)){const e=n.breaks.find(e=>!e.end);return'You\u2019re on a break since '+l(e.start)+'. Breaks today: '+i+' minutes. Tap End break on the Clock tab when you\u2019re back.'}return i?'You\u2019ve had '+i+' minutes of break today. Start a break on the Clock tab.':'No break taken yet today. Start one on the Clock tab.'}},{id:'todays_specials',apps:k,title:'Today\u2019s specials',risk:'look',description:'Read out today\u2019s specials board.',params:[],keywords:['specials'],match:e=>p(e,/\bspecials?\b/)&&!p(e,/\b(draft|add|new|make)\b/)?6:0,preview:()=>'Today\u2019s specials',run:(e,t)=>{const o=a.useSpecials.getState().current[t.rid]?.items??[];return o.length?'Today\u2019s specials: '+o.map(e=>e.name+(null!=e.price?', '+(0,s.gbp)(e.price):'')).join('; ')+'.':'There are no specials on the board today.'}},{id:'sold_out_list',apps:k,title:'What\u2019s sold out',risk:'look',description:'List dishes that are sold out right now.',params:[],keywords:['sold out','86'],match:e=>p(e,/\b(sold out|86(ed)?|run out|off the menu|unavailable)\b/)?6:0,preview:()=>'What\u2019s sold out',run:(e,t)=>{const a=(0,o.dishesFor)(t.rid).filter(e=>e.soldOut).map(e=>e.name);return a.length?'Sold out: '+a.join(', ')+'.':'Nothing is sold out right now.'}}],C=new Set(['log_check','allergen_info','next_table_free',...x.filter(e=>e.apps?.includes('staff')).map(e=>e.id)])},1506,[831,891,995,867,1500,1047,1098]); +__d(function(g,r,i,_a,_m2,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NUM_WORDS",{enumerable:!0,get:function(){return s}}),e.numberOf=l,e.normaliseHeard=function(t){let n=` ${t.replace(/[\u2019\u2018]/g,"'").replace(/\s+/g,' ').trim()} `;n=n.replace(/\bwalk[\s-]?ins?\b/gi,'walk-in').replace(/\bwalking\b(?=\s+(?:of|for|in|on|at|party|\d|one|two|three|four|five|six|seven|eight|nine|ten|to|too)\b)/gi,'walk-in').replace(/\bseat(?:er|ed|a)?\s+(?:a\s+|at\s+|the\s+)?walk-in\b/gi,'seat a walk-in').replace(/\bsit\s+(?:a\s+)?walk-in\b/gi,'seat a walk-in').replace(/\b(?:quitter|quieter|pew ta|puta|put the|push a)\s+walk-in\b/gi,'put a walk-in').replace(/^(\s*)(?:lock|clock)\s+table\b/i,'$1block table').replace(/^(\s*)(?:[Ss]id|[Ss]it|[Ss]eed|[Ss]ee)\s+(?=[A-Z][a-z]+\b.*\b(?:waitlist|wait list|waiting list)\b)/,'$1seat ').replace(/\b(table \S+ (?:needs|is needing|wants)) cleaning\b/gi,'$1 clearing').replace(/^(\s*)have many\b/i,'$1how many').replace(/^(\s*)(?:meet|need|reed|weed) the (orders|shift notes|messages|specials)\b/i,'$1read the $2'),n=n.replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)(${a})\\b(?!\\s+(?:${b})\\b)`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp("\\btable(\\s+(?:number\\s+)?)(for|fore)\\b(?=\\s*(?:$|[.,!?]|\\b(?:please|now|is|has|needs|wants|on|at)\\b))",'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\btable(\\s+(?:number\\s+)?)((?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s})\\b`,'gi'),(t,n,s)=>`table${n}${p(s)}`).replace(new RegExp(`\\b(walk-in(?:\\s+party)?\\s+(?:of|for)|party of|table for|of|for)\\s+(${o})\\b${w}`,'gi'),(t,n,s)=>`${n} ${p(s)}`).replace(new RegExp(`\\bwalk-in\\s+(${s}|\\d{1,2})\\b${w}`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\bwalk-in\\s+(${o})\\b(?=\\s*(?:$|[.,!?]|\\b(?:on|at|people|covers|guests|please|now)\\b))`,'gi'),(t,n)=>`walk-in of ${p(n)}`).replace(new RegExp(`\\b(${o})\\s+(covers|people|guests|adults)\\b`,'gi'),(t,n,s)=>`${p(n)} ${s}`);const c=n.match(new RegExp(`^\\s*(?:(?:put|seat|sit)\\s+)?(?:a\\s+)?(${b})\\s+(?:on|at|to|onto)\\s+table\\s+(\\w+)[.,!?]?(?:\\s+(?:please|now|thanks))?\\s*[.!?]?\\s*$`,'i'));c&&l(c[1])&&l(c[1])<=30&&(n=` seat a walk-in of ${p(c[1])} at table ${p(c[2])} `);return n.replace(/\s+/g,' ').trim()},e.walkInCovers=function(t){const n=` ${t.toLowerCase()} `,a=`(\\d{1,2}|${s})`,o=n.match(new RegExp(`\\bwalk-in(?:\\s+party)?\\s+(?:of|for)\\s+${a}\\b`))??n.match(new RegExp(`\\bwalk-in\\s+(?:at|a|of a|for a)\\s+${a}\\s+(?:at|on)\\s+table\\b`))??n.match(new RegExp(`\\b${a}\\s+walk-in`))??n.match(new RegExp(`\\b(?:party of|table for|for|of)\\s+${a}\\b(?!\\s*(?:am|pm|[:.]\\d|o.?clock))`))??n.match(new RegExp(`\\b${a}\\s*(?:covers|people|guests|adults|pax|persons|of us)\\b`)),b=l(o?.[1],!1);return b&&b>=1&&b<=30?b:void 0},e.tableSaid=function(t){const n=[...` ${t.toLowerCase()} `.matchAll(/\btable\s+(?:number\s+)?([a-z]?\d{1,3}[a-z]?)\b/g)];return n.length?n[n.length-1][1].toUpperCase():void 0},e.coversAnswer=function(t){const n=t.toLowerCase().replace(/[.,!?]/g,' '),a=n.match(new RegExp(`\\b(\\d{1,2}|${s})\\b`))??n.match(new RegExp(`^\\s*(?:just\\s+)?(${o})\\s*(?:people|of us|please)?\\s*$`)),b=l(a?.[1]);return b&&b>=1&&b<=30?b:void 0};const t={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},n={to:2,too:2,tu:2,for:4,fore:4,ate:8,won:1,tree:3,free:3,sax:6,sex:6,fiver:5,nein:9,tin:10},s=Object.keys(t).join('|'),a='to|too|tu|ate|won|tree|free|sax|sex|fiver|nein|tin',o='to|too|tu|for|fore|ate|won',b=`\\d{1,2}|(?:twenty|thirty)[ -](?:one|two|three|four|five|six|seven|eight|nine)|${s}|${o}`;function l(s,a=!0){if(!s)return;const o=s.toLowerCase().trim().replace(/-/g,' ');if(/^\d+$/.test(o))return Number(o);const b=o.match(/^(twenty|thirty) (one|two|three|four|five|six|seven|eight|nine)$/);return b?t[b[1]]+t[b[2]]:t[o]??(a?n[o]:void 0)}const p=t=>String(l(t)??t),w='(?=\\s*(?:$|[.,!?]|\\bon\\b|\\bat\\b|\\bin\\b|\\bto\\b|\\btable\\b|\\bplease\\b|\\bnow\\b|\\bpeople\\b|\\bcovers?\\b|\\bguests?\\b))'},1507,[]); +__d(function(g,r,i,_a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_KEYTERMS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"MAX_APP_KEYTERMS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"VENUE_WORDS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"cleanTerm",{enumerable:!0,get:function(){return u}}),e.venueKeyterms=function(l){const b=[],f=new Set,h=t=>{const a=u(t??''),n=a.toLowerCase();a.length>=2&&!f.has(n)&&b.lengtht.active).forEach(t=>h(String(t.name).split(/\s+/)[0]))}catch{}try{(n.useFloor.getState().plans[l]??(0,n.seedPlan)(l)).areas.forEach(t=>h(t.name))}catch{}try{s.forEach(h)}catch{}try{a.useStore.getState().menu.filter(t=>!t.restaurantId||t.restaurantId===l).forEach(t=>h(t.name))}catch{}return b};var t=r(d[0]),a=r(d[1]),n=r(d[2]);const l=100,c=80,o=['walk-in','covers','table','seat','seated','clear','cleared','needs clearing','block','unblock','waitlist','lobster','crab','langoustines','scallops','sold out','no-show','Sitooterie','Beer Garden','Main Restaurant','party of','people'],s=['table one','table two','table three','table four','table five','table six','table seven','table eight','table nine','table ten','table eleven','table twelve'],u=t=>t.replace(/\([^)]*\)/g,' ').replace(/[^\p{L}\p{N} '&.-]/gu,' ').replace(/\s+/g,' ').trim().slice(0,50).trim()},1508,[891,831,1029]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"useVoiceNav",{enumerable:!0,get:function(){return t}});const t=(0,r(d[0]).create)(()=>({go:null}))},1509,[846]); +__d(function(g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"VOICE_TASKS_PER_MONTH",{enumerable:!0,get:function(){return u}}),Object.defineProperty(_e,"VOICE_WARN_AT",{enumerable:!0,get:function(){return c}}),Object.defineProperty(_e,"VOICE_FAIR_USAGE",{enumerable:!0,get:function(){return d}}),Object.defineProperty(_e,"monthKey",{enumerable:!0,get:function(){return f}}),Object.defineProperty(_e,"voiceUsage",{enumerable:!0,get:function(){return b}}),Object.defineProperty(_e,"REACHED_TEXT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"WARN_TEXT",{enumerable:!0,get:function(){return v}}),_e.useVoiceUsage=function(e,t=new Date){const n=h(n=>n.used[e]?.[f(t)]??0);return _(n)};var e,t=r(_d[0]),n=(e=t)&&e.__esModule?e:{default:e},o=r(_d[1]),s=r(_d[2]);const u=1e3,c=.8,d='Fair usage: 1,000 voice tasks a month per venue',l=new Set(['log_check']),f=(e=new Date)=>e.getFullYear()+'-'+String(e.getMonth()+1).padStart(2,'0'),h=(0,o.create)()((0,s.persist)(e=>({used:{},add:(t,n)=>e(e=>({used:{...e.used,[t]:{[n]:(e.used[t]?.[n]??0)+1}}}))}),{name:'covercharge-voice-usage-v1',version:1,storage:(0,s.createJSONStorage)(()=>n.default)})),_=e=>{const t=e/u;return{used:e,limit:u,pct:t,warn:t>=c,reached:e>=u,line:'Voice assistant: '+e.toLocaleString('en-GB')+' of 1,000 tasks used this month, resets on the 1st'}},b={get:(e,t=new Date)=>_(h.getState().used[e]?.[f(t)]??0),allowed:(e,t,n=new Date)=>null!=t&&l.has(t)||!b.get(e,n).reached,record:(e,t=new Date)=>h.getState().add(e,f(t))},p='This venue has used its fair-usage allowance of 1,000 voice tasks for this month. It starts again on the 1st. Food safety logging still works, and the owner can contact CoverCharge if you need more.',v=e=>e.line+'. That\u2019s '+Math.round(100*e.pct)+'% of this venue\u2019s fair-usage allowance.'},1510,[839,846,849]); +__d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"useVoiceKeys",{enumerable:!0,get:function(){return e}}),_e.installVoiceKeys=function(){if('undefined'==typeof window||!window.addEventListener)return()=>{};let n=!1;const o=o=>(o.metaKey||o.ctrlKey)&&o.shiftKey&&'g'===o.key.toLowerCase()?(o.preventDefault(),void(o.repeat||e.getState().send('toggle'))):!o.metaKey&&!o.ctrlKey||o.shiftKey||'/'!==o.key?void('Space'!==o.code||o.metaKey||o.ctrlKey||o.altKey||t(o.target)||(o.preventDefault(),o.repeat||n||(n=!0,e.getState().send('start')))):(o.preventDefault(),void e.getState().send('type')),s=t=>{'Space'===t.code&&n&&(t.preventDefault(),n=!1,e.getState().send('stop'))},l=()=>{n&&(n=!1,e.getState().send('stop'))};return window.addEventListener('keydown',o,!0),window.addEventListener('keyup',s,!0),window.addEventListener('blur',l),()=>{window.removeEventListener('keydown',o,!0),window.removeEventListener('keyup',s,!0),window.removeEventListener('blur',l)}};const e=(0,r(d[0]).create)((e,t)=>({last:null,send:n=>e({last:{cmd:n,n:(t().last?.n??0)+1}})})),t=e=>{const t=e?.tagName;return'INPUT'===t||'TEXTAREA'===t||'SELECT'===t||!!e?.isContentEditable}},1511,[846]); +__d(function(g,r,_i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.seedPitch=function(){const p='owner'===d.APP_VARIANT?'st-tracy':'chef'===d.APP_VARIANT?'st-bisto':'staff'===d.APP_VARIANT?'st-lenny':null;!p||i.useSession.getState().meId||/[?&]invite=/.test('undefined'!=typeof window?window.location.search:'')||i.useSession.getState().signIn(p);t.useStore.setState(t=>({bookings:t.bookings.map((t,e)=>t.phone||t.walkIn?t:{...t,phone:`07700 900${String(100+e).slice(-3)}`})})),c.PITCH_ANCHORAGE&&(0,u.seedDesktopDemo)((0,e.nowFrom)(t.useStore.getState().clock));const y=s.useOwner.getState();if(y.shifts.some(t=>t.id.startsWith('pitch-')))return;const m=(0,e.nowFrom)(t.useStore.getState().clock),w=l(m),k=m.getHours()+m.getMinutes()/60,A=(0,s.addDays)(w,-(0,s.weekdayOf)(w)),I=[],b=[];for(const[t,[e,o,i]]of Object.entries(S))if(n.ROSTER.some(e=>e.id===t))for(let n=-7;n<14;n++){const d=(0,s.addDays)(A,n),c=(0,s.weekdayOf)(d);if(i.includes(c))continue;I.push({id:`pitch-${t}-${d}`,staffId:t,date:d,day:c,start:e,end:o,published:n<7,breakAt:o-e>=6?e+3.5:void 0});const u='st-jack'===t?{auto:'rota'}:{};d=6?30:0,signOff:d<(0,s.addDays)(w,-1)?{by:'Alex',byId:'st-gordon',at:h(d,23.5)}:void 0,...u}):d===w&&e<=k&&b.push({id:`pitch-a-${t}-${d}`,staffId:t,date:d,in:h(d,u.auto?e:e-.05),inSite:!0,...u})}s.useOwner.setState({shifts:[...y.shifts.filter(t=>!I.some(e=>e.staffId===t.staffId&&e.date===t.date)),...I],attendance:[...y.attendance,...b]});const v=o.useCashUp.getState();for(let t=1;t<=10;t++){const e=(0,s.addDays)(w,-t);if([0,1].includes((0,s.weekdayOf)(e)))continue;if(v.cashUps.some(t=>t.rid===f&&t.date===e))continue;const o=1450+373*t%900,n=210+97*t%240;v.saveCashUp({rid:f,date:e,vals:{card:o,cash:n,float:200,cashTips:38+13*t%40,cardTips:92+29*t%70,overUnder:3===t?-2.5:0,notes:3===t?'Till 2 short \xa32.50, counted twice.':''},photos:[],confirmedBy:t%2?'Alex':'Priya',confirmedAt:h(e,23.25),readBy:null})}for(let t=1;t<=3;t++){const e=(0,s.addDays)(A,-7*t);if(v.sales.some(t=>t.rid===f&&t.weekStart===e))continue;const o=11800+640*t;v.saveSales({rid:f,weekStart:e,vals:{gross:o,net:Math.round(o/1.2),vat:Math.round(o-o/1.2),covers:610+22*t,discounts:140,refunds:35},categories:[{name:'Food',amount:Math.round(.62*o)},{name:'Drinks',amount:Math.round(.31*o)},{name:'Takeaway',amount:Math.round(.07*o)}],photos:[],confirmedBy:'Alex',confirmedAt:h((0,s.addDays)(e,7),11),readBy:null})}};var t=r(_d[0]),e=r(_d[1]),s=r(_d[2]),o=r(_d[3]),n=r(_d[4]),i=r(_d[5]),d=r(_d[6]),c=r(_d[7]),u=r(_d[8]);const f='anchorage',l=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,h=(t,e)=>{const[s,o,n]=t.split('-').map(Number);return new Date(s,o-1,n,Math.floor(e),Math.round(e%1*60)).toISOString()},S={'st-gordon':[11,21,[0,1]],'st-bisto':[10,20.5,[0,1]],'st-agate':[16,22.5,[0,1,2]],'st-lenny':[11,19,[0,1,3]],'st-finn':[17,23,[0,1,4]],'st-eilidh':[12,18,[0,1,2]],'st-emily':[17,22,[0,1,3]],'st-lillie':[12,20,[0,1,5]],'st-jack':[16,22,[0,1,6]]}},1512,[874,831,891,1039,15,1004,872,2,1513]); +__d(function(g,_r,_i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.desktopDemoBookings=m,e.seedDesktopDemo=function(o){if(t.useStore.getState().bookings.some(t=>t.id.startsWith('desk-')))return;const s=m(o);t.useStore.setState(t=>({bookings:[...t.bookings.filter(t=>t.restaurantId!==r),...s]}));const i=n.useCashUp.getState(),l=c(o);for(let t=1;t<=35;t++){const n=u(l,-t),o=new Date(`${n}T12:00:00`).getDay();if(1===o||2===o)continue;if(i.cashUps.some(t=>t.rid===r&&t.date===n))continue;const s=5===o||6===o?1.45:0===o?1.2:.8,d=Math.round((1550+700*h(t+41))*s),c=Math.round((190+200*h(t+43))*s);i.saveCashUp({rid:r,date:n,vals:{card:d,cash:c,float:200,cashTips:Math.round(30+40*h(t+47)),cardTips:Math.round(80+80*h(t+53)*s),overUnder:0,notes:''},photos:[],confirmedBy:'Alex',confirmedAt:new Date(`${n}T23:15:00`).toISOString(),readBy:null})}};var t=_r(_d[0]),n=_r(_d[1]);const r='anchorage',o=['Campbell','Fraser','McLeod','Kerr','Wallace','Boyd','Hamilton','Stewart','Murray','Robertson','Thomson','Reid','Paterson','Ross','Morrison','Young','Watson','Mitchell','Gray','Ferguson','Kennedy','Duncan','Sinclair','Munro','Grant','Docherty','Gallacher','Craig','Shaw','Baird','Hunter','Hendry','Lindsay','Ogilvie','Rennie','Galbraith'],s=['Fiona','Callum','Isla','Euan','Morag','Ross','Kirsty','Andrew','Heather','Neil','Catriona','Graeme','Shona','Iain','Lorna','Craig','Ailsa','Douglas'],i=['12:00','12:30','13:00','13:15','13:30','14:00','17:00','17:30','18:00','18:15','18:30','19:00','19:15','19:30','20:00','20:30'],l=['1','2','3','4','5','6','7','8','9','10','11','12','14','15','16','17','18','19','20','21','22'],d=[[{allergen:'gluten',severity:'coeliac'}],[{allergen:'crustaceans',severity:'allergy'}],[{allergen:'milk',severity:'intolerance'}],[{allergen:'peanuts',severity:'anaphylaxis'},{allergen:'treenuts',severity:'anaphylaxis'}]],c=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,'0')}-${String(t.getDate()).padStart(2,'0')}`,u=(t,n)=>{const[r,o,s]=t.split('-').map(Number);return c(new Date(r,o-1,s+n,12))},h=t=>{const n=233280*Math.sin(9301*t+49297);return n-Math.floor(n)},p=t=>60*Number(t.slice(0,2))+Number(t.slice(3,5)),y=(t,n)=>t[Math.floor(h(n)*t.length)%t.length];function m(t){const n=c(t),m=60*t.getHours()+t.getMinutes(),S=[];let f=0;for(let c=-28;c<=14;c++){const M=u(n,c),D=new Date(`${M}T12:00:00`).getDay();if(1===D||2===D)continue;const v=5===D||6===D?16:0===D?13:8,b=Math.max(2,v-(c>0?Math.round(.7*c):0));for(let u=0;u0&&$<.05,I=b?$<.03?'noshow':$<.07?'cancelled':w?'seated':'finished':k?'pending':'confirmed',T=k?9+f%4:v,C=h(f+13)<.12?y(d,f+17):[],A=h(f+19);S.push({id:`desk-${f}`,ref:`B-${4100+f}`,restaurantId:r,customerId:null,name:`${y(s,f+11)} ${y(o,f+5)}`,partySize:T,date:M,time:D,table:k?void 0:y(l,f+29),allergies:C,allergyNone:!C.length,notes:h(f+31)<.08?'Window table if possible':'',status:I,security:T>=8?'deposit':'none',depositPaid:T>=8&&!k?1e3*T:0,depositDue:T>=8?1e3*T:void 0,createdAt:new Date(t.getTime()-864e5*(30-c)).toISOString(),phone:`07700 900${String(f%1e3).padStart(3,'0')}`,source:h(f+37)<.62?'online':'phone',occasion:A<.06?'birthday':A<.09?'anniversary':void 0,...'seated'===I?{seatedAt:new Date(t.getTime()-6e4*(m-p(D))).toISOString()}:{}})}}return S}},1513,[874,1039]); +__d(function(e,s,o,p,t,a,f){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf"},1514,[]); +__d(function(s,o,e,p,t,c,d){"use strict";t.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf"},1515,[]); +__d(function(o,s,e,f,p,t,d){"use strict";p.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf"},1516,[]); +__d(function(o,s,p,t,d,e,n){"use strict";d.exports="/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf"},1517,[]); +__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 c}});var t=r(d[0]);r(d[1]);var n=r(d[2]),u=r(d[3]);function c(){return(0,u.jsx)(t.Redirect,{href:n.ENTRY[n.APP_VARIANT]})}},1518,[30,34,872,25]); +__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.Head}});const t=(n=r(d[0]),c=e,Object.keys(n).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(c,t)||Object.defineProperty(c,t,{enumerable:!0,get:function(){return n[t]}})}),n);var n,c},1519,[1520]); +__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 c in n)Object.defineProperty(t,c,{enumerable:!0,get:Object.getOwnPropertyDescriptor(n,c).get})})(e,{get Head(){return u},get default(){return s}});const n=r(d[1]),c=r(d[2]);function o({children:c}){return(0,t().jsx)(n.Helmet,{children:c})}const u=({children:n})=>(0,c.useIsFocused)()?(0,t().jsx)(o,{children:n}):null;u.Provider=n.HelmetProvider;const s=u},1520,[25,1521,591]); +__d(function(g,r,_i,a,m,e,d){"use strict";var t,n=Object.create,s=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,p=(t,n,l,p)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let u of o(n))c.call(t,u)||u===l||s(t,u,{get:()=>n[u],enumerable:!(p=i(n,u))||p.enumerable});return t},u=(t,i,o)=>(o=null!=t?n(l(t)):{},p(!i&&t&&t.__esModule?o:s(o,"default",{value:t,enumerable:!0}),t)),h={};((t,n)=>{for(var i in n)s(t,i,{get:n[i],enumerable:!0})})(h,{Helmet:()=>fe,HelmetData:()=>se,HelmetProvider:()=>oe}),m.exports=(t=h,p(s({},"__esModule",{value:!0}),t));var y=u(r(d[0])),f=u(r(d[1])),b=u(r(d[0])),T=u(r(d[0])),A=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(A||{}),O={rel:["amphtml","canonical","alternate"]},C={type:["application/ld+json"]},w={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},x=Object.values(A),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$=Object.entries(v).reduce((t,[n,s])=>(t[s]=n,t),{}),j="data-rh",k="defaultTitle",S="defer",E="encodeSpecialCharacters",M="onChangeClientState",P="titleTemplate",H="prioritizeSeoTags",D=(t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=t[s];if(Object.prototype.hasOwnProperty.call(i,n))return i[n]}return null},L=t=>{let n=D(t,"title");const s=D(t,P);if(Array.isArray(n)&&(n=n.join("")),s&&n)return s.replace(/%s/g,()=>n);const i=D(t,k);return n||i||void 0},I=t=>D(t,M)||(()=>{}),U=(t,n)=>n.filter(n=>void 0!==n[t]).map(n=>n[t]).reduce((t,n)=>({...t,...n}),{}),N=(t,n)=>n.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((n,s)=>{if(!n.length){const i=Object.keys(s);for(let o=0;o{const i={};return s.filter(n=>{return!!Array.isArray(n[t])||(void 0!==n[t]&&(s=`Helmet: ${t} should be of type "Array". Instead found type "${typeof n[t]}"`,console&&"function"==typeof console.warn&&console.warn(s)),!1);var s}).map(n=>n[t]).reverse().reduce((t,s)=>{const o={};s.filter(t=>{let s;const l=Object.keys(t);for(let i=0;it.push(n));const l=Object.keys(o);for(let t=0;t{if(Array.isArray(t)&&t.length)for(let s=0;sArray.isArray(t)?t.join(""):t,z=(t,n)=>{const s=Object.keys(t);for(let i=0;iArray.isArray(t)?t.reduce((t,s)=>(z(s,n)?t.priority.push(s):t.default.push(s),t),{priority:[],default:[]}):{default:t,priority:[]},F=(t,n)=>({...t,[n]:void 0}),Y=["noscript","script","style"],K=(t,n=!0)=>!1===n?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),G=t=>Object.keys(t).reduce((n,s)=>{const i=void 0!==t[s]?`${s}="${K(t[s])}"`:`${s}`;return n?`${n} ${i}`:i},""),W=(t,n,s,i)=>{const o=G(s),l=R(n);return o?`<${t} ${j}="true" ${o}>${K(l,i)}`:`<${t} ${j}="true">${K(l,i)}`},J=(t,n,s=!0)=>n.reduce((n,i)=>{const o=i,l=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,n)=>{const i=void 0===o[n]?n:`${n}="${K(o[n],s)}"`;return t?`${t} ${i}`:i},""),c=o.innerHTML||o.cssText||"",p=-1===Y.indexOf(t);return`${n}<${t} ${j}="true" ${l}${p?"/>":`>${c}`}`},""),Q=(t,n={})=>Object.keys(t).reduce((n,s)=>(n[v[s]||s]=t[s],n),n),V=(t,n,s)=>{const i=Q(s,{key:n,[j]:!0});return[T.default.createElement("title",i,n)]},X=(t,n)=>n.map((n,s)=>{const i={key:s,[j]:!0};return Object.keys(n).forEach(t=>{const s=v[t]||t;if("innerHTML"===s||"cssText"===s){const t=n.innerHTML||n.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[s]=n[t]}),T.default.createElement(t,i)}),Z=(t,n,s=!0)=>{switch(t){case"title":return{toComponent:()=>V(0,n.title,n.titleAttributes),toString:()=>W(t,n.title,n.titleAttributes,s)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Q(n),toString:()=>G(n)};default:return{toComponent:()=>X(t,n),toString:()=>J(t,n,s)}}},ee=({metaTags:t,linkTags:n,scriptTags:s,encode:i})=>{const o=B(t,w),l=B(n,O),c=B(s,C);return{priorityMethods:{toComponent:()=>[...X("meta",o.priority),...X("link",l.priority),...X("script",c.priority)],toString:()=>`${Z("meta",o.priority,i)} ${Z("link",l.priority,i)} ${Z("script",c.priority,i)}`},metaTags:o.default,linkTags:l.default,scriptTags:c.default}},te=t=>{const{baseTag:n,bodyAttributes:s,encode:i=!0,htmlAttributes:o,noscriptTags:l,styleTags:c,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:f,scriptTags:b}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:f,scriptTags:b}=ee(t)),{priority:T,base:Z("base",n,i),bodyAttributes:Z("bodyAttributes",s,i),htmlAttributes:Z("htmlAttributes",o,i),link:Z("link",y,i),meta:Z("meta",f,i),noscript:Z("noscript",l,i),script:Z("script",b,i),style:Z("style",c,i),title:Z("title",{title:p,titleAttributes:u},i)}},re=[],ne=!("undefined"==typeof window||!window.document||!window.document.createElement),se=class{instances=[];canUseDOM=ne;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?re:this.instances,add:t=>{(this.canUseDOM?re:this.instances).push(t)},remove:t=>{const n=(this.canUseDOM?re:this.instances).indexOf(t);(this.canUseDOM?re:this.instances).splice(n,1)}}};constructor(t,n){this.context=t,this.canUseDOM=n||!1,n||(t.helmet=te({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ie=b.default.createContext({}),oe=class t extends b.Component{static canUseDOM=ne;constructor(n){super(n),this.helmetData=new se(this.props.context||{},t.canUseDOM)}render(){return b.default.createElement(ie.Provider,{value:this.helmetData.value},this.props.children)}},ae=r(d[0]),le=(t,n)=>{if(t===n)return!0;if("object"!=typeof t||!t||"object"!=typeof n||!n)return!1;const s=Object.keys(t),i=Object.keys(n);return s.length===i.length&&s.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&t[s]===n[s])},ce=(t,n)=>{const s=document.head||document.querySelector("head"),i=s.querySelectorAll(`${t}[${j}]`),o=[].slice.call(i),l=[];let c;return n&&n.length&&n.forEach(n=>{const s=document.createElement(t);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t))if("innerHTML"===t)s.innerHTML=n.innerHTML;else if("cssText"===t)s.styleSheet?s.styleSheet.cssText=n.cssText:s.appendChild(document.createTextNode(n.cssText));else{const i=t,o=void 0===n[i]?"":n[i];s.setAttribute(t,o)}s.setAttribute(j,"true"),o.some((t,n)=>(c=n,s.isEqualNode(t)))?o.splice(c,1):l.push(s)}),o.forEach(t=>t.parentNode?.removeChild(t)),l.forEach(t=>s.appendChild(t)),{oldTags:o,newTags:l}},pe=(t,n)=>{const s=document.getElementsByTagName(t)[0];if(!s)return;const i=s.getAttribute(j),o=i?i.split(","):[],l=[...o],c=Object.keys(n);for(const t of c){const i=n[t]||"";s.getAttribute(t)!==i&&s.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const c=l.indexOf(t);-1!==c&&l.splice(c,1)}for(let t=l.length-1;t>=0;t-=1)s.removeAttribute(l[t]);o.length===l.length?s.removeAttribute(j):s.getAttribute(j)!==c.join(",")&&s.setAttribute(j,c.join(","))},ue=(t,n)=>{void 0!==t&&document.title!==t&&(document.title=R(t)),pe("title",n)},de=(t,n)=>{const{baseTag:s,bodyAttributes:i,htmlAttributes:o,linkTags:l,metaTags:c,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:f,titleAttributes:b}=t;pe("body",i),pe("html",o),ue(f,b);const T={baseTag:ce("base",s),linkTags:ce("link",l),metaTags:ce("meta",c),noscriptTags:ce("noscript",p),scriptTags:ce("script",h),styleTags:ce("style",y)},A={},O={};Object.keys(T).forEach(t=>{const{newTags:n,oldTags:s}=T[t];n.length&&(A[t]=n),s.length&&(O[t]=T[t].oldTags)}),n&&n(),u(t,A,O)},he=null,me=t=>{he&&cancelAnimationFrame(he),t.defer?he=requestAnimationFrame(()=>{de(t,()=>{he=null})}):(de(t),he=null)},ye=class extends ae.Component{rendered=!1;shouldComponentUpdate(t){return!le(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:n}=this.props.context;let s=null;const i=(o=t.get().map(t=>{const n={...t.props};return delete n.context,n}),{baseTag:N(["href"],o),bodyAttributes:U("bodyAttributes",o),defer:D(o,S),encode:D(o,E),htmlAttributes:U("htmlAttributes",o),linkTags:q("link",["rel","href"],o),metaTags:q("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:q("noscript",["innerHTML"],o),onChangeClientState:I(o),scriptTags:q("script",["src","innerHTML"],o),styleTags:q("style",["cssText"],o),title:L(o),titleAttributes:U("titleAttributes",o),prioritizeSeoTags:_(o,H)});var o;oe.canUseDOM?me(i):te&&(s=te(i)),n(s)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},fe=class extends y.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,f.default)(F(this.props,"helmetData"),F(t,"helmetData"))}mapNestedChildrenToProps(t,n){if(!n)return null;switch(t.type){case"script":case"noscript":return{innerHTML:n};case"style":return{cssText:n};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,n,s,i){return{...n,[t.type]:[...n[t.type]||[],{...s,...this.mapNestedChildrenToProps(t,i)}]}}mapObjectTypeChildren(t,n,s,i){switch(t.type){case"title":return{...n,[t.type]:i,titleAttributes:{...s}};case"body":return{...n,bodyAttributes:{...s}};case"html":return{...n,htmlAttributes:{...s}};default:return{...n,[t.type]:{...s}}}}mapArrayTypeChildrenToProps(t,n){let s={...n};return Object.keys(t).forEach(n=>{s={...s,[n]:t[n]}}),s}warnOnInvalidChildren(t,n){if(!x.some(n=>t.type===n))throw new Error("function"==typeof t.type?"You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${x.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`);if(n&&"string"!=typeof n&&(!Array.isArray(n)||n.some(t=>"string"!=typeof t)))throw new Error(`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`} ) Refer to our API for more information.`);return!0}mapChildrenToProps(t,n){let s={};return y.default.Children.forEach(t,t=>{if(!t||!t.props)return;const{children:i,...o}=t.props,l=Object.keys(o).reduce((t,n)=>(t[$[n]||n]=o[n],t),{});let{type:c}=t;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(t,i),c){case"Symbol(react.fragment)":n=this.mapChildrenToProps(i,n);break;case"link":case"meta":case"noscript":case"script":case"style":s=this.flattenArrayTypeChildren(t,s,l,i);break;default:n=this.mapObjectTypeChildren(t,n,l,i)}}),this.mapArrayTypeChildrenToProps(s,n)}render(){const{children:t,...n}=this.props;let s={...n},{helmetData:i}=n;if(t&&(s=this.mapChildrenToProps(t,s)),i&&!(i instanceof se)){i=new se(i.context,!0),delete s.helmetData}return i?y.default.createElement(ye,{...s,context:i.value}):y.default.createElement(ie.Consumer,null,t=>y.default.createElement(ye,{...s,context:t}))}}},1521,[34,172]); +__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},1522,[]); +__d(function(g,r,i,a,m,_e,d){"use strict";function t(){const e=r(d[0]);return t=function(){return e},e}function e(){const t=r(d[1]);return e=function(){return t},t}function n(){const t=f(r(d[2]));return n=function(){return t},t}function o(){const t=r(d[3]);return o=function(){return t},t}Object.defineProperty(_e,"__esModule",{value:!0}),Object.defineProperty(_e,"renderRootComponent",{enumerable:!0,get:function(){return y}});const u=f(r(d[4]));function c(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,n=new WeakMap;return(c=function(t){return t?n:e})(t)}function f(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!=typeof t&&"function"!=typeof t)return{default:t};var n=c(e);if(n&&n.has(t))return n.get(t);var o={__proto__:null},u=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in t)if("default"!==f&&Object.prototype.hasOwnProperty.call(t,f)){var s=u?Object.getOwnPropertyDescriptor(t,f):null;s&&(s.get||s.set)?Object.defineProperty(o,f,s):o[f]=t[f]}return o.default=t,n&&n.set(t,o),o}function s(t){if('[object Object]'!==Object.prototype.toString.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.prototype}function p(t){return t&&'object'==typeof t&&'string'==typeof t.name&&'string'==typeof t.message}function l(t){return p(t)?t:s(t)?new Error(JSON.stringify(t)):new Error(String(t))}function y(c){try{setTimeout(()=>{u._internal_preventAutoHideAsync?.()}),n().startTransition(()=>{(0,e().registerRootComponent)(c)})}catch(n){u.hideAsync();const c=l(n);(0,e().registerRootComponent)(()=>(0,t().jsx)(o().View,{})),console.error(c),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw c})}}},1523,[25,499,34,270,651]); __r(501); __r(21); __r(0); \ No newline at end of file diff --git a/staff-app/admin.html b/staff-app/admin.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/admin.html +++ b/staff-app/admin.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer.html b/staff-app/customer.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer.html +++ b/staff-app/customer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage.html b/staff-app/customer/anchorage.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage.html +++ b/staff-app/customer/anchorage.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/book.html b/staff-app/customer/anchorage/book.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/book.html +++ b/staff-app/customer/anchorage/book.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/feedback.html b/staff-app/customer/anchorage/feedback.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/feedback.html +++ b/staff-app/customer/anchorage/feedback.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/gift.html b/staff-app/customer/anchorage/gift.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/gift.html +++ b/staff-app/customer/anchorage/gift.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/lost.html b/staff-app/customer/anchorage/lost.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/lost.html +++ b/staff-app/customer/anchorage/lost.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/loyalty.html b/staff-app/customer/anchorage/loyalty.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/loyalty.html +++ b/staff-app/customer/anchorage/loyalty.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/merch.html b/staff-app/customer/anchorage/merch.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/merch.html +++ b/staff-app/customer/anchorage/merch.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/offers.html b/staff-app/customer/anchorage/offers.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/offers.html +++ b/staff-app/customer/anchorage/offers.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/refer.html b/staff-app/customer/anchorage/refer.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/refer.html +++ b/staff-app/customer/anchorage/refer.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/waitlist.html b/staff-app/customer/anchorage/waitlist.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/waitlist.html +++ b/staff-app/customer/anchorage/waitlist.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/anchorage/whatson.html b/staff-app/customer/anchorage/whatson.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/anchorage/whatson.html +++ b/staff-app/customer/anchorage/whatson.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/basket.html b/staff-app/customer/basket.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/basket.html +++ b/staff-app/customer/basket.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/customer/profile.html b/staff-app/customer/profile.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/customer/profile.html +++ b/staff-app/customer/profile.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/demo.html b/staff-app/demo.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/demo.html +++ b/staff-app/demo.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/display.html b/staff-app/display.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/display.html +++ b/staff-app/display.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/index.html b/staff-app/index.html index e2167cbe393701699733c005b98dc62f8b7943d7..5dc441ae4f50b1a07cc15db648a8a7350d58d435 100644 --- a/staff-app/index.html +++ b/staff-app/index.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/kitchen.html b/staff-app/kitchen.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/kitchen.html +++ b/staff-app/kitchen.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/owner.html b/staff-app/owner.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/owner.html +++ b/staff-app/owner.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/staff.html b/staff-app/staff.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/staff.html +++ b/staff-app/staff.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - + diff --git a/staff-app/sw.js b/staff-app/sw.js index 47665f96564adf721330481c28eeba927126ac94..ae5a38d315d2f6f7bb73fa190d8691a8659656ee 100644 --- a/staff-app/sw.js +++ b/staff-app/sw.js @@ -1,7 +1,7 @@ // Anchorage Staff service worker: precache the app shell so it opens offline after the first visit. -const V = "cc-staff-cbb5d7184e"; +const V = "cc-staff-a7d97422be"; const BASE = "/staff-app/"; -const PRECACHE = ["/staff-app/apple-touch-icon.png", "/staff-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/staff-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/staff-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/staff-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/staff-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/staff-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/staff-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/staff-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/staff-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/staff-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/staff-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/staff-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/staff-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/staff-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/staff-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/staff-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/staff-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/staff-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/staff-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/staff-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/staff-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/staff-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/staff-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/staff-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/staff-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/staff-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/staff-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/staff-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/staff-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/staff-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/staff-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/staff-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/staff-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/staff-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/staff-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/staff-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/staff-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/staff-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/staff-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/staff-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/staff-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/staff-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/staff-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/staff-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/staff-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/staff-app/brand-logo.png", "/staff-app/favicon.ico", "/staff-app/icon-192.png", "/staff-app/icon-512.png", "/staff-app/icon-maskable-192.png", "/staff-app/icon-maskable-512.png", "/staff-app/manifest.webmanifest", "/staff-app/index.html", "/staff-app/_expo/static/js/web/bundle.js?v=cbb5d7184ebea7b58f3d31466dd96558dd9e8157904ade7c7ff47433d464d199"]; +const PRECACHE = ["/staff-app/apple-touch-icon.png", "/staff-app/assets/assets/brand/3idiots-hero.e5dfd53739f05086b1956e72d585a66a.png", "/staff-app/assets/assets/brand/3idiots.df4a76d2130f0e5b0042f06a8c88693a.png", "/staff-app/assets/assets/brand/abbotsford-hero.78fcb8ee06ee22c4ca659c9254db7512.png", "/staff-app/assets/assets/brand/abbotsford.b26602bba5ce4969733c5422a45ad053.png", "/staff-app/assets/assets/brand/anchorage-hero.0450b828e4f9c1f4456240096598f6f5.png", "/staff-app/assets/assets/brand/anchorage.fea5ce2f6fd18bf2950aa21c0980ed8e.png", "/staff-app/assets/assets/brand/brae.8de9e89ac30966c6669de990370d8e40.png", "/staff-app/assets/assets/brand/cecchinis-hero.f77780fcc94fd668cf35d66d6dc52d81.png", "/staff-app/assets/assets/brand/cecchinis.ebf752fef363247848ae7c0d91938765.png", "/staff-app/assets/assets/brand/drunkencoo-hero.65c21c4da9e466cf4bffc969639a1427.png", "/staff-app/assets/assets/brand/drunkencoo.f6d92af3b14e4205a3deaf4434754c51.png", "/staff-app/assets/assets/brand/greenside-hero.1caec5a6cb939434cccb5f3a613b50f8.png", "/staff-app/assets/assets/brand/greenside.9d1556db97dcb903a3c57e2063ee2255.png", "/staff-app/assets/assets/brand/kirkmichael-hero.63b13cde7fd82eb622622b39ac80c394.png", "/staff-app/assets/assets/brand/kirkmichael.63b13cde7fd82eb622622b39ac80c394.png", "/staff-app/assets/assets/brand/kirkton-hero.9d0837b292c2f4f30f4521d806bb28c3.png", "/staff-app/assets/assets/brand/kirkton.bcf8d846df4861474d224a7a77f498fb.png", "/staff-app/assets/assets/brand/mrbasrais-hero.4ce74641cfcf52d099157c84005b9d2a.png", "/staff-app/assets/assets/brand/mrbasrais.7cc4086dd12ace82529795f1c9f8c900.png", "/staff-app/assets/assets/brand/pizzaioli-hero.1896657c08264cefb49b401891d5448d.png", "/staff-app/assets/assets/brand/pizzaioli.db8c000b62ee407121aa8b90ce45e170.png", "/staff-app/assets/assets/brand/rupeeroom-hero.969fa372add526aaacf3a6c009b8ac92.png", "/staff-app/assets/assets/brand/rupeeroom.689e6fb536dc0845eeb174a1ec7bd346.png", "/staff-app/assets/assets/brand/saltmarsh.85a6a65732635e5148478d743d9ca884.png", "/staff-app/assets/assets/brand/smokinggoat-hero.0588f17ef0eed7f757f22916cd4d37db.png", "/staff-app/assets/assets/brand/smokinggoat.20a3a1970596ab43c5d6468d4ed549a7.png", "/staff-app/assets/assets/brand/souters.f4c58d9349b6e1700fe5abcc9e9b665c.png", "/staff-app/assets/assets/brand/wildings-hero-logo-text.4661e4b935726f2511f9c17a1567c89a.png", "/staff-app/assets/assets/brand/wildings.076f4fcd06d19a0af0205c410f461b14.png", "/staff-app/assets/assets/brand/williewastles-hero.b9d53d27b66f903b5618a7177b2ffad4.png", "/staff-app/assets/assets/brand/williewastles.055a77893ced99bf3a6c5402ba5baac6.png", "/staff-app/assets/assets/brand/yasmins-hero.a5aef62e37dfcecbe0afc056186f4ad9.png", "/staff-app/assets/assets/brand/yasmins.8482602e9f0a965655924835625cb02b.png", "/staff-app/assets/assets/recipes/fishsupper.1609c58319e1e8721f5c639049fb054e.jpg", "/staff-app/assets/assets/recipes/lobster.2fb3485c8e372972099259017358c1b8.jpg", "/staff-app/assets/assets/recipes/moules.a4f342fc7e7fb62c8a0b5c1678bbea3f.jpg", "/staff-app/assets/assets/recipes/skink.4ce7b7c676f9cdcd0a060eda46f5a00e.jpg", "/staff-app/assets/assets/recipes/stp.1061ced765efdcafff2554adc3fc7113.jpg", "/staff-app/assets/assets/specials/sample-chalkboard.e7b4e4450a8483d4219bc6a214158d8f.jpg", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/400Regular/Poppins_400Regular.093ee89be9ede30383f39a899c485a82.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/500Medium/Poppins_500Medium.bf59c687bc6d3a70204d3944082c5cc0.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/600SemiBold/Poppins_600SemiBold.6f1520d107205975713ba09df778f93f.ttf", "/staff-app/assets/node_modules/@expo-google-fonts/poppins/700Bold/Poppins_700Bold.08c20a487911694291bd8c5de41315ad.ttf", "/staff-app/assets/node_modules/expo-router/assets/arrow_down.017bc6ba3fc25503e5eb5e53826d48a8.png", "/staff-app/assets/node_modules/expo-router/assets/error.d1ea1496f9057eb392d5bbf3732a61b7.png", "/staff-app/assets/node_modules/expo-router/assets/file.19eeb73b9593a38f8e9f418337fc7d10.png", "/staff-app/assets/node_modules/expo-router/assets/forward.d8b800c443b8972542883e0b9de2bdc6.png", "/staff-app/assets/node_modules/expo-router/assets/pkg.ab19f4cbc543357183a20571f68380a3.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon-mask.0a328cd9c1afd0afe8e3b1ec5165b1b4.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/back-icon.35ba0eaec5a4f5ed12ca16fabeae451d.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/clear-icon.c94f6478e7ae0cdd9f15de1fcb9e5e55@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@2x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@3x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/close-icon.808e1b1b9b53114ec2838071a7e6daa7@4x.png", "/staff-app/assets/node_modules/expo-router/assets/react-navigation/elements/search-icon.286d67d3f74808a60a78d3ebf1a5fb57.png", "/staff-app/assets/node_modules/expo-router/assets/sitemap.412dd9275b6b48ad28f5e3d81bb1f626.png", "/staff-app/assets/node_modules/expo-router/assets/unmatched.20e71bdf79e3a97bf55fd9e164041578.png", "/staff-app/brand-logo.png", "/staff-app/favicon.ico", "/staff-app/icon-192.png", "/staff-app/icon-512.png", "/staff-app/icon-maskable-192.png", "/staff-app/icon-maskable-512.png", "/staff-app/manifest.webmanifest", "/staff-app/index.html", "/staff-app/_expo/static/js/web/bundle.js?v=a7d97422beb60e29a89b3fccb3ed7d2d8ed27f401795c3ac5a6bf324014938ef"]; // Hugging Face serves large files (fonts) through a redirect to its CDN. Browsers refuse to hand a *redirected* cached // response to a page, so store a plain copy instead (otherwise fonts, and so the app, fail to load offline). const plain = r => r.redirected ? r.blob().then(b => new Response(b, { status: 200, headers: { 'Content-Type': r.headers.get('Content-Type') || b.type || 'application/octet-stream' } })) : Promise.resolve(r); diff --git a/staff-app/team.html b/staff-app/team.html index 2d57397aa6e2f1bd4b33d1740ec26508cba62a1a..6c80b6bbc6131a7ee2bfca8ca13b28e83c7189ad 100644 --- a/staff-app/team.html +++ b/staff-app/team.html @@ -96,5 +96,5 @@ function ccWatch(r){if(r.waiting&&navigator.serviceWorker.controller)ccShowUpdat }, 1000); })(); - +